go-bambou: github.com/nuagenetworks/go-bambou/bambou Index | Files

package bambou

import "github.com/nuagenetworks/go-bambou/bambou"

Package bambou provides the basic contructs used by ReST frameworks generated using Monolithe.

Bambou provides a set of objects that allow the manipulation of ReST entities very easily. It deals with all possible CRUD operations and defines all these low level operations in a single place.


Package Files

doc.go error.go fetchinginfo.go identity.go logger.go notification.go pushcenter.go session.go


var AllIdentity = Identity{
    Name:     "__all__",
    Category: "__all__",

AllIdentity represents all possible Identities.

func Logger Uses

func Logger() *logging.Logger

Logger returns the defaut Bambou logger.

type Error Uses

type Error struct {
    Title       string `json:"title"`
    Description string `json:"description"`

func NewBambouError Uses

func NewBambouError(title, description string) *Error

func NewError Uses

func NewError(code int, description string) *Error

func (*Error) Error Uses

func (be *Error) Error() string

Error returns the string representation of a Bambou Error (making it an "error") Valid JSON formatted

type Event Uses

type Event struct {
    DataMap         []map[string]interface{} `json:"entities"`
    Data            []byte                   `json:"-"`
    EntityType      string                   `json:"entityType"`
    Type            string                   `json:"type"`
    UpdateMechanism string                   `json:"updateMechanism"`

Event represents one item of a Notification. It will contain data from the server regarding the object that has been created, deleted, or modified.

type EventHandler Uses

type EventHandler func(*Event)

EventHandler is prototype of a Push Center Handler.

type EventsList Uses

type EventsList []*Event

EventsList represents a list of *Event.

type FetchingInfo Uses

type FetchingInfo struct {
    Filter     string
    FilterType string
    GroupBy    []string
    OrderBy    string
    Page       int
    PageSize   int
    TotalCount int

FetchingInfo is a structure that contains differents values about the fetching of children, either for the user to set, of for the server to fill. This structure will be used to pass and get back information during the fetching of some children.

func NewFetchingInfo Uses

func NewFetchingInfo() *FetchingInfo

NewFetchingInfo returns a new *FetchingInfo

func (*FetchingInfo) String Uses

func (f *FetchingInfo) String() string

String returns the string representation of the FetchingInfo.

type Identifiable Uses

type Identifiable interface {

    // Identity returns the Identity of the of the receiver.
    Identity() Identity

    // Identifier returns the unique identifier of the of the receiver.
    Identifier() string

    // SetIdentifier sets the unique identifier of the of the receiver.

Identifiable is the interface that object which have Identity must implement.

type IdentifiablesList Uses

type IdentifiablesList []Identifiable

IdentifiablesList is a list of objects implementing the Identifiable interface.

type Identity Uses

type Identity struct {
    Name     string
    Category string

Identity is a structure that contains the necessary information about an Identifiable. The Name is usually the singular form of the Category. For instance, "enterprise" and "enterprises".

func (Identity) String Uses

func (i Identity) String() string

String returns the string representation of the identity.

type Notification Uses

type Notification struct {
    Events EventsList `json:"events"`
    UUID   string     `json:"uuid"`

Notification represents a collection of Event structures. It also contains a identifier for the Notification.

func NewNotification Uses

func NewNotification() *Notification

NewNotification returns a new *Notification.

type NotificationsChannel Uses

type NotificationsChannel chan *Notification

NotificationsChannel is used to received notification from the session

type PushCenter Uses

type PushCenter struct {
    Channel NotificationsChannel
    // contains filtered or unexported fields

PushCenter is a structure that allows the user to deal with notifications. You can register multiple handlers for several Identity. When a notification is sent by the server and the Identity of its content matches one of the registered handler, this handler will be called.

func NewPushCenter Uses

func NewPushCenter(session *Session) *PushCenter

NewPushCenter creates a new PushCenter.

func (*PushCenter) HasHandlerForIdentity Uses

func (p *PushCenter) HasHandlerForIdentity(identity Identity) bool

HasHandlerForIdentity verifies if the given identity has a registered handler.

func (*PushCenter) RegisterHandlerForIdentity Uses

func (p *PushCenter) RegisterHandlerForIdentity(handler EventHandler, identity Identity)

RegisterHandlerForIdentity registers the given EventHandler for the given Entity Identity. You can pass the bambou.AllIdentity as identity to register the handler for all events. If you pass a handler for an Identity that is already registered the previous handler will be silently overwriten.

func (*PushCenter) Start Uses

func (p *PushCenter) Start() error

Start starts the Push Center.

func (*PushCenter) Stop Uses

func (p *PushCenter) Stop() error

Stop stops a running PushCenter.

func (*PushCenter) UnregisterHandlerForIdentity Uses

func (p *PushCenter) UnregisterHandlerForIdentity(identity Identity)

UnregisterHandlerForIdentity unegisters the given EventHandler for the given Entity Identity.

type Rootable Uses

type Rootable interface {

    // APIKey returns the token that will be used to authentify the communication
    // between a Storer and the backend.
    APIKey() string

    // SetAPIKey sets the token used by the Storer.

Rootable is the interface that must be implemented by the root object of the API. A Rootable also implements the Identifiable interface.

type Session Uses

type Session struct {
    Certificate  *tls.Certificate
    Username     string
    Password     string
    Organization string
    URL          string
    // contains filtered or unexported fields

Session represents a user session. It provides the entire communication layer with the backend. It must implement the Operationable interface. A session can be authenticated via 1) TLS certificates or 2) user + password (different API endpoints)

func NewSession Uses

func NewSession(username, password, organization, url string, root Rootable) *Session

NewSession returns a new *Session You need to provide a Rootable object that will be used to contain the results of the authentication process, like the api key for instance. Authentication using user + password

func NewX509Session Uses

func NewX509Session(cert *tls.Certificate, url string, root Rootable) *Session

func (*Session) AssignChildren Uses

func (s *Session) AssignChildren(parent Identifiable, children []Identifiable, identity Identity) *Error

AssignChildren assigns the list of given child Identifiables to the given Identifiable parent in the server.

func (*Session) CreateChild Uses

func (s *Session) CreateChild(parent Identifiable, child Identifiable) *Error

CreateChild creates a new child Identifiable under the given parent Identifiable in the server.

func (*Session) DeleteEntity Uses

func (s *Session) DeleteEntity(object Identifiable) *Error

DeleteEntity deletes the given Identifiable from the server.

func (*Session) FetchChildren Uses

func (s *Session) FetchChildren(parent Identifiable, identity Identity, dest interface{}, info *FetchingInfo) *Error

FetchChildren fetches the children with of given parent identified by the given Identity.

func (*Session) FetchEntity Uses

func (s *Session) FetchEntity(object Identifiable) *Error

FetchEntity fetchs the given Identifiable from the server.

func (*Session) NextEvent Uses

func (s *Session) NextEvent(channel NotificationsChannel, lastEventID string) *Error

NextEvent will return the next notification from the backend as it occurs and will send it to the correct channel.

func (*Session) Reset Uses

func (s *Session) Reset()

Reset resets the session.

func (*Session) Root Uses

func (s *Session) Root() Rootable

Root returns the Root API object.

func (*Session) SaveEntity Uses

func (s *Session) SaveEntity(object Identifiable) *Error

SaveEntity saves the given Identifiable into the server.

func (*Session) SetInsecureSkipVerify Uses

func (s *Session) SetInsecureSkipVerify(skip bool) *Error

Dummy function avail for backwards compat. Logic moved to the new session methods

func (*Session) Start Uses

func (s *Session) Start() *Error

Start starts the session. At that point the authentication will be done.

type Storer Uses

type Storer interface {
    Start() *Error
    Root() Rootable

    FetchEntity(Identifiable) *Error
    SaveEntity(Identifiable) *Error
    DeleteEntity(Identifiable) *Error
    FetchChildren(Identifiable, Identity, interface{}, *FetchingInfo) *Error
    CreateChild(Identifiable, Identifiable) *Error
    AssignChildren(Identifiable, []Identifiable, Identity) *Error
    NextEvent(NotificationsChannel, string) *Error

Storer is the interface that must be implemented by object that can perform CRUD operations on RemoteObjects.

func CurrentSession Uses

func CurrentSession() Storer

CurrentSession returns the current active and authenticated Session.

type VsdError Uses

type VsdError struct {
    Property     string  `json:"property"`
    Descriptions []Error `json:"descriptions"` // XXX -- note

type VsdErrorList Uses

type VsdErrorList struct {
    VsdErrors    []VsdError `json:"errors"`
    VsdErrorCode int        `json:"internalErrorCode"`

Package bambou imports 14 packages (graph) and is imported by 3 packages. Updated 2018-11-29. Refresh now. Tools for package owners.