internal

package
v0.19.2 Latest Latest
Warning

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

Go to latest
Published: Feb 24, 2026 License: MPL-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type HttpClient

type HttpClient struct {
	http.Client
	RootUrl   *url.URL
	UserAgent string

	ApiKey                 string
	ApiSecret              string
	Authorization          string
	AuthorizationExpiresAt time.Time
}

HttpClient wraps http.Client with convenient request handling thanks to RequestOption.

func (*HttpClient) GetMeshInfo

func (c *HttpClient) GetMeshInfo(ctx context.Context) (*MeshInfo, error)

type Logger

type Logger interface {
	Info(ctx context.Context, msg string, args ...any)
	Debug(ctx context.Context, msg string, args ...any)
}

Logger only supports Debug and Info log levels.

var Log Logger = noopLogger{}

type MeshInfo

type MeshInfo struct {
	Version version.Version `json:"version"`
}

type MeshObjectClient

type MeshObjectClient[M any] struct {
	*HttpClient
	Kind       string
	ApiVersion string
	ApiUrl     *url.URL
}

MeshObjectClient provides typed CRUD operations for meshStack API objects. It embeds HttpClient and adds meshObject-specific functionality including automatic MIME type handling and pagination. Also handles authentication in doAuthorizedRequest using the ApiKey/ApiSecret values, which are embedded in HttpClient for convenient construction with NewMeshObjectClient.

func NewMeshObjectClient

func NewMeshObjectClient[M any](ctx context.Context, httpClient *HttpClient, apiVersion string, explicitApiPathElems ...string) MeshObjectClient[M]

NewMeshObjectClient creates a new MeshObjectClient for a specific meshObject type with automatic URL path inference. The meshObject kind is inferred from type M. T The API URL is constructed from explicitApiPathElems if provided, otherwise the pluralized and lowercased kind is used as a single element.

func (MeshObjectClient[M]) Delete

func (c MeshObjectClient[M]) Delete(ctx context.Context, id string) (err error)

Delete removes a meshObject by ID.

func (MeshObjectClient[M]) Get

func (c MeshObjectClient[M]) Get(ctx context.Context, id string) (*M, error)

Get retrieves a meshObject by ID. Returns nil if not found.

func (MeshObjectClient[M]) List

func (c MeshObjectClient[M]) List(ctx context.Context, options ...RequestOption) ([]M, error)

List retrieves all meshObjects with automatic pagination handling. Accepts optional RequestOption parameters for filtering and querying.

func (MeshObjectClient[M]) Post

func (c MeshObjectClient[M]) Post(ctx context.Context, payload any) (*M, error)

Post creates a new meshObject with the given payload.

func (MeshObjectClient[M]) Put

func (c MeshObjectClient[M]) Put(ctx context.Context, id string, payload any) (*M, error)

Put updates an existing meshObject by ID with the given payload.

type RequestOption

type RequestOption func(opts *requestOptions)

RequestOption is a functional option for configuring HTTP requests.

func WithUrlQuery

func WithUrlQuery(key string, value any) RequestOption

WithUrlQuery adds a URL query parameter to the request. The value is stringified using fmt.Stringer.String() if implemented, otherwise fmt.Sprintf("%v", value).

Jump to

Keyboard shortcuts

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