clients

package
v0.1.33 Latest Latest
Warning

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

Go to latest
Published: Oct 24, 2019 License: Apache-2.0 Imports: 11 Imported by: 80

Documentation

Overview

Package clients provides REST-based integration with the core APIs of the EdgeX Foundry platform.

Each individual service client can be found in its respective package within clients. View the Subdirectories section below for more information.

While it is certainly possible to utilize the exported functions in this package to make calls to a given service, it is recommended (unless you really specifically know what you're doing) to use the service clients instead. The functions here are exported primarily for the use of the service clients.

Index

Constants

View Source
const (
	ClientMonitorDefault = 15000            // Defaults the interval at which a given service client will refresh its endpoint from the Registry, if used
	CorrelationHeader    = "correlation-id" // Sets the key of the Correlation ID HTTP header
)

Do not assume that if a constant is identified by your IDE as not being used within this module that it is not being used at all. Any application wishing to exchange information with the EdgeX core services will utilize this module, so constants located here may be used externally.

Miscellaneous constants

View Source
const (
	ApiVersionRoute            = "/api/version"
	ApiBase                    = "/api/v1"
	ApiAddressableRoute        = "/api/v1/addressable"
	ApiCallbackRoute           = "/api/v1/callback"
	ApiCommandRoute            = "/api/v1/command"
	ApiConfigRoute             = "/api/v1/config"
	ApiDeviceRoute             = "/api/v1/device"
	ApiDeviceProfileRoute      = "/api/v1/deviceprofile"
	ApiDeviceServiceRoute      = "/api/v1/deviceservice"
	ApiEventRoute              = "/api/v1/event"
	ApiLoggingRoute            = "/api/v1/logs"
	ApiMetricsRoute            = "/api/v1/metrics"
	ApiNotificationRoute       = "/api/v1/notification"
	ApiNotifyRegistrationRoute = "/api/v1/notify/registrations"
	ApiPingRoute               = "/api/v1/ping"
	ApiProvisionWatcherRoute   = "/api/v1/provisionwatcher"
	ApiReadingRoute            = "/api/v1/reading"
	ApiRegistrationRoute       = "/api/v1/registration"
	ApiRegistrationByNameRoute = ApiRegistrationRoute + "/name"
	ApiSubscriptionRoute       = "/api/v1/subscription"
	ApiTransmissionRoute       = "/api/v1/transmission"
	ApiValueDescriptorRoute    = "/api/v1/valuedescriptor"
	ApiIntervalRoute           = "/api/v1/interval"
	ApiIntervalActionRoute     = "/api/v1/intervalaction"
)

Constants related to defined routes in the service APIs

View Source
const (
	ServiceKeyPrefix                = "edgex-"
	ConfigSeedServiceKey            = "edgex-config-seed"
	CoreCommandServiceKey           = "edgex-core-command"
	CoreDataServiceKey              = "edgex-core-data"
	CoreMetaDataServiceKey          = "edgex-core-metadata"
	ExportClientServiceKey          = "edgex-export-client"
	ExportDistroServiceKey          = "edgex-export-distro"
	SupportLoggingServiceKey        = "edgex-support-logging"
	SupportNotificationsServiceKey  = "edgex-support-notifications"
	SystemManagementAgentServiceKey = "edgex-sys-mgmt-agent"
	SupportSchedulerServiceKey      = "edgex-support-scheduler"
)

Constants related to how services identify themselves in the Service Registry

View Source
const (
	ContentType     = "Content-Type"
	ContentTypeCBOR = "application/cbor"
	ContentTypeJSON = "application/json"
	ContentTypeYAML = "application/x-yaml"
	ContentTypeText = "text/plain"
)

Constants related to the possible content types supported by the APIs

Variables

This section is empty.

Functions

func CountRequest

func CountRequest(url string, ctx context.Context) (int, error)

Helper method to make the count request

func DeleteRequest

func DeleteRequest(url string, ctx context.Context) error

Helper method to make the delete request

func FromContext

func FromContext(key string, ctx context.Context) string

FromContext allows for the retrieval of the specified key's value from the supplied Context. If the value is not found, an empty string is returned.

func GetRequest

func GetRequest(url string, ctx context.Context) ([]byte, error)

Helper method to make the get request and return the body

func PostJsonRequest

func PostJsonRequest(url string, data interface{}, ctx context.Context) (string, error)

Helper method to make the post JSON request and return the body

func PostRequest

func PostRequest(url string, data []byte, ctx context.Context) (string, error)

Helper method to make the post request and return the body

func PutRequest

func PutRequest(url string, body []byte, ctx context.Context) (string, error)

Helper method to make the put request

func UpdateRequest

func UpdateRequest(url string, data interface{}, ctx context.Context) error

Helper method to make the update request

func UploadFileRequest

func UploadFileRequest(url string, filePath string, ctx context.Context) (string, error)

Helper method to make a post request in order to upload a file and return the request body

Types

type CorrelatedRequest

type CorrelatedRequest struct {
	*http.Request
}

CorrelatedRequest is a wrapper type for use in managing Correlation IDs during service to service API calls.

func NewCorrelatedRequest

func NewCorrelatedRequest(req *http.Request, ctx context.Context) CorrelatedRequest

NewCorrelatedRequest will add the Correlation ID header to the supplied request. If no Correlation ID header is present in the supplied context, one will be created along with a value.

type Endpointer

type Endpointer interface {
	//Fetch will return a string containing the URL for a service endpoint corresponding to the params.ServiceKey property.
	Fetch(params types.EndpointParams) string
	//Monitor is responsible for refreshing information about the service endpoint corresponding
	//to the params.ServiceKey property on a set interval. Information about the service from the
	//discovery provider should be used to construct a URL which will then be pushed to the supplied channel.
	Monitor(params types.EndpointParams, ch chan string)
}

Endpointer is the interface for types that need to implement or simulate integration with a service discovery provider.

Directories

Path Synopsis
Package command provides a client for integration with the core-command service.
Package command provides a client for integration with the core-command service.
Package coredata provides clients used for integration with the core-data service.
Package coredata provides clients used for integration with the core-data service.
export
distro
Package distro provides a client for integration with the export-distro service.
Package distro provides a client for integration with the export-distro service.
Package general provides a client for calling operational endpoints that are present on all service APIs.
Package general provides a client for calling operational endpoints that are present on all service APIs.
Package logger provides a client for integration with the support-logging service.
Package logger provides a client for integration with the support-logging service.
Package metadata provides clients used for integration with the core-metadata service.
Package metadata provides clients used for integration with the core-metadata service.
Package notifications provides a client for integrating with the support-notifications service.
Package notifications provides a client for integrating with the support-notifications service.
Package scheduler provides clients used for integration with the support-scheduler service.
Package scheduler provides clients used for integration with the support-scheduler service.
Package types provides supporting types that facilitate the various service client implementations.
Package types provides supporting types that facilitate the various service client implementations.

Jump to

Keyboard shortcuts

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