# 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.Sheets do
@moduledoc """
API calls for all endpoints tagged `Sheets`.
"""
alias Spatio.Connection
import Spatio.RequestBuilder
@doc """
Create a sheet.
Creates a new sheet under the target account. Target resolution mirrors `POST /v1/notes`: body `accountId` → `?accountId=` → body `provider` → `?provider=` → caller's single connected account (errors with `ambiguous_account` if more than one is connected and no selector is supplied).
### Parameters
- `connection` (Spatio.Connection): Connection to server
- `create_sheet_request` (CreateSheetRequest):
- `opts` (keyword): Optional parameters
- `:accountId` (String.t): Connected-account row id. Selects which provider account this request targets when more than one is connected. Mutually exclusive with `provider`. If omitted on a list endpoint the call fans out across every connected account.
- `:provider` (String.t): Provider id (e.g. `native-notes`, `notion`). Selects every connected account for the provider. Mutually exclusive with `accountId`.
- `:"X-Workspace-ID"` (String.t): Workspace scope for unscoped tokens. Workspace-scoped PATs and OAuth tokens carry this implicitly; for session/JWT auth without a scoped PAT, pass it explicitly.
### Returns
- `{:ok, Spatio.Model.Sheet.t}` on success
- `{:error, Tesla.Env.t}` on failure
"""
@spec create_sheet(Tesla.Env.client, Spatio.Model.CreateSheetRequest.t, keyword()) :: {:ok, Spatio.Model.Sheet.t} | {:ok, Spatio.Model.ApiError.t} | {:ok, Spatio.Model.CreateNote400Response.t} | {:error, Tesla.Env.t}
def create_sheet(connection, create_sheet_request, opts \\ []) do
optional_params = %{
:accountId => :query,
:provider => :query,
:"X-Workspace-ID" => :headers
}
request =
%{}
|> method(:post)
|> url("/v1/sheets")
|> add_param(:body, :body, create_sheet_request)
|> add_optional_params(optional_params, opts)
|> Enum.into([])
connection
|> Connection.request(request)
|> evaluate_response([
{201, Spatio.Model.Sheet},
{400, Spatio.Model.CreateNote400Response},
{401, Spatio.Model.ApiError},
{500, Spatio.Model.ApiError}
])
end
@doc """
Insert a row.
Inserts a row at `index` (zero-based) or appends to the end when `index` is omitted.
### Parameters
- `connection` (Spatio.Connection): Connection to server
- `id` (String.t): Sheet id.
- `create_row_request` (CreateRowRequest):
- `opts` (keyword): Optional parameters
- `:accountId` (String.t): Connected-account row id. Selects which provider account this request targets when more than one is connected. Mutually exclusive with `provider`. If omitted on a list endpoint the call fans out across every connected account.
- `:"X-Workspace-ID"` (String.t): Workspace scope for unscoped tokens. Workspace-scoped PATs and OAuth tokens carry this implicitly; for session/JWT auth without a scoped PAT, pass it explicitly.
### Returns
- `{:ok, Spatio.Model.Row.t}` on success
- `{:error, Tesla.Env.t}` on failure
"""
@spec create_sheet_row(Tesla.Env.client, String.t, Spatio.Model.CreateRowRequest.t, keyword()) :: {:ok, Spatio.Model.ApiError.t} | {:ok, Spatio.Model.Row.t} | {:error, Tesla.Env.t}
def create_sheet_row(connection, id, create_row_request, opts \\ []) do
optional_params = %{
:accountId => :query,
:"X-Workspace-ID" => :headers
}
request =
%{}
|> method(:post)
|> url("/v1/sheets/#{id}/rows")
|> add_param(:body, :body, create_row_request)
|> add_optional_params(optional_params, opts)
|> Enum.into([])
connection
|> Connection.request(request)
|> evaluate_response([
{201, Spatio.Model.Row},
{400, Spatio.Model.ApiError},
{401, Spatio.Model.ApiError},
{404, Spatio.Model.ApiError}
])
end
@doc """
Delete a sheet.
### Parameters
- `connection` (Spatio.Connection): Connection to server
- `id` (String.t): Sheet id.
- `opts` (keyword): Optional parameters
- `:accountId` (String.t): Connected-account row id. Selects which provider account this request targets when more than one is connected. Mutually exclusive with `provider`. If omitted on a list endpoint the call fans out across every connected account.
- `:"X-Workspace-ID"` (String.t): Workspace scope for unscoped tokens. Workspace-scoped PATs and OAuth tokens carry this implicitly; for session/JWT auth without a scoped PAT, pass it explicitly.
### Returns
- `{:ok, Spatio.Model.SuccessFlag.t}` on success
- `{:error, Tesla.Env.t}` on failure
"""
@spec delete_sheet(Tesla.Env.client, String.t, keyword()) :: {:ok, Spatio.Model.ApiError.t} | {:ok, Spatio.Model.SuccessFlag.t} | {:error, Tesla.Env.t}
def delete_sheet(connection, id, opts \\ []) do
optional_params = %{
:accountId => :query,
:"X-Workspace-ID" => :headers
}
request =
%{}
|> method(:delete)
|> url("/v1/sheets/#{id}")
|> add_optional_params(optional_params, opts)
|> Enum.into([])
connection
|> Connection.request(request)
|> evaluate_response([
{200, Spatio.Model.SuccessFlag},
{401, Spatio.Model.ApiError},
{404, Spatio.Model.ApiError}
])
end
@doc """
Delete a row.
### Parameters
- `connection` (Spatio.Connection): Connection to server
- `id` (String.t): Sheet id.
- `row_index` (integer()): Zero-based row index.
- `opts` (keyword): Optional parameters
- `:accountId` (String.t): Connected-account row id. Selects which provider account this request targets when more than one is connected. Mutually exclusive with `provider`. If omitted on a list endpoint the call fans out across every connected account.
- `:"X-Workspace-ID"` (String.t): Workspace scope for unscoped tokens. Workspace-scoped PATs and OAuth tokens carry this implicitly; for session/JWT auth without a scoped PAT, pass it explicitly.
### Returns
- `{:ok, Spatio.Model.SuccessFlag.t}` on success
- `{:error, Tesla.Env.t}` on failure
"""
@spec delete_sheet_row(Tesla.Env.client, String.t, integer(), keyword()) :: {:ok, Spatio.Model.ApiError.t} | {:ok, Spatio.Model.SuccessFlag.t} | {:error, Tesla.Env.t}
def delete_sheet_row(connection, id, row_index, opts \\ []) do
optional_params = %{
:accountId => :query,
:"X-Workspace-ID" => :headers
}
request =
%{}
|> method(:delete)
|> url("/v1/sheets/#{id}/rows/#{row_index}")
|> add_optional_params(optional_params, opts)
|> Enum.into([])
connection
|> Connection.request(request)
|> evaluate_response([
{200, Spatio.Model.SuccessFlag},
{400, Spatio.Model.ApiError},
{401, Spatio.Model.ApiError},
{404, Spatio.Model.ApiError}
])
end
@doc """
Fetch one sheet.
### Parameters
- `connection` (Spatio.Connection): Connection to server
- `id` (String.t): Sheet id.
- `opts` (keyword): Optional parameters
- `:accountId` (String.t): Connected-account row id. Selects which provider account this request targets when more than one is connected. Mutually exclusive with `provider`. If omitted on a list endpoint the call fans out across every connected account.
- `:"X-Workspace-ID"` (String.t): Workspace scope for unscoped tokens. Workspace-scoped PATs and OAuth tokens carry this implicitly; for session/JWT auth without a scoped PAT, pass it explicitly.
### Returns
- `{:ok, Spatio.Model.Sheet.t}` on success
- `{:error, Tesla.Env.t}` on failure
"""
@spec get_sheet(Tesla.Env.client, String.t, keyword()) :: {:ok, Spatio.Model.Sheet.t} | {:ok, Spatio.Model.ApiError.t} | {:ok, Spatio.Model.CreateNote400Response.t} | {:error, Tesla.Env.t}
def get_sheet(connection, id, opts \\ []) do
optional_params = %{
:accountId => :query,
:"X-Workspace-ID" => :headers
}
request =
%{}
|> method(:get)
|> url("/v1/sheets/#{id}")
|> add_optional_params(optional_params, opts)
|> Enum.into([])
connection
|> Connection.request(request)
|> evaluate_response([
{200, Spatio.Model.Sheet},
{400, Spatio.Model.CreateNote400Response},
{401, Spatio.Model.ApiError},
{404, Spatio.Model.ApiError}
])
end
@doc """
List rows in a sheet.
Single-account row list. Unlike `GET /v1/sheets`, row listing always targets the one account that owns the sheet, so the response is a plain `{ rows, total }` rather than a fan-out envelope.
### Parameters
- `connection` (Spatio.Connection): Connection to server
- `id` (String.t): Sheet id.
- `opts` (keyword): Optional parameters
- `:accountId` (String.t): Connected-account row id. Selects which provider account this request targets when more than one is connected. Mutually exclusive with `provider`. If omitted on a list endpoint the call fans out across every connected account.
- `:"X-Workspace-ID"` (String.t): Workspace scope for unscoped tokens. Workspace-scoped PATs and OAuth tokens carry this implicitly; for session/JWT auth without a scoped PAT, pass it explicitly.
- `:limit` (integer()):
- `:offset` (integer()):
### Returns
- `{:ok, Spatio.Model.RowList.t}` on success
- `{:error, Tesla.Env.t}` on failure
"""
@spec list_sheet_rows(Tesla.Env.client, String.t, keyword()) :: {:ok, Spatio.Model.RowList.t} | {:ok, Spatio.Model.ApiError.t} | {:error, Tesla.Env.t}
def list_sheet_rows(connection, id, opts \\ []) do
optional_params = %{
:accountId => :query,
:"X-Workspace-ID" => :headers,
:limit => :query,
:offset => :query
}
request =
%{}
|> method(:get)
|> url("/v1/sheets/#{id}/rows")
|> add_optional_params(optional_params, opts)
|> Enum.into([])
connection
|> Connection.request(request)
|> evaluate_response([
{200, Spatio.Model.RowList},
{401, Spatio.Model.ApiError},
{404, Spatio.Model.ApiError}
])
end
@doc """
List sheets across connected accounts.
Fan-out list. Returns every sheet visible to the caller across every connected sheets provider, paginated by `limit` / `offset`. Pass `?accountId=` or `?provider=` to scope to a single source.
### Parameters
- `connection` (Spatio.Connection): Connection to server
- `opts` (keyword): Optional parameters
- `:accountId` (String.t): Connected-account row id. Selects which provider account this request targets when more than one is connected. Mutually exclusive with `provider`. If omitted on a list endpoint the call fans out across every connected account.
- `:provider` (String.t): Provider id (e.g. `native-notes`, `notion`). Selects every connected account for the provider. Mutually exclusive with `accountId`.
- `:"X-Workspace-ID"` (String.t): Workspace scope for unscoped tokens. Workspace-scoped PATs and OAuth tokens carry this implicitly; for session/JWT auth without a scoped PAT, pass it explicitly.
- `:limit` (integer()):
- `:offset` (integer()):
### Returns
- `{:ok, Spatio.Model.SheetListEnvelope.t}` on success
- `{:error, Tesla.Env.t}` on failure
"""
@spec list_sheets(Tesla.Env.client, keyword()) :: {:ok, Spatio.Model.SheetListEnvelope.t} | {:ok, Spatio.Model.ApiError.t} | {:error, Tesla.Env.t}
def list_sheets(connection, opts \\ []) do
optional_params = %{
:accountId => :query,
:provider => :query,
:"X-Workspace-ID" => :headers,
:limit => :query,
:offset => :query
}
request =
%{}
|> method(:get)
|> url("/v1/sheets")
|> add_optional_params(optional_params, opts)
|> Enum.into([])
connection
|> Connection.request(request)
|> evaluate_response([
{200, Spatio.Model.SheetListEnvelope},
{401, Spatio.Model.ApiError},
{500, Spatio.Model.ApiError}
])
end
@doc """
Update a sheet (partial).
Partial update of sheet metadata. The renderer also calls this via `PUT /v1/sheets/{id}` for autosave parity; both verbs invoke the same handler. Per-cell and per-row mutations live on their dedicated endpoints, not here.
### Parameters
- `connection` (Spatio.Connection): Connection to server
- `id` (String.t): Sheet id.
- `update_sheet_request` (UpdateSheetRequest):
- `opts` (keyword): Optional parameters
- `:accountId` (String.t): Connected-account row id. Selects which provider account this request targets when more than one is connected. Mutually exclusive with `provider`. If omitted on a list endpoint the call fans out across every connected account.
- `:"X-Workspace-ID"` (String.t): Workspace scope for unscoped tokens. Workspace-scoped PATs and OAuth tokens carry this implicitly; for session/JWT auth without a scoped PAT, pass it explicitly.
### Returns
- `{:ok, Spatio.Model.Sheet.t}` on success
- `{:error, Tesla.Env.t}` on failure
"""
@spec update_sheet(Tesla.Env.client, String.t, Spatio.Model.UpdateSheetRequest.t, keyword()) :: {:ok, Spatio.Model.Sheet.t} | {:ok, Spatio.Model.ApiError.t} | {:error, Tesla.Env.t}
def update_sheet(connection, id, update_sheet_request, opts \\ []) do
optional_params = %{
:accountId => :query,
:"X-Workspace-ID" => :headers
}
request =
%{}
|> method(:patch)
|> url("/v1/sheets/#{id}")
|> add_param(:body, :body, update_sheet_request)
|> add_optional_params(optional_params, opts)
|> Enum.into([])
connection
|> Connection.request(request)
|> evaluate_response([
{200, Spatio.Model.Sheet},
{400, Spatio.Model.ApiError},
{401, Spatio.Model.ApiError},
{404, Spatio.Model.ApiError}
])
end
@doc """
Update a single cell.
### Parameters
- `connection` (Spatio.Connection): Connection to server
- `id` (String.t): Sheet id.
- `row_index` (integer()): Zero-based row index.
- `column` (String.t): Column identifier. Provider-specific — usually a letter (`A`, `AB`) for spreadsheet providers or a column key string for structured providers.
- `update_cell_request` (UpdateCellRequest):
- `opts` (keyword): Optional parameters
- `:accountId` (String.t): Connected-account row id. Selects which provider account this request targets when more than one is connected. Mutually exclusive with `provider`. If omitted on a list endpoint the call fans out across every connected account.
- `:"X-Workspace-ID"` (String.t): Workspace scope for unscoped tokens. Workspace-scoped PATs and OAuth tokens carry this implicitly; for session/JWT auth without a scoped PAT, pass it explicitly.
### Returns
- `{:ok, Spatio.Model.Cell.t}` on success
- `{:error, Tesla.Env.t}` on failure
"""
@spec update_sheet_cell(Tesla.Env.client, String.t, integer(), String.t, Spatio.Model.UpdateCellRequest.t, keyword()) :: {:ok, Spatio.Model.Cell.t} | {:ok, Spatio.Model.ApiError.t} | {:error, Tesla.Env.t}
def update_sheet_cell(connection, id, row_index, column, update_cell_request, opts \\ []) do
optional_params = %{
:accountId => :query,
:"X-Workspace-ID" => :headers
}
request =
%{}
|> method(:patch)
|> url("/v1/sheets/#{id}/rows/#{row_index}/cells/#{column}")
|> add_param(:body, :body, update_cell_request)
|> add_optional_params(optional_params, opts)
|> Enum.into([])
connection
|> Connection.request(request)
|> evaluate_response([
{200, Spatio.Model.Cell},
{400, Spatio.Model.ApiError},
{401, Spatio.Model.ApiError},
{404, Spatio.Model.ApiError}
])
end
@doc """
Update a row (sparse).
Sparse update — keys present in `cells` overwrite that column; keys absent are preserved.
### Parameters
- `connection` (Spatio.Connection): Connection to server
- `id` (String.t): Sheet id.
- `row_index` (integer()): Zero-based row index.
- `update_row_request` (UpdateRowRequest):
- `opts` (keyword): Optional parameters
- `:accountId` (String.t): Connected-account row id. Selects which provider account this request targets when more than one is connected. Mutually exclusive with `provider`. If omitted on a list endpoint the call fans out across every connected account.
- `:"X-Workspace-ID"` (String.t): Workspace scope for unscoped tokens. Workspace-scoped PATs and OAuth tokens carry this implicitly; for session/JWT auth without a scoped PAT, pass it explicitly.
### Returns
- `{:ok, Spatio.Model.Row.t}` on success
- `{:error, Tesla.Env.t}` on failure
"""
@spec update_sheet_row(Tesla.Env.client, String.t, integer(), Spatio.Model.UpdateRowRequest.t, keyword()) :: {:ok, Spatio.Model.ApiError.t} | {:ok, Spatio.Model.Row.t} | {:error, Tesla.Env.t}
def update_sheet_row(connection, id, row_index, update_row_request, opts \\ []) do
optional_params = %{
:accountId => :query,
:"X-Workspace-ID" => :headers
}
request =
%{}
|> method(:patch)
|> url("/v1/sheets/#{id}/rows/#{row_index}")
|> add_param(:body, :body, update_row_request)
|> add_optional_params(optional_params, opts)
|> Enum.into([])
connection
|> Connection.request(request)
|> evaluate_response([
{200, Spatio.Model.Row},
{400, Spatio.Model.ApiError},
{401, Spatio.Model.ApiError},
{404, Spatio.Model.ApiError}
])
end
end