api_impl

package
v0.17.29 Latest Latest
Warning

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

Go to latest
Published: Jan 28, 2022 License: Apache-2.0 Imports: 41 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"
)
View Source
const EntityNameCircuit = "circuits"
View Source
const EntityNameInspect = "inspections"
View Source
const EntityNameLink = "links"
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(network *network.Network, rc api.RequestContext, loader models.EntityRetriever, mapper ModelToApiMapper)

func Int64OrDefault

func Int64OrDefault(val *int64) int64

func List

func List(rc api.RequestContext, f modelListF)

func ListAssociationWithHandler

func ListAssociationWithHandler(n *network.Network, rc api.RequestContext, lister models.EntityRetriever, associationLoader models.EntityRetriever, mapper ModelToApiMapper)

func ListAssociations

func ListAssociations(rc api.RequestContext, listF listAssocF)

func ListWithEnvelopeFactory

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

func ListWithHandler

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

func ListWithQueryF

func ListWithQueryF(n *network.Network, rc api.RequestContext, lister models.EntityRetriever, mapper ModelToApiMapper, qf queryF)

func ListWithQueryFAndCollector

func ListWithQueryFAndCollector(n *network.Network, rc api.RequestContext, lister models.EntityRetriever, mapper ModelToApiMapper, toEnvelope ApiListEnvelopeFactory, qf queryF)

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(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 MapRouterToRestEntity

func MapRouterToRestEntity(n *network.Network, rc api.RequestContext, e models.Entity) (interface{}, error)

func MapRouterToRestModel

func MapRouterToRestModel(n *network.Network, _ api.RequestContext, router *network.Router) (*rest_model.RouterDetail, error)

func MapServiceToRestEntity

func MapServiceToRestEntity(n *network.Network, rc api.RequestContext, e models.Entity) (interface{}, error)

func MapServiceToRestModel

func MapServiceToRestModel(_ *network.Network, _ api.RequestContext, service *network.Service) (*rest_model.ServiceDetail, error)

func MapTerminatorToRestEntity

func MapTerminatorToRestEntity(n *network.Network, _ api.RequestContext, e models.Entity) (interface{}, error)

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 DeleteHandler

type DeleteHandler interface {
	Delete(id string) error
}

type DeleteHandlerF

type DeleteHandlerF func(id string) error

func (DeleteHandlerF) Delete

func (self DeleteHandlerF) Delete(id string) 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

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) 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) *ManagementApiFactory

func (ManagementApiFactory) Binding

func (factory ManagementApiFactory) Binding() string

func (ManagementApiFactory) New

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

func (ManagementApiFactory) Validate

func (factory ManagementApiFactory) Validate(_ *xweb.Config) 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 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 api.JsonFields) error

type ModelToApiMapper

type ModelToApiMapper func(*network.Network, api.RequestContext, models.Entity) (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 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
}

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