apiclient

package
v0.8.4 Latest Latest
Warning

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

Go to latest
Published: Apr 26, 2021 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Overview

Package apiclient implements a client for connecting to Kopia HTTP API server.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type HTTPStatusError added in v0.8.0

type HTTPStatusError struct {
	HTTPStatusCode int
	ErrorMessage   string
}

HTTPStatusError encapsulates HTTP status error.

func (HTTPStatusError) Error added in v0.8.0

func (e HTTPStatusError) Error() string

type KopiaAPIClient

type KopiaAPIClient struct {
	BaseURL    string
	HTTPClient *http.Client
}

KopiaAPIClient provides helper methods for communicating with Kopia API server.

func NewKopiaAPIClient

func NewKopiaAPIClient(options Options) (*KopiaAPIClient, error)

NewKopiaAPIClient creates a client for connecting to Kopia HTTP API.

func (*KopiaAPIClient) Delete

func (c *KopiaAPIClient) Delete(ctx context.Context, urlSuffix string, onNotFound error, reqPayload, respPayload interface{}) error

Delete is a helper that performs HTTP DELETE on a URL with the specified body from reqPayload and decodes the response onto respPayload which must be a pointer to byte slice or JSON-serializable structure.

func (*KopiaAPIClient) Get

func (c *KopiaAPIClient) Get(ctx context.Context, urlSuffix string, onNotFound error, respPayload interface{}) error

Get is a helper that performs HTTP GET on a URL with the specified suffix and decodes the response onto respPayload which must be a pointer to byte slice or JSON-serializable structure.

func (*KopiaAPIClient) Post

func (c *KopiaAPIClient) Post(ctx context.Context, urlSuffix string, reqPayload, respPayload interface{}) error

Post is a helper that performs HTTP POST on a URL with the specified body from reqPayload and decodes the response onto respPayload which must be a pointer to byte slice or JSON-serializable structure.

func (*KopiaAPIClient) Put

func (c *KopiaAPIClient) Put(ctx context.Context, urlSuffix string, reqPayload, respPayload interface{}) error

Put is a helper that performs HTTP PUT on a URL with the specified body from reqPayload and decodes the response onto respPayload which must be a pointer to byte slice or JSON-serializable structure.

type Options

type Options struct {
	BaseURL string

	Username string
	Password string

	TrustedServerCertificateFingerprint string

	LogRequests bool
}

Options encapsulates all optional parameters for KopiaAPIClient.

Jump to

Keyboard shortcuts

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