api/generated.go
// Package api provides primitives to interact the openapi HTTP API.
//
// Code generated by github.com/deepmap/oapi-codegen DO NOT EDIT.
package api
import (
"fmt"
"net/http"
"github.com/deepmap/oapi-codegen/pkg/runtime"
"github.com/labstack/echo/v4"
)
// Event defines model for Event.
type Event struct {
// V4 UUID assigned by Corda to a record
ConsentId *string `json:"consentId,omitempty"`
// error reason in case of a functional error
Error *string `json:"error,omitempty"`
// ID calculated by crypto using BSN and private key of initiatorLegalEntity
ExternalId string `json:"externalId"`
// Generic identifier used for representing BSN, agbcode, etc. It's always constructed as an URN followed by a double colon (:) and then the identifying value of the given URN
InitiatorLegalEntity Identifier `json:"initiatorLegalEntity"`
Name string `json:"name"`
// NewConsentRequestState JSON as accepted by consent-bridge (:ref:`nuts-consent-bridge-api`)
Payload string `json:"payload"`
// 0 to X
RetryCount int `json:"retryCount"`
// V4 UUID assigned by Corda to a transaction
TransactionId *string `json:"transactionId,omitempty"`
// V4 UUID
Uuid string `json:"uuid"`
}
// EventListResponse defines model for EventListResponse.
type EventListResponse struct {
Events *[]Event `json:"events,omitempty"`
}
// Identifier defines model for Identifier.
type Identifier string
// ServerInterface represents all server handlers.
type ServerInterface interface {
// Return all events currently in store
// (GET /events)
List(ctx echo.Context) error
// Find a specific event by its externalId
// (GET /events/by_external_id/{external_id})
GetEventByExternalId(ctx echo.Context, externalId string) error
// Find a specific event
// (GET /events/{uuid})
GetEvent(ctx echo.Context, uuid string) error
}
// ServerInterfaceWrapper converts echo contexts to parameters.
type ServerInterfaceWrapper struct {
Handler ServerInterface
}
// List converts echo context to params.
func (w *ServerInterfaceWrapper) List(ctx echo.Context) error {
var err error
// Invoke the callback with all the unmarshalled arguments
err = w.Handler.List(ctx)
return err
}
// GetEventByExternalId converts echo context to params.
func (w *ServerInterfaceWrapper) GetEventByExternalId(ctx echo.Context) error {
var err error
// ------------- Path parameter "external_id" -------------
var externalId string
err = runtime.BindStyledParameter("simple", false, "external_id", ctx.Param("external_id"), &externalId)
if err != nil {
return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("Invalid format for parameter external_id: %s", err))
}
// Invoke the callback with all the unmarshalled arguments
err = w.Handler.GetEventByExternalId(ctx, externalId)
return err
}
// GetEvent converts echo context to params.
func (w *ServerInterfaceWrapper) GetEvent(ctx echo.Context) error {
var err error
// ------------- Path parameter "uuid" -------------
var uuid string
err = runtime.BindStyledParameter("simple", false, "uuid", ctx.Param("uuid"), &uuid)
if err != nil {
return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("Invalid format for parameter uuid: %s", err))
}
// Invoke the callback with all the unmarshalled arguments
err = w.Handler.GetEvent(ctx, uuid)
return err
}
// This is a simple interface which specifies echo.Route addition functions which
// are present on both echo.Echo and echo.Group, since we want to allow using
// either of them for path registration
type EchoRouter interface {
CONNECT(path string, h echo.HandlerFunc, m ...echo.MiddlewareFunc) *echo.Route
DELETE(path string, h echo.HandlerFunc, m ...echo.MiddlewareFunc) *echo.Route
GET(path string, h echo.HandlerFunc, m ...echo.MiddlewareFunc) *echo.Route
HEAD(path string, h echo.HandlerFunc, m ...echo.MiddlewareFunc) *echo.Route
OPTIONS(path string, h echo.HandlerFunc, m ...echo.MiddlewareFunc) *echo.Route
PATCH(path string, h echo.HandlerFunc, m ...echo.MiddlewareFunc) *echo.Route
POST(path string, h echo.HandlerFunc, m ...echo.MiddlewareFunc) *echo.Route
PUT(path string, h echo.HandlerFunc, m ...echo.MiddlewareFunc) *echo.Route
TRACE(path string, h echo.HandlerFunc, m ...echo.MiddlewareFunc) *echo.Route
}
// RegisterHandlers adds each server route to the EchoRouter.
func RegisterHandlers(router EchoRouter, si ServerInterface) {
RegisterHandlersWithBaseURL(router, si, "")
}
// Registers handlers, and prepends BaseURL to the paths, so that the paths
// can be served under a prefix.
func RegisterHandlersWithBaseURL(router EchoRouter, si ServerInterface, baseURL string) {
wrapper := ServerInterfaceWrapper{
Handler: si,
}
router.GET(baseURL+"/events", wrapper.List)
router.GET(baseURL+"/events/by_external_id/:external_id", wrapper.GetEventByExternalId)
router.GET(baseURL+"/events/:uuid", wrapper.GetEvent)
}