graphapi

package
v0.0.25 Latest Latest
Warning

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

Go to latest
Published: Aug 30, 2023 License: Apache-2.0 Imports: 31 Imported by: 0

Documentation

Overview

Package graphapi provides the graph api handler and resolver for load balancer api

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrUnknownType  = errors.New("unknown type")
	ErrTypeNotFound = errors.New("type not found")
)
View Source
var ErrPortNumberInUse = errors.New("port number already in use")

ErrPortNumberInUse is returned when a port number is already in use.

Functions

func NewExecutableSchema

func NewExecutableSchema(cfg Config) graphql.ExecutableSchema

NewExecutableSchema creates an ExecutableSchema from the ResolverRoot interface.

Types

type ComplexityRoot

type ComplexityRoot struct {
	Entity struct {
		FindLoadBalancerByID         func(childComplexity int, id gidx.PrefixedID) int
		FindLoadBalancerOriginByID   func(childComplexity int, id gidx.PrefixedID) int
		FindLoadBalancerPoolByID     func(childComplexity int, id gidx.PrefixedID) int
		FindLoadBalancerPortByID     func(childComplexity int, id gidx.PrefixedID) int
		FindLoadBalancerProviderByID func(childComplexity int, id gidx.PrefixedID) int
		FindLocationByID             func(childComplexity int, id gidx.PrefixedID) int
		FindResourceOwnerByID        func(childComplexity int, id gidx.PrefixedID) int
	}

	LoadBalancer struct {
		CreatedAt func(childComplexity int) int
		ID        func(childComplexity int) int
		Location  func(childComplexity int) int
		Name      func(childComplexity int) int
		Owner     func(childComplexity int) int
		Ports     func(childComplexity int, after *entgql.Cursor[gidx.PrefixedID], first *int, before *entgql.Cursor[gidx.PrefixedID], last *int, orderBy *generated.LoadBalancerPortOrder, where *generated.LoadBalancerPortWhereInput) int
		Provider  func(childComplexity int) int
		UpdatedAt func(childComplexity int) int
	}

	LoadBalancerConnection struct {
		Edges      func(childComplexity int) int
		PageInfo   func(childComplexity int) int
		TotalCount func(childComplexity int) int
	}

	LoadBalancerCreatePayload struct {
		LoadBalancer func(childComplexity int) int
	}

	LoadBalancerDeletePayload struct {
		DeletedID func(childComplexity int) int
	}

	LoadBalancerEdge struct {
		Cursor func(childComplexity int) int
		Node   func(childComplexity int) int
	}

	LoadBalancerOrigin struct {
		Active     func(childComplexity int) int
		CreatedAt  func(childComplexity int) int
		ID         func(childComplexity int) int
		Name       func(childComplexity int) int
		Pool       func(childComplexity int) int
		PoolID     func(childComplexity int) int
		PortNumber func(childComplexity int) int
		Target     func(childComplexity int) int
		UpdatedAt  func(childComplexity int) int
	}

	LoadBalancerOriginConnection struct {
		Edges      func(childComplexity int) int
		PageInfo   func(childComplexity int) int
		TotalCount func(childComplexity int) int
	}

	LoadBalancerOriginCreatePayload struct {
		LoadBalancerOrigin func(childComplexity int) int
	}

	LoadBalancerOriginDeletePayload struct {
		DeletedID func(childComplexity int) int
	}

	LoadBalancerOriginEdge struct {
		Cursor func(childComplexity int) int
		Node   func(childComplexity int) int
	}

	LoadBalancerOriginUpdatePayload struct {
		LoadBalancerOrigin func(childComplexity int) int
	}

	LoadBalancerPool struct {
		CreatedAt func(childComplexity int) int
		ID        func(childComplexity int) int
		Name      func(childComplexity int) int
		Origins   func(childComplexity int, after *entgql.Cursor[gidx.PrefixedID], first *int, before *entgql.Cursor[gidx.PrefixedID], last *int, orderBy *generated.LoadBalancerOriginOrder, where *generated.LoadBalancerOriginWhereInput) int
		Owner     func(childComplexity int) int
		OwnerID   func(childComplexity int) int
		Ports     func(childComplexity int) int
		Protocol  func(childComplexity int) int
		UpdatedAt func(childComplexity int) int
	}

	LoadBalancerPoolConnection struct {
		Edges      func(childComplexity int) int
		PageInfo   func(childComplexity int) int
		TotalCount func(childComplexity int) int
	}

	LoadBalancerPoolCreatePayload struct {
		LoadBalancerPool func(childComplexity int) int
	}

	LoadBalancerPoolDeletePayload struct {
		DeletedID func(childComplexity int) int
	}

	LoadBalancerPoolEdge struct {
		Cursor func(childComplexity int) int
		Node   func(childComplexity int) int
	}

	LoadBalancerPoolUpdatePayload struct {
		LoadBalancerPool func(childComplexity int) int
	}

	LoadBalancerPort struct {
		CreatedAt      func(childComplexity int) int
		ID             func(childComplexity int) int
		LoadBalancer   func(childComplexity int) int
		LoadBalancerID func(childComplexity int) int
		Name           func(childComplexity int) int
		Number         func(childComplexity int) int
		Pools          func(childComplexity int) int
		UpdatedAt      func(childComplexity int) int
	}

	LoadBalancerPortConnection struct {
		Edges      func(childComplexity int) int
		PageInfo   func(childComplexity int) int
		TotalCount func(childComplexity int) int
	}

	LoadBalancerPortCreatePayload struct {
		LoadBalancerPort func(childComplexity int) int
	}

	LoadBalancerPortDeletePayload struct {
		DeletedID func(childComplexity int) int
	}

	LoadBalancerPortEdge struct {
		Cursor func(childComplexity int) int
		Node   func(childComplexity int) int
	}

	LoadBalancerPortUpdatePayload struct {
		LoadBalancerPort func(childComplexity int) int
	}

	LoadBalancerProvider struct {
		CreatedAt     func(childComplexity int) int
		ID            func(childComplexity int) int
		LoadBalancers func(childComplexity int, after *entgql.Cursor[gidx.PrefixedID], first *int, before *entgql.Cursor[gidx.PrefixedID], last *int, orderBy *generated.LoadBalancerOrder, where *generated.LoadBalancerWhereInput) int
		Name          func(childComplexity int) int
		Owner         func(childComplexity int) int
		UpdatedAt     func(childComplexity int) int
	}

	LoadBalancerProviderConnection struct {
		Edges      func(childComplexity int) int
		PageInfo   func(childComplexity int) int
		TotalCount func(childComplexity int) int
	}

	LoadBalancerProviderCreatePayload struct {
		LoadBalancerProvider func(childComplexity int) int
	}

	LoadBalancerProviderDeletePayload struct {
		DeletedID func(childComplexity int) int
	}

	LoadBalancerProviderEdge struct {
		Cursor func(childComplexity int) int
		Node   func(childComplexity int) int
	}

	LoadBalancerProviderUpdatePayload struct {
		LoadBalancerProvider func(childComplexity int) int
	}

	LoadBalancerUpdatePayload struct {
		LoadBalancer func(childComplexity int) int
	}

	Location struct {
		ID            func(childComplexity int) int
		LoadBalancers func(childComplexity int, after *entgql.Cursor[gidx.PrefixedID], first *int, before *entgql.Cursor[gidx.PrefixedID], last *int, orderBy *generated.LoadBalancerOrder, where *generated.LoadBalancerWhereInput) int
	}

	Mutation struct {
		LoadBalancerCreate         func(childComplexity int, input generated.CreateLoadBalancerInput) int
		LoadBalancerDelete         func(childComplexity int, id gidx.PrefixedID) int
		LoadBalancerOriginCreate   func(childComplexity int, input generated.CreateLoadBalancerOriginInput) int
		LoadBalancerOriginDelete   func(childComplexity int, id gidx.PrefixedID) int
		LoadBalancerOriginUpdate   func(childComplexity int, id gidx.PrefixedID, input generated.UpdateLoadBalancerOriginInput) int
		LoadBalancerPoolCreate     func(childComplexity int, input generated.CreateLoadBalancerPoolInput) int
		LoadBalancerPoolDelete     func(childComplexity int, id gidx.PrefixedID) int
		LoadBalancerPoolUpdate     func(childComplexity int, id gidx.PrefixedID, input generated.UpdateLoadBalancerPoolInput) int
		LoadBalancerPortCreate     func(childComplexity int, input generated.CreateLoadBalancerPortInput) int
		LoadBalancerPortDelete     func(childComplexity int, id gidx.PrefixedID) int
		LoadBalancerPortUpdate     func(childComplexity int, id gidx.PrefixedID, input generated.UpdateLoadBalancerPortInput) int
		LoadBalancerProviderCreate func(childComplexity int, input generated.CreateLoadBalancerProviderInput) int
		LoadBalancerProviderDelete func(childComplexity int, id gidx.PrefixedID) int
		LoadBalancerProviderUpdate func(childComplexity int, id gidx.PrefixedID, input generated.UpdateLoadBalancerProviderInput) int
		LoadBalancerUpdate         func(childComplexity int, id gidx.PrefixedID, input generated.UpdateLoadBalancerInput) int
	}

	PageInfo struct {
		EndCursor       func(childComplexity int) int
		HasNextPage     func(childComplexity int) int
		HasPreviousPage func(childComplexity int) int
		StartCursor     func(childComplexity int) int
	}

	Query struct {
		LoadBalancer         func(childComplexity int, id gidx.PrefixedID) int
		LoadBalancerPool     func(childComplexity int, id gidx.PrefixedID) int
		LoadBalancerPools    func(childComplexity int, after *entgql.Cursor[gidx.PrefixedID], first *int, before *entgql.Cursor[gidx.PrefixedID], last *int, orderBy *generated.LoadBalancerPoolOrder, where *generated.LoadBalancerPoolWhereInput) int
		LoadBalancerProvider func(childComplexity int, id gidx.PrefixedID) int
		// contains filtered or unexported fields
	}

	ResourceOwner struct {
		ID                     func(childComplexity int) int
		LoadBalancerPools      func(childComplexity int, after *entgql.Cursor[gidx.PrefixedID], first *int, before *entgql.Cursor[gidx.PrefixedID], last *int, orderBy *generated.LoadBalancerPoolOrder, where *generated.LoadBalancerPoolWhereInput) int
		LoadBalancers          func(childComplexity int, after *entgql.Cursor[gidx.PrefixedID], first *int, before *entgql.Cursor[gidx.PrefixedID], last *int, orderBy *generated.LoadBalancerOrder, where *generated.LoadBalancerWhereInput) int
		LoadBalancersProviders func(childComplexity int, after *entgql.Cursor[gidx.PrefixedID], first *int, before *entgql.Cursor[gidx.PrefixedID], last *int, orderBy *generated.LoadBalancerOrder, where *generated.LoadBalancerProviderWhereInput) int
	}
	// contains filtered or unexported fields
}

type Config

type Config struct {
	Resolvers  ResolverRoot
	Directives DirectiveRoot
	Complexity ComplexityRoot
}

type DirectiveRoot

type DirectiveRoot struct {
	ComposeDirective func(ctx context.Context, obj interface{}, next graphql.Resolver, name string) (res interface{}, err error)
}

type EntityResolver

type EntityResolver interface {
	FindLoadBalancerByID(ctx context.Context, id gidx.PrefixedID) (*generated.LoadBalancer, error)
	FindLoadBalancerOriginByID(ctx context.Context, id gidx.PrefixedID) (*generated.Origin, error)
	FindLoadBalancerPoolByID(ctx context.Context, id gidx.PrefixedID) (*generated.Pool, error)
	FindLoadBalancerPortByID(ctx context.Context, id gidx.PrefixedID) (*generated.Port, error)
	FindLoadBalancerProviderByID(ctx context.Context, id gidx.PrefixedID) (*generated.Provider, error)
	FindLocationByID(ctx context.Context, id gidx.PrefixedID) (*Location, error)
	FindResourceOwnerByID(ctx context.Context, id gidx.PrefixedID) (*ResourceOwner, error)
}

type Handler

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

Handler is an http handler wrapping a Resolver

func (*Handler) Handler

func (h *Handler) Handler() http.HandlerFunc

Handler returns the http.HandlerFunc for the GraphAPI

func (*Handler) Routes

func (h *Handler) Routes(e *echo.Group)

Routes ...

type LoadBalancerCreatePayload

type LoadBalancerCreatePayload struct {
	// The created load balancer.
	LoadBalancer *generated.LoadBalancer `json:"loadBalancer"`
}

Return response from loadBalancerCreate

type LoadBalancerDeletePayload

type LoadBalancerDeletePayload struct {
	// The ID of the deleted load balancer.
	DeletedID gidx.PrefixedID `json:"deletedID"`
}

Return response from loadBalancerDelete

type LoadBalancerOriginCreatePayload

type LoadBalancerOriginCreatePayload struct {
	// The created pool origin.
	LoadBalancerOrigin *generated.Origin `json:"loadBalancerOrigin"`
}

Return response from loadBalancerOriginCreate

type LoadBalancerOriginDeletePayload

type LoadBalancerOriginDeletePayload struct {
	// The deleted pool origin.
	DeletedID gidx.PrefixedID `json:"deletedID"`
}

Return response from loadBalancerOriginDelete

type LoadBalancerOriginUpdatePayload

type LoadBalancerOriginUpdatePayload struct {
	// The updated pool origin.
	LoadBalancerOrigin *generated.Origin `json:"loadBalancerOrigin"`
}

Return response from loadBalancerOriginUpdate

type LoadBalancerPoolCreatePayload

type LoadBalancerPoolCreatePayload struct {
	// The created pool.
	LoadBalancerPool *generated.Pool `json:"loadBalancerPool"`
}

Return response from LoadBalancerPoolCreate

type LoadBalancerPoolDeletePayload

type LoadBalancerPoolDeletePayload struct {
	// The ID of the deleted pool.
	DeletedID *gidx.PrefixedID `json:"deletedID,omitempty"`
}

Return response from LoadBalancerPoolDelete

type LoadBalancerPoolResolver

type LoadBalancerPoolResolver interface {
	Owner(ctx context.Context, obj *generated.Pool) (*ResourceOwner, error)
}

type LoadBalancerPoolUpdatePayload

type LoadBalancerPoolUpdatePayload struct {
	// The updated pool.
	LoadBalancerPool *generated.Pool `json:"loadBalancerPool"`
}

Return response from LoadBalancerPoolUpdate

type LoadBalancerPortCreatePayload

type LoadBalancerPortCreatePayload struct {
	// The created load balancer port.
	LoadBalancerPort *generated.Port `json:"loadBalancerPort"`
}

Return response from loadBalancerPortCreate

type LoadBalancerPortDeletePayload

type LoadBalancerPortDeletePayload struct {
	// The ID of the deleted load balancer port.
	DeletedID gidx.PrefixedID `json:"deletedID"`
}

Return response from loadBalancerPortDelete

type LoadBalancerPortUpdatePayload

type LoadBalancerPortUpdatePayload struct {
	// The updated load balancer port.
	LoadBalancerPort *generated.Port `json:"loadBalancerPort"`
}

Return response from loadBalancerPortUpdate

type LoadBalancerProviderCreatePayload

type LoadBalancerProviderCreatePayload struct {
	// The created load balancer provider.
	LoadBalancerProvider *generated.Provider `json:"loadBalancerProvider"`
}

Return response from loadBalancerProviderCreate

type LoadBalancerProviderDeletePayload

type LoadBalancerProviderDeletePayload struct {
	// The ID of the deleted load balancer provider.
	DeletedID gidx.PrefixedID `json:"deletedID"`
}

Return response from loadBalancerProviderDelete

type LoadBalancerProviderResolver

type LoadBalancerProviderResolver interface {
	Owner(ctx context.Context, obj *generated.Provider) (*ResourceOwner, error)
}

type LoadBalancerProviderUpdatePayload

type LoadBalancerProviderUpdatePayload struct {
	// The updated load balancer provider.
	LoadBalancerProvider *generated.Provider `json:"loadBalancerProvider"`
}

Return response from loadBalancerProviderUpdate

type LoadBalancerResolver

type LoadBalancerResolver interface {
	Location(ctx context.Context, obj *generated.LoadBalancer) (*Location, error)
	Owner(ctx context.Context, obj *generated.LoadBalancer) (*ResourceOwner, error)
}

type LoadBalancerUpdatePayload

type LoadBalancerUpdatePayload struct {
	// The updated load balancer.
	LoadBalancer *generated.LoadBalancer `json:"loadBalancer"`
}

Return response from loadBalancerUpdate

type Location

type Location struct {
	ID            gidx.PrefixedID                   `json:"id"`
	LoadBalancers *generated.LoadBalancerConnection `json:"loadBalancers"`
	// contains filtered or unexported fields
}

Location represents a Location in the graph for the bits load-balancer-api is able to return

func (Location) IsEntity

func (Location) IsEntity()

IsEntity ensures the entity interface is met

type LocationResolver

type LocationResolver interface {
	LoadBalancers(ctx context.Context, obj *Location, after *entgql.Cursor[gidx.PrefixedID], first *int, before *entgql.Cursor[gidx.PrefixedID], last *int, orderBy *generated.LoadBalancerOrder, where *generated.LoadBalancerWhereInput) (*generated.LoadBalancerConnection, error)
}

type MutationResolver

type MutationResolver interface {
	LoadBalancerOriginCreate(ctx context.Context, input generated.CreateLoadBalancerOriginInput) (*LoadBalancerOriginCreatePayload, error)
	LoadBalancerOriginUpdate(ctx context.Context, id gidx.PrefixedID, input generated.UpdateLoadBalancerOriginInput) (*LoadBalancerOriginUpdatePayload, error)
	LoadBalancerOriginDelete(ctx context.Context, id gidx.PrefixedID) (*LoadBalancerOriginDeletePayload, error)
	LoadBalancerCreate(ctx context.Context, input generated.CreateLoadBalancerInput) (*LoadBalancerCreatePayload, error)
	LoadBalancerUpdate(ctx context.Context, id gidx.PrefixedID, input generated.UpdateLoadBalancerInput) (*LoadBalancerUpdatePayload, error)
	LoadBalancerDelete(ctx context.Context, id gidx.PrefixedID) (*LoadBalancerDeletePayload, error)
	LoadBalancerPoolCreate(ctx context.Context, input generated.CreateLoadBalancerPoolInput) (*LoadBalancerPoolCreatePayload, error)
	LoadBalancerPoolUpdate(ctx context.Context, id gidx.PrefixedID, input generated.UpdateLoadBalancerPoolInput) (*LoadBalancerPoolUpdatePayload, error)
	LoadBalancerPoolDelete(ctx context.Context, id gidx.PrefixedID) (*LoadBalancerPoolDeletePayload, error)
	LoadBalancerPortCreate(ctx context.Context, input generated.CreateLoadBalancerPortInput) (*LoadBalancerPortCreatePayload, error)
	LoadBalancerPortUpdate(ctx context.Context, id gidx.PrefixedID, input generated.UpdateLoadBalancerPortInput) (*LoadBalancerPortUpdatePayload, error)
	LoadBalancerPortDelete(ctx context.Context, id gidx.PrefixedID) (*LoadBalancerPortDeletePayload, error)
	LoadBalancerProviderCreate(ctx context.Context, input generated.CreateLoadBalancerProviderInput) (*LoadBalancerProviderCreatePayload, error)
	LoadBalancerProviderUpdate(ctx context.Context, id gidx.PrefixedID, input generated.UpdateLoadBalancerProviderInput) (*LoadBalancerProviderUpdatePayload, error)
	LoadBalancerProviderDelete(ctx context.Context, id gidx.PrefixedID) (*LoadBalancerProviderDeletePayload, error)
}

type Owner added in v0.0.18

type Owner struct {
	ID                gidx.PrefixedID                       `json:"id"`
	LoadBalancers     *generated.LoadBalancerConnection     `json:"loadBalancers"`
	LoadBalancerPools *generated.LoadBalancerPoolConnection `json:"loadBalancerPools"`
}

Owner represents a Location in the graph for the bits load-balancer-api is able to return

func (Owner) IsEntity added in v0.0.18

func (Owner) IsEntity()

IsEntity ensures the entity interface is met

type QueryResolver

type QueryResolver interface {
	LoadBalancerPools(ctx context.Context, after *entgql.Cursor[gidx.PrefixedID], first *int, before *entgql.Cursor[gidx.PrefixedID], last *int, orderBy *generated.LoadBalancerPoolOrder, where *generated.LoadBalancerPoolWhereInput) (*generated.LoadBalancerPoolConnection, error)
	LoadBalancer(ctx context.Context, id gidx.PrefixedID) (*generated.LoadBalancer, error)
	LoadBalancerPool(ctx context.Context, id gidx.PrefixedID) (*generated.Pool, error)
	LoadBalancerProvider(ctx context.Context, id gidx.PrefixedID) (*generated.Provider, error)
}

type Resolver

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

Resolver provides a graph response resolver

func NewResolver

func NewResolver(client *ent.Client, logger *zap.SugaredLogger) *Resolver

NewResolver returns a resolver configured with the given ent client

func (*Resolver) Entity

func (r *Resolver) Entity() EntityResolver

Entity returns EntityResolver implementation.

func (*Resolver) Handler

func (r *Resolver) Handler(withPlayground bool, middleware ...echo.MiddlewareFunc) *Handler

Handler returns an http handler for a graph resolver

func (*Resolver) LoadBalancer

func (r *Resolver) LoadBalancer() LoadBalancerResolver

LoadBalancer returns LoadBalancerResolver implementation.

func (*Resolver) LoadBalancerPool

func (r *Resolver) LoadBalancerPool() LoadBalancerPoolResolver

LoadBalancerPool returns LoadBalancerPoolResolver implementation.

func (*Resolver) LoadBalancerProvider

func (r *Resolver) LoadBalancerProvider() LoadBalancerProviderResolver

LoadBalancerProvider returns LoadBalancerProviderResolver implementation.

func (*Resolver) Location

func (r *Resolver) Location() LocationResolver

Location returns LocationResolver implementation.

func (*Resolver) Mutation

func (r *Resolver) Mutation() MutationResolver

Mutation returns MutationResolver implementation.

func (*Resolver) Query

func (r *Resolver) Query() QueryResolver

Query returns QueryResolver implementation.

func (*Resolver) ResourceOwner added in v0.0.20

func (r *Resolver) ResourceOwner() ResourceOwnerResolver

ResourceOwner returns ResourceOwnerResolver implementation.

type ResolverRoot

type ResolverRoot interface {
	Entity() EntityResolver
	LoadBalancer() LoadBalancerResolver
	LoadBalancerPool() LoadBalancerPoolResolver
	LoadBalancerProvider() LoadBalancerProviderResolver
	Location() LocationResolver
	Mutation() MutationResolver
	Query() QueryResolver
	ResourceOwner() ResourceOwnerResolver
}

type ResourceOwner added in v0.0.20

type ResourceOwner struct {
	ID                     gidx.PrefixedID                           `json:"id"`
	LoadBalancers          *generated.LoadBalancerConnection         `json:"loadBalancers"`
	LoadBalancerPools      *generated.LoadBalancerPoolConnection     `json:"loadBalancerPools"`
	LoadBalancersProviders *generated.LoadBalancerProviderConnection `json:"loadBalancersProviders"`
}

func (ResourceOwner) IsEntity added in v0.0.20

func (ResourceOwner) IsEntity()

Jump to

Keyboard shortcuts

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