Documentation ¶
Index ¶
- Constants
- type AccessToken
- type AttributeType
- type ChallengeCode
- type ClaimResult
- type ClientRequest
- type CompressionConfig
- type DataModel
- type Dataset
- type EntitiesExist
- type EventType
- type Events
- type ExponentialBackoffConfig
- type Mnubo
- type Model
- func (m *Model) AddEventTypeRelation(typeKey string, entityKey string) error
- func (m *Model) AddObjectTypeRelation(typeKey string, entityKey string) error
- func (m *Model) ApplyObjectAttributeDeployCode(key string, cc ChallengeCode) error
- func (m *Model) ApplyOwnerAttributeDeployCode(key string, cc ChallengeCode) error
- func (m *Model) ApplyResetCode(cc ChallengeCode) error
- func (m *Model) ApplyTimeseriesDeployCode(key string, cc ChallengeCode) error
- func (m *Model) CreateEventTypes(et []EventType) error
- func (m *Model) CreateObjectAttributes(oa []ObjectAttribute) error
- func (m *Model) CreateObjectTypes(ot []ObjectType) error
- func (m *Model) CreateOwnerAttributes(oa []OwnerAttribute) error
- func (m *Model) CreateTimeseries(ts []Timeseries) error
- func (m *Model) DeleteEventType(key string) error
- func (m *Model) DeleteObjectType(key string) error
- func (m *Model) DeployObjectAttributeToProduction(key string) error
- func (m *Model) DeployOwnerAttributeToProduction(key string) error
- func (m *Model) DeployTimeseriesToProduction(key string) error
- func (m *Model) Export(results *DataModel) error
- func (m *Model) GenerateObjectAttributeDeployCode(key string, results *ChallengeCode) error
- func (m *Model) GenerateOwnerAttributeDeployCode(key string, results *ChallengeCode) error
- func (m *Model) GenerateResetCode(results *ChallengeCode) error
- func (m *Model) GenerateTimeseriesDeployCode(key string, results *ChallengeCode) error
- func (m *Model) GetEventTypes(results *[]EventType) error
- func (m *Model) GetObjectAttributes(results *[]ObjectAttribute) error
- func (m *Model) GetObjectTypes(results *[]ObjectType) error
- func (m *Model) GetOwnerAttributes(results *[]OwnerAttribute) error
- func (m *Model) GetTimeseries(results *[]Timeseries) error
- func (m *Model) RemoveEventTypeRelation(typeKey string, entityKey string) error
- func (m *Model) RemoveObjectTypeRelation(typeKey string, entityKey string) error
- func (m *Model) ResetDataModel() error
- func (m *Model) UpdateEventType(key string, et EventType) error
- func (m *Model) UpdateObjectAttribute(key string, oa ObjectAttribute) error
- func (m *Model) UpdateObjectType(key string, ot ObjectType) error
- func (m *Model) UpdateOwnerAttribute(key string, oa OwnerAttribute) error
- func (m *Model) UpdateTimeseries(key string, ts Timeseries) error
- type ObjectAttribute
- type ObjectOwnerPair
- type ObjectType
- type Objects
- type OwnerAttribute
- type Owners
- func (o *Owners) Claim(pairs []ObjectOwnerPair, results *[]ClaimResult) error
- func (o *Owners) Create(owners interface{}, results interface{}) error
- func (o *Owners) Delete(username string) error
- func (o *Owners) Exist(usernames []string, results *EntitiesExist) error
- func (o *Owners) Unclaim(pairs []ObjectOwnerPair, results *[]ClaimResult) error
- func (o *Owners) Update(owners interface{}, results interface{}) error
- func (o *Owners) UpdateOwnerPassword(username string, password string) error
- type PasswordUpdatePayload
- type QueryValidation
- type Search
- func (s *Search) CreateBasicQuery(mql interface{}, results interface{}) error
- func (s *Search) CreateBasicQueryWithBytes(mql []byte, results interface{}) error
- func (s *Search) CreateBasicQueryWithString(mql string, results interface{}) error
- func (s *Search) GetDatasets(results *[]Dataset) error
- func (s *Search) ValidateQuery(mql interface{}, results *QueryValidation) error
- func (s *Search) ValidateQueryWithBytes(mql []byte, results *QueryValidation) error
- func (s *Search) ValidateQueryWithString(mql string, results *QueryValidation) error
- type SearchResults
- type SearchResultsColumn
- type SendEventsOptions
- type SendEventsReport
- type Sessionizer
- type Timeseries
- type TimeseriesType
Constants ¶
const ( DefaultTimeout = time.Second * 10 DefaultBackoffMaxInterval = time.Minute * 5 )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AccessToken ¶
type AccessToken struct { Value string `json:"access_token"` TokenType string `json:"token_type"` ExpiresIn int `json:"expires_in"` ExpiresAt time.Time Scope string `json:"scope"` Jti string `json:"jti"` }
AccessToken represents a token obtained after validating client id and secret.
type AttributeType ¶
type ChallengeCode ¶
type ChallengeCode struct {
Code string `json:"code"`
}
type ClaimResult ¶
type ClaimResult struct { ID string `json:"id"` Result string `json:"result"` Message string `json:"message"` }
ClaimResult contains useful information after claiming obects.
type ClientRequest ¶
type ClientRequest struct {
// contains filtered or unexported fields
}
ClientRequest is an internal structure to help with making HTTP requests to SmartObjects.
type CompressionConfig ¶
CompressionConfig is used to compress requests and / or response to / from the SmartObjects platform.
type DataModel ¶
type DataModel struct { ObjectTypes []ObjectType `json:"objectTypes"` EventTypes []EventType `json:"eventTypes"` OwnerAttributes []OwnerAttribute `json:"ownerAttributes"` Sessionizers []Sessionizer `json:"sessionizers"` Orphans struct { Timeseries []Timeseries `json:"timeseries"` } `json:"orphans,omitempty"` Enrichers map[string][]string `json:"enrichers,omitempty"` ReservedEnrichersFields []string `json:"reservedEnrichersFields,omitempty"` }
type Dataset ¶
type Dataset struct { Key string `json:"key"` Description interface{} `json:"description"` DisplayName string `json:"displayName"` Fields []struct { Key string `json:"key"` HighLevelType string `json:"highLevelType"` DisplayName string `json:"displayName"` Description string `json:"description"` ContainerType string `json:"containerType"` PrimaryKey bool `json:"primaryKey"` } `json:"fields"` }
Dataset is the main structure used to make queries to SmartObjects. Its key represent the "From" to use when making queries.
type EntitiesExist ¶
EntitiesExist is an array of map useful when checking if events, objects or owners exist.
type Events ¶
type Events struct {
Mnubo *Mnubo
}
Events is a helper to Mnubo client which contains Events related functions.
func (*Events) Exists ¶
func (e *Events) Exists(eventIds []string, results *EntitiesExist) error
Exists checks if an event has already been submitted. See: https://smartobjects.mnubo.com/documentation/api_ingestion.html#post-api-v3-events-exists
func (*Events) Send ¶
func (e *Events) Send(events interface{}, options SendEventsOptions, results interface{}) error
Send allows to post events to SmartObjects. The events payload depends on the data model. See: https://smartobjects.mnubo.com/documentation/api_ingestion.html#post-api-v3-events
func (*Events) SendFromDevice ¶
func (e *Events) SendFromDevice(deviceId string, events interface{}, options SendEventsOptions, results interface{}) error
SendFromDevice allows to post events to SmartObjects from one device. See: https://smartobjects.mnubo.com/documentation/api_ingestion.html#post-api-v3-objects-x-device-id-events
type ExponentialBackoffConfig ¶
type ExponentialBackoffConfig struct { // After MaxElapsedTime the ExponentialBackOff stops. // It never stops if MaxElapsedTime == 0. MaxElapsedTime time.Duration // Callback called between retries when the platform is not available. // It will not be called if value is nil. NotifyOnError func(error, time.Duration) }
ExponentialBackoffConfig is used to configure exponential backoff. You should not need to configure this, but it's available if you require further tweaking.
type Mnubo ¶
type Mnubo struct { ClientId string ClientSecret string ClientToken string Host string AccessToken AccessToken Timeout time.Duration // Timeout for HTTP requests sent to SmartObjects. Compression CompressionConfig ExponentialBackoff ExponentialBackoffConfig Model *Model Events *Events Objects *Objects Owners *Owners Search *Search CustomTransport *http.Transport }
Mnubo is the main object representing all available endpoints in SmartObjects.
func NewClientWithToken ¶
NewClientWithToken creates a new Mnubo structure based on a static token.
func (*Mnubo) GetAccessToken ¶
func (m *Mnubo) GetAccessToken() (AccessToken, error)
GetAccessToken fetches a new AccessToken with scope ALL.
func (*Mnubo) GetAccessTokenWithScope ¶
func (m *Mnubo) GetAccessTokenWithScope(scope string) (AccessToken, error)
GetAccessTokenWithScope fetches a new AccessToken with specified scope.
type Model ¶
type Model struct {
Mnubo *Mnubo
}
Model is a helper to Mnubo client which contains Model related functions.
func (*Model) AddEventTypeRelation ¶
Add a relation to a timeseries. See: https://smartobjects.mnubo.com/documentation/api_modeler.html#linking-a-timeseries-to-an-event-type
func (*Model) AddObjectTypeRelation ¶
Add a relation to an object attribute. See: https://smartobjects.mnubo.com/documentation/api_modeler.html#linking-an-attribute-to-an-object-type
func (*Model) ApplyObjectAttributeDeployCode ¶
func (m *Model) ApplyObjectAttributeDeployCode(key string, cc ChallengeCode) error
ApplyObjectAttributeDeployCode applies the challenge code to deploy the attribute to production. See: https://smartobjects.mnubo.com/documentation/api_modeler.html#id11
func (*Model) ApplyOwnerAttributeDeployCode ¶
func (m *Model) ApplyOwnerAttributeDeployCode(key string, cc ChallengeCode) error
ApplyOwnerAttributeDeployCode applies the challenge code to deploy the attribute to production. See: https://smartobjects.mnubo.com/documentation/api_modeler.html#id11
func (*Model) ApplyResetCode ¶
func (m *Model) ApplyResetCode(cc ChallengeCode) error
ApplyResetCode sends the reset code for sandbox reset (if the code is valid). See: https://smartobjects.mnubo.com/documentation/api_modeler.html#part-2-using-the-code
func (*Model) ApplyTimeseriesDeployCode ¶
func (m *Model) ApplyTimeseriesDeployCode(key string, cc ChallengeCode) error
ApplyTimeseriesDeployCode applies the challenge code to deploy the timeseries to production. See: https://smartobjects.mnubo.com/documentation/api_modeler.html#part-2-challenging-code
func (*Model) CreateEventTypes ¶
CreateEventTypes creates an array of event types in the data model. See: https://smartobjects.mnubo.com/documentation/api_modeler.html#creating-event-types
func (*Model) CreateObjectAttributes ¶
func (m *Model) CreateObjectAttributes(oa []ObjectAttribute) error
CreateObjectAttributes creates new object attribute. See: https://smartobjects.mnubo.com/documentation/api_modeler.html#creating-object-attributes
func (*Model) CreateObjectTypes ¶
func (m *Model) CreateObjectTypes(ot []ObjectType) error
CreateObjectTypes creates an array of object types in the data model. See: https://smartobjects.mnubo.com/documentation/api_modeler.html#creating-object-types
func (*Model) CreateOwnerAttributes ¶
func (m *Model) CreateOwnerAttributes(oa []OwnerAttribute) error
CreateOwnerAttributes creates new owner attribute. See: https://smartobjects.mnubo.com/documentation/api_modeler.html#creating-object-attributes
func (*Model) CreateTimeseries ¶
func (m *Model) CreateTimeseries(ts []Timeseries) error
CreateTimeseries creates new timeseries to the data model. See: https://smartobjects.mnubo.com/documentation/api_modeler.html#creating-timeseries
func (*Model) DeleteEventType ¶
DeleteEventType deletes an event type from the data model. See: https://smartobjects.mnubo.com/documentation/api_modeler.html#deleting-an-event-type
func (*Model) DeleteObjectType ¶
DeleteObjectType deletes an object type from the data model. See: https://smartobjects.mnubo.com/documentation/api_modeler.html#deleting-an-object-type
func (*Model) DeployObjectAttributeToProduction ¶
DeployObjectAttributeToProduction deploys an object attribute created in sandbox to production. Making calls to GenerateObjectAttributeDeployCode and ApplyObjectAttributeDeployCode. See: https://smartobjects.mnubo.com/documentation/api_modeler.html#deploying-an-object-attribute-into-production
func (*Model) DeployOwnerAttributeToProduction ¶
DeployOwnerAttributeToProduction deploys an owner attribute created in sandbox to production. Making calls to GenerateOwnerAttributeDeployCode and ApplyOwnerAttributeDeployCode. See: https://smartobjects.mnubo.com/documentation/api_modeler.html#deploying-an-object-attribute-into-production
func (*Model) DeployTimeseriesToProduction ¶
DeployTimeseriesToProduction deploys a timeseries created in sandbox to production. Making calls to GenerateTimeseriesDeployCode and ApplyTimeseriesDeployCode. See: https://smartobjects.mnubo.com/documentation/api_modeler.html#deploying-a-timeseries-into-production
func (*Model) Export ¶
Export dumps a JSON object representing the current data model. See: https://smartobjects.mnubo.com/documentation/api_modeler.html#exporting-your-data-model
func (*Model) GenerateObjectAttributeDeployCode ¶
func (m *Model) GenerateObjectAttributeDeployCode(key string, results *ChallengeCode) error
GenerateObjectAttributeDeployCode generates a new challenge code before deploying an object attribute to production. See: https://smartobjects.mnubo.com/documentation/api_modeler.html#id10
func (*Model) GenerateOwnerAttributeDeployCode ¶
func (m *Model) GenerateOwnerAttributeDeployCode(key string, results *ChallengeCode) error
GenerateOwnerAttributeDeployCode generates a new challenge code before deploying an owner attribute to production. See: https://smartobjects.mnubo.com/documentation/api_modeler.html#id10
func (*Model) GenerateResetCode ¶
func (m *Model) GenerateResetCode(results *ChallengeCode) error
GenerateResetCode generates a new code that must be used in order to reset a data model in sandbox. See: https://smartobjects.mnubo.com/documentation/api_modeler.html#resetting-your-sandbox-data-model
func (*Model) GenerateTimeseriesDeployCode ¶
func (m *Model) GenerateTimeseriesDeployCode(key string, results *ChallengeCode) error
GenerateTimeseriesDeployCode generates a new challenge code before deploying a timeseries to production. See: https://smartobjects.mnubo.com/documentation/api_modeler.html#part-1-getting-code
func (*Model) GetEventTypes ¶
GetEventTypes retrieves the event types of the data model. See: https://smartobjects.mnubo.com/documentation/api_modeler.html#getting-all-event-types
func (*Model) GetObjectAttributes ¶
func (m *Model) GetObjectAttributes(results *[]ObjectAttribute) error
GetObjectAttributes retrieves the object attributes of the data model. See: https://smartobjects.mnubo.com/documentation/api_modeler.html#getting-all-object-attributes
func (*Model) GetObjectTypes ¶
func (m *Model) GetObjectTypes(results *[]ObjectType) error
GetObjectTypes retrieves the object types of the data model. See: https://smartobjects.mnubo.com/documentation/api_modeler.html#getting-all-event-types
func (*Model) GetOwnerAttributes ¶
func (m *Model) GetOwnerAttributes(results *[]OwnerAttribute) error
GetOwnerAttributes retrieves the owner attributes of the data model. See: https://smartobjects.mnubo.com/documentation/api_modeler.html#getting-all-owner-attributes
func (*Model) GetTimeseries ¶
func (m *Model) GetTimeseries(results *[]Timeseries) error
GetTimeseries retrieves the timeseries of the data model. See: https://smartobjects.mnubo.com/documentation/api_modeler.html#getting-all-timeseries
func (*Model) RemoveEventTypeRelation ¶
Remove a relation to a timeseries. See: https://smartobjects.mnubo.com/documentation/api_modeler.html#deleting-the-link-between-a-timeseries-and-an-event-type
func (*Model) RemoveObjectTypeRelation ¶
Remove a relation to an object attribute. See: https://smartobjects.mnubo.com/documentation/api_modeler.html#deleting-the-link-between-an-attribute-and-an-object-type
func (*Model) ResetDataModel ¶
ResetDataModel performs both GenerateResetCode and ApplyResetCode at the same time for convenience.
func (*Model) UpdateEventType ¶
UpdateEventType updates an event type in the data model. See: https://smartobjects.mnubo.com/documentation/api_modeler.html#updating-an-event-type
func (*Model) UpdateObjectAttribute ¶
func (m *Model) UpdateObjectAttribute(key string, oa ObjectAttribute) error
UpdateObjectAttribute updates the DisplayName and Description (only those) from an object attribute. See: https://smartobjects.mnubo.com/documentation/api_modeler.html#updating-an-object-attribute
func (*Model) UpdateObjectType ¶
func (m *Model) UpdateObjectType(key string, ot ObjectType) error
UpdateObjectType updates an object type in the data model. See: https://smartobjects.mnubo.com/documentation/api_modeler.html#updating-an-object-type
func (*Model) UpdateOwnerAttribute ¶
func (m *Model) UpdateOwnerAttribute(key string, oa OwnerAttribute) error
UpdateOwnerAttribute updates the DisplayName and Description (only those) from an owner attribute. See: https://smartobjects.mnubo.com/documentation/api_modeler.html#updating-an-object-attribute
func (*Model) UpdateTimeseries ¶
func (m *Model) UpdateTimeseries(key string, ts Timeseries) error
UpdateTimeseries updates the DisplayName and Description (only those) from a Timeseries. See: https://smartobjects.mnubo.com/documentation/api_modeler.html#updating-timeseries
type ObjectAttribute ¶
type ObjectAttribute struct { Key string `json:"key"` DisplayName string `json:"displayName"` Description string `json:"description"` Type AttributeType `json:"type,omitempty"` ObjectTypeKeys []string `json:"objectTypeKeys,omitempty"` }
type ObjectOwnerPair ¶
type ObjectOwnerPair struct { XDeviceID string `json:"x_device_id"` Username string `json:"username"` }
ObjectOwnerPair can be used to claim and unclaim devices.
type ObjectType ¶
type ObjectType struct { Key string `json:"key"` DisplayName string `json:"displayName"` Description string `json:"description"` ObjectAttributesKeys []string `json:"objectAttributesKeys,omitempty"` ObjectAttributes []ObjectAttribute `json:"objectAttributes,omitempty"` }
type Objects ¶
type Objects struct {
Mnubo *Mnubo
}
Objects is a helper to Mnubo client which contains Objects related functions.
func NewObjects ¶
NewObjects creates an Objects wrapper for Mnubo client.
func (*Objects) Create ¶
Create creates an object to SmartObjects. The objects payload is based on the data model. See: https://smartobjects.mnubo.com/documentation/api_ingestion.html#post-api-v3-objects
func (*Objects) Delete ¶
Delete deletes an object See: https://smartobjects.mnubo.com/documentation/api_ingestion.html#delete-api-v3-objects-x-device-id
func (*Objects) Exist ¶
func (o *Objects) Exist(deviceIds []string, results *EntitiesExist) error
Exist checks if an array of objects have been created. See: https://smartobjects.mnubo.com/documentation/api_ingestion.html#post-api-v3-objects-exists
func (*Objects) Update ¶
Update creates and / or updates a batch of objects at once. See: https://smartobjects.mnubo.com/documentation/api_ingestion.html#put-api-v3-objects-batch
type OwnerAttribute ¶
type OwnerAttribute struct { Key string `json:"key"` DisplayName string `json:"displayName"` Description string `json:"description"` Type AttributeType `json:"type"` }
type Owners ¶
type Owners struct {
Mnubo *Mnubo
}
Owners is a helper to Mnubo client which contains Owners related functions.
func (*Owners) Claim ¶
func (o *Owners) Claim(pairs []ObjectOwnerPair, results *[]ClaimResult) error
Claim claims an array of object / owner pair. See: https://smartobjects.mnubo.com/documentation/api_ingestion.html#post-api-v3-owners-claim-batch
func (*Owners) Create ¶
Create creates a new owner to SmartObjects. The owner payload is based on the data model. See: https://smartobjects.mnubo.com/documentation/api_ingestion.html#post-api-v3-owners
func (*Owners) Delete ¶
Delete deletes an owner from SmartObjects. See: https://smartobjects.mnubo.com/documentation/api_ingestion.html#delete-api-v3-owners-username
func (*Owners) Exist ¶
func (o *Owners) Exist(usernames []string, results *EntitiesExist) error
Exist checks if an array of owners exist in SmartObjects. See: https://smartobjects.mnubo.com/documentation/api_ingestion.html#get-api-v3-owners-exists-username
func (*Owners) Unclaim ¶
func (o *Owners) Unclaim(pairs []ObjectOwnerPair, results *[]ClaimResult) error
Unclaim unclaims an array of object / owner pair. See: https://smartobjects.mnubo.com/documentation/api_ingestion.html#post-api-v3-owners-unclaim-batch
func (*Owners) Update ¶
Update creates and / or updates a batch of owners at once. See: https://smartobjects.mnubo.com/documentation/api_ingestion.html#put-api-v3-owners-batch
func (*Owners) UpdateOwnerPassword ¶
UpdateOwnerPassword updates an owner password. See: https://smartobjects.mnubo.com/documentation/api_ingestion.html#put-api-v3-owners-username-password
type PasswordUpdatePayload ¶
type PasswordUpdatePayload struct {
XPassword string `json:"x_password"`
}
PasswordUpdatePayload helps building the update password function.
type QueryValidation ¶
type QueryValidation struct { IsValid bool `json:"isValid"` ValidationErrors []string `json:"validationErrors"` }
QueryValidation is a helper structure that contains useful information about MQL queries validity.
type Search ¶
type Search struct {
Mnubo *Mnubo
}
Search is a helper to Mnubo client which contains Search related functions.
func (*Search) CreateBasicQuery ¶
CreateBasicQuery is the main function to make analytics queries to SmartObjects. Its mql data structure varies depending on the data model. This method trust the user will use the proper structure based on its model. See: https://smartobjects.mnubo.com/documentation/api_search.html#basic
func (*Search) CreateBasicQueryWithBytes ¶
CreateBasicQueryWithString is a helper to use an array of bytes.
func (*Search) CreateBasicQueryWithString ¶
CreateBasicQueryWithString is a helper to use a string instead of creating a dedicated structure.
func (*Search) GetDatasets ¶
GetDatasets returns an array of SmartObjects datasets to perform queries.
func (*Search) ValidateQuery ¶
func (s *Search) ValidateQuery(mql interface{}, results *QueryValidation) error
ValidateQuery is the main function to use to understand why an MQL query is not valid. See: https://smartobjects.mnubo.com/documentation/api_search.html#validate
func (*Search) ValidateQueryWithBytes ¶
func (s *Search) ValidateQueryWithBytes(mql []byte, results *QueryValidation) error
ValidateQueryWithBytes is a helper that allows to send bytes.
func (*Search) ValidateQueryWithString ¶
func (s *Search) ValidateQueryWithString(mql string, results *QueryValidation) error
ValidateQueryWithString is a helper that allows to send a string instead of creating a dedicated structure.
type SearchResults ¶
type SearchResults struct { Columns []SearchResultsColumn `json:"columns"` Rows [][]interface{} `json:"rows"` }
SearchResults is the main structure that contain results after a valid query has been sent.
type SearchResultsColumn ¶
SearchResultsColumn is the definition of the a SearchResults column.
type SendEventsOptions ¶
SendEventsOptions helps configure the Send events function.
type SendEventsReport ¶
type SendEventsReport struct { ID string `json:"id"` Result string `json:"result"` ObjectExists bool `json:"objectExists"` }
SendEventsReport contains information when sending events with ReportResults set to true.
type Sessionizer ¶
type Timeseries ¶
type Timeseries struct { Key string `json:"key,omitempty"` DisplayName string `json:"displayName"` Description string `json:"description"` EventTypeKeys []string `json:"eventTypeKeys,omitempty"` Type TimeseriesType `json:"type,omitempty"` }
type TimeseriesType ¶
type TimeseriesType struct {
HighLevelType string `json:"highLevelType"`
}