Documentation ¶
Index ¶
- func RegisterTypeMap(m TypeMap)
- type ApiClient
- type Authenticator
- type Client
- func (c *Client) Create(ptr IObject) error
- func (c *Client) Delete(ptr IObject) error
- func (c *Client) DeleteByUuid(typename, uuid string) error
- func (c *Client) FQNameByUuid(uuid string) ([]string, error)
- func (c *Client) FindByName(typename string, fqn string) (IObject, error)
- func (c *Client) FindByUuid(typename string, uuid string) (IObject, error)
- func (c *Client) GetField(obj IObject, field string) error
- func (c *Client) GetServer() string
- func (c *Client) List(typename string) ([]ListResult, error)
- func (c *Client) ListByParent(typename string, parentID string) ([]ListResult, error)
- func (c *Client) ListDetail(typename string, fields []string) ([]IObject, error)
- func (c *Client) ListDetailByParent(typename string, parentID string, fields []string) ([]IObject, error)
- func (c *Client) ReadListResult(typename string, result *ListResult) (IObject, error)
- func (c *Client) ReadReference(typename string, ref *Reference) (IObject, error)
- func (c *Client) SetAuthenticator(auth Authenticator)
- func (c *Client) Update(ptr IObject) error
- func (c *Client) UpdateReference(msg *ReferenceUpdateMsg) error
- func (c *Client) UuidByName(typename string, fqn string) (string, error)
- type IObject
- type KeystoneClient
- type KeystoneToken
- type LinkAttribute
- type ListResult
- type NopAuthenticator
- type ObjectBase
- func (obj *ObjectBase) GetFQName() []string
- func (obj *ObjectBase) GetField(ptr IObject, field string) error
- func (obj *ObjectBase) GetHref() string
- func (obj *ObjectBase) GetName() string
- func (obj *ObjectBase) GetParentType() string
- func (obj *ObjectBase) GetUuid() string
- func (obj *ObjectBase) IsTransient() bool
- func (obj *ObjectBase) MarshalCommon(m map[string]*json.RawMessage) error
- func (obj *ObjectBase) MarshalId(m map[string]*json.RawMessage) error
- func (obj *ObjectBase) SetClient(c objectInterface)
- func (obj *ObjectBase) SetFQName(parentType string, fqn []string)
- func (obj *ObjectBase) SetUuid(uuid string)
- func (obj *ObjectBase) UnmarshalCommon(m map[string]json.RawMessage) error
- func (obj *ObjectBase) UpdateReference(ptr IObject, field string, current, prev ReferenceList) error
- func (obj *ObjectBase) VSetName(vPtr IObject, name string)
- func (obj *ObjectBase) VSetParent(vPtr IObject, parent IObject)
- type Reference
- type ReferenceList
- type ReferencePair
- type ReferenceUpdateMsg
- type TypeMap
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func RegisterTypeMap ¶
func RegisterTypeMap(m TypeMap)
RegisterTypeMap is used by the generated types library to register the list of known object types.
Types ¶
type ApiClient ¶
type ApiClient interface { Create(ptr IObject) error Update(ptr IObject) error DeleteByUuid(typename, uuid string) error Delete(ptr IObject) error FindByUuid(typename string, uuid string) (IObject, error) UuidByName(typename string, fqn string) (string, error) FQNameByUuid(uuid string) ([]string, error) FindByName(typename string, fqn string) (IObject, error) List(typename string) ([]ListResult, error) ListByParent(typename string, parentID string) ([]ListResult, error) ListDetail(typename string, fields []string) ([]IObject, error) ListDetailByParent(typename string, parentID string, fields []string) ([]IObject, error) }
ApiClient interface
type Authenticator ¶
The Authenticator interface is used to add an autentication token on a per request basis. This is used by the Keystone authentication class to decorate the requests with a token.
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
A Client of the OpenContrail API server.
func (*Client) Create ¶
Create an object in the OpenContrail API server.
The object must have been initialized with a name.
func (*Client) DeleteByUuid ¶
DeleteByUuid deletes the specified object.
func (*Client) FQNameByUuid ¶
FQNameByUuid returns the fully-qualified name of an object as identified by a UUID.
func (*Client) FindByName ¶
FindByName reads an object identified by fully-qualified name represented as a string.
func (*Client) FindByUuid ¶
FindByUuid reads an object identified by UUID.
func (*Client) GetField ¶
GetField retrieves a specified field of an object from the API server. This API is used by the generated types library to retrieve reference lists.
func (*Client) List ¶
func (c *Client) List(typename string) ([]ListResult, error)
List retrieves the identifiers of all objects of a given type.
func (*Client) ListByParent ¶
func (c *Client) ListByParent( typename string, parentID string) ([]ListResult, error)
ListByParent retrieves the identifiers of the objects of a specific type that are descendents of a specific object.
func (*Client) ListDetail ¶
ListDetail reads all the objects of a specific type.
func (*Client) ListDetailByParent ¶
func (c *Client) ListDetailByParent( typename string, parentID string, fields []string) ( []IObject, error)
ListDetailByParent reads all the objects of a given type that are descendents of the specified parent object.
func (*Client) ReadListResult ¶
func (c *Client) ReadListResult( typename string, result *ListResult) (IObject, error)
Given a ListResult, retrieve an object from the API server.
func (*Client) ReadReference ¶
Given a link reference, retrieve an object from the API server.
func (*Client) SetAuthenticator ¶
func (c *Client) SetAuthenticator(auth Authenticator)
SetAuthenticator enables the user to configure an Authenticator (e.g. Keystone) to be used by Contrail API requests.
func (*Client) Update ¶
Update the API server with the changes made in the local representation of the object.
There is currently no mechanism to guarantee that the object as not been concurrently modified in the API server. Updates modify properties that have been marked as modified in the local representation.
func (*Client) UpdateReference ¶
func (c *Client) UpdateReference(msg *ReferenceUpdateMsg) error
UpdateReference sends a reference update message to the API server. Used by the generated types library.
type IObject ¶
type IObject interface { GetDefaultParent() []string GetDefaultParentType() string GetFQName() []string GetName() string GetType() string GetParentType() string GetUuid() string GetHref() string SetName(string) SetUuid(string) SetFQName(string, []string) SetClient(objectInterface) UpdateObject() ([]byte, error) UpdateReferences() error UpdateDone() }
IObject describes the interface implemented by auto-generated types.
type KeystoneClient ¶
type KeystoneClient struct {
// contains filtered or unexported fields
}
KeystoneClient is a client of the OpenStack Keystone service that adds authentication tokens to the Contrail API requests.
func NewKeystoneClient ¶
func NewKeystoneClient(auth_url, tenant_name, username, password, token string) *KeystoneClient
NewKeystoneClient allocates and initializes a KeystoneClient
func (*KeystoneClient) AddAuthentication ¶
func (kClient *KeystoneClient) AddAuthentication(req *http.Request) error
AddAuthentication adds the authentication data to the HTTP header.
func (*KeystoneClient) Authenticate ¶
func (kClient *KeystoneClient) Authenticate() error
Authenticate sends an authentication request to keystone.
type KeystoneToken ¶
type KeystoneToken struct { Id string Expires string Tenant struct { Id string Name string Description string Enabled bool } Issued_At string }
KeystoneToken represents an auth token issued by OpenStack keystone service. The field names are defined by the Keystone API schema.
type LinkAttribute ¶
type LinkAttribute interface { }
LinkAttribute is an attribute on a link between two objects.
type ListResult ¶
ListResult is the return type of the {List, ListByParent} API calls.
type NopAuthenticator ¶
type NopAuthenticator struct { }
NopAuthenticator is an authentication that doesn't modify the request.
func (*NopAuthenticator) AddAuthentication ¶
func (*NopAuthenticator) AddAuthentication(*http.Request) error
AddAuthentication implements the Authenticator interface for NopAuthenticator.
type ObjectBase ¶
type ObjectBase struct {
// contains filtered or unexported fields
}
ObjectBase is used as base class by the auto-generated types.
func (*ObjectBase) GetFQName ¶
func (obj *ObjectBase) GetFQName() []string
GetFQName is the accessor method for the fully qualified name.
func (*ObjectBase) GetField ¶
func (obj *ObjectBase) GetField(ptr IObject, field string) error
GetField is used to retrieve references. When an object is first read, children, forward and backward references are not fetched since these lists can be very large. This method explicitly retrieves a reference field. It is used implicitly when reading and/or modifying reference fields via the generated types library.
func (*ObjectBase) GetHref ¶
func (obj *ObjectBase) GetHref() string
GetHref is the accessor for href.
func (*ObjectBase) GetName ¶
func (obj *ObjectBase) GetName() string
GetName is the accessor method for object (unqualified) name
func (*ObjectBase) GetParentType ¶
func (obj *ObjectBase) GetParentType() string
GetParentType is the access method for the parent type.
func (*ObjectBase) GetUuid ¶
func (obj *ObjectBase) GetUuid() string
GetUuid is the accessor for object uuid.
func (*ObjectBase) IsTransient ¶
func (obj *ObjectBase) IsTransient() bool
IsTransient returns true if the object has been allocated locally but not yet created in the Contrail API. Objects read from the API server via Find or ListDetail APIs are not considered to be transient and can be updated or deleted.
func (*ObjectBase) MarshalCommon ¶
func (obj *ObjectBase) MarshalCommon(m map[string]*json.RawMessage) error
MarshalCommon encodes the information stored in the ObjectBase struct.
func (*ObjectBase) MarshalId ¶
func (obj *ObjectBase) MarshalId(m map[string]*json.RawMessage) error
MarshalId encodes fq_name and uuid.
func (*ObjectBase) SetClient ¶
func (obj *ObjectBase) SetClient(c objectInterface)
SetClient is used to mark an object as persistent (it has been created or read) from the API and supplying it with the methods required to perform an update.
func (*ObjectBase) SetFQName ¶
func (obj *ObjectBase) SetFQName(parentType string, fqn []string)
SetFQName sets the fully qualified domain name. This implies that the parent is being specified also.
func (*ObjectBase) SetUuid ¶
func (obj *ObjectBase) SetUuid(uuid string)
SetUuid set for object uuid on transient objects.
func (*ObjectBase) UnmarshalCommon ¶
func (obj *ObjectBase) UnmarshalCommon(m map[string]json.RawMessage) error
UnmarshalCommon is used to unmarshal the JSON data on ObjectBase.
func (*ObjectBase) UpdateReference ¶
func (obj *ObjectBase) UpdateReference( ptr IObject, field string, current, prev ReferenceList) error
UpdateReference is a helper function that compares two reference lists and generates the appropriate list of changes to be resented as POST requests to the ref-update URL on the API server.
func (*ObjectBase) VSetName ¶
func (obj *ObjectBase) VSetName(vPtr IObject, name string)
VSetName implements IObject.SetName methods.
The implementation must be able to access both the ObjectBase fields as well as the IObject interface in order to retrieve data specific to a given type.
func (*ObjectBase) VSetParent ¶
func (obj *ObjectBase) VSetParent(vPtr IObject, parent IObject)
VSetParent is used by the auto-generated types library to set the parent of an object that is being created.
type Reference ¶
type Reference struct { To []string `json:"to,omitempty"` Uuid string `json:"uuid,omitempty"` Href string `json:"href,omitempty"` Attr LinkAttribute `json:"attr,omitempty"` }
A Reference represents a link (and optional associated metadata) between two objects.
type ReferencePair ¶
type ReferencePair struct { Object IObject Attribute LinkAttribute }
A ReferencePair is the data used to add a reference.
type ReferenceUpdateMsg ¶
type ReferenceUpdateMsg struct { // object typename Type string `json:"type"` // object uuid Uuid string `json:"uuid"` // object field (without the trailing _refs and tr/_/-/) RefType string `json:"ref-type"` // reference uuid RefUuid string `json:"ref-uuid"` // reference fqn RefFQName []string `json:"ref-fq-name"` // ADD, DELETE Operation string `json:"operation"` // Attribute Attr LinkAttribute `json:"attr"` }
ReferenceUpdateMsg is the data type used by POST requests to http://server:port/ref-update
type TypeMap ¶
TypeMap is used to inject the auto-generated types library.
Types are generated from the OpenContrail schema and allow the library to operate in terms of go structs that contain fields that represent IF-MAP properties (metadata associated with a single Identifier) and arrays of references to other Identifiers (with optional metadata). Each auto-generated type implements the IObject interface.