c8y

package
v0.15.10 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 26, 2024 License: MIT Imports: 42 Imported by: 356

Documentation

Index

Constants

View Source
const (
	AlarmSeverityCritical = "CRITICAL"
	AlarmSeverityMajor    = "MAJOR"
	AlarmSeverityMinor    = "MINOR"
	AlarmSeverityWarning  = "WARNING"
)

Cumulocity alarm Severity types

View Source
const (
	AlarmStatusActive       = "ACTIVE"
	AlarmStatusAcknowledged = "ACKNOWLEDGED"
	AlarmStatusCleared      = "CLEARED"
)

Cumulocity alarm status states

View Source
const (
	ApplicationTypeMicroservice = "MICROSERVICE"
	ApplicationTypeExternal     = "EXTERNAL"
	ApplicationTypeHosted       = "HOSTED"
	ApplicationTypeApamaCEPRule = "APAMA_CEP_RULE"
)

Cumulocity Application Types

View Source
const (
	ApplicationAvailabilityMarket  = "MARKET"
	ApplicationAvailabilityPrivate = "PRIVATE"
	ApplicationAvailabilityShared  = "SHARED"
)

Cumulocity Application Availability values

View Source
const (
	// AuthMethodOAuth2Internal OAuth2 internal mode
	AuthMethodOAuth2Internal = "OAUTH2_INTERNAL"

	// AuthMethodBasic Basic authentication
	AuthMethodBasic = "BASIC"

	// AuthMethodNone no authentication
	AuthMethodNone = "NONE"
)
View Source
const (
	NewDeviceRequestWaitingForConnection = "WAITING_FOR_CONNECTION"
	NewDeviceRequestPendingAcceptance    = "PENDING_ACCEPTANCE"
	NewDeviceRequestAccepted             = "ACCEPTED"
)

Cumulocity New Device Request statuses

View Source
const (
	EnvironmentBootstrapTenant   = "C8Y_BOOTSTRAP_TENANT"
	EnvironmentBootstrapUsername = "C8Y_BOOTSTRAP_USER"
	EnvironmentBootstrapPassword = "C8Y_BOOTSTRAP_PASSWORD"
)

Application Bootstrap User Environment variables

View Source
const (
	EnvironmentApplicationName = "APPLICATION_NAME"
	EnvironmentBaseURL         = "C8Y_BASEURL"
	EnvironmentTenant          = "C8Y_TENANT"
	EnvironmentUsername        = "C8Y_USER"
	EnvironmentPassword        = "C8Y_PASSWORD"
)

Application Environment variables

View Source
const (
	OperationStatusPending    = "PENDING"
	OperationStatusExecuting  = "EXECUTING"
	OperationStatusSuccessful = "SUCCESSFUL"
	OperationStatusFailed     = "FAILED"
)

Cumulocity Operation Status states

View Source
const (
	// VERSION preferred Bayeux version
	VERSION = "1.0"

	// MINIMUMVERSION supported Bayeux version
	MINIMUMVERSION = "1.0"

	// MinimumRetryDelay is the minimum retry delay in milliseconds to wait before sending another /meta/connect message
	MinimumRetryDelay int64 = 500
)
View Source
const (
	// MaximumRetryInterval is the maximum interval (in seconds) between reconnection attempts
	MaximumRetryInterval int64 = 30

	// MinimumRetryInterval is the minimum interval (in seconds) between reconnection attempts
	MinimumRetryInterval int64 = 5

	// RetryBackoffFactor is the backoff factor applied to the retry interval for every unsuccessful reconnection attempt.
	// i.e. the next retry interval is calculated as followins
	// interval = MinimumRetryInterval
	// interval = Min(MaximumRetryInterval, interval * RetryBackoffFactor)
	RetryBackoffFactor float64 = 1.5
)
View Source
const CumulocityUIManifestFile = "cumulocity.json"
View Source
const DeviceFragmentName = "c8y_IsDevice"

DeviceFragmentName name of the c8yDevice Fragment property

View Source
const (
	EnvironmentMicroserviceIsolation = "C8Y_MICROSERVICE_ISOLATION"
)

Microservice environment variables

View Source
const FragmentFirmware = "c8y_Firmware"
View Source
const FragmentFirmwareBinary = "c8y_FirmwareBinary"
View Source
const FragmentSoftware = "c8y_Software"
View Source
const FragmentSoftwareBinary = "c8y_SoftwareBinary"
View Source
const (
	// RetentionRuleAPI base endpoint
	RetentionRuleAPI = "retention/retentions"
)
View Source
const TimeFormat = "Mon, 02 Jan 2006 15:04:05 GMT"

Variables

View Source
var ApplicationTagLatest = "latest"
View Source
var ContentTypeApplicationVersion = "application/vnd.com.nsn.cumulocity.applicationVersion+json"
View Source
var ContentTypeApplicationVersionCollection = "application/vnd.com.nsn.cumulocity.applicationVersionCollection+json"
View Source
var (
	// EnvVarLoggerHideSensitive environment variable name used to control whethere sensitive session information is logged or not. When set to "true", then the tenant, username, password, base 64 passwords will be obfuscated from the log messages
	EnvVarLoggerHideSensitive = "C8Y_LOGGER_HIDE_SENSITIVE"
)
View Source
var ErrNotFound = errors.New("item: not found")

Logger used within the c8y client

View Source
var (
	MinTokenMinutes int64 = 1
)

Functions

func CheckResponse

func CheckResponse(r *http.Response) error

CheckResponse checks the API response for errors, and returns them if present. A response is considered an error if it has a status code outside the 200 range or equal to 202 Accepted. API error responses are expected to have either no response body, or a JSON response body that maps to ErrorResponse. Any other response body will be silently ignored.

func DecodeJSONBytes

func DecodeJSONBytes(v []byte, dst interface{}) error

DecodeJSONBytes decodes json preserving number formatting (especially large integers and scientific notation floats)

func DecodeJSONFile

func DecodeJSONFile(filepath string, dst interface{}) error

DecodeJSONFile decodes a json file into dst interface

func DecodeJSONReader

func DecodeJSONReader(r io.Reader, dst interface{}) error

DecodeJSONReader decodes bytes using a reader interface

Note: Decode with the UseNumber() set so large or scientific notation numbers are not wrongly converted to integers! i.e. otherwise this conversion will happen (which causes a problem with mongodb!)

9.2233720368547758E+18 --> 9223372036854776000

func GetBootstrapUserFromEnvironment

func GetBootstrapUserFromEnvironment() (tenant, username, password string)

GetBootstrapUserFromEnvironment returns the tenant, username and password set in environment variables (used by the microservice)

func GetDateRange

func GetDateRange(dateInterval string) (string, string)

GetDateRange returns the dateFrom and dateTo based on an interval string, i.e. 1d, is 1 day

func GetRoundedTime

func GetRoundedTime(date *time.Time, unit string) (roundTime time.Time)

GetRoundedTime Get the rounded timestamp (i.e. start of the hour, start of the minute, start of the day)

func GetServiceUserFromEnvironment

func GetServiceUserFromEnvironment() (tenant, username, password string)

GetServiceUserFromEnvironment returns the service user information (tenant, username and password) from environment variables.

func GetUIExtensionManifestContents added in v0.15.0

func GetUIExtensionManifestContents(zipFilename string, contents interface{}) error

func HasTag added in v0.15.10

func HasTag(tags []string, tag string) bool

func IsID added in v0.14.0

func IsID(v string) bool

IsID check if a string is most likely an id

func NewAuthorizationContext

func NewAuthorizationContext(tenant, username, password string) context.Context

NewAuthorizationContext returns context with the Authorization token set given explicit tenant, username and password.

func NewAuthorizationContextFromRequest

func NewAuthorizationContextFromRequest(req *http.Request) context.Context

NewAuthorizationContextFromRequest returns a new context with the Authorization token set which will override the Basic Auth in subsequent REST requests

func NewBasicAuthString

func NewBasicAuthString(tenant, username, password string) string

NewBasicAuthString returns a Basic Authorization key used for rest requests

func NewCachedClient added in v0.14.0

func NewCachedClient(httpClient *http.Client, cacheDir string, cacheTTL time.Duration, isCacheable Cacheable, opts CacheOptions) *http.Client

func NewHTTPClient added in v0.14.0

func NewHTTPClient(opts ...ClientOption) *http.Client

NewHTTPClient initializes an http.Client which can be then provided to the NewClient

func RealtimeAlarms

func RealtimeAlarms(id ...string) string

RealtimeAlarms subscribes to events on alarms objects from the CEP realtime engine

func RealtimeAlarmsWithChildren

func RealtimeAlarmsWithChildren(id ...string) string

RealtimeAlarmsWithChildren subscribes to events on alarms (including children) objects from the CEP realtime engine

func RealtimeEvents

func RealtimeEvents(id ...string) string

RealtimeEvents subscribes to events on event objects from the CEP realtime engine

func RealtimeManagedObjects

func RealtimeManagedObjects(id ...string) string

RealtimeManagedObjects subscribes to events on managed objects from the CEP realtime engine

func RealtimeMeasurements

func RealtimeMeasurements(id ...string) string

RealtimeMeasurements subscribes to events on measurement objects from the CEP realtime engine

func RealtimeOperations

func RealtimeOperations(id ...string) string

RealtimeOperations subscribes to events on operations objects from the CEP realtime engine

func RequestSupportsBody added in v0.14.0

func RequestSupportsBody(method string) bool

Check if method supports a body with the request

func SilenceLogger added in v0.8.0

func SilenceLogger()

SilenceLogger causes all log messages to be hidden

func UnsilenceLogger added in v0.14.0

func UnsilenceLogger()

UnsilenceLogger enables the logger (opposite of Silence logger)

func Upload

func Upload(client *http.Client, url string, values map[string]io.Reader) (err error)

Upload performs a http binary upload

func WithCommonOptionsContext added in v0.14.9

func WithCommonOptionsContext(ctx context.Context, opts CommonOptions) context.Context

Create a context with common options

func WithDisabledDryRunContext added in v0.14.9

func WithDisabledDryRunContext(ctx context.Context) context.Context

Create a context where dry run is disabled

Types

type AdditionParents added in v0.14.0

type AdditionParents struct {
	Self       string                   `json:"self"`
	References []ManagedObjectReference `json:"references"`
}

type Agent

Agent is a subset of a managed object

func NewAgent

func NewAgent(name string) *Agent

NewAgent returns a simple agent managed object

type AgentConfiguration

type AgentConfiguration struct {
	Configuration string `json:"config"`
}

AgentConfiguration agent configuration fragment

type AgentFragment

type AgentFragment struct {
	AgentFragment struct{} `json:"com_cumulocity_model_Agent"`
}

AgentFragment is the special agent fragment used to identify managed objects which are representations of an Agent.

type Alarm

type Alarm struct {
	ID                  string     `json:"id,omitempty"`
	Source              *Source    `json:"source,omitempty"`
	Type                string     `json:"type,omitempty"`
	Time                *Timestamp `json:"time,omitempty"`
	CreationTime        *Timestamp `json:"creationTime,omitempty"`
	FirstOccurrenceTime *Timestamp `json:"firstOccurrenceTime,omitempty"`
	Text                string     `json:"text,omitempty"`
	Status              string     `json:"status,omitempty"`
	Severity            string     `json:"severity,omitempty"`
	Count               uint64     `json:"count,omitempty"`
	Self                string     `json:"self,omitempty"`

	// Allow access to custom fields
	Item gjson.Result `json:"-"`
}

Alarm representation

type AlarmBuilder

type AlarmBuilder struct {
	// contains filtered or unexported fields
}

AlarmBuilder represents a alarm where the mandatory properties are set via its constructor NewAlarmBuilder

func NewAlarmBuilder

func NewAlarmBuilder(deviceID string, typeName string, text string) *AlarmBuilder

NewAlarmBuilder returns a new alarm builder with the required fields set. The alarm will have a timestamp set to Now(). The timestamp can be set to another timestamp by using SetTimestamp() The alarm will have a default severity of MAJOR, but it can be changed by using .SetSeverity functions

func (AlarmBuilder) DeviceID

func (b AlarmBuilder) DeviceID() string

DeviceID returns the device id of the alarm

func (AlarmBuilder) Get

func (b AlarmBuilder) Get(name string) (interface{}, bool)

Get returns the given property value. If the property does not exist, then the second parameter will be set to false

func (AlarmBuilder) MarshalJSON

func (b AlarmBuilder) MarshalJSON() ([]byte, error)

MarshalJSON returns the given event in json format

func (*AlarmBuilder) Set

func (b *AlarmBuilder) Set(name string, value interface{}) *AlarmBuilder

Set sets the name property with the given value

func (*AlarmBuilder) SetDeviceID

func (b *AlarmBuilder) SetDeviceID(ID string) *AlarmBuilder

SetDeviceID sets the device id for the alarm

func (*AlarmBuilder) SetSeverityCritical

func (b *AlarmBuilder) SetSeverityCritical() *AlarmBuilder

SetSeverityCritical sets the alarm severity to Critical

func (*AlarmBuilder) SetSeverityMajor

func (b *AlarmBuilder) SetSeverityMajor() *AlarmBuilder

SetSeverityMajor sets the alarm severity to Major

func (*AlarmBuilder) SetSeverityMinor

func (b *AlarmBuilder) SetSeverityMinor() *AlarmBuilder

SetSeverityMinor sets the alarm severity to Minor

func (*AlarmBuilder) SetSeverityWarning

func (b *AlarmBuilder) SetSeverityWarning() *AlarmBuilder

SetSeverityWarning sets the alarm severity to Warning

func (*AlarmBuilder) SetText

func (b *AlarmBuilder) SetText(ID string) *AlarmBuilder

SetText sets the alarm text

func (*AlarmBuilder) SetTimestamp

func (b *AlarmBuilder) SetTimestamp(value *Timestamp) *AlarmBuilder

SetTimestamp sets the timestamp when the event was created. If the value is nil, then the current timestamp will be used

func (*AlarmBuilder) SetType

func (b *AlarmBuilder) SetType(ID string) *AlarmBuilder

SetType sets the alarm type

func (AlarmBuilder) Severity

func (b AlarmBuilder) Severity() string

Severity returns the alarm severity

func (AlarmBuilder) Text

func (b AlarmBuilder) Text() string

Text returns the device id of the alarm

func (AlarmBuilder) Timestamp

func (b AlarmBuilder) Timestamp() Timestamp

Timestamp returns the timestamp of the alarm

func (AlarmBuilder) Type

func (b AlarmBuilder) Type() string

Type returns the alarm type

type AlarmCollection

type AlarmCollection struct {
	*BaseResponse

	Alarms []Alarm `json:"alarms"`

	Items []gjson.Result `json:"-"`
}

AlarmCollection todo

type AlarmCollectionOptions

type AlarmCollectionOptions struct {
	// Source device to filter measurements by
	Source string `url:"source,omitempty"`

	// DateFrom Timestamp `url:"dateFrom,omitempty"`
	DateFrom string `url:"dateFrom,omitempty"`

	DateTo string `url:"dateTo,omitempty"`

	Type string `url:"type,omitempty"`

	FragmentType string `url:"fragmentType,omitempty"`

	Status string `url:"status,omitempty"`

	Severity string `url:"severity,omitempty"`

	Resolved bool `url:"resolved,omitempty"`

	WithAssets bool `url:"withAssets,omitempty"`

	WithDevices bool `url:"withDevices,omitempty"`

	PaginationOptions
}

AlarmCollectionOptions to use when search for alarms

type AlarmService

type AlarmService service

AlarmService provides api to get/set/delete alarms in Cumulocity

func (*AlarmService) BulkUpdateAlarms

func (s *AlarmService) BulkUpdateAlarms(ctx context.Context, status string, opts AlarmUpdateOptions) (*Response, error)

BulkUpdateAlarms bulk update of alarm collection The PUT method allows for updating alarms collections. Currently only the status of alarms can be changed. Response status: 200 - if the process has completed, all alarms have been updated 202 - if process continues in background

Since this operations can take a lot of time, request returns after maximum 0.5 sec of processing, and updating is continued as a background process in the platform.

func (*AlarmService) Create

func (s *AlarmService) Create(ctx context.Context, body interface{}) (*Alarm, *Response, error)

Create creates a new alarm object

func (*AlarmService) DeleteAlarms

func (s *AlarmService) DeleteAlarms(ctx context.Context, opt *AlarmCollectionOptions) (*Response, error)

DeleteAlarms removes a list of alarms using the specified search options

func (*AlarmService) GetAlarm

func (s *AlarmService) GetAlarm(ctx context.Context, ID string) (*Alarm, *Response, error)

GetAlarm returns an alarm object by its ID

func (*AlarmService) GetAlarms

GetAlarms returns a collection of alarms using the specified search options

func (*AlarmService) Update

Update updates specific properties for an existing alarm Changes to alarms will generate a new audit record. The audit record will include the username and application that triggered the update, if applicable. To get the list of audits for alarm, use the following request: GET /audit/auditRecords?source=

Please notice that if update actually doesn't change anything (i.e. request body contains data that is identical to already present in database), there will be no audit record added and no notifications will be sent.

Only text, status, severity and custom properties can be modified. Non-modifiable fields will be ignored when provided in request. Required : ROLE_ALARM_ADMIN or owner of source object

type AlarmUpdateOptions

type AlarmUpdateOptions struct {
	// Status alarm status filter
	Status string `url:"status,omitempty"`

	// Source device to filter measurements by
	Source string `url:"source,omitempty"`

	Resolved bool `url:"resolved,omitempty"`

	Severity string `url:"severity,omitempty"`

	// DateFrom Timestamp `url:"dateFrom,omitempty"`
	DateFrom string `url:"dateFrom,omitempty"`

	DateTo string `url:"dateTo,omitempty"`
}

AlarmUpdateOptions option which can be used to filter when updating alarms

type AlarmUpdateProperties

type AlarmUpdateProperties struct {
	Text     string `json:"text,omitempty"`
	Status   string `json:"status,omitempty"`
	Severity string `json:"severity,omitempty"`
}

AlarmUpdateProperties properties which can be updated on an existing alarm

type Application

type Application struct {
	ID                string            `json:"id,omitempty"`
	Key               string            `json:"key,omitempty"`
	Name              string            `json:"name,omitempty"`
	Type              string            `json:"type,omitempty"`
	Availability      string            `json:"availability,omitempty"`
	Self              string            `json:"self,omitempty"`
	ContextPath       string            `json:"contextPath,omitempty"`
	ExternalURL       string            `json:"externalUrl,omitempty"`
	ResourcesURL      string            `json:"resourcesUrl,omitempty"`
	ResourcesUsername string            `json:"resourcesUsername,omitempty"`
	ResourcesPassword string            `json:"resourcesPassword,omitempty"`
	Owner             *ApplicationOwner `json:"owner,omitempty"`

	// Hosted application
	ActiveVersionID string `json:"activeVersionId,omitempty"`

	// Microservice roles
	RequiredRoles []string `json:"requiredRoles,omitempty"`
	Roles         []string `json:"roles,omitempty"`

	// Application versions
	ApplicationVersions []ApplicationVersion `json:"applicationVersions,omitempty"`

	Item gjson.Result `json:"-"`
}

Application todo

func NewApplicationMicroservice

func NewApplicationMicroservice(name string) *Application

NewApplicationMicroservice returns a new microservice application representation

type ApplicationCollection

type ApplicationCollection struct {
	*BaseResponse

	Applications []Application `json:"applications"`

	Items []gjson.Result `json:"-"`
}

ApplicationCollection contains information about a list of applications

type ApplicationOptions

type ApplicationOptions struct {
	PaginationOptions

	Name         string `url:"name,omitempty"`
	Owner        string `url:"owner,omitempty"`
	ProviderFor  string `url:"providerFor,omitempty"`
	Subscriber   string `url:"subscriber,omitempty"`
	Tenant       string `url:"tenant,omitempty"`
	Type         string `url:"type,omitempty"`
	User         string `url:"user,omitempty"`
	Availability string `url:"availability,omitempty"`
	HasVersions  *bool  `url:"hasVersions,omitempty"`
}

ApplicationOptions options that can be provided when using application api calls

func (*ApplicationOptions) WithHasVersions added in v0.14.12

func (o *ApplicationOptions) WithHasVersions(v bool) *ApplicationOptions

type ApplicationOwner

type ApplicationOwner struct {
	Self   string                      `json:"self,omitempty"`
	Tenant *ApplicationTenantReference `json:"tenant,omitempty"`
}

ApplicationOwner application owner

type ApplicationReference

type ApplicationReference struct {
	Self        string       `json:"self,omitempty"`
	Application *Application `json:"application"`
}

type ApplicationReferenceCollection

type ApplicationReferenceCollection struct {
	*BaseResponse
	References []ApplicationReference `json:"references,omitempty"`
	Self       string                 `json:"self,omitempty"`
}

type ApplicationService

type ApplicationService service

ApplicationService provides the service provider for the Cumulocity Application API

func (*ApplicationService) Copy

Copy creates a new application based on an already existing one The properties are copied to the newly created application. For name, key and context path a "clone" prefix is added in order to be unique. If the target application is hosted and has an active version, the new application will have the active version with the same content. The response contains a representation of the newly created application.

func (*ApplicationService) Create

Create adds a new application to Cumulocity

func (*ApplicationService) CreateBinary

func (s *ApplicationService) CreateBinary(ctx context.Context, filename string, ID string) (*Response, error)

CreateBinary uploads a binary For the applications of type "microservice", "web application" and "custom Apama rule" to be available for Cumulocity platform users, a binary zip file must be uploaded. For the microservice application, the zip file must consist of:

  • cumulocity.json - file describing the deployment
  • image.tar - executable docker image

For the web application, the zip file must include index.html in the root directory. For the custom Apama rule application, the zip file must consist of a single .mon file.

func (*ApplicationService) Delete

func (s *ApplicationService) Delete(ctx context.Context, ID string) (*Response, error)

Delete removes an existing application

func (*ApplicationService) GetApplication

func (s *ApplicationService) GetApplication(ctx context.Context, ID string) (*Application, *Response, error)

GetApplication returns an application by its ID

func (*ApplicationService) GetApplicationUser

func (s *ApplicationService) GetApplicationUser(ctx context.Context, ID string) (*ApplicationUser, *Response, error)

GetApplicationUser returns the application user for a given microservice application

func (*ApplicationService) GetApplications

GetApplications returns a list of applications with no filtering

func (*ApplicationService) GetApplicationsByName

func (s *ApplicationService) GetApplicationsByName(ctx context.Context, name string, opt *ApplicationOptions) (*ApplicationCollection, *Response, error)

GetApplicationsByName returns a list of applications by name

func (*ApplicationService) GetApplicationsByOwner

func (s *ApplicationService) GetApplicationsByOwner(ctx context.Context, tenant string, opt *ApplicationOptions) (*ApplicationCollection, *Response, error)

GetApplicationsByOwner returns a list of applications by owner

func (*ApplicationService) GetApplicationsByTenant

func (s *ApplicationService) GetApplicationsByTenant(ctx context.Context, tenant string, opt *ApplicationOptions) (*ApplicationCollection, *Response, error)

GetApplicationsByTenant returns a list of applications by tenant name

func (*ApplicationService) GetCurrentApplication

func (s *ApplicationService) GetCurrentApplication(ctx context.Context) (*Application, *Response, error)

GetCurrentApplication returns the current application. Note: Required authentication with bootstrap user

func (*ApplicationService) GetCurrentApplicationSubscriptions

func (s *ApplicationService) GetCurrentApplicationSubscriptions(ctx context.Context) (*ApplicationSubscriptions, *Response, error)

GetCurrentApplicationSubscriptions returns the list of application subscriptions per tenant along with the service user credentials This function can only be called using Application Bootstrap credentials, otherwise a 403 (forbidden) response will be returned

func (*ApplicationService) Update

Update updates an existing application

func (*ApplicationService) UpdateCurrentApplication

func (s *ApplicationService) UpdateCurrentApplication(ctx context.Context, ID string, body *Application) (*Application, *Response, error)

UpdateCurrentApplication updates the current application from a microservice using bootstrap credentials

type ApplicationSubscriptions

type ApplicationSubscriptions struct {
	Users []ServiceUser `json:"users"`

	Item gjson.Result `json:"-"`
}

ApplicationSubscriptions contains the list of service users for each application subscription

type ApplicationTenantReference

type ApplicationTenantReference struct {
	ID string `json:"id,omitempty"`
}

ApplicationTenantReference tenant reference information about the application

type ApplicationUser

type ApplicationUser struct {
	Username string `json:"name,omitempty"`
	Password string `json:"password,omitempty"`
	Tenant   string `json:"tenant,omitempty"`
}

ApplicationUser is the representation of the bootstrap user for microservices

type ApplicationVersion added in v0.15.0

type ApplicationVersion struct {
	Version  string   `json:"version,omitempty"`
	BinaryID string   `json:"binaryId,omitempty"`
	Tags     []string `json:"tags,omitempty"`

	Application *Application `json:"-,omitempty"`

	Item gjson.Result `json:"-"`
}

Application version

type ApplicationVersionsCollection added in v0.15.0

type ApplicationVersionsCollection struct {
	*BaseResponse

	Versions []ApplicationVersion `json:"applicationVersions"`

	Items []gjson.Result `json:"-"`
}

ApplicationVersionsCollection a list of versions related to an application

type ApplicationVersionsOptions added in v0.15.0

type ApplicationVersionsOptions struct {
	PaginationOptions

	Name         string `url:"name,omitempty"`
	Owner        string `url:"owner,omitempty"`
	ProviderFor  string `url:"providerFor,omitempty"`
	Subscriber   string `url:"subscriber,omitempty"`
	Tenant       string `url:"tenant,omitempty"`
	Type         string `url:"type,omitempty"`
	User         string `url:"user,omitempty"`
	Availability string `url:"availability,omitempty"`
	HasVersions  *bool  `url:"hasVersions,omitempty"`
}

ApplicationVersionsOptions options that can be provided when using application api calls

func (*ApplicationVersionsOptions) WithHasVersions added in v0.15.0

type ApplicationVersionsService added in v0.15.0

type ApplicationVersionsService service

ApplicationService provides the service provider for the Cumulocity Application API WARNING: THE UI Extension Service API is not yet finalized so expect changes in the future!

func (*ApplicationVersionsService) CreateVersion added in v0.15.0

func (s *ApplicationVersionsService) CreateVersion(ctx context.Context, ID string, filenameOrURL string, version ApplicationVersion) (*ApplicationVersion, *Response, error)

CreateVersion creates a new version of an application from a given file or url

func (*ApplicationVersionsService) CreateVersionFromReader added in v0.15.3

func (s *ApplicationVersionsService) CreateVersionFromReader(ctx context.Context, ID string, file io.Reader, version ApplicationVersion) (*ApplicationVersion, *Response, error)

CreateVersion creates a new version of an application from a given file or url

func (*ApplicationVersionsService) DeleteVersionByName added in v0.15.0

func (s *ApplicationVersionsService) DeleteVersionByName(ctx context.Context, ID string, version string) (*Response, error)

Delete removes an application version by the version name

func (*ApplicationVersionsService) DeleteVersionByTag added in v0.15.0

func (s *ApplicationVersionsService) DeleteVersionByTag(ctx context.Context, ID string, tag string) (*Response, error)

Delete removes an application version by the tag

func (*ApplicationVersionsService) GetVersionByName added in v0.15.0

func (s *ApplicationVersionsService) GetVersionByName(ctx context.Context, ID string, version string) (*ApplicationVersion, *Response, error)

Retrieve the selected version of an application in your tenant using the version name

func (*ApplicationVersionsService) GetVersionByTag added in v0.15.0

Retrieve the selected version of an application in your tenant using the tag

func (*ApplicationVersionsService) GetVersions added in v0.15.0

Retrieve all versions of an application in your tenant

func (*ApplicationVersionsService) IsUrl added in v0.15.0

func (*ApplicationVersionsService) ReplaceTags added in v0.15.0

func (s *ApplicationVersionsService) ReplaceTags(ctx context.Context, ID string, version string, tags []string) (*ApplicationVersion, *Response, error)

Replaces the tags of a given application version in your tenant

type AssetParents added in v0.14.0

type AssetParents struct {
	Self       string                   `json:"self"`
	References []ManagedObjectReference `json:"references"`
}

type AuditRecord

type AuditRecord struct {
	ID           string     `json:"id,omitempty"`
	Self         string     `json:"self,omitempty"`
	CreationTime *Timestamp `json:"creationTime,omitempty"`
	Type         string     `json:"type,omitempty"`
	Time         *Timestamp `json:"time,omitempty"`
	Text         string     `json:"text,omitempty"`
	Source       *Source    `json:"source,omitempty"`
	User         string     `json:"user,omitempty"`
	Application  string     `json:"application,omitempty"`
	Activity     string     `json:"activity,omitempty"`
	Severity     string     `json:"severity,omitempty"`

	// Allow access to custom fields
	Item gjson.Result `json:"-"`
}

AuditRecord representation

type AuditRecordCollection

type AuditRecordCollection struct {
	*BaseResponse

	AuditRecords []AuditRecord `json:"auditRecords"`

	Items []gjson.Result `json:"-"`
}

AuditRecordCollection todo

type AuditRecordCollectionOptions

type AuditRecordCollectionOptions struct {
	DateFrom string `url:"dateFrom,omitempty"`

	DateTo string `url:"dateTo,omitempty"`

	Type string `url:"type,omitempty"`

	Application string `url:"application,omitempty"`

	User string `url:"user,omitempty"`

	Revert bool `url:"revert,omitempty"`

	PaginationOptions
}

AuditRecordCollectionOptions to use when search for audit entries

type AuditService

type AuditService service

AuditService provides api to get/set/delete audit entries in Cumulocity

func (*AuditService) Create

func (s *AuditService) Create(ctx context.Context, body interface{}) (*AuditRecord, *Response, error)

Create creates a new alarm object

func (*AuditService) DeleteAuditRecords

func (s *AuditService) DeleteAuditRecords(ctx context.Context, opt *AuditRecordCollectionOptions) (*Response, error)

DeleteAuditRecords removes a collection of audit records based on search options

func (*AuditService) GetAuditRecord

func (s *AuditService) GetAuditRecord(ctx context.Context, ID string) (*AuditRecord, *Response, error)

GetAuditRecord returns a specific audit record

func (*AuditService) GetAuditRecords

GetAuditRecords returns a collection of audit records using search options

type BaseResponse

type BaseResponse struct {
	Next       *string     `json:"next"`
	Self       *string     `json:"self"`
	Statistics *Statistics `json:"statistics"`
}

BaseResponse common response from all c8y api calls

type BinaryFragment

type BinaryFragment struct {
	BinaryFragment string `json:"c8y_IsBinary"`
}

BinaryFragment marks a managed object which are binary representations Note: the binary fragment is a string, not a struct!

type CacheOptions added in v0.14.0

type CacheOptions struct {
	// ExcludeAuth excludes Authorization header value
	ExcludeAuth bool

	// ExcludeHost excludes Host from the full URL value
	ExcludeHost bool

	// Mode cache store mode which controls the read and writes into cache
	Mode StoreMode

	// BodyKeys Only cache on specific json keys on the body
	BodyKeys []string
}

CacheOptions Cache key generation options

type Cacheable added in v0.14.14

type Cacheable func(*http.Request) bool

type Certificate added in v0.14.0

type Certificate struct {
	AlgorithmName           string `json:"algorithmName"`
	CertInPemFormat         string `json:"certInPemFormat"`
	Fingerprint             string `json:"fingerprint"`
	Issuer                  string `json:"issuer"`
	Name                    string `json:"name"`
	NotAfter                string `json:"notAfter"`
	NotBefore               string `json:"notBefore"`
	Self                    string `json:"self"`
	SerialNumber            string `json:"serialNumber"`
	Status                  string `json:"status"`
	Subject                 string `json:"subject"`
	AutoRegistrationEnabled bool   `json:"autoRegistrationEnabled"`
	Version                 int    `json:"version"`
}

Certificate properties

type ChildAdditions added in v0.14.0

type ChildAdditions struct {
	Self       string                   `json:"self"`
	References []ManagedObjectReference `json:"references"`
}

type ChildAssets added in v0.14.0

type ChildAssets struct {
	Self       string                   `json:"self"`
	References []ManagedObjectReference `json:"references"`
}

type ChildDevices

type ChildDevices struct {
	Self       string                   `json:"self"`
	References []ManagedObjectReference `json:"references"`
}

ChildDevices todo

type Client

type Client struct {
	Realtime *RealtimeClient

	// Base URL for API requests. Defaults to the public Cumulocity API, but can be
	// set to a domain endpoint to use with Cumulocity. BaseURL should
	// always be specified with a trailing slash.
	BaseURL *url.URL

	// Domain. This can be different to the BaseURL when using a proxy or a custom alias
	Domain string

	// User agent used when communicating with the Cumulocity API.
	UserAgent string

	// Username for Cumulocity Authentication
	Username string

	// Cumulocity Tenant
	TenantName string

	// Cumulocity Version
	Version string

	// Password for Cumulocity Authentication
	Password string

	// Token for bearer authorization
	Token string

	// TFACode (Two Factor Authentication) code.
	TFACode string

	// Authorization method
	AuthorizationMethod string

	Cookies []*http.Cookie

	UseTenantInUsername bool

	// Microservice bootstrap and service users
	BootstrapUser ServiceUser
	ServiceUsers  []ServiceUser

	// Services used for talking to different parts of the Cumulocity API.
	Context             *ContextService
	Alarm               *AlarmService
	Audit               *AuditService
	DeviceCredentials   *DeviceCredentialsService
	Measurement         *MeasurementService
	Operation           *OperationService
	Tenant              *TenantService
	Event               *EventService
	Inventory           *InventoryService
	Application         *ApplicationService
	UIExtension         *UIExtensionService
	ApplicationVersions *ApplicationVersionsService
	Identity            *IdentityService
	Microservice        *MicroserviceService
	Notification2       *Notification2Service
	Retention           *RetentionRuleService
	TenantOptions       *TenantOptionsService
	Software            *InventorySoftwareService
	Firmware            *InventoryFirmwareService
	User                *UserService
	DeviceCertificate   *DeviceCertificateService
	// contains filtered or unexported fields
}

A Client manages communication with the Cumulocity API.

func NewClient

func NewClient(httpClient *http.Client, baseURL string, tenant string, username string, password string, skipRealtimeClient bool) *Client

NewClient returns a new Cumulocity API client. If a nil httpClient is provided, http.DefaultClient will be used. To use API methods which require authentication, provide an http.Client that will perform the authentication for you (such as that provided by the golang.org/x/oauth2 library).

func NewClientFromEnvironment

func NewClientFromEnvironment(httpClient *http.Client, skipRealtimeClient bool) *Client

NewClientFromEnvironment returns a new c8y client configured from environment variables

Environment Variables C8Y_HOST - Cumulocity host server address e.g. https://cumulocity.com C8Y_TENANT - Tenant name e.g. mycompany C8Y_USER - Username e.g. myuser@mycompany.com C8Y_PASSWORD - Password

func NewClientUsingBootstrapUserFromEnvironment

func NewClientUsingBootstrapUserFromEnvironment(httpClient *http.Client, baseURL string, skipRealtimeClient bool) *Client

NewClientUsingBootstrapUserFromEnvironment returns a Cumulocity client using the the bootstrap credentials set in the environment variables

func (*Client) DefaultDryRunHandler added in v0.14.0

func (c *Client) DefaultDryRunHandler(options *RequestOptions, req *http.Request)

DefaultDryRunHandler is the default dry run handler

func (*Client) Do

func (c *Client) Do(ctx context.Context, req *http.Request, v interface{}, middleware ...RequestMiddleware) (*Response, error)

Do sends an API request and returns the API response. The API response is JSON decoded and stored in the value pointed to by v, or returned as an error if an API error has occurred. If v implements the io.Writer interface, the raw response body will be written to v, without attempting to first decode it.

The provided ctx must be non-nil. If it is canceled or times out, ctx.Err() will be returned.

func (*Client) GetHostname added in v0.14.7

func (c *Client) GetHostname() string

Get hostname (parse from either the token)

func (*Client) GetTenantName added in v0.14.7

func (c *Client) GetTenantName(ctx context.Context) string

Get tenant name. Parse the token if exists, or a cached value, and finally the name from the server if required

func (*Client) GetUsername added in v0.14.7

func (c *Client) GetUsername() string

Get the username. Parse the token if exists

func (*Client) GetXSRFToken added in v0.14.0

func (c *Client) GetXSRFToken() string

GetXSRFToken returns the XSRF Token if found in the configured cookies

func (*Client) LoginUsingOAuth2 added in v0.14.0

func (c *Client) LoginUsingOAuth2(ctx context.Context, initRequest ...string) error

LoginUsingOAuth2 login to Cumulocity using OAuth2 and save the cookies from the response

func (*Client) NewRealtimeClientFromServiceUser

func (c *Client) NewRealtimeClientFromServiceUser(tenant string) *RealtimeClient

NewRealtimeClientFromServiceUser returns a realtime client using a microservice's service user for a specified tenant If no service user is found for the set tenant, then nil is returned

func (*Client) NewRequest

func (c *Client) NewRequest(method, path string, query string, body interface{}) (*http.Request, error)

NewRequest returns a request with the required additional base url, authentication header, accept and user-agent.NewRequest

func (*Client) NewRequestWithoutAuth added in v0.14.0

func (c *Client) NewRequestWithoutAuth(method, path string, query string, body interface{}) (*http.Request, error)

NewRequestWithoutAuth returns a request with the required additional base url, accept and user-agent.NewRequest

func (*Client) Noop

func (c *Client) Noop()

Noop todo

func (*Client) ParseToken added in v0.14.7

func (c *Client) ParseToken(tokenString string) (*CumulocityTokenClaim, error)

Parse a JWT claims

func (*Client) SendRequest

func (c *Client) SendRequest(ctx context.Context, options RequestOptions) (*Response, error)

SendRequest creates and sends a request

func (*Client) SetAuthorization

func (c *Client) SetAuthorization(req *http.Request)

SetAuthorization sets the configured authorization to the given request. By default it will set the Basic Authorization header

func (*Client) SetBasicAuthorization added in v0.14.0

func (c *Client) SetBasicAuthorization(req *http.Request)

SetBasicAuthorization sets the configured authorization to the given request. By default it will set the Basic Authorization header

func (*Client) SetBearerAuthorization added in v0.14.0

func (c *Client) SetBearerAuthorization(req *http.Request)

SetBearerAuthorization set bearer authorization header

func (*Client) SetCookies added in v0.14.0

func (c *Client) SetCookies(cookies []*http.Cookie)

SetCookies set the cookies to use for all rest requests

func (*Client) SetDomain added in v0.14.0

func (c *Client) SetDomain(v string)

Set the domain which will be used to set the Host header manually. Set the domain if it differs from the BaseURL

func (*Client) SetHostHeader added in v0.14.0

func (c *Client) SetHostHeader(req *http.Request)

func (*Client) SetJSONItems

func (c *Client) SetJSONItems(resp *Response, v interface{}) error

SetJSONItems sets the GJSON items to the input v object

func (*Client) SetRequestOptions added in v0.14.0

func (c *Client) SetRequestOptions(options DefaultRequestOptions)

SetRequestOptions sets default request options to use in all requests

func (*Client) SetToken added in v0.14.0

func (c *Client) SetToken(v string)

SetToken sets the Bearer auth token to use for all rest requests

type ClientOption added in v0.14.0

type ClientOption = func(http.RoundTripper) http.RoundTripper

ClientOption represents an argument to NewClient

func CacheResponse added in v0.14.0

func CacheResponse(ttl time.Duration, dir string, isCacheable Cacheable, options CacheOptions) ClientOption

CacheResponse produces a RoundTripper that caches HTTP responses to disk for a specified amount of time

func ReplaceTripper added in v0.14.0

func ReplaceTripper(tr http.RoundTripper) ClientOption

ReplaceTripper substitutes the underlying RoundTripper with a custom one

func WithInsecureSkipVerify added in v0.14.0

func WithInsecureSkipVerify(skipVerify bool) ClientOption

WithInsecureSkipVerify sets the ssl verify settings to control if ssl certificates are verified or not Useful when using self-signed certificates in a trusted environment. Should only be used if you know you can trust the server, otherwise just leave verify enabled.

type CommonOptions added in v0.14.0

type CommonOptions struct {
	// DryRun command will not be sent
	DryRun bool

	// OnResponse called on the response before the body is processed
	OnResponse func(response *http.Response) io.Reader
}

CommonOptions provides options on how the request is processed by the client

type ConfigurationFragment

type ConfigurationFragment struct {
	C8yConfiguration AgentConfiguration `json:"c8y_Configuration,omitempty"`
}

ConfigurationFragment fragment containing the agent's configuration information

type ContextAuthTokenKey

type ContextAuthTokenKey string

ContextAuthTokenKey todo

func GetContextAuthTokenKey

func GetContextAuthTokenKey() ContextAuthTokenKey

GetContextAuthTokenKey authentication key used to override the given Basic Authentication token

type ContextCommonOptionsKey added in v0.14.0

type ContextCommonOptionsKey string

ContextCommonOptionsKey todo

func GetContextCommonOptionsKey added in v0.14.0

func GetContextCommonOptionsKey() ContextCommonOptionsKey

GetContextCommonOptionsKey common optinos key used to override request options for a single request

type ContextService

type ContextService service

ContextService api

func (*ContextService) BootstrapUserFromEnvironment

func (s *ContextService) BootstrapUserFromEnvironment() context.Context

BootstrapUserFromEnvironment returns a context with the Microservice Bootstrap user (set via environment variables)

func (*ContextService) ClientUser

func (s *ContextService) ClientUser() context.Context

ClientUser returns a context with the client username (if set)

func (*ContextService) CommonOptions added in v0.14.0

func (s *ContextService) CommonOptions(opts CommonOptions) context.Context

CommonOptions create common options for a single request

func (*ContextService) ServiceUserContext

func (s *ContextService) ServiceUserContext(tenant string, skipUpdateServiceUsers bool) context.Context

ServiceUserContext returns authorization context for a Microservice Service user based on the given tenant. If tenant is empty, then the first service user will be used. If no service users are found then it will panic.

func (*ContextService) ServiceUserFromEnvironment

func (s *ContextService) ServiceUserFromEnvironment() context.Context

ServiceUserFromEnvironment returns a context with the Service User authorization (set via environment variables)

func (*ContextService) ServiceUserFromRequest

func (s *ContextService) ServiceUserFromRequest(req *http.Request) context.Context

ServiceUserFromRequest returns a new context with the Authorization token set which will override the Basic Auth in subsequent REST requests. The service user will be seletected based on the tenant credentials provided in the request. If the request's Authorization header does not use the tenant/username format, then the request's URL will be used to determine which tenant to use. Should only be used for MULTI_TENANT microservices

type CumulocityTokenClaim added in v0.14.7

type CumulocityTokenClaim struct {
	User      string `json:"sub,omitempty"`
	Tenant    string `json:"ten,omitempty"`
	XSRFToken string `json:"xsrfToken,omitempty"`
	TGA       bool   `json:"tfa,omitempty"`
	jwt.RegisteredClaims
}

type CurrentTenant

type CurrentTenant struct {
	Name               string      `json:"name"`
	DomainName         string      `json:"domainName"`
	AllowCreateTenants bool        `json:"allowCreateTenants"`
	CustomProperties   interface{} `json:"customProperties"`
}

CurrentTenant todo

type DefaultRequestOptions added in v0.14.0

type DefaultRequestOptions struct {
	DryRun bool

	// DryRunResponse return a mock response when using dry run
	DryRunResponse bool

	// DryRunHandler called when a request should be called
	DryRunHandler func(options *RequestOptions, req *http.Request)
}

DefaultRequestOptions default request options which are added to each outgoing request

type Device

type Device struct {
	DeviceFragment
	ManagedObject
}

Device is a subset of a managed object

func NewDevice

func NewDevice(name string) *Device

NewDevice returns a simple device managed object

type DeviceCertificateCollection added in v0.14.0

type DeviceCertificateCollection struct {
	*BaseResponse

	Certificates []Certificate `json:"certificates"`

	Items []gjson.Result `json:"-"`
}

DeviceCertificateCollection a list of the trusted device certificates

type DeviceCertificateCollectionOptions added in v0.14.0

type DeviceCertificateCollectionOptions struct {
	// Pagination options
	PaginationOptions
}

DeviceCertificateCollectionOptions query options

type DeviceCertificateService added in v0.14.0

type DeviceCertificateService service

DeviceCertificateService interacts with the trusted device certificates in the platform

func (*DeviceCertificateService) Create added in v0.14.0

func (s *DeviceCertificateService) Create(ctx context.Context, body interface{}) (*Certificate, *Response, error)

Create will upload a new trusted certificate

func (*DeviceCertificateService) Delete added in v0.14.0

func (s *DeviceCertificateService) Delete(ctx context.Context, fingerprint string) (*Response, error)

Delete removed a measurement by ID

func (*DeviceCertificateService) GetCertificate added in v0.14.0

func (s *DeviceCertificateService) GetCertificate(ctx context.Context, fingerprint string) (*Certificate, *Response, error)

GetCertificate returns a single certificate

func (*DeviceCertificateService) GetCertificates added in v0.14.0

GetCertificates returns collection of certificates

func (*DeviceCertificateService) Update added in v0.14.0

func (s *DeviceCertificateService) Update(ctx context.Context, fingerprint string, body interface{}) (*Certificate, *Response, error)

Update an existing trusted certificate

type DeviceCredentials

type DeviceCredentials struct {
	ID       string `json:"id,omitempty"`
	TenantID string `json:"tenantId,omitempty"`
	Username string `json:"username,omitempty"`
	Password string `json:"password,omitempty"`
	Self     string `json:"self,omitempty"`
}

DeviceCredentials is the representation of credentials to be used by a device

type DeviceCredentialsService

type DeviceCredentialsService service

DeviceCredentialsService provides api to get/set/delete alarms in Cumulocity

func (*DeviceCredentialsService) Create

Create creates a new Device Request

func (*DeviceCredentialsService) CreateDeviceCredentials

func (s *DeviceCredentialsService) CreateDeviceCredentials(ctx context.Context, ID string) (*DeviceCredentials, *Response, error)

CreateDeviceCredentials creates new device credentials

func (*DeviceCredentialsService) Delete

Delete removes an existing New Device Request

func (*DeviceCredentialsService) GetNewDeviceRequest

func (s *DeviceCredentialsService) GetNewDeviceRequest(ctx context.Context, ID string) (*NewDeviceRequest, *Response, error)

GetNewDeviceRequest returns a New Device Request by its id

func (*DeviceCredentialsService) GetNewDeviceRequests

GetNewDeviceRequests returns a collection of New Device requests

func (*DeviceCredentialsService) PollNewDeviceRequest

func (s *DeviceCredentialsService) PollNewDeviceRequest(ctx context.Context, deviceID string, interval time.Duration, timeout time.Duration) (<-chan struct{}, <-chan error)

PollNewDeviceRequest continuously polls a device request for a specified id at defined intervales. The func will wait until the device request has been set to ACCEPTED. If the device request does not reach the ACCEPTED state in the defined timeout period, then an error will be returned.

func (*DeviceCredentialsService) Update

Update updates an existing New Device Requests status

type DeviceFragment

type DeviceFragment struct {
	DeviceFragment struct{} `json:"c8y_IsDevice"`
}

DeviceFragment marks a managed object which are device representations

type EmptyFragment

type EmptyFragment struct{}

EmptyFragment fragment used for special c8y fragments, i.e. c8y_IsDevice etc.

type Error

type Error struct {
	Resource     string `json:"resource"` // resource on which the error occurred
	Field        string `json:"field"`    // field on which the error occurred
	Code         string `json:"code"`     // validation error code
	Message      string `json:"message"`  // Message describing the error. Errors with Code == "custom" will always have this set.
	ErrorMessage string `json:"error"`
	Information  string `json:"info"`
}

An Error reports more details on an individual error in an ErrorResponse. These are the possible validation error codes:

missing:
    resource does not exist
missing_field:
    a required field on a resource has not been set
invalid:
    the formatting of a field is invalid
already_exists:
    another resource has the same valid as this field
custom:
    some resources return this (e.g. github.User.CreateKey()), additional
    information is set in the Message field of the Error

func (*Error) Error

func (e *Error) Error() string

type ErrorResponse

type ErrorResponse struct {
	Response  *http.Response `json:"-"`                 // HTTP response that caused this error
	ErrorType string         `json:"error,omitempty"`   // Error type formatted as "<<resource type>>/<<error name>>"". For example, an object not found in the inventory is reported as "inventory/notFound".
	Message   string         `json:"message,omitempty"` // error message
	Info      string         `json:"info,omitempty"`    // URL to an error description on the Internet.

	// Error details. Only available in DEBUG mode.
	Details *struct {
		ExceptionClass      string `json:"exceptionClass,omitempty"`
		ExceptionMessage    string `json:"exceptionMessage,omitempty"`
		ExceptionStackTrace string `json:"exceptionStackTrace,omitempty"`
	} `json:"details,omitempty"`
}

An ErrorResponse reports one or more errors caused by an API request.

func (*ErrorResponse) Error

func (r *ErrorResponse) Error() string

type Event

type Event struct {
	ID     string     `json:"id,omitempty"`
	Source *Source    `json:"source,omitempty"`
	Type   string     `json:"type,omitempty"`
	Text   string     `json:"text,omitempty"`
	Self   string     `json:"self,omitempty"`
	Time   *Timestamp `json:"time,omitempty"`

	// Allow access to custom fields
	Item gjson.Result `json:"-"`
}

Event todo

type EventBinary

type EventBinary struct {
	Self   string `json:"self"`
	Type   string `json:"type"`
	Source string `json:"source"`
	Length int64  `json:"length"`

	// Allow access to custom fields
	Item gjson.Result `json:"-"`
}

EventBinary binary object associated with an event

type EventBuilder

type EventBuilder struct {
	// contains filtered or unexported fields
}

EventBuilder represents a custom event where the mandatory properties are set via its constructor NewEventBuilder

func NewEventBuilder

func NewEventBuilder(deviceID string, typeName string, text string) *EventBuilder

NewEventBuilder returns a new custom event with the required fields set. The event will have a timestamp set to Now(). The timestamp can be set to another timestamp by using SetTimestamp()

func (EventBuilder) DeviceID

func (b EventBuilder) DeviceID() string

DeviceID returns the device id of the custom event

func (EventBuilder) Get

func (b EventBuilder) Get(name string) (interface{}, bool)

Get returns the given property value. If the property does not exist, then the second return parameter will be set to false

func (EventBuilder) MarshalJSON

func (b EventBuilder) MarshalJSON() ([]byte, error)

MarshalJSON returns the given event in json format

func (*EventBuilder) Set

func (b *EventBuilder) Set(name string, value interface{}) *EventBuilder

Set sets the name property with the given value

func (*EventBuilder) SetDeviceID

func (b *EventBuilder) SetDeviceID(ID string) *EventBuilder

SetDeviceID sets the device id for the custom event

func (*EventBuilder) SetText

func (b *EventBuilder) SetText(text string) *EventBuilder

SetText sets the event text for the custom event

func (*EventBuilder) SetTimestamp

func (b *EventBuilder) SetTimestamp(value *Timestamp) *EventBuilder

SetTimestamp sets the timestamp when the event was created. If the value is nil, then the current timestamp will be used

func (*EventBuilder) SetType

func (b *EventBuilder) SetType(name string) *EventBuilder

SetType sets the event type

func (EventBuilder) Text

func (b EventBuilder) Text() string

Text returns the device id of the custom event

func (EventBuilder) Timestamp

func (b EventBuilder) Timestamp() Timestamp

Timestamp returns the timestamp of the custom event

func (EventBuilder) Type

func (b EventBuilder) Type() string

Type returns the event type

type EventCollection

type EventCollection struct {
	*BaseResponse

	Events []Event `json:"events"`

	// Allow access to custom fields
	Items []gjson.Result `json:"-"`
}

EventCollection todo

type EventCollectionOptions

type EventCollectionOptions struct {
	// Source device to filter measurements by
	Source string `url:"source,omitempty"`

	// DateFrom Timestamp `url:"dateFrom,omitempty"`
	DateFrom string `url:"dateFrom,omitempty"`

	DateTo string `url:"dateTo,omitempty"`

	Type string `url:"type,omitempty"`

	FragmentType string `url:"fragmentType,omitempty"`

	PaginationOptions
}

EventCollectionOptions todo

type EventService

type EventService service

EventService does something

func (*EventService) Create

func (s *EventService) Create(ctx context.Context, body interface{}) (*Event, *Response, error)

Create creates a new event object

func (*EventService) CreateBinary

func (s *EventService) CreateBinary(ctx context.Context, filename string, ID string) (*EventBinary, *Response, error)

CreateBinary uploads a binary that should be associated with an event. Size of attachment cannot exceed 50MB

func (*EventService) Delete

func (s *EventService) Delete(ctx context.Context, ID string) (*Response, error)

Delete event by its ID

func (*EventService) DeleteBinary

func (s *EventService) DeleteBinary(ctx context.Context, ID string) (*Response, error)

DeleteBinary removes binary file associated to an event

func (*EventService) DeleteEvents

func (s *EventService) DeleteEvents(ctx context.Context, opt *EventCollectionOptions) (*Response, error)

DeleteEvents removes a collection of events based on the given filters

func (*EventService) DownloadBinary

func (s *EventService) DownloadBinary(ctx context.Context, ID string) (filepath string, err error)

DownloadBinary retrieves the binary attached to the given event

func (*EventService) GetEvent

func (s *EventService) GetEvent(ctx context.Context, ID string) (*Event, *Response, error)

GetEvent returns a new event object

func (*EventService) GetEvents

GetEvents returns a list of events based on given filters

func (*EventService) Update

func (s *EventService) Update(ctx context.Context, ID string, body interface{}) (*Event, *Response, error)

Update updates properties on an existing event

func (*EventService) UpdateBinary

func (s *EventService) UpdateBinary(ctx context.Context, ID, filename string) (*EventBinary, *Response, error)

UpdateBinary updates an existing binary associated with an event

type ExtensionOptions added in v0.15.0

type ExtensionOptions struct {
	PaginationOptions

	Name         string `url:"name,omitempty"`
	Owner        string `url:"owner,omitempty"`
	Availability string `url:"availability,omitempty"`
	ProviderFor  string `url:"providerFor,omitempty"`
	Subscriber   string `url:"subscriber,omitempty"`
	Tenant       string `url:"tenant,omitempty"`
	Type         string `url:"type,omitempty"`
	User         string `url:"user,omitempty"`
	HasVersions  bool   `url:"hasVersions,omitempty"`
}

type Firmware added in v0.14.0

type Firmware struct {
	ManagedObject
}

Firmware is the general Inventory Managed Object data structure

func NewFirmware added in v0.14.0

func NewFirmware(name string) *Firmware

NewFirmware returns a simple firmware managed object

type FirmwareFragment added in v0.14.0

type FirmwareFragment struct {
	Version string `json:"version"`
	URL     string `json:"url"`
}

AgentFragment is the special agent fragment used to identify managed objects which are representations of an Agent.

type FirmwareVersion added in v0.14.0

type FirmwareVersion struct {
	ManagedObject

	Firmware *FirmwareFragment `json:"c8y_Firmware,omitempty"`
}

FirmwareVersion firmware version details

func NewFirmwareVersion added in v0.14.0

func NewFirmwareVersion(name string) *FirmwareVersion

NewFirmwareVersion returns a firmware version

type FragmentName

type FragmentName string

FragmentName is a fragment name which can be added to a measurement object. These are commonly used to tag particular measurements with additional information In JSON a fragment name will look like this:

{
  ...
  customMarker: {},
  ...
}

func NewFragmentNameSeries

func NewFragmentNameSeries(names ...string) []FragmentName

NewFragmentNameSeries returns a new array of fragment names will can be appended to a particular measurement

type Group

type Group struct {
	ID                uint64                   `json:"id,omitempty"`
	Self              string                   `json:"self,omitempty"`
	Name              string                   `json:"name,omitempty"`
	Roles             *RoleReferenceCollection `json:"roles,omitempty"`
	DevicePermissions map[string]interface{}   `json:"devicePermissions,omitempty"`
}

func (*Group) GetID

func (g *Group) GetID() string

GetID returns the group id as a string

type GroupCollection

type GroupCollection struct {
	*BaseResponse

	Self   string  `json:"self,omitempty"`
	Groups []Group `json:"groups,omitempty"`

	Items []gjson.Result `json:"-"`
}

type GroupOptions

type GroupOptions struct {
	PaginationOptions
}

GroupOptions available options when querying a list of groups

type GroupReference

type GroupReference struct {
	Self  string `json:"self,omitempty"`
	Group *Group `json:"group,omitempty"`
}

GroupReference represents group information

type GroupReferenceCollection

type GroupReferenceCollection struct {
	*BaseResponse

	Self       string           `json:"self,omitempty"`
	References []GroupReference `json:"references,omitempty"`
}

type Hub added in v0.6.0

type Hub struct {
	// contains filtered or unexported fields
}

Hub maintains the set of active subscriptions and broadcasts messages to the clients.

func NewHub added in v0.14.0

func NewHub() *Hub

func (*Hub) GetActiveChannels added in v0.6.0

func (h *Hub) GetActiveChannels() []string

GetActiveChannels returns the list of active channels which are currently subscribed to

func (*Hub) Run added in v0.14.0

func (h *Hub) Run()

type Identity

type Identity struct {
	ExternalID    string            `json:"externalId"`
	Type          string            `json:"type"`
	Self          string            `json:"self"`
	ManagedObject IdentityReference `json:"managedObject"`

	Item gjson.Result `json:"-"`
}

Identity Cumulocity Identity object holding the information about the external id and link to the managed object

type IdentityOptions

type IdentityOptions struct {
	ExternalID string `json:"externalId"`
	Type       string `json:"type"`
}

IdentityOptions Identity parameters required when creating a new externalid

type IdentityReference

type IdentityReference struct {
	ID   string `json:"id"`
	Self string `json:"self"`
}

IdentityReference contains the id and self link to the identify resource

type IdentityService

type IdentityService service

IdentityService does something

func (*IdentityService) Create

func (s *IdentityService) Create(ctx context.Context, ID string, identityType string, externalID string) (*Identity, *Response, error)

Create adds a new external id for the given managed object id

func (*IdentityService) Delete

func (s *IdentityService) Delete(ctx context.Context, identityType, externalID string) (*Response, error)

Delete removes an existing external id

func (*IdentityService) GetExternalID

func (s *IdentityService) GetExternalID(ctx context.Context, identityType string, externalID string) (*Identity, *Response, error)

GetExternalID Get a managed object by an external ID

type InventoryFirmwareService added in v0.14.0

type InventoryFirmwareService service

InventoryFirmwareService responsible for all inventory api calls

func (*InventoryFirmwareService) CreateVersion added in v0.14.0

func (s *InventoryFirmwareService) CreateVersion(ctx context.Context, firmwareID string, binaryFile binary.MultiPartReader, version FirmwareVersion) (*ManagedObject, *Response, error)

CreateVersion upload a binary and creates a firmware version referencing it THe URL can be left blank in the firmware version as it will be automatically set if a filename is provided

func (*InventoryFirmwareService) GetFirmwareByName added in v0.14.0

GetFirmwareByName returns firmware packages by name

func (*InventoryFirmwareService) GetFirmwareVersionsByName added in v0.14.0

func (s *InventoryFirmwareService) GetFirmwareVersionsByName(ctx context.Context, firmware string, name string, withParents bool, paging *PaginationOptions) (*ManagedObjectCollection, *Response, error)

GetFirmwareVersionsByName returns firmware package versions by name firmware: can also be referenced by name

type InventoryService

type InventoryService service

InventoryService responsible for all inventory api calls

func (*InventoryService) AddChildAddition added in v0.14.0

func (s *InventoryService) AddChildAddition(ctx context.Context, ID, childID string) (*ManagedObject, *Response, error)

AddChildAddition add a managed object as a child addition to an existing managed object

func (*InventoryService) Create

func (s *InventoryService) Create(ctx context.Context, body interface{}) (*ManagedObject, *Response, error)

Create create a new managed object

func (*InventoryService) CreateBinary

func (s *InventoryService) CreateBinary(ctx context.Context, binaryFile binary.MultiPartReader, middleware ...RequestMiddleware) (*ManagedObject, *Response, error)

CreateBinary uploads a given binary to Cumulocity under the inventory managed objects

func (*InventoryService) CreateChildAddition added in v0.14.0

func (s *InventoryService) CreateChildAddition(ctx context.Context, ID string, body interface{}) (*ManagedObject, *Response, error)

CreateChildAddition create a new managed object as a child addition to an existing managed object

func (*InventoryService) CreateChildAdditionWithBinary added in v0.14.0

func (s *InventoryService) CreateChildAdditionWithBinary(ctx context.Context, parentID string, binaryFile binary.MultiPartReader, bodyFunc func(binaryURL string) interface{}, middleware ...RequestMiddleware) (*ManagedObject, *Response, error)

CreateChildAdditionWithBinary create a child addition with a child binary upload a binary and creates a software version referencing it

func (*InventoryService) CreateDevice

func (s *InventoryService) CreateDevice(ctx context.Context, name string) (*ManagedObject, *Response, error)

CreateDevice creates a device in the Cumulocity platform with the required Device Fragment

func (*InventoryService) CreateWithBinary added in v0.14.0

func (s *InventoryService) CreateWithBinary(ctx context.Context, binaryFile binary.MultiPartReader, bodyFunc func(binaryURL string) interface{}, middleware ...RequestMiddleware) (*ManagedObject, *Response, error)

CreateWithBinary create managed object which also has a binary linked as a child addition so that the binary is deleted when the parent maanaged object is deleted

func (*InventoryService) Delete

func (s *InventoryService) Delete(ctx context.Context, ID string) (*Response, error)

Delete removes a managed object by ID

func (*InventoryService) DeleteBinary

func (s *InventoryService) DeleteBinary(ctx context.Context, ID string) (*Response, error)

DeleteBinary removes a managed object Binary by ID

func (*InventoryService) DeleteWithOptions added in v0.14.0

func (s *InventoryService) DeleteWithOptions(ctx context.Context, ID string, options *ManagedObjectDeleteOptions) (*Response, error)

Delete a managed object with additional options

func (*InventoryService) DownloadBinary

func (s *InventoryService) DownloadBinary(ctx context.Context, ID string) (filepath string, err error)

DownloadBinary downloads a binary by its ID

func (*InventoryService) ExpandCollection

func (s *InventoryService) ExpandCollection(ctx context.Context, col *ManagedObjectCollection, maxPages int) (out *ManagedObjectCollection)

ExpandCollection fetches all of the results by iterating through the .next links in the Cumulocity responses

func (*InventoryService) GetBinaries

GetBinaries returns a list of managed object binaries

func (*InventoryService) GetChildAdditions added in v0.14.0

GetChildAdditions returns a list of child additions related to a given managed object

func (*InventoryService) GetChildAssets added in v0.14.0

GetChildAssets returns a list of child assets related to a given managed object

func (*InventoryService) GetChildDevices

GetChildDevices Get the child devices of a given managed object

func (*InventoryService) GetDevices

GetDevices returns the c8y device managed objects. These are the objects with the fragment "c8y_IsDevice"

func (*InventoryService) GetDevicesByName

func (s *InventoryService) GetDevicesByName(ctx context.Context, name string, paging *PaginationOptions) (*ManagedObjectCollection, *Response, error)

GetDevicesByName returns managed object devices by filter by a name

func (*InventoryService) GetManagedObject

func (s *InventoryService) GetManagedObject(ctx context.Context, ID string, opt *ManagedObjectOptions) (*ManagedObject, *Response, error)

GetManagedObject returns a managed object by its id

func (*InventoryService) GetManagedObjects

GetManagedObjects returns a list of managed objects

func (*InventoryService) GetSupportedMeasurements

func (s *InventoryService) GetSupportedMeasurements(ctx context.Context, id string) (*SupportedMeasurements, *Response, error)

GetSupportedMeasurements returns the supported measurements for a given device

func (*InventoryService) GetSupportedSeries

func (s *InventoryService) GetSupportedSeries(ctx context.Context, id string) (*SupportedSeries, *Response, error)

GetSupportedSeries returns the supported series for a give device

func (*InventoryService) Update

func (s *InventoryService) Update(ctx context.Context, ID string, body interface{}) (*ManagedObject, *Response, error)

Update updates a managed object Link: http://cumulocity.com/guides/reference/inventory

func (*InventoryService) UpdateBinary

func (s *InventoryService) UpdateBinary(ctx context.Context, ID string, file io.Reader) (*ManagedObject, *Response, error)

UpdateBinary updates an existing binary under the inventory managed objects

type InventorySoftwareService added in v0.14.0

type InventorySoftwareService service

InventorySoftwareService responsible for all inventory api calls

func (*InventorySoftwareService) CreateVersion added in v0.14.0

func (s *InventorySoftwareService) CreateVersion(ctx context.Context, softwareID string, binaryFile binary.MultiPartReader, version SoftwareVersion) (*ManagedObject, *Response, error)

CreateVersion upload a binary and creates a software version referencing it THe URL can be left blank in the software version as it will be automatically set if a filename is provided

func (*InventorySoftwareService) GetSoftwareByName added in v0.14.0

GetSoftwareByName returns software packages by name

func (*InventorySoftwareService) GetSoftwareVersionsByName added in v0.14.0

func (s *InventorySoftwareService) GetSoftwareVersionsByName(ctx context.Context, software string, name string, withParents bool, paging *PaginationOptions) (*ManagedObjectCollection, *Response, error)

GetSoftwareVersionsByName returns software package versions by name software: can also be referenced by name

type Kpi

type Kpi struct {
	Series   string `json:"series"`
	Fragment string `json:"fragment"`
}

Kpi is the Data Point Library fragment

type ManagedObject

type ManagedObject struct {
	ID               string              `json:"id,omitempty"`
	Name             string              `json:"name,omitempty"`
	Type             string              `json:"type,omitempty"`
	Self             string              `json:"self,omitempty"`
	Owner            string              `json:"owner,omitempty"`
	DeviceParents    *ParentDevices      `json:"deviceParents,omitempty"`
	ChildDevices     *ChildDevices       `json:"childDevices,omitempty"`
	AdditionParents  *AdditionParents    `json:"additionParents,omitempty"`
	AssetParents     *AssetParents       `json:"assetParents,omitempty"`
	ChildAdditions   *ChildAdditions     `json:"childAdditions,omitempty"`
	ChildAssets      *ChildAssets        `json:"childAssets,omitempty"`
	Kpi              *Kpi                `json:"c8y_Kpi,omitempty"`
	C8yConfiguration *AgentConfiguration `json:"c8y_Configuration,omitempty"`

	Item gjson.Result `json:"-"`
}

ManagedObject is the general Inventory Managed Object data structure

type ManagedObjectCollection

type ManagedObjectCollection struct {
	*BaseResponse

	ManagedObjects []ManagedObject `json:"managedObjects"`
	Items          []gjson.Result
}

ManagedObjectCollection todo

func (*ManagedObjectCollection) All

func (s *ManagedObjectCollection) All() error

All todo

type ManagedObjectDeleteOptions added in v0.14.0

type ManagedObjectDeleteOptions struct {
	// When set to true and the managed object is a device or group, all the hierarchy will be deleted
	Cascade *bool `url:"cascade,omitempty"`

	// When set to true all the hierarchy will be deleted without checking the type of managed object. It takes precedence over the parameter cascade
	ForceCascade *bool `url:"forceCascade,omitempty"`

	// When set to true and the managed object is a device, it deletes the associated device user (credentials)
	DeviceUser *bool `url:"withDeviceUser,omitempty"`
}

BinaryObjectOptions managed object options which can be given with the managed object request

func (*ManagedObjectDeleteOptions) WithCascade added in v0.14.0

func (*ManagedObjectDeleteOptions) WithDeviceUser added in v0.14.0

func (*ManagedObjectDeleteOptions) WithForceCascade added in v0.14.0

type ManagedObjectOptions

type ManagedObjectOptions struct {
	Type string `url:"type,omitempty"`

	FragmentType string `url:"fragmentType,omitempty"`

	Text string `url:"text,omitempty"`

	WithParents bool `url:"withParents,omitempty"`

	// Read-only collection of managed objects fetched for a given list of ids (placeholder {ids}),for example "?ids=41,43,68".
	Ids []string `url:"ids,omitempty"`

	Query string `url:"query,omitempty"`

	PaginationOptions
}

ManagedObjectOptions managed object options which can be given with the managed object request

type ManagedObjectReference

type ManagedObjectReference struct {
	Self          string        `json:"self,omitempty"`
	ManagedObject ManagedObject `json:"managedObject,omitempty"`
}

ManagedObjectReference Managed object reference

type ManagedObjectReferencesCollection

type ManagedObjectReferencesCollection struct {
	*BaseResponse
	References []ManagedObjectReference `json:"references"`
}

ManagedObjectReferencesCollection Managed object references

type Measurement

type Measurement struct {
	ID     string     `json:"id,omitempty"`
	Source *Source    `json:"source,omitempty"`
	Type   string     `json:"type,omitempty"`
	Self   string     `json:"self,omitempty"`
	Time   *Timestamp `json:"time,omitempty"`

	Item gjson.Result `json:"-"`
}

Measurement is the Cumulocity measurement representation in the platform

type MeasurementAggregateValue

type MeasurementAggregateValue struct {
	Min Number `json:"min"`
	Max Number `json:"max"`
}

MeasurementAggregateValue represents the aggregate value of a single measurement.

type MeasurementCollection

type MeasurementCollection struct {
	*BaseResponse

	Measurements []Measurement `json:"measurements"`

	Items []gjson.Result `json:"-"`
}

MeasurementCollection is the generic data structure which contains the response cumulocity when requesting a measurement collection

type MeasurementCollectionOptions

type MeasurementCollectionOptions struct {
	// Source device to filter measurements by
	Source string `url:"source,omitempty"`

	// DateFrom Timestamp `url:"dateFrom,omitempty"`
	DateFrom string `url:"dateFrom,omitempty"`

	DateTo string `url:"dateTo,omitempty"`

	Type string `url:"type,omitempty"`

	FragmentType string `url:"fragmentType,omitempty"`

	ValueFragmentType string `url:"valueFragmentType,omitempty"`

	ValueFragmentSeries string `url:"valueFragmentSeries,omitempty"`

	Revert bool `url:"revert,omitempty"`

	// Pagination options
	PaginationOptions
}

MeasurementCollectionOptions todo

type MeasurementRepresentation

type MeasurementRepresentation struct {
	Timestamp          time.Time           `json:"time"`
	Source             MeasurementSource   `json:"source"`
	Type               string              `json:"type"`
	Fragments          []FragmentName      `json:"-"`
	ValueFragmentTypes []ValueFragmentType `json:"-"`
}

MeasurementRepresentation is the measurement object in order to push it into the Cumulocity platform

func NewSimpleMeasurementRepresentation

func NewSimpleMeasurementRepresentation(opt SimpleMeasurementOptions) (*MeasurementRepresentation, error)

NewSimpleMeasurementRepresentation returns a measurement with one value Fragment type/series It is a helper function to make it easier to create simple measurements that can be added to the platform

func (MeasurementRepresentation) MarshalJSON

func (m MeasurementRepresentation) MarshalJSON() ([]byte, error)

MarshalJSON converts the Measurement Representation to a json string A custom marshaling is required as the meausurement object is structured differently to the official Cumulocity Measurement structure to make it easier to handle

type MeasurementSeriesAggregateGroup

type MeasurementSeriesAggregateGroup struct {
	Series    []MeasurementSeriesDefinition          `json:"series"`
	Values    []MeasurementSeriesAggregateValueGroup `json:"values"`
	DateFrom  time.Time                              `json:"dateFrom"`
	DateTo    time.Time                              `json:"dateTo"`
	Truncated bool                                   `json:"truncated"`
}

MeasurementSeriesAggregateGroup represents a group of aggregate series

func (*MeasurementSeriesAggregateGroup) UnmarshalJSON

func (d *MeasurementSeriesAggregateGroup) UnmarshalJSON(data []byte) error

UnmarshalJSON controls the conversion of json bytes to the MeasurementSeriesAggregateGroup struct

type MeasurementSeriesAggregateValueGroup

type MeasurementSeriesAggregateValueGroup struct {
	Timestamp time.Time                   `json:"timestamp"`
	Values    []MeasurementAggregateValue `json:"values"`
}

MeasurementSeriesAggregateValueGroup represents multiple aggregate values for multiple series for a single timestamp

type MeasurementSeriesDefinition added in v0.14.14

type MeasurementSeriesDefinition struct {
	Unit string `json:"unit"`
	Name string `json:"name"`
	Type string `json:"type"`
}

MeasurementSeriesDefinition represents information about a single series

type MeasurementSeriesGroup

type MeasurementSeriesGroup struct {
	DeviceID  string                        `json:"deviceId"`
	Series    []MeasurementSeriesDefinition `json:"series"`
	Values    []MeasurementSeriesValueGroup `json:"values"`
	DateFrom  time.Time                     `json:"dateFrom"`
	DateTo    time.Time                     `json:"dateTo"`
	Truncated bool                          `json:"truncated"`
}

MeasurementSeriesGroup represents a group of series values (no aggregate values)

func (*MeasurementSeriesGroup) MarshalCSV

func (d *MeasurementSeriesGroup) MarshalCSV(delimiter string) ([]byte, error)

MarshalCSV converts the measurement series group to a csv output so it can be more easily parsed by other languages Example output timestamp,c8y_Temperature.A,c8y_Temperature.B 2018-11-23T00:45:39+01:00,60.699993,44.300003 2018-11-23T01:45:39+01:00,67.63333,47.199997

func (*MeasurementSeriesGroup) UnmarshalJSON

func (d *MeasurementSeriesGroup) UnmarshalJSON(data []byte) error

UnmarshalJSON converts the Cumulocity measurement Series response to a format which is easier to parse.

{
    "series": [ "c8y_Temperature.A", "c8y_Temperature.B" ],
    "unit": [ "degC", "degC" ],
    "truncated": true,
    "values": [
        { "timestamp": "2018-11-11T23:20:00.000+01:00", values: [0.0001, 0.1001] },
        { "timestamp": "2018-11-11T23:20:01.000+01:00", values: [0.1234, 2.2919] },
        { "timestamp": "2018-11-11T23:20:02.000+01:00", values: [0.8370, 4.8756] }
    ]
}

type MeasurementSeriesOptions

type MeasurementSeriesOptions struct {
	// Source device to filter measurements by
	Source string `url:"source,omitempty"`

	DateFrom string `url:"dateFrom,omitempty"`

	DateTo string `url:"dateTo,omitempty"`

	AggregationType string `url:"aggregationType,omitempty"`

	Variables []string `url:"series,omitempty"`

	Revert bool `url:"revert,omitempty"`
}

MeasurementSeriesOptions todo

type MeasurementSeriesValueGroup

type MeasurementSeriesValueGroup struct {
	Timestamp time.Time `json:"timestamp"`
	Values    []Number  `json:"values"`
}

MeasurementSeriesValueGroup represents multiple values for multiple series for a single timestamp

type MeasurementService

type MeasurementService service

MeasurementService does something

func (*MeasurementService) Create

Create posts a new measurement to the platform

func (*MeasurementService) CreateMeasurements

func (s *MeasurementService) CreateMeasurements(ctx context.Context, body *Measurements) (*Measurements, *Response, error)

CreateMeasurements posts multiple measurement to the platform

func (*MeasurementService) Delete

func (s *MeasurementService) Delete(ctx context.Context, ID string) (*Response, error)

Delete removed a measurement by ID Deprecated: Deleting single measurements is no longer supported in Cumulocity IoT when using the time series feature. Use `DeleteMeasurements` instead

func (*MeasurementService) DeleteMeasurements

func (s *MeasurementService) DeleteMeasurements(ctx context.Context, opt *MeasurementCollectionOptions) (*Response, error)

DeleteMeasurements removes a measurement collection

func (*MeasurementService) GetMeasurement

func (s *MeasurementService) GetMeasurement(ctx context.Context, ID string) (*Measurement, *Response, error)

GetMeasurement returns a single measurement Deprecated: Retrieving single measurements is no longer supported in Cumulocity IoT when using the time series feature. Use `GetMeasurements` instead

func (*MeasurementService) GetMeasurementSeries

GetMeasurementSeries returns the measurement series for a given source and variables The data is returned in a user friendly format to make it easier to use the data

func (*MeasurementService) GetMeasurements

GetMeasurements return a measurement collection (multiple measurements)

func (*MeasurementService) NewMeasurementSourceByName

func (s *MeasurementService) NewMeasurementSourceByName(ctx context.Context, name string) (*MeasurementSource, error)

NewMeasurementSourceByName returns the source object by searching for a matching device by name

type MeasurementSource

type MeasurementSource struct {
	ID   string `json:"id"`
	Name string `json:"name,omitempty"`
}

MeasurementSource represents a device source.

type Measurements

type Measurements struct {
	Measurements []MeasurementRepresentation `json:"measurements"`

	Items []gjson.Result `json:"-"`
}

Measurements represents multiple measurements

type Message

type Message struct {
	Channel      string       `json:"channel"`
	Payload      RealtimeData `json:"data,omitempty"`
	ID           string       `json:"id,omitempty"`
	ClientID     string       `json:"clientId,omitempty"`
	Extension    interface{}  `json:"ext,omitempty"`
	Advice       *advice      `json:"advice,omitempty"`
	Successful   bool         `json:"successful,omitempty"`
	Subscription string       `json:"subscription,omitempty"`
}

Message is the type delivered to subscribers.

type MetaMessage

type MetaMessage struct {
	Message
	Version                  string   `json:"version,omitempty"`
	MinimumVersion           string   `json:"minimumVersion,omitempty"`
	SupportedConnectionTypes []string `json:"supportedConnectionTypes,omitempty"`
	ConnectionType           string   `json:"connectionType,omitempty"`
	Timestamp                string   `json:"timestamp,omitempty"`
	Successful               bool     `json:"successful"`
	Subscription             string   `json:"subscription,omitempty"`
	Error                    string   `json:"error,omitempty"`
	Advice                   *advice  `json:"advice,omitempty"`
}

MetaMessage Bayeux message

type MicroserviceService

type MicroserviceService service

MicroserviceService api

func (*MicroserviceService) GetServiceUsers

func (s *MicroserviceService) GetServiceUsers() (*ApplicationSubscriptions, error)

GetServiceUsers returns a list of the subscribed tenant where the application is running along with the service user subscriptions for each tenant

func (*MicroserviceService) SetServiceUsers

func (s *MicroserviceService) SetServiceUsers() error

SetServiceUsers sets the service users which can then be used later for following requests The service users are retrieved by using the bootstrap credentials stored in environment variables

type NewDeviceRequest

type NewDeviceRequest struct {
	ID           string `json:"id,omitempty"`
	Status       string `json:"status,omitempty"`
	Self         string `json:"self,omitempty"`
	Owner        string `json:"owner,omitempty"`
	CreationTime string `json:"creationTime,omitempty"`
	TenantID     string `json:"tenantId,omitempty"`

	// Allow access to custom fields
	Item gjson.Result `json:"-"`
}

NewDeviceRequest representation

type NewDeviceRequestCollection

type NewDeviceRequestCollection struct {
	*BaseResponse

	NewDeviceRequests []NewDeviceRequest `json:"newDeviceRequests"`

	Items []gjson.Result `json:"-"`
}

NewDeviceRequestCollection todo

type NewDeviceRequestOptions

type NewDeviceRequestOptions struct {
	PaginationOptions
}

NewDeviceRequestOptions options which can be used when requesting the New Device Requests

type Notification2ClientOptions added in v0.14.0

type Notification2ClientOptions struct {
	Token             string
	Consumer          string
	Options           Notification2TokenOptions
	ConnectionOptions notification2.ConnectionOptions
}

type Notification2Service added in v0.14.0

type Notification2Service service

Notification2Service manages tokens and subscriptions for the notification2 interface

func (*Notification2Service) CreateClient added in v0.14.0

Create a notification2 client to subscribe to new options

Example

```

notifClient, err := client.Notification2.CreateClient(context.Background(), c8y.Notification2ClientOptions{
    Token:    os.Getenv("NOTIFICATION2_TOKEN"),
    Consumer: *consumer,
    Options: &c8y.Notification2TokenOptions{
    	   ExpiresInMinutes: 2,
    	   Subscription:     *subscription,
    	   Subscriber:       *subscriber,
    },
})

if err != nil {
    panic(err)
}

messagesCh := make(chan notifications2.Message) notifClient.Register("*", messagesCh) signalCh := make(chan os.Signal, 1) signal.Notify(signalCh, os.Interrupt)

for {
  select {
  case msg := <-messagesCh:
	      log.Printf("Received message. %s", msg.Payload)
       notifClient.SendMessageAck(msg.Identifier)

  case <-signalCh:
  	// Enable ctrl-c to stop
  	notificationClient.Close()
  	return
  }
}

```

func (*Notification2Service) CreateSubscription added in v0.14.0

func (s *Notification2Service) CreateSubscription(ctx context.Context, ID string, subscription Notification2Subscription) (*Event, *Response, error)

Update updates properties on an existing event

func (*Notification2Service) CreateToken added in v0.14.0

Create token

func (*Notification2Service) DeleteSubscription added in v0.14.0

func (s *Notification2Service) DeleteSubscription(ctx context.Context, ID string) (*Response, error)

Delete subscription by id

func (*Notification2Service) DeleteSubscriptionBySource added in v0.14.0

func (s *Notification2Service) DeleteSubscriptionBySource(ctx context.Context, opt Notification2SubscriptionDeleteOptions) (*Response, error)

DeleteSubscription removes a subscription by source

func (*Notification2Service) GetSubscription added in v0.14.0

Get subscription by id

func (*Notification2Service) GetSubscriptions added in v0.14.0

Get collection of subscriptions

func (*Notification2Service) ParseToken added in v0.14.0

func (s *Notification2Service) ParseToken(tokenString string) (*Notification2TokenClaim, error)

func (*Notification2Service) RenewToken added in v0.14.0

func (*Notification2Service) UnsubscribeSubscriber added in v0.14.0

func (s *Notification2Service) UnsubscribeSubscriber(ctx context.Context, token string) (*UnsubscribeResponse, *Response, error)

Unsubscribe a notification subscriber using the notification token

type Notification2Subscription added in v0.14.0

type Notification2Subscription struct {
	ID                 string                          `json:"id,omitempty"`
	Self               string                          `json:"self,omitempty"`
	Context            string                          `json:"context,omitempty"`
	FragmentsToCopy    []string                        `json:"fragmentsToCopy,omitempty"`
	Source             *Source                         `json:"source,omitempty"`
	Subscription       string                          `json:"subscription,omitempty"`
	SubscriptionFilter Notification2SubscriptionFilter `json:"subscriptionFilter,omitempty"`

	// Allow access to custom fields
	Item gjson.Result `json:"-"`
}

Notificatioin2Subscription notification subscription object

type Notification2SubscriptionCollection added in v0.14.0

type Notification2SubscriptionCollection struct {
	*BaseResponse

	Subscriptions []Notification2Subscription `json:"subscriptions"`

	// Allow access to custom fields
	Items []gjson.Result `json:"-"`
}

type Notification2SubscriptionCollectionOptions added in v0.14.0

type Notification2SubscriptionCollectionOptions struct {
	Context string `url:"context,omitempty"`
	Source  string `url:"source,omitempty"`

	PaginationOptions
}

Notificatioin2Subscription collection options

type Notification2SubscriptionDeleteOptions added in v0.14.0

type Notification2SubscriptionDeleteOptions struct {
	Context string `url:"context,omitempty"`
	Source  string `url:"source,omitempty"`
}

Notification2SubscriptionDeleteOptions options when deleting a subscription by source

type Notification2SubscriptionFilter added in v0.14.0

type Notification2SubscriptionFilter struct {
	Apis       []string `json:"apis,omitempty"`
	TypeFilter string   `json:"typeFilter,omitempty"`
}

type Notification2Token added in v0.14.0

type Notification2Token struct {
	*BaseResponse

	Token string `json:"token"`

	// Allow access to custom fields
	Items []gjson.Result `json:"-"`
}

Notification2Token notification2 token which can be used by client to subscribe to notifications

type Notification2TokenClaim added in v0.14.0

type Notification2TokenClaim struct {
	Subscriber string `json:"sub,omitempty"`
	Topic      string `json:"topic,omitempty"`
	Shared     string `json:"shared,omitempty"`
	jwt.RegisteredClaims
}

func (*Notification2TokenClaim) HasExpired added in v0.14.0

func (c *Notification2TokenClaim) HasExpired() bool

func (*Notification2TokenClaim) IsShared added in v0.14.5

func (c *Notification2TokenClaim) IsShared() bool

func (*Notification2TokenClaim) Subscription added in v0.14.0

func (c *Notification2TokenClaim) Subscription() string

func (*Notification2TokenClaim) Tenant added in v0.14.0

func (c *Notification2TokenClaim) Tenant() string

type Notification2TokenOptions added in v0.14.0

type Notification2TokenOptions struct {
	// The token expiration duration
	ExpiresInMinutes int64 `json:"expiresInMinutes,omitempty"`

	// The subscriber name which the client wishes to be identified with
	Subscriber string `json:"subscriber,omitempty"`

	// The subscription name. This value must match the same that was used when the subscription was created
	Subscription string `json:"subscription,omitempty"`

	// Subscription is shared by multiple consumers
	Shared bool `json:"shared,omitempty"`
}

EventCollectionOptions todo

type Number

type Number struct {
	json.Number
}

Number is a nullable representation of a JSON Number which can either be null, an integer or a float(64) The number is actually stored as a string internally and then converted to a float64 or an integer on demand.

func NewNumber

func NewNumber(value string) *Number

NewNumber returns a new number

func (*Number) IsNull

func (s *Number) IsNull() bool

IsNull checks if the number is null/valid or not

func (*Number) MarshalJSON

func (s *Number) MarshalJSON() ([]byte, error)

MarshalJSON converts the Number to its json representation (allowing for null values)

func (*Number) SimpleFloat64

func (s *Number) SimpleFloat64() float64

SimpleFloat64 returns the value as a float64. If the value is currently null, then 0 will be returned. This is simpler to use rather than .Float64() as the user does not have to worry about error checking. However the user should call IsNull() first in order to determine if the number is valid or not.

type Operation

type Operation struct {
	ID            string     `json:"id,omitempty"`
	CreationTime  *Timestamp `json:"creationTime,omitempty"`
	DeviceID      string     `json:"deviceId,omitempty"`
	DeviceName    string     `json:"deviceName,omitempty"`
	Status        string     `json:"status,omitempty"`
	Description   string     `json:"description,omitempty"`
	Self          string     `json:"self,omitempty"`
	EventID       string     `json:"eventId,omitempty"`
	FailureReason string     `json:"failureReason,omitempty"`

	Item gjson.Result `json:"-"`
}

Operation todo

type OperationBuilder

type OperationBuilder struct {
	// contains filtered or unexported fields
}

OperationBuilder is a generic operation representation that can be used to build custom operations with a free format

func NewOperationAgentUpdateConfiguration

func NewOperationAgentUpdateConfiguration(deviceID string, configuration string) *OperationBuilder

NewOperationAgentUpdateConfiguration returns a operation which can be used to update the agent's configuration

func NewOperationBuilder

func NewOperationBuilder(deviceID string) *OperationBuilder

NewOperationBuilder returns a new Custom Operation with the specified device id The operation requires at least one custom fragment before it is sent to Cumulocity i.e. b.Set("my_CustomOperation", map[string]string{"myprop": "one"})

func (OperationBuilder) DeviceID

func (b OperationBuilder) DeviceID() string

DeviceID returns the device id of the operation

func (OperationBuilder) Get

func (b OperationBuilder) Get(name string) (interface{}, bool)

Get returns the given property value. If the property does not exist, then the second return parameter will be set to false

func (OperationBuilder) MarshalJSON

func (b OperationBuilder) MarshalJSON() ([]byte, error)

MarshalJSON returns the given operation in json format

func (*OperationBuilder) Set

func (b *OperationBuilder) Set(name string, value interface{}) *OperationBuilder

Set sets the name property with the given value

func (*OperationBuilder) SetDeviceID

func (b *OperationBuilder) SetDeviceID(ID string) *OperationBuilder

SetDeviceID sets the device id for the custom operation

type OperationCollection

type OperationCollection struct {
	*BaseResponse

	Operations []Operation `json:"operations"`

	Items []gjson.Result `json:"-"`
}

OperationCollection todo

type OperationCollectionOptions

type OperationCollectionOptions struct {
	// Source device to filter measurements by
	Status string `url:"status,omitempty"`

	AgentID string `url:"agentId,omitempty"`

	DeviceID string `url:"deviceId,omitempty"`

	DateFrom string `url:"dateFrom,omitempty"`

	DateTo string `url:"dateTo,omitempty"`

	BulkOperationId string `url:"bulkOperationId,omitempty"`

	FragmentType string `url:"fragmentType,omitempty"`

	Revert bool `url:"revert,omitempty"`

	// Pagination options
	PaginationOptions
}

OperationCollectionOptions todo

type OperationService

type OperationService service

OperationService todo

func (*OperationService) Create

func (s *OperationService) Create(ctx context.Context, body interface{}) (*Operation, *Response, error)

Create creates a new operation for a device

func (*OperationService) DeleteOperations

func (s *OperationService) DeleteOperations(ctx context.Context, opt *OperationCollectionOptions) (*Response, error)

DeleteOperations deletes a collection of Cumulocity operations

func (*OperationService) GetOperation

func (s *OperationService) GetOperation(ctx context.Context, ID string) (*Operation, *Response, error)

GetOperation returns a collection of Cumulocity operations

func (*OperationService) GetOperations

GetOperations returns a collection of Cumulocity operations

func (*OperationService) Update

Update updates a Cumulocity operation

type OperationUpdateOptions

type OperationUpdateOptions struct {
	// Status Operation status, can be one of SUCCESSFUL, FAILED, EXECUTING or PENDING
	Status string `json:"status,omitempty"`

	// FailureReason is the Reason for the failure
	FailureReason string `json:"failureReason,omitempty"`
}

OperationUpdateOptions todo

type PaginationOptions

type PaginationOptions struct {
	// Pagesize of results to return in one request
	PageSize int `url:"pageSize,omitempty"`

	// Include total pages included in the pagination at the given page size
	WithTotalPages bool `url:"withTotalPages,omitempty"`

	// Include count of elements in the statistics response. Only supported >= 10.13
	WithTotalElements bool `url:"withTotalElements,omitempty"`

	// Defines the slice of data to be returned, starting with 1. By default, the first page is returned.
	CurrentPage *int `url:"currentPage,omitempty"`
}

PaginationOptions is the cumulocity pagination options

func NewPaginationOptions

func NewPaginationOptions(pageSize int) *PaginationOptions

NewPaginationOptions returns a pagination options object with a specified pagesize and WithTotalPages set to false

func (*PaginationOptions) SetCurrentPage added in v0.15.1

func (o *PaginationOptions) SetCurrentPage(v int) *PaginationOptions

Set the current page to return

type ParentDevices

type ParentDevices struct {
	Self       string                   `json:"self"`
	References []ManagedObjectReference `json:"references"`
}

ParentDevices todo

type ProxyReader added in v0.14.0

type ProxyReader struct {
	// contains filtered or unexported fields
}

func NewByteReader added in v0.14.0

func NewByteReader(v []byte) *ProxyReader

func NewProxyReader added in v0.14.0

func NewProxyReader(r io.Reader) *ProxyReader

func NewStringReader added in v0.14.0

func NewStringReader(v string) *ProxyReader

func (ProxyReader) Close added in v0.14.0

func (r ProxyReader) Close() error

func (ProxyReader) GetValue added in v0.14.0

func (r ProxyReader) GetValue() string

func (ProxyReader) Read added in v0.14.0

func (r ProxyReader) Read(p []byte) (n int, err error)

type RealtimeClient

type RealtimeClient struct {
	// contains filtered or unexported fields
}

RealtimeClient allows connecting to a Bayeux server and subscribing to channels.

func NewRealtimeClient

func NewRealtimeClient(host string, wsDialer *websocket.Dialer, tenant, username, password string) *RealtimeClient

NewRealtimeClient initializes a new Bayeux client. By default `http.DefaultClient` is used for HTTP connections.

func (*RealtimeClient) Close

func (c *RealtimeClient) Close() error

Close notifies the Bayeux server of the intent to disconnect and terminates the background polling loop.

func (*RealtimeClient) Connect

func (c *RealtimeClient) Connect() error

Connect performs a handshake with the server and will repeatedly initiate a websocket connection until `Close` is called on the client.

func (*RealtimeClient) Disconnect added in v0.6.0

func (c *RealtimeClient) Disconnect() error

Disconnect sends a disconnect signal to the server and closes the websocket

func (*RealtimeClient) IsConnected

func (c *RealtimeClient) IsConnected() bool

IsConnected returns true if the websocket is connected

func (*RealtimeClient) SetBearerToken added in v0.14.0

func (c *RealtimeClient) SetBearerToken(token string)

SetBearerToken set the token required for authentication via OAUTH

func (*RealtimeClient) SetCookies added in v0.14.0

func (c *RealtimeClient) SetCookies(cookies []*http.Cookie) error

SetCookies sets the cookies used for outgoing requests

func (*RealtimeClient) SetRequestHeader added in v0.14.0

func (c *RealtimeClient) SetRequestHeader(header http.Header)

SetRequestHeader sets the header to use when estabilishing the realtime connection.

func (*RealtimeClient) SetXSRFToken added in v0.14.0

func (c *RealtimeClient) SetXSRFToken(token string)

SetXSRFToken set the token required for authentication via OAUTH

func (*RealtimeClient) Subscribe

func (c *RealtimeClient) Subscribe(pattern string, out chan<- *Message) chan error

Subscribe setup a subscription to the given element

func (*RealtimeClient) TenantName

func (c *RealtimeClient) TenantName() string

TenantName returns the tenant name used in the client

func (*RealtimeClient) Unsubscribe

func (c *RealtimeClient) Unsubscribe(pattern string) chan error

Unsubscribe unsubscribe to a given pattern

func (*RealtimeClient) UnsubscribeAll

func (c *RealtimeClient) UnsubscribeAll() chan error

UnsubscribeAll unsubscribes to all of the subscribed channels. The channel related to the subscription is left open, and will be reused if another call with the same pattern is made to Subscribe()

func (*RealtimeClient) WaitForMessage added in v0.6.0

func (c *RealtimeClient) WaitForMessage(ID string) chan error

WaitForMessage waits for a message with the corresponding id to be sent by the server

func (*RealtimeClient) WaitForMessages added in v0.6.0

func (c *RealtimeClient) WaitForMessages(ids ...string) chan error

WaitForMessages waits for a server response related to the list of message ids

type RealtimeData

type RealtimeData struct {
	RealtimeAction string          `json:"realtimeAction,omitempty"`
	Data           json.RawMessage `json:"data,omitempty"`

	Item gjson.Result `json:"-"`
}

RealtimeData contains the websocket frame data

type RequestMiddleware added in v0.14.0

type RequestMiddleware func(r *http.Request) (*http.Request, error)

type RequestOptions

type RequestOptions struct {
	Method           string
	Host             string
	Path             string
	Accept           string
	ContentType      string
	Query            interface{} // Use string if you want
	Body             interface{}
	ResponseData     interface{}
	FormData         map[string]io.Reader
	Header           http.Header
	IgnoreAccept     bool
	NoAuthentication bool
	DryRun           bool
	DryRunResponse   bool
	ValidateFuncs    []RequestValidator
	PrepareRequest   func(*http.Request) (*http.Request, error)

	PrepareRequestOnDryRun bool
}

RequestOptions struct which contains the options to be used with the SendRequest function

func (*RequestOptions) GetEscapedPath added in v0.14.0

func (r *RequestOptions) GetEscapedPath() (string, error)

func (*RequestOptions) GetPath added in v0.14.0

func (r *RequestOptions) GetPath() (string, error)

func (*RequestOptions) GetQuery added in v0.14.0

func (r *RequestOptions) GetQuery() (string, error)

func (*RequestOptions) WithValidateFunc added in v0.15.4

func (r *RequestOptions) WithValidateFunc(v ...RequestValidator) *RequestOptions

Add a validator function which will check if the outgoing http request is valid or not

type RequestValidator added in v0.15.4

type RequestValidator func(*http.Request) error

Request validator function to be used to check if the outgoing request is properly formulated

type Response

type Response struct {
	Response *http.Response
	// contains filtered or unexported fields
}

Response struct holds response values of executed request.

func (*Response) Body added in v0.14.0

func (r *Response) Body() []byte

Body method returns HTTP response as []byte array for the executed request.

Note: `Response.Body` might be nil, if `Request.SetOutput` is used.

func (*Response) Cookies added in v0.14.0

func (r *Response) Cookies() []*http.Cookie

Cookies method to access all the response cookies

func (*Response) DecodeJSON

func (r *Response) DecodeJSON(v interface{}) error

DecodeJSON returns the json response decoded into the given interface

func (*Response) Duration added in v0.14.2

func (r *Response) Duration() time.Duration

func (*Response) Header added in v0.14.0

func (r *Response) Header() http.Header

Header method returns the response headers

func (*Response) IsError added in v0.14.0

func (r *Response) IsError() bool

IsError method returns true if HTTP status `code >= 400` otherwise false.

func (*Response) IsSuccess added in v0.14.0

func (r *Response) IsSuccess() bool

IsSuccess method returns true if HTTP status `code >= 200 and <= 299` otherwise false.

func (*Response) JSON

func (r *Response) JSON(path ...string) gjson.Result

func (*Response) Proto added in v0.14.0

func (r *Response) Proto() string

Proto method returns the HTTP response protocol used for the request.

func (*Response) RawBody added in v0.14.0

func (r *Response) RawBody() io.ReadCloser

RawBody method exposes the HTTP raw response body. Use this method in-conjunction with `SetDoNotParseResponse` option otherwise you get an error as `read err: http: read on closed response body`.

Do not forget to close the body, otherwise you might get into connection leaks, no connection reuse. Basically you have taken over the control of response parsing from `Resty`.

func (*Response) ReceivedAt added in v0.14.0

func (r *Response) ReceivedAt() time.Time

ReceivedAt method returns when response got received from server for the request.

func (*Response) SetBody added in v0.14.1

func (r *Response) SetBody(v []byte)

func (*Response) Size added in v0.14.0

func (r *Response) Size() int64

Size method returns the HTTP response size in bytes. Ya, you can relay on HTTP `Content-Length` header, however it won't be good for chucked transfer/compressed response. Since Resty calculates response size at the client end. You will get actual size of the http response.

func (*Response) Status added in v0.14.0

func (r *Response) Status() string

Status method returns the HTTP status string for the executed request.

Example: 200 OK

func (*Response) StatusCode added in v0.14.0

func (r *Response) StatusCode() int

StatusCode method returns the HTTP status code for the executed request.

Example: 200

func (*Response) String added in v0.14.0

func (r *Response) String() string

String method returns the body of the server response as String.

type RetentionRule

type RetentionRule struct {
	// RetentionRule id
	ID string `json:"id,omitempty"`

	// RetentionRule will be applied to documents with source
	Source string `json:"source,omitempty"`

	// RetentionRule will be applied to documents with type
	Type string `json:"type,omitempty"`

	// RetentionRule will be applied to this type of documents, possible values [ALARM, AUDIT, EVENT, MEASUREMENT, OPERATION, *]
	DataType string `json:"dataType,omitempty"`

	// RetentionRule will be applied to documents with fragmentType
	FragmentType string `json:"fragmentType,omitempty"`

	// Link to this resource
	Self string `json:"self,omitempty"`

	// Maximum age of document in days
	MaximumAge int64 `json:"maximumAge,omitempty"`

	// Whether the rule is editable. Can be updated only by management tenant
	Editable bool `json:"editable,omitempty"`
}

RetentionRule todo

type RetentionRuleCollection

type RetentionRuleCollection struct {
	*BaseResponse

	RetentionRules []RetentionRule `json:"retentionRules"`
}

RetentionRuleCollection todo

type RetentionRuleService

type RetentionRuleService service

RetentionRuleService does something

func (*RetentionRuleService) Create

Create creates a new event object

func (*RetentionRuleService) Delete

func (s *RetentionRuleService) Delete(ctx context.Context, ID string) (*Response, error)

Delete retention rule by its ID

func (*RetentionRuleService) GetRetentionRule

func (s *RetentionRuleService) GetRetentionRule(ctx context.Context, ID string) (*RetentionRule, *Response, error)

GetRetentionRule returns the retention rule related to the id

func (*RetentionRuleService) GetRetentionRules

GetRetentionRules returns a list of events based on given filters

func (*RetentionRuleService) Update

Update updates properties on an existing retention rule

type Role

type Role struct {
	Self string `json:"self,omitempty"`
	ID   string `json:"id,omitempty"`
	Name string `json:"name,omitempty"`
}

type RoleCollection

type RoleCollection struct {
	*BaseResponse

	Self  string `json:"self,omitempty"`
	Roles []Role `json:"roles,omitempty"`

	Items []gjson.Result `json:"-"`
}

RoleCollection is a list of user roles in the platform

type RoleOptions

type RoleOptions struct {
	PaginationOptions
}

RoleOptions options to be used when querying for roles

type RoleReference

type RoleReference struct {
	Self string `json:"self,omitempty"`
	Role *Role  `json:"role,omitempty"`
}

type RoleReferenceCollection

type RoleReferenceCollection struct {
	Self       string          `json:"self,omitempty"`
	References []RoleReference `json:"references,omitempty"`
}

type ServiceUser

type ServiceUser struct {
	Username string `json:"name"`
	Password string `json:"password"`
	Tenant   string `json:"tenant"`
}

ServiceUser has the service user credentials for a given application subscription

func DecodeBasicAuth

func DecodeBasicAuth(auth string, host string) (*ServiceUser, error)

DecodeBasicAuth returns Service User Credentials object from a given a Basic Auth

type SimpleMeasurementOptions

type SimpleMeasurementOptions struct {
	SourceID            string
	Timestamp           *time.Time
	Type                string
	ValueFragmentType   string
	ValueFragmentSeries string
	FragmentType        []string
	Value               interface{}
	Unit                string
}

SimpleMeasurementOptions contains the arguments which can be provided when using the NewSimpleMeasurementRepresentation constructor Timestamp will be set to time.Now() if it is not provided by the user

type Software added in v0.14.0

type Software struct {
	ManagedObject
}

Software is the general Inventory Managed Object data structure

func NewSoftware added in v0.14.0

func NewSoftware(name string) *Software

NewSoftware returns a simple software managed object

type SoftwareFragment added in v0.14.0

type SoftwareFragment struct {
	Version string `json:"version"`
	URL     string `json:"url"`
}

AgentFragment is the special agent fragment used to identify managed objects which are representations of an Agent.

type SoftwareVersion added in v0.14.0

type SoftwareVersion struct {
	ManagedObject

	Software *SoftwareFragment `json:"c8y_Software,omitempty"`
}

func NewSoftwareVersion added in v0.14.0

func NewSoftwareVersion(name string) *SoftwareVersion

type Source

type Source struct {
	ID   string `json:"id,omitempty"`
	Name string `json:"name,omitempty"`
	Self string `json:"self,omitempty"`
}

Source represents a source reference

func NewSource

func NewSource(id string) *Source

NewSource returns a new source object

type Statistics

type Statistics struct {
	CurrentPage   *int `json:"currentPage"`
	PageSize      *int `json:"pageSize"`
	TotalPages    *int `json:"totalPages"`
	TotalElements *int `json:"totalElements"`
}

Statistics statistics about the returned rest response

type StoreMode added in v0.14.0

type StoreMode int
const (
	// StoreModeReadWrite read and write to cache
	StoreModeReadWrite StoreMode = 0

	// StoreModeWrite only write to cache, don't read from it.
	StoreModeWrite StoreMode = 1
)

type SupportedMeasurements

type SupportedMeasurements struct {
	SupportedMeasurements []string `json:"c8y_SupportedMeasurements"`
}

SupportedMeasurements is a list of measurement fragments for the given device

type SupportedOperationsFragment

type SupportedOperationsFragment struct {
	SupportedOperations []string `json:"c8y_SupportedOperations,omitempty"`
}

SupportedOperationsFragment list of supported operations which can be sent to device/agent which has this fragment

type SupportedSeries

type SupportedSeries struct {
	SupportedSeries []string `json:"c8y_SupportedSeries"`
}

SupportedSeries is a list of the supported series in the format of <fragment>.<series>

type Tenant

type Tenant struct {
	ID                     string                          `json:"id,omitempty"`
	Self                   string                          `json:"self,omitempty"`
	Status                 string                          `json:"status,omitempty"`
	AdminName              string                          `json:"adminName,omitempty"`
	AdminEmail             string                          `json:"adminEmail,omitempty"`
	AdminPassword          string                          `json:"adminPassword,omitempty"`
	Domain                 string                          `json:"domain,omitempty"`
	Company                string                          `json:"company,omitempty"`
	ContactName            string                          `json:"contactName,omitempty"`
	ContactPhone           string                          `json:"contactPhone,omitempty"`
	CustomProperties       interface{}                     `json:"customProperties,omitempty"`
	Parent                 string                          `json:"parent,omitempty"`
	StorageLimitPerDevice  int64                           `json:"storageLimitPerDevice,omitempty"`
	Applications           *ApplicationReferenceCollection `json:"applications,omitempty"`
	OwnedApplications      *ApplicationReferenceCollection `json:"ownedApplications,omitempty"`
	AllowCreateTenants     bool                            `json:"allowCreateTenants,omitempty"`
	SendPasswordResetEmail bool                            `json:"sendPasswordResetEmail,omitempty"`
}

Tenant application/vnd.com.nsn.cumulocity.tenant+json

func NewTenant

func NewTenant(company, domain string) *Tenant

NewTenant returns a tenant object with the required fields

type TenantCollection

type TenantCollection struct {
	*BaseResponse

	Tenants []Tenant `json:"tenants"`
}

TenantCollection todo

type TenantLoginOption added in v0.14.0

type TenantLoginOption struct {
	ID                   string `json:"id"`
	Self                 string `json:"self"`
	Type                 string `json:"type"`
	UserManagementSource string `json:"userManagementSource,omitempty"`
	TFAStrategy          string `json:"tfaStrategy,omitempty"`
	InitRequest          string `json:"initRequest,omitempty"`
	GrantType            string `json:"grantType,omitempty"`
	VisibleOnLoginPage   bool   `json:"visibleOnLoginPage"`
}

TenantLoginOption tenant login option

type TenantLoginOptions added in v0.14.0

type TenantLoginOptions struct {
	Self         string              `json:"self"`
	LoginOptions []TenantLoginOption `json:"loginOptions"`
}

TenantLoginOptions tenant login options

type TenantOption

type TenantOption struct {
	Category string `json:"category,omitempty"`
	Key      string `json:"key,omitempty"`
	Value    string `json:"value,omitempty"`

	Item gjson.Result `json:"-"`
}

TenantOption is a setting used to customize a tenant

type TenantOptionCollection

type TenantOptionCollection struct {
	*BaseResponse

	Options []TenantOption `json:"options"`

	Items []gjson.Result `json:"-"`
}

TenantOptionCollection todo

type TenantOptionsService

type TenantOptionsService service

TenantOptionsService does something

func (*TenantOptionsService) Create

Create adds a new tenant

func (*TenantOptionsService) Delete

func (s *TenantOptionsService) Delete(ctx context.Context, category, key string) (*Response, error)

Delete removes an existing tenant option by category and key

func (*TenantOptionsService) GetOption

func (s *TenantOptionsService) GetOption(ctx context.Context, category, key string) (*TenantOption, *Response, error)

GetOption returns the given tenant option by category and key

func (*TenantOptionsService) GetOptions

GetOptions returns collection of tenant options

func (*TenantOptionsService) GetOptionsForCategory

func (s *TenantOptionsService) GetOptionsForCategory(ctx context.Context, category string) (map[string]string, *Response, error)

GetOptionsForCategory returns collection of tenant options for the specified category

func (*TenantOptionsService) GetSystemOption

func (s *TenantOptionsService) GetSystemOption(ctx context.Context, category, key string) (*TenantOption, *Response, error)

GetSystemOption returns the given system option by category and key

func (*TenantOptionsService) GetSystemOptions

GetSystemOptions returns collection system options

func (*TenantOptionsService) GetVersion added in v0.14.0

func (s *TenantOptionsService) GetVersion(ctx context.Context) (string, error)

GetVersion returns Cumulocity version information

func (*TenantOptionsService) Update

func (s *TenantOptionsService) Update(ctx context.Context, category, key string, value string) (*TenantOption, *Response, error)

Update updates an existing tenant option

func (*TenantOptionsService) UpdateEditability

func (s *TenantOptionsService) UpdateEditability(ctx context.Context, category, key string, editable bool) (*TenantOption, *Response, error)

UpdateEditability sets the editability of the given option. Only possible from management tenant

func (*TenantOptionsService) UpdateOptions

func (s *TenantOptionsService) UpdateOptions(ctx context.Context, category string, body map[string]string) (map[string]string, *Response, error)

UpdateOptions updates multiple options for the specified category

type TenantService

type TenantService service

TenantService does something

func (*TenantService) AddApplicationReference

func (s *TenantService) AddApplicationReference(ctx context.Context, tenantID string, appSelfReference string) (*ApplicationReference, *Response, error)

AddApplicationReference adds a new tenant Note: Can only be called from the management tenant

func (*TenantService) Create

func (s *TenantService) Create(ctx context.Context, body *Tenant) (*Tenant, *Response, error)

Create adds a new tenant

func (*TenantService) Delete

func (s *TenantService) Delete(ctx context.Context, ID string) (*Response, error)

Delete removes a tenant and all of its data

func (*TenantService) DeleteApplicationReference

func (s *TenantService) DeleteApplicationReference(ctx context.Context, tenantID string, applicationID string) (*Response, error)

DeleteApplicationReference removes an application references from the tenant Note: Can only be called from the management tenant

func (*TenantService) GetAllTenantsStatisticsSummary

func (s *TenantService) GetAllTenantsStatisticsSummary(ctx context.Context, opt *TenantStatisticsOptions) ([]TenantUsageStatisticsSummaryExtended, *Response, error)

GetAllTenantsStatisticsSummary returns the usage statistics from all of the subtenants Note: It will only returns results if the current tenant has subtenants or it is called from the managed tenant

func (*TenantService) GetApplicationReferences

func (s *TenantService) GetApplicationReferences(ctx context.Context, tenantID string, opts *PaginationOptions) (*ApplicationReferenceCollection, *Response, error)

GetApplicationReferences returns list of applications associated with the tenant Note: Can only be called from the management tenant

func (*TenantService) GetCurrentTenant

func (s *TenantService) GetCurrentTenant(ctx context.Context) (*CurrentTenant, *Response, error)

GetCurrentTenant returns tenant for the currently logged in service user's tenant

func (*TenantService) GetLoginOptions added in v0.14.0

func (s *TenantService) GetLoginOptions(ctx context.Context) (*TenantLoginOptions, *Response, error)

GetLoginOptions returns the login options available for the tenant

func (*TenantService) GetTenant

func (s *TenantService) GetTenant(ctx context.Context, ID string) (*Tenant, *Response, error)

GetTenant returns a tenant using its ID

func (*TenantService) GetTenantStatistics

GetTenantStatistics returns statics for the current tenant between the specified days

func (*TenantService) GetTenantStatisticsSummary

func (s *TenantService) GetTenantStatisticsSummary(ctx context.Context, opt *TenantSummaryOptions) (*TenantSummary, *Response, error)

GetTenantStatisticsSummary returns summary of requests and database usage from the start of this month until now.

func (*TenantService) GetTenants

GetTenants returns collection of tenants

func (*TenantService) Update

func (s *TenantService) Update(ctx context.Context, ID string, body *Tenant) (*Tenant, *Response, error)

Update adds an existing tenant

type TenantStatisticsOptions

type TenantStatisticsOptions struct {
	DateFrom string `url:"dateFrom,omitempty"`
	DateTo   string `url:"dateTill,omitempty"`

	PaginationOptions
}

type TenantSummary

type TenantSummary struct {
	Self                    string   `json:"self"`
	Day                     string   `json:"day"`
	DeviceCount             int64    `json:"deviceCount"`
	DeviceWithChildrenCount int64    `json:"deviceWithChildrenCount"`
	DeviceEndpointCount     int64    `json:"deviceEndpointCount"`
	DeviceRequestCount      int64    `json:"deviceRequestCount"`
	RequestCount            int64    `json:"requestCount"`
	StorageSize             int64    `json:"storageSize"`
	SubscribedApplications  []string `json:"subscribedApplications"`
}

TenantSummary todo

type TenantSummaryOptions

type TenantSummaryOptions struct {
	DateFrom string `url:"dateFrom,omitempty"`
	DateTo   string `url:"dateTill,omitempty"`
}

TenantSummaryOptions todo

type TenantUsageStatisticsCollection

type TenantUsageStatisticsCollection struct {
	*BaseResponse
	UsageStatistics []TenantSummary `json:"usageStatistics,omitempty"`
}

type TenantUsageStatisticsSummary

type TenantUsageStatisticsSummary struct {
	DeviceCount             int64    `json:"deviceCount"`
	DeviceWithChildrenCount int64    `json:"deviceWithChildrenCount"`
	DeviceEndpointCount     int64    `json:"deviceEndpointCount"`
	DeviceRequestCount      int64    `json:"deviceRequestCount"`
	RequestCount            int64    `json:"requestCount"`
	StorageSize             int64    `json:"storageSize"`
	SubscribedApplications  []string `json:"subscribedApplications"`
}

type TenantUsageStatisticsSummaryExtended

type TenantUsageStatisticsSummaryExtended struct {
	DeviceCount             int64    `json:"deviceCount,omitempty"`
	DeviceWithChildrenCount int64    `json:"deviceWithChildrenCount,omitempty"`
	DeviceEndpointCount     int64    `json:"deviceEndpointCount,omitempty"`
	DeviceRequestCount      int64    `json:"deviceRequestCount,omitempty"`
	RequestCount            int64    `json:"requestCount,omitempty"`
	StorageSize             int64    `json:"storageSize,omitempty"`
	SubscribedApplications  []string `json:"subscribedApplications,omitempty"`

	// All
	TenantID                          string    `json:"tenantId,omitempty"`
	ParentTenantID                    string    `json:"parentTenantId,omitempty"`
	TenantDomain                      string    `json:"tenantDomain,omitempty"`
	InventoriesUpdateCount            int64     `json:"inventoriesUpdateCount,omitempty"`
	CreationTime                      Timestamp `json:"creationTime,omitempty"`
	EventsCreatedCount                int64     `json:"eventsCreatedCount,omitempty"`
	TotalResourceCreateAndUpdateCount int64     `json:"totalResourceCreateAndUpdateCount,omitempty"`
	PeakDeviceCount                   int64     `json:"peakDeviceCount,omitempty"`
	TenantCompany                     int64     `json:"tenantCompany,omitempty"`
	InventoriesCreatedCount           int64     `json:"inventoriesCreatedCount,omitempty"`
	MeasurementsCreatedCount          int64     `json:"measurementsCreatedCount,omitempty"`
	PeakDeviceWithChildrenCount       int64     `json:"peakDeviceWithChildrenCount,omitempty"`
	PeakStorageSize                   int64     `json:"peakStorageSize,omitempty"`
	AlarmsUpdatedCount                int64     `json:"alarmsUpdatedCount,omitempty"`
	EventsUpdatedCount                int64     `json:"eventsUpdatedCount,omitempty"`
	AlarmsCreatedCount                int64     `json:"alarmsCreatedCount,omitempty"`
}

type Timestamp

type Timestamp struct {
	time.Time
}

Timestamp represents a time that can be unmarshalled from a JSON string formatted as either an RFC3339 or Unix timestamp. This is necessary for some fields since the GitHub API is inconsistent in how it represents times. All exported methods of time.Time can be called on Timestamp.

func NewTimestamp

func NewTimestamp(value ...time.Time) *Timestamp

NewTimestamp returns a new timestamp set to Now() or using the specified timestamp If the function is called with multiple time.Time values, then only the first will be used to generate the Timestamp

func (*Timestamp) Equal

func (t *Timestamp) Equal(u Timestamp) bool

Equal reports whether t and u are equal based on time.Equal

func (*Timestamp) String

func (t *Timestamp) String() string

func (*Timestamp) UnmarshalJSON

func (t *Timestamp) UnmarshalJSON(data []byte) (err error)

UnmarshalJSON implements the json.Unmarshaler interface. Time is expected in RFC3339 or Unix format.

type UIExtension added in v0.15.0

type UIExtension struct {
	Application
	Manifest     *UIManifest     `json:"manifest,omitempty"`
	ManifestFile *UIManifestFile `json:"-"`
}

func NewApplicationExtension added in v0.15.0

func NewApplicationExtension(name string) *UIExtension

func NewUIExtension added in v0.15.0

func NewUIExtension(name string) *UIExtension

type UIExtensionService added in v0.15.0

type UIExtensionService service

UIExtensionService to managed UI extensions WARNING: THE UI Extension Service API is not yet finalized so expect changes in the future!

func (*UIExtensionService) CreateExtension added in v0.15.0

func (s *UIExtensionService) CreateExtension(ctx context.Context, application *Application, filename any, opt UpsertOptions) (*ApplicationVersion, *Response, error)

CreateVersion creates a new version of an application from a given file The filename can either be a string or a io.Reader

func (*UIExtensionService) GetExtensions added in v0.15.0

GetVersions returns a list of versions for a given application

func (*UIExtensionService) NewUIExtensionFromFile added in v0.15.0

func (s *UIExtensionService) NewUIExtensionFromFile(filename string) (*UIExtension, error)

func (*UIExtensionService) SetActive added in v0.15.0

func (s *UIExtensionService) SetActive(ctx context.Context, appID string, binaryID string) (*Application, *Response, error)

type UIManifest added in v0.15.0

type UIManifest struct {
	Package   string `json:"package,omitempty"`
	IsPackage *bool  `json:"isPackage,omitempty"`
}

func (*UIManifest) WithIsPackage added in v0.15.0

func (m *UIManifest) WithIsPackage(v bool) *UIManifest

func (*UIManifest) WithPackage added in v0.15.0

func (m *UIManifest) WithPackage(v string) *UIManifest

type UIManifestFile added in v0.15.0

type UIManifestFile struct {
	Name        string `json:"name,omitempty"`
	Key         string `json:"key,omitempty"`
	ContextPath string `json:"contextPath,omitempty"`
	Package     string `json:"package,omitempty"`
	IsPackage   bool   `json:"isPackage,omitempty"`
	Version     string `json:"version,omitempty"`

	Author                  string              `json:"author"`
	Description             string              `json:"description,omitempty"`
	License                 string              `json:"license"`
	Remotes                 map[string][]string `json:"remotes"`
	RequiredPlatformVersion string              `json:"requiredPlatformVersion"`
}

type UnsubscribeResponse added in v0.14.0

type UnsubscribeResponse struct {
	Result string `json:"result,omitempty"`
}

UnsubscribeResponse response after unsubscribing a subscriber

type UpsertOptions added in v0.15.0

type UpsertOptions struct {
	SkipActivation bool
	Version        *ApplicationVersion
}

type User

type User struct {
	ID                string                    `json:"id,omitempty"`
	Self              string                    `json:"self,omitempty"`
	Username          string                    `json:"userName,omitempty"`
	Password          string                    `json:"password,omitempty"`
	FirstName         string                    `json:"firstName,omitempty"`
	LastName          string                    `json:"lastName,omitempty"`
	Phone             string                    `json:"phone,omitempty"`
	Email             string                    `json:"email,omitempty"`
	Enabled           bool                      `json:"enabled,omitempty"`
	CustomProperties  interface{}               `json:"customProperties,omitempty"`
	Groups            *GroupReferenceCollection `json:"groups,omitempty"`
	Roles             *RoleReferenceCollection  `json:"roles,omitempty"`
	DevicePermissions map[string]interface{}    `json:"devicePermissions,omitempty"`

	Item gjson.Result `json:"-"`
}

User todo

func NewUser

func NewUser(username string, email string, password string) *User

NewUser returns a new user object

func (*User) SetEmail

func (u *User) SetEmail(value string) *User

func (*User) SetEnabled

func (u *User) SetEnabled(value bool) *User

func (*User) SetFirstName

func (u *User) SetFirstName(value string) *User

func (*User) SetLastName

func (u *User) SetLastName(value string) *User

func (*User) SetPhone

func (u *User) SetPhone(value string) *User

type UserCollection

type UserCollection struct {
	*BaseResponse

	Users []User `json:"users"`

	Items []gjson.Result `json:"-"`
}

UserCollection contains information about a list of users

type UserOptions

type UserOptions struct {
	// Prefix or full username
	Username string `url:"username,omitempty"`

	Groups []string `url:"groups,omitempty"`

	// Exact username
	Owner string `url:"owner,omitempty"`

	// OnlyDevices If set to "true", result will contain only users created during bootstrap process (starting with "device_"). If flag is absent (or false) the result will not contain "device_" users.
	OnlyDevices bool `url:"onlyDevices,omitempty"`

	// WithSubusersCount if set to "true", then each of returned users will contain additional field "subusersCount" - number of direct subusers (users with corresponding "owner").
	WithSubusersCount bool `url:"withSubusersCount,omitempty"`

	PaginationOptions
}

UserOptions options that can be provided when using user api calls

type UserReference

type UserReference struct {
	Self string `json:"self,omitempty"`
	User *User  `json:"user,omitempty"`
}

type UserReferenceCollection

type UserReferenceCollection struct {
	*BaseResponse

	Self       string          `json:"self,omitempty"`
	References []UserReference `json:"references,omitempty"`
}

type UserService

type UserService service

UserService provides the service provider for the Cumulocity Application API

func (*UserService) AddUserToGroup

func (s *UserService) AddUserToGroup(ctx context.Context, user *User, groupID string) (*UserReference, *Response, error)

AddUserToGroup adds the user to an existing group

func (*UserService) AssignRoleToGroup

func (s *UserService) AssignRoleToGroup(ctx context.Context, groupID string, roleSelfReference string) (*RoleReference, *Response, error)

AssignRoleToGroup adds a role to an existing group

func (*UserService) AssignRoleToUser

func (s *UserService) AssignRoleToUser(ctx context.Context, username string, roleSelfReference string) (*RoleReference, *Response, error)

func (*UserService) Create

func (s *UserService) Create(ctx context.Context, body *User) (*User, *Response, error)

Create adds a new user

func (*UserService) CreateGroup

func (s *UserService) CreateGroup(ctx context.Context, body *Group) (*Group, *Response, error)

CreateGroup creates a new group with the given name

func (*UserService) Delete

func (s *UserService) Delete(ctx context.Context, ID string) (*Response, error)

Delete removes an existing user

func (*UserService) DeleteGroup

func (s *UserService) DeleteGroup(ctx context.Context, ID string) (*Response, error)

DeleteGroup deletes an existing group Info: ADMINS and DEVICES groups can not be deleted

func (*UserService) GetCurrentUser

func (s *UserService) GetCurrentUser(ctx context.Context) (*User, *Response, error)

GetCurrentUser returns the current user based on the request's credentials

func (*UserService) GetGroup

func (s *UserService) GetGroup(ctx context.Context, ID string) (*Group, *Response, error)

GetGroup returns a group by its id

func (*UserService) GetGroupByName

func (s *UserService) GetGroupByName(ctx context.Context, name string) (*Group, *Response, error)

GetGroupByName returns the group by its name

func (*UserService) GetGroups

func (s *UserService) GetGroups(ctx context.Context, opt *GroupOptions) (*GroupCollection, *Response, error)

GetGroups returns the list of user groups

func (*UserService) GetGroupsByUser

func (s *UserService) GetGroupsByUser(ctx context.Context, username string, opt *GroupOptions) (*GroupReferenceCollection, *Response, error)

GetGroupsByUser returns list of groups assigned to a given user

func (*UserService) GetRole added in v0.8.0

func (s *UserService) GetRole(ctx context.Context, ID string) (*Role, *Response, error)

GetRole returns the role of the given id

func (*UserService) GetRoles

func (s *UserService) GetRoles(ctx context.Context, opt *RoleOptions) (*RoleCollection, *Response, error)

GetRoles returns a list of existing roles

func (*UserService) GetRolesByGroup

func (s *UserService) GetRolesByGroup(ctx context.Context, groupID string, opt *RoleOptions) (*RoleReferenceCollection, *Response, error)

GetRolesByGroup returns list of roles of an existing group

func (*UserService) GetRolesByUser

func (s *UserService) GetRolesByUser(ctx context.Context, username string, opt *RoleOptions) (*RoleReferenceCollection, *Response, error)

GetRolesByUser returns list of roles of an existing user

func (*UserService) GetUser

func (s *UserService) GetUser(ctx context.Context, ID string) (*User, *Response, error)

GetUser returns a user by its ID

func (*UserService) GetUserByUsername

func (s *UserService) GetUserByUsername(ctx context.Context, username string) (*User, *Response, error)

GetUserByUsername returns a user by their username

func (*UserService) GetUsers

func (s *UserService) GetUsers(ctx context.Context, opt *UserOptions) (*UserCollection, *Response, error)

GetUsers returns a list of users for the given tenant Users in the response are sorted by username in ascending order.

func (*UserService) GetUsersByGroup

func (s *UserService) GetUsersByGroup(ctx context.Context, groupID string, opt *UserOptions) (*UserReferenceCollection, *Response, error)

GetUsersByGroup returns the list of users in the given group

func (*UserService) RemoveUserFromGroup

func (s *UserService) RemoveUserFromGroup(ctx context.Context, username string, groupID string) (*Response, error)

RemoveUserFromGroup removes a user from a group

func (*UserService) UnassignRoleFromGroup

func (s *UserService) UnassignRoleFromGroup(ctx context.Context, groupID string, roleName string) (*Response, error)

UnassignRoleFromGroup removes a role from an existing user

func (*UserService) UnassignRoleFromUser

func (s *UserService) UnassignRoleFromUser(ctx context.Context, username string, roleName string) (*Response, error)

UnassignRoleFromUser removes a role from an existing user

func (*UserService) Update

func (s *UserService) Update(ctx context.Context, ID string, body *User) (*User, *Response, error)

Update updates an existing user

func (*UserService) UpdateCurrentUser

func (s *UserService) UpdateCurrentUser(ctx context.Context, body *User) (*User, *Response, error)

UpdateCurrentUser updates the current user based on the request's credentials

func (*UserService) UpdateGroup

func (s *UserService) UpdateGroup(ctx context.Context, ID string, body *Group) (*Group, *Response, error)

UpdateGroup updates properties of an existing group

type ValueFragmentSeries

type ValueFragmentSeries struct {
	Name  string
	Value interface{}
	Unit  string
}

ValueFragmentSeries represents the Value Fragment Series information This layout deviates from the Cumulocity Measurement model

type ValueFragmentType

type ValueFragmentType struct {
	Name   string
	Values []ValueFragmentSeries
}

ValueFragmentType represents the Value Fragment Type information A Value Fragment Type can have multiple series definitions This layout deviates from the Cumulocity Measurement model

func (ValueFragmentType) MarshalJSON

func (m ValueFragmentType) MarshalJSON() ([]byte, error)

MarshalJSON custom marshaling of the Value Fragment Type representation in a measurement

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL