Help us shape the future of Go! Take the 2026 Go Developer Survey

internal

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Sep 29, 2026 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func InferKind

func InferKind[M any]() string

InferKind infers the meshObject kind from a struct type name using the same convention as the meshObject API: MeshWorkspace → "meshWorkspace", MeshBuildingBlockV2 → "meshBuildingBlock". Version suffixes (V\d+) are stripped. Tested when client.Kind is statically initialized.

func WithListOptions added in v0.2.0

func WithListOptions(ctx context.Context, options ListOptions) context.Context

Types

type HttpClient

type HttpClient struct {
	http.AuthorizedClient

	EndpointUrl xurl.URL
}

type ListOptions added in v0.2.0

type ListOptions struct {
	PageSize int
	OnPage   func(Page)
}

func ListOptionsFrom added in v0.2.0

func ListOptionsFrom(ctx context.Context) ListOptions

type MeshObjectClient

type MeshObjectClient[M any] struct {
	http.AuthorizedClient

	Kind       string
	ApiVersion string
	ApiUrl     *url.URL
}

MeshObjectClient provides typed CRUD operations for meshStack API objects. It embeds http.AuthorizedClient and adds meshObject-specific functionality including automatic MIME type handling and pagination.

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. The API URL is constructed from explicitApiPathElems if provided, otherwise the pluralized and lowercased kind is used as a single element, a convention only the workspace and project user/group binding APIs break.

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]) DeleteAtPath

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

func (MeshObjectClient[M]) Get

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

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

func (MeshObjectClient[M]) GetAtPath

func (c MeshObjectClient[M]) GetAtPath[R any](ctx context.Context, id string, extraPath ...string) (R, error)

func (MeshObjectClient[M]) List

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

func (MeshObjectClient[M]) ListSeq added in v0.2.0

func (c MeshObjectClient[M]) ListSeq(ctx context.Context, options ...http.RequestOption) iter.Seq2[M, error]

ListSeq retrieves all meshObjects with automatic pagination handling, and yields each one as its page arrives.

func (MeshObjectClient[M]) ListSeqAs added in v0.2.0

func (c MeshObjectClient[M]) ListSeqAs[T any](ctx context.Context, options ...http.RequestOption) iter.Seq2[T, error]

func (MeshObjectClient[M]) MeshObjectMimeType

func (c MeshObjectClient[M]) MeshObjectMimeType() string

func (MeshObjectClient[M]) Post

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

Post creates a new meshObject with the given payload. Automatically injects apiVersion and kind into the JSON payload.

func (MeshObjectClient[M]) PostAtPath

func (c MeshObjectClient[M]) PostAtPath[R, P any](ctx context.Context, payload P, extraPath ...string) (R, error)

func (MeshObjectClient[M]) Put

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

Put updates an existing meshObject by ID with the given payload. Automatically injects apiVersion and kind into the JSON payload.

type Page added in v0.2.0

type Page struct {
	Size          int `json:"size"`
	TotalElements int `json:"totalElements"`
	TotalPages    int `json:"totalPages"`
	Number        int `json:"number"`
}

Jump to

Keyboard shortcuts

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