# 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.PersonalAccessTokens do
@moduledoc """
API calls for all endpoints tagged `PersonalAccessTokens`.
"""
alias Spatio.Connection
import Spatio.RequestBuilder
@doc """
Create a new PAT. The full token is returned only once on creation; the API never reveals the secret again.
### Parameters
- `connection` (Spatio.Connection): Connection to server
- `create_pat_request` (CreatePatRequest):
- `opts` (keyword): Optional parameters
### Returns
- `{:ok, Spatio.Model.CreatePatResponse.t}` on success
- `{:error, Tesla.Env.t}` on failure
"""
@spec create_personal_access_token(Tesla.Env.client, Spatio.Model.CreatePatRequest.t, keyword()) :: {:ok, Spatio.Model.CreatePatResponse.t} | {:ok, Spatio.Model.ApiError.t} | {:error, Tesla.Env.t}
def create_personal_access_token(connection, create_pat_request, _opts \\ []) do
request =
%{}
|> method(:post)
|> url("/v1/tokens")
|> add_param(:body, :body, create_pat_request)
|> Enum.into([])
connection
|> Connection.request(request)
|> evaluate_response([
{201, Spatio.Model.CreatePatResponse},
{401, Spatio.Model.ApiError}
])
end
@doc """
List the scope strings PATs can be issued with.
### Parameters
- `connection` (Spatio.Connection): Connection to server
- `opts` (keyword): Optional parameters
### Returns
- `{:ok, Spatio.Model.PatScopesResponse.t}` on success
- `{:error, Tesla.Env.t}` on failure
"""
@spec list_available_pat_scopes(Tesla.Env.client, keyword()) :: {:ok, Spatio.Model.PatScopesResponse.t} | {:ok, Spatio.Model.ApiError.t} | {:error, Tesla.Env.t}
def list_available_pat_scopes(connection, _opts \\ []) do
request =
%{}
|> method(:get)
|> url("/v1/tokens/scopes")
|> Enum.into([])
connection
|> Connection.request(request)
|> evaluate_response([
{200, Spatio.Model.PatScopesResponse},
{401, Spatio.Model.ApiError}
])
end
@doc """
List the caller's personal access tokens (with available scopes).
### Parameters
- `connection` (Spatio.Connection): Connection to server
- `opts` (keyword): Optional parameters
### Returns
- `{:ok, Spatio.Model.PatListResponse.t}` on success
- `{:error, Tesla.Env.t}` on failure
"""
@spec list_personal_access_tokens(Tesla.Env.client, keyword()) :: {:ok, Spatio.Model.PatListResponse.t} | {:ok, Spatio.Model.ApiError.t} | {:error, Tesla.Env.t}
def list_personal_access_tokens(connection, _opts \\ []) do
request =
%{}
|> method(:get)
|> url("/v1/tokens")
|> Enum.into([])
connection
|> Connection.request(request)
|> evaluate_response([
{200, Spatio.Model.PatListResponse},
{401, Spatio.Model.ApiError}
])
end
@doc """
Revoke a PAT.
### Parameters
- `connection` (Spatio.Connection): Connection to server
- `id` (String.t):
- `opts` (keyword): Optional parameters
### Returns
- `{:ok, nil}` on success
- `{:error, Tesla.Env.t}` on failure
"""
@spec revoke_personal_access_token(Tesla.Env.client, String.t, keyword()) :: {:ok, nil} | {:ok, Spatio.Model.ApiError.t} | {:error, Tesla.Env.t}
def revoke_personal_access_token(connection, id, _opts \\ []) do
request =
%{}
|> method(:delete)
|> url("/v1/tokens/#{id}")
|> Enum.into([])
connection
|> Connection.request(request)
|> evaluate_response([
{204, false},
{401, Spatio.Model.ApiError}
])
end
@doc """
Rename or re-describe a PAT (scopes are immutable).
### Parameters
- `connection` (Spatio.Connection): Connection to server
- `id` (String.t):
- `update_pat_request` (UpdatePatRequest):
- `opts` (keyword): Optional parameters
### Returns
- `{:ok, Spatio.Model.PersonalAccessToken.t}` on success
- `{:error, Tesla.Env.t}` on failure
"""
@spec update_personal_access_token(Tesla.Env.client, String.t, Spatio.Model.UpdatePatRequest.t, keyword()) :: {:ok, Spatio.Model.PersonalAccessToken.t} | {:ok, Spatio.Model.ApiError.t} | {:error, Tesla.Env.t}
def update_personal_access_token(connection, id, update_pat_request, _opts \\ []) do
request =
%{}
|> method(:patch)
|> url("/v1/tokens/#{id}")
|> add_param(:body, :body, update_pat_request)
|> Enum.into([])
connection
|> Connection.request(request)
|> evaluate_response([
{200, Spatio.Model.PersonalAccessToken},
{401, Spatio.Model.ApiError}
])
end
@doc """
### Parameters
- `connection` (Spatio.Connection): Connection to server
- `org` (String.t):
- `workspace` (String.t):
- `request_body` (%{optional(String.t) => any()}):
- `opts` (keyword): Optional parameters
### Returns
- `{:ok, %{}}` on success
- `{:error, Tesla.Env.t}` on failure
"""
@spec workspace_create_pat(Tesla.Env.client, String.t, String.t, %{optional(String.t) => any()}, keyword()) :: {:ok, %{optional(String.t) => any()}} | {:ok, Spatio.Model.ApiError.t} | {:error, Tesla.Env.t}
def workspace_create_pat(connection, org, workspace, request_body, _opts \\ []) do
request =
%{}
|> method(:post)
|> url("/v1/organizations/#{org}/workspaces/#{workspace}/tokens")
|> add_param(:body, :body, request_body)
|> Enum.into([])
connection
|> Connection.request(request)
|> evaluate_response([
{201, %{}},
{401, Spatio.Model.ApiError},
{403, Spatio.Model.ApiError}
])
end
@doc """
### Parameters
- `connection` (Spatio.Connection): Connection to server
- `org` (String.t):
- `workspace` (String.t):
- `opts` (keyword): Optional parameters
### Returns
- `{:ok, %{}}` on success
- `{:error, Tesla.Env.t}` on failure
"""
@spec workspace_list_pats(Tesla.Env.client, String.t, String.t, keyword()) :: {:ok, %{optional(String.t) => any()}} | {:ok, Spatio.Model.ApiError.t} | {:error, Tesla.Env.t}
def workspace_list_pats(connection, org, workspace, _opts \\ []) do
request =
%{}
|> method(:get)
|> url("/v1/organizations/#{org}/workspaces/#{workspace}/tokens")
|> Enum.into([])
connection
|> Connection.request(request)
|> evaluate_response([
{200, %{}},
{401, Spatio.Model.ApiError},
{403, Spatio.Model.ApiError}
])
end
@doc """
### Parameters
- `connection` (Spatio.Connection): Connection to server
- `org` (String.t):
- `workspace` (String.t):
- `id` (String.t):
- `opts` (keyword): Optional parameters
### Returns
- `{:ok, nil}` on success
- `{:error, Tesla.Env.t}` on failure
"""
@spec workspace_revoke_pat(Tesla.Env.client, String.t, String.t, String.t, keyword()) :: {:ok, nil} | {:ok, Spatio.Model.ApiError.t} | {:error, Tesla.Env.t}
def workspace_revoke_pat(connection, org, workspace, id, _opts \\ []) do
request =
%{}
|> method(:delete)
|> url("/v1/organizations/#{org}/workspaces/#{workspace}/tokens/#{id}")
|> Enum.into([])
connection
|> Connection.request(request)
|> evaluate_response([
{204, false},
{401, Spatio.Model.ApiError},
{403, Spatio.Model.ApiError}
])
end
@doc """
### Parameters
- `connection` (Spatio.Connection): Connection to server
- `org` (String.t):
- `workspace` (String.t):
- `id` (String.t):
- `request_body` (%{optional(String.t) => any()}):
- `opts` (keyword): Optional parameters
### Returns
- `{:ok, %{}}` on success
- `{:error, Tesla.Env.t}` on failure
"""
@spec workspace_update_pat(Tesla.Env.client, String.t, String.t, String.t, %{optional(String.t) => any()}, keyword()) :: {:ok, %{optional(String.t) => any()}} | {:ok, Spatio.Model.ApiError.t} | {:error, Tesla.Env.t}
def workspace_update_pat(connection, org, workspace, id, request_body, _opts \\ []) do
request =
%{}
|> method(:patch)
|> url("/v1/organizations/#{org}/workspaces/#{workspace}/tokens/#{id}")
|> add_param(:body, :body, request_body)
|> Enum.into([])
connection
|> Connection.request(request)
|> evaluate_response([
{200, %{}},
{401, Spatio.Model.ApiError},
{403, Spatio.Model.ApiError}
])
end
end