# 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.Resources do
@moduledoc """
API calls for all endpoints tagged `Resources`.
"""
alias Spatio.Connection
import Spatio.RequestBuilder
@doc """
List access grants on a resource (per-resource ACL).
### Parameters
- `connection` (Spatio.Connection): Connection to server
- `platform` (String.t):
- `resource_id` (String.t):
- `opts` (keyword): Optional parameters
### Returns
- `{:ok, %{}}` on success
- `{:error, Tesla.Env.t}` on failure
"""
@spec list_resource_permission_grants(Tesla.Env.client, String.t, String.t, keyword()) :: {:ok, %{optional(String.t) => any()}} | {:ok, Spatio.Model.ApiError.t} | {:error, Tesla.Env.t}
def list_resource_permission_grants(connection, platform, resource_id, _opts \\ []) do
request =
%{}
|> method(:get)
|> url("/v1/resources/#{platform}/#{resource_id}/permissions")
|> Enum.into([])
connection
|> Connection.request(request)
|> evaluate_response([
{200, %{}},
{401, Spatio.Model.ApiError}
])
end
@doc """
Revoke an access grant.
### Parameters
- `connection` (Spatio.Connection): Connection to server
- `platform` (String.t):
- `resource_id` (String.t):
- `grant_id` (String.t):
- `opts` (keyword): Optional parameters
### Returns
- `{:ok, nil}` on success
- `{:error, Tesla.Env.t}` on failure
"""
@spec revoke_resource_permission_grant(Tesla.Env.client, String.t, String.t, String.t, keyword()) :: {:ok, nil} | {:ok, Spatio.Model.ApiError.t} | {:error, Tesla.Env.t}
def revoke_resource_permission_grant(connection, platform, resource_id, grant_id, _opts \\ []) do
request =
%{}
|> method(:delete)
|> url("/v1/resources/#{platform}/#{resource_id}/permissions/#{grant_id}")
|> Enum.into([])
connection
|> Connection.request(request)
|> evaluate_response([
{204, false},
{401, Spatio.Model.ApiError}
])
end
@doc """
Create or update an access grant.
### Parameters
- `connection` (Spatio.Connection): Connection to server
- `platform` (String.t):
- `resource_id` (String.t):
- `request_body` (%{optional(String.t) => any()}):
- `opts` (keyword): Optional parameters
### Returns
- `{:ok, %{}}` on success
- `{:error, Tesla.Env.t}` on failure
"""
@spec set_resource_permission_grant(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 set_resource_permission_grant(connection, platform, resource_id, request_body, _opts \\ []) do
request =
%{}
|> method(:post)
|> url("/v1/resources/#{platform}/#{resource_id}/permissions")
|> add_param(:body, :body, request_body)
|> Enum.into([])
connection
|> Connection.request(request)
|> evaluate_response([
{200, %{}},
{401, Spatio.Model.ApiError}
])
end
end