api_impl

package
v0.23.36 Latest Latest
Warning

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

Go to latest
Published: Jun 13, 2023 License: Apache-2.0 Imports: 61 Imported by: 1

Documentation

Index

Constants

View Source
const (
	ApiVersion = "1.0.0"

	VersionV1 = "v1"

	RestApiV1 = "/" + VersionV1

	FabricRestApiRootPath = "/fabric"

	FabricRestApiBaseUrlV1 = FabricRestApiRootPath + RestApiV1

	FabricRestApiBaseUrlLatest = FabricRestApiBaseUrlV1

	FabricRestApiSpecUrl = FabricRestApiBaseUrlLatest + "/swagger.json"

	FabricApiBinding = "fabric"

	MetricApiBinding = "metrics"
)
View Source
const EntityNameCircuit = "circuits"
View Source
const EntityNameInspect = "inspections"
View Source
const EntityNameLink = "links"
View Source
const EntityNameMetrics = "metrics"
View Source
const EntityNameRouter = "routers"
View Source
const (
	EntityNameSelf = "self"
)
View Source
const EntityNameService = "services"
View Source
const EntityNameTerminator = "terminators"
View Source
const (
	LimitMax = 500
)
View Source
const (
	ServerHeader = "server"
)

Variables

View Source
var AllApiBindingVersions = map[string]map[string]string{
	FabricApiBinding: {
		VersionV1: FabricRestApiBaseUrlV1,
	},
}

AllApiBindingVersions is a map of: API Binding -> Api Version -> API Path Adding values here will add them to the /versions REST API endpoint

View Source
var CircuitLinkFactory = NewCircuitLinkFactory()
View Source
var LinkLinkFactory = NewLinkLinkFactory()
View Source
var RouterLinkFactory = NewRouterLinkFactory()
View Source
var ServiceLinkFactory = NewServiceLinkFactory()

Functions

func AddRouter

func AddRouter(router Router)

func BaseEntityToRestModel

func BaseEntityToRestModel(entity models.Entity, linkFactory LinksFactory) rest_model.BaseEntity

func BoolOrDefault

func BoolOrDefault(val *bool) bool

func Create

func Create(rc api.RequestContext, linkFactory CreateLinkFactory, creator ModelCreateF)

func CreateWithResponder

func CreateWithResponder(rsp api.Responder, linkFactory CreateLinkFactory, creator ModelCreateF)

func Delete

func Delete(rc api.RequestContext, deleteF ModelDeleteF)

func DeleteWithHandler

func DeleteWithHandler(rc api.RequestContext, deleteHandler DeleteHandler)

func Detail

func Detail(rc api.RequestContext, f ModelDetailF)

func DetailWithHandler

func DetailWithHandler[T models.Entity](network *network.Network, rc api.RequestContext, loader models.EntityRetriever[T], mapper ModelToApiMapper[T])

func Int64OrDefault

func Int64OrDefault(val *int64) int64

func ListAssociationWithHandler

func ListAssociationWithHandler[T models.Entity, A models.Entity](n *network.Network, rc api.RequestContext, sourceR models.EntityRetriever[T], associatedR models.EntityRetriever[A], mapper ModelToApiMapper[A])

func ListAssociations

func ListAssociations(rc api.RequestContext, listF listAssocF)

func ListWithEnvelopeFactory

func ListWithEnvelopeFactory(rc api.RequestContext, toEnvelope ApiListEnvelopeFactory, f modelListF)

func ListWithHandler

func ListWithHandler[T models.Entity](n *network.Network, rc api.RequestContext, lister models.EntityRetriever[T], mapper ModelToApiMapper[T])

func ListWithQueryF

func ListWithQueryF[T models.Entity](n *network.Network, rc api.RequestContext, lister models.EntityRetriever[T], mapper ModelToApiMapper[T], qf func(query ast.Query) (*models.EntityListResult[T], error))

func ListWithQueryFAndCollector

func ListWithQueryFAndCollector[T models.Entity](n *network.Network, rc api.RequestContext, lister models.EntityRetriever[T], mapper ModelToApiMapper[T], toEnvelope ApiListEnvelopeFactory, qf func(query ast.Query) (*models.EntityListResult[T], error))

func MapCircuitToRestModel

func MapCircuitToRestModel(_ *network.Network, _ api.RequestContext, circuit *network.Circuit) (*rest_model.CircuitDetail, error)

func MapCreateRouterToModel

func MapCreateRouterToModel(router *rest_model.RouterCreate) *network.Router

func MapCreateServiceToModel

func MapCreateServiceToModel(service *rest_model.ServiceCreate) *network.Service

func MapCreateTerminatorToModel

func MapCreateTerminatorToModel(terminator *rest_model.TerminatorCreate) *network.Terminator

func MapInspectResultToRestModel added in v0.17.9

func MapInspectResultToRestModel(n *network.Network, inspectResult *network.InspectResult) *rest_model.InspectResponse

func MapLinkToRestModel

func MapLinkToRestModel(_ *network.Network, _ api.RequestContext, link *network.Link) (*rest_model.LinkDetail, error)

func MapPatchRouterToModel

func MapPatchRouterToModel(id string, router *rest_model.RouterPatch) *network.Router

func MapPatchServiceToModel

func MapPatchServiceToModel(id string, service *rest_model.ServicePatch) *network.Service

func MapPatchTerminatorToModel

func MapPatchTerminatorToModel(id string, terminator *rest_model.TerminatorPatch) *network.Terminator

func MapTerminatorToRestModel

func MapTerminatorToRestModel(n *network.Network, terminator *network.Terminator) (*rest_model.TerminatorDetail, error)

func MapUpdateRouterToModel

func MapUpdateRouterToModel(id string, router *rest_model.RouterUpdate) *network.Router

func MapUpdateServiceToModel

func MapUpdateServiceToModel(id string, service *rest_model.ServiceUpdate) *network.Service

func MapUpdateTerminatorToModel

func MapUpdateTerminatorToModel(id string, terminator *rest_model.TerminatorUpdate) *network.Terminator
func NewLink(path string) rest_model.Link

func NewRequestContext

func NewRequestContext(rw http.ResponseWriter, r *http.Request) api.RequestContext

func OverrideRequestWrapper

func OverrideRequestWrapper(rw RequestWrapper)

func Patch

func Patch(rc api.RequestContext, patchF ModelPatchF)

func RespondWithCreatedId

func RespondWithCreatedId(responder api.Responder, id string, link rest_model.Link)

func RespondWithOk

func RespondWithOk(responder api.Responder, data interface{}, meta *rest_model.Meta)

func ServeError

func ServeError(rw http.ResponseWriter, r *http.Request, inErr error)

Wrapper for the OpenAPI REST server to allow the the Edge API Error message responses to be used

func TagsOrDefault

func TagsOrDefault(tags *rest_model.Tags) map[string]interface{}

func ToEntityRef

func ToEntityRef(name string, entity LinkEntity, factory LinksFactory) *rest_model.EntityRef

func ToRestModel

func ToRestModel(e *errorz.ApiError, requestId string) *rest_model.APIError

func Update

func Update(rc api.RequestContext, updateF ModelUpdateF)

func UpdateAllowEmptyBody

func UpdateAllowEmptyBody(rc api.RequestContext, updateF ModelUpdateF)

Types

type ApiEntityEnvelopeFactory

type ApiEntityEnvelopeFactory func(data interface{}, meta *rest_model.Meta) interface{}

type ApiListEnvelopeFactory

type ApiListEnvelopeFactory func(data []interface{}, meta *rest_model.Meta) interface{}

type BasicLinkFactory

type BasicLinkFactory struct {
	// contains filtered or unexported fields
}

func NewBasicLinkFactory

func NewBasicLinkFactory(entityName string) *BasicLinkFactory

func (*BasicLinkFactory) EntityName

func (factory *BasicLinkFactory) EntityName() string
func (factory *BasicLinkFactory) Links(entity LinkEntity) rest_model.Links
func (factory BasicLinkFactory) NewNestedLink(entity LinkEntity, elem ...string) rest_model.Link
func (factory *BasicLinkFactory) SelfLink(entity LinkEntity) rest_model.Link

func (*BasicLinkFactory) SelfLinkFromId

func (factory *BasicLinkFactory) SelfLinkFromId(id string) rest_model.Link

func (*BasicLinkFactory) SelfUrlString

func (factory *BasicLinkFactory) SelfUrlString(id string) string

type CircuitLinkFactoryIml

type CircuitLinkFactoryIml struct {
	BasicLinkFactory
}

func NewCircuitLinkFactory

func NewCircuitLinkFactory() *CircuitLinkFactoryIml
func (factory *CircuitLinkFactoryIml) Links(entity LinkEntity) rest_model.Links

type CircuitRouter

type CircuitRouter struct {
	BasePath string
}

func NewCircuitRouter

func NewCircuitRouter() *CircuitRouter

func (*CircuitRouter) Delete

func (*CircuitRouter) Detail

func (r *CircuitRouter) Detail(n *network.Network, rc api.RequestContext)

func (*CircuitRouter) ListCircuits

func (r *CircuitRouter) ListCircuits(n *network.Network, rc api.RequestContext)

func (*CircuitRouter) Register

func (r *CircuitRouter) Register(fabricApi *operations.ZitiFabricAPI, wrapper RequestWrapper)

type CreateLinkFactory

type CreateLinkFactory interface {
	SelfLinkFromId(id string) rest_model.Link
}

type DatabaseRouter added in v0.17.62

type DatabaseRouter struct {
	// contains filtered or unexported fields
}

func NewDatabaseRouter added in v0.17.62

func NewDatabaseRouter() *DatabaseRouter

func (*DatabaseRouter) CheckDatastoreIntegrity added in v0.17.62

func (r *DatabaseRouter) CheckDatastoreIntegrity(n *network.Network, rc api.RequestContext, fixErrors bool)

func (*DatabaseRouter) CreateSnapshot added in v0.17.62

func (r *DatabaseRouter) CreateSnapshot(n *network.Network, rc api.RequestContext)

func (*DatabaseRouter) GetCheckProgress added in v0.17.62

func (r *DatabaseRouter) GetCheckProgress(_ *network.Network, rc api.RequestContext)

func (*DatabaseRouter) Register added in v0.17.62

func (r *DatabaseRouter) Register(fabricApi *operations.ZitiFabricAPI, wrapper RequestWrapper)

type DeleteHandler

type DeleteHandler interface {
	Delete(id string, ctx *change.Context) error
}

type DeleteHandlerF

type DeleteHandlerF func(id string, ctx *change.Context) error

func (DeleteHandlerF) Delete

func (self DeleteHandlerF) Delete(id string, ctx *change.Context) error

type FabricRequestWrapper

type FabricRequestWrapper struct {
	// contains filtered or unexported fields
}

func (*FabricRequestWrapper) WrapHttpHandler

func (self *FabricRequestWrapper) WrapHttpHandler(handler http.Handler) http.Handler

func (*FabricRequestWrapper) WrapRequest

func (self *FabricRequestWrapper) WrapRequest(handler RequestHandler, request *http.Request, entityId, entitySubId string) openApiMiddleware.Responder

func (*FabricRequestWrapper) WrapWsHandler added in v0.17.104

func (self *FabricRequestWrapper) WrapWsHandler(handler http.Handler) http.Handler

type FullLinkFactory

type FullLinkFactory interface {
	LinksFactory
	SelfLinkFactory
}

type InspectRouter added in v0.17.9

type InspectRouter struct {
	BasePath string
}

func NewInspectRouter added in v0.17.9

func NewInspectRouter() *InspectRouter

func (*InspectRouter) Inspect added in v0.17.9

func (*InspectRouter) Register added in v0.17.9

func (r *InspectRouter) Register(fabricApi *operations.ZitiFabricAPI, wrapper RequestWrapper)

type LinkEntity

type LinkEntity interface {
	GetId() string
}

type LinkLinkFactoryIml

type LinkLinkFactoryIml struct {
	BasicLinkFactory
}

func NewLinkLinkFactory

func NewLinkLinkFactory() *LinkLinkFactoryIml
func (factory *LinkLinkFactoryIml) Links(entity LinkEntity) rest_model.Links

type LinkRouter

type LinkRouter struct {
	BasePath string
}

func NewLinkRouter

func NewLinkRouter() *LinkRouter

func (*LinkRouter) Delete added in v0.17.121

func (r *LinkRouter) Delete(network *network.Network, rc api.RequestContext)

func (*LinkRouter) Detail

func (r *LinkRouter) Detail(n *network.Network, rc api.RequestContext)
func (r *LinkRouter) ListLinks(n *network.Network, rc api.RequestContext)

func (*LinkRouter) Patch

func (r *LinkRouter) Patch(n *network.Network, rc api.RequestContext, params link.PatchLinkParams)

func (*LinkRouter) Register

func (r *LinkRouter) Register(fabricApi *operations.ZitiFabricAPI, wrapper RequestWrapper)

type LinksFactory

type LinksFactory interface {
	Links(entity LinkEntity) rest_model.Links
	EntityName() string
}

type ManagementApiFactory

type ManagementApiFactory struct {
	InitFunc func(managementApi *ManagementApiHandler) error
	// contains filtered or unexported fields
}

func NewManagementApiFactory

func NewManagementApiFactory(nodeId identity.Identity, network *network.Network, xmgmts []xmgmt.Xmgmt) *ManagementApiFactory

func (*ManagementApiFactory) Binding

func (factory *ManagementApiFactory) Binding() string

func (*ManagementApiFactory) New

func (factory *ManagementApiFactory) New(_ *xweb.ServerConfig, options map[interface{}]interface{}) (xweb.ApiHandler, error)

func (*ManagementApiFactory) Validate

func (factory *ManagementApiFactory) Validate(_ *xweb.InstanceConfig) error

type ManagementApiHandler

type ManagementApiHandler struct {
	// contains filtered or unexported fields
}

func NewManagementApiHandler

func NewManagementApiHandler(fabricApi *operations.ZitiFabricAPI, options map[interface{}]interface{}) (*ManagementApiHandler, error)

func (*ManagementApiHandler) Binding

func (managementApi *ManagementApiHandler) Binding() string

func (*ManagementApiHandler) IsHandler

func (managementApi *ManagementApiHandler) IsHandler(r *http.Request) bool

func (*ManagementApiHandler) Options

func (managementApi *ManagementApiHandler) Options() map[interface{}]interface{}

func (*ManagementApiHandler) RootPath

func (managementApi *ManagementApiHandler) RootPath() string

func (*ManagementApiHandler) ServeHTTP

func (managementApi *ManagementApiHandler) ServeHTTP(writer http.ResponseWriter, request *http.Request)

type MetricsApiFactory added in v0.18.4

type MetricsApiFactory struct {
	// contains filtered or unexported fields
}

func NewMetricsApiFactory added in v0.18.4

func NewMetricsApiFactory(nodeId identity.Identity, network *network.Network, xmgmts []xmgmt.Xmgmt) *MetricsApiFactory

func (*MetricsApiFactory) Binding added in v0.18.4

func (factory *MetricsApiFactory) Binding() string

func (*MetricsApiFactory) New added in v0.18.4

func (factory *MetricsApiFactory) New(_ *xweb.ServerConfig, options map[interface{}]interface{}) (xweb.ApiHandler, error)

func (*MetricsApiFactory) Validate added in v0.18.4

func (factory *MetricsApiFactory) Validate(_ *xweb.InstanceConfig) error

type MetricsApiHandler added in v0.18.4

type MetricsApiHandler struct {
	// contains filtered or unexported fields
}

func NewMetricsApiHandler added in v0.18.4

func NewMetricsApiHandler(n *network.Network, options map[interface{}]interface{}) (*MetricsApiHandler, error)

func (*MetricsApiHandler) Binding added in v0.18.4

func (metricsApi *MetricsApiHandler) Binding() string

func (*MetricsApiHandler) IsHandler added in v0.18.4

func (metricsApi *MetricsApiHandler) IsHandler(r *http.Request) bool

func (*MetricsApiHandler) Options added in v0.18.4

func (metricsApi *MetricsApiHandler) Options() map[interface{}]interface{}

func (*MetricsApiHandler) RootPath added in v0.18.4

func (metricsApi *MetricsApiHandler) RootPath() string

func (*MetricsApiHandler) ServeHTTP added in v0.18.4

func (metricsApi *MetricsApiHandler) ServeHTTP(writer http.ResponseWriter, request *http.Request)

type MetricsModelMapper added in v0.18.7

type MetricsModelMapper interface {
	MapInspectResultToMetricsResult(inspectResult *network.InspectResult) (*string, error)
	MapInspectResultValueToMetricsResult(inspectResultValue *network.InspectResultValue) (any, error)
}

func NewMetricsModelMapper added in v0.18.7

func NewMetricsModelMapper(n *network.Network, format string, includeTimestamps bool) MetricsModelMapper

type ModelCreateF

type ModelCreateF func() (string, error)

type ModelDeleteF

type ModelDeleteF func(rc api.RequestContext, id string) error

type ModelDetailF

type ModelDetailF func(rc api.RequestContext, id string) (interface{}, error)

type ModelPatchF

type ModelPatchF func(id string, fields fields.UpdatedFields) error

type ModelToApiMapper

type ModelToApiMapper[T models.Entity] interface {
	ToApi(*network.Network, api.RequestContext, T) (interface{}, error)
}

type ModelUpdateF

type ModelUpdateF func(id string) error

type Paging

type Paging struct {
	Offset    int64
	Limit     int64
	ReturnAll bool
}

func GetRequestPaging

func GetRequestPaging(r *http.Request) (*Paging, error)

func (*Paging) String

func (paging *Paging) String() string

type PublicQueryOptions

type PublicQueryOptions struct {
	Predicate string
	Sort      string
	Paging    *Paging
}

PublicQueryOptions represents external query options, which limits some query options (i.e. return all vs max limit). PublicQueryOptions can be used internally as long as the public option limitations are fitting.

func GetModelQueryOptionsFromRequest

func GetModelQueryOptionsFromRequest(r *http.Request) (*PublicQueryOptions, error)

func (*PublicQueryOptions) String

func (qo *PublicQueryOptions) String() string

type QueryResult

type QueryResult struct {
	Result           interface{}
	Count            int64
	Limit            int64
	Offset           int64
	FilterableFields []string
}

func NewQueryResult

func NewQueryResult(result interface{}, metadata *models.QueryMetaData) *QueryResult

type RaftRouter added in v0.22.10

type RaftRouter struct {
}

func NewRaftRouter added in v0.22.10

func NewRaftRouter() *RaftRouter

func (*RaftRouter) ListMembers added in v0.22.10

func (r *RaftRouter) ListMembers(n *network.Network, rc api.RequestContext)

func (*RaftRouter) Register added in v0.22.10

func (r *RaftRouter) Register(fabricApi *operations.ZitiFabricAPI, wrapper RequestWrapper)

type RequestHandler

type RequestHandler func(network *network.Network, rc api.RequestContext)

type RequestWrapper

type RequestWrapper interface {
	WrapRequest(handler RequestHandler, request *http.Request, entityId, entitySubId string) openApiMiddleware.Responder
	WrapHttpHandler(handler http.Handler) http.Handler
	WrapWsHandler(handler http.Handler) http.Handler
}

type Router

type Router interface {
	Register(fabricApi *operations.ZitiFabricAPI, wrapper RequestWrapper)
}

type RouterLinkFactoryIml

type RouterLinkFactoryIml struct {
	BasicLinkFactory
}

func NewRouterLinkFactory

func NewRouterLinkFactory() *RouterLinkFactoryIml
func (factory *RouterLinkFactoryIml) Links(entity LinkEntity) rest_model.Links

type RouterModelMapper added in v0.19.30

type RouterModelMapper struct{}

func (RouterModelMapper) ToApi added in v0.19.30

func (RouterModelMapper) ToApi(n *network.Network, _ api.RequestContext, router *network.Router) (interface{}, error)

type RouterRouter

type RouterRouter struct {
	BasePath string
}

func NewRouterRouter

func NewRouterRouter() *RouterRouter

func (*RouterRouter) Create

func (*RouterRouter) Delete

func (r *RouterRouter) Delete(network *network.Network, rc api.RequestContext)

func (*RouterRouter) Detail

func (r *RouterRouter) Detail(n *network.Network, rc api.RequestContext)

func (*RouterRouter) ListRouters

func (r *RouterRouter) ListRouters(n *network.Network, rc api.RequestContext)

func (*RouterRouter) Patch

func (*RouterRouter) Register

func (r *RouterRouter) Register(fabricApi *operations.ZitiFabricAPI, wrapper RequestWrapper)

func (*RouterRouter) Update

type SelfLinkFactory

type SelfLinkFactory interface {
	SelfLink(entity models.Entity) rest_model.Link
}

type ServiceLinkFactoryIml

type ServiceLinkFactoryIml struct {
	BasicLinkFactory
}

func NewServiceLinkFactory

func NewServiceLinkFactory() *ServiceLinkFactoryIml
func (factory *ServiceLinkFactoryIml) Links(entity LinkEntity) rest_model.Links

type ServiceModelMapper added in v0.19.30

type ServiceModelMapper struct{}

func (ServiceModelMapper) ToApi added in v0.19.30

func (ServiceModelMapper) ToApi(_ *network.Network, _ api.RequestContext, service *network.Service) (interface{}, error)

type ServiceRouter

type ServiceRouter struct {
	BasePath string
}

func NewServiceRouter

func NewServiceRouter() *ServiceRouter

func (*ServiceRouter) Create

func (*ServiceRouter) Delete

func (r *ServiceRouter) Delete(network *network.Network, rc api.RequestContext)

func (*ServiceRouter) Detail

func (r *ServiceRouter) Detail(n *network.Network, rc api.RequestContext)

func (*ServiceRouter) ListServices

func (r *ServiceRouter) ListServices(n *network.Network, rc api.RequestContext)

func (*ServiceRouter) Patch

func (*ServiceRouter) Register

func (r *ServiceRouter) Register(fabricApi *operations.ZitiFabricAPI, wrapper RequestWrapper)

func (*ServiceRouter) Update

type TerminatorModelMapper added in v0.19.30

type TerminatorModelMapper struct{}

func (TerminatorModelMapper) ToApi added in v0.19.30

func (TerminatorModelMapper) ToApi(n *network.Network, _ api.RequestContext, terminator *network.Terminator) (interface{}, error)

type TerminatorRouter

type TerminatorRouter struct {
	BasePath string
}

func NewTerminatorRouter

func NewTerminatorRouter() *TerminatorRouter

func (*TerminatorRouter) Create

func (*TerminatorRouter) Delete

func (*TerminatorRouter) Detail

func (*TerminatorRouter) List

func (*TerminatorRouter) Patch

func (*TerminatorRouter) Register

func (r *TerminatorRouter) Register(fabricApi *operations.ZitiFabricAPI, wrapper RequestWrapper)

func (*TerminatorRouter) Update

Jump to

Keyboard shortcuts

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