Documentation
¶
Index ¶
- Constants
- Variables
- func NewDataService(store *EntitlementStore, sClient *storageclient.DataApi, ...) dataResource
- func NewDeviceService(ctx context.Context, entitlementStore *EntitlementStore, ...) deviceResource
- func NewEntitlementService(store *EntitlementStore, mClient *metadataclient.MetadataApi) entitlementResource
- type AccessLevel
- type DataRequest
- type DataResponse
- type DeviceRequest
- type DeviceResponse
- type Entitlement
- type EntitlementRequest
- type EntitlementStore
- type ErrorResponse
- type Metadata
- type MetadataRequest
- type MetadataStore
- type Status
Constants ¶
const ( OwnerOnly = AccessLevel("owner-only") CanAccess = AccessLevel("can-access") CanDiscover = AccessLevel("can-discover") )
const ( Requested = Status("requested") Accepted = Status("accepted") Declined = Status("declined") Revoked = Status("revoked") )
Variables ¶
var (
ErrEntitlementNotFound = errors.New("entitlement not found")
)
Functions ¶
func NewDataService ¶
func NewDataService(store *EntitlementStore, sClient *storageclient.DataApi, metaStore *MetadataStore) dataResource
func NewDeviceService ¶
func NewDeviceService(ctx context.Context, entitlementStore *EntitlementStore, metaStore *MetadataStore, out chan<- sensors.SensorMessage) deviceResource
func NewEntitlementService ¶
func NewEntitlementService(store *EntitlementStore, mClient *metadataclient.MetadataApi) entitlementResource
Types ¶
type AccessLevel ¶
type AccessLevel string
type DataRequest ¶
type DataRequest struct {
Key string `json:"key" description:"unique name for the data"`
}
type DataResponse ¶
type DataResponse struct {
Data interface{} `json:"data" description:"data returned type="object"`
Metadata Metadata `json:"metadata" description:"metadata for the data e.g. description"`
}
type DeviceRequest ¶
type DeviceRequest struct {
Type string `json:"type" description:"type of device" validate:"nonzero"`
}
type DeviceResponse ¶
type DeviceResponse struct {
DeviceRequest
UID string `json:"uid" description:"unique identifier for the device"`
Name string `json:"name" description:"unique name for the device" `
Description string `json:"description" description:"information about the device" `
}
type Entitlement ¶
type Entitlement struct {
EntitlementRequest
UID string `json:"uid" description:"unique identifier of the entitlement request" validate:"nonzero"`
Status Status `` /* 140-byte string literal not displayed */
}
Entitlement is returned to encapsulate the current status of the entitlement
func (Entitlement) IsAccessible ¶
func (e Entitlement) IsAccessible() bool
IsAccessible returns true if the data can be accessed e.g. viewed, collated etc
func (Entitlement) IsDiscoverable ¶
func (e Entitlement) IsDiscoverable() bool
IsDiscoverable returns true if the presence of the data can be discovered For the purposes of the prototype this means the data will be sent to the metadata service
type EntitlementRequest ¶
type EntitlementRequest struct {
Subject string `json:"subject" description:"path of the data e.g. data://user/email" validate:"nonzero"`
AccessLevel AccessLevel `json:"level" description:"access level requested. Valid values 'owner-only', 'can-read','can-discover'" validate:"nonzero"`
}
EntitlementRequest are made to request some access to a bit of data
type EntitlementStore ¶
type EntitlementStore struct {
Accepted entitlementMap
Declined entitlementMap
Requested entitlementMap
Revoked entitlementMap
}
func NewEntitlementStore ¶
func NewEntitlementStore() *EntitlementStore
type ErrorResponse ¶
type ErrorResponse struct {
Error string `json:"error" description:"error message if any"`
}
ErrorResponse signals error messages back to the client
type Metadata ¶
type Metadata struct {
Description string `json:"description" description:"human readable description of the data"`
Subject string `json:"subject" description:"description of the data"`
Name string `json:"name" description:"name of the data"`
Path string `json:"path" description:"path to the key of the data"`
}
type MetadataRequest ¶
type MetadataRequest struct {
Description string `json:"description" description:"human readable description of the data"`
}
type MetadataStore ¶
type MetadataStore struct {
// contains filtered or unexported fields
}
func NewMetadataStore ¶
func NewMetadataStore() *MetadataStore
func (*MetadataStore) Add ¶
func (m *MetadataStore) Add(meta Metadata)
func (*MetadataStore) All ¶
func (m *MetadataStore) All() []Metadata
func (*MetadataStore) FindBySubject ¶
func (m *MetadataStore) FindBySubject(subject utils.Subject) (Metadata, bool)