client

package
v0.0.4 Latest Latest
Warning

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

Go to latest
Published: Jan 17, 2024 License: Apache-2.0 Imports: 7 Imported by: 3

Documentation

Overview

Package client provides a client for interacting with the metadata-api service

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrUnauthorized returned when the request is not authorized
	ErrUnauthorized = errors.New("client is unauthorized")

	// ErrPermissionDenied returned when the request is not authorized
	ErrPermissionDenied = errors.New("client does not have permission to perform this action")
)

Functions

This section is empty.

Types

type Client

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

Client is a client for the metadata api

func New

func New(url string, opts ...Option) *Client

New creates a new metadata api client

func (*Client) StatusUpdate

func (c *Client) StatusUpdate(ctx context.Context, input *StatusUpdateInput) (*StatusUpdate, error)

StatusUpdate mutates the requested nodeID with json status

type ErrInvalidID

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

ErrInvaliID returned when an invalid id is provided

func (*ErrInvalidID) Error

func (e *ErrInvalidID) Error() string

Error implements the error interface.

type GQLClient

type GQLClient interface {
	Query(tx context.Context, q interface{}, variables map[string]interface{}, options ...graphql.Option) error
	Mutate(ctx context.Context, m interface{}, variables map[string]interface{}, options ...graphql.Option) error
}

GQLClient is an interface for a graphql client

type Option

type Option func(*Client)

Option is a function that modifies a client

func WithHTTPClient

func WithHTTPClient(cli *http.Client) Option

WithHTTPClient functional option to set the http client

type StatusUpdate

type StatusUpdate struct {
	StatusUpdate StatusUpdateResponse `graphql:"statusUpdate(input: $input)"`
}

StatusUpdate is the statusUpdate mutation

type StatusUpdateInput

type StatusUpdateInput struct {
	// The node ID for this status.
	NodeID string `graphql:"nodeID" json:"nodeID"`
	// The namespace ID for this status.
	NamespaceID string `graphql:"namespaceID" json:"namespaceID"`
	// The source for this status.
	Source string `graphql:"source" json:"source"`
	// The data to save in this status.
	Data json.RawMessage `graphql:"data" json:"data"`
}

StatusUpdateInput is the input for the statusUpdate mutation

type StatusUpdateResponse

type StatusUpdateResponse struct {
	Status struct {
		ID                string          `graphql:"id"`
		Data              json.RawMessage `graphql:"data"`
		Source            string          `graphql:"source"`
		StatusNamespaceID string          `graphql:"statusNamespaceID"`

		Metadata struct {
			ID     string `graphql:"id"`
			NodeID string `graphql:"nodeID"`
		} `graphql:"metadata"`
	} `graphql:"status"`
}

StatusUpdateResponse is the response for the statusUpdate mutation

Directories

Path Synopsis
Package mockmetadata Simplifying testing metadata node status updates in applications.
Package mockmetadata Simplifying testing metadata node status updates in applications.

Jump to

Keyboard shortcuts

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