Documentation ¶
Index ¶
- Variables
- type Client
- func (w *Client) Close()
- func (w *Client) Collection(identifier string) (*Collection, error)
- func (w *Client) CreateCollection(name string, opts ...CreateOption) (*Collection, error)
- func (w *Client) Item(in string) (*Item, error)
- func (w *Client) Link(in string) (*Link, error)
- func (w *Client) Resource(in string) (*Resource, error)
- func (w *Client) Search(opts ...SearchParam) *Search
- func (w *Client) Version(in string) (*Version, error)
- type ClientOption
- type Collection
- func (c *Collection) Collections(opts ...SearchParam) ([]*Collection, error)
- func (c *Collection) CreateCollection(name string, opts ...CreateOption) (*Collection, error)
- func (c *Collection) CreateItem(itemtype, variant string, opts ...CreateOption) (*Item, error)
- func (c *Collection) Delete() error
- func (i *Collection) Facet(key string) (string, bool)
- func (i *Collection) Facets() map[string]string
- func (c *Collection) Id() string
- func (c *Collection) Items(opts ...SearchParam) ([]*Item, error)
- func (c *Collection) Name() string
- func (c *Collection) Parent() (*Collection, error)
- func (c *Collection) ParentId() string
- func (i *Collection) SetFacets(in map[string]string) error
- func (c *Collection) Uri() string
- type CreateOption
- type Item
- func (i *Item) CreateVersion(opts ...CreateOption) (*Version, error)
- func (i *Item) Delete() error
- func (i *Item) Facet(key string) (string, bool)
- func (i *Item) Facets() map[string]string
- func (i *Item) Id() string
- func (i *Item) LinkTo(name string, other *Item, opts ...CreateOption) (*Link, error)
- func (i *Item) Linked(opts ...SearchParam) (map[string][]*Item, error)
- func (i *Item) Parent() (*Collection, error)
- func (i *Item) ParentId() string
- func (i *Item) PublishedVersion() (*Version, error)
- func (i *Item) SetFacets(in map[string]string) error
- func (i *Item) Type() string
- func (i *Item) Uri() string
- func (i *Item) Variant() string
- type Link
- type Resource
- func (i *Resource) Delete() error
- func (i *Resource) Facet(key string) (string, bool)
- func (i *Resource) Facets() map[string]string
- func (i *Resource) Id() string
- func (i *Resource) Location() string
- func (i *Resource) Name() string
- func (i *Resource) Parent() (*Version, error)
- func (i *Resource) ParentId() string
- func (i *Resource) SetFacets(in map[string]string) error
- func (i *Resource) Type() string
- func (i *Resource) Uri() string
- type Search
- func (i *Search) FindCollections(opts ...SearchOption) ([]*Collection, error)
- func (i *Search) FindItems(opts ...SearchOption) ([]*Item, error)
- func (i *Search) FindLinks(opts ...SearchOption) ([]*Link, error)
- func (i *Search) FindResources(opts ...SearchOption) ([]*Resource, error)
- func (i *Search) FindVersions(opts ...SearchOption) ([]*Version, error)
- func (i *Search) Or(opts ...SearchParam) *Search
- type SearchOption
- type SearchParam
- func ChildOf(s string) SearchParam
- func HasFacets(f map[string]string) SearchParam
- func Id(s string) SearchParam
- func ItemType(s string) SearchParam
- func ItemVariant(s string) SearchParam
- func LinkDestination(s string) SearchParam
- func LinkSource(s string) SearchParam
- func Name(s string) SearchParam
- func ResourceLocation(s string) SearchParam
- func ResourceType(s string) SearchParam
- func Uri(s string) SearchParam
- func VersionNumber(n int32) SearchParam
- type Version
- func (i *Version) AddResource(name, rtype, location string, opts ...CreateOption) (*Resource, error)
- func (i *Version) Delete() error
- func (i *Version) Facet(key string) (string, bool)
- func (i *Version) Facets() map[string]string
- func (i *Version) Id() string
- func (i *Version) LinkTo(name string, other *Version, opts ...CreateOption) (*Link, error)
- func (i *Version) Linked(opts ...SearchParam) (map[string][]*Version, error)
- func (i *Version) Parent() (*Item, error)
- func (i *Version) ParentId() string
- func (i *Version) Publish() error
- func (i *Version) Resources(opts ...SearchParam) ([]*Resource, error)
- func (i *Version) SetFacets(in map[string]string) error
- func (i *Version) Uri() string
- func (i *Version) Version() int32
Constants ¶
This section is empty.
Variables ¶
var ( // These are copied over from github.com/voidshard/wysteria/common for convenience // FacetRootCollection = wyc.FacetRootCollection FacetCollection = wyc.FacetCollection FacetItemType = wyc.FacetItemType FacetItemVariant = wyc.FacetItemVariant FacetLinkType = wyc.FacetLinkType FacetVersionLink = wyc.ValueLinkTypeVersion FacetItemLink = wyc.ValueLinkTypeItem )
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client wraps the desired middleware and supplies a more user friendly interface to users
func New ¶
func New(opts ...ClientOption) (*Client, error)
Create a new client and connect to the server
func (*Client) Collection ¶
func (w *Client) Collection(identifier string) (*Collection, error)
Collection is a helpful wrapper that looks for a single collection with either the name or Id of the given 'identifier' and returns it if found. Nb. This will error if more than one potential match is found (if two collections with the same name under different parents are returned).
func (*Client) CreateCollection ¶
func (w *Client) CreateCollection(name string, opts ...CreateOption) (*Collection, error)
Create a new collection & return it (that is, a collection with no parent)
- The collection name is required to be unique among all collections
func (*Client) Item ¶
Item is a helpful wrapper that looks up an Item by ID or URI and returns it (if found).
func (*Client) Link ¶
Link is a helpful wrapper that looks up an Link by ID or URI and returns it (if found).
func (*Client) Resource ¶
Resource is a helpful wrapper that looks up an Resource by ID or URI and returns it (if found).
func (*Client) Search ¶
func (w *Client) Search(opts ...SearchParam) *Search
Start a new search request.
This builds up a query (or set of queries) clientside to send to the server. 'Find<ObjectType>' functions send this query(ies) and request matching objects of the given <ObjectType>. Since network round trip time is invariably expensive, it's recommended to make few specific queries than many non specific.
type ClientOption ¶
type ClientOption func(*Client)
func Driver ¶
func Driver(name string) ClientOption
Set a particular driver for the client to connect with (overrides config var). (See example config for details & examples).
func Host ¶
func Host(url string) ClientOption
Set a particular host for the client to connect to (overrides config var). The exact format of this depends on the middleware driver being used. (See example config for details & examples).
func SSLVerify ¶
func SSLVerify(in bool) ClientOption
Verify SSL certificates on connecting
That is, if this is 'false' we'll accept insecure certificates (like self signed certs for example)
type Collection ¶
type Collection struct {
// contains filtered or unexported fields
}
Wrapper class for wysteria/common Collection
func (*Collection) Collections ¶
func (c *Collection) Collections(opts ...SearchParam) ([]*Collection, error)
Get all Collection objects that name this collection as "parent"
func (*Collection) CreateCollection ¶
func (c *Collection) CreateCollection(name string, opts ...CreateOption) (*Collection, error)
Create a child collection of this collection
func (*Collection) CreateItem ¶
func (c *Collection) CreateItem(itemtype, variant string, opts ...CreateOption) (*Item, error)
Create a new Item with the given fields & return it.
- The item type & variant fields must be unique within a given collection.
- The reserved facet FacetCollection is set as a facet automatically.
func (*Collection) Delete ¶
func (c *Collection) Delete() error
Delete this collection. Warning: Any & all child Items and their children will be deleted too.
func (*Collection) Facet ¶
func (i *Collection) Facet(key string) (string, bool)
Get the facet value and a bool indicating if the value exists for the given key.
func (*Collection) Items ¶
func (c *Collection) Items(opts ...SearchParam) ([]*Item, error)
Get all Item objects that name this collection as "parent"
func (*Collection) Parent ¶
func (c *Collection) Parent() (*Collection, error)
Return the parent collection of this collection (if any)
func (*Collection) ParentId ¶
func (c *Collection) ParentId() string
Return the Id of this collection's parent (if any)
type CreateOption ¶
type CreateOption func(clientStruct, clientStruct) // func(parent, child)
Definition of an option that can be passed in a Create function call.
func Facets ¶
func Facets(in map[string]string) CreateOption
Set the initial Facets on the soon to be created child
Note that you still cannot overwrite client reserved facets this way
type Item ¶
type Item struct {
// contains filtered or unexported fields
}
Wrapper around wysteria/common Item object
func (*Item) CreateVersion ¶
func (i *Item) CreateVersion(opts ...CreateOption) (*Version, error)
Create the next child version of this item, with the given facets (if any). That is,
- create a version whose parent is this item's id
- set the reserved Facets for Collection, ItemType and ItemVariant accordingly
- the server will allocate us a Version number
func (*Item) Delete ¶
Delete this Item. Note all child Versions & their children will be deleted too.
func (*Item) Facet ¶
Get the facet value and a bool indicating if the value exists for the given key.
func (*Item) Linked ¶
func (i *Item) Linked(opts ...SearchParam) (map[string][]*Item, error)
Find and return all linked items for which links exist that name this as the source. That is, this first finds all links for which the source Id is this Item's Id, then gets all matching Items. Since this would cause us to lose the link 'name' we return a map of link name -> []*Item
func (*Item) Parent ¶
func (i *Item) Parent() (*Collection, error)
Lookup and return the parent Collection of this Item
func (*Item) PublishedVersion ¶
Get which ever Version object is considered the "published" version of this Item
Note that this may not be the latest, or even be set, even if child versions exist.
type Link ¶
type Link struct {
// contains filtered or unexported fields
}
Wrapper around wysteria/common Link object
func (*Link) DestinationId ¶
Return the Id of the object (either a Version or Item) that is considered the "destination" of this link.
func (*Link) Facet ¶
Get the facet value and a bool indicating if the value exists for the given key.
type Resource ¶
type Resource struct {
// contains filtered or unexported fields
}
Wrapper around wysteria/common Resource obj
func (*Resource) Facet ¶
Get the facet value and a bool indicating if the value exists for the given key.
type Search ¶
type Search struct {
// contains filtered or unexported fields
}
Search obj represents a query or set of queries that are about to be sent to the server
func (*Search) FindCollections ¶
func (i *Search) FindCollections(opts ...SearchOption) ([]*Collection, error)
Find all matching Collections given our search params
func (*Search) FindItems ¶
func (i *Search) FindItems(opts ...SearchOption) ([]*Item, error)
Find all matching Items given our search params
func (*Search) FindLinks ¶
func (i *Search) FindLinks(opts ...SearchOption) ([]*Link, error)
Find all matching Links given our search params
func (*Search) FindResources ¶
func (i *Search) FindResources(opts ...SearchOption) ([]*Resource, error)
Find all matching Resources given our search params
func (*Search) FindVersions ¶
func (i *Search) FindVersions(opts ...SearchOption) ([]*Version, error)
Find all matching Versions given our search params
func (*Search) Or ¶
func (i *Search) Or(opts ...SearchParam) *Search
All of the search params before this are considered "AND" (to the Search obj or the last "Or"), this adds a new sub query to find another object based on more params.
type SearchOption ¶
type SearchOption func(*Search)
type SearchParam ¶
type SearchParam func(*Search)
func ChildOf ¶
func ChildOf(s string) SearchParam
Search for something whose parent has the given Id
func HasFacets ¶
func HasFacets(f map[string]string) SearchParam
Search for something that has all of the given facets
func LinkDestination ¶
func LinkDestination(s string) SearchParam
Search for a link whose destination is the given Id
func LinkSource ¶
func LinkSource(s string) SearchParam
Search for a link whose source is the given Id
func Name ¶
func Name(s string) SearchParam
Search for something with a name matching the given name
func ResourceLocation ¶
func ResourceLocation(s string) SearchParam
Search for a resource with the given location
func ResourceType ¶
func ResourceType(s string) SearchParam
Search for a resource with the given ResourceType
func VersionNumber ¶
func VersionNumber(n int32) SearchParam
Search for a version with the given version number
type Version ¶
type Version struct {
// contains filtered or unexported fields
}
Wrapper around wysteria/common Version object
func (*Version) AddResource ¶
func (i *Version) AddResource(name, rtype, location string, opts ...CreateOption) (*Resource, error)
Add a resource with the given name, type and location to this version.
func (*Version) Facet ¶
Get the facet value and a bool indicating if the value exists for the given key.
func (*Version) Linked ¶
func (i *Version) Linked(opts ...SearchParam) (map[string][]*Version, error)
Find and return all linked Versions for which links exist that name this as the source. That is, this first finds all links for which the source Id is this Version's Id, then gets all matching Versions. Since this would cause us to lose the link 'name' we return a map of link name -> []*Version
func (*Version) Publish ¶
Mark this Version as the published version. An item can only have one 'published' version at a time.
func (*Version) Resources ¶
func (i *Version) Resources(opts ...SearchParam) ([]*Resource, error)
Retrieve all child resources of this Version with the given name & resource type