up

package module
v1.8.0 Latest Latest
Warning

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

Go to latest
Published: Sep 25, 2024 License: Apache-2.0 Imports: 10 Imported by: 3

README

Upbound Go SDK

up-sdk-go is the official Go SDK for Upbound. It is currently under active development and subject to breaking changes.

Supported Services

The following services are currently supported:

  • Accounts
  • Configurations
  • Control Planes
  • Organizations
  • Repositories
  • Robots
  • Tokens

Authentication

up-sdk-go currently defers authentication to the consumer by passing a configured http.Client. The _examples directory contains examples of how this can be accomplished with a cookiejar implementation and session tokens.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client interface {
	NewRequest(ctx context.Context, method, prefix, urlPath string, body interface{}) (*http.Request, error)
	Do(req *http.Request, obj interface{}) error
	With(modifiers ...ClientModifierFn) Client
}

Client is an HTTP client for communicating with Upbound.

type ClientModifierFn

type ClientModifierFn func(*HTTPClient)

A ClientModifierFn modifies an HTTP client.

type Config

type Config struct {
	// Client is the underlying client.
	Client Client

	// Logger is the interface for structured logging.
	Logger logging.Logger
}

Config represents common configuration for Upbound SDK clients.

func NewConfig

func NewConfig(modifiers ...ConfigModifierFn) *Config

NewConfig builds a new Config for communicating with the Upbound API.

type ConfigModifierFn

type ConfigModifierFn func(*Config)

A ConfigModifierFn modifies a Config.

type DefaultErrorHandler

type DefaultErrorHandler struct{}

DefaultErrorHandler is the default operations for handling errors returned by the Upbound API.

func (*DefaultErrorHandler) Handle

func (h *DefaultErrorHandler) Handle(res *http.Response) error

Handle handles HTTP response errors from the Upbound API. Caller is responsible for closing response body.

type HTTPClient

type HTTPClient struct {
	// BaseURL is the base Upbound API URL.
	BaseURL *url.URL

	// ErrorHandler controls how the client handles errors.
	ErrorHandler ResponseErrorHandler

	// HTTP is the underlying HTTP client.
	HTTP *http.Client

	// User agent for communicating with the Upbound API.
	UserAgent string
}

HTTPClient implements the Client interface and allows for overriding of base URL, error handling, and user agent.

func NewClient

func NewClient(modifiers ...ClientModifierFn) *HTTPClient

NewClient builds a new default HTTP client for Upbound.

func (*HTTPClient) Do

func (c *HTTPClient) Do(req *http.Request, obj interface{}) error

Do performs an HTTP request and reads the body into the provided interface.

func (*HTTPClient) NewRequest

func (c *HTTPClient) NewRequest(ctx context.Context, method, prefix, urlPath string, body interface{}) (*http.Request, error)

NewRequest builds an HTTP request.

func (*HTTPClient) With added in v0.3.0

func (c *HTTPClient) With(modifiers ...ClientModifierFn) Client

With returns a new Client after applying given modifiers.

type ResponseErrorHandler

type ResponseErrorHandler interface {
	Handle(res *http.Response) error
}

A ResponseErrorHandler handles errors in HTTP responses.

Directories

Path Synopsis
_examples
Package apis contains Kubernetes API for the MXE provider.
Package apis contains Kubernetes API for the MXE provider.
common
Package common contains common types for other packages to use.
Package common contains common types for other packages to use.
observability/v1alpha1
Package v1alpha1 contains Observability resources.
Package v1alpha1 contains Observability resources.
policy/v1alpha1
Package v1alpha1 contains Policy resources.
Package v1alpha1 contains Policy resources.
query
Package query contains query.spaces.upbound.io API versions.
Package query contains query.spaces.upbound.io API versions.
query/v1alpha1
Package v1alpha1 contains ControlPlane resources.
Package v1alpha1 contains ControlPlane resources.
query/v1alpha2
Package v1alpha2 contains v1alpha2 of the Query API.
Package v1alpha2 contains v1alpha2 of the Query API.
spaces
Package spaces contains spaces.upbound.io API versions.
Package spaces contains spaces.upbound.io API versions.
spaces/v1alpha1
Package v1alpha1 contains ControlPlane resources.
Package v1alpha1 contains ControlPlane resources.
spaces/v1beta1
Package v1beta1 contains ControlPlane resources.
Package v1beta1 contains ControlPlane resources.
upbound
Package upbound contains upbound.io API versions.
Package upbound contains upbound.io API versions.
upbound/v1alpha1
Package v1alpha1 contains the Cluster resource.
Package v1alpha1 contains the Cluster resource.
service

Jump to

Keyboard shortcuts

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