Documentation ¶
Index ¶
- Constants
- type AssetsService
- type Client
- func (c *Client) NewRequest(method, endpoint, url string, body interface{}) (*http.Request, error)
- func (c *Client) NewRequestContentType(method, endpoint, urlStr, headerContentType, headerAccept string, ...) (*http.Request, error)
- func (c *Client) Token() string
- func (c *Client) URLFor(endpoint, uri string) string
- type IAMAuthConfiguration
- type IAMClient
- type IAMDomain
- type IAMGroup
- type IAMRule
- type IAMScope
- type IAMService
- func (i *IAMService) ClientAdd(client *IAMClient) (string, error)
- func (i *IAMService) ClientDelete(domainName, id string) error
- func (i *IAMService) ClientGet(domainName, id string, client *IAMClient) error
- func (i *IAMService) ClientSearch(domainName string) *Search
- func (i *IAMService) ClientUpdate(id string, client *IAMClient) error
- func (i *IAMService) DomainAdd(domain *IAMDomain) (string, error)
- func (i *IAMService) DomainDelete(id string) error
- func (i *IAMService) DomainGet(id string, domain *IAMDomain) error
- func (i *IAMService) DomainSearch() *Search
- func (i *IAMService) DomainUpdate(id string, domain *IAMDomain) error
- func (i *IAMService) GroupAdd(group *IAMGroup) (string, error)
- func (i *IAMService) GroupDelete(id string) error
- func (i *IAMService) GroupDeleteScope(id string, scope string) error
- func (i *IAMService) GroupGet(id string, group *IAMGroup) error
- func (i *IAMService) GroupGetAll(groups []*IAMGroup) error
- func (i *IAMService) GroupSetScopes(id string, scopes []string) error
- func (i *IAMService) OauthToken() error
- func (i *IAMService) OauthTokenBasicAuth(username, password string) error
- func (i *IAMService) OauthTokenPrn(username string) error
- func (i *IAMService) OauthTokenUpgrade(assetsToken string) error
- func (i *IAMService) RefreshToken() error
- func (i *IAMService) ScopeAdd(scope *IAMScope) (string, error)
- func (i *IAMService) ScopeDelete(id string) error
- func (i *IAMService) ScopeGet(id string, scope *IAMScope) error
- func (i *IAMService) ScopeUpdate(scope *IAMScope) (string, error)
- func (i *IAMService) UserAdd(user *IAMUser) (string, error)
- func (i *IAMService) UserAddGroups(userID string, groupIDs []string) error
- func (i *IAMService) UserByUsername(username string) (*IAMUser, error)
- func (i *IAMService) UserDelete(id string) error
- func (i *IAMService) UserDeleteGroup(userID, groupID string) error
- func (i *IAMService) UserDeleteMe() error
- func (i *IAMService) UserExists(username string) bool
- func (i *IAMService) UserGet(id string, user *IAMUser) error
- func (i *IAMService) UserGetMe(user *IAMUser) error
- func (i *IAMService) UserSearch() *Search
- func (i *IAMService) UserUpdate(id string, user *IAMUser) error
- func (i *IAMService) UserUpdateMe(user *IAMUser) error
- type IAMUser
- type RelationData
- type ResourcesService
- func (r *ResourcesService) AddRelation(...) (string, error)
- func (r *ResourcesService) AddToCollection(collectionName string, resource interface{}) (string, error)
- func (r *ResourcesService) CollectionRequest(method, accept, collectionName string, send interface{}) (*http.Request, error)
- func (r *ResourcesService) DeleteACLCollection(id string) error
- func (r *ResourcesService) DeleteAllRelations(collectionName, resourceID, relationName string) error
- func (r *ResourcesService) DeleteFromCollection(collectionName, id string) error
- func (r *ResourcesService) DeleteRelation(...) error
- func (r *ResourcesService) GetFromCollection(collectionName, id string, resource interface{}) error
- func (r *ResourcesService) GetFromRelationDefinition(id string, resource interface{}) error
- func (r *ResourcesService) MarkCollectionAsACL(info interface{}) error
- func (r *ResourcesService) MoveRelation(...) (string, error)
- func (r *ResourcesService) RelationRequest(method, accept, collectionName, resourceID, relationName, ... string, ...) (*http.Request, error)
- func (r *ResourcesService) ResourceRequest(method, accept, collectionName, id string, send interface{}) (*http.Request, error)
- func (r *ResourcesService) SearchCollection(collectionName string) *Search
- func (r *ResourcesService) SearchRelation(collectionName, resourceID, relationName string) *Search
- func (r *ResourcesService) SearchSpecificRelation(...) *Search
- func (r *ResourcesService) UpdateACLCollection(id string, info interface{}) error
- func (r *ResourcesService) UpdateInCollection(collectionName, id string, resource interface{}) error
- func (r *ResourcesService) UpdateResourceACL(collectionName, id string, acl interface{}) error
- type Search
- type SearchListOptions
- type UserACL
Constants ¶
const ( // SortAsc used for sorting (ascending) SortAsc = "asc" // SortDesc used for sorting (descending) SortDesc = "desc" )
const Version = "0.1.0"
Version of the library
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AssetsService ¶
type AssetsService struct {
// contains filtered or unexported fields
}
AssetsService handles communication with the Assets service of Corbel. It takes care of user assets that gives special scopes to the resources.
Full API info: http://docs.silkroadassets.apiary.io/
func (*AssetsService) UpgradeToken ¶
func (a *AssetsService) UpgradeToken() error
UpgradeToken returns the assertion to upgrade the token on IAM to get the 'purchased' scopes
type Client ¶
type Client struct { // Endpoint is a structure that stores the uri for each resource Endpoints map[string]string // ClientName is the name that match the clientID // (Optional) The required information is the clientID ClientName string // ClientID is the application defined client on Corbel. ClientID string // ClientSecret is the application secret hash that match with clientID. ClientSecret string // ClientScopes are those scopes the client will ask for to the platform when building the client connection // ClientScopes is a string with the scopes delimited by spaces. ClientScopes string // ClientDomain is the SR domain where to make the operations using the provided credentials. // (Optional) Every clientID only maps to one SR domain. ClientDomain string // ClientJWTSigningMethod defines the signing method configured for the client. // Must match with the one configured on the platform since it will understand only that one. // Only allowed signing methods at the moment are: HS256 and RSA ClientJWTSigningMethod string // TokenExpirationTime define the amount of time in seconds that a token must be valid. // It must be lower than 3600 seconds, since is the imposed requisite from the platform. TokenExpirationTime uint64 // UserAgent defines the UserAgent to send in the Headers for every request to the platform. UserAgent string // Token is the actual token to send as Authentication Bearer CurrentToken string // CurrentTokenExpiresAt is the unix time where the token will expire CurrentTokenExpiresAt int64 // CurrentRefreshToken is the current refresh token received from the IAM service CurrentRefreshToken string // IAM endpoint struct IAM *IAMService Resources *ResourcesService Assets *AssetsService // LogLevel for the logger. LogLevel string // contains filtered or unexported fields }
Client is the struct that manages communication with the Corbel APIs.
func DefaultClient ¶
func DefaultClient(endpoints map[string]string, clientID, clientName, clientSecret, clientScopes, clientDomain string) (*Client, error)
DefaultClient return a client with most of its values set to the default ones
func NewClient ¶
func NewClient(httpClient *http.Client, endpoints map[string]string, clientID, clientName, clientSecret, clientScopes, clientDomain, clientJWTSigningMethod string, tokenExpirationTime uint64, logLevel string) (*Client, error)
NewClient returns a new Corbel API client. If a nil httpClient is provided, it will return a http.DefaultClient. If a empty environment is provided, it will use production as environment.
func (*Client) NewRequest ¶
NewRequest creates an API request using 'application/json', most common api query. method is the HTTP method to use endpoint is the endpoint of SR to speak with url is the url to query. it must be preceded by a slash. body is, if specified, the value JSON encoded to be used as request body.
func (*Client) NewRequestContentType ¶
func (c *Client) NewRequestContentType(method, endpoint, urlStr, headerContentType, headerAccept string, body interface{}) (*http.Request, error)
NewRequestContentType creates an API request. method is the HTTP method to use endpoint is the endpoint of SR to speak with urlStr is the url to query. it must be preceded by a slash. headerContentType is the header['Content-Type'] of the request. headerAccept is the header['Accept'] of the request. body is, if specified, the value JSON encoded to be used as request body.
type IAMAuthConfiguration ¶
type IAMAuthConfiguration struct { // Type defined the Auth Configuration type defined Type string `json:"type"` RedirectURL string `json:"redirectUri"` // ClientId used for Facebook, Google and Corbel Oauth 2.0 ClientID string `json:"clientID,omitempty"` ClientSecret string `json:"clientSecret,omitempty"` // OAuthServerURL is the Oauth URL to use in Corbel Oauth OAuthServerURL string `json:"oAuthServerUrl,omitempty"` // CounsumerKey used for Twitter Oauth ConsumerKey string `json:"consumerKey,omitempty"` ConsumerSecret string `json:"consumerSecret,omitempty"` }
IAMAuthConfiguration is the representation of an AuthConfiguration object used by IAM
type IAMClient ¶
type IAMClient struct { ID string `json:"id,omitempty"` Key string `json:"key"` Name string `json:"name"` Domain string `json:"domain"` Version string `json:"version,omitempty"` SignatureAlgorithm string `json:"signatureAlgorithm,omitempty"` Scopes []string `json:"scopes,omitempty"` ClientSideAuthentication bool `json:"clientSideAuthentication"` ResetURL string `json:"resetUrl,omitempty"` ResetNotificationID string `json:"resetNotificationId,omitempty"` }
IAMClient is the representation of a Client object used by IAM
type IAMDomain ¶
type IAMDomain struct { ID string `json:"id"` Description string `json:"description,omitempty"` AuthURL string `json:"authUrl, omitempty"` AllowedDomains string `json:"allowedDomains"` Scopes []string `json:"scopes,omitempty"` DefaultScopes []string `json:"defaultScopes,omitempty"` AuthConfigurations map[string]IAMAuthConfiguration `json:"authConfigurations,omitempty"` UserProfileFields []string `json:"userProfileFields,omitempty"` CreatedDate int `json:"createdDate,omitempty"` CreatedBy string `json:"createdBy,omitempty"` }
IAMDomain is the representation of an Domain object used by IAM
type IAMGroup ¶
type IAMGroup struct { ID string `json:"id,omitempty"` Name string `json:"name"` Scopes []string `json:"scopes"` // must be omitempty }
IAMGroup is the representation of a Group object used by IAM
type IAMRule ¶
type IAMRule struct { MediaTypes []string `json:"mediaTypes"` Methods []string `json:"methods"` Type string `json:"type"` URI string `json:"uri"` TokenType string `json:"tokenType"` }
IAMRule is the representation of a Rule for a Scope object used by IAM
type IAMScope ¶
type IAMScope struct { ID string `json:"id"` Audience string `json:"audience"` Type string `json:"type"` Scopes []string `json:"scopes,omitempty"` Parameters map[string]string `json:"parameters,omitempty"` Rules []IAMRule `json:"rules,omitempty"` }
IAMScope is the representation of a Scope object used by IAM
type IAMService ¶
type IAMService struct {
// contains filtered or unexported fields
}
IAMService handles communication with the IAM service of Corbel. It takes care of all Identity and Authorization Management
Full API info: http://docs.silkroadiam.apiary.io/
func (*IAMService) ClientAdd ¶
func (i *IAMService) ClientAdd(client *IAMClient) (string, error)
ClientAdd adds an Client defined struct to the platform
func (*IAMService) ClientDelete ¶
func (i *IAMService) ClientDelete(domainName, id string) error
ClientDelete deletes the desired client from IAM by id
func (*IAMService) ClientGet ¶
func (i *IAMService) ClientGet(domainName, id string, client *IAMClient) error
ClientGet gets the desired IAMClient
func (*IAMService) ClientSearch ¶
func (i *IAMService) ClientSearch(domainName string) *Search
ClientSearch gets the desired objects in base of a search query
func (*IAMService) ClientUpdate ¶
func (i *IAMService) ClientUpdate(id string, client *IAMClient) error
ClientUpdate updates an client by using IAMClient
func (*IAMService) DomainAdd ¶
func (i *IAMService) DomainAdd(domain *IAMDomain) (string, error)
DomainAdd adds an Domain defined struct to the platform
func (*IAMService) DomainDelete ¶
func (i *IAMService) DomainDelete(id string) error
DomainDelete deletes the desired domain from IAM by id
func (*IAMService) DomainGet ¶
func (i *IAMService) DomainGet(id string, domain *IAMDomain) error
DomainGet gets the desired IAMUdomain from the domain by id
func (*IAMService) DomainSearch ¶
func (i *IAMService) DomainSearch() *Search
DomainSearch gets the desired objects in base of a search query
func (*IAMService) DomainUpdate ¶
func (i *IAMService) DomainUpdate(id string, domain *IAMDomain) error
DomainUpdate updates an domain by using IAMDomain
func (*IAMService) GroupAdd ¶
func (i *IAMService) GroupAdd(group *IAMGroup) (string, error)
GroupAdd adds a new group to iam into the current domain
func (*IAMService) GroupDelete ¶
func (i *IAMService) GroupDelete(id string) error
GroupDelete deletes the desired group from IAM by id
func (*IAMService) GroupDeleteScope ¶
func (i *IAMService) GroupDeleteScope(id string, scope string) error
GroupDeleteScope deletes a scope of a group
func (*IAMService) GroupGet ¶
func (i *IAMService) GroupGet(id string, group *IAMGroup) error
GroupGet gets the desired IAMGroup from the domain by id
func (*IAMService) GroupGetAll ¶
func (i *IAMService) GroupGetAll(groups []*IAMGroup) error
GroupGetAll gets all Groups of the client current domain
func (*IAMService) GroupSetScopes ¶
func (i *IAMService) GroupSetScopes(id string, scopes []string) error
GroupSetScopes set the scopes of a Group
func (*IAMService) OauthToken ¶
func (i *IAMService) OauthToken() error
OauthToken gets an access token
API Docs: http://docs.silkroadiam.apiary.io/#reference/authorization/oauthtoken
func (*IAMService) OauthTokenBasicAuth ¶
func (i *IAMService) OauthTokenBasicAuth(username, password string) error
OauthTokenBasicAuth gets an access token using username/password scheme (basic auth)
API Docs: http://docs.silkroadiam.apiary.io/#reference/authorization/oauthtoken
func (*IAMService) OauthTokenPrn ¶
func (i *IAMService) OauthTokenPrn(username string) error
OauthTokenPrn get user access token to use it
func (*IAMService) OauthTokenUpgrade ¶
func (i *IAMService) OauthTokenUpgrade(assetsToken string) error
OauthTokenUpgrade upgrade the token using the token generated by the module Assets
on /assets/access and adds the scopes assigned at assets level to the current logged user returning a new token with those additional scopes.
API Docs: http://docs.silkroadiam.apiary.io/#reference/authorization/oauthtokenupgrade
func (*IAMService) RefreshToken ¶
func (i *IAMService) RefreshToken() error
RefreshToken gets an access token
API Docs: http://docs.silkroadiam.apiary.io/#reference/authorization/oauthtoken
func (*IAMService) ScopeAdd ¶
func (i *IAMService) ScopeAdd(scope *IAMScope) (string, error)
ScopeAdd adds an Scope defined struct to the platform
func (*IAMService) ScopeDelete ¶
func (i *IAMService) ScopeDelete(id string) error
ScopeDelete deletes the desired scope from IAM by id
func (*IAMService) ScopeGet ¶
func (i *IAMService) ScopeGet(id string, scope *IAMScope) error
ScopeGet gets the desired IAMScope from the scope by id
func (*IAMService) ScopeUpdate ¶
func (i *IAMService) ScopeUpdate(scope *IAMScope) (string, error)
ScopeUpdate updates an scope by using IAMScope
func (*IAMService) UserAdd ¶
func (i *IAMService) UserAdd(user *IAMUser) (string, error)
UserAdd adds an IAMUser defined struct to the domain of the client
func (*IAMService) UserAddGroups ¶
func (i *IAMService) UserAddGroups(userID string, groupIDs []string) error
UserAddGroups add groups to user's list of groups
func (*IAMService) UserByUsername ¶
func (i *IAMService) UserByUsername(username string) (*IAMUser, error)
UserByUsername allow to find an user based on its username
func (*IAMService) UserDelete ¶
func (i *IAMService) UserDelete(id string) error
UserDelete deletes the desired user from IAM by id
func (*IAMService) UserDeleteGroup ¶
func (i *IAMService) UserDeleteGroup(userID, groupID string) error
UserDeleteGroup deletes a groups from the user group list
func (*IAMService) UserDeleteMe ¶
func (i *IAMService) UserDeleteMe() error
UserDeleteMe deletes the user authenticated by the current token
func (*IAMService) UserExists ¶
func (i *IAMService) UserExists(username string) bool
UserExists checks if an user exists in the domain of the client
func (*IAMService) UserGet ¶
func (i *IAMService) UserGet(id string, user *IAMUser) error
UserGet gets the desired IAMUuser from the domain by id
func (*IAMService) UserGetMe ¶
func (i *IAMService) UserGetMe(user *IAMUser) error
UserGetMe gets the user authenticated by the current token
func (*IAMService) UserSearch ¶
func (i *IAMService) UserSearch() *Search
UserSearch gets the desired objects in base of a search query
func (*IAMService) UserUpdate ¶
func (i *IAMService) UserUpdate(id string, user *IAMUser) error
UserUpdate updates an user by using IAMUser
func (*IAMService) UserUpdateMe ¶
func (i *IAMService) UserUpdateMe(user *IAMUser) error
UserUpdateMe updates the user authenticated by the current token
type IAMUser ¶
type IAMUser struct { ID string `json:"id,omitempty"` Domain string `json:"domain,omitempty"` Username string `json:"username,omitempty"` Email string `json:"email,omitempty"` Password string `json:"password,omitempty"` FirstName string `json:"firstName,omitempty"` LastName string `json:"lastName,omitempty"` ProfileURL string `json:"profileUrl,omitempty"` PhoneNumber string `json:"phoneNumber,omitempty"` Scopes []string `json:"scopes"` Properties map[string]interface{} `json:"properties,omitempty"` Country string `json:"country,omitempty"` CreatedDate int `json:"createdDate,omitempty"` CreatedBy string `json:"createdBy,omitempty"` Groups []string `json:"groups,omitempty"` }
IAMUser is the representation of an User object used by IAM
type RelationData ¶
type RelationData struct { Order float64 `json:"_order,omitempty"` ID string `json:"id,omitempty"` Links []map[string]interface{} `json:"links, omitempty"` }
RelationData is a basic structure of data relations. By default this are the simplest data stored in a relation, but since it's possible to add specific data to the relation you can create your own RelationData struct. You must include ID as minimum if you want to use GetFromRelation func to retrieve the resource itself.
type ResourcesService ¶
type ResourcesService struct {
// contains filtered or unexported fields
}
ResourcesService handles the interface for retrival resource's representation on Corbel.
Full API info: http://docs.corbelresources.apiary.io/
func (*ResourcesService) AddRelation ¶
func (r *ResourcesService) AddRelation(collectionName, resourceID, relationName, relatedCollectionName, relatedID string, relationInfo interface{}) (string, error)
AddRelation adds the required relation to the resource in the collection with the _related_ resource. Additionally arbitrary information can be passed to as relation data or nil.
func (*ResourcesService) AddToCollection ¶
func (r *ResourcesService) AddToCollection(collectionName string, resource interface{}) (string, error)
AddToCollection add the required struct formated as json to the desired collection resource must have exported variables and optionally its representation as JSON.
func (*ResourcesService) CollectionRequest ¶
func (r *ResourcesService) CollectionRequest(method, accept, collectionName string, send interface{}) (*http.Request, error)
CollectionRequest perform a specific collection request on resources
func (*ResourcesService) DeleteACLCollection ¶
func (r *ResourcesService) DeleteACLCollection(id string) error
DeleteACLCollection is used to delete an acl managed collection
func (*ResourcesService) DeleteAllRelations ¶
func (r *ResourcesService) DeleteAllRelations(collectionName, resourceID, relationName string) error
DeleteAllRelations deletes all the relations by relationName of the desired resource
func (*ResourcesService) DeleteFromCollection ¶
func (r *ResourcesService) DeleteFromCollection(collectionName, id string) error
DeleteFromCollection deletes the desired resource from the platform by id
func (*ResourcesService) DeleteRelation ¶
func (r *ResourcesService) DeleteRelation(collectionName, resourceID, relationName, relatedCollectionName, relatedID string) error
DeleteRelation deletes the desired relation between the origin and the related resource
func (*ResourcesService) GetFromCollection ¶
func (r *ResourcesService) GetFromCollection(collectionName, id string, resource interface{}) error
GetFromCollection gets the desired object from the collection by id
func (*ResourcesService) GetFromRelationDefinition ¶
func (r *ResourcesService) GetFromRelationDefinition(id string, resource interface{}) error
GetFromRelationDefinition gets the desired object from the collection by id
func (*ResourcesService) MarkCollectionAsACL ¶
func (r *ResourcesService) MarkCollectionAsACL(info interface{}) error
MarkCollectionAsACL is used to set a collection as ACL managed
func (*ResourcesService) MoveRelation ¶
func (r *ResourcesService) MoveRelation(collectionName, resourceID, relationName, relatedCollectionName, relatedID string, order int) (string, error)
MoveRelation sets the required order of the related items on the relationship.
func (*ResourcesService) RelationRequest ¶
func (r *ResourcesService) RelationRequest(method, accept, collectionName, resourceID, relationName, relatedCollectionName, relatedID string, send interface{}) (*http.Request, error)
RelationRequest perform a specific relation request on resources
func (*ResourcesService) ResourceRequest ¶
func (r *ResourcesService) ResourceRequest(method, accept, collectionName, id string, send interface{}) (*http.Request, error)
ResourceRequest perform a specific resource request on resources
func (*ResourcesService) SearchCollection ¶
func (r *ResourcesService) SearchCollection(collectionName string) *Search
SearchCollection gets the desired objects in base of a search query
func (*ResourcesService) SearchRelation ¶
func (r *ResourcesService) SearchRelation(collectionName, resourceID, relationName string) *Search
SearchRelation returns an instance to the Search Builder
func (*ResourcesService) SearchSpecificRelation ¶
func (r *ResourcesService) SearchSpecificRelation(collectionName, resourceID, relationName, relatedCollectionName, relatedID string) *Search
SearchSpecificRelation returns a relation between two objects belonging to the relation
func (*ResourcesService) UpdateACLCollection ¶
func (r *ResourcesService) UpdateACLCollection(id string, info interface{}) error
UpdateACLCollection is used to update an acl managed collection
func (*ResourcesService) UpdateInCollection ¶
func (r *ResourcesService) UpdateInCollection(collectionName, id string, resource interface{}) error
UpdateInCollection updates the required struct formated as json to the desired collection resource must have exported variables and optionally its representation as JSON.
func (*ResourcesService) UpdateResourceACL ¶
func (r *ResourcesService) UpdateResourceACL(collectionName, id string, acl interface{}) error
UpdateResourceACL updates the acl of the associated resource. ACL entries will be added if they were not previously there or modified otherwise. Any entries previously added but not passed will be removed.
type Search ¶
type Search struct { Query *apiquery Sort *sort PageSize int // contains filtered or unexported fields }
Search is the struct used to query every searcheable api in the platform
func NewSearch ¶
NewSearch returns a Search struct that allows to select especific search requirements
func (*Search) CountAll ¶
CountAll returns the aggregated count of all items in the search. It's an alias of Count("*")
type SearchListOptions ¶
type SearchListOptions struct { APIQuery string `url:"api:query,omitempty"` APISort string `url:"api:sort,omitempty"` APIPageSize int `url:"api:pageSize,omitempty"` APIPage int `url:"api:page,omitempty"` APIAggregation string `url:"api:aggregation,omitempty"` }
SearchListOptions specifies the optional parameters for searches supporting paging and aggregation