Documentation
¶
Overview ¶
Package tdr provides support for HSDP TDR operations Contract management and DataItem creation and retrieval are supported
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 GetContractOptions
- type GetDataItemOptions
- type KeyValue
- type Meta
- type OptionFunc
- type RelatedPeripheral
- type RelatedUser
- type Response
- type User
Constants ¶
const (
TDRAPIVersion = "4"
)
Constants
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) NewTDRRequest ¶
func (c *Client) NewTDRRequest(method, path string, opt interface{}, options []OptionFunc) (*http.Request, error)
NewTDRRequest creates an new TDR API request. A relative URL path can be provided in urlStr, in which case it is resolved relative to the base URL of the Client. Relative URL paths should always be specified without a preceding slash. If specified, the value pointed to by body is JSON encoded and included as the request body.
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 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 Device ¶
type Device struct { Description string `json:"description,omitempty"` System string `json:"system"` Value string `json:"value"` }
Device describes a TDR device
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 ¶
type RelatedPeripheral struct { Description string `json:"description,omitempty"` System string `json:"system"` Value string `json:"value"` }
RelatedPeripheral describes a TDR related peripheral
type RelatedUser ¶
type RelatedUser struct { Description string `json:"description,omitempty"` System string `json:"system"` Value string `json:"value"` }
RelatedUser describes a TDR related user