Documentation ¶
Index ¶
- func JSONFrom(v interface{}) io.WriterTo
- func JSONTo(v interface{}) io.ReaderFrom
- type All
- type Any
- type Archive
- type Archives
- type Body
- type Client
- type Database
- type Databases
- type Document
- type DocumentOption
- type FieldDef
- type FieldProps
- type FieldType
- type FieldVal
- type File
- type HTTPMethod
- type ID
- type IDAndNamer
- type IDAndNamerFilter
- type ImportDocument
- type ImportField
- type ImportFile
- type License
- type Name
- type Operator
- type Prompt
- type RWClient
- type ReaderBody
- type RequestOption
- func ContentType(t string) RequestOption
- func Method(m HTTPMethod) RequestOption
- func Path(segments ...interface{}) RequestOption
- func RequestBody(wt io.WriterTo) RequestOption
- func ResponseBody(rf io.ReaderFrom) RequestOption
- func SecureID(hash string) RequestOption
- func Value(k string, vs ...interface{}) RequestOption
- type Results
- type Search
- type SearchCriterion
- type Session
- func (s *Session) Archives(ctx context.Context, d *Database, f IDAndNamerFilter) (ars []Archive, err error)
- func (s *Session) Close() error
- func (s *Session) Databases(ctx context.Context, f IDAndNamerFilter) (ds []Database, err error)
- func (s *Session) DeleteDocument(ctx context.Context, d *Database, a *Archive, doc *Document) error
- func (s *Session) Document(ctx context.Context, d *Database, a *Archive, doc *Document, o DocumentOption, ...) error
- func (s *Session) Fields(ctx context.Context, d *Database, a *Archive, f IDAndNamerFilter) (fds []FieldDef, err error)
- func (s *Session) Import(ctx context.Context, d *Database, a *Archive, ifs []ImportField, ...) (Err error)
- func (s *Session) Search(ctx context.Context, d *Database, a *Archive, sr *Search, fs []SearchCriterion, ...) error
- func (s *Session) Searches(ctx context.Context, d *Database, a *Archive, f IDAndNamerFilter) (srs []Search, err error)
- func (s *Session) Session(ctx context.Context, f func(context.Context, *Session) error) error
- type SessionOption
- type SessionPool
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func JSONTo ¶
func JSONTo(v interface{}) io.ReaderFrom
JSONBodyTo returns a WriteCloser that when closed will unmarshal the content into the target.
Types ¶
type All ¶
type All []IDAndNamerFilter
All is an IDAndNamerFilter that requires all its inner filters evaluate to true.
func (All) Filter ¶
func (a All) Filter(ian IDAndNamer) bool
Filter implements the IDAndNamerFilter interface.
type Any ¶
type Any []IDAndNamerFilter
Any requires only one of its inner filters to evaluate to true
func (Any) Filter ¶
func (a Any) Filter(ian IDAndNamer) bool
Filter implements the IDAndNamerFilter interface.
type Archive ¶
type Archive struct { ArchiveID int64 `json:"Id"` ArchiveName string `json:"Name"` Parent int64 `json:"Parent"` Permissions int64 `json:"Permissions"` Properties int64 `json:"Properties"` }
Archive in Square 9
func (*Archive) PathSegments ¶
PathSegments is used by Request to know how to insert this object int64o a URL.
type Archives ¶
type Archives struct {
Archives []Archive `json:"Archives"`
}
Archives is a useless outer wrapper around the response that comes from getting a list of archives from Square 9
type Body ¶
type Body interface { // WriteTo the *http.Request's body before sending to the server WriteTo(w io.Writer) (n int64, err error) // ReadFrom the *http.Response back from the server. ReadFrom(r io.Reader) (n int64, err error) }
Body is the body of a request or response.
type Client ¶
type Client interface { // Close the client and release the license(s) it's consuming. Close() error // Session gets a session from the client and passes it into function f // as a parameter. Neither the session nor any intermediate API // objects may be stored outside of f's scope (e.g. via closure). // // Many API objects are bound to a single session. Calling Session // does not guarantee (or even try) to give you the same session, so // you should do all of your work that you want to do with the session // while you have it and only return the final result. Session(context.Context, func(context.Context, *Session) error) error }
Client interacts with the Square 9 REST API.
type Database ¶
Database defines a Square 9 database
func (*Database) PathSegments ¶
PathSegments is used by Request to know how to insert this object int64o a URL.
type Databases ¶
type Databases struct {
Databases []Database `json:"Databases"`
}
Databases is a useless outer wrapper around the response that comes from getting a list of databases from Square 9
type Document ¶
type Document struct { DocumentID int64 `json:"Id"` Hash string TID int64 Fields []FieldVal Version int64 RootVersionID int64 Username string `json:"User_Name"` Hits int64 Permissions uint64 RevisionOptions int64 FileType string }
Document as returned by search results
func (*Document) PathSegments ¶
type DocumentOption ¶
type DocumentOption string
DocumentOption is included in the call to Client.Document to specify the requested format of the document.
const ( // FileOption Returns the requested file FileOption DocumentOption = "File" // EmailOption Returns a ready-to-email version of the document EmailOption DocumentOption = "Email" // Print64Option Returns a ready-to-print64 version of the document Print64Option DocumentOption = "Print64" // ThumbOption Returns a thumbnail of the document ThumbOption DocumentOption = "Thumb" // ZoneOption ---data missing--- ZoneOption DocumentOption = "Zone" )
type FieldDef ¶
type FieldDef struct { FieldID int64 `json:"ID"` FieldName string `json:"Name"` List int64 Type FieldType Mask string Size int64 RegEx string Prop FieldProps Parent int64 ListF1 int64 ListF2 int64 }
FieldDef is the definition of an Archive field.
type FieldProps ¶
type FieldProps uint64
FieldProps is a bit mask describing the properties of fields.
const ( // Required indicates that the field is required Required FieldProps = 2 // SystemFieldDateEntered indicates that the field is a system field // storing the date that the document was stored. SystemFieldDateEntered FieldProps = 4 // System Field: Date Entered // SystemFieldIndexedBy indicates that the field stores the username // of the person who indexed the document SystemFieldIndexedBy FieldProps = 8 // System Field: Indexed By // SystemFieldPageCount stores the page count of the document SystemFieldPageCount FieldProps = 16 // System Field: Page Count // MultiValueField indicates that the field accepts more than one // value MultiValueField FieldProps = 32 // Multi-Value Field // FieldContainsDropdownList indicates that the field has a static // drop-down list FieldContainsDropdownList FieldProps = 64 // Field contains drop-down list // FieldContainsDynamicList indicates that the field has a dynamic // drop-down list. FieldContainsDynamicList FieldProps = 128 // Field contains dynamic list // SystemFieldLastModifiedBy indicates that the field holds the name // of the user that last modified the document. SystemFieldLastModifiedBy FieldProps = 256 // System Field: Last Modified By // TableField indicates that the field is a member of a table. TableField FieldProps = 512 // Table Field // SystemFieldFileType holds the file type of the document SystemFieldFileType FieldProps = 1024 // System Field: File Type // SystemFieldReadOnly indicates that the field is read-only. SystemFieldReadOnly FieldProps = 2048 // System Field: Read-only )
type FieldType ¶
type FieldType int64
FieldType indicates the data type of the field.
const ( // InvalidFieldType indicates an invalid field type InvalidFieldType FieldType = 0 // Invalid // CharacterField indicates that the field stores character data CharacterField FieldType = 1 // Character // IntegerField indicates that the field stores int64eger data IntegerField FieldType = 2 // Integer // DateTimeField indicates that the field stores date or date/time // data DateTimeField FieldType = 3 // DateTime // DecimalField indicates that the field stores decimal data DecimalField FieldType = 4 // Decimal )
type FieldVal ¶
type FieldVal struct { FieldID int64 `json:"ID"` Value string `json:"VAL"` MultiValue []interface{} `json:"MVAL"` }
FieldVal is a field value within a Document.
type File ¶
type File struct { Name string `json:"name"` IsEmail bool `json:"isEmail"` EmailData interface{} `json:"oEmailData"` Test interface{} `json:"test"` }
File is a temporary file created by posting an upload to the "WebPortalCache"
type HTTPMethod ¶
type HTTPMethod string
HTTPMethod is a type-safe HTTP method
const ( // DELETE HTTP method DELETE HTTPMethod = http.MethodDelete // GET HTTP method GET HTTPMethod = http.MethodGet // POST HTTP method POST HTTPMethod = http.MethodPost )
type ID ¶
type ID int64
ID of a Square 9 metadata object
func (ID) Filter ¶
func (f ID) Filter(ian IDAndNamer) bool
Filter implements the IDAndNamerFilter interface.
type IDAndNamer ¶
IDAndNamer is implemented by most metadata objects in the Square 9 API. It lets some functionality in this wrapping API work "genericaly."
type IDAndNamerFilter ¶
type IDAndNamerFilter interface {
Filter(ian IDAndNamer) bool
}
IDAndNamerFilter provides a predicate for IDAndNamers so they can be filtered
type ImportDocument ¶
type ImportDocument struct { Fields []ImportField `json:"fields"` Files []ImportFile `json:"files"` }
ImportDocument is a completely different layout from the Update layout to import a document that has already been uploaded to the cache.
type ImportField ¶
ImportField is a completely different layout from FieldVal that's used when importing a new document.
type ImportFile ¶
type ImportFile struct {
Name string `json:"name"`
}
ImportFile is used in ImportDocument to specify one or more files uploaded to the WebPortalCache.
type License ¶
type License struct { Username string `json:"Username"` Domain string `json:"Domain"` AuthServer string `json:"AuthServer"` Type int64 `json:"Type"` IPAddress string `json:"IPAddress"` DateCreated time.Time `json:"DateCreated"` DateAccessed time.Time `json:"DateAccessed"` Token uuid.UUID `json:"Token"` Reg int64 `json:"Reg"` }
License is returned when requesting a license from Square 9
type Name ¶
type Name string
Name of a Square 9 metadata object
func (Name) Filter ¶
func (f Name) Filter(ian IDAndNamer) bool
Filter implements the IDAndNamerFilter interface.
type Prompt ¶
type Prompt struct { PromptID int64 `json:"ID"` FieldID int64 `json:"FID"` ListID int64 Parent int64 Operator Operator Prompt string Value string `json:"VAL"` Prop int64 }
Prompt is a single prompt in a Search.
type RWClient ¶
type RWClient struct {
// contains filtered or unexported fields
}
RWClient maintains two client implementations: one for read-only access and another for read-write access. By default, when implementing the Client interface, the full-access implementation is used.
func NewRWClient ¶
NewRWClient implements the Client interface by choosing between a read-only implementation or a read-write implementation. By default, when the RWClient implements Client directly, it uses the full access client. This can be changed with the defaultReadOnly parameter here.
func (*RWClient) FullAccess ¶
FullAccess gets the FullAccess client explicitly to implement the Client interface.
type ReaderBody ¶
ReaderBody implements io.WriterTo by copying to the reader.
type RequestOption ¶
type RequestOption func(r *request) error
RequestOption configures a Square 9 request.
func ContentType ¶
func ContentType(t string) RequestOption
ContentType sets the content type of the request
func Method ¶
func Method(m HTTPMethod) RequestOption
Method defines the HTTPMethod to use for a Request.
func RequestBody ¶
func RequestBody(wt io.WriterTo) RequestOption
RequestBody specifies the Body to use for the request
func ResponseBody ¶
func ResponseBody(rf io.ReaderFrom) RequestOption
ResponseBody specifies the Body to use for the response
func SecureID ¶
func SecureID(hash string) RequestOption
SecureID configures the SecureID to use with this request. It usually comes from a "Hash" or "SecureId" field of a previously-requested object.
func Value ¶
func Value(k string, vs ...interface{}) RequestOption
Value adds a Value (either part of the Query string or POST values, depending on the Method) to the request.
type Search ¶
type Search struct { Archives []Archive SearchID int64 `json:"Id"` SearchName string `json:"Name"` Parent int64 Hash string Detail []Prompt Props int64 Fuzzy int64 Grouping string Settings int64 }
Search in a Database.
func (*Search) PathSegments ¶
PathSegments is used by Request to know how to insert this object int64o a URL.
type SearchCriterion ¶
type SearchCriterion struct { // Prompt ID or text for the search criterion. Prompt IDAndNamerFilter // Value to use for the search. Value interface{} }
SearchCriterion is a single search parameter
type Session ¶
type Session struct {
// contains filtered or unexported fields
}
Session is an implementation of the Client interface for a single user.
func NewSession ¶
func NewSession(ctx context.Context, options ...SessionOption) (*Session, error)
NewSession creates a new Square 9 session.
func (*Session) Archives ¶
func (s *Session) Archives(ctx context.Context, d *Database, f IDAndNamerFilter) (ars []Archive, err error)
Archives gets the archives in the database matching the filter.
func (*Session) DeleteDocument ¶
DeleteDocument deletes a document.
func (*Session) Document ¶
func (s *Session) Document(ctx context.Context, d *Database, a *Archive, doc *Document, o DocumentOption, rf io.ReaderFrom) error
Document retrieves document data associated with the given document. This document must have been returned from a previous call to Search with the same session or else it will fail.
func (*Session) Fields ¶
func (s *Session) Fields(ctx context.Context, d *Database, a *Archive, f IDAndNamerFilter) (fds []FieldDef, err error)
Fields gets all the fields in an Archive matching the filter. The filter can be nil to get all fields.
func (*Session) Import ¶
func (s *Session) Import(ctx context.Context, d *Database, a *Archive, ifs []ImportField, wts ...io.WriterTo) (Err error)
Import one or more files to an archive with the given fields.
func (*Session) Search ¶
func (s *Session) Search(ctx context.Context, d *Database, a *Archive, sr *Search, fs []SearchCriterion, rs *Results, options ...RequestOption) error
Search executes a search
type SessionOption ¶
SessionOption configures a session
func APIURL ¶
func APIURL(u *url.URL) SessionOption
APIURL specifies the base URL of the Square 9 REST API.
func APIURLString ¶
func APIURLString(u string) SessionOption
APIURLString configures the API URL with a string.
func BasicAuth ¶
func BasicAuth(username, password string) SessionOption
BasicAuth configures a session to use basic authentication
func HTTPClient ¶
func HTTPClient(h *http.Client) SessionOption
HTTPClient configures the HTTP client that a Session should use.
type SessionPool ¶
type SessionPool struct {
// contains filtered or unexported fields
}
SessionPool is a pool of individual sessions. Sessions are not safe for concurrent use but SessionPools are.
Implementation notes:
The implementation is too complicated but I don't yet know what to do about it. I'm open to suggestions!
The sessions field is initialized with a capacity equal to the limit value passed to NewSessionPool. The limit field also gets this capacity. No sessions are created initialy; not until the first call to Session is made. There, we try to get from the sessions channel (and fail the first time) so we create a new session. If using the session succeeds, it is put into the channel so a future attempt through the "fast path" (receive from the sessions channel) succeeds. If usage of the session returns an error
func NewSessionPool ¶
NewSessionPool creates a pool of clients.
func (*SessionPool) Close ¶
func (p *SessionPool) Close() error
Close the pool by waiting for and closing all the sessions from the pool.