api

package
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Feb 9, 2022 License: MPL-2.0 Imports: 24 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// Client errors
	ErrInvalidDeviceRequest = errors.New("unable to parse device, is invalid")    //400
	ErrInvalidDMSId         = errors.New("unable to parse DMS ID, is invalid")    //400
	ErrInvalidDeviceId      = errors.New("unable to parse Device ID, is invalid") //400
	ErrIncorrectType        = errors.New("unsupported media type")                //415
	ErrEmptyBody            = errors.New("empty body")

	//Server errors
	ErrInvalidOperation = errors.New("invalid operation")
	ErrActiveCert       = errors.New("can't isuee certificate. The device has a valid cert")
	ErrResponseEncode   = errors.New("error encoding response")
)

Functions

func HTTPToContext

func HTTPToContext(logger log.Logger) httptransport.RequestFunc

func MakeDeleteDeviceEndpoint

func MakeDeleteDeviceEndpoint(s Service) endpoint.Endpoint

func MakeDeleteRevokeEndpoint

func MakeDeleteRevokeEndpoint(s Service) endpoint.Endpoint

func MakeGetDeviceByIdEndpoint

func MakeGetDeviceByIdEndpoint(s Service) endpoint.Endpoint

func MakeGetDeviceCertEndpoint

func MakeGetDeviceCertEndpoint(s Service) endpoint.Endpoint

func MakeGetDeviceCertHistoryEndpoint

func MakeGetDeviceCertHistoryEndpoint(s Service) endpoint.Endpoint

func MakeGetDeviceLogsEndpoint

func MakeGetDeviceLogsEndpoint(s Service) endpoint.Endpoint

func MakeGetDevicesByDMSEndpoint

func MakeGetDevicesByDMSEndpoint(s Service) endpoint.Endpoint

func MakeGetDevicesEndpoint

func MakeGetDevicesEndpoint(s Service) endpoint.Endpoint

func MakeGetDmsCertHistoryThirtyDaysEndpoint

func MakeGetDmsCertHistoryThirtyDaysEndpoint(s Service) endpoint.Endpoint

func MakeGetDmsLastIssueCertEndpoint

func MakeGetDmsLastIssueCertEndpoint(s Service) endpoint.Endpoint

func MakeHTTPHandler

func MakeHTTPHandler(s Service, logger log.Logger, otTracer stdopentracing.Tracer) http.Handler

func MakeHealthEndpoint

func MakeHealthEndpoint(s Service) endpoint.Endpoint

func MakePostDeviceEndpoint

func MakePostDeviceEndpoint(s Service) endpoint.Endpoint

func NewParserm

func NewParserm(mtlsCa x509.Certificate) endpoint.Middleware

Types

type Endpoints

type Endpoints struct {
	HealthEndpoint              endpoint.Endpoint
	PostDeviceEndpoint          endpoint.Endpoint
	GetDevices                  endpoint.Endpoint
	GetDeviceById               endpoint.Endpoint
	GetDevicesByDMS             endpoint.Endpoint
	DeleteDevice                endpoint.Endpoint
	DeleteRevoke                endpoint.Endpoint
	GetDeviceLogs               endpoint.Endpoint
	GetDeviceCert               endpoint.Endpoint
	GetDeviceCertHistory        endpoint.Endpoint
	GetDmsCertHistoryThirtyDays endpoint.Endpoint
	GetDmsLastIssueCert         endpoint.Endpoint
}

func MakeServerEndpoints

func MakeServerEndpoints(s Service, otTracer stdopentracing.Tracer) Endpoints

type Middleware

type Middleware func(Service) Service

func LoggingMiddleware

func LoggingMiddleware(logger log.Logger) Middleware

func NewInstrumentingMiddleware

func NewInstrumentingMiddleware(counter metrics.Counter, latency metrics.Histogram) Middleware

type Service

type Service interface {
	Health(ctx context.Context) bool
	PostDevice(ctx context.Context, device devicesModel.Device) (devicesModel.Device, error)
	GetDevices(ctx context.Context) (devicesModel.Devices, error)
	GetDeviceById(ctx context.Context, deviceId string) (devicesModel.Device, error)
	GetDevicesByDMS(ctx context.Context, dmsId string) (devicesModel.Devices, error)
	DeleteDevice(ctx context.Context, id string) error
	RevokeDeviceCert(ctx context.Context, id string, revocationReason string) error

	GetDeviceLogs(ctx context.Context, id string) (devicesModel.DeviceLogs, error)
	GetDeviceCert(ctx context.Context, id string) (devicesModel.DeviceCert, error)
	GetDeviceCertHistory(ctx context.Context, id string) (devicesModel.DeviceCertsHistory, error)
	GetDmsCertHistoryThirtyDays(ctx context.Context) (devicesModel.DMSCertsHistory, error)
	GetDmsLastIssuedCert(ctx context.Context) (devicesModel.DMSsLastIssued, error)
}

func NewDevicesService

func NewDevicesService(devicesDb devicesStore.DB, lamassuCa *lamassucaclient.LamassuCaClient, logger log.Logger) Service

Jump to

Keyboard shortcuts

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