WardrikRest.Call (wardrik_rest v0.1.0-rc.1)

Copy Markdown

Makes one call to an operation for an agent.

  • The credentials of the operation's first scheme alternative the API has sources for go in as its description says, with the API's :headers and the header arguments given.
  • A 401 tells the agent's WardrikCore.Credentials the token was refused, then the call is made once more with a fresh one.
  • A 429, a 5xx or no answer raises WardrikRest.Unavailable, so the tool runner retries.
  • Any other status is an error naming it, with the API's message.
  • An answer longer than the API's :max_result_bytes is cut, as JSON text.

Summary

Types

t()

One call: the operation of an API, its arguments, and the turn it's made in.

Functions

Calls operation of api with the tool's args, as whoever context acts for.

Types

t()

@type t() :: %WardrikRest.Call{
  api: WardrikRest.API.t(),
  args: %{required(String.t()) => term()},
  context: WardrikCore.Context.t(),
  operation: WardrikRest.Operation.t()
}

One call: the operation of an API, its arguments, and the turn it's made in.

Functions

run(api, operation, args, context)

@spec run(
  WardrikRest.API.t(),
  WardrikRest.Operation.t(),
  map(),
  WardrikCore.Context.t()
) ::
  {:ok, term()} | {:error, String.t()} | {:park, WardrikCore.Authorization.t()}

Calls operation of api with the tool's args, as whoever context acts for.