graphapi

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Feb 1, 2024 License: Apache-2.0 Imports: 25 Imported by: 0

Documentation

Overview

Package graphapi provides the graph api handler and resolver for ipam api

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrUnknownType  = errors.New("unknown type")
	ErrTypeNotFound = errors.New("type not found")
)

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 {
		FindIPAddressByID     func(childComplexity int, id gidx.PrefixedID) int
		FindIPAddressableByID func(childComplexity int, id gidx.PrefixedID) int
		FindIPBlockByID       func(childComplexity int, id gidx.PrefixedID) int
		FindIPBlockTypeByID   func(childComplexity int, id gidx.PrefixedID) int
		FindResourceOwnerByID func(childComplexity int, id gidx.PrefixedID) int
	}

	IPAddress struct {
		CreatedAt func(childComplexity int) int
		ID        func(childComplexity int) int
		IP        func(childComplexity int) int
		IPBlock   func(childComplexity int) int
		Node      func(childComplexity int) int
		Reserved  func(childComplexity int) int
		UpdatedAt func(childComplexity int) int
	}

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

	IPAddressCreatePayload struct {
		IPAddress func(childComplexity int) int
	}

	IPAddressDeletePayload struct {
		DeletedID func(childComplexity int) int
	}

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

	IPAddressUpdatePayload struct {
		IPAddress func(childComplexity int) int
	}

	IPAddressable struct {
		ID          func(childComplexity int) int
		IPAddresses func(childComplexity int) int
	}

	IPBlock struct {
		AllowAutoAllocate func(childComplexity int) int
		AllowAutoSubnet   func(childComplexity int) int
		CreatedAt         func(childComplexity int) int
		ID                func(childComplexity int) int
		IPAddress         func(childComplexity int, after *entgql.Cursor[gidx.PrefixedID], first *int, before *entgql.Cursor[gidx.PrefixedID], last *int, orderBy *generated.IPAddressOrder, where *generated.IPAddressWhereInput) int
		IPBlockType       func(childComplexity int) int
		Prefix            func(childComplexity int) int
		UpdatedAt         func(childComplexity int) int
	}

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

	IPBlockCreatePayload struct {
		IPBlock func(childComplexity int) int
	}

	IPBlockDeletePayload struct {
		DeletedID func(childComplexity int) int
	}

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

	IPBlockType struct {
		CreatedAt func(childComplexity int) int
		ID        func(childComplexity int) int
		IPBlock   func(childComplexity int, after *entgql.Cursor[gidx.PrefixedID], first *int, before *entgql.Cursor[gidx.PrefixedID], last *int, orderBy *generated.IPBlockOrder, where *generated.IPBlockWhereInput) int
		Name      func(childComplexity int) int
		Owner     func(childComplexity int) int
		UpdatedAt func(childComplexity int) int
	}

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

	IPBlockTypeCreatePayload struct {
		IPBlockType func(childComplexity int) int
	}

	IPBlockTypeDeletePayload struct {
		DeletedID func(childComplexity int) int
	}

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

	IPBlockTypeUpdatePayload struct {
		IPBlockType func(childComplexity int) int
	}

	IPBlockUpdatePayload struct {
		IPBlock func(childComplexity int) int
	}

	Mutation struct {
		CreateIPAddress   func(childComplexity int, input generated.CreateIPAddressInput) int
		CreateIPBlock     func(childComplexity int, input generated.CreateIPBlockInput) int
		CreateIPBlockType func(childComplexity int, input generated.CreateIPBlockTypeInput) int
		DeleteIPAddress   func(childComplexity int, id gidx.PrefixedID) int
		DeleteIPBlock     func(childComplexity int, id gidx.PrefixedID) int
		DeleteIPBlockType func(childComplexity int, id gidx.PrefixedID) int
		UpdateIPAddress   func(childComplexity int, id gidx.PrefixedID, input generated.UpdateIPAddressInput) int
		UpdateIPBlock     func(childComplexity int, id gidx.PrefixedID, input generated.UpdateIPBlockInput) int
		UpdateIPBlockType func(childComplexity int, id gidx.PrefixedID, input generated.UpdateIPBlockTypeInput) 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 {
		IPAddress   func(childComplexity int, id gidx.PrefixedID) int
		IPBlock     func(childComplexity int, id gidx.PrefixedID) int
		IPBlockType func(childComplexity int, id gidx.PrefixedID) int
		// contains filtered or unexported fields
	}

	ResourceOwner struct {
		ID          func(childComplexity int) int
		IPBlockType func(childComplexity int, after *entgql.Cursor[gidx.PrefixedID], first *int, before *entgql.Cursor[gidx.PrefixedID], last *int, orderBy *generated.IPBlockTypeOrder, where *generated.IPBlockTypeWhereInput) 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 {
	FindIPAddressByID(ctx context.Context, id gidx.PrefixedID) (*generated.IPAddress, error)
	FindIPAddressableByID(ctx context.Context, id gidx.PrefixedID) (*IPAddressable, error)
	FindIPBlockByID(ctx context.Context, id gidx.PrefixedID) (*generated.IPBlock, error)
	FindIPBlockTypeByID(ctx context.Context, id gidx.PrefixedID) (*generated.IPBlockType, 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 IPAddressCreatePayload

type IPAddressCreatePayload struct {
	// Created ip address
	IPAddress *generated.IPAddress `json:"ipAddress"`
}

Return response for createIPAddress mutation

type IPAddressDeletePayload

type IPAddressDeletePayload struct {
	// Deleted ip address ID
	DeletedID gidx.PrefixedID `json:"deletedID"`
}

Return response for deleteIPAddress mutation

type IPAddressResolver

type IPAddressResolver interface {
	Node(ctx context.Context, obj *generated.IPAddress) (*IPAddressable, error)
}

type IPAddressUpdatePayload

type IPAddressUpdatePayload struct {
	// Updated ip address
	IPAddress *generated.IPAddress `json:"ipAddress"`
}

Return response for updateIPAddress mutation

type IPAddressable

type IPAddressable struct {
	ID gidx.PrefixedID `json:"id"`
	// IPAddressable describes IP addresses attached to a node
	IPAddresses []*generated.IPAddress `json:"IPAddresses"`
}

IPAddressable provides an interface for describing IP addresses attached to a node

func (IPAddressable) IsEntity

func (IPAddressable) IsEntity()

type IPAddressableResolver

type IPAddressableResolver interface {
	IPAddresses(ctx context.Context, obj *IPAddressable) ([]*generated.IPAddress, error)
}

type IPBlockCreatePayload

type IPBlockCreatePayload struct {
	// Created ip block
	IPBlock *generated.IPBlock `json:"ipBlock"`
}

Return response for createIPBlock mutation

type IPBlockDeletePayload

type IPBlockDeletePayload struct {
	// Deleted ip block
	DeletedID gidx.PrefixedID `json:"deletedID"`
}

Return response for deleteIPBlock mutation

type IPBlockTypeCreatePayload

type IPBlockTypeCreatePayload struct {
	// Created ip block type
	IPBlockType *generated.IPBlockType `json:"ipBlockType"`
}

Return response for createIPBlockType mutation

type IPBlockTypeDeletePayload

type IPBlockTypeDeletePayload struct {
	// Deleted ip block type
	DeletedID gidx.PrefixedID `json:"deletedID"`
}

Return response for deleteIPBlockType mutation

type IPBlockTypeResolver

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

type IPBlockTypeUpdatePayload

type IPBlockTypeUpdatePayload struct {
	// Updated ip block type
	IPBlockType *generated.IPBlockType `json:"ipBlockType"`
}

Return response for updateIPBlockType mutation

type IPBlockUpdatePayload

type IPBlockUpdatePayload struct {
	// Updated ip block
	IPBlock *generated.IPBlock `json:"ipBlock"`
}

Return response for updateIPBlock mutation

type QueryResolver

type QueryResolver interface {
	IPAddress(ctx context.Context, id gidx.PrefixedID) (*generated.IPAddress, error)
	IPBlock(ctx context.Context, id gidx.PrefixedID) (*generated.IPBlock, error)
	IPBlockType(ctx context.Context, id gidx.PrefixedID) (*generated.IPBlockType, 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) IPAddress

func (r *Resolver) IPAddress() IPAddressResolver

IPAddress returns IPAddressResolver implementation.

func (*Resolver) IPAddressable

func (r *Resolver) IPAddressable() IPAddressableResolver

IPAddressable returns IPAddressableResolver implementation.

func (*Resolver) IPBlockType

func (r *Resolver) IPBlockType() IPBlockTypeResolver

IPBlockType returns IPBlockTypeResolver 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.3

func (r *Resolver) ResourceOwner() ResourceOwnerResolver

ResourceOwner returns ResourceOwnerResolver implementation.

type ResolverRoot

type ResolverRoot interface {
	Entity() EntityResolver
	IPAddress() IPAddressResolver
	IPAddressable() IPAddressableResolver
	IPBlockType() IPBlockTypeResolver
	Mutation() MutationResolver
	Query() QueryResolver
	ResourceOwner() ResourceOwnerResolver
}

type ResourceOwner added in v0.0.3

type ResourceOwner struct {
	ID          gidx.PrefixedID                  `json:"id"`
	IPBlockType *generated.IPBlockTypeConnection `json:"ipBlockType"`
}

func (ResourceOwner) IsEntity added in v0.0.3

func (ResourceOwner) IsEntity()

type ResourceOwnerResolver added in v0.0.3

type ResourceOwnerResolver interface {
	IPBlockType(ctx context.Context, obj *ResourceOwner, after *entgql.Cursor[gidx.PrefixedID], first *int, before *entgql.Cursor[gidx.PrefixedID], last *int, orderBy *generated.IPBlockTypeOrder, where *generated.IPBlockTypeWhereInput) (*generated.IPBlockTypeConnection, error)
}

Jump to

Keyboard shortcuts

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