Documentation
¶
Overview ¶
Package tdr provides support for HSDP TDR operations
Index ¶
- Constants
- Variables
- func String(v string) *string
- type Client
- type Config
- type Contract
- type ContractsService
- type DataItem
- type DataItemsService
- type DataType
- type DeletePolicy
- type Device
- type ErrorResponse
- type GetContractOptions
- type GetDataItemOptions
- type KeyValue
- type Meta
- type OptionFunc
- type RelatedPeripheral
- type RelatedUser
- type Response
- type User
Constants ¶
const (
APIVersion = "5"
)
Variables ¶
var ( ErrBaseTDRCannotBeEmpty = errors.New("base TDR URL cannot be empty") ErrMissingTDRScopes = errors.New("missing TDR scopes. Need 'tdr.contract' and 'tdr.dataitem'") ErrEmptyResult = errors.New("empty result") ErrCouldNoReadResourceAfterCreate = errors.New("could not read resource after create") ErrEmptyResults = errors.New("empty results") )
Errors
Functions ¶
Types ¶
type Client ¶
type Client struct { // User agent used when communicating with the HSDP IAM API. UserAgent string Contracts *ContractsService DataItems *DataItemsService // contains filtered or unexported fields }
A Client manages communication with HSDP IAM API
func NewClient ¶
NewClient returns a new HSDP TDR API client. If a nil httpClient is provided, http.DefaultClient will be used. A configured IAM client must be provided as well
func (*Client) Do ¶
Do executes a http request. If v implements the io.Writer interface, the raw response body will be written to v, without attempting to first decode it.
func (*Client) SetBaseTDRURL ¶
SetBaseTDRURL sets the base URL for API requests to a custom endpoint. urlStr should always be specified with a trailing slash.
type Contract ¶
type Contract struct { ID string `json:"id,omitempty"` Meta *Meta `json:"meta,omitempty"` DataType DataType `json:"dataType,omitempty"` Schema json.RawMessage `json:"schema,omitempty"` Organization string `json:"organization,omitempty"` SendNotifications bool `json:"sendNotifications"` NotificationServiceTopicID string `json:"notificationServiceTopicId,omitempty"` DeletePolicy DeletePolicy `json:"deletePolicy"` }
Contract describes a TDR Contract
type ContractsService ¶
type ContractsService struct {
// contains filtered or unexported fields
}
ContractsService provides operations on TDR contracts
func (*ContractsService) CreateContract ¶
func (c *ContractsService) CreateContract(contract Contract) (bool, *Response, error)
CreateContract creates a new contract in TDR
func (*ContractsService) GetContract ¶
func (c *ContractsService) GetContract(opt *GetContractOptions, options ...OptionFunc) ([]*Contract, *Response, error)
GetContract searches for contracts in TDR
type DataItem ¶
type DataItem struct { ID string `json:"id,omitempty"` Meta Meta `json:"meta,omitempty"` ResourceType string `json:"resourceType,omitempty"` Timestamp string `json:"timestamp,omitempty"` SequenceNumber int `json:"sequenceNumber,omitempty"` Device Device `json:"device,omitempty"` User User `json:"user,omitempty"` RelatedPeripheral RelatedPeripheral `json:"relatedPeripheral,omitempty"` RelatedUser RelatedUser `json:"relatedUser,omitempty"` DataType DataType `json:"dataType,omitempty"` Organization string `json:"organization,omitempty"` Application string `json:"application,omitempty"` Proposition string `json:"proposition,omitempty"` Subscription string `json:"subscription,omitempty"` DataSource string `json:"dataSource,omitempty"` DataCategory string `json:"dataCategory,omitempty"` Data json.RawMessage `json:"data,omitempty"` Blob string `json:"blob,omitempty"` DeleteTimestamp string `json:"deleteTimestamp,omitempty"` CreationTimestamp string `json:"creationTimestamp,omitempty"` Tombstone bool `json:"tombstone,omitempty"` }
DataItem describes a TDR Data item
type DataItemsService ¶
type DataItemsService struct {
// contains filtered or unexported fields
}
DataItemsService provides operations on TDR data items
func (*DataItemsService) GetDataItem ¶
func (d *DataItemsService) GetDataItem(opt *GetDataItemOptions, options ...OptionFunc) ([]*DataItem, *Response, error)
GetDataItem searches for data items in TDR Use the DataSearch OptionFunc to search in the data part. When using this the DataType must be added as part of the options
type DataType ¶
type DataType struct { System string `json:"system,omitempty"` Code string `json:"code,omitempty"` }
DataType describes the system and code of a resource
type DeletePolicy ¶
type ErrorResponse ¶ added in v0.30.0
type ErrorResponse struct { Response *http.Response `json:"-"` Code string `json:"responseCode"` Message string `json:"responseMessage"` }
ErrorResponse represents an IAM errors response containing a code and a human readable message
func (*ErrorResponse) Error ¶ added in v0.30.0
func (e *ErrorResponse) Error() string
type GetContractOptions ¶
type GetContractOptions struct { Organization *string `url:"organization,omitempty"` DataType *string `url:"dataType,omitempty"` Count *int `url:"_count,omitempty"` }
GetContractOptions describes the fields on which you can search for contracts
type GetDataItemOptions ¶
type GetDataItemOptions struct { Organization *string `url:"organization,omitempty"` DataType *string `url:"dataType,omitempty"` Count *int `url:"_count,omitempty"` }
GetDataItemOptions describes the fields on which you can search for data items
type Meta ¶
type Meta struct { LastUpdated string `json:"lastUpdated,omitempty"` VersionID string `json:"versionId,omitempty"` }
Meta contains versioning info about the resource
type OptionFunc ¶
OptionFunc is the function signature function for options
func DataSearch ¶
func DataSearch(kv KeyValue) OptionFunc
DataSearch builds a custom query for TDR searches on the data element
func WithContext ¶
func WithContext(ctx context.Context) OptionFunc
WithContext runs the request with the provided context
type RelatedPeripheral ¶
RelatedPeripheral describes a TDR related peripheral
type RelatedUser ¶
RelatedUser describes a TDR related user
type Response ¶
Response is a HSDP IAM API response. This wraps the standard http.Response returned from HSDP IAM and provides convenient access to things like errors