# 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.Notes do
@moduledoc """
API calls for all endpoints tagged `Notes`.
"""
alias Spatio.Connection
import Spatio.RequestBuilder
@doc """
Insert a block in a note.
### Parameters
- `connection` (Spatio.Connection): Connection to server
- `id` (String.t): Note id.
- `create_block_request` (CreateBlockRequest):
- `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.Block.t}` on success
- `{:error, Tesla.Env.t}` on failure
"""
@spec create_block(Tesla.Env.client, String.t, Spatio.Model.CreateBlockRequest.t, keyword()) :: {:ok, Spatio.Model.ApiError.t} | {:ok, Spatio.Model.Block.t} | {:error, Tesla.Env.t}
def create_block(connection, id, create_block_request, opts \\ []) do
optional_params = %{
:accountId => :query,
:"X-Workspace-ID" => :headers
}
request =
%{}
|> method(:post)
|> url("/v1/notes/#{id}/blocks")
|> add_param(:body, :body, create_block_request)
|> add_optional_params(optional_params, opts)
|> Enum.into([])
connection
|> Connection.request(request)
|> evaluate_response([
{201, Spatio.Model.Block},
{400, Spatio.Model.ApiError},
{401, Spatio.Model.ApiError},
{404, Spatio.Model.ApiError}
])
end
@doc """
Create a note.
Creates a new note under the target account. The target is resolved in this order: `accountId` field on the body → `?accountId=` query → `provider` field on the body → `?provider=` query → the 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_note_request` (CreateNoteRequest):
- `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.Note.t}` on success
- `{:error, Tesla.Env.t}` on failure
"""
@spec create_note(Tesla.Env.client, Spatio.Model.CreateNoteRequest.t, keyword()) :: {:ok, Spatio.Model.Note.t} | {:ok, Spatio.Model.ApiError.t} | {:ok, Spatio.Model.CreateNote400Response.t} | {:error, Tesla.Env.t}
def create_note(connection, create_note_request, opts \\ []) do
optional_params = %{
:accountId => :query,
:provider => :query,
:"X-Workspace-ID" => :headers
}
request =
%{}
|> method(:post)
|> url("/v1/notes")
|> add_param(:body, :body, create_note_request)
|> add_optional_params(optional_params, opts)
|> Enum.into([])
connection
|> Connection.request(request)
|> evaluate_response([
{201, Spatio.Model.Note},
{400, Spatio.Model.CreateNote400Response},
{401, Spatio.Model.ApiError},
{500, Spatio.Model.ApiError}
])
end
@doc """
Create a comment or reply.
### Parameters
- `connection` (Spatio.Connection): Connection to server
- `id` (String.t): Note id.
- `create_comment_request` (CreateCommentRequest):
- `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.CommentMutationResponse.t}` on success
- `{:error, Tesla.Env.t}` on failure
"""
@spec create_note_comment(Tesla.Env.client, String.t, Spatio.Model.CreateCommentRequest.t, keyword()) :: {:ok, Spatio.Model.CommentMutationResponse.t} | {:ok, Spatio.Model.ApiError.t} | {:error, Tesla.Env.t}
def create_note_comment(connection, id, create_comment_request, opts \\ []) do
optional_params = %{
:accountId => :query,
:"X-Workspace-ID" => :headers
}
request =
%{}
|> method(:post)
|> url("/v1/notes/#{id}/comments")
|> add_param(:body, :body, create_comment_request)
|> add_optional_params(optional_params, opts)
|> Enum.into([])
connection
|> Connection.request(request)
|> evaluate_response([
{200, Spatio.Model.CommentMutationResponse},
{400, Spatio.Model.ApiError},
{401, Spatio.Model.ApiError}
])
end
@doc """
Delete a block.
### Parameters
- `connection` (Spatio.Connection): Connection to server
- `id` (String.t): Block 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_block(Tesla.Env.client, String.t, keyword()) :: {:ok, Spatio.Model.ApiError.t} | {:ok, Spatio.Model.SuccessFlag.t} | {:error, Tesla.Env.t}
def delete_block(connection, id, opts \\ []) do
optional_params = %{
:accountId => :query,
:"X-Workspace-ID" => :headers
}
request =
%{}
|> method(:delete)
|> url("/v1/notes/blocks/#{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 note.
### Parameters
- `connection` (Spatio.Connection): Connection to server
- `id` (String.t): Note 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_note(Tesla.Env.client, String.t, keyword()) :: {:ok, Spatio.Model.ApiError.t} | {:ok, Spatio.Model.SuccessFlag.t} | {:error, Tesla.Env.t}
def delete_note(connection, id, opts \\ []) do
optional_params = %{
:accountId => :query,
:"X-Workspace-ID" => :headers
}
request =
%{}
|> method(:delete)
|> url("/v1/notes/#{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 """
Soft-delete (native) or hard-delete (provider) a comment.
Allowed for the comment author and for the note owner.
### Parameters
- `connection` (Spatio.Connection): Connection to server
- `id` (String.t): Note id.
- `comment_id` (String.t): Comment 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_note_comment(Tesla.Env.client, String.t, String.t, keyword()) :: {:ok, Spatio.Model.ApiError.t} | {:ok, Spatio.Model.SuccessFlag.t} | {:error, Tesla.Env.t}
def delete_note_comment(connection, id, comment_id, opts \\ []) do
optional_params = %{
:accountId => :query,
:"X-Workspace-ID" => :headers
}
request =
%{}
|> method(:delete)
|> url("/v1/notes/#{id}/comments/#{comment_id}")
|> 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},
{403, Spatio.Model.ApiError},
{404, Spatio.Model.ApiError}
])
end
@doc """
Disable public sharing.
Owner-only. Subsequent public viewer requests 404.
### Parameters
- `connection` (Spatio.Connection): Connection to server
- `id` (String.t): Note 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, nil}` on success
- `{:error, Tesla.Env.t}` on failure
"""
@spec disable_note_share(Tesla.Env.client, String.t, keyword()) :: {:ok, nil} | {:ok, Spatio.Model.ApiError.t} | {:error, Tesla.Env.t}
def disable_note_share(connection, id, opts \\ []) do
optional_params = %{
:accountId => :query,
:"X-Workspace-ID" => :headers
}
request =
%{}
|> method(:delete)
|> url("/v1/notes/#{id}/share")
|> add_optional_params(optional_params, opts)
|> Enum.into([])
connection
|> Connection.request(request)
|> evaluate_response([
{204, false},
{401, Spatio.Model.ApiError},
{403, Spatio.Model.ApiError},
{404, Spatio.Model.ApiError}
])
end
@doc """
Enable (or update password on) public sharing.
Owner-only. Calling with an empty body or `setPassword: false` flips the note public without changing the password. With `setPassword: true`, applies `password` (empty string clears).
### Parameters
- `connection` (Spatio.Connection): Connection to server
- `id` (String.t): Note 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.
- `:body` (EnableShareRequest):
### Returns
- `{:ok, Spatio.Model.ShareSettings.t}` on success
- `{:error, Tesla.Env.t}` on failure
"""
@spec enable_note_share(Tesla.Env.client, String.t, keyword()) :: {:ok, Spatio.Model.ShareSettings.t} | {:ok, Spatio.Model.ApiError.t} | {:error, Tesla.Env.t}
def enable_note_share(connection, id, opts \\ []) do
optional_params = %{
:accountId => :query,
:"X-Workspace-ID" => :headers,
:body => :body
}
request =
%{}
|> method(:post)
|> url("/v1/notes/#{id}/share")
|> add_optional_params(optional_params, opts)
|> ensure_body()
|> Enum.into([])
connection
|> Connection.request(request)
|> evaluate_response([
{200, Spatio.Model.ShareSettings},
{400, Spatio.Model.ApiError},
{401, Spatio.Model.ApiError},
{403, Spatio.Model.ApiError},
{404, Spatio.Model.ApiError}
])
end
@doc """
Fetch one block.
### Parameters
- `connection` (Spatio.Connection): Connection to server
- `id` (String.t): Block 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.Block.t}` on success
- `{:error, Tesla.Env.t}` on failure
"""
@spec get_block(Tesla.Env.client, String.t, keyword()) :: {:ok, Spatio.Model.ApiError.t} | {:ok, Spatio.Model.Block.t} | {:error, Tesla.Env.t}
def get_block(connection, id, opts \\ []) do
optional_params = %{
:accountId => :query,
:"X-Workspace-ID" => :headers
}
request =
%{}
|> method(:get)
|> url("/v1/notes/blocks/#{id}")
|> add_optional_params(optional_params, opts)
|> Enum.into([])
connection
|> Connection.request(request)
|> evaluate_response([
{200, Spatio.Model.Block},
{400, Spatio.Model.ApiError},
{401, Spatio.Model.ApiError},
{404, Spatio.Model.ApiError}
])
end
@doc """
Fetch one note.
### Parameters
- `connection` (Spatio.Connection): Connection to server
- `id` (String.t): Note 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.Note.t}` on success
- `{:error, Tesla.Env.t}` on failure
"""
@spec get_note(Tesla.Env.client, String.t, keyword()) :: {:ok, Spatio.Model.Note.t} | {:ok, Spatio.Model.ApiError.t} | {:ok, Spatio.Model.CreateNote400Response.t} | {:error, Tesla.Env.t}
def get_note(connection, id, opts \\ []) do
optional_params = %{
:accountId => :query,
:"X-Workspace-ID" => :headers
}
request =
%{}
|> method(:get)
|> url("/v1/notes/#{id}")
|> add_optional_params(optional_params, opts)
|> Enum.into([])
connection
|> Connection.request(request)
|> evaluate_response([
{200, Spatio.Model.Note},
{400, Spatio.Model.CreateNote400Response},
{401, Spatio.Model.ApiError},
{404, Spatio.Model.ApiError}
])
end
@doc """
Fetch one comment.
Useful for permalink hydration when the renderer deep-links into a reply thread.
### Parameters
- `connection` (Spatio.Connection): Connection to server
- `id` (String.t): Note id.
- `comment_id` (String.t): Comment 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.CommentResponse.t}` on success
- `{:error, Tesla.Env.t}` on failure
"""
@spec get_note_comment(Tesla.Env.client, String.t, String.t, keyword()) :: {:ok, Spatio.Model.CommentResponse.t} | {:ok, Spatio.Model.ApiError.t} | {:error, Tesla.Env.t}
def get_note_comment(connection, id, comment_id, opts \\ []) do
optional_params = %{
:accountId => :query,
:"X-Workspace-ID" => :headers
}
request =
%{}
|> method(:get)
|> url("/v1/notes/#{id}/comments/#{comment_id}")
|> add_optional_params(optional_params, opts)
|> Enum.into([])
connection
|> Connection.request(request)
|> evaluate_response([
{200, Spatio.Model.CommentResponse},
{400, Spatio.Model.ApiError},
{401, Spatio.Model.ApiError},
{404, Spatio.Model.ApiError}
])
end
@doc """
Fetch share settings for a note.
Owner-only. Returns the current public-share configuration, including the share token and computed public viewer URL when the note is currently public.
### Parameters
- `connection` (Spatio.Connection): Connection to server
- `id` (String.t): Note 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.ShareSettings.t}` on success
- `{:error, Tesla.Env.t}` on failure
"""
@spec get_note_share_settings(Tesla.Env.client, String.t, keyword()) :: {:ok, Spatio.Model.ShareSettings.t} | {:ok, Spatio.Model.ApiError.t} | {:error, Tesla.Env.t}
def get_note_share_settings(connection, id, opts \\ []) do
optional_params = %{
:accountId => :query,
:"X-Workspace-ID" => :headers
}
request =
%{}
|> method(:get)
|> url("/v1/notes/#{id}/share")
|> add_optional_params(optional_params, opts)
|> Enum.into([])
connection
|> Connection.request(request)
|> evaluate_response([
{200, Spatio.Model.ShareSettings},
{401, Spatio.Model.ApiError},
{403, Spatio.Model.ApiError},
{404, Spatio.Model.ApiError}
])
end
@doc """
Fetch a publicly shared note.
Unauthenticated. The share token is the credential. For password-protected notes the password is supplied via the `?password=` query param; the response distinguishes \"no password supplied\" from \"wrong password\" so the viewer can render the right prompt. Unknown tokens and disabled-share notes both return `404` to prevent token enumeration.
### Parameters
- `connection` (Spatio.Connection): Connection to server
- `token` (String.t): Opaque public-share token.
- `opts` (keyword): Optional parameters
- `:password` (String.t): Optional viewer password.
### Returns
- `{:ok, %{}}` on success
- `{:error, Tesla.Env.t}` on failure
"""
@spec get_public_note(Tesla.Env.client, String.t, keyword()) :: {:ok, %{optional(String.t) => any()}} | {:ok, Spatio.Model.ApiError.t} | {:ok, Spatio.Model.PasswordRequiredError.t} | {:error, Tesla.Env.t}
def get_public_note(connection, token, opts \\ []) do
optional_params = %{
:password => :query
}
request =
%{}
|> method(:get)
|> url("/public/notes/#{token}")
|> add_optional_params(optional_params, opts)
|> Enum.into([])
connection
|> Connection.request(request)
|> evaluate_response([
{200, %{}},
{400, Spatio.Model.ApiError},
{401, Spatio.Model.PasswordRequiredError},
{404, Spatio.Model.ApiError},
{500, Spatio.Model.ApiError}
])
end
@doc """
List blocks under a note.
Returns the block tree for a note, paginated. Block listing always targets a single account (the one that owns the note) so it does not fan out — the response is a plain `{ blocks, total }`.
### Parameters
- `connection` (Spatio.Connection): Connection to server
- `id` (String.t): Note 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.
- `:parent_id` (String.t): Filter to children of this block id. Omit to list root-level blocks.
- `:limit` (integer()):
- `:offset` (integer()):
### Returns
- `{:ok, Spatio.Model.BlockListResponse.t}` on success
- `{:error, Tesla.Env.t}` on failure
"""
@spec list_blocks(Tesla.Env.client, String.t, keyword()) :: {:ok, Spatio.Model.BlockListResponse.t} | {:ok, Spatio.Model.ApiError.t} | {:error, Tesla.Env.t}
def list_blocks(connection, id, opts \\ []) do
optional_params = %{
:accountId => :query,
:"X-Workspace-ID" => :headers,
:parent_id => :query,
:limit => :query,
:offset => :query
}
request =
%{}
|> method(:get)
|> url("/v1/notes/#{id}/blocks")
|> add_optional_params(optional_params, opts)
|> Enum.into([])
connection
|> Connection.request(request)
|> evaluate_response([
{200, Spatio.Model.BlockListResponse},
{401, Spatio.Model.ApiError},
{404, Spatio.Model.ApiError}
])
end
@doc """
List comments on a note.
Returns active (non-deleted) comments. When `?accountId=` targets an external provider that supports comments (e.g. Notion), the provider is queried directly; otherwise the native store is used.
### Parameters
- `connection` (Spatio.Connection): Connection to server
- `id` (String.t): Note 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.CommentListResponse.t}` on success
- `{:error, Tesla.Env.t}` on failure
"""
@spec list_note_comments(Tesla.Env.client, String.t, keyword()) :: {:ok, Spatio.Model.ApiError.t} | {:ok, Spatio.Model.CommentListResponse.t} | {:error, Tesla.Env.t}
def list_note_comments(connection, id, opts \\ []) do
optional_params = %{
:accountId => :query,
:"X-Workspace-ID" => :headers
}
request =
%{}
|> method(:get)
|> url("/v1/notes/#{id}/comments")
|> add_optional_params(optional_params, opts)
|> Enum.into([])
connection
|> Connection.request(request)
|> evaluate_response([
{200, Spatio.Model.CommentListResponse},
{400, Spatio.Model.ApiError},
{401, Spatio.Model.ApiError}
])
end
@doc """
List notes across connected accounts.
Fan-out list. Returns every note visible to the caller across every connected notes 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.
- `:archived` (boolean()): When `true`, return archived notes instead of active ones.
- `:parent_id` (String.t): Filter to notes nested under this parent note id.
- `:tags` ([String.t]): Repeatable. Filter to notes carrying every tag listed.
- `:limit` (integer()): Max items to return. Defaults to 50.
- `:offset` (integer()): Number of items to skip.
- `:sort_by` (String.t): Sort field. Provider-dependent; the native provider supports `updated_at`, `created_at`, `title`.
- `:sort_order` (String.t):
### Returns
- `{:ok, Spatio.Model.NoteListEnvelope.t}` on success
- `{:error, Tesla.Env.t}` on failure
"""
@spec list_notes(Tesla.Env.client, keyword()) :: {:ok, Spatio.Model.NoteListEnvelope.t} | {:ok, Spatio.Model.ApiError.t} | {:error, Tesla.Env.t}
def list_notes(connection, opts \\ []) do
optional_params = %{
:accountId => :query,
:provider => :query,
:"X-Workspace-ID" => :headers,
:archived => :query,
:parent_id => :query,
:tags => :query,
:limit => :query,
:offset => :query,
:sort_by => :query,
:sort_order => :query
}
request =
%{}
|> method(:get)
|> url("/v1/notes")
|> add_optional_params(optional_params, opts)
|> Enum.into([])
connection
|> Connection.request(request)
|> evaluate_response([
{200, Spatio.Model.NoteListEnvelope},
{401, Spatio.Model.ApiError},
{500, Spatio.Model.ApiError}
])
end
@doc """
Reparent or reorder a block.
### Parameters
- `connection` (Spatio.Connection): Connection to server
- `id` (String.t): Block id.
- `move_block_request` (MoveBlockRequest):
- `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 move_block(Tesla.Env.client, String.t, Spatio.Model.MoveBlockRequest.t, keyword()) :: {:ok, Spatio.Model.ApiError.t} | {:ok, Spatio.Model.SuccessFlag.t} | {:error, Tesla.Env.t}
def move_block(connection, id, move_block_request, opts \\ []) do
optional_params = %{
:accountId => :query,
:"X-Workspace-ID" => :headers
}
request =
%{}
|> method(:post)
|> url("/v1/notes/blocks/#{id}/move")
|> add_param(:body, :body, move_block_request)
|> 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 """
Rotate the share token, invalidating any outstanding URLs.
### Parameters
- `connection` (Spatio.Connection): Connection to server
- `id` (String.t): Note 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.ShareSettings.t}` on success
- `{:error, Tesla.Env.t}` on failure
"""
@spec rotate_note_share_token(Tesla.Env.client, String.t, keyword()) :: {:ok, Spatio.Model.ShareSettings.t} | {:ok, Spatio.Model.ApiError.t} | {:error, Tesla.Env.t}
def rotate_note_share_token(connection, id, opts \\ []) do
optional_params = %{
:accountId => :query,
:"X-Workspace-ID" => :headers
}
request =
%{}
|> method(:post)
|> url("/v1/notes/#{id}/share/rotate")
|> add_optional_params(optional_params, opts)
|> ensure_body()
|> Enum.into([])
connection
|> Connection.request(request)
|> evaluate_response([
{200, Spatio.Model.ShareSettings},
{401, Spatio.Model.ApiError},
{403, Spatio.Model.ApiError},
{404, Spatio.Model.ApiError}
])
end
@doc """
Update a block (partial).
### Parameters
- `connection` (Spatio.Connection): Connection to server
- `id` (String.t): Block id.
- `update_block_request` (UpdateBlockRequest):
- `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.Block.t}` on success
- `{:error, Tesla.Env.t}` on failure
"""
@spec update_block(Tesla.Env.client, String.t, Spatio.Model.UpdateBlockRequest.t, keyword()) :: {:ok, Spatio.Model.ApiError.t} | {:ok, Spatio.Model.Block.t} | {:error, Tesla.Env.t}
def update_block(connection, id, update_block_request, opts \\ []) do
optional_params = %{
:accountId => :query,
:"X-Workspace-ID" => :headers
}
request =
%{}
|> method(:patch)
|> url("/v1/notes/blocks/#{id}")
|> add_param(:body, :body, update_block_request)
|> add_optional_params(optional_params, opts)
|> Enum.into([])
connection
|> Connection.request(request)
|> evaluate_response([
{200, Spatio.Model.Block},
{400, Spatio.Model.ApiError},
{401, Spatio.Model.ApiError},
{404, Spatio.Model.ApiError}
])
end
@doc """
Update a note (partial).
### Parameters
- `connection` (Spatio.Connection): Connection to server
- `id` (String.t): Note id.
- `update_note_request` (UpdateNoteRequest):
- `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.Note.t}` on success
- `{:error, Tesla.Env.t}` on failure
"""
@spec update_note(Tesla.Env.client, String.t, Spatio.Model.UpdateNoteRequest.t, keyword()) :: {:ok, Spatio.Model.Note.t} | {:ok, Spatio.Model.ApiError.t} | {:error, Tesla.Env.t}
def update_note(connection, id, update_note_request, opts \\ []) do
optional_params = %{
:accountId => :query,
:"X-Workspace-ID" => :headers
}
request =
%{}
|> method(:patch)
|> url("/v1/notes/#{id}")
|> add_param(:body, :body, update_note_request)
|> add_optional_params(optional_params, opts)
|> Enum.into([])
connection
|> Connection.request(request)
|> evaluate_response([
{200, Spatio.Model.Note},
{400, Spatio.Model.ApiError},
{401, Spatio.Model.ApiError},
{404, Spatio.Model.ApiError}
])
end
@doc """
Edit a comment.
Only the comment author can edit. The note owner can delete via `DELETE` but cannot rewrite.
### Parameters
- `connection` (Spatio.Connection): Connection to server
- `id` (String.t): Note id.
- `comment_id` (String.t): Comment id.
- `update_comment_request` (UpdateCommentRequest):
- `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.CommentMutationResponse.t}` on success
- `{:error, Tesla.Env.t}` on failure
"""
@spec update_note_comment(Tesla.Env.client, String.t, String.t, Spatio.Model.UpdateCommentRequest.t, keyword()) :: {:ok, Spatio.Model.CommentMutationResponse.t} | {:ok, Spatio.Model.ApiError.t} | {:error, Tesla.Env.t}
def update_note_comment(connection, id, comment_id, update_comment_request, opts \\ []) do
optional_params = %{
:accountId => :query,
:"X-Workspace-ID" => :headers
}
request =
%{}
|> method(:patch)
|> url("/v1/notes/#{id}/comments/#{comment_id}")
|> add_param(:body, :body, update_comment_request)
|> add_optional_params(optional_params, opts)
|> Enum.into([])
connection
|> Connection.request(request)
|> evaluate_response([
{200, Spatio.Model.CommentMutationResponse},
{400, Spatio.Model.ApiError},
{401, Spatio.Model.ApiError},
{403, Spatio.Model.ApiError},
{404, 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_note(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_note(connection, org, workspace, request_body, _opts \\ []) do
request =
%{}
|> method(:post)
|> url("/v1/organizations/#{org}/workspaces/#{workspace}/notes")
|> 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):
- `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_create_note_block(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_create_note_block(connection, org, workspace, id, request_body, _opts \\ []) do
request =
%{}
|> method(:post)
|> url("/v1/organizations/#{org}/workspaces/#{workspace}/notes/#{id}/blocks")
|> 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):
- `id` (String.t):
- `opts` (keyword): Optional parameters
### Returns
- `{:ok, nil}` on success
- `{:error, Tesla.Env.t}` on failure
"""
@spec workspace_delete_note(Tesla.Env.client, String.t, String.t, String.t, keyword()) :: {:ok, nil} | {:ok, Spatio.Model.ApiError.t} | {:error, Tesla.Env.t}
def workspace_delete_note(connection, org, workspace, id, _opts \\ []) do
request =
%{}
|> method(:delete)
|> url("/v1/organizations/#{org}/workspaces/#{workspace}/notes/#{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):
- `opts` (keyword): Optional parameters
### Returns
- `{:ok, nil}` on success
- `{:error, Tesla.Env.t}` on failure
"""
@spec workspace_delete_note_block(Tesla.Env.client, String.t, String.t, String.t, keyword()) :: {:ok, nil} | {:ok, Spatio.Model.ApiError.t} | {:error, Tesla.Env.t}
def workspace_delete_note_block(connection, org, workspace, id, _opts \\ []) do
request =
%{}
|> method(:delete)
|> url("/v1/organizations/#{org}/workspaces/#{workspace}/notes/blocks/#{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):
- `opts` (keyword): Optional parameters
### Returns
- `{:ok, %{}}` on success
- `{:error, Tesla.Env.t}` on failure
"""
@spec workspace_get_note(Tesla.Env.client, String.t, String.t, String.t, keyword()) :: {:ok, %{optional(String.t) => any()}} | {:ok, Spatio.Model.ApiError.t} | {:error, Tesla.Env.t}
def workspace_get_note(connection, org, workspace, id, _opts \\ []) do
request =
%{}
|> method(:get)
|> url("/v1/organizations/#{org}/workspaces/#{workspace}/notes/#{id}")
|> Enum.into([])
connection
|> Connection.request(request)
|> evaluate_response([
{200, %{}},
{401, Spatio.Model.ApiError},
{403, Spatio.Model.ApiError},
{404, 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, %{}}` on success
- `{:error, Tesla.Env.t}` on failure
"""
@spec workspace_get_note_block(Tesla.Env.client, String.t, String.t, String.t, keyword()) :: {:ok, %{optional(String.t) => any()}} | {:ok, Spatio.Model.ApiError.t} | {:error, Tesla.Env.t}
def workspace_get_note_block(connection, org, workspace, id, _opts \\ []) do
request =
%{}
|> method(:get)
|> url("/v1/organizations/#{org}/workspaces/#{workspace}/notes/blocks/#{id}")
|> Enum.into([])
connection
|> Connection.request(request)
|> evaluate_response([
{200, %{}},
{401, Spatio.Model.ApiError},
{403, Spatio.Model.ApiError},
{404, 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, %{}}` on success
- `{:error, Tesla.Env.t}` on failure
"""
@spec workspace_list_note_blocks(Tesla.Env.client, String.t, String.t, String.t, keyword()) :: {:ok, %{optional(String.t) => any()}} | {:ok, Spatio.Model.ApiError.t} | {:error, Tesla.Env.t}
def workspace_list_note_blocks(connection, org, workspace, id, _opts \\ []) do
request =
%{}
|> method(:get)
|> url("/v1/organizations/#{org}/workspaces/#{workspace}/notes/#{id}/blocks")
|> 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):
- `opts` (keyword): Optional parameters
### Returns
- `{:ok, %{}}` on success
- `{:error, Tesla.Env.t}` on failure
"""
@spec workspace_list_notes(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_notes(connection, org, workspace, _opts \\ []) do
request =
%{}
|> method(:get)
|> url("/v1/organizations/#{org}/workspaces/#{workspace}/notes")
|> 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):
- `request_body` (%{optional(String.t) => any()}):
- `opts` (keyword): Optional parameters
### Returns
- `{:ok, %{}}` on success
- `{:error, Tesla.Env.t}` on failure
"""
@spec workspace_move_note_block(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_move_note_block(connection, org, workspace, id, request_body, _opts \\ []) do
request =
%{}
|> method(:post)
|> url("/v1/organizations/#{org}/workspaces/#{workspace}/notes/blocks/#{id}/move")
|> add_param(:body, :body, request_body)
|> 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):
- `request_body` (%{optional(String.t) => any()}):
- `opts` (keyword): Optional parameters
### Returns
- `{:ok, %{}}` on success
- `{:error, Tesla.Env.t}` on failure
"""
@spec workspace_update_note(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_note(connection, org, workspace, id, request_body, _opts \\ []) do
request =
%{}
|> method(:patch)
|> url("/v1/organizations/#{org}/workspaces/#{workspace}/notes/#{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
@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_note_block(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_note_block(connection, org, workspace, id, request_body, _opts \\ []) do
request =
%{}
|> method(:patch)
|> url("/v1/organizations/#{org}/workspaces/#{workspace}/notes/blocks/#{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