Documentation
¶
Index ¶
- func Create[T any](ctx context.Context, c *Client, path string, body any) (*T, error)
- func CreateList[T any](ctx context.Context, c *Client, path string, body any) ([]T, error)
- func CreateRaw[T any](ctx context.Context, c *Client, path string, body any) (*T, []byte, error)
- func Delete(ctx context.Context, c *Client, path string) error
- func DeleteWithBody(ctx context.Context, c *Client, path string, body any) error
- func Get[T any](ctx context.Context, c *Client, path string) (*T, error)
- func GetRaw[T any](ctx context.Context, c *Client, path string) (*T, []byte, error)
- func IsNotFound(err error) bool
- func List[T any](ctx context.Context, c *Client, basePath string) ([]T, error)
- func Patch[T any](ctx context.Context, c *Client, path string, body any) (*T, error)
- func PathEscape(s string) string
- func Update[T any](ctx context.Context, c *Client, path string, body any) (*T, error)
- func UpdateRaw[T any](ctx context.Context, c *Client, path string, body any) (*T, []byte, error)
- type APIError
- type Client
- type SingleValueResponse
- type TableResponse
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CreateList ¶
CreateList POSTs to an endpoint that returns a TableResponse[T] (e.g. the tag-management sub-resources on monitors, which return the full collection after the mutation rather than a single entity). Use Create when the endpoint returns SingleValueResponse[T].
func DeleteWithBody ¶
DeleteWithBody issues a DELETE with a JSON request body. Used for endpoints that accept a body (e.g. DELETE /monitors/{id}/tags with a list of tag IDs).
func GetRaw ¶
GetRaw is the escape-hatch variant of Get that also returns the raw response body so callers can extract polymorphic / discriminated-union fields whose generated Go type loses information during a typed unmarshal (e.g. monitor `auth`, where the spec collapsed the oneOf into a base `MonitorAuthConfig{Type string}` and only the `type` discriminator survives). Use the typed result for everything else; only reach into the raw body for the specific field whose round-trip you need to preserve.
func IsNotFound ¶
func PathEscape ¶
Types ¶
type Client ¶
type SingleValueResponse ¶
type SingleValueResponse[T any] struct { Data T `json:"data"` }
SingleValueResponse is the single-value envelope used by most endpoints.
Note on the zero-value contract: when the upstream JSON is malformed or the server returns a 2xx without a `data` field (which the API contract should never produce, but is worth being explicit about), `Data` will be the zero value of `T` and `Get`/`Create`/`Update`/`Patch` will return a non-nil pointer to that zero value. Callers should NOT treat a non-nil return as "the resource exists" — they should rely on the per-resource semantic invariants instead (e.g. `dto.Id != uuid.Nil` for newly-created resources, or `IsNotFound(err)` for explicit 404 handling). Nil-checking `&resp.Data` itself is meaningless because the address of a value-typed struct field inside a stack-allocated struct is always non-nil.
type TableResponse ¶
Table response wrapper used by list endpoints.