TypeSafe.Response (TypeSafe v0.2.2)

Copy Markdown View Source

Decoding of successful API responses into their public structs.

This module is used internally by TypeSafe; you normally interact with the returned TypeSafe.Response.SystemOne and TypeSafe.Response.ListModels structs rather than calling it directly.

Summary

Types

HTTP metadata carried alongside a decoded body.

Functions

Decode a GET /v1/models body into a TypeSafe.Response.ListModels.

Decode a POST /v1/systemone body into a TypeSafe.Response.SystemOne.

Types

meta()

@type meta() :: %{
  status: pos_integer(),
  headers: %{optional(String.t()) => String.t()},
  request_id: String.t() | nil,
  endpoint: String.t() | nil,
  raw: term()
}

HTTP metadata carried alongside a decoded body.

  • :status — response status code.
  • :headers — map of lowercased header names to values.
  • :request_id — the x-typesafe-request-id header, or nil.
  • :endpoint — "METHOD URL" without credentials, or nil.
  • :raw — the underlying Req.Response.

Functions

parse_list_models(arg1, meta)

@spec parse_list_models(term(), meta()) ::
  {:ok, TypeSafe.Response.ListModels.t()}
  | {:error, TypeSafe.ResponseValidationError.t()}

Decode a GET /v1/models body into a TypeSafe.Response.ListModels.

parse_system_one(decoded, meta)

@spec parse_system_one(term(), meta()) ::
  {:ok, TypeSafe.Response.SystemOne.t()}
  | {:error, TypeSafe.ResponseValidationError.t()}

Decode a POST /v1/systemone body into a TypeSafe.Response.SystemOne.