wysteria_client

package
v0.0.0-...-301923a Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 29, 2019 License: BSD-3-Clause Imports: 6 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

View Source
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) Close

func (w *Client) Close()

Close any open server connection(s)

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

func (w *Client) Item(in string) (*Item, error)

Item is a helpful wrapper that looks up an Item by ID or URI and returns it (if found).

func (w *Client) Link(in string) (*Link, error)

Link is a helpful wrapper that looks up an Link by ID or URI and returns it (if found).

func (*Client) Resource

func (w *Client) Resource(in string) (*Resource, error)

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.

func (*Client) Version

func (w *Client) Version(in string) (*Version, error)

Version is a helpful wrapper that looks up an Version by ID or URI and returns it (if found).

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 SSLCert

func SSLCert(in string) ClientOption

Set SSL certificate to use

func SSLEnable

func SSLEnable(in bool) ClientOption

Enable SSL

func SSLKey

func SSLKey(in string) ClientOption

Set SSL key to use

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) Facets

func (i *Collection) Facets() map[string]string

Get all facets

func (*Collection) Id

func (c *Collection) Id() string

Return the Id of this collection

func (*Collection) Items

func (c *Collection) Items(opts ...SearchParam) ([]*Item, error)

Get all Item objects that name this collection as "parent"

func (*Collection) Name

func (c *Collection) Name() string

Return the name of this collection

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)

func (*Collection) SetFacets

func (i *Collection) SetFacets(in map[string]string) error

Set all the key:value pairs given on this Collection's facets.

func (*Collection) Uri

func (c *Collection) Uri() string

Get the Uri for this Collection

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

func (i *Item) Delete() error

Delete this Item. Note all child Versions & their children will be deleted too.

func (*Item) Facet

func (i *Item) Facet(key string) (string, bool)

Get the facet value and a bool indicating if the value exists for the given key.

func (*Item) Facets

func (i *Item) Facets() map[string]string

Get all facets

func (*Item) Id

func (i *Item) Id() string

Get the Id for this Item

func (*Item) LinkTo

func (i *Item) LinkTo(name string, other *Item, opts ...CreateOption) (*Link, error)

Link this item with a link described by 'name' to some other item.

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) ParentId

func (i *Item) ParentId() string

Return the Id of the parent of this Item

func (*Item) PublishedVersion

func (i *Item) PublishedVersion() (*Version, error)

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.

func (*Item) SetFacets

func (i *Item) SetFacets(in map[string]string) error

Set all the key:value pairs given on this Item's facets. Note that the server will ignore the setting of reserved facets.

func (*Item) Type

func (i *Item) Type() string

Return the ItemType of this item

func (*Item) Uri

func (i *Item) Uri() string

Get the URI for this Item

func (*Item) Variant

func (i *Item) Variant() string

Return the variant string associated with this Item

type Link struct {
	// contains filtered or unexported fields
}

Wrapper around wysteria/common Link object

func (*Link) DestinationId

func (i *Link) DestinationId() string

Return the Id of the object (either a Version or Item) that is considered the "destination" of this link.

func (*Link) Facet

func (i *Link) Facet(key string) (string, bool)

Get the facet value and a bool indicating if the value exists for the given key.

func (*Link) Facets

func (i *Link) Facets() map[string]string

Get all facets

func (*Link) Id

func (i *Link) Id() string

Return the Id of this link

func (*Link) Name

func (i *Link) Name() string

Return the name of this link

func (*Link) SetFacets

func (i *Link) SetFacets(in map[string]string) error

Set all the key:value pairs given on this Link's facets.

func (*Link) SourceId

func (i *Link) SourceId() string

Return the Id of the object (either a Version or Item) that is considered the "source" of this link.

func (*Link) Uri

func (i *Link) Uri() string

Get the URI for this Resource

type Resource

type Resource struct {
	// contains filtered or unexported fields
}

Wrapper around wysteria/common Resource obj

func (*Resource) Delete

func (i *Resource) Delete() error

Delete this resource

func (*Resource) Facet

func (i *Resource) Facet(key string) (string, bool)

Get the facet value and a bool indicating if the value exists for the given key.

func (*Resource) Facets

func (i *Resource) Facets() map[string]string

Get all facets

func (*Resource) Id

func (i *Resource) Id() string

Return the Id of this resource

func (*Resource) Location

func (i *Resource) Location() string

Return the location string

func (*Resource) Name

func (i *Resource) Name() string

Return the name given for this resource

func (*Resource) Parent

func (i *Resource) Parent() (*Version, error)

Return the parent (Version) of this resource

func (*Resource) ParentId

func (i *Resource) ParentId() string

Return the Id of this resources' parent (the Id of a Version object)

func (*Resource) SetFacets

func (i *Resource) SetFacets(in map[string]string) error

Set all the key:value pairs given on this Resource's facets.

func (*Resource) Type

func (i *Resource) Type() string

Return the resource type for this resource

func (*Resource) Uri

func (i *Resource) Uri() string

Get the URI for this Resource

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 (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)

func Limit

func Limit(val int) SearchOption

Set limit on number of results

func Offset

func Offset(val int) SearchOption

Get results from the given offset.

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 Id

func Id(s string) SearchParam

Search for something with the given Id

func ItemType

func ItemType(s string) SearchParam

Search for an item with the given type

func ItemVariant

func ItemVariant(s string) SearchParam

Search for an item with the given variant

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 Uri

func Uri(s string) SearchParam

Search for something with the given Uri

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) Delete

func (i *Version) Delete() error

Delete this version, and any & all children

func (*Version) Facet

func (i *Version) Facet(key string) (string, bool)

Get the facet value and a bool indicating if the value exists for the given key.

func (*Version) Facets

func (i *Version) Facets() map[string]string

Get all facets

func (*Version) Id

func (i *Version) Id() string

Get this version's Id

func (*Version) LinkTo

func (i *Version) LinkTo(name string, other *Version, opts ...CreateOption) (*Link, error)

Link this Version with a link described by 'name' to some other Version.

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) Parent

func (i *Version) Parent() (*Item, error)

Get the parent Item of this Version

func (*Version) ParentId

func (i *Version) ParentId() string

Return the Id of this Version's parent

func (*Version) Publish

func (i *Version) Publish() error

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

func (*Version) SetFacets

func (i *Version) SetFacets(in map[string]string) error

Set all the key:value pairs given on this Item's facets. Note that the server will ignore the setting of reserved facets.

func (*Version) Uri

func (i *Version) Uri() string

Get the URI for this version

func (*Version) Version

func (i *Version) Version() int32

Return the version number associated with this version. Each version of a given item is numbered starting from 1

Directories

Path Synopsis
examples
01
02
03
04
05
06
07
08
09
10
11
12
13

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL