Documentation ¶
Index ¶
- Constants
- Variables
- type APIError
- type Admin
- type AdminAppRBAC
- type AdminApplication
- type AdminGroups
- func (a *AdminGroups) AddMember(id, userID string) error
- func (a *AdminGroups) Delete(id string) error
- func (a *AdminGroups) GetByID(id string, object interface{}) error
- func (a *AdminGroups) GetMany(queryOptions QueryOptions, object interface{}) error
- func (a *AdminGroups) Insert(object interface{}) (map[string]interface{}, error)
- func (a *AdminGroups) RemoveMember(id, userID string) error
- func (a *AdminGroups) Update(id string, from, to interface{}) error
- type AdminRBAC
- type AdminUsers
- func (a *AdminUsers) Delete(id string) error
- func (a *AdminUsers) GetByID(id string, object interface{}) error
- func (a *AdminUsers) GetMany(queryOptions QueryOptions, object interface{}) error
- func (a *AdminUsers) Insert(object interface{}) (map[string]interface{}, error)
- func (a *AdminUsers) Update(id string, from, to interface{}) error
- type Apps
- func (a *Apps) Delete(id string) error
- func (a *Apps) GetByID(id string, object interface{}) error
- func (a *Apps) GetMany(queryOptions QueryOptions, object interface{}) error
- func (a *Apps) Insert(object interface{}) (map[string]interface{}, error)
- func (a *Apps) Update(id string, from, to interface{}) error
- type Backd
- func (b *Backd) App(appID string) *AdminApplication
- func (b *Backd) Apps() *Apps
- func (b *Backd) BootstrapCluster(code, name, username, email, password string) error
- func (b *Backd) ConnectionTimeouts(dialer, tlsHandshake, timeout time.Duration)
- func (b *Backd) Domain(domainID string) *Admin
- func (b *Backd) Domains() *Domains
- func (b *Backd) Functions(applicationID string) *Funcs
- func (b *Backd) Login(username, password, domain string) error
- func (b *Backd) Logout() error
- func (b *Backd) Me() (user User, err error)
- func (b *Backd) MeMapInterface() (user map[string]interface{}, err error)
- func (b *Backd) Objects(applicationID string) *Objects
- func (b *Backd) RBAC(appID string) *AdminAppRBAC
- func (b *Backd) Session() (string, int, time.Time)
- func (b *Backd) SetSession(sessionID string, expiresAt int64)
- func (b *Backd) SetSessionID(sessionID string)
- type BootstrapRequest
- type Domain
- type DomainType
- type Domains
- func (a *Domains) Delete(id string) error
- func (a *Domains) GetByID(id string, object interface{}) error
- func (a *Domains) GetMany(queryOptions QueryOptions, object interface{}) error
- func (a *Domains) Insert(object interface{}) (map[string]interface{}, error)
- func (a *Domains) Update(id string, from, to interface{}) error
- type Funcs
- func (a *Funcs) Delete(id string) error
- func (a *Funcs) GetByID(id string, object interface{}) error
- func (a *Funcs) GetMany(queryOptions QueryOptions, object interface{}) error
- func (a *Funcs) Insert(object interface{}) (map[string]interface{}, error)
- func (a *Funcs) Run(id string, input map[string]interface{}) (map[string]interface{}, error)
- func (a *Funcs) Update(id string, from, to interface{}) error
- type Function
- type Group
- type Login
- type LoginResponse
- type Metadata
- type Objects
- func (o *Objects) Delete(collection, id string) error
- func (o *Objects) GetByID(collection, id string, object interface{}) error
- func (o *Objects) GetMany(collection string, queryOptions QueryOptions, object interface{}) error
- func (o *Objects) GetRelationsOf(collection, id, relation, direction string, object interface{}) error
- func (o *Objects) Insert(collection string, object interface{}) (map[string]interface{}, error)
- func (o *Objects) RelationDelete(id string) error
- func (o *Objects) RelationGetByID(id string, object interface{}) error
- func (o *Objects) RelationGetMany(collection, id, direction string, object interface{}) error
- func (o *Objects) RelationInsert(object interface{}) (map[string]interface{}, error)
- func (o *Objects) Update(collection, id string, from, to interface{}) error
- type Permission
- type QueryOptions
- type RBAC
- type Relation
- type RequestByID
- type User
Constants ¶
const ( HeaderSessionID = "X-Session-ID" HeaderApplicationID = "X-Application-ID" )
Headers for the endpoints
const ( StateAnonymous int = iota StateExpired StateLoggedIn )
Session state
const ( RBACActionGet = "get" RBACActionSet = "set" RBACActionAdd = "add" RBACActionRemove = "remove" )
RBAC Actions
Variables ¶
var ( ErrBadRequest = errors.New(http.StatusText(http.StatusBadRequest)) ErrNotFound = errors.New(http.StatusText(http.StatusNotFound)) ErrMethodNotAllowed = errors.New(http.StatusText(http.StatusMethodNotAllowed)) ErrConflict = errors.New(http.StatusText(http.StatusConflict)) )
HTTP Errors returns if found
Functions ¶
This section is empty.
Types ¶
type APIError ¶
type APIError struct { Code int `json:"code"` Message string `json:"message"` Reason string `json:"reason,omitempty"` // contains filtered or unexported fields }
APIError is the struct that is returned when an error is returned from the APIs
type Admin ¶
type Admin struct { Users *AdminUsers Groups *AdminGroups // contains filtered or unexported fields }
Admin is the struct that contains all the actions doable with the Objects API
type AdminAppRBAC ¶
type AdminAppRBAC struct {
// contains filtered or unexported fields
}
AdminAppRBAC holds groups operations
func (*AdminAppRBAC) Add ¶
func (a *AdminAppRBAC) Add(rbac RBAC) error
Add adds role/s to the role permission set
func (*AdminAppRBAC) Get ¶
func (a *AdminAppRBAC) Get(rbac *RBAC) error
Get get current role permission set
func (*AdminAppRBAC) Remove ¶
func (a *AdminAppRBAC) Remove(rbac RBAC) error
Remove removes role/s to the role permission set
func (*AdminAppRBAC) Set ¶
func (a *AdminAppRBAC) Set(rbac RBAC) error
Set sets a new role permission set
type AdminApplication ¶
type AdminApplication struct { RBAC *AdminAppRBAC // contains filtered or unexported fields }
AdminApplication is the struct that contains all the actions doable with the Objects API
type AdminGroups ¶
type AdminGroups struct {
// contains filtered or unexported fields
}
AdminGroups holds groups operations
func (*AdminGroups) AddMember ¶
func (a *AdminGroups) AddMember(id, userID string) error
AddMember adds a new member to the group
func (*AdminGroups) Delete ¶
func (a *AdminGroups) Delete(id string) error
Delete removes a group by ID
func (*AdminGroups) GetByID ¶
func (a *AdminGroups) GetByID(id string, object interface{}) error
GetByID returns an group by its ID
func (*AdminGroups) GetMany ¶
func (a *AdminGroups) GetMany(queryOptions QueryOptions, object interface{}) error
GetMany returns all groups that matches the conditions especified
func (*AdminGroups) Insert ¶
func (a *AdminGroups) Insert(object interface{}) (map[string]interface{}, error)
Insert inserts a new group on the desired collection if the user have the required permissions
func (*AdminGroups) RemoveMember ¶
func (a *AdminGroups) RemoveMember(id, userID string) error
RemoveMember removes a member from a group by ID
func (*AdminGroups) Update ¶
func (a *AdminGroups) Update(id string, from, to interface{}) error
Update updates the required group if the user has permissions for
from is the original group updated by the user to is the group retreived by the API
type AdminRBAC ¶
type AdminRBAC struct {
// contains filtered or unexported fields
}
AdminRBAC holds groups operations
type AdminUsers ¶
type AdminUsers struct {
// contains filtered or unexported fields
}
AdminUsers holds users operations
func (*AdminUsers) Delete ¶
func (a *AdminUsers) Delete(id string) error
Delete removes a user by ID
func (*AdminUsers) GetByID ¶
func (a *AdminUsers) GetByID(id string, object interface{}) error
GetByID returns an user by its ID
func (*AdminUsers) GetMany ¶
func (a *AdminUsers) GetMany(queryOptions QueryOptions, object interface{}) error
GetMany returns all users that matches the conditions especified
func (*AdminUsers) Insert ¶
func (a *AdminUsers) Insert(object interface{}) (map[string]interface{}, error)
Insert inserts a new user on the desired collection if the user have the required permissions
func (*AdminUsers) Update ¶
func (a *AdminUsers) Update(id string, from, to interface{}) error
Update updates the required user if the user has permissions for
from is the original user updated by the user to is the object retreived by the API
type Apps ¶
type Apps struct {
// contains filtered or unexported fields
}
Apps is a simple struct that holds the operations doable for applications
func (*Apps) GetMany ¶
func (a *Apps) GetMany(queryOptions QueryOptions, object interface{}) error
GetMany returns all applications that matches the conditions especified
type Backd ¶
type Backd struct {
// contains filtered or unexported fields
}
Backd is the struct that holds the client for the service
func (*Backd) App ¶
func (b *Backd) App(appID string) *AdminApplication
App returns an instance of the Admin struct
func (*Backd) BootstrapCluster ¶
BootstrapCluster creates the first user on the cluster with full Administration permissions on the the backd application
func (*Backd) ConnectionTimeouts ¶
ConnectionTimeouts allow to change the client timeouts for:
- Dialer
- TLS Handshake
- HTTP timeout
func (*Backd) Functions ¶
Functions returns an instance of Funcs exposing the helper functions
for the function publishing workflow
func (*Backd) Logout ¶
Logout deletes the session on the API so the client will make request (if any) as anonymous
func (*Backd) MeMapInterface ¶
MeMapInterface returns an instance of the current user logged as map[string]interface{}
func (*Backd) RBAC ¶
func (b *Backd) RBAC(appID string) *AdminAppRBAC
RBAC returns an instance of the AdminAppRBAC struct
func (*Backd) Session ¶
Session returns current session status and remaining time if session is established
func (*Backd) SetSession ¶
SetSession sets a sessionID and expires information from elsewhere, used as commodity for the cli
No check will be done on the client library so errors (if any) will arise when requesting the API
func (*Backd) SetSessionID ¶
SetSessionID sets a sessionID and expires information from elsewhere, used as commodity for the cli
No check will be done on the client library so errors (if any) will arise when requesting the API
type BootstrapRequest ¶
type BootstrapRequest struct { Code string `json:"code"` Name string `json:"name"` Username string `json:"username"` Email string `json:"email"` Password string `json:"password"` }
BootstrapRequest is the request to initialize a `backd` cluster
type Domain ¶
type Domain struct { ID string `json:"_id"` Description string `json:"desc"` Type DomainType `json:"type"` Config map[string]interface{} `json:"config,omitempty"` Metadata `json:"meta"` }
Domain struct
type DomainType ¶
type DomainType string
DomainType defines the behavior to build a session on a backd defined domain
const ( // DomainTypeBackd when set the domain will use natively only the backd users/groups DomainTypeBackd DomainType = "b" // DomainTypeActiveDirectory when set the domain will inherit the groups from the users // on logon. So user membership will be updated from the ones received when the user // creates a session. DomainTypeActiveDirectory DomainType = "ad" )
type Domains ¶
type Domains struct {
// contains filtered or unexported fields
}
Domains is a simple struct that holds the operations doable for domains
func (*Domains) GetMany ¶
func (a *Domains) GetMany(queryOptions QueryOptions, object interface{}) error
GetMany returns all domains that matches the conditions especified
type Funcs ¶
type Funcs struct {
// contains filtered or unexported fields
}
Funcs is the struct that contains all helpers to work with the
functions on the admin endpoint
func (*Funcs) GetMany ¶
func (a *Funcs) GetMany(queryOptions QueryOptions, object interface{}) error
GetMany returns all functions that matches the conditions especified
type Function ¶
type Function struct { ID string `json:"_id"` Name string `json:"name"` API bool `json:"api"` RunAs string `json:"run_as"` Code string `json:"code"` Metadata `json:"meta"` }
Function defines a function to be called from other places API, scheduler, etc
type Group ¶
type Group struct { ID string `json:"_id"` // (required) ID generated by the API Name string `json:"name,omitempty"` // (required) Name of the group Description string `json:"desc,omitempty"` // (optional) Description Metadata `json:"meta"` }
Group is the struct that api expects
type Login ¶
type Login struct { Username string `json:"username"` Password string `json:"password"` Domain string `json:"domain"` }
Login is the struct that is expected by the API as request for an user authentication
type LoginResponse ¶
LoginResponse is the response if success. Upon a successful login it returns a
Session ID and ExpiresAt expiration date (as seconds from epoch)
type Metadata ¶
type Metadata struct { CreatedBy string `json:"cby" mapstructure:"cby"` UpdatedBy string `json:"uby" mapstructure:"uby"` CreatedAt int64 `json:"cat" mapstructure:"cat"` UpdatedAt int64 `json:"uat" mapstructure:"uat"` }
Metadata is the struct that defines how metadata is stored on the API
type Objects ¶
type Objects struct {
// contains filtered or unexported fields
}
Objects is the struct that contains all the actions doable with the Objects API
func (*Objects) GetMany ¶
func (o *Objects) GetMany(collection string, queryOptions QueryOptions, object interface{}) error
GetMany returns all objects that matches the conditions especified
func (*Objects) GetRelationsOf ¶
func (o *Objects) GetRelationsOf(collection, id, relation, direction string, object interface{}) error
GetRelationsOf returns all objects that matches the conditions especified
func (*Objects) Insert ¶
Insert inserts a new object on the desired collection if the user have the required permissions
func (*Objects) RelationDelete ¶
RelationDelete removes a object by ID
func (*Objects) RelationGetByID ¶
RelationGetByID returns an object by its ID
func (*Objects) RelationGetMany ¶
RelationGetMany returns all relation structs that matches the conditions especified, not the items itself
func (*Objects) RelationInsert ¶
RelationInsert inserts a new relation between items if the user have the required permissions
type Permission ¶
type Permission string
Permission is the required level of permission required to operate
const ( PermissionRead Permission = "read" PermissionCreate Permission = "create" PermissionUpdate Permission = "update" PermissionDelete Permission = "delete" PermissionAdmin Permission = "admin" )
Exported permissions
type QueryOptions ¶
type QueryOptions struct { Q map[string]interface{} `json:"q,omitempty" url:"-"` // for url it must be decode to string Sort []string `json:"sort,omitempty" url:"sort,omitempty"` Page int `json:"page,omitempty" url:"page,omitempty"` PerPage int `json:"per_page,omitempty" url:"per_page,omitempty"` }
QueryOptions is the builder of query parameters used for getMany queries
type RBAC ¶
type RBAC struct { Action string `json:"action,omitempty"` // allowed actions: add / remove / set DomainID string `json:"domain_id"` // domain IdentityID string `json:"identity_id"` // user_id / group_id Collection string `json:"collection"` // collection if application, if domain there is no concept of 'collection' you can manage or not if entity_id match CollectionID string `json:"collection_id"` // id if application, entity_id if domain Permissions []string `json:"permissions"` // array of permissions matching entity and item }
RBAC is the struct used to manage roles and permissions by the API
type Relation ¶
type Relation struct { ID string `json:"_id"` Source string `json:"src"` SourceID string `json:"sid"` Destination string `json:"dst"` DestinationID string `json:"did"` Relation string `json:"rel"` Metadata `json:"meta"` }
Relation is the representation of linked data.
type RequestByID ¶
type RequestByID struct {
ID string `json:"_id"`
}
RequestByID is a request that only especifies an ID (for simple things like group membership)
type User ¶
type User struct { ID string `json:"_id" mapstructure:"_id"` // (required) ID generated by the API Username string `json:"username" mapstructure:"username"` // (required) Username is the entity that will be used for logon. If email will be used as username then both must match Name string `json:"name" mapstructure:"name"` // (required) Name of the user (it can get filled with the data from the remote authorization authority) Email string `json:"email" mapstructure:"email"` // (required) Email of the user (the one used to notify by mail) Description string `json:"desc,omitempty" mapstructure:"desc,omitempty"` // (optional) User description Password string `json:"password,omitempty" mapstructure:"-"` // (optional) Password is only used to get the initial password on user creation GeneratedPassword string `json:"generated_password,omitempty" mapstructure:"-"` // GeneratedPassword will be filled only if the user didn't set a password on user creation, so it generates one randomly Active bool `json:"active,omitempty" mapstructure:"active,omitempty"` // (required) Active defines when the user can interact with the APIs (some authorizations can leave it as active if the authentication system will allow or restrict the user) Validated bool `json:"validated,omitempty" mapstructure:"validated,omitempty"` // (required) Validated shows if the user needs to make any action to active its email (and probably its account too) Data map[string]interface{} `json:"data,omitempty" mapstructure:"data,omitempty"` // (optional) Data is the arbitrary information that can be stored for the user Metadata `json:"meta" mapstructure:"meta"` }
User is the struct that API expects to get on user operations