Documentation
¶
Index ¶
- Constants
- Variables
- func CheckResponse(r *http.Response) error
- func DecodeJSONBytes(v []byte, dst interface{}) error
- func DecodeJSONFile(filepath string, dst interface{}) error
- func DecodeJSONReader(r io.Reader, dst interface{}) error
- func FormatBaseURL(v string) string
- func GetBootstrapUserFromEnvironment() (tenant, username, password string)
- func GetDateRange(dateInterval string) (string, string)
- func GetRoundedTime(date *time.Time, unit string) (roundTime time.Time)
- func GetServiceUserFromEnvironment() (tenant, username, password string)
- func GetUIExtensionManifestContents(zipFilename string, contents interface{}) error
- func HasTag(tags []string, tag string) bool
- func IsID(v string) bool
- func NewAuthorizationContext(tenant, username, password string) context.Context
- func NewAuthorizationContextFromRequest(req *http.Request) context.Context
- func NewBasicAuthString(tenant, username, password string) string
- func NewCachedClient(httpClient *http.Client, cacheDir string, cacheTTL time.Duration, ...) *http.Client
- func NewHTTPClient(opts ...ClientOption) *http.Client
- func RealtimeAlarms(id ...string) string
- func RealtimeAlarmsWithChildren(id ...string) string
- func RealtimeEvents(id ...string) string
- func RealtimeManagedObjects(id ...string) string
- func RealtimeMeasurements(id ...string) string
- func RealtimeOperations(id ...string) string
- func RequestSupportsBody(method string) bool
- func SilenceLogger()
- func UnsilenceLogger()
- func Upload(client *http.Client, url string, values map[string]io.Reader) (err error)
- func WithCommonOptionsContext(ctx context.Context, opts CommonOptions) context.Context
- func WithDisabledDryRunContext(ctx context.Context) context.Context
- type AdditionParents
- type Agent
- type AgentConfiguration
- type AgentFragment
- type Alarm
- type AlarmBuilder
- func (b AlarmBuilder) DeviceID() string
- func (b AlarmBuilder) Get(name string) (interface{}, bool)
- func (b AlarmBuilder) MarshalJSON() ([]byte, error)
- func (b *AlarmBuilder) Set(name string, value interface{}) *AlarmBuilder
- func (b *AlarmBuilder) SetDeviceID(ID string) *AlarmBuilder
- func (b *AlarmBuilder) SetSeverityCritical() *AlarmBuilder
- func (b *AlarmBuilder) SetSeverityMajor() *AlarmBuilder
- func (b *AlarmBuilder) SetSeverityMinor() *AlarmBuilder
- func (b *AlarmBuilder) SetSeverityWarning() *AlarmBuilder
- func (b *AlarmBuilder) SetText(ID string) *AlarmBuilder
- func (b *AlarmBuilder) SetTimestamp(value *Timestamp) *AlarmBuilder
- func (b *AlarmBuilder) SetType(ID string) *AlarmBuilder
- func (b AlarmBuilder) Severity() string
- func (b AlarmBuilder) Text() string
- func (b AlarmBuilder) Timestamp() Timestamp
- func (b AlarmBuilder) Type() string
- type AlarmCollection
- type AlarmCollectionOptions
- type AlarmService
- func (s *AlarmService) BulkUpdateAlarms(ctx context.Context, status string, opts AlarmUpdateOptions) (*Response, error)
- func (s *AlarmService) Create(ctx context.Context, body interface{}) (*Alarm, *Response, error)
- func (s *AlarmService) DeleteAlarms(ctx context.Context, opt *AlarmCollectionOptions) (*Response, error)
- func (s *AlarmService) GetAlarm(ctx context.Context, ID string) (*Alarm, *Response, error)
- func (s *AlarmService) GetAlarms(ctx context.Context, opt *AlarmCollectionOptions) (*AlarmCollection, *Response, error)
- func (s *AlarmService) Update(ctx context.Context, ID string, body AlarmUpdateProperties) (*Alarm, *Response, error)
- type AlarmUpdateOptions
- type AlarmUpdateProperties
- type Application
- type ApplicationCollection
- type ApplicationOptions
- type ApplicationOwner
- type ApplicationReference
- type ApplicationReferenceCollection
- type ApplicationService
- func (s *ApplicationService) Copy(ctx context.Context, ID string) (*Application, *Response, error)
- func (s *ApplicationService) Create(ctx context.Context, body *Application) (*Application, *Response, error)
- func (s *ApplicationService) CreateBinary(ctx context.Context, filename string, ID string) (*Response, error)
- func (s *ApplicationService) Delete(ctx context.Context, ID string) (*Response, error)
- func (s *ApplicationService) GetApplication(ctx context.Context, ID string) (*Application, *Response, error)
- func (s *ApplicationService) GetApplicationUser(ctx context.Context, ID string) (*ApplicationUser, *Response, error)
- func (s *ApplicationService) GetApplications(ctx context.Context, opt *ApplicationOptions) (*ApplicationCollection, *Response, error)
- func (s *ApplicationService) GetApplicationsByName(ctx context.Context, name string, opt *ApplicationOptions) (*ApplicationCollection, *Response, error)
- func (s *ApplicationService) GetApplicationsByOwner(ctx context.Context, tenant string, opt *ApplicationOptions) (*ApplicationCollection, *Response, error)
- func (s *ApplicationService) GetApplicationsByTenant(ctx context.Context, tenant string, opt *ApplicationOptions) (*ApplicationCollection, *Response, error)
- func (s *ApplicationService) GetCurrentApplication(ctx context.Context) (*Application, *Response, error)
- func (s *ApplicationService) GetCurrentApplicationSubscriptions(ctx context.Context) (*ApplicationSubscriptions, *Response, error)
- func (s *ApplicationService) Update(ctx context.Context, ID string, body *Application) (*Application, *Response, error)
- func (s *ApplicationService) UpdateCurrentApplication(ctx context.Context, ID string, body *Application) (*Application, *Response, error)
- type ApplicationSubscriptions
- type ApplicationTenantReference
- type ApplicationUser
- type ApplicationVersion
- type ApplicationVersionsCollection
- type ApplicationVersionsOptions
- type ApplicationVersionsService
- func (s *ApplicationVersionsService) CreateVersion(ctx context.Context, ID string, filenameOrURL string, ...) (*ApplicationVersion, *Response, error)
- func (s *ApplicationVersionsService) CreateVersionFromReader(ctx context.Context, ID string, file io.Reader, version ApplicationVersion) (*ApplicationVersion, *Response, error)
- func (s *ApplicationVersionsService) DeleteVersionByName(ctx context.Context, ID string, version string) (*Response, error)
- func (s *ApplicationVersionsService) DeleteVersionByTag(ctx context.Context, ID string, tag string) (*Response, error)
- func (s *ApplicationVersionsService) GetVersionByName(ctx context.Context, ID string, version string) (*ApplicationVersion, *Response, error)
- func (s *ApplicationVersionsService) GetVersionByTag(ctx context.Context, ID string, tag string) (*ApplicationVersion, *Response, error)
- func (s *ApplicationVersionsService) GetVersions(ctx context.Context, ID string, opt *ApplicationVersionsOptions) (*ApplicationVersionsCollection, *Response, error)
- func (s *ApplicationVersionsService) IsUrl(u string) bool
- func (s *ApplicationVersionsService) ReplaceTags(ctx context.Context, ID string, version string, tags []string) (*ApplicationVersion, *Response, error)
- type AssetParents
- type AuditRecord
- type AuditRecordCollection
- type AuditRecordCollectionOptions
- type AuditService
- func (s *AuditService) Create(ctx context.Context, body interface{}) (*AuditRecord, *Response, error)
- func (s *AuditService) DeleteAuditRecords(ctx context.Context, opt *AuditRecordCollectionOptions) (*Response, error)
- func (s *AuditService) GetAuditRecord(ctx context.Context, ID string) (*AuditRecord, *Response, error)
- func (s *AuditService) GetAuditRecords(ctx context.Context, opt *AuditRecordCollectionOptions) (*AuditRecordCollection, *Response, error)
- type BaseResponse
- type BinaryFragment
- type CacheOptions
- type Cacheable
- type Certificate
- type ChildAdditions
- type ChildAssets
- type ChildDevices
- type Client
- func NewClient(httpClient *http.Client, baseURL string, tenant string, username string, ...) *Client
- func NewClientFromEnvironment(httpClient *http.Client, skipRealtimeClient bool) *Client
- func NewClientUsingBootstrapUserFromEnvironment(httpClient *http.Client, baseURL string, skipRealtimeClient bool) *Client
- func (c *Client) DefaultDryRunHandler(options *RequestOptions, req *http.Request)
- func (c *Client) Do(ctx context.Context, req *http.Request, v interface{}, ...) (*Response, error)
- func (c *Client) GetHostname() string
- func (c *Client) GetTenantName(ctx context.Context) string
- func (c *Client) GetUsername() string
- func (c *Client) GetXSRFToken() string
- func (c *Client) HideSensitiveInformationIfActive(message string) string
- func (c *Client) LoginUsingOAuth2(ctx context.Context, initRequest ...string) error
- func (c *Client) LoginUsingOAuth2External(ctx context.Context, code string, initRequest ...string) error
- func (c *Client) NewRealtimeClientFromServiceUser(tenant string) *RealtimeClient
- func (c *Client) NewRequest(method, path string, query string, body interface{}) (*http.Request, error)
- func (c *Client) NewRequestWithoutAuth(method, path string, query string, body interface{}) (*http.Request, error)
- func (c *Client) Noop()
- func (c *Client) ParseToken(tokenString string) (*CumulocityTokenClaim, error)
- func (c *Client) SendRequest(ctx context.Context, options RequestOptions) (*Response, error)
- func (c *Client) SetAuthorization(req *http.Request)
- func (c *Client) SetBasicAuthorization(req *http.Request)
- func (c *Client) SetBearerAuthorization(req *http.Request)
- func (c *Client) SetCookies(cookies []*http.Cookie)
- func (c *Client) SetDomain(v string)
- func (c *Client) SetHostHeader(req *http.Request)
- func (c *Client) SetJSONItems(resp *Response, v interface{}) error
- func (c *Client) SetRequestOptions(options DefaultRequestOptions)
- func (c *Client) SetToken(v string)
- type ClientOption
- type CommonOptions
- type ConfigurationFragment
- type ContextAuthTokenKey
- type ContextCommonOptionsKey
- type ContextService
- func (s *ContextService) BootstrapUserFromEnvironment() context.Context
- func (s *ContextService) ClientUser() context.Context
- func (s *ContextService) CommonOptions(opts CommonOptions) context.Context
- func (s *ContextService) ServiceUserContext(tenant string, skipUpdateServiceUsers bool) context.Context
- func (s *ContextService) ServiceUserFromEnvironment() context.Context
- func (s *ContextService) ServiceUserFromRequest(req *http.Request) context.Context
- type CumulocityTokenClaim
- type CurrentTenant
- type DefaultRequestOptions
- type Device
- type DeviceCertificateCollection
- type DeviceCertificateCollectionOptions
- type DeviceCertificateService
- func (s *DeviceCertificateService) Create(ctx context.Context, tenant string, body interface{}) (*Certificate, *Response, error)
- func (s *DeviceCertificateService) Delete(ctx context.Context, tenant string, fingerprint string) (*Response, error)
- func (s *DeviceCertificateService) GetCertificate(ctx context.Context, tenant string, fingerprint string) (*Certificate, *Response, error)
- func (s *DeviceCertificateService) GetCertificates(ctx context.Context, tenant string, opt *DeviceCertificateCollectionOptions) (*DeviceCertificateCollection, *Response, error)
- func (s *DeviceCertificateService) Update(ctx context.Context, tenant string, fingerprint string, body interface{}) (*Certificate, *Response, error)
- type DeviceCredentials
- type DeviceCredentialsService
- func (s *DeviceCredentialsService) Create(ctx context.Context, ID string) (*NewDeviceRequest, *Response, error)
- func (s *DeviceCredentialsService) CreateDeviceCredentials(ctx context.Context, ID string) (*DeviceCredentials, *Response, error)
- func (s *DeviceCredentialsService) Delete(ctx context.Context, ID string) (*Response, error)
- func (s *DeviceCredentialsService) GetNewDeviceRequest(ctx context.Context, ID string) (*NewDeviceRequest, *Response, error)
- func (s *DeviceCredentialsService) GetNewDeviceRequests(ctx context.Context, opt *NewDeviceRequestOptions) (*NewDeviceRequestCollection, *Response, error)
- func (s *DeviceCredentialsService) PollNewDeviceRequest(ctx context.Context, deviceID string, interval time.Duration, ...) (<-chan struct{}, <-chan error)
- func (s *DeviceCredentialsService) Update(ctx context.Context, ID string, status string) (*NewDeviceRequest, *Response, error)
- type DeviceFragment
- type EmptyFragment
- type Error
- type ErrorResponse
- type Event
- type EventBinary
- type EventBuilder
- func (b EventBuilder) DeviceID() string
- func (b EventBuilder) Get(name string) (interface{}, bool)
- func (b EventBuilder) MarshalJSON() ([]byte, error)
- func (b *EventBuilder) Set(name string, value interface{}) *EventBuilder
- func (b *EventBuilder) SetDeviceID(ID string) *EventBuilder
- func (b *EventBuilder) SetText(text string) *EventBuilder
- func (b *EventBuilder) SetTimestamp(value *Timestamp) *EventBuilder
- func (b *EventBuilder) SetType(name string) *EventBuilder
- func (b EventBuilder) Text() string
- func (b EventBuilder) Timestamp() Timestamp
- func (b EventBuilder) Type() string
- type EventCollection
- type EventCollectionOptions
- type EventService
- func (s *EventService) Create(ctx context.Context, body interface{}) (*Event, *Response, error)
- func (s *EventService) CreateBinary(ctx context.Context, filename string, ID string) (*EventBinary, *Response, error)
- func (s *EventService) Delete(ctx context.Context, ID string) (*Response, error)
- func (s *EventService) DeleteBinary(ctx context.Context, ID string) (*Response, error)
- func (s *EventService) DeleteEvents(ctx context.Context, opt *EventCollectionOptions) (*Response, error)
- func (s *EventService) DownloadBinary(ctx context.Context, ID string) (filepath string, err error)
- func (s *EventService) GetEvent(ctx context.Context, ID string) (*Event, *Response, error)
- func (s *EventService) GetEvents(ctx context.Context, opt *EventCollectionOptions) (*EventCollection, *Response, error)
- func (s *EventService) Update(ctx context.Context, ID string, body interface{}) (*Event, *Response, error)
- func (s *EventService) UpdateBinary(ctx context.Context, ID, filename string) (*EventBinary, *Response, error)
- type ExtensionOptions
- type Firmware
- type FirmwareFragment
- type FirmwareVersion
- type FragmentName
- type Group
- type GroupCollection
- type GroupOptions
- type GroupReference
- type GroupReferenceCollection
- type Hub
- type Identity
- type IdentityOptions
- type IdentityReference
- type IdentityService
- func (s *IdentityService) Create(ctx context.Context, ID string, identityType string, externalID string) (*Identity, *Response, error)
- func (s *IdentityService) Delete(ctx context.Context, identityType, externalID string) (*Response, error)
- func (s *IdentityService) GetExternalID(ctx context.Context, identityType string, externalID string) (*Identity, *Response, error)
- type InventoryFirmwareService
- func (s *InventoryFirmwareService) CreateVersion(ctx context.Context, firmwareID string, binaryFile binary.MultiPartReader, ...) (*ManagedObject, *Response, error)
- func (s *InventoryFirmwareService) GetFirmwareByName(ctx context.Context, name string, paging *PaginationOptions) (*ManagedObjectCollection, *Response, error)
- func (s *InventoryFirmwareService) GetFirmwareVersionsByName(ctx context.Context, firmware string, name string, withParents bool, ...) (*ManagedObjectCollection, *Response, error)
- type InventoryService
- func (s *InventoryService) AddChildAddition(ctx context.Context, ID, childID string) (*ManagedObject, *Response, error)
- func (s *InventoryService) Create(ctx context.Context, body interface{}) (*ManagedObject, *Response, error)
- func (s *InventoryService) CreateBinary(ctx context.Context, binaryFile binary.MultiPartReader, ...) (*ManagedObject, *Response, error)
- func (s *InventoryService) CreateChildAddition(ctx context.Context, ID string, body interface{}) (*ManagedObject, *Response, error)
- func (s *InventoryService) CreateChildAdditionWithBinary(ctx context.Context, parentID string, binaryFile binary.MultiPartReader, ...) (*ManagedObject, *Response, error)
- func (s *InventoryService) CreateDevice(ctx context.Context, name string) (*ManagedObject, *Response, error)
- func (s *InventoryService) CreateWithBinary(ctx context.Context, binaryFile binary.MultiPartReader, ...) (*ManagedObject, *Response, error)
- func (s *InventoryService) Delete(ctx context.Context, ID string) (*Response, error)
- func (s *InventoryService) DeleteBinary(ctx context.Context, ID string) (*Response, error)
- func (s *InventoryService) DeleteWithOptions(ctx context.Context, ID string, options *ManagedObjectDeleteOptions) (*Response, error)
- func (s *InventoryService) DownloadBinary(ctx context.Context, ID string) (filepath string, err error)
- func (s *InventoryService) ExpandCollection(ctx context.Context, col *ManagedObjectCollection, maxPages int) (out *ManagedObjectCollection)
- func (s *InventoryService) GetBinaries(ctx context.Context, opt *ManagedObjectOptions) (*ManagedObjectCollection, *Response, error)
- func (s *InventoryService) GetChildAdditions(ctx context.Context, id string, opt *ManagedObjectOptions) (*ManagedObjectReferencesCollection, *Response, error)
- func (s *InventoryService) GetChildAssets(ctx context.Context, id string, opt *ManagedObjectOptions) (*ManagedObjectReferencesCollection, *Response, error)
- func (s *InventoryService) GetChildDevices(ctx context.Context, id string, opt *PaginationOptions) (*ManagedObjectReferencesCollection, *Response, error)
- func (s *InventoryService) GetDevices(ctx context.Context, paging *PaginationOptions) (*ManagedObjectCollection, *Response, error)
- func (s *InventoryService) GetDevicesByName(ctx context.Context, name string, paging *PaginationOptions) (*ManagedObjectCollection, *Response, error)
- func (s *InventoryService) GetManagedObject(ctx context.Context, ID string, opt *ManagedObjectOptions) (*ManagedObject, *Response, error)
- func (s *InventoryService) GetManagedObjects(ctx context.Context, opt *ManagedObjectOptions) (*ManagedObjectCollection, *Response, error)
- func (s *InventoryService) GetSupportedMeasurements(ctx context.Context, id string) (*SupportedMeasurements, *Response, error)
- func (s *InventoryService) GetSupportedSeries(ctx context.Context, id string) (*SupportedSeries, *Response, error)
- func (s *InventoryService) Update(ctx context.Context, ID string, body interface{}) (*ManagedObject, *Response, error)
- func (s *InventoryService) UpdateBinary(ctx context.Context, ID string, file io.Reader) (*ManagedObject, *Response, error)
- type InventorySoftwareService
- func (s *InventorySoftwareService) CreateVersion(ctx context.Context, softwareID string, binaryFile binary.MultiPartReader, ...) (*ManagedObject, *Response, error)
- func (s *InventorySoftwareService) GetSoftwareByName(ctx context.Context, name string, paging *PaginationOptions) (*ManagedObjectCollection, *Response, error)
- func (s *InventorySoftwareService) GetSoftwareVersionsByName(ctx context.Context, software string, name string, withParents bool, ...) (*ManagedObjectCollection, *Response, error)
- type Kpi
- type ManagedObject
- type ManagedObjectCollection
- type ManagedObjectDeleteOptions
- type ManagedObjectOptions
- type ManagedObjectReference
- type ManagedObjectReferencesCollection
- type Measurement
- type MeasurementAggregateValue
- type MeasurementCollection
- type MeasurementCollectionOptions
- type MeasurementRepresentation
- type MeasurementSeriesAggregateGroup
- type MeasurementSeriesAggregateValueGroup
- type MeasurementSeriesDefinition
- type MeasurementSeriesGroup
- type MeasurementSeriesOptions
- type MeasurementSeriesValueGroup
- type MeasurementService
- func (s *MeasurementService) Create(ctx context.Context, body MeasurementRepresentation) (*Measurement, *Response, error)
- func (s *MeasurementService) CreateMeasurements(ctx context.Context, body *Measurements) (*Measurements, *Response, error)
- func (s *MeasurementService) Delete(ctx context.Context, ID string) (*Response, error)
- func (s *MeasurementService) DeleteMeasurements(ctx context.Context, opt *MeasurementCollectionOptions) (*Response, error)
- func (s *MeasurementService) GetMeasurement(ctx context.Context, ID string) (*Measurement, *Response, error)
- func (s *MeasurementService) GetMeasurementSeries(ctx context.Context, opt *MeasurementSeriesOptions) (*MeasurementSeriesGroup, *Response, error)
- func (s *MeasurementService) GetMeasurements(ctx context.Context, opt *MeasurementCollectionOptions) (*MeasurementCollection, *Response, error)
- func (s *MeasurementService) NewMeasurementSourceByName(ctx context.Context, name string) (*MeasurementSource, error)
- type MeasurementSource
- type Measurements
- type Message
- type MetaMessage
- type MicroserviceService
- type NewDeviceRequest
- type NewDeviceRequestCollection
- type NewDeviceRequestOptions
- type Notification2ClientOptions
- type Notification2Service
- func (s *Notification2Service) CreateClient(ctx context.Context, opt Notification2ClientOptions) (*notification2.Notification2Client, error)
- func (s *Notification2Service) CreateSubscription(ctx context.Context, ID string, subscription Notification2Subscription) (*Event, *Response, error)
- func (s *Notification2Service) CreateToken(ctx context.Context, options Notification2TokenOptions) (*Notification2Token, *Response, error)
- func (s *Notification2Service) DeleteSubscription(ctx context.Context, ID string) (*Response, error)
- func (s *Notification2Service) DeleteSubscriptionBySource(ctx context.Context, opt Notification2SubscriptionDeleteOptions) (*Response, error)
- func (s *Notification2Service) GetSubscription(ctx context.Context, ID string) (*Notification2Subscription, *Response, error)
- func (s *Notification2Service) GetSubscriptions(ctx context.Context, opt *Notification2SubscriptionCollectionOptions) (*Notification2SubscriptionCollection, *Response, error)
- func (s *Notification2Service) ParseToken(tokenString string) (*Notification2TokenClaim, error)
- func (s *Notification2Service) RenewToken(ctx context.Context, opt Notification2ClientOptions) (string, error)
- func (s *Notification2Service) UnsubscribeSubscriber(ctx context.Context, token string) (*UnsubscribeResponse, *Response, error)
- type Notification2Subscription
- type Notification2SubscriptionCollection
- type Notification2SubscriptionCollectionOptions
- type Notification2SubscriptionDeleteOptions
- type Notification2SubscriptionFilter
- type Notification2Token
- type Notification2TokenClaim
- type Notification2TokenOptions
- type Number
- type OAuthTokenResponse
- type Operation
- type OperationBuilder
- func (b OperationBuilder) DeviceID() string
- func (b OperationBuilder) Get(name string) (interface{}, bool)
- func (b OperationBuilder) MarshalJSON() ([]byte, error)
- func (b *OperationBuilder) Set(name string, value interface{}) *OperationBuilder
- func (b *OperationBuilder) SetDeviceID(ID string) *OperationBuilder
- type OperationCollection
- type OperationCollectionOptions
- type OperationService
- func (s *OperationService) Create(ctx context.Context, body interface{}) (*Operation, *Response, error)
- func (s *OperationService) DeleteOperations(ctx context.Context, opt *OperationCollectionOptions) (*Response, error)
- func (s *OperationService) GetOperation(ctx context.Context, ID string) (*Operation, *Response, error)
- func (s *OperationService) GetOperations(ctx context.Context, opt *OperationCollectionOptions) (*OperationCollection, *Response, error)
- func (s *OperationService) Update(ctx context.Context, ID string, body *OperationUpdateOptions) (*Operation, *Response, error)
- type OperationUpdateOptions
- type PaginationOptions
- type ParentDevices
- type ProxyReader
- type RealtimeClient
- func (c *RealtimeClient) Close() error
- func (c *RealtimeClient) Connect() error
- func (c *RealtimeClient) Disconnect() error
- func (c *RealtimeClient) IsConnected() bool
- func (c *RealtimeClient) SetBearerToken(token string)
- func (c *RealtimeClient) SetCookies(cookies []*http.Cookie) error
- func (c *RealtimeClient) SetRequestHeader(header http.Header)
- func (c *RealtimeClient) SetXSRFToken(token string)
- func (c *RealtimeClient) Subscribe(pattern string, out chan<- *Message) chan error
- func (c *RealtimeClient) TenantName() string
- func (c *RealtimeClient) Unsubscribe(pattern string) chan error
- func (c *RealtimeClient) UnsubscribeAll() chan error
- func (c *RealtimeClient) WaitForMessage(ID string) chan error
- func (c *RealtimeClient) WaitForMessages(ids ...string) chan error
- type RealtimeData
- type RemoteAccessCollectionOptions
- type RemoteAccessConfiguration
- type RemoteAccessCredentials
- type RemoteAccessService
- func (s *RemoteAccessService) Create(ctx context.Context, mo_id string, config_id string, body interface{}) (*RemoteAccessConfiguration, *Response, error)
- func (s *RemoteAccessService) DeleteConfiguration(ctx context.Context, mo_id string, config_id string, ...) (*Response, error)
- func (s *RemoteAccessService) GetConfiguration(ctx context.Context, mo_id, config_id string) (*RemoteAccessConfiguration, *Response, error)
- func (s *RemoteAccessService) GetConfigurations(ctx context.Context, mo_id string, opt *RemoteAccessCollectionOptions) ([]RemoteAccessConfiguration, *Response, error)
- func (s *RemoteAccessService) Update(ctx context.Context, mo_id string, config_id string, ...) (*Operation, *Response, error)
- type RequestMiddleware
- type RequestOptions
- type RequestValidator
- type Response
- func (r *Response) Body() []byte
- func (r *Response) Cookies() []*http.Cookie
- func (r *Response) DecodeJSON(v interface{}) error
- func (r *Response) Duration() time.Duration
- func (r *Response) Header() http.Header
- func (r *Response) IsError() bool
- func (r *Response) IsSuccess() bool
- func (r *Response) JSON(path ...string) gjson.Result
- func (r *Response) Proto() string
- func (r *Response) RawBody() io.ReadCloser
- func (r *Response) ReceivedAt() time.Time
- func (r *Response) SetBody(v []byte)
- func (r *Response) Size() int64
- func (r *Response) Status() string
- func (r *Response) StatusCode() int
- func (r *Response) String() string
- type RetentionRule
- type RetentionRuleCollection
- type RetentionRuleService
- func (s *RetentionRuleService) Create(ctx context.Context, body RetentionRule) (*RetentionRule, *Response, error)
- func (s *RetentionRuleService) Delete(ctx context.Context, ID string) (*Response, error)
- func (s *RetentionRuleService) GetRetentionRule(ctx context.Context, ID string) (*RetentionRule, *Response, error)
- func (s *RetentionRuleService) GetRetentionRules(ctx context.Context, opt *PaginationOptions) (*RetentionRuleCollection, *Response, error)
- func (s *RetentionRuleService) Update(ctx context.Context, ID string, body RetentionRule) (*RetentionRule, *Response, error)
- type Role
- type RoleCollection
- type RoleOptions
- type RoleReference
- type RoleReferenceCollection
- type ServiceUser
- type SimpleMeasurementOptions
- type Software
- type SoftwareFragment
- type SoftwareVersion
- type Source
- type Statistics
- type StoreMode
- type SupportedMeasurements
- type SupportedOperationsFragment
- type SupportedSeries
- type Tenant
- type TenantCollection
- type TenantLoginOption
- type TenantLoginOptions
- type TenantOption
- type TenantOptionCollection
- type TenantOptionsService
- func (s *TenantOptionsService) Create(ctx context.Context, body *TenantOption) (*TenantOption, *Response, error)
- func (s *TenantOptionsService) Delete(ctx context.Context, category, key string) (*Response, error)
- func (s *TenantOptionsService) GetOption(ctx context.Context, category, key string) (*TenantOption, *Response, error)
- func (s *TenantOptionsService) GetOptions(ctx context.Context, opt *PaginationOptions) (*TenantOptionCollection, *Response, error)
- func (s *TenantOptionsService) GetOptionsForCategory(ctx context.Context, category string) (map[string]string, *Response, error)
- func (s *TenantOptionsService) GetSystemOption(ctx context.Context, category, key string) (*TenantOption, *Response, error)
- func (s *TenantOptionsService) GetSystemOptions(ctx context.Context, opt *PaginationOptions) (*TenantOptionCollection, *Response, error)
- func (s *TenantOptionsService) GetVersion(ctx context.Context) (string, error)
- func (s *TenantOptionsService) Update(ctx context.Context, category, key string, value string) (*TenantOption, *Response, error)
- func (s *TenantOptionsService) UpdateEditability(ctx context.Context, category, key string, editable bool) (*TenantOption, *Response, error)
- func (s *TenantOptionsService) UpdateOptions(ctx context.Context, category string, body map[string]string) (map[string]string, *Response, error)
- type TenantService
- func (s *TenantService) AddApplicationReference(ctx context.Context, tenantID string, appSelfReference string) (*ApplicationReference, *Response, error)
- func (s *TenantService) Create(ctx context.Context, body *Tenant) (*Tenant, *Response, error)
- func (s *TenantService) Delete(ctx context.Context, ID string) (*Response, error)
- func (s *TenantService) DeleteApplicationReference(ctx context.Context, tenantID string, applicationID string) (*Response, error)
- func (s *TenantService) GetAllTenantsStatisticsSummary(ctx context.Context, opt *TenantStatisticsOptions) ([]TenantUsageStatisticsSummaryExtended, *Response, error)
- func (s *TenantService) GetApplicationReferences(ctx context.Context, tenantID string, opts *PaginationOptions) (*ApplicationReferenceCollection, *Response, error)
- func (s *TenantService) GetCurrentTenant(ctx context.Context) (*CurrentTenant, *Response, error)
- func (s *TenantService) GetLoginOptions(ctx context.Context) (*TenantLoginOptions, *Response, error)
- func (s *TenantService) GetTenant(ctx context.Context, ID string) (*Tenant, *Response, error)
- func (s *TenantService) GetTenantStatistics(ctx context.Context, opt *TenantStatisticsOptions) (*TenantUsageStatisticsCollection, *Response, error)
- func (s *TenantService) GetTenantStatisticsSummary(ctx context.Context, opt *TenantSummaryOptions) (*TenantSummary, *Response, error)
- func (s *TenantService) GetTenants(ctx context.Context, opt *PaginationOptions) (*TenantCollection, *Response, error)
- func (s *TenantService) Update(ctx context.Context, ID string, body *Tenant) (*Tenant, *Response, error)
- type TenantStatisticsOptions
- type TenantSummary
- type TenantSummaryOptions
- type TenantUsageStatisticsCollection
- type TenantUsageStatisticsSummary
- type TenantUsageStatisticsSummaryExtended
- type Timestamp
- type UIExtension
- type UIExtensionService
- func (s *UIExtensionService) CreateExtension(ctx context.Context, application *Application, filename any, opt UpsertOptions) (*ApplicationVersion, *Response, error)
- func (s *UIExtensionService) GetExtensions(ctx context.Context, opt *ExtensionOptions) (*ApplicationCollection, *Response, error)
- func (s *UIExtensionService) NewUIExtensionFromFile(filename string) (*UIExtension, error)
- func (s *UIExtensionService) SetActive(ctx context.Context, appID string, binaryID string) (*Application, *Response, error)
- type UIManifest
- type UIManifestFile
- type UnsubscribeResponse
- type UpsertOptions
- type User
- type UserCollection
- type UserOptions
- type UserReference
- type UserReferenceCollection
- type UserService
- func (s *UserService) AddUserToGroup(ctx context.Context, user *User, groupID string) (*UserReference, *Response, error)
- func (s *UserService) AssignRoleToGroup(ctx context.Context, groupID string, roleSelfReference string) (*RoleReference, *Response, error)
- func (s *UserService) AssignRoleToUser(ctx context.Context, username string, roleSelfReference string) (*RoleReference, *Response, error)
- func (s *UserService) Create(ctx context.Context, body *User) (*User, *Response, error)
- func (s *UserService) CreateGroup(ctx context.Context, body *Group) (*Group, *Response, error)
- func (s *UserService) Delete(ctx context.Context, ID string) (*Response, error)
- func (s *UserService) DeleteGroup(ctx context.Context, ID string) (*Response, error)
- func (s *UserService) GetCurrentUser(ctx context.Context) (*User, *Response, error)
- func (s *UserService) GetGroup(ctx context.Context, ID string) (*Group, *Response, error)
- func (s *UserService) GetGroupByName(ctx context.Context, name string) (*Group, *Response, error)
- func (s *UserService) GetGroups(ctx context.Context, opt *GroupOptions) (*GroupCollection, *Response, error)
- func (s *UserService) GetGroupsByUser(ctx context.Context, username string, opt *GroupOptions) (*GroupReferenceCollection, *Response, error)
- func (s *UserService) GetRole(ctx context.Context, ID string) (*Role, *Response, error)
- func (s *UserService) GetRoles(ctx context.Context, opt *RoleOptions) (*RoleCollection, *Response, error)
- func (s *UserService) GetRolesByGroup(ctx context.Context, groupID string, opt *RoleOptions) (*RoleReferenceCollection, *Response, error)
- func (s *UserService) GetRolesByUser(ctx context.Context, username string, opt *RoleOptions) (*RoleReferenceCollection, *Response, error)
- func (s *UserService) GetUser(ctx context.Context, ID string) (*User, *Response, error)
- func (s *UserService) GetUserByUsername(ctx context.Context, username string) (*User, *Response, error)
- func (s *UserService) GetUsers(ctx context.Context, opt *UserOptions) (*UserCollection, *Response, error)
- func (s *UserService) GetUsersByGroup(ctx context.Context, groupID string, opt *UserOptions) (*UserReferenceCollection, *Response, error)
- func (s *UserService) RemoveUserFromGroup(ctx context.Context, username string, groupID string) (*Response, error)
- func (s *UserService) UnassignRoleFromGroup(ctx context.Context, groupID string, roleName string) (*Response, error)
- func (s *UserService) UnassignRoleFromUser(ctx context.Context, username string, roleName string) (*Response, error)
- func (s *UserService) Update(ctx context.Context, ID string, body *User) (*User, *Response, error)
- func (s *UserService) UpdateCurrentUser(ctx context.Context, body *User) (*User, *Response, error)
- func (s *UserService) UpdateGroup(ctx context.Context, ID string, body *Group) (*Group, *Response, error)
- type ValueFragmentSeries
- type ValueFragmentType
Constants ¶
const ( AlarmSeverityCritical = "CRITICAL" AlarmSeverityMajor = "MAJOR" AlarmSeverityMinor = "MINOR" AlarmSeverityWarning = "WARNING" )
Cumulocity alarm Severity types
const ( AlarmStatusActive = "ACTIVE" AlarmStatusAcknowledged = "ACKNOWLEDGED" AlarmStatusCleared = "CLEARED" )
Cumulocity alarm status states
const ( ApplicationTypeMicroservice = "MICROSERVICE" ApplicationTypeExternal = "EXTERNAL" ApplicationTypeHosted = "HOSTED" ApplicationTypeApamaCEPRule = "APAMA_CEP_RULE" )
Cumulocity Application Types
const ( ApplicationAvailabilityMarket = "MARKET" ApplicationAvailabilityPrivate = "PRIVATE" )
Cumulocity Application Availability values
const ( // AuthMethodOAuth2Internal OAuth2 internal mode AuthMethodOAuth2Internal = "OAUTH2_INTERNAL" // AuthMethodBasic Basic authentication AuthMethodBasic = "BASIC" // AuthMethodNone no authentication AuthMethodNone = "NONE" )
const ( NewDeviceRequestWaitingForConnection = "WAITING_FOR_CONNECTION" NewDeviceRequestPendingAcceptance = "PENDING_ACCEPTANCE" NewDeviceRequestAccepted = "ACCEPTED" )
Cumulocity New Device Request statuses
const ( EnvironmentBootstrapTenant = "C8Y_BOOTSTRAP_TENANT" EnvironmentBootstrapUsername = "C8Y_BOOTSTRAP_USER" EnvironmentBootstrapPassword = "C8Y_BOOTSTRAP_PASSWORD" )
Application Bootstrap User Environment variables
const ( EnvironmentApplicationName = "APPLICATION_NAME" EnvironmentBaseURL = "C8Y_BASEURL" EnvironmentTenant = "C8Y_TENANT" EnvironmentUsername = "C8Y_USER" EnvironmentPassword = "C8Y_PASSWORD" )
Application Environment variables
const ( OperationStatusPending = "PENDING" OperationStatusExecuting = "EXECUTING" OperationStatusSuccessful = "SUCCESSFUL" OperationStatusFailed = "FAILED" )
Cumulocity Operation Status states
const ( // VERSION preferred Bayeux version VERSION = "1.0" // MINIMUM_VERSION supported Bayeux version MINIMUM_VERSION = "1.0" // MinimumRetryDelay is the minimum retry delay in milliseconds to wait before sending another /meta/connect message MinimumRetryDelay int64 = 500 )
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 follows // interval = MinimumRetryInterval // interval = Min(MaximumRetryInterval, interval * RetryBackoffFactor) RetryBackoffFactor float64 = 1.5 )
const ( RemoteAccessProtocolPassthrough = "PASSTHROUGH" RemoteAccessProtocolSSH = "SSH" RemoteAccessProtocolVNC = "VNC" RemoteAccessProtocolTelnet = "TELNET" )
const CumulocityUIManifestFile = "cumulocity.json"
const DeviceFragmentName = "c8y_IsDevice"
DeviceFragmentName name of the c8yDevice Fragment property
const (
EnvironmentMicroserviceIsolation = "C8Y_MICROSERVICE_ISOLATION"
)
Microservice environment variables
const FragmentFirmware = "c8y_Firmware"
const FragmentFirmwareBinary = "c8y_FirmwareBinary"
const FragmentSoftware = "c8y_Software"
const FragmentSoftwareBinary = "c8y_SoftwareBinary"
const (
// RetentionRuleAPI base endpoint
RetentionRuleAPI = "retention/retentions"
)
const TimeFormat = "Mon, 02 Jan 2006 15:04:05 GMT"
Variables ¶
var ApplicationTagLatest = "latest"
var ContentTypeApplicationVersion = "application/vnd.com.nsn.cumulocity.applicationVersion+json"
var ContentTypeApplicationVersionCollection = "application/vnd.com.nsn.cumulocity.applicationVersionCollection+json"
var (
// EnvVarLoggerHideSensitive environment variable name used to control whether 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"
)
var ErrNotFound = errors.New("item: not found")
var Logger logger.Logger
Logger used within the c8y client
var MethodsWithBody = []string{ http.MethodDelete, http.MethodPatch, http.MethodPost, http.MethodPut, }
var (
MinTokenMinutes int64 = 1
)
Functions ¶
func CheckResponse ¶
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 ¶
DecodeJSONBytes decodes json preserving number formatting (especially large integers and scientific notation floats)
func DecodeJSONFile ¶
DecodeJSONFile decodes a json file into dst interface
func DecodeJSONReader ¶
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 FormatBaseURL ¶ added in v0.21.2
Format the base url to ensure it is normalized for cases where the scheme can be missing, and the trailing slash (which affects the default path used in calls)
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 ¶
GetDateRange returns the dateFrom and dateTo based on an interval string, i.e. 1d, is 1 day
func GetRoundedTime ¶
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 NewAuthorizationContext ¶
NewAuthorizationContext returns context with the Authorization token set given explicit tenant, username and password.
func NewAuthorizationContextFromRequest ¶
NewAuthorizationContextFromRequest returns a new context with the Authorization token set which will override the Basic Auth in subsequent REST requests
func NewBasicAuthString ¶
NewBasicAuthString returns a Basic Authorization key used for rest requests
func NewCachedClient ¶ added in v0.14.0
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 ¶
RealtimeAlarms subscribes to events on alarms objects from the CEP realtime engine
func RealtimeAlarmsWithChildren ¶
RealtimeAlarmsWithChildren subscribes to events on alarms (including children) objects from the CEP realtime engine
func RealtimeEvents ¶
RealtimeEvents subscribes to events on event objects from the CEP realtime engine
func RealtimeManagedObjects ¶
RealtimeManagedObjects subscribes to events on managed objects from the CEP realtime engine
func RealtimeMeasurements ¶
RealtimeMeasurements subscribes to events on measurement objects from the CEP realtime engine
func RealtimeOperations ¶
RealtimeOperations subscribes to events on operations objects from the CEP realtime engine
func RequestSupportsBody ¶ added in v0.14.0
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 WithCommonOptionsContext ¶ added in v0.14.9
func WithCommonOptionsContext(ctx context.Context, opts CommonOptions) context.Context
Create a context with common options
Types ¶
type AdditionParents ¶ added in v0.14.0
type AdditionParents struct { Self string `json:"self"` References []ManagedObjectReference `json:"references"` }
type Agent ¶
type Agent struct { DeviceFragment AgentFragment ManagedObject }
Agent is a subset of a 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
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) 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) GetAlarms ¶
func (s *AlarmService) GetAlarms(ctx context.Context, opt *AlarmCollectionOptions) (*AlarmCollection, *Response, error)
GetAlarms returns a collection of alarms using the specified search options
func (*AlarmService) Update ¶
func (s *AlarmService) Update(ctx context.Context, ID string, body AlarmUpdateProperties) (*Alarm, *Response, error)
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 ¶
func (s *ApplicationService) Copy(ctx context.Context, ID string) (*Application, *Response, error)
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 ¶
func (s *ApplicationService) Create(ctx context.Context, body *Application) (*Application, *Response, error)
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) 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 ¶
func (s *ApplicationService) GetApplications(ctx context.Context, opt *ApplicationOptions) (*ApplicationCollection, *Response, error)
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 ¶
func (s *ApplicationService) Update(ctx context.Context, ID string, body *Application) (*Application, *Response, error)
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
func (o *ApplicationVersionsOptions) WithHasVersions(v bool) *ApplicationVersionsOptions
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
func (s *ApplicationVersionsService) GetVersionByTag(ctx context.Context, ID string, tag string) (*ApplicationVersion, *Response, error)
Retrieve the selected version of an application in your tenant using the tag
func (*ApplicationVersionsService) GetVersions ¶ added in v0.15.0
func (s *ApplicationVersionsService) GetVersions(ctx context.Context, ID string, opt *ApplicationVersionsOptions) (*ApplicationVersionsCollection, *Response, error)
Retrieve all versions of an application in your tenant
func (*ApplicationVersionsService) IsUrl ¶ added in v0.15.0
func (s *ApplicationVersionsService) IsUrl(u string) bool
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 ¶
func (s *AuditService) GetAuditRecords(ctx context.Context, opt *AuditRecordCollectionOptions) (*AuditRecordCollection, *Response, error)
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 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 RemoteAccess *RemoteAccessService 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 ¶
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
Get hostname (parse from either the token)
func (*Client) GetTenantName ¶ added in v0.14.7
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
Get the username. Parse the token if exists
func (*Client) GetXSRFToken ¶ added in v0.14.0
GetXSRFToken returns the XSRF Token if found in the configured cookies
func (*Client) HideSensitiveInformationIfActive ¶ added in v0.16.0
func (*Client) LoginUsingOAuth2 ¶ added in v0.14.0
LoginUsingOAuth2 login to Cumulocity using OAuth2
func (*Client) LoginUsingOAuth2External ¶ added in v0.21.4
func (c *Client) LoginUsingOAuth2External(ctx context.Context, code string, initRequest ...string) error
LoginUsingOAuth2External login to Cumulocity using an external OAuth2 code
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) ParseToken ¶ added in v0.14.7
func (c *Client) ParseToken(tokenString string) (*CumulocityTokenClaim, error)
Parse a JWT claims
func (*Client) SendRequest ¶
SendRequest creates and sends a request
func (*Client) SetAuthorization ¶
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
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
SetBearerAuthorization set bearer authorization header
func (*Client) SetCookies ¶ added in v0.14.0
SetCookies set the cookies to use for all rest requests
func (*Client) SetDomain ¶ added in v0.14.0
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 (*Client) SetJSONItems ¶
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
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 options 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 selected 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 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
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, tenant string, 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, tenant string, 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, tenant string, fingerprint string) (*Certificate, *Response, error)
GetCertificate returns a single certificate
func (*DeviceCertificateService) GetCertificates ¶ added in v0.14.0
func (s *DeviceCertificateService) GetCertificates(ctx context.Context, tenant string, opt *DeviceCertificateCollectionOptions) (*DeviceCertificateCollection, *Response, error)
GetCertificates returns collection of certificates
func (*DeviceCertificateService) Update ¶ added in v0.14.0
func (s *DeviceCertificateService) Update(ctx context.Context, tenant string, 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 ¶
func (s *DeviceCredentialsService) Create(ctx context.Context, ID string) (*NewDeviceRequest, *Response, error)
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) 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 ¶
func (s *DeviceCredentialsService) GetNewDeviceRequests(ctx context.Context, opt *NewDeviceRequestOptions) (*NewDeviceRequestCollection, *Response, error)
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 intervals. 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 ¶
func (s *DeviceCredentialsService) Update(ctx context.Context, ID string, status string) (*NewDeviceRequest, *Response, error)
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
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
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) 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) DeleteBinary ¶
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 ¶
DownloadBinary retrieves the binary attached to the given event
func (*EventService) GetEvents ¶
func (s *EventService) GetEvents(ctx context.Context, opt *EventCollectionOptions) (*EventCollection, *Response, error)
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
NewFirmware returns a simple firmware managed object
type FirmwareFragment ¶ added in v0.14.0
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"` }
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 (*Hub) GetActiveChannels ¶ added in v0.6.0
GetActiveChannels returns the list of active channels which are currently subscribed to
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 ¶
IdentityOptions Identity parameters required when creating a new external id
type IdentityReference ¶
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
func (s *InventoryFirmwareService) GetFirmwareByName(ctx context.Context, name string, paging *PaginationOptions) (*ManagedObjectCollection, *Response, error)
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 managed object is deleted
func (*InventoryService) DeleteBinary ¶
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 ¶
func (s *InventoryService) GetBinaries(ctx context.Context, opt *ManagedObjectOptions) (*ManagedObjectCollection, *Response, error)
GetBinaries returns a list of managed object binaries
func (*InventoryService) GetChildAdditions ¶ added in v0.14.0
func (s *InventoryService) GetChildAdditions(ctx context.Context, id string, opt *ManagedObjectOptions) (*ManagedObjectReferencesCollection, *Response, error)
GetChildAdditions returns a list of child additions related to a given managed object
func (*InventoryService) GetChildAssets ¶ added in v0.14.0
func (s *InventoryService) GetChildAssets(ctx context.Context, id string, opt *ManagedObjectOptions) (*ManagedObjectReferencesCollection, *Response, error)
GetChildAssets returns a list of child assets related to a given managed object
func (*InventoryService) GetChildDevices ¶
func (s *InventoryService) GetChildDevices(ctx context.Context, id string, opt *PaginationOptions) (*ManagedObjectReferencesCollection, *Response, error)
GetChildDevices Get the child devices of a given managed object
func (*InventoryService) GetDevices ¶
func (s *InventoryService) GetDevices(ctx context.Context, paging *PaginationOptions) (*ManagedObjectCollection, *Response, error)
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 ¶
func (s *InventoryService) GetManagedObjects(ctx context.Context, opt *ManagedObjectOptions) (*ManagedObjectCollection, *Response, error)
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
func (s *InventorySoftwareService) GetSoftwareByName(ctx context.Context, name string, paging *PaginationOptions) (*ManagedObjectCollection, *Response, error)
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 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
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 (o *ManagedObjectDeleteOptions) WithCascade(v bool) *ManagedObjectDeleteOptions
func (*ManagedObjectDeleteOptions) WithDeviceUser ¶ added in v0.14.0
func (o *ManagedObjectDeleteOptions) WithDeviceUser(v bool) *ManagedObjectDeleteOptions
func (*ManagedObjectDeleteOptions) WithForceCascade ¶ added in v0.14.0
func (o *ManagedObjectDeleteOptions) WithForceCascade(v bool) *ManagedObjectDeleteOptions
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 ¶
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 measurement 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 ¶
func (s *MeasurementService) Create(ctx context.Context, body MeasurementRepresentation) (*Measurement, *Response, error)
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 ¶
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 ¶
func (s *MeasurementService) GetMeasurementSeries(ctx context.Context, opt *MeasurementSeriesOptions) (*MeasurementSeriesGroup, *Response, error)
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 ¶
func (s *MeasurementService) GetMeasurements(ctx context.Context, opt *MeasurementCollectionOptions) (*MeasurementCollection, *Response, error)
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 ¶
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
func (s *Notification2Service) CreateClient(ctx context.Context, opt Notification2ClientOptions) (*notification2.Notification2Client, error)
Create a notification2 client to subscribe to new options
Example ¶
```
notificationsClient, 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) notificationsClient.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) notificationsClient.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
func (s *Notification2Service) CreateToken(ctx context.Context, options Notification2TokenOptions) (*Notification2Token, *Response, error)
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
func (s *Notification2Service) GetSubscription(ctx context.Context, ID string) (*Notification2Subscription, *Response, error)
Get subscription by id
func (*Notification2Service) GetSubscriptions ¶ added in v0.14.0
func (s *Notification2Service) GetSubscriptions(ctx context.Context, opt *Notification2SubscriptionCollectionOptions) (*Notification2SubscriptionCollection, *Response, error)
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 (s *Notification2Service) RenewToken(ctx context.Context, opt Notification2ClientOptions) (string, error)
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:"-"` }
Notification2Subscription 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 }
Notification2SubscriptionCollectionOptions 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 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"` 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"` Shared bool `json:"shared,omitempty"` }
EventCollectionOptions todo
type 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 (*Number) MarshalJSON ¶
MarshalJSON converts the Number to its json representation (allowing for null values)
func (*Number) SimpleFloat64 ¶
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 OAuthTokenResponse ¶ added in v0.21.4
type OAuthTokenResponse struct {
AccessToken string `json:"access_token,omitempty"`
}
OAuthTokenResponse OAuth Token Response
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 ¶
func (s *OperationService) GetOperations(ctx context.Context, opt *OperationCollectionOptions) (*OperationCollection, *Response, error)
GetOperations returns a collection of Cumulocity operations
func (*OperationService) Update ¶
func (s *OperationService) Update(ctx context.Context, ID string, body *OperationUpdateOptions) (*Operation, *Response, error)
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
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 establishing 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 RemoteAccessCollectionOptions ¶ added in v0.16.0
type RemoteAccessCollectionOptions struct { // Pagination options PaginationOptions }
RemoteAccessCollectionOptions remote access collection filter options
type RemoteAccessConfiguration ¶ added in v0.16.0
type RemoteAccessConfiguration struct { ID string `json:"id"` Name string `json:"name"` Hostname string `json:"hostname"` Port int `json:"port"` Protocol string `json:"protocol"` Credentials RemoteAccessCredentials `json:"credentials"` }
RemoteAccessCollection collection of remote access configurations
type RemoteAccessCredentials ¶ added in v0.16.0
type RemoteAccessCredentials struct { Type string `json:"type"` Username string `json:"username"` Password string `json:"password"` PublicKey string `json:"publicKey"` PrivateKey string `json:"privateKey"` HostKey string `json:"hostKey"` }
RemoteAccessCredentials
type RemoteAccessService ¶ added in v0.16.0
type RemoteAccessService service
RemoteAccessService
func (*RemoteAccessService) Create ¶ added in v0.16.0
func (s *RemoteAccessService) Create(ctx context.Context, mo_id string, config_id string, body interface{}) (*RemoteAccessConfiguration, *Response, error)
Create creates a new operation for a device
func (*RemoteAccessService) DeleteConfiguration ¶ added in v0.16.0
func (s *RemoteAccessService) DeleteConfiguration(ctx context.Context, mo_id string, config_id string, opt *RemoteAccessCollectionOptions) (*Response, error)
DeleteConfiguration delete remote access configuration
func (*RemoteAccessService) GetConfiguration ¶ added in v0.16.0
func (s *RemoteAccessService) GetConfiguration(ctx context.Context, mo_id, config_id string) (*RemoteAccessConfiguration, *Response, error)
GetConfiguration return a specific remote access configuration for a given device
func (*RemoteAccessService) GetConfigurations ¶ added in v0.16.0
func (s *RemoteAccessService) GetConfigurations(ctx context.Context, mo_id string, opt *RemoteAccessCollectionOptions) ([]RemoteAccessConfiguration, *Response, error)
GetConfigurations returns a collection of Cumulocity remote access configurations for a given managed object
type RequestMiddleware ¶ added in v0.14.0
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
Request validator function to be used to check if the outgoing request is properly formulated
type Response ¶
Response struct holds response values of executed request.
func (*Response) Body ¶ added in v0.14.0
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) DecodeJSON ¶
DecodeJSON returns the json response decoded into the given interface
func (*Response) IsError ¶ added in v0.14.0
IsError method returns true if HTTP status `code >= 400` otherwise false.
func (*Response) IsSuccess ¶ added in v0.14.0
IsSuccess method returns true if HTTP status `code >= 200 and <= 299` otherwise false.
func (*Response) Proto ¶ added in v0.14.0
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.
func (*Response) ReceivedAt ¶ added in v0.14.0
ReceivedAt method returns when response got received from server for the request.
func (*Response) Size ¶ added in v0.14.0
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 the client calculates response size at the client end. You will get actual size of the http response.
func (*Response) Status ¶ added in v0.14.0
Status method returns the HTTP status string for the executed request.
Example: 200 OK
func (*Response) StatusCode ¶ added in v0.14.0
StatusCode method returns the HTTP status code for the executed request.
Example: 200
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 ¶
func (s *RetentionRuleService) Create(ctx context.Context, body RetentionRule) (*RetentionRule, *Response, error)
Create creates a new event object
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 ¶
func (s *RetentionRuleService) GetRetentionRules(ctx context.Context, opt *PaginationOptions) (*RetentionRuleCollection, *Response, error)
GetRetentionRules returns a list of events based on given filters
func (*RetentionRuleService) Update ¶
func (s *RetentionRuleService) Update(ctx context.Context, ID string, body RetentionRule) (*RetentionRule, *Response, error)
Update updates properties on an existing retention rule
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 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
NewSoftware returns a simple software managed object
type SoftwareFragment ¶ added in v0.14.0
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
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 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"` }
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 ¶
func (s *TenantOptionsService) Create(ctx context.Context, body *TenantOption) (*TenantOption, *Response, error)
Create adds a new tenant
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 ¶
func (s *TenantOptionsService) GetOptions(ctx context.Context, opt *PaginationOptions) (*TenantOptionCollection, *Response, error)
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 ¶
func (s *TenantOptionsService) GetSystemOptions(ctx context.Context, opt *PaginationOptions) (*TenantOptionCollection, *Response, error)
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
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) 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) GetTenantStatistics ¶
func (s *TenantService) GetTenantStatistics(ctx context.Context, opt *TenantStatisticsOptions) (*TenantUsageStatisticsCollection, *Response, error)
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 ¶
func (s *TenantService) GetTenants(ctx context.Context, opt *PaginationOptions) (*TenantCollection, *Response, error)
GetTenants returns collection of tenants
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 ¶
Timestamp represents a time that can be deserialized 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 ¶
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) UnmarshalJSON ¶
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
func (s *UIExtensionService) GetExtensions(ctx context.Context, opt *ExtensionOptions) (*ApplicationCollection, *Response, error)
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"` EffectiveRoles []Role `json:"effectiveRoles,omitempty"` Item gjson.Result `json:"-"` }
User todo
func (*User) SetEnabled ¶
func (*User) SetFirstName ¶
func (*User) SetLastName ¶
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 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) CreateGroup ¶
CreateGroup creates a new group with the given name
func (*UserService) DeleteGroup ¶
DeleteGroup deletes an existing group Info: ADMINS and DEVICES groups can not be deleted
func (*UserService) GetCurrentUser ¶
GetCurrentUser returns the current user based on the request's credentials
func (*UserService) GetGroupByName ¶
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) 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) 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) UpdateCurrentUser ¶
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 ¶
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
Source Files
¶
- alarm.go
- alarmBuilder.go
- application.go
- applicationVersions.go
- audit.go
- auth.go
- cache.go
- client.go
- commonOptions.go
- context.go
- dateHelper.go
- device.go
- deviceCertificate.go
- deviceCredentials.go
- event.go
- eventBuilder.go
- firmware.go
- hub.go
- identity.go
- inventory.go
- logger.go
- measurement.go
- measurementRepresentation.go
- microservice.go
- middleware.go
- notification2service.go
- number.go
- operation.go
- operationBuilder.go
- operationRepresentation.go
- paginationOptions.go
- proxyreader.go
- realtime.go
- remoteaccess.go
- response.go
- retentionRules.go
- software.go
- statistics.go
- tenant.go
- tenantOptions.go
- timestamp.go
- uiExtension.go
- user.go
- utils.go