inventory

package
v0.0.0-...-0600186 Latest Latest
Warning

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

Go to latest
Published: Nov 9, 2020 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MANAGED_OBJECT_TYPE            = "application/vnd.com.nsn.cumulocity.managedObject+json"
	MANAGED_OBJECT_COLLECTION_TYPE = "application/vnd.com.nsn.cumulocity.managedObjectCollection+json"

	INVENTORY_API_PATH = "/inventory/managedObjects"
)
View Source
const (
	MANAGED_OBJECT_REFERENCE_TYPE            = "application/vnd.com.nsn.cumulocity.managedObjectReference+json"
	MANAGED_OBJECT_REFERENCE_COLLECTION_TYPE = "application/vnd.com.nsn.cumulocity.managedObjectReferenceCollection+json"

	INVENTORY_REFERENCE_API_PATH = "/inventory/managedObjects"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type AdditionParents

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

type AssetParents

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

type C8YActiveAlarmsStatus

type C8YActiveAlarmsStatus struct {
	Critical int `json:"critical,omitempty"`
	Major    int `json:"major,omitempty"`
}

type C8YAvailability

type C8YAvailability struct {
	LastMessage *time.Time `json:"lastMessage,omitempty"`
	Status      string     `json:"status,omitempty"`
}

type C8YConnection

type C8YConnection struct {
	Status string `json:"status,omitempty"`
}

type C8YDataPoint

type C8YDataPoint struct {
}

type C8YFirmware

type C8YFirmware struct {
	Version string `json:"version,omitempty"`
}

type C8YHardware

type C8YHardware struct {
	Model        string `json:"model,omitempty"`
	SerialNumber string `json:"serialNumber,omitempty"`
}

type C8YRequiredAvailability

type C8YRequiredAvailability struct {
	ResponseInterval int `json:"responseInterval,omitempty"`
}

type C8YStatus

type C8YStatus struct {
	Details struct {
		Active              int `json:"active,omitempty"`
		AggregatedResources struct {
			CPU    string `json:"cpu,omitempty"`
			Memory string `json:"memory,omitempty"`
		} `json:"aggregatedResources,omitempty"`
		Desired  int `json:"desired,omitempty"`
		Restarts int `json:"restarts,omitempty"`
	} `json:"details,omitempty"`
	Instances struct {
		DeviceSimulatorScopeManagementDeployment77678578B4Vkn66 struct {
			CPUInMillis int `json:"cpuInMillis,omitempty"`
			LastUpdated struct {
				Date struct {
					Date *time.Time `json:"date,omitempty"`
				} `json:"date,omitempty"`
				Offset int `json:"offset,omitempty"`
			} `json:"lastUpdated,omitempty"`
			MemoryInBytes int `json:"memoryInBytes,omitempty"`
			Restarts      int `json:"restarts,omitempty"`
		} `json:"device-simulator-scope-management-deployment-77678578b4-vkn66,omitempty"`
	} `json:"instances,omitempty"`
	LastUpdated struct {
		Date struct {
			Date *time.Time `json:"date,omitempty"`
		} `json:"date,omitempty"`
		Offset int `json:"offset,omitempty"`
	} `json:"lastUpdated,omitempty"`
	Status string `json:"status,omitempty"`
}

type ChildAdditions

type ChildAdditions struct {
	References []struct {
		ManagedObject struct {
			Id   string `json:"id,omitempty"`
			Name string `json:"name,omitempty"`
			Self string `json:"self,omitempty"`
		} `json:"managedObject,omitempty"`
		Self string `json:"self,omitempty"`
	} `json:"references"`
	Self string `json:"self,omitempty"`
}

type ChildAssets

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

type ChildDevices

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

type DeviceParents

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

type InventoryApi

type InventoryApi interface {
	// Create a new managed object and returns the created entity with id, creation time and other properties
	Create(newManagedObject *NewManagedObject) (*ManagedObject, *generic.Error)

	// Gets an exiting managed object by its id. If the id does not exists, nil is returned.
	Get(managedObjectId string) (*ManagedObject, *generic.Error)

	Update(managedObjectId string, managedObject *ManagedObjectUpdate) (*ManagedObject, *generic.Error)

	// Deletion by managedObject id. If error is nil, managed object was deleted successfully.
	Delete(managedObjectId string) *generic.Error

	// Returns a managed object collection, found by the given managed object filter parameters.
	// All query parameters are AND concatenated.
	Find(managedObjectFilter *InventoryFilter, pageSize int) (*ManagedObjectCollection, *generic.Error)

	// Returns a managed object collection, found by the given managed object query.
	// See the query language: https://cumulocity.com/guides/reference/inventory/#query-language
	FindByQuery(query string, pageSize int) (*ManagedObjectCollection, *generic.Error)

	// Gets the next page from an existing managed object collection.
	// If there is no next page, nil is returned.
	NextPage(c *ManagedObjectCollection) (*ManagedObjectCollection, *generic.Error)

	// Gets the previous page from an existing managed object collection.
	// If there is no previous page, nil is returned.
	PreviousPage(c *ManagedObjectCollection) (*ManagedObjectCollection, *generic.Error)
}

func NewInventoryApi

func NewInventoryApi(client *generic.Client) InventoryApi

Creates a new inventory api object

client - Must be a gomulocity client. returns - The `inventory`-api object

type InventoryFilter

type InventoryFilter struct {
	Type         string
	FragmentType string
	Ids          []string
	Text         string
}

func (InventoryFilter) QueryParams

func (inventoryFilter InventoryFilter) QueryParams(params *url.Values) error

Appends the filter query parameters to the provided parameter values for a request. When provided values is nil an error will be created

type InventoryReferenceApi

type InventoryReferenceApi interface {
	// Create a new managed object reference and returns the created entity with id, creation time and other properties
	Create(managedObjectId string, referenceType ReferenceType, referenceId string) (*ManagedObjectReference, *generic.Error)

	// Gets an exiting managed object reference by its id. If the id does not exists, nil is returned.
	Get(managedObjectId string, referenceType ReferenceType, referenceId string) (*ManagedObjectReference, *generic.Error)

	GetMany(managedObjectId string, referenceType ReferenceType, pageSize int) (*ManagedObjectReferenceCollection, *generic.Error)

	// Deletion by managedObjectReference id. If error is nil, managed object reference was deleted successfully.
	Delete(managedObjectId string, referenceType ReferenceType, referenceId string) *generic.Error

	// Gets the next page from an existing managed object reference collection.
	// If there is no next page, nil is returned.
	NextPage(c *ManagedObjectReferenceCollection) (*ManagedObjectReferenceCollection, *generic.Error)

	// Gets the previous page from an existing managed object reference collection.
	// If there is no previous page, nil is returned.
	PreviousPage(c *ManagedObjectReferenceCollection) (*ManagedObjectReferenceCollection, *generic.Error)
}

func NewInventoryReferenceApi

func NewInventoryReferenceApi(client *generic.Client) InventoryReferenceApi

Creates a new inventory reference api object

client - Must be a gomulocity client. returns - The `InventoryReferenceApi` object

type ManagedObject

type ManagedObject struct {
	Id           string    `json:"id"`
	Type         string    `json:"type,omitempty"`
	Name         string    `json:"name,omitempty"`
	CreationTime time.Time `json:"creationTime"`
	LastUpdated  time.Time `json:"lastUpdated"`
	Self         string    `json:"self"`
	Owner        string    `json:"owner"`

	AdditionParents AdditionParents `json:"additionParents,omitempty"`
	AssetParents    AssetParents    `json:"assetParents,omitempty"`
	DeviceParents   DeviceParents   `json:"deviceParents,omitempty"`

	ChildAdditions ChildAdditions `json:"childAdditions,omitempty"`
	ChildAssets    ChildAssets    `json:"childAssets,omitempty"`
	ChildDevices   ChildDevices   `json:"childDevices,omitempty"`

	C8YIsDevice      *interface{} `json:"c8y_IsDevice,omitempty"`
	C8YIsSensorPhone *interface{} `json:"c8y_IsSensorPhone,omitempty"`

	C8YSupportedOperations *[]string              `json:"c8y_SupportedOperations,omitempty"`
	AdditionalFields       map[string]interface{} `jsonc:"flat"`
}

func (*ManagedObject) FilterAdditionalFieldByName

func (m *ManagedObject) FilterAdditionalFieldByName(fieldName string) (interface{}, string, error)

FilterAdditionalFieldByName returns an additional field by given name and information on the structure of the field. If no additional field found, an error is returned.

type ManagedObjectCollection

type ManagedObjectCollection struct {
	Self           string                    `json:"self"`
	ManagedObjects []ManagedObject           `json:"managedObjects" jsonc:"collection"`
	Statistics     *generic.PagingStatistics `json:"statistics,omitempty"`
	Prev           string                    `json:"prev,omitempty"`
	Next           string                    `json:"next,omitempty"`
}

type ManagedObjectReference

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

type ManagedObjectReferenceCollection

type ManagedObjectReferenceCollection struct {
	Self       string                    `json:"self"`
	References []ManagedObjectReference  `json:"references"`
	Statistics *generic.PagingStatistics `json:"statistics,omitempty"`
	Prev       string                    `json:"prev,omitempty"`
	Next       string                    `json:"next,omitempty"`
}

type ManagedObjectUpdate

type ManagedObjectUpdate struct {
	Type             string                 `json:"type,omitempty"`
	Name             string                 `json:"name,omitempty"`
	AdditionalFields map[string]interface{} `jsonc:"flat"`
}

type NewManagedObject

type NewManagedObject struct {
	Type         string      `json:"type,omitempty"`
	Name         string      `json:"name,omitempty"`
	CreationTime *time.Time  `json:"creationTime,omitempty"`
	C8y_IsDevice interface{} `json:"c8y_IsDevice"`
}

type NewManagedObjectReference

type NewManagedObjectReference struct {
	ManagedObject Source `json:"managedObject"`
}

type ReferenceType

type ReferenceType string
const (
	CHILD_DEVICES ReferenceType = "childDevices"
	CHILD_ASSETS  ReferenceType = "childAssets"
)

type Source

type Source struct {
	Id string `json:"id"`
}

Jump to

Keyboard shortcuts

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