# `WardrikRest`

Tools for agents from an HTTP API's description: one tool per operation, with the API's own
sign-in and keys.

    {:ok, analytics} =
      WardrikRest.API.load(
        {WardrikRest.Discovery,
         url: "https://analyticsdata.googleapis.com/$discovery/rest?version=v1beta"},
        name: "ga4",
        base_url: "https://analyticsdata.googleapis.com/",
        auth: %{"oauth2" => {:credential, "google"}},
        only: ["properties_runReport", "properties_getMetadata"],
        read_only: ["properties_runReport"]
      )

    WardrikCore.start_agent(
      agent_id: "agt_marketing",
      model: "anthropic:claude-haiku-4-5",
      capabilities: [{WardrikRest, apis: [analytics]}],
      credentials: {MyApp.Credentials, []}
    )

  * Each tool is named `<api>__<operation>`, as `ga4__properties_runReport`, and takes the
    operation's path, query and body arguments.
  * `GET`s and the operations given as `:read_only` are read-only; the rest need a person's
    approval unless the policy allows them.
  * Answers are labelled `"outside"` unless the API is `:trusted`.
  * A tool whose schema is over the API's `:max_schema_bytes` names its deeper types instead
    of listing their fields, and `<api>__describe` gives them.

Descriptions are read by a `WardrikRest.Reader`. See `WardrikRest.Discovery` and
`WardrikRest.API`.

# `tool`

```elixir
@spec tool(WardrikRest.API.t(), WardrikRest.Operation.t()) :: WardrikCore.Tool.t()
```

Returns the tool for `operation` of `api`.

---

*Consult [api-reference.md](api-reference.md) for complete listing*
