Documentation ¶
Overview ¶
Package apihandler defines haul's v1 API endpoint logic
It defines the APIHandler struct that allows more a efficient reuse of single *db.PostgresClient.
The APIHandler also implements the Declare method for activation of the `/v1/*` routes by cmd.apiCmd
This package is a work-in-progress during haul's migration from the old `/v1/*` routes (which now reside at `/v0/*`) to the ones declared here.
Index ¶
- Constants
- func Declare(e *echo.Group, h *APIHandler, prefix string)
- type APIHandler
- func (h *APIHandler) AssetAttributesGET(c echo.Context) (err error)
- func (h *APIHandler) AssetDELETE(c echo.Context) (err error)
- func (h *APIHandler) AssetDescriptionGET(c echo.Context) (err error)
- func (h *APIHandler) AssetDescriptionPUT(c echo.Context) (err error)
- func (h *APIHandler) AssetGET(c echo.Context) (err error)
- func (h *APIHandler) AssetRestorePOST(c echo.Context) (err error)
- func (h *APIHandler) AssetStatusDELETE(c echo.Context) (err error)
- func (h *APIHandler) AssetStatusGET(c echo.Context) (err error)
- func (h *APIHandler) AssetStatusPUT(c echo.Context) (err error)
- func (h *APIHandler) AssetTargetDELETE(c echo.Context) (err error)
- func (h *APIHandler) AssetTargetGET(c echo.Context) (err error)
- func (h *APIHandler) AssetTargetPUT(c echo.Context) (err error)
- func (h *APIHandler) AssetsAllGET(c echo.Context) (err error)
- func (h *APIHandler) AssetsDELETE(c echo.Context) error
- func (h *APIHandler) AssetsDetailedGET(c echo.Context) (err error)
- func (h *APIHandler) AssetsGET(c echo.Context) (err error)
- func (h *APIHandler) AssetsPOST(c echo.Context) (err error)
- func (h *APIHandler) AssetsRestorePOST(c echo.Context) (err error)
- func (h *APIHandler) AttributeAllowEmptyValuePUT(c echo.Context) (err error)
- func (h *APIHandler) AttributeAssetsGET(c echo.Context) (err error)
- func (h *APIHandler) AttributeDELETE(c echo.Context) (err error)
- func (h *APIHandler) AttributeGET(c echo.Context) (err error)
- func (h *APIHandler) AttributeKeyPUT(c echo.Context) (err error)
- func (h *APIHandler) AttributeRestorePOST(c echo.Context) (err error)
- func (h *APIHandler) AttributesDELETE(c echo.Context) (err error)
- func (h *APIHandler) AttributesGET(c echo.Context) (err error)
- func (h *APIHandler) AttributesPOST(c echo.Context) (err error)
- func (h *APIHandler) EventsGET(c echo.Context) (err error)
- func (h *APIHandler) HealthGET(c echo.Context) (err error)
- func (h *APIHandler) SeedPOST(c echo.Context) (err error)
- func (h *APIHandler) SpecGET(c echo.Context) (err error)
- func (h *APIHandler) TagDELETE(c echo.Context) (err error)
- func (h *APIHandler) TagDetailedGET(c echo.Context) (err error)
- func (h *APIHandler) TagGET(c echo.Context) (err error)
- func (h *APIHandler) TagValueGET(c echo.Context) (err error)
- func (h *APIHandler) TagValuePUT(c echo.Context) (err error)
- func (h *APIHandler) TagsDELETE(c echo.Context) (err error)
- func (h *APIHandler) TagsGET(c echo.Context) (err error)
- func (h *APIHandler) TagsPOST(c echo.Context) (err error)
Constants ¶
const DescriptionAssetAttributesGET string = "List attributes for an asset"
const DescriptionAssetDELETE string = "Delete asset"
const DescriptionAssetDescriptionGET string = "Get asset description"
const DescriptionAssetDescriptionPUT string = "Set asset description"
const DescriptionAssetGET string = "Get asset"
const DescriptionAssetRestorePOST string = "Restore asset"
const DescriptionAssetStatusDELETE string = "Clear asset status"
const DescriptionAssetStatusGET string = "Get asset status"
const DescriptionAssetStatusPUT string = "Set asset status"
const DescriptionAssetTargetDELETE string = "Clear asset target"
const DescriptionAssetTargetGET string = "Get asset target"
const DescriptionAssetTargetPUT string = "Set asset target"
const DescriptionAssetsAllGET string = "List all assets"
const DescriptionAssetsDELETE string = "Delete assets"
const DescriptionAssetsDetailedGET string = "List detailed assets"
const DescriptionAssetsGET string = "List assets"
const DescriptionAssetsPOST string = "Insert assets"
const DescriptionAssetsRestorePOST string = "Restore assets"
const DescriptionAttributeAllowEmptyValuePUT string = "Set attribute allow_empty_value"
const DescriptionAttributeAssetsGET string = "List assets for an attribute"
const DescriptionAttributeDELETE string = "Delete attribute"
const DescriptionAttributeGET string = "Get attribute"
const DescriptionAttributeKeyPUT string = "Set attribute key"
const DescriptionAttributeRestorePOST string = "Restore attribute"
const DescriptionAttributesDELETE string = "Delete attributes"
const DescriptionAttributesGET string = "List attributes"
const DescriptionAttributesPOST string = "Insert attributes"
const DescriptionEventsGET string = "List events"
const DescriptionHealthGET string = "Print server's healthcheck to test connection"
const DescriptionSeedPOST string = "Create tables in the database ('seed'), if needed"
const DescriptionSpecGET string = "Print the API server spec (pave, not openapi)"
const DescriptionTagDELETE string = "Delete tag"
const DescriptionTagDetailedGET string = "Get detailed tag"
const DescriptionTagGET string = "Get tag"
const DescriptionTagValueGET string = "Get tag value"
const DescriptionTagValuePUT string = "Set tag value"
const DescriptionTagsDELETE string = "Delete tags"
const DescriptionTagsGET string = "List tags"
const DescriptionTagsPOST string = "Insert tags"
const EndpointAsset string = "/assets/:asset_id/"
const EndpointAssetAttributes string = "/assets/:asset_id/attributes/"
const EndpointAssetDescription string = "/assets/:asset_id/description/"
const EndpointAssetRestore string = "/assets/:asset_id/restore/"
const EndpointAssetStatus string = "/assets/:asset_id/status/"
const EndpointAssetTarget string = "/assets/:asset_id/target/"
const EndpointAssets string = "/assets/"
const EndpointAssetsAll string = "/assets/all/"
const EndpointAssetsDetailed string = "/assets/detailed/"
const EndpointAssetsRestore string = "/assets/restore/"
const EndpointAttribute string = "/attributes/:attribute_id/"
const EndpointAttributeAllowEmptyValue string = "/attributes/:attribute_id/allow-empty-value/"
const EndpointAttributeAssets string = "/attributes/:attribute_id/assets/"
const EndpointAttributeKey string = "/attributes/:attribute_id/key/"
const EndpointAttributeRestore string = "/attributes/:attribute_id/restore/"
const EndpointAttributes string = "/attributes/"
const EndpointEvents string = "/events/"
const EndpointHealth string = "/health/"
const EndpointSeed string = "/seed/"
const EndpointSpec string = "/spec/"
const EndpointTag string = "/tags/:tag_id/"
const EndpointTagDetailed string = "/tags/:tag_id/detailed/"
const EndpointTagValue string = "/tags/:tag_id/value/"
const EndpointTags string = "/tags/"
Variables ¶
This section is empty.
Functions ¶
func Declare ¶
func Declare(e *echo.Group, h *APIHandler, prefix string)
Declare adds routes defined in its scope to the specified *echo.Group
It is used by cmd.apiCmd to declare the `/v1/*` routes.
Types ¶
type APIHandler ¶
type APIHandler struct { APIClient *apiclient.APIClient PostgresClient *db.PostgresClient Pave *pave.Pave }
func New ¶
func New(postgresClient *db.PostgresClient) *APIHandler
func NewWithAPIClient ¶ added in v0.66.0
func NewWithAPIClient(apiClient *apiclient.APIClient, postgresClient *db.PostgresClient) *APIHandler
func NewWithPave ¶ added in v0.87.0
func NewWithPave(apiClient *apiclient.APIClient, postgresClient *db.PostgresClient, paveClient *pave.Pave) *APIHandler
func (*APIHandler) AssetAttributesGET ¶ added in v0.63.0
func (h *APIHandler) AssetAttributesGET(c echo.Context) (err error)
AssetAttributesGET is the handler for `GET /v1/assets/{asset_id}/attributes`
func (*APIHandler) AssetDELETE ¶ added in v0.63.0
func (h *APIHandler) AssetDELETE(c echo.Context) (err error)
AssetDELETE is the handler for `DELETE /v1/assets/{asset_id}`
func (*APIHandler) AssetDescriptionGET ¶ added in v0.63.0
func (h *APIHandler) AssetDescriptionGET(c echo.Context) (err error)
AssetDescriptionGET is the handler for `GET /v1/assets/{asset_id}/description`
func (*APIHandler) AssetDescriptionPUT ¶ added in v0.63.0
func (h *APIHandler) AssetDescriptionPUT(c echo.Context) (err error)
AssetDescriptionPUT is the handler for `PUT /v1/assets/{asset_id}/description`
func (*APIHandler) AssetGET ¶ added in v0.63.0
func (h *APIHandler) AssetGET(c echo.Context) (err error)
AssetGET is the handler for `GET /v1/assets/{asset_id}`
func (*APIHandler) AssetRestorePOST ¶ added in v0.63.0
func (h *APIHandler) AssetRestorePOST(c echo.Context) (err error)
AssetRestorePOST is the handler for `POST /v1/assets/{asset_id}/restore`
func (*APIHandler) AssetStatusDELETE ¶ added in v0.63.0
func (h *APIHandler) AssetStatusDELETE(c echo.Context) (err error)
AssetStatusDELETE is the handler for `DELETE /v1/assets/{asset_id}/status`
func (*APIHandler) AssetStatusGET ¶ added in v0.63.0
func (h *APIHandler) AssetStatusGET(c echo.Context) (err error)
AssetStatusGET is the handler for `GET /v1/assets/{asset_id}/status`
func (*APIHandler) AssetStatusPUT ¶ added in v0.63.0
func (h *APIHandler) AssetStatusPUT(c echo.Context) (err error)
AssetStatusPUT is the handler for `PUT /v1/assets/{asset_id}/status`
func (*APIHandler) AssetTargetDELETE ¶ added in v0.63.0
func (h *APIHandler) AssetTargetDELETE(c echo.Context) (err error)
AssetTargetDELETE is the handler for `DELETE /v1/assets/{asset_id}/target`
func (*APIHandler) AssetTargetGET ¶ added in v0.63.0
func (h *APIHandler) AssetTargetGET(c echo.Context) (err error)
AssetTargetGET is the handler for `GET /v1/assets/{asset_id}/target`
func (*APIHandler) AssetTargetPUT ¶ added in v0.63.0
func (h *APIHandler) AssetTargetPUT(c echo.Context) (err error)
AssetTargetPUT is the handler for `PUT /v1/assets/{asset_id}/target`
func (*APIHandler) AssetsAllGET ¶ added in v0.60.0
func (h *APIHandler) AssetsAllGET(c echo.Context) (err error)
AssetsAllGET is the handler for `GET /v1/assets/all`
func (*APIHandler) AssetsDELETE ¶ added in v0.63.0
func (h *APIHandler) AssetsDELETE(c echo.Context) error
AssetsDELETE is the handler for `DELETE /v1/assets`
func (*APIHandler) AssetsDetailedGET ¶ added in v0.74.0
func (h *APIHandler) AssetsDetailedGET(c echo.Context) (err error)
AssetsDetailedGET is the handler for `GET /v1/assets/detailed`
func (*APIHandler) AssetsGET ¶ added in v0.63.0
func (h *APIHandler) AssetsGET(c echo.Context) (err error)
AssetsGET is the handler for `GET /v1/assets`
func (*APIHandler) AssetsPOST ¶ added in v0.63.0
func (h *APIHandler) AssetsPOST(c echo.Context) (err error)
AssetsPOST is the handler for `POST /v1/assets`
func (*APIHandler) AssetsRestorePOST ¶ added in v0.67.0
func (h *APIHandler) AssetsRestorePOST(c echo.Context) (err error)
AssetsRestorePOST is the handler for `POST /v1/assets/restore`
func (*APIHandler) AttributeAllowEmptyValuePUT ¶ added in v0.75.0
func (h *APIHandler) AttributeAllowEmptyValuePUT(c echo.Context) (err error)
AttributeAllowEmptyValuePUT
func (*APIHandler) AttributeAssetsGET ¶ added in v0.63.0
func (h *APIHandler) AttributeAssetsGET(c echo.Context) (err error)
AttributeAssetsGET is the handler for `GET /v1/attributes/{attribute_id}/assets`
func (*APIHandler) AttributeDELETE ¶ added in v0.63.0
func (h *APIHandler) AttributeDELETE(c echo.Context) (err error)
AttributeDELETE is the handler for `DELETE /v1/attributes/{attribute_id}`
func (*APIHandler) AttributeGET ¶ added in v0.63.0
func (h *APIHandler) AttributeGET(c echo.Context) (err error)
AttributeGET is the handler for `GET /v1/attributes/{attribute_id}`
func (*APIHandler) AttributeKeyPUT ¶ added in v0.75.0
func (h *APIHandler) AttributeKeyPUT(c echo.Context) (err error)
AttributeKeyPUT
func (*APIHandler) AttributeRestorePOST ¶ added in v0.63.0
func (h *APIHandler) AttributeRestorePOST(c echo.Context) (err error)
AttributeRestorePOST
func (*APIHandler) AttributesDELETE ¶ added in v0.77.0
func (h *APIHandler) AttributesDELETE(c echo.Context) (err error)
AttributesDELETE
func (*APIHandler) AttributesGET ¶ added in v0.63.0
func (h *APIHandler) AttributesGET(c echo.Context) (err error)
AttributesGET is the handler for `GET /v1/attributes`
func (*APIHandler) AttributesPOST ¶ added in v0.63.0
func (h *APIHandler) AttributesPOST(c echo.Context) (err error)
AttributesPOST is the handler for `POST /v1/attributes`
func (*APIHandler) EventsGET ¶ added in v0.62.0
func (h *APIHandler) EventsGET(c echo.Context) (err error)
EventsGET is the handler for `GET /events`
func (*APIHandler) HealthGET ¶
func (h *APIHandler) HealthGET(c echo.Context) (err error)
HealthGET is the handler for `GET /v1/health`
func (*APIHandler) SeedPOST ¶ added in v0.61.0
func (h *APIHandler) SeedPOST(c echo.Context) (err error)
SeedPOST is the handler for `POST /v1/seed`
func (*APIHandler) SpecGET ¶ added in v0.87.0
func (h *APIHandler) SpecGET(c echo.Context) (err error)
SpecGET is the handler for `POST /v1/seed`
func (*APIHandler) TagDELETE ¶ added in v0.78.0
func (h *APIHandler) TagDELETE(c echo.Context) (err error)
TagDELETE is the handler for `DELETE /v1/tags/{tag_id}`
func (*APIHandler) TagDetailedGET ¶ added in v0.78.0
func (h *APIHandler) TagDetailedGET(c echo.Context) (err error)
func (*APIHandler) TagGET ¶ added in v0.78.0
func (h *APIHandler) TagGET(c echo.Context) (err error)
TagGET is the handler for `GET /v1/tags/{tag_id}`
func (*APIHandler) TagValueGET ¶ added in v0.78.0
func (h *APIHandler) TagValueGET(c echo.Context) (err error)
func (*APIHandler) TagValuePUT ¶ added in v0.78.0
func (h *APIHandler) TagValuePUT(c echo.Context) (err error)
func (*APIHandler) TagsDELETE ¶ added in v0.78.0
func (h *APIHandler) TagsDELETE(c echo.Context) (err error)
TagsDELETE is the handler for `DELETE /v1/tags`
func (*APIHandler) TagsGET ¶ added in v0.78.0
func (h *APIHandler) TagsGET(c echo.Context) (err error)
TagsGET is the handler for `GET /v1/tags`
func (*APIHandler) TagsPOST ¶ added in v0.78.0
func (h *APIHandler) TagsPOST(c echo.Context) (err error)
TagsPOST is `POST /tags`