ppdmclient

package
v1.6.0 Latest Latest
Warning

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

Go to latest
Published: Jun 14, 2026 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Overview

Package ppdmclient is the per-server Dell PowerProtect Data Manager REST API client.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetAll

func GetAll[T any](ctx context.Context, c Client, path string, pageSize int) ([]T, error)

GetAll fetches every page of a PPDM list endpoint and returns the concatenated content. pageSize caps items per request; a 200-page safety bound prevents runaways.

Types

type Client

type Client interface {
	// Name returns the configured server name (used as the `server` label).
	Name() string
	// Get fetches an absolute API path (e.g. "/api/v2/activities") and JSON-decodes
	// the body into out. It (re-)authenticates as needed.
	Get(ctx context.Context, path string, out any) error
	// Close releases the session and HTTP resources.
	Close() error
}

Client is the per-server PPDM API client abstraction, satisfied by the live ServerClient and by Mock (tests). Get authenticates lazily and decodes JSON.

type Config

type Config struct {
	Name               string
	BaseURL            string // e.g. https://ppdm01.example.com:8443
	Username           string
	Password           string
	InsecureSkipVerify bool
	HTTPClient         *http.Client
	// Trace logs every API response body (method, URL, status, body) for
	// validating payload shapes against a live appliance. The login exchange is
	// skipped — PPDM returns the access_token in the login response body — and
	// headers are never logged, so the bearer token cannot leak. Verbose —
	// debugging only.
	Trace bool
}

Config configures a ServerClient. HTTPClient is optional (tests inject the httptest TLS client); when nil a client honoring InsecureSkipVerify is built.

type Mock

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

Mock is an in-memory Client that serves canned JSON bodies per path. Tests use it to drive collectors without a live server.

func NewMock

func NewMock(name string) *Mock

NewMock returns an empty Mock for the named server.

func (*Mock) Close

func (m *Mock) Close() error

func (*Mock) Get

func (m *Mock) Get(_ context.Context, path string, out any) error

func (*Mock) Name

func (m *Mock) Name() string

func (*Mock) SetJSON

func (m *Mock) SetJSON(path, body string)

SetJSON registers a response body for an exact path.

func (*Mock) SetJSONPrefix

func (m *Mock) SetJSONPrefix(prefix, body string)

SetJSONPrefix registers a body matched by path prefix (ignores the query string), so paginated calls like "/api/v2/assets?page=0&pageSize=500" resolve to one body.

type ServerClient

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

ServerClient is the live per-server PPDM REST client.

func NewServerClient

func NewServerClient(cfg Config) *ServerClient

NewServerClient builds a client. Auth is lazy (on first Get).

func (*ServerClient) Close

func (c *ServerClient) Close() error

Close is best-effort logout. PPDM access tokens expire on their own; there is no mandatory server-side logout, so this just drops the cached token.

func (*ServerClient) Get

func (c *ServerClient) Get(ctx context.Context, path string, out any) error

Get fetches path, authenticating first and re-authenticating once on 401.

func (*ServerClient) Name

func (c *ServerClient) Name() string

Jump to

Keyboard shortcuts

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