lib/spatio/api/misc.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.Misc do
  @moduledoc """
  API calls for all endpoints tagged `Misc`.
  """

  alias Spatio.Connection
  import Spatio.RequestBuilder

  @doc """
  Unpin a platform.

  ### Parameters

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

  ### Returns

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

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

  @doc """
  Single-shot identity + config bundle the renderer hits on first load. Replaces the legacy server-side hydration in app/layout.tsx. 

  ### Parameters

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

  ### Returns

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

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

  @doc """
  Pending invitations the caller can accept during onboarding.

  ### Parameters

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

  ### Returns

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

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

  @doc """
  Read the caller's pinned-platform list (sidebar order).

  ### Parameters

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

  ### Returns

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

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

  @doc """
  Read the caller's per-platform sidebar/visibility preferences.

  ### Parameters

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

  ### Returns

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

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

  @doc """
  Legacy admin-tier platform settings read endpoint.

  ### Parameters

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

  ### Returns

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

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

  @doc """
  Async-thread / job-runner status snapshot.

  ### Parameters

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

  ### Returns

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

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

  @doc """
  Read the caller's effective per-resource permissions.

  ### Parameters

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

  ### Returns

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

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

  @doc """
  Recent activity feed for a workspace.

  ### Parameters

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

  ### Returns

  - `{:ok, %{}}` on success
  - `{:error, Tesla.Env.t}` on failure
  """
  @spec get_workspace_activity(Tesla.Env.client, keyword()) :: {:ok, %{optional(String.t) => any()}} | {:ok, Spatio.Model.ApiError.t} | {:error, Tesla.Env.t}
  def get_workspace_activity(connection, opts \\ []) do
    optional_params = %{
      :workspaceId => :query,
      :limit => :query
    }

    request =
      %{}
      |> method(:get)
      |> url("/v1/workspace-activity")
      |> add_optional_params(optional_params, opts)
      |> Enum.into([])

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

  @doc """
  Read the renderer's saved pane layout for a workspace.

  ### Parameters

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

  ### Returns

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

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

  @doc """
  Pin a platform.

  ### Parameters

  - `connection` (Spatio.Connection): Connection to server
  - `request_body` (%{optional(String.t) => any()}): 
  - `opts` (keyword): Optional parameters

  ### Returns

  - `{:ok, nil}` on success
  - `{:error, Tesla.Env.t}` on failure
  """
  @spec put_pinned_platform(Tesla.Env.client, %{optional(String.t) => any()}, keyword()) :: {:ok, nil} | {:ok, Spatio.Model.ApiError.t} | {:error, Tesla.Env.t}
  def put_pinned_platform(connection, request_body, _opts \\ []) do
    request =
      %{}
      |> method(:put)
      |> url("/v1/pinned-platforms")
      |> add_param(:body, :body, request_body)
      |> Enum.into([])

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

  @doc """
  Replace the caller's platform preferences.

  ### Parameters

  - `connection` (Spatio.Connection): Connection to server
  - `request_body` (%{optional(String.t) => any()}): 
  - `opts` (keyword): Optional parameters

  ### Returns

  - `{:ok, nil}` on success
  - `{:error, Tesla.Env.t}` on failure
  """
  @spec put_platform_preferences(Tesla.Env.client, %{optional(String.t) => any()}, keyword()) :: {:ok, nil} | {:ok, Spatio.Model.ApiError.t} | {:error, Tesla.Env.t}
  def put_platform_preferences(connection, request_body, _opts \\ []) do
    request =
      %{}
      |> method(:put)
      |> url("/v1/platform-preferences")
      |> add_param(:body, :body, request_body)
      |> Enum.into([])

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

  @doc """
  Save the renderer's pane layout.

  ### Parameters

  - `connection` (Spatio.Connection): Connection to server
  - `workspace_id` (String.t): 
  - `request_body` (%{optional(String.t) => any()}): 
  - `opts` (keyword): Optional parameters

  ### Returns

  - `{:ok, nil}` on success
  - `{:error, Tesla.Env.t}` on failure
  """
  @spec put_workspace_layout(Tesla.Env.client, String.t, %{optional(String.t) => any()}, keyword()) :: {:ok, nil} | {:ok, Spatio.Model.ApiError.t} | {:error, Tesla.Env.t}
  def put_workspace_layout(connection, workspace_id, request_body, _opts \\ []) do
    request =
      %{}
      |> method(:put)
      |> url("/v1/layout/#{workspace_id}")
      |> add_param(:body, :body, request_body)
      |> Enum.into([])

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

  @doc """
  Reorder the pinned-platform list.

  ### Parameters

  - `connection` (Spatio.Connection): Connection to server
  - `request_body` (%{optional(String.t) => any()}): 
  - `opts` (keyword): Optional parameters

  ### Returns

  - `{:ok, nil}` on success
  - `{:error, Tesla.Env.t}` on failure
  """
  @spec reorder_pinned_platforms(Tesla.Env.client, %{optional(String.t) => any()}, keyword()) :: {:ok, nil} | {:ok, Spatio.Model.ApiError.t} | {:error, Tesla.Env.t}
  def reorder_pinned_platforms(connection, request_body, _opts \\ []) do
    request =
      %{}
      |> method(:post)
      |> url("/v1/pinned-platforms/reorder")
      |> add_param(:body, :body, request_body)
      |> Enum.into([])

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

  @doc """
  Reset platform preferences to defaults.

  ### Parameters

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

  ### Returns

  - `{:ok, nil}` on success
  - `{:error, Tesla.Env.t}` on failure
  """
  @spec reset_platform_preferences(Tesla.Env.client, keyword()) :: {:ok, nil} | {:ok, Spatio.Model.ApiError.t} | {:error, Tesla.Env.t}
  def reset_platform_preferences(connection, _opts \\ []) do
    request =
      %{}
      |> method(:post)
      |> url("/v1/platform-preferences/reset")
      |> ensure_body()
      |> Enum.into([])

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

  @doc """
  Update the caller's user profile (name, avatar, etc.).

  ### Parameters

  - `connection` (Spatio.Connection): Connection to server
  - `request_body` (%{optional(String.t) => any()}): 
  - `opts` (keyword): Optional parameters

  ### Returns

  - `{:ok, %{}}` on success
  - `{:error, Tesla.Env.t}` on failure
  """
  @spec update_user_profile(Tesla.Env.client, %{optional(String.t) => any()}, keyword()) :: {:ok, %{optional(String.t) => any()}} | {:ok, Spatio.Model.ApiError.t} | {:error, Tesla.Env.t}
  def update_user_profile(connection, request_body, _opts \\ []) do
    request =
      %{}
      |> method(:patch)
      |> url("/v1/user/profile")
      |> add_param(:body, :body, request_body)
      |> Enum.into([])

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

  @doc """
  Check whether an org slug is available.

  ### Parameters

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

  ### Returns

  - `{:ok, %{}}` on success
  - `{:error, Tesla.Env.t}` on failure
  """
  @spec validate_organization_slug(Tesla.Env.client, keyword()) :: {:ok, %{optional(String.t) => any()}} | {:ok, Spatio.Model.ApiError.t} | {:error, Tesla.Env.t}
  def validate_organization_slug(connection, opts \\ []) do
    optional_params = %{
      :slug => :query
    }

    request =
      %{}
      |> method(:get)
      |> url("/v1/validate-slug/organization")
      |> add_optional_params(optional_params, opts)
      |> Enum.into([])

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

  @doc """
  Check whether a workspace slug is available.

  ### Parameters

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

  ### Returns

  - `{:ok, %{}}` on success
  - `{:error, Tesla.Env.t}` on failure
  """
  @spec validate_workspace_slug(Tesla.Env.client, keyword()) :: {:ok, %{optional(String.t) => any()}} | {:ok, Spatio.Model.ApiError.t} | {:error, Tesla.Env.t}
  def validate_workspace_slug(connection, opts \\ []) do
    optional_params = %{
      :slug => :query,
      :organizationId => :query
    }

    request =
      %{}
      |> method(:get)
      |> url("/v1/validate-slug/workspace")
      |> add_optional_params(optional_params, opts)
      |> Enum.into([])

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