client

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Jun 18, 2024 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Overview

Package client provides a client for the API.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type APIv1

type APIv1 struct {
	// Config is the configuration for the APIv1 client
	Config Config
	// HTTPSlingClient is the HTTP client for the APIv1 client
	HTTPSlingClient *httpsling.Client
}

APIv1 implements the Client interface and provides methods to interact with the Datum Cloud API

func (*APIv1) WorkspaceCreate

func (c *APIv1) WorkspaceCreate(ctx context.Context, in *models.WorkspaceRequest) (out *models.WorkspaceReply, err error)

WorkspaceCreate creates an organizational hierarchy for a new workspace based on the name, environment(s), bucket(s), and relationship(s) provided in the request

type Client

type Client interface {
	// WorkspaceCreate creates an organizational hierarchy for a workspace
	WorkspaceCreate(context.Context, *models.WorkspaceRequest) (*models.WorkspaceReply, error)
}

Client is the interface that wraps the DatumCloud API REST client methods

func New

func New(config Config, opts ...ClientOption) (_ Client, err error)

New creates a new API v1 client that implements the Client interface

func NewWithDefaults

func NewWithDefaults() (Client, error)

NewWithDefaults creates a new API v1 client with default configuration

type ClientOption

type ClientOption func(c *APIv1) error

ClientOption allows us to configure the APIv1 client when it is created

func WithBaseURL

func WithBaseURL(baseURL *url.URL) ClientOption

WithBaseURL sets the base URL for the APIv1 client

type Config

type Config struct {
	// BaseURL is the base URL for the Datum API
	BaseURL *url.URL `json:"baseUrl" yaml:"base_url" default:"http://localhost:17610"`
	// HTTPSling is the configuration for the HTTPSling client
	HTTPSling *httpsling.Config
}

Config is the configuration for the Datum Cloud API client

func NewDefaultConfig

func NewDefaultConfig() Config

NewDefaultConfig returns a new default configuration for the Datum Cloud API client

type RequestError

type RequestError struct {
	// StatusCode is the http response code that was returned
	StatusCode int
	// Body of the response
	Body string
}

RequestError is a generic error when a request with the client fails

func (*RequestError) Error

func (e *RequestError) Error() string

Error returns the RequestError in string format

Jump to

Keyboard shortcuts

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