Documentation ¶
Index ¶
- Constants
- func ToJson(object interface{}) ([]byte, error)
- type AccessControl
- type AuthenticationMode
- type ChangeNotifyType
- type Client
- func (c *Client) Clear() (*Result, error)
- func (c *Client) Delete(url string, processor HttpRequestProcessor) (*http.Response, error)
- func (c *Client) DeleteItem(item *Item) (*Result, error)
- func (c *Client) DeleteItemType(itemType *ItemType) (*Result, error)
- func (c *Client) DeleteItemTypeAttr(typeAttr *ItemTypeAttribute) (*Result, error)
- func (c *Client) DeleteLink(link *Link) (*Result, error)
- func (c *Client) DeleteLinkRule(linkRule *LinkRule) (*Result, error)
- func (c *Client) DeleteLinkType(linkType *LinkType) (*Result, error)
- func (c *Client) DeleteLinkTypeAttr(typeAttr *LinkTypeAttribute) (*Result, error)
- func (c *Client) DeleteMembership(member *Membership) (*Result, error)
- func (c *Client) DeleteModel(model *Model) (*Result, error)
- func (c *Client) DeletePartition(partition *Partition) (*Result, error)
- func (c *Client) DeletePrivilege(privilege *Privilege) (*Result, error)
- func (c *Client) DeleteRole(role *Role) (*Result, error)
- func (c *Client) DeleteUser(user *User) (*Result, error)
- func (c *Client) Get(url string, processor HttpRequestProcessor) (*http.Response, error)
- func (c *Client) GetChildrenByType(item *Item, childType string) (*ItemList, error)
- func (c *Client) GetItem(item *Item) (*Item, error)
- func (c *Client) GetItemChildren(item *Item) (*ItemList, error)
- func (c *Client) GetItemType(itemType *ItemType) (*ItemType, error)
- func (c *Client) GetItemTypeAttr(typeAttr *ItemTypeAttribute) (*ItemTypeAttribute, error)
- func (c *Client) GetItemsByType(itemType string) (*ItemList, error)
- func (c *Client) GetItemsOfType(itemType string) (*ItemList, error)
- func (c *Client) GetLink(link *Link) (*Link, error)
- func (c *Client) GetLinkRule(linkRule *LinkRule) (*LinkRule, error)
- func (c *Client) GetLinkType(linkType *LinkType) (*LinkType, error)
- func (c *Client) GetLinkTypeAttr(typeAttr *LinkTypeAttribute) (*LinkTypeAttribute, error)
- func (c *Client) GetLinks() (*LinkList, error)
- func (c *Client) GetMembership(member *Membership) (*Membership, error)
- func (c *Client) GetModel(model *Model) (*Model, error)
- func (c *Client) GetPartition(partition *Partition) (*Partition, error)
- func (c *Client) GetPrivilege(privilege *Privilege) (*Privilege, error)
- func (c *Client) GetRole(role *Role) (*Role, error)
- func (c *Client) GetUser(user *User) (*User, error)
- func (c *Client) Login(credentials *Login) (*h.UserPrincipal, error)
- func (c *Client) MakeRequest(method string, url string, payload Serializable, ...) (*http.Response, error)
- func (c *Client) Post(url string, payload Serializable, processor HttpRequestProcessor) (*http.Response, error)
- func (c *Client) Put(url string, payload Serializable, processor HttpRequestProcessor) (*http.Response, error)
- func (c *Client) PutData(data *GraphData) (*Result, error)
- func (c *Client) PutItem(item *Item) (*Result, error)
- func (c *Client) PutItemType(itemType *ItemType) (*Result, error)
- func (c *Client) PutItemTypeAttr(typeAttr *ItemTypeAttribute) (*Result, error)
- func (c *Client) PutLink(link *Link) (*Result, error)
- func (c *Client) PutLinkRule(linkRule *LinkRule) (*Result, error)
- func (c *Client) PutLinkType(linkType *LinkType) (*Result, error)
- func (c *Client) PutLinkTypeAttr(typeAttr *LinkTypeAttribute) (*Result, error)
- func (c *Client) PutMembership(member *Membership) (*Result, error)
- func (c *Client) PutModel(model *Model) (*Result, error)
- func (c *Client) PutPartition(partition *Partition) (*Result, error)
- func (c *Client) PutPrivilege(privilege *Privilege) (*Result, error)
- func (c *Client) PutRole(role *Role) (*Result, error)
- func (c *Client) PutUser(user *User, notify bool) (*Result, error)
- type ClientConf
- type EventConfig
- type EventManager
- type GraphData
- type HttpRequestProcessor
- type Item
- type ItemList
- type ItemType
- type ItemTypeAttribute
- type ItemTypeAttributeList
- type ItemTypeList
- type Link
- type LinkList
- type LinkRule
- type LinkRuleList
- type LinkType
- type LinkTypeAttribute
- type LinkTypeAttributeList
- type LinkTypeList
- type Login
- type Membership
- type MembershipList
- type Model
- type ModelList
- type OAuthTokenResponse
- type Partition
- type PartitionList
- type Privilege
- type PrivilegeList
- type Result
- type Role
- type RoleList
- type Serializable
- type StringPayload
- type User
- type UserList
Constants ¶
const ( DELETE = "DELETE" PUT = "PUT" GET = "GET" POST = "POST" )
Variables ¶
This section is empty.
Functions ¶
Types ¶
type AccessControl ¶
type AuthenticationMode ¶
type AuthenticationMode int
the authentication mode type
const ( // no authentication used None AuthenticationMode = iota // use basic access authentication Basic // use OpenId Connect token OIDC )
the different authentication modes available to the client
type ChangeNotifyType ¶
type ChangeNotifyType string
const ( NotifyTypeNone ChangeNotifyType = "N" NotifyTypeType ChangeNotifyType = "T" NotifyTypeItem ChangeNotifyType = "I" )
func FromString ¶
func FromString(changeNotifyType string) ChangeNotifyType
func (*ChangeNotifyType) ToString ¶
func (n *ChangeNotifyType) ToString() string
type Client ¶
Onix HTTP client
func NewClient ¶
func NewClient(conf *ClientConf) (*Client, error)
creates a new Onix Web API client
func (*Client) DeleteItem ¶
issue a Delete http request to the resource URI
func (*Client) DeleteItemType ¶
issue a Delete http request to the resource URI
func (*Client) DeleteItemTypeAttr ¶
func (c *Client) DeleteItemTypeAttr(typeAttr *ItemTypeAttribute) (*Result, error)
issue a Delete http request to the resource URI
func (*Client) DeleteLink ¶
DeleteLink issue a Delete http request to the resource URI
func (*Client) DeleteLinkRule ¶
issue a Delete http request to the resource URI
func (*Client) DeleteLinkType ¶
issue a Delete http request to the resource URI
func (*Client) DeleteLinkTypeAttr ¶
func (c *Client) DeleteLinkTypeAttr(typeAttr *LinkTypeAttribute) (*Result, error)
issue a Delete http request to the resource URI
func (*Client) DeleteMembership ¶
func (c *Client) DeleteMembership(member *Membership) (*Result, error)
issue a Delete http request to the resource URI
func (*Client) DeleteModel ¶
issue a Delete http request to the resource URI
func (*Client) DeletePartition ¶
issue a Delete http request to the resource URI
func (*Client) DeletePrivilege ¶
issue a Delete http request to the resource URI
func (*Client) DeleteRole ¶
issue a Delete http request to the resource URI
func (*Client) DeleteUser ¶
DeleteUser issue a Delete http request to the resource URI
func (*Client) GetChildrenByType ¶
GetChildrenByType get a list of first level children of the specified type
func (*Client) GetItemChildren ¶
Get a list of items which are linked to the specified item
func (*Client) GetItemType ¶
issue a Get http request to the resource URI itemType: an instance of the Item Type with the key of the item to retrieve
func (*Client) GetItemTypeAttr ¶
func (c *Client) GetItemTypeAttr(typeAttr *ItemTypeAttribute) (*ItemTypeAttribute, error)
issue a Get http request to the resource URI
func (*Client) GetLinkRule ¶
issue a Get http request to the resource URI
func (*Client) GetLinkType ¶
issue a Get http request to the resource URI
func (*Client) GetLinkTypeAttr ¶
func (c *Client) GetLinkTypeAttr(typeAttr *LinkTypeAttribute) (*LinkTypeAttribute, error)
issue a Get http request to the resource URI
func (*Client) GetMembership ¶
func (c *Client) GetMembership(member *Membership) (*Membership, error)
issue a Get http request to the resource URI
func (*Client) GetPartition ¶
issue a Get http request to the resource URI
func (*Client) GetPrivilege ¶
issue a Get http request to the resource URI
func (*Client) Login ¶
func (c *Client) Login(credentials *Login) (*h.UserPrincipal, error)
Login check that the user is authenticated using the CMDB as user store and returns a list of access controls for the user
func (*Client) MakeRequest ¶
func (c *Client) MakeRequest(method string, url string, payload Serializable, processor HttpRequestProcessor) (*http.Response, error)
Make a generic HTTP request
func (*Client) Post ¶
func (c *Client) Post(url string, payload Serializable, processor HttpRequestProcessor) (*http.Response, error)
Make a POST HTTP request to the specified URL
func (*Client) Put ¶
func (c *Client) Put(url string, payload Serializable, processor HttpRequestProcessor) (*http.Response, error)
Make a PUT HTTP request to the specified URL
func (*Client) PutItemType ¶
issue a Put http request with the Item Type data as payload to the resource URI
func (*Client) PutItemTypeAttr ¶
func (c *Client) PutItemTypeAttr(typeAttr *ItemTypeAttribute) (*Result, error)
issue a Put http request with the Item Type Attribute data as payload to the resource URI
func (*Client) PutLink ¶
PutLink issue a Put http request with the Link data as payload to the resource URI
func (*Client) PutLinkRule ¶
issue a Put http request with the Link rule data as payload to the resource URI
func (*Client) PutLinkType ¶
issue a Put http request with the link type data as payload to the resource URI
func (*Client) PutLinkTypeAttr ¶
func (c *Client) PutLinkTypeAttr(typeAttr *LinkTypeAttribute) (*Result, error)
issue a Put http request with the Link Type Attribute data as payload to the resource URI
func (*Client) PutMembership ¶
func (c *Client) PutMembership(member *Membership) (*Result, error)
issue a Put http request with the Membership data as payload to the resource URI
func (*Client) PutModel ¶
issue a Put http request with the Model data as payload to the resource URI
func (*Client) PutPartition ¶
issue a Put http request with the Partition data as payload to the resource URI
func (*Client) PutPrivilege ¶
issue a Put http request with the Privilege data as payload to the resource URI
type ClientConf ¶
type ClientConf struct { // the base URI for the service BaseURI string // disables TLS certificate verification InsecureSkipVerify bool // how to authenticate with the Web API AuthMode AuthenticationMode // the user username for Basic and OpenId user authentication Username string // the user password for Basic and OpenId user authentication Password string // the URI of the OpenId server token endpoint // used by the client to retrieve an OpenId token TokenURI string // the username to authenticate with the token service ClientId string // the password to authenticate with the token service AppSecret string // time out Timeout time.Duration }
client configuration information
func (*ClientConf) SetAuthMode ¶
func (cfg *ClientConf) SetAuthMode(authMode string)
sets the AuthMode from a passed-in string
type EventConfig ¶
type EventConfig struct { // the MQTT Server url Server string // the item type for which to get notification changes (itemInstance must be empty) ItemType string // the item instance for which to get notification changes (ItemType must be empty) ItemInstance string // the quality of service for message delivery - 0: at most once, 1: at least once, 2: exactly once Qos int // authentication Username Username string // authentication Password Password string // skip tls certificate verification InsecureSkipVerify bool // the policy the Server will follow for TLS Client Authentication ClientAuthType tls.ClientAuthType // a function to process received messages OnMsgReceived MQTT.MessageHandler }
configuration for the event manager (mqtt broker)
type EventManager ¶
type EventManager struct {
// contains filtered or unexported fields
}
EventManager MQTT client for change notifications
func NewEventManager ¶
func NewEventManager(cfg *EventConfig) (*EventManager, error)
NewEventManager creates a new event manager subscribed to a specific topic cfg: the mqtt server configuration
func (*EventManager) Disconnect ¶
func (m *EventManager) Disconnect(timeoutMilSecs uint)
Disconnect from the message broker
type GraphData ¶
type GraphData struct { Models []Model `json:"models"` ItemTypes []ItemType `json:"itemTypes"` ItemTypeAttributes []ItemTypeAttribute `json:"itemTypeAttributes"` LinkTypes []LinkType `json:"linkTypes"` LinkTypeAttribute []LinkTypeAttribute `json:"linkTypeAttributes"` LinkRules []LinkRule `json:"linkRules"` Items []Item `json:"items"` Links []Link `json:"links"` }
type HttpRequestProcessor ¶
type HttpRequestProcessor func(req *http.Request, payload Serializable) error
modify the http request for example by adding any relevant http headers payload is provided for example, in case a Content-MD5 header has to be added to the request
type Item ¶
type Item struct { Key string `json:"key"` Name string `json:"name"` Description string `json:"description"` Status int `json:"status"` Type string `json:"type"` Tag []interface{} `json:"tag"` Meta map[string]interface{} `json:"meta"` Txt string `json:"txt"` Attribute map[string]interface{} `json:"attribute"` Partition string `json:"partition"` Version int64 `json:"version"` Created string `json:"created"` Updated string `json:"updated"` EncKeyIx int64 `json:"encKeyIx"` ChangedBy string `json:"changedBy"` }
the Item resource
func (*Item) GetBoolAttr ¶
GetBoolAttr return the value of the boolean attribute for the specified name or false if the attribute does not exist
func (*Item) GetStringAttr ¶
GetStringAttr return the value of the string attribute for the specified name or empty if the attribute does not exist
type ItemType ¶
type ItemType struct { Key string `json:"key"` Name string `json:"name"` Description string `json:"description"` Filter map[string]interface{} `json:"filter"` MetaSchema map[string]interface{} `json:"metaSchema"` Model string `json:"modelKey"` NotifyChange ChangeNotifyType `json:"notifyChange"` Tag []interface{} `json:"tag"` EncryptMeta bool `json:"encryptMeta"` EncryptTxt bool `json:"encryptTxt"` Style map[string]interface{} `json:"style"` Version int64 `json:"version"` Created string `json:"created"` Updated string `json:"updated"` ChangedBy string `json:"changedBy"` }
the Item Type resource
type ItemTypeAttribute ¶
type ItemTypeAttribute struct { Key string `json:"key"` Name string `json:"name"` Description string `json:"description"` Type string `json:"type"` DefValue string `json:"defValue"` Required bool `json:"required"` Regex string `json:"regex"` ItemTypeKey string `json:"itemTypeKey"` Version int64 `json:"version"` Created string `json:"created"` Updated string `json:"updated"` ChangedBy string `json:"changedBy"` }
type ItemTypeAttributeList ¶
type ItemTypeAttributeList struct {
Values []ItemTypeAttribute
}
type ItemTypeList ¶
type ItemTypeList struct {
Values []ItemType
}
type Link ¶
type Link struct { Key string `json:"key"` Description string `json:"description"` Type string `json:"type"` Tag []interface{} `json:"tag"` Meta map[string]interface{} `json:"meta"` Attribute map[string]interface{} `json:"attribute"` StartItemKey string `json:"startItemKey"` EndItemKey string `json:"endItemKey"` Version int64 `json:"version"` Created string `json:"created"` Updated string `json:"updated"` ChangedBy string `json:"changedBy"` }
type LinkRule ¶
type LinkRule struct { Key string `json:"key"` Name string `json:"name"` Description string `json:"description"` LinkTypeKey string `json:"linkTypeKey"` StartItemTypeKey string `json:"startItemTypeKey"` EndItemTypeKey string `json:"endItemTypeKey"` Version int64 `json:"version"` Created string `json:"created"` Updated string `json:"updated"` ChangedBy string `json:"changedBy"` }
type LinkRuleList ¶
type LinkRuleList struct {
Values []LinkRule
}
type LinkType ¶
type LinkType struct { Key string `json:"key"` Name string `json:"name"` Description string `json:"description"` MetaSchema map[string]interface{} `json:"metaSchema"` Model string `json:"modelKey"` Tag []interface{} `json:"tag"` EncryptMeta bool `json:"encryptMeta"` EncryptTxt bool `json:"encryptTxt"` Style map[string]interface{} `json:"style"` Version int64 `json:"version"` Created string `json:"created"` Updated string `json:"updated"` ChangedBy string `json:"changedBy"` }
type LinkTypeAttribute ¶
type LinkTypeAttribute struct { Key string `json:"key"` Name string `json:"name"` Description string `json:"description"` Type string `json:"type"` DefValue string `json:"defValue"` Required bool `json:"required"` Regex string `json:"regex"` LinkTypeKey string `json:"linkTypeKey"` Version int64 `json:"version"` Created string `json:"created"` Updated string `json:"updated"` ChangedBy string `json:"changedBy"` }
type LinkTypeAttributeList ¶
type LinkTypeAttributeList struct {
Values []LinkTypeAttribute
}
type LinkTypeList ¶
type LinkTypeList struct {
Values []Item
}
type Membership ¶
type Membership struct { Key string `json:"key"` User string `json:"userKey"` Role string `json:"roleKey"` Version int64 `json:"version"` Created string `json:"created"` Updated string `json:"updated"` ChangedBy string `json:"changedBy"` }
the Role resource
type MembershipList ¶
type MembershipList struct {
Values []Membership
}
type Model ¶
type Model struct { Key string `json:"key"` Name string `json:"name"` Description string `json:"description"` Partition string `json:"partition"` Managed bool `json:"managed"` Version int64 `json:"version"` Created string `json:"created"` Updated string `json:"updated"` ChangedBy string `json:"changedBy"` }
the Model resource
type OAuthTokenResponse ¶
type OAuthTokenResponse struct { AccessToken string `json:"access_token"` TokenType string `json:"token_type"` ExpiresIn int `json:"expires_in"` Scope string `json:"scope"` IdToken string `json:"id_token"` }
Response to an OAUth 2.0 token request
type Partition ¶
type Partition struct { Key string `json:"key"` Name string `json:"name"` Description string `json:"description"` Owner string `json:"owner"` Version int64 `json:"version"` Created string `json:"created"` Updated string `json:"updated"` ChangedBy string `json:"changedBy"` }
the Partition resource
type PartitionList ¶
type PartitionList struct {
Values []Partition
}
type Privilege ¶
type Privilege struct { Key string `json:"key"` Role string `json:"roleKey"` Partition string `json:"partitionKey"` Create bool `json:"canCreate"` Read bool `json:"canRead"` Delete bool `json:"canDelete"` Version int64 `json:"version"` Created string `json:"created"` Updated string `json:"updated"` ChangedBy string `json:"changedBy"` }
the Privilege resource
type PrivilegeList ¶
type PrivilegeList struct {
Values []Privilege
}
type Result ¶
type Result struct { Changed bool `json:"changed"` Error bool `json:"error"` Message string `json:"message"` Operation string `json:"operation"` Ref string `json:"ref"` }
Result data retrieved by PUT and DELETE WAPI resources
type Role ¶
type Role struct { Key string `json:"key"` Name string `json:"name"` Description string `json:"description"` Owner string `json:"owner"` Level int `json:"level"` Version int64 `json:"version"` Created string `json:"created"` Updated string `json:"updated"` ChangedBy string `json:"changedBy"` }
the Role resource
type Serializable ¶
type Serializable interface {
// contains filtered or unexported methods
}
all entities interface for payload serialisation
type User ¶
type User struct { Key string `json:"key"` Name string `json:"name"` Email string `json:"email"` Pwd string `json:"pwd"` Expires string `json:"expires"` Service bool `json:"service"` ACL string `json:"acl"` Version int64 `json:"version"` Created string `json:"created"` Updated string `json:"updated"` ChangedBy string `json:"changedBy"` }
User the user resource
func (*User) Controls ¶
func (user *User) Controls() []AccessControl
Source Files ¶
- client.go
- client_conf.go
- client_data.go
- client_item.go
- client_item_type.go
- client_item_type_attr.go
- client_link.go
- client_link_rule.go
- client_link_type.go
- client_link_type_attr.go
- client_login.go
- client_membership.go
- client_misc.go
- client_model.go
- client_partition.go
- client_privilege.go
- client_role.go
- client_user.go
- event.go
- eventConf.go
- graph_data.go
- item.go
- item_type.go
- item_type_attr.go
- link.go
- link_rule.go
- link_type.go
- link_type_attr.go
- login.go
- membership.go
- model.go
- partition.go
- privilege.go
- role.go
- user.go