lib/spatio/api/actions.ex

# NOTE: This file is auto generated by OpenAPI Generator 7.22.0 (https://openapi-generator.tech).
# Do not edit this file manually.

defmodule Spatio.Api.Actions do
  @moduledoc """
  API calls for all endpoints tagged `Actions`.
  """

  alias Spatio.Connection
  import Spatio.RequestBuilder

  @doc """
  Renderer-side execute alias. The canonical endpoint is `POST /v1/agent/actions/execute`; this path delegates to the same handler. 

  ### Parameters

  - `connection` (Spatio.Connection): Connection to server
  - `execute_action_request` (ExecuteActionRequest): 
  - `opts` (keyword): Optional parameters

  ### Returns

  - `{:ok, Spatio.Model.ExecuteActionResponse.t}` on success
  - `{:error, Tesla.Env.t}` on failure
  """
  @spec execute_action(Tesla.Env.client, Spatio.Model.ExecuteActionRequest.t, keyword()) :: {:ok, Spatio.Model.ExecuteActionResponse.t} | {:ok, Spatio.Model.ApiError.t} | {:error, Tesla.Env.t}
  def execute_action(connection, execute_action_request, _opts \\ []) do
    request =
      %{}
      |> method(:post)
      |> url("/v1/actions/execute")
      |> add_param(:body, :body, execute_action_request)
      |> Enum.into([])

    connection
    |> Connection.request(request)
    |> evaluate_response([
      {200, Spatio.Model.ExecuteActionResponse},
      {401, Spatio.Model.ApiError}
    ])
  end

  @doc """
  Fetch a single core action by id.

  ### Parameters

  - `connection` (Spatio.Connection): Connection to server
  - `id` (String.t): 
  - `opts` (keyword): Optional parameters

  ### Returns

  - `{:ok, Spatio.Model.CoreAction.t}` on success
  - `{:error, Tesla.Env.t}` on failure
  """
  @spec get_core_action(Tesla.Env.client, String.t, keyword()) :: {:ok, Spatio.Model.CoreAction.t} | {:ok, Spatio.Model.ApiError.t} | {:error, Tesla.Env.t}
  def get_core_action(connection, id, _opts \\ []) do
    request =
      %{}
      |> method(:get)
      |> url("/v1/actions/core/#{id}")
      |> Enum.into([])

    connection
    |> Connection.request(request)
    |> evaluate_response([
      {200, Spatio.Model.CoreAction},
      {401, Spatio.Model.ApiError},
      {404, Spatio.Model.ApiError}
    ])
  end

  @doc """
  List every action the agent platform exposes.

  ### Parameters

  - `connection` (Spatio.Connection): Connection to server
  - `opts` (keyword): Optional parameters

  ### Returns

  - `{:ok, [%ActionDescriptor{}, ...]}` on success
  - `{:error, Tesla.Env.t}` on failure
  """
  @spec list_available_actions(Tesla.Env.client, keyword()) :: {:ok, [Spatio.Model.ActionDescriptor.t]} | {:ok, Spatio.Model.ApiError.t} | {:error, Tesla.Env.t}
  def list_available_actions(connection, _opts \\ []) do
    request =
      %{}
      |> method(:get)
      |> url("/v1/actions/available")
      |> Enum.into([])

    connection
    |> Connection.request(request)
    |> evaluate_response([
      {200, Spatio.Model.ActionDescriptor},
      {401, Spatio.Model.ApiError}
    ])
  end

  @doc """
  List renderer-curated \"core actions\" (command-palette + keybindings backing).

  ### Parameters

  - `connection` (Spatio.Connection): Connection to server
  - `opts` (keyword): Optional parameters

  ### Returns

  - `{:ok, Spatio.Model.CoreActionListResponse.t}` on success
  - `{:error, Tesla.Env.t}` on failure
  """
  @spec list_core_actions(Tesla.Env.client, keyword()) :: {:ok, Spatio.Model.CoreActionListResponse.t} | {:ok, Spatio.Model.ApiError.t} | {:error, Tesla.Env.t}
  def list_core_actions(connection, _opts \\ []) do
    request =
      %{}
      |> method(:get)
      |> url("/v1/actions/core")
      |> Enum.into([])

    connection
    |> Connection.request(request)
    |> evaluate_response([
      {200, Spatio.Model.CoreActionListResponse},
      {401, Spatio.Model.ApiError}
    ])
  end

  @doc """
  Core actions filtered to one platform.

  ### Parameters

  - `connection` (Spatio.Connection): Connection to server
  - `platform` (String.t): 
  - `opts` (keyword): Optional parameters

  ### Returns

  - `{:ok, Spatio.Model.CoreActionListResponse.t}` on success
  - `{:error, Tesla.Env.t}` on failure
  """
  @spec list_core_actions_by_platform(Tesla.Env.client, String.t, keyword()) :: {:ok, Spatio.Model.CoreActionListResponse.t} | {:ok, Spatio.Model.ApiError.t} | {:error, Tesla.Env.t}
  def list_core_actions_by_platform(connection, platform, _opts \\ []) do
    request =
      %{}
      |> method(:get)
      |> url("/v1/actions/core/platform/#{platform}")
      |> Enum.into([])

    connection
    |> Connection.request(request)
    |> evaluate_response([
      {200, Spatio.Model.CoreActionListResponse},
      {401, Spatio.Model.ApiError}
    ])
  end

  @doc """
  List actions tagged for a specific platform (notes, mail, ...).

  ### Parameters

  - `connection` (Spatio.Connection): Connection to server
  - `platform` (String.t): 
  - `opts` (keyword): Optional parameters

  ### Returns

  - `{:ok, [%ActionDescriptor{}, ...]}` on success
  - `{:error, Tesla.Env.t}` on failure
  """
  @spec list_platform_actions(Tesla.Env.client, String.t, keyword()) :: {:ok, [Spatio.Model.ActionDescriptor.t]} | {:ok, Spatio.Model.ApiError.t} | {:error, Tesla.Env.t}
  def list_platform_actions(connection, platform, _opts \\ []) do
    request =
      %{}
      |> method(:get)
      |> url("/v1/actions/platform/#{platform}")
      |> Enum.into([])

    connection
    |> Connection.request(request)
    |> evaluate_response([
      {200, Spatio.Model.ActionDescriptor},
      {401, Spatio.Model.ApiError}
    ])
  end
end