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(ctx context.Context, urlSuffix string, urlClient interfaces.URLClient) (int, error)
- func DeleteRequest(ctx context.Context, urlSuffix string, urlClient interfaces.URLClient) error
- func FromContext(ctx context.Context, key string) string
- func GetRequest(ctx context.Context, urlSuffix string, urlClient interfaces.URLClient) ([]byte, error)
- func GetRequestWithURL(ctx context.Context, url string) ([]byte, error)
- func PostJSONRequest(ctx context.Context, urlSuffix string, data interface{}, ...) (string, error)
- func PostJSONRequestWithURL(ctx context.Context, url string, data interface{}) (string, error)
- func PostRequest(ctx context.Context, urlSuffix string, data []byte, ...) (string, error)
- func PostRequestWithURL(ctx context.Context, url string, data []byte) (string, error)
- func PutRequest(ctx context.Context, urlSuffix string, body []byte, ...) (string, error)
- func UpdateRequest(ctx context.Context, urlSuffix string, data interface{}, ...) error
- func UploadFileRequest(ctx context.Context, urlSuffix string, filePath string, ...) (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" ApiHealthRoute = "/api/v1/health" ApiLoggingRoute = "/api/v1/logs" ApiMetricsRoute = "/api/v1/metrics" ApiNotificationRoute = "/api/v1/notification" ApiNotifyRegistrationRoute = "/api/v1/notify/registrations" ApiOperationRoute = "/api/v1/operations" 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(ctx context.Context, urlSuffix string, 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(ctx context.Context, urlSuffix string, 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 ¶ added in v0.1.46
func PostJSONRequest( ctx context.Context, urlSuffix string, data interface{}, urlClient interfaces.URLClient) (string, error)
Helper method to make the post JSON request and return the body
func PostJSONRequestWithURL ¶ added in v0.1.46
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(ctx context.Context, urlSuffix string, data []byte, 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(ctx context.Context, urlSuffix string, body []byte, urlClient interfaces.URLClient) (string, error)
Helper method to make the put request
func UpdateRequest ¶
func UpdateRequest(ctx context.Context, urlSuffix string, data interface{}, urlClient interfaces.URLClient) error
Helper method to make the update request
func UploadFileRequest ¶
func UploadFileRequest( ctx context.Context, urlSuffix string, filePath string, 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(ctx context.Context, req *http.Request) 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 |
---|---|
agent provides a client for integrating with the system management agent.
|
agent provides a client for integrating with the system management agent. |
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. |
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. |
urlclient
|
|
errors
errors defines a set of errors that urlclient will use.
|
errors defines a set of errors that urlclient will use. |