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
- func CountRequest(urlSuffix string, ctx context.Context, urlClient interfaces.URLClient) (int, error)
- func DeleteRequest(urlSuffix string, ctx context.Context, urlClient interfaces.URLClient) error
- func FromContext(key string, ctx context.Context) string
- func GetRequest(urlSuffix string, ctx context.Context, urlClient interfaces.URLClient) ([]byte, error)
- func GetRequestWithURL(url string, ctx context.Context) ([]byte, error)
- func PostJsonRequest(urlSuffix string, data interface{}, ctx context.Context, ...) (string, error)
- func PostJsonRequestWithURL(url string, data interface{}, ctx context.Context) (string, error)
- func PostRequest(urlSuffix string, data []byte, ctx context.Context, ...) (string, error)
- func PostRequestWithURL(url string, data []byte, ctx context.Context) (string, error)
- func PutRequest(urlSuffix string, body []byte, ctx context.Context, ...) (string, error)
- func UpdateRequest(urlSuffix string, data interface{}, ctx context.Context, ...) error
- func UploadFileRequest(urlSuffix string, filePath string, ctx context.Context, ...) (string, error)
- type CorrelatedRequest
Constants ¶
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
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
const ( ServiceKeyPrefix = "edgex-" ConfigSeedServiceKey = "edgex-config-seed" CoreCommandServiceKey = "edgex-core-command" CoreDataServiceKey = "edgex-core-data" CoreMetaDataServiceKey = "edgex-core-metadata" SupportLoggingServiceKey = "edgex-support-logging" SupportNotificationsServiceKey = "edgex-support-notifications" SystemManagementAgentServiceKey = "edgex-sys-mgmt-agent" SupportSchedulerServiceKey = "edgex-support-scheduler" SecuritySecretStoreSetupServiceKey = "edgex-security-secretstore-setup" SecuritySecretsSetupServiceKey = "edgex-security-secrets-setup" SecurityProxySetupServiceKey = "edgex-security-proxy-setup" SecurityFileTokenProviderServiceKey = "edgex-security-file-token-provider" )
Constants related to how services identify themselves in the Service Registry
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(urlSuffix string, ctx context.Context, urlClient interfaces.URLClient) (int, error)
Helper method to make the count request
func DeleteRequest ¶
Helper method to make the delete request
func FromContext ¶
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(urlSuffix string, ctx context.Context, urlClient interfaces.URLClient) ([]byte, error)
GetRequest will make a GET request to the specified URL with the root URL retrieved by the URLClient prepended. It returns the body as a byte array if successful and an error otherwise.
func GetRequestWithURL ¶ added in v0.1.43
GetRequestWithURL will make a GET request to the specified URL. It returns the body as a byte array if successful and an error otherwise.
func PostJsonRequest ¶
func PostJsonRequest( urlSuffix string, data interface{}, ctx context.Context, urlClient interfaces.URLClient) (string, error)
Helper method to make the post JSON request and return the body
func PostJsonRequestWithURL ¶ added in v0.1.43
PostJsonRequestWithURL will make a POST request to the specified URL with the object passed in marshaled into a JSON formatted byte array. It returns the body on success and an error otherwise.
func PostRequest ¶
func PostRequest(urlSuffix string, data []byte, ctx context.Context, urlClient interfaces.URLClient) (string, error)
Helper method to make the post request and return the body
func PostRequestWithURL ¶ added in v0.1.43
PostRequestWithURL will make a POST request to the specified URL. It returns the body as a byte array if successful and an error otherwise.
func PutRequest ¶
func PutRequest(urlSuffix string, body []byte, ctx context.Context, urlClient interfaces.URLClient) (string, error)
Helper method to make the put request
func UpdateRequest ¶
func UpdateRequest(urlSuffix string, data interface{}, ctx context.Context, urlClient interfaces.URLClient) error
Helper method to make the update request
func UploadFileRequest ¶
func UploadFileRequest( urlSuffix string, filePath string, ctx context.Context, urlClient interfaces.URLClient) (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 {
}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.
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. |
coredata provides clients used for integration with the core-data service.
|
coredata provides clients used for integration with the core-data service. |
general provides a client for calling operational endpoints that are present on all service APIs.
|
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. |
metadata provides clients used for integration with the core-metadata service.
|
metadata provides clients used for integration with the core-metadata service. |
notifications provides a client for integrating with the support-notifications service.
|
notifications provides a client for integrating with the support-notifications service. |
scheduler provides clients used for integration with the support-scheduler service.
|
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. |
urlclient provides concrete implementation types that implement the URLClient interface.
|
urlclient provides concrete implementation types that implement the URLClient interface. |