client

package
v0.0.0-...-2b6d021 Latest Latest
Warning

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

Go to latest
Published: Sep 7, 2023 License: MPL-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ResourcesCreateEndpoint = "create"
)

Variables

View Source
var (
	// ErrRequestFailed is returned in the instance a
	// http request does not return a 200
	ErrRequestFailed = errors.New("failed request not successful")

	// ErrNotFound is returned in the instance a
	// http request returns a 404
	ErrNotFound = errors.New("resource not found")
)

Functions

func NewInsecureGrpcConn

func NewInsecureGrpcConn(ctx context.Context) (*grpc.ClientConn, error)

func NewSecureGrpcConnection

func NewSecureGrpcConnection(ctx context.Context) (*grpc.ClientConn, error)

Types

type Client

type Client struct {
	HTTP    *http.Client
	APIHost string
	Token   string
}

Client implements a api client

func NewClient

func NewClient() *Client

NewClient returns a new client for access the ai-platform API client

func NewClientWithToken

func NewClientWithToken() (*Client, error)

NewClientWithToken returns a new client for access the ai-platform API client and reads the JWT token from settings

func (*Client) CreateResource

func (c *Client) CreateResource(p plan.Definition) (plan.Definition, error)

func (*Client) Do

func (c *Client) Do(req *http.Request) (*http.Response, error)

Do executes and parses an HTTP request

func (*Client) ParseResponseBody

func (c *Client) ParseResponseBody(resp *http.Response) ([]byte, error)

ParseResponseBody takes an http response and turns the body to a *[]byte pointer

func (*Client) Request

func (c *Client) Request(method string, url string, data io.Reader) (*http.Request, error)

Request builds a request to execute, this will also add the JWT token if one is set up in the client.

Strong Argument: that this should return and error an never make a request IF there is no token set? I'm open

func (*Client) Status

func (c *Client) Status() ([]byte, error)

Status fetches and returns the raw json status payload from the API server. The stauts is a simple healthcheck primarily used for healthcheck and availability of the API, but tells us nothing about working functionality or connections to dbs

type Error

type Error struct {
	Message string

	Info []string
}

Error is the structure of a API error response

Jump to

Keyboard shortcuts

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