http

package
v0.0.0-...-d8d72a7 Latest Latest
Warning

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

Go to latest
Published: Dec 16, 2021 License: Apache-2.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ParamTenantID = "tenant_id"
	ParamDeviceID = "device_id"
)
View Source
const (
	HdrKeyAuthz       = "Authorization"
	HdrKeyXFF         = "X-Forwarded-For"
	HdrKeyMSRequestID = "X-Ms-Request-Id"
)
View Source
const (
	APIURLInternal = "/api/internal/v1/azure-iot-manager"

	APIURLAlive             = "/alive"
	APIURLHealth            = "/health"
	APIURLTenants           = "/tenants"
	APIURLTenant            = APIURLTenants + "/:tenant_id"
	APIURLTenantDevices     = APIURLTenant + "/devices"
	APIURLTenantDevice      = APIURLTenantDevices + "/:device_id"
	APIURLTenantBulkDevices = APIURLTenant + "/bulk/devices"
	APIURLTenantBulkStatus  = APIURLTenantBulkDevices + "/status"

	APIURLManagement = "/api/management/v1/azure-iot-manager"

	APIURLSettings      = "/settings"
	APIURLDevice        = "/devices/:id"
	APIURLDeviceTwin    = "/devices/:id/twin"
	APIURLDeviceModules = "/devices/:id/modules"
)

API URL used by the HTTP router

Variables

View Source
var (
	ErrMissingUserAuthentication = errors.New(
		"user identity missing from authorization token",
	)
	ErrMissingConnectionString = errors.New("connection string is not configured")
)

Functions

func NewRouter

func NewRouter(
	app app.App,
	config ...*Config,
) *gin.Engine

NewRouter returns the gin router

Types

type APIHandler

type APIHandler struct {
	*http.Client
	// contains filtered or unexported fields
}

func NewAPIHandler

func NewAPIHandler(app app.App, config ...*Config) *APIHandler

func (*APIHandler) Alive

func (h *APIHandler) Alive(c *gin.Context)

Alive responds to GET /alive

func (*APIHandler) Health

func (h *APIHandler) Health(c *gin.Context)

Health responds to GET /health

func (*APIHandler) NoRoute

func (h *APIHandler) NoRoute(c *gin.Context)

type AzureDeviceURI

type AzureDeviceURI string
const (
	// https://docs.microsoft.com/en-us/rest/api/iothub/service/devices
	AzureAPIVersion = "2021-04-12"

	AzureURIDeviceTwin    AzureDeviceURI = "/twins/:id"
	AzureURIDevice        AzureDeviceURI = "/devices/:id"
	AzureURIDeviceModules AzureDeviceURI = "/devices/:id/modules"
)

func (AzureDeviceURI) URI

func (s AzureDeviceURI) URI(deviceID string) string

type BulkItem

type BulkItem struct {
	// Status code for the operation (translates to HTTP status)
	Status int `json:"status"`
	// Description in case of error
	Description string `json:"description,omitempty"`
	// Parameters used for producing BulkItem
	Parameters map[string]interface{} `json:"parameters"`
}

type BulkResult

type BulkResult struct {
	Error bool       `json:"error"`
	Items []BulkItem `json:"items"`
}

type Config

type Config struct {
	Client *http.Client
}

func NewConfig

func NewConfig(configs ...*Config) *Config

NewConfig initializes a new empty config and optionally merges the configurations provided as argument.

func (*Config) SetClient

func (conf *Config) SetClient(client *http.Client) *Config

type InternalHandler

type InternalHandler APIHandler

func (*InternalHandler) BulkSetDeviceStatus

func (h *InternalHandler) BulkSetDeviceStatus(c *gin.Context)

PUT /tenants/:tenant_id/bulk/devices/status

func (*InternalHandler) DecomissionDevice

func (h *InternalHandler) DecomissionDevice(c *gin.Context)

func (*InternalHandler) ProvisionDevice

func (h *InternalHandler) ProvisionDevice(c *gin.Context)

POST /tenants/:tenant_id/devices code: 204 - device provisioned to iothub

500 - internal server error

type ManagementHandler

type ManagementHandler APIHandler

ManagementHandler is the namespace for management API handlers.

func (*ManagementHandler) GetDevice

func (h *ManagementHandler) GetDevice(c *gin.Context)

func (*ManagementHandler) GetDeviceModules

func (h *ManagementHandler) GetDeviceModules(c *gin.Context)

func (*ManagementHandler) GetDeviceTwin

func (h *ManagementHandler) GetDeviceTwin(c *gin.Context)

GET /device/:id/twin

func (*ManagementHandler) GetSettings

func (h *ManagementHandler) GetSettings(c *gin.Context)

GET /settings

func (*ManagementHandler) SetSettings

func (h *ManagementHandler) SetSettings(c *gin.Context)

PUT /settings

func (*ManagementHandler) UpdateDeviceTwin

func (h *ManagementHandler) UpdateDeviceTwin(c *gin.Context)

PATCH /device/:id/twin

Jump to

Keyboard shortcuts

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