http

package
v0.0.0-...-eef5929 Latest Latest
Warning

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

Go to latest
Published: Apr 29, 2024 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ParamTenantID = "tenant_id"
	ParamDeviceID = "device_id"
)
View Source
const (
	APIURLInternal = "/api/internal/v1/iot-manager"

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

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

	APIURLIntegrations           = "/integrations"
	APIURLIntegration            = "/integrations/:id"
	APIURLIntegrationCredentials = APIURLIntegration + "/credentials"

	APIURLDevice                 = "/devices/:id"
	APIURLDeviceState            = APIURLDevice + "/state"
	APIURLDeviceStateIntegration = APIURLDevice + "/state/:integrationId"

	APIURLEvents = "/events"
)

API URL used by the HTTP router

Variables

View Source
var (
	ErrMissingUserAuthentication = errors.New(
		"user identity missing from authorization token",
	)
	ErrIntegrationNotFound = errors.New("integration not found")
)
View Source
var (
	ErrEmptyDeviceID        = errors.New("device ID is empty")
	ErrInvalidIntegrationID = errors.New("integration ID is not a valid UUID")
)

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 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/devices/status/{status}

func (*InternalHandler) DecommissionDevice

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

func (*InternalHandler) PreauthorizeHandler

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

POST /tenants/:tenant_id/auth

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) CreateIntegration

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

POST /integrations

func (*ManagementHandler) GetDeviceState

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

GET /devices/:id/state

func (*ManagementHandler) GetDeviceStateIntegration

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

GET /devices/:id/state/:integrationId

func (*ManagementHandler) GetEvents

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

GET /events

func (*ManagementHandler) GetIntegrationById

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

GET /integrations/{id}

func (*ManagementHandler) GetIntegrations

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

GET /integrations

func (*ManagementHandler) RemoveIntegration

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

DELETE /integrations/{id}

func (*ManagementHandler) SetDeviceStateIntegration

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

PUT /devices/:id/state/:integrationId

func (*ManagementHandler) SetIntegrationCredentials

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

PUT /integrations/{id}/credentials

Jump to

Keyboard shortcuts

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