# NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). # https://openapi-generator.tech # Do not edit the class manually. defmodule Ory.Api.Permission do @moduledoc """ API calls for all endpoints tagged `Permission`. """ alias Ory.Connection import Ory.RequestBuilder @doc """ Check a permission To learn how relationship tuples and the check works, head over to [the documentation](https://www.ory.sh/docs/keto/concepts/api-overview). ## Parameters - connection (Ory.Connection): Connection to server - opts (KeywordList): [optional] Optional parameters - :namespace (String.t): Namespace of the Relationship - :object (String.t): Object of the Relationship - :relation (String.t): Relation of the Relationship - :subject_id (String.t): SubjectID of the Relationship - :subject_set_periodnamespace (String.t): Namespace of the Subject Set - :subject_set_periodobject (String.t): Object of the Subject Set - :subject_set_periodrelation (String.t): Relation of the Subject Set - :max_depth (integer()): ## Returns {:ok, Ory.Model.CheckPermissionResult.t} on success {:error, Tesla.Env.t} on failure """ @spec check_permission(Tesla.Env.client, keyword()) :: {:ok, Ory.Model.CheckPermissionResult.t} | {:ok, Ory.Model.ErrorGeneric.t} | {:error, Tesla.Env.t} def check_permission(connection, opts \\ []) do optional_params = %{ :namespace => :query, :object => :query, :relation => :query, :subject_id => :query, :"subject_set.namespace" => :query, :"subject_set.object" => :query, :"subject_set.relation" => :query, :"max-depth" => :query } %{} |> method(:get) |> url("/relation-tuples/check/openapi") |> add_optional_params(optional_params, opts) |> Enum.into([]) |> (&Connection.request(connection, &1)).() |> evaluate_response([ { 200, %Ory.Model.CheckPermissionResult{}}, { 400, %Ory.Model.ErrorGeneric{}}, { :default, %Ory.Model.ErrorGeneric{}} ]) end @doc """ Check a permission To learn how relationship tuples and the check works, head over to [the documentation](https://www.ory.sh/docs/keto/concepts/api-overview). ## Parameters - connection (Ory.Connection): Connection to server - opts (KeywordList): [optional] Optional parameters - :namespace (String.t): Namespace of the Relationship - :object (String.t): Object of the Relationship - :relation (String.t): Relation of the Relationship - :subject_id (String.t): SubjectID of the Relationship - :subject_set_periodnamespace (String.t): Namespace of the Subject Set - :subject_set_periodobject (String.t): Object of the Subject Set - :subject_set_periodrelation (String.t): Relation of the Subject Set - :max_depth (integer()): ## Returns {:ok, Ory.Model.CheckPermissionResult.t} on success {:error, Tesla.Env.t} on failure """ @spec check_permission_or_error(Tesla.Env.client, keyword()) :: {:ok, Ory.Model.CheckPermissionResult.t} | {:ok, Ory.Model.ErrorGeneric.t} | {:error, Tesla.Env.t} def check_permission_or_error(connection, opts \\ []) do optional_params = %{ :namespace => :query, :object => :query, :relation => :query, :subject_id => :query, :"subject_set.namespace" => :query, :"subject_set.object" => :query, :"subject_set.relation" => :query, :"max-depth" => :query } %{} |> method(:get) |> url("/relation-tuples/check") |> add_optional_params(optional_params, opts) |> Enum.into([]) |> (&Connection.request(connection, &1)).() |> evaluate_response([ { 200, %Ory.Model.CheckPermissionResult{}}, { 400, %Ory.Model.ErrorGeneric{}}, { 403, %Ory.Model.CheckPermissionResult{}}, { :default, %Ory.Model.ErrorGeneric{}} ]) end @doc """ Expand a Relationship into permissions. Use this endpoint to expand a relationship tuple into permissions. ## Parameters - connection (Ory.Connection): Connection to server - namespace (String.t): Namespace of the Subject Set - object (String.t): Object of the Subject Set - relation (String.t): Relation of the Subject Set - opts (KeywordList): [optional] Optional parameters - :max_depth (integer()): ## Returns {:ok, Ory.Model.ExpandedPermissionTree.t} on success {:error, Tesla.Env.t} on failure """ @spec expand_permissions(Tesla.Env.client, String.t, String.t, String.t, keyword()) :: {:ok, Ory.Model.ErrorGeneric.t} | {:ok, Ory.Model.ExpandedPermissionTree.t} | {:error, Tesla.Env.t} def expand_permissions(connection, namespace, object, relation, opts \\ []) do optional_params = %{ :"max-depth" => :query } %{} |> method(:get) |> url("/relation-tuples/expand") |> add_param(:query, :namespace, namespace) |> add_param(:query, :object, object) |> add_param(:query, :relation, relation) |> add_optional_params(optional_params, opts) |> Enum.into([]) |> (&Connection.request(connection, &1)).() |> evaluate_response([ { 200, %Ory.Model.ExpandedPermissionTree{}}, { 400, %Ory.Model.ErrorGeneric{}}, { 404, %Ory.Model.ErrorGeneric{}}, { :default, %Ory.Model.ErrorGeneric{}} ]) end @doc """ Check a permission To learn how relationship tuples and the check works, head over to [the documentation](https://www.ory.sh/docs/keto/concepts/api-overview). ## Parameters - connection (Ory.Connection): Connection to server - opts (KeywordList): [optional] Optional parameters - :max_depth (integer()): - :body (PostCheckPermissionBody): ## Returns {:ok, Ory.Model.CheckPermissionResult.t} on success {:error, Tesla.Env.t} on failure """ @spec post_check_permission(Tesla.Env.client, keyword()) :: {:ok, Ory.Model.CheckPermissionResult.t} | {:ok, Ory.Model.ErrorGeneric.t} | {:error, Tesla.Env.t} def post_check_permission(connection, opts \\ []) do optional_params = %{ :"max-depth" => :query, :body => :body } %{} |> method(:post) |> url("/relation-tuples/check/openapi") |> add_optional_params(optional_params, opts) |> ensure_body() |> Enum.into([]) |> (&Connection.request(connection, &1)).() |> evaluate_response([ { 200, %Ory.Model.CheckPermissionResult{}}, { 400, %Ory.Model.ErrorGeneric{}}, { :default, %Ory.Model.ErrorGeneric{}} ]) end @doc """ Check a permission To learn how relationship tuples and the check works, head over to [the documentation](https://www.ory.sh/docs/keto/concepts/api-overview). ## Parameters - connection (Ory.Connection): Connection to server - opts (KeywordList): [optional] Optional parameters - :max_depth (integer()): - :body (PostCheckPermissionOrErrorBody): ## Returns {:ok, Ory.Model.CheckPermissionResult.t} on success {:error, Tesla.Env.t} on failure """ @spec post_check_permission_or_error(Tesla.Env.client, keyword()) :: {:ok, Ory.Model.CheckPermissionResult.t} | {:ok, Ory.Model.ErrorGeneric.t} | {:error, Tesla.Env.t} def post_check_permission_or_error(connection, opts \\ []) do optional_params = %{ :"max-depth" => :query, :body => :body } %{} |> method(:post) |> url("/relation-tuples/check") |> add_optional_params(optional_params, opts) |> ensure_body() |> Enum.into([]) |> (&Connection.request(connection, &1)).() |> evaluate_response([ { 200, %Ory.Model.CheckPermissionResult{}}, { 400, %Ory.Model.ErrorGeneric{}}, { 403, %Ory.Model.CheckPermissionResult{}}, { :default, %Ory.Model.ErrorGeneric{}} ]) end end