gql

package
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Feb 13, 2019 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func MarshalMachineState

func MarshalMachineState(state sabakan.MachineState) graphql.Marshaler

MarshalMachineState helps mapping sabakan.MachineState with GraphQL enum.

func NewExecutableSchema

func NewExecutableSchema(cfg Config) graphql.ExecutableSchema

NewExecutableSchema creates an ExecutableSchema from the ResolverRoot interface.

func UnmarshalMachineState

func UnmarshalMachineState(v interface{}) (sabakan.MachineState, error)

UnmarshalMachineState helps mapping sabakan.MachineState with GraphQL enum.

Types

type BMCResolver

type BMCResolver interface {
	BmcType(ctx context.Context, obj *sabakan.MachineBMC) (string, error)
	Ipv4(ctx context.Context, obj *sabakan.MachineBMC) (IPAddress, error)
}

type ComplexityRoot

type ComplexityRoot struct {
	Bmc struct {
		BmcType func(childComplexity int) int
		Ipv4    func(childComplexity int) int
	}

	Bmcinfo struct {
		Ipv4 func(childComplexity int) int
	}

	Label struct {
		Name  func(childComplexity int) int
		Value func(childComplexity int) int
	}

	Machine struct {
		Spec   func(childComplexity int) int
		Status func(childComplexity int) int
		Info   func(childComplexity int) int
	}

	MachineInfo struct {
		Network func(childComplexity int) int
		Bmc     func(childComplexity int) int
	}

	MachineSpec struct {
		Serial       func(childComplexity int) int
		Labels       func(childComplexity int) int
		Rack         func(childComplexity int) int
		IndexInRack  func(childComplexity int) int
		Role         func(childComplexity int) int
		Ipv4         func(childComplexity int) int
		RegisterDate func(childComplexity int) int
		RetireDate   func(childComplexity int) int
		Bmc          func(childComplexity int) int
	}

	MachineStatus struct {
		State     func(childComplexity int) int
		Timestamp func(childComplexity int) int
		Duration  func(childComplexity int) int
	}

	Nicconfig struct {
		Address  func(childComplexity int) int
		Netmask  func(childComplexity int) int
		Maskbits func(childComplexity int) int
		Gateway  func(childComplexity int) int
	}

	NetworkInfo struct {
		Ipv4 func(childComplexity int) int
	}

	Query struct {
		Machine        func(childComplexity int, serial string) int
		SearchMachines func(childComplexity int, having *MachineParams, notHaving *MachineParams) int
	}
}

type Config

type Config struct {
	Resolvers  ResolverRoot
	Directives DirectiveRoot
	Complexity ComplexityRoot
}

type DateTime

type DateTime time.Time

DateTime represents "DateTime" GraphQL custom scalar.

func (DateTime) MarshalGQL

func (dt DateTime) MarshalGQL(w io.Writer)

MarshalGQL implements graphql.Marshaler interface.

func (*DateTime) UnmarshalGQL

func (dt *DateTime) UnmarshalGQL(v interface{}) error

UnmarshalGQL implements graphql.Marshaler interface.

type DirectiveRoot

type DirectiveRoot struct {
}

type IPAddress

type IPAddress net.IP

IPAddress represents "IPAddress" GraphQL custom scalar.

func (IPAddress) MarshalGQL

func (a IPAddress) MarshalGQL(w io.Writer)

MarshalGQL implements graphql.Marshaler interface.

func (*IPAddress) UnmarshalGQL

func (a *IPAddress) UnmarshalGQL(v interface{}) error

UnmarshalGQL implements graphql.Marshaler interface.

type Label

type Label struct {
	Name  string `json:"name"`
	Value string `json:"value"`
}

Label represents an arbitrary key-value pairs.

type LabelInput

type LabelInput struct {
	Name  string `json:"name"`
	Value string `json:"value"`
}

LabelInput represents a label to search machines.

func UnmarshalLabelInput

func UnmarshalLabelInput(v interface{}) (LabelInput, error)

type MachineParams

type MachineParams struct {
	Labels              []LabelInput           `json:"labels"`
	Racks               []int                  `json:"racks"`
	Roles               []string               `json:"roles"`
	States              []sabakan.MachineState `json:"states"`
	MinDaysBeforeRetire *int                   `json:"minDaysBeforeRetire"`
}

MachineParams is a set of input parameters to search machines.

func UnmarshalMachineParams

func UnmarshalMachineParams(v interface{}) (MachineParams, error)

type MachineSpecResolver

type MachineSpecResolver interface {
	Labels(ctx context.Context, obj *sabakan.MachineSpec) ([]Label, error)
	Rack(ctx context.Context, obj *sabakan.MachineSpec) (int, error)
	IndexInRack(ctx context.Context, obj *sabakan.MachineSpec) (int, error)

	Ipv4(ctx context.Context, obj *sabakan.MachineSpec) ([]IPAddress, error)
	RegisterDate(ctx context.Context, obj *sabakan.MachineSpec) (DateTime, error)
	RetireDate(ctx context.Context, obj *sabakan.MachineSpec) (DateTime, error)
}

type MachineStatusResolver

type MachineStatusResolver interface {
	Timestamp(ctx context.Context, obj *sabakan.MachineStatus) (DateTime, error)
}

type NICConfigResolver added in v1.2.0

type NICConfigResolver interface {
	Address(ctx context.Context, obj *sabakan.NICConfig) (IPAddress, error)
	Netmask(ctx context.Context, obj *sabakan.NICConfig) (IPAddress, error)

	Gateway(ctx context.Context, obj *sabakan.NICConfig) (IPAddress, error)
}

type QueryResolver

type QueryResolver interface {
	Machine(ctx context.Context, serial string) (sabakan.Machine, error)
	SearchMachines(ctx context.Context, having *MachineParams, notHaving *MachineParams) ([]sabakan.Machine, error)
}

type Resolver

type Resolver struct {
	Model sabakan.Model
}

Resolver implements ResolverRoot.

func (*Resolver) BMC

func (r *Resolver) BMC() BMCResolver

BMC implements ResolverRoot.

func (*Resolver) MachineSpec

func (r *Resolver) MachineSpec() MachineSpecResolver

MachineSpec implements ResolverRoot.

func (*Resolver) MachineStatus

func (r *Resolver) MachineStatus() MachineStatusResolver

MachineStatus implements ResolverRoot.

func (*Resolver) NICConfig added in v1.2.0

func (r *Resolver) NICConfig() NICConfigResolver

NICConfig implements ResolverRoot.

func (*Resolver) Query

func (r *Resolver) Query() QueryResolver

Query implements ResolverRoot.

type ResolverRoot

type ResolverRoot interface {
	BMC() BMCResolver
	MachineSpec() MachineSpecResolver
	MachineStatus() MachineStatusResolver
	NICConfig() NICConfigResolver
	Query() QueryResolver
}

Jump to

Keyboard shortcuts

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