Documentation
¶
Index ¶
- type HttpClient
- type Logger
- type MeshInfo
- type MeshObjectClient
- func (c MeshObjectClient[M]) Delete(ctx context.Context, id string) (err error)
- func (c MeshObjectClient[M]) Get(ctx context.Context, id string) (*M, error)
- func (c MeshObjectClient[M]) List(ctx context.Context, options ...RequestOption) ([]M, error)
- func (c MeshObjectClient[M]) Post(ctx context.Context, payload any) (*M, error)
- func (c MeshObjectClient[M]) Put(ctx context.Context, id string, payload any) (*M, error)
- type RequestOption
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 MeshObjectClient ¶
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, explicitApiPaths ...string) MeshObjectClient[M]
NewMeshObjectClient creates a new MeshObjectClient for a specific meshObject type with automatic URL path inference. The meshObject name is inferred from type M, and the API URL is constructed from explicitApiPaths or the pluralized type name.
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.
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).