# 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.V0alpha2 do @moduledoc """ API calls for all endpoints tagged `V0alpha2`. """ alias Ory.Connection import Ory.RequestBuilder @doc """ Create an Identity This endpoint creates an identity. Learn how identities work in [Ory Kratos' User And Identity Model Documentation](https://www.ory.sh/docs/next/kratos/concepts/identity-user-model). ## Parameters - connection (Ory.Connection): Connection to server - opts (KeywordList): [optional] Optional parameters - :body (AdminCreateIdentityBody): ## Returns {:ok, Ory.Model.Identity.t} on success {:error, Tesla.Env.t} on failure """ @spec admin_create_identity(Tesla.Env.client, keyword()) :: {:ok, Ory.Model.JsonError.t} | {:ok, Ory.Model.Identity.t} | {:error, Tesla.Env.t} def admin_create_identity(connection, opts \\ []) do optional_params = %{ :body => :body } %{} |> method(:post) |> url("/admin/identities") |> add_optional_params(optional_params, opts) |> ensure_body() |> Enum.into([]) |> (&Connection.request(connection, &1)).() |> evaluate_response([ { 201, %Ory.Model.Identity{}}, { 400, %Ory.Model.JsonError{}}, { 409, %Ory.Model.JsonError{}}, { 500, %Ory.Model.JsonError{}} ]) end @doc """ Create a Recovery Link This endpoint creates a recovery link which should be given to the user in order for them to recover (or activate) their account. ## Parameters - connection (Ory.Connection): Connection to server - opts (KeywordList): [optional] Optional parameters - :body (AdminCreateSelfServiceRecoveryLinkBody): ## Returns {:ok, Ory.Model.SelfServiceRecoveryLink.t} on success {:error, Tesla.Env.t} on failure """ @spec admin_create_self_service_recovery_link(Tesla.Env.client, keyword()) :: {:ok, Ory.Model.SelfServiceRecoveryLink.t} | {:ok, Ory.Model.JsonError.t} | {:error, Tesla.Env.t} def admin_create_self_service_recovery_link(connection, opts \\ []) do optional_params = %{ :body => :body } %{} |> method(:post) |> url("/admin/recovery/link") |> add_optional_params(optional_params, opts) |> ensure_body() |> Enum.into([]) |> (&Connection.request(connection, &1)).() |> evaluate_response([ { 200, %Ory.Model.SelfServiceRecoveryLink{}}, { 400, %Ory.Model.JsonError{}}, { 404, %Ory.Model.JsonError{}}, { 500, %Ory.Model.JsonError{}} ]) end @doc """ Delete an Identity Calling this endpoint irrecoverably and permanently deletes the identity given its ID. This action can not be undone. This endpoint returns 204 when the identity was deleted or when the identity was not found, in which case it is assumed that is has been deleted already. Learn how identities work in [Ory Kratos' User And Identity Model Documentation](https://www.ory.sh/docs/next/kratos/concepts/identity-user-model). ## Parameters - connection (Ory.Connection): Connection to server - id (String.t): ID is the identity's ID. - opts (KeywordList): [optional] Optional parameters ## Returns {:ok, nil} on success {:error, Tesla.Env.t} on failure """ @spec admin_delete_identity(Tesla.Env.client, String.t, keyword()) :: {:ok, nil} | {:ok, Ory.Model.JsonError.t} | {:error, Tesla.Env.t} def admin_delete_identity(connection, id, _opts \\ []) do %{} |> method(:delete) |> url("/admin/identities/#{id}") |> Enum.into([]) |> (&Connection.request(connection, &1)).() |> evaluate_response([ { 204, false}, { 404, %Ory.Model.JsonError{}}, { 500, %Ory.Model.JsonError{}} ]) end @doc """ Calling this endpoint irrecoverably and permanently deletes and invalidates all sessions that belong to the given Identity. This endpoint is useful for: To forcefully logout Identity from all devices and sessions ## Parameters - connection (Ory.Connection): Connection to server - id (String.t): ID is the identity's ID. - opts (KeywordList): [optional] Optional parameters ## Returns {:ok, nil} on success {:error, Tesla.Env.t} on failure """ @spec admin_delete_identity_sessions(Tesla.Env.client, String.t, keyword()) :: {:ok, nil} | {:ok, Ory.Model.JsonError.t} | {:error, Tesla.Env.t} def admin_delete_identity_sessions(connection, id, _opts \\ []) do %{} |> method(:delete) |> url("/admin/identities/#{id}/sessions") |> Enum.into([]) |> (&Connection.request(connection, &1)).() |> evaluate_response([ { 204, false}, { 400, %Ory.Model.JsonError{}}, { 401, %Ory.Model.JsonError{}}, { 404, %Ory.Model.JsonError{}}, { 500, %Ory.Model.JsonError{}} ]) end @doc """ Calling this endpoint extends the given session ID. If `session.earliest_possible_extend` is set it will only extend the session after the specified time has passed. Retrieve the session ID from the `/sessions/whoami` endpoint / `toSession` SDK method. ## Parameters - connection (Ory.Connection): Connection to server - id (String.t): ID is the session's ID. - opts (KeywordList): [optional] Optional parameters ## Returns {:ok, Ory.Model.Session.t} on success {:error, Tesla.Env.t} on failure """ @spec admin_extend_session(Tesla.Env.client, String.t, keyword()) :: {:ok, Ory.Model.JsonError.t} | {:ok, Ory.Model.Session.t} | {:error, Tesla.Env.t} def admin_extend_session(connection, id, _opts \\ []) do %{} |> method(:patch) |> url("/admin/sessions/#{id}/extend") |> ensure_body() |> Enum.into([]) |> (&Connection.request(connection, &1)).() |> evaluate_response([ { 200, %Ory.Model.Session{}}, { 400, %Ory.Model.JsonError{}}, { 404, %Ory.Model.JsonError{}}, { 500, %Ory.Model.JsonError{}} ]) end @doc """ Get an Identity Learn how identities work in [Ory Kratos' User And Identity Model Documentation](https://www.ory.sh/docs/next/kratos/concepts/identity-user-model). ## Parameters - connection (Ory.Connection): Connection to server - id (String.t): ID must be set to the ID of identity you want to get - opts (KeywordList): [optional] Optional parameters - :include_credential ([String.t]): DeclassifyCredentials will declassify one or more identity's credentials Currently, only `oidc` is supported. This will return the initial OAuth 2.0 Access, Refresh and (optionally) OpenID Connect ID Token. ## Returns {:ok, Ory.Model.Identity.t} on success {:error, Tesla.Env.t} on failure """ @spec admin_get_identity(Tesla.Env.client, String.t, keyword()) :: {:ok, Ory.Model.JsonError.t} | {:ok, Ory.Model.Identity.t} | {:error, Tesla.Env.t} def admin_get_identity(connection, id, opts \\ []) do optional_params = %{ :include_credential => :query } %{} |> method(:get) |> url("/admin/identities/#{id}") |> add_optional_params(optional_params, opts) |> Enum.into([]) |> (&Connection.request(connection, &1)).() |> evaluate_response([ { 200, %Ory.Model.Identity{}}, { 404, %Ory.Model.JsonError{}}, { 500, %Ory.Model.JsonError{}} ]) end @doc """ List Identities Lists all identities. Does not support search at the moment. Learn how identities work in [Ory Kratos' User And Identity Model Documentation](https://www.ory.sh/docs/next/kratos/concepts/identity-user-model). ## Parameters - connection (Ory.Connection): Connection to server - opts (KeywordList): [optional] Optional parameters - :per_page (integer()): Items per Page This is the number of items per page. - :page (integer()): Pagination Page This value is currently an integer, but it is not sequential. The value is not the page number, but a reference. The next page can be any number and some numbers might return an empty list. For example, page 2 might not follow after page 1. And even if page 3 and 5 exist, but page 4 might not exist. ## Returns {:ok, [%Identity{}, ...]} on success {:error, Tesla.Env.t} on failure """ @spec admin_list_identities(Tesla.Env.client, keyword()) :: {:ok, Ory.Model.JsonError.t} | {:ok, list(Ory.Model.Identity.t)} | {:error, Tesla.Env.t} def admin_list_identities(connection, opts \\ []) do optional_params = %{ :per_page => :query, :page => :query } %{} |> method(:get) |> url("/admin/identities") |> add_optional_params(optional_params, opts) |> Enum.into([]) |> (&Connection.request(connection, &1)).() |> evaluate_response([ { 200, [%Ory.Model.Identity{}]}, { 500, %Ory.Model.JsonError{}} ]) end @doc """ This endpoint returns all sessions that belong to the given Identity. This endpoint is useful for: Listing all sessions that belong to an Identity in an administrative context. ## Parameters - connection (Ory.Connection): Connection to server - id (String.t): ID is the identity's ID. - opts (KeywordList): [optional] Optional parameters - :per_page (integer()): Items per Page This is the number of items per page. - :page (integer()): Pagination Page This value is currently an integer, but it is not sequential. The value is not the page number, but a reference. The next page can be any number and some numbers might return an empty list. For example, page 2 might not follow after page 1. And even if page 3 and 5 exist, but page 4 might not exist. - :active (boolean()): Active is a boolean flag that filters out sessions based on the state. If no value is provided, all sessions are returned. ## Returns {:ok, [%Session{}, ...]} on success {:error, Tesla.Env.t} on failure """ @spec admin_list_identity_sessions(Tesla.Env.client, String.t, keyword()) :: {:ok, list(Ory.Model.Session.t)} | {:ok, Ory.Model.JsonError.t} | {:error, Tesla.Env.t} def admin_list_identity_sessions(connection, id, opts \\ []) do optional_params = %{ :per_page => :query, :page => :query, :active => :query } %{} |> method(:get) |> url("/admin/identities/#{id}/sessions") |> add_optional_params(optional_params, opts) |> Enum.into([]) |> (&Connection.request(connection, &1)).() |> evaluate_response([ { 200, [%Ory.Model.Session{}]}, { 400, %Ory.Model.JsonError{}}, { 401, %Ory.Model.JsonError{}}, { 404, %Ory.Model.JsonError{}}, { 500, %Ory.Model.JsonError{}} ]) end @doc """ Partially updates an Identity's field using [JSON Patch](https://jsonpatch.com/) NOTE: The fields `id`, `stateChangedAt` and `credentials` are not updateable. Learn how identities work in [Ory Kratos' User And Identity Model Documentation](https://www.ory.sh/docs/next/kratos/concepts/identity-user-model). ## Parameters - connection (Ory.Connection): Connection to server - id (String.t): ID must be set to the ID of identity you want to update - opts (KeywordList): [optional] Optional parameters - :body ([Ory.Model.JsonPatch.t]): ## Returns {:ok, Ory.Model.Identity.t} on success {:error, Tesla.Env.t} on failure """ @spec admin_patch_identity(Tesla.Env.client, String.t, keyword()) :: {:ok, Ory.Model.JsonError.t} | {:ok, Ory.Model.Identity.t} | {:error, Tesla.Env.t} def admin_patch_identity(connection, id, opts \\ []) do optional_params = %{ :body => :body } %{} |> method(:patch) |> url("/admin/identities/#{id}") |> add_optional_params(optional_params, opts) |> ensure_body() |> Enum.into([]) |> (&Connection.request(connection, &1)).() |> evaluate_response([ { 200, %Ory.Model.Identity{}}, { 400, %Ory.Model.JsonError{}}, { 404, %Ory.Model.JsonError{}}, { 409, %Ory.Model.JsonError{}}, { 500, %Ory.Model.JsonError{}} ]) end @doc """ Update an Identity This endpoint updates an identity. The full identity payload (except credentials) is expected. This endpoint does not support patching. Learn how identities work in [Ory Kratos' User And Identity Model Documentation](https://www.ory.sh/docs/next/kratos/concepts/identity-user-model). ## Parameters - connection (Ory.Connection): Connection to server - id (String.t): ID must be set to the ID of identity you want to update - opts (KeywordList): [optional] Optional parameters - :body (AdminUpdateIdentityBody): ## Returns {:ok, Ory.Model.Identity.t} on success {:error, Tesla.Env.t} on failure """ @spec admin_update_identity(Tesla.Env.client, String.t, keyword()) :: {:ok, Ory.Model.JsonError.t} | {:ok, Ory.Model.Identity.t} | {:error, Tesla.Env.t} def admin_update_identity(connection, id, opts \\ []) do optional_params = %{ :body => :body } %{} |> method(:put) |> url("/admin/identities/#{id}") |> add_optional_params(optional_params, opts) |> ensure_body() |> Enum.into([]) |> (&Connection.request(connection, &1)).() |> evaluate_response([ { 200, %Ory.Model.Identity{}}, { 400, %Ory.Model.JsonError{}}, { 404, %Ory.Model.JsonError{}}, { 409, %Ory.Model.JsonError{}}, { 500, %Ory.Model.JsonError{}} ]) end @doc """ # Create a Project Creates a new project. ## Parameters - connection (Ory.Connection): Connection to server - opts (KeywordList): [optional] Optional parameters - :body (CreateProjectBody): ## Returns {:ok, Ory.Model.Project.t} on success {:error, Tesla.Env.t} on failure """ @spec create_project(Tesla.Env.client, keyword()) :: {:ok, Ory.Model.Project.t} | {:ok, Ory.Model.GenericError.t} | {:error, Tesla.Env.t} def create_project(connection, opts \\ []) do optional_params = %{ :body => :body } %{} |> method(:post) |> url("/projects") |> add_optional_params(optional_params, opts) |> ensure_body() |> Enum.into([]) |> (&Connection.request(connection, &1)).() |> evaluate_response([ { 201, %Ory.Model.Project{}}, { 401, %Ory.Model.GenericError{}}, { 403, %Ory.Model.GenericError{}}, { 404, %Ory.Model.GenericError{}}, { :default, %Ory.Model.GenericError{}} ]) end @doc """ # Create API Token Create an API token for a project. ## Parameters - connection (Ory.Connection): Connection to server - project (String.t): The Project ID or Project slug - opts (KeywordList): [optional] Optional parameters - :body (CreateProjectApiKeyRequest): ## Returns {:ok, Ory.Model.ProjectApiKey.t} on success {:error, Tesla.Env.t} on failure """ @spec create_project_api_key(Tesla.Env.client, String.t, keyword()) :: {:ok, Ory.Model.ProjectApiKey.t} | {:ok, Ory.Model.GenericError.t} | {:error, Tesla.Env.t} def create_project_api_key(connection, project, opts \\ []) do optional_params = %{ :body => :body } %{} |> method(:post) |> url("/projects/#{project}/tokens") |> add_optional_params(optional_params, opts) |> ensure_body() |> Enum.into([]) |> (&Connection.request(connection, &1)).() |> evaluate_response([ { 201, %Ory.Model.ProjectApiKey{}}, { :default, %Ory.Model.GenericError{}} ]) end @doc """ Create a Logout URL for Browsers This endpoint initializes a browser-based user logout flow and a URL which can be used to log out the user. This endpoint is NOT INTENDED for API clients and only works with browsers (Chrome, Firefox, ...). For API clients you can call the `/self-service/logout/api` URL directly with the Ory Session Token. The URL is only valid for the currently signed in user. If no user is signed in, this endpoint returns a 401 error. When calling this endpoint from a backend, please ensure to properly forward the HTTP cookies. ## Parameters - connection (Ory.Connection): Connection to server - opts (KeywordList): [optional] Optional parameters - :cookie (String.t): HTTP Cookies If you call this endpoint from a backend, please include the original Cookie header in the request. ## Returns {:ok, Ory.Model.SelfServiceLogoutUrl.t} on success {:error, Tesla.Env.t} on failure """ @spec create_self_service_logout_flow_url_for_browsers(Tesla.Env.client, keyword()) :: {:ok, Ory.Model.JsonError.t} | {:ok, Ory.Model.SelfServiceLogoutUrl.t} | {:error, Tesla.Env.t} def create_self_service_logout_flow_url_for_browsers(connection, opts \\ []) do optional_params = %{ :cookie => :headers } %{} |> method(:get) |> url("/self-service/logout/browser") |> add_optional_params(optional_params, opts) |> Enum.into([]) |> (&Connection.request(connection, &1)).() |> evaluate_response([ { 200, %Ory.Model.SelfServiceLogoutUrl{}}, { 401, %Ory.Model.JsonError{}}, { 500, %Ory.Model.JsonError{}} ]) end @doc """ # Delete API Token Deletes an API Token and immediately removes it. ## Parameters - connection (Ory.Connection): Connection to server - project (String.t): The Project ID or Project slug - token_id (String.t): The Token ID - opts (KeywordList): [optional] Optional parameters ## Returns {:ok, nil} on success {:error, Tesla.Env.t} on failure """ @spec delete_project_api_key(Tesla.Env.client, String.t, String.t, keyword()) :: {:ok, nil} | {:ok, Ory.Model.GenericError.t} | {:error, Tesla.Env.t} def delete_project_api_key(connection, project, token_id, _opts \\ []) do %{} |> method(:delete) |> url("/projects/#{project}/tokens/#{token_id}") |> Enum.into([]) |> (&Connection.request(connection, &1)).() |> evaluate_response([ { 204, false}, { :default, %Ory.Model.GenericError{}} ]) end @doc """ Get a JSON Schema ## Parameters - connection (Ory.Connection): Connection to server - id (String.t): ID must be set to the ID of schema you want to get - opts (KeywordList): [optional] Optional parameters ## Returns {:ok, map()} on success {:error, Tesla.Env.t} on failure """ @spec get_identity_schema(Tesla.Env.client, String.t, keyword()) :: {:ok, Ory.Model.JsonError.t} | {:ok, Map.t} | {:error, Tesla.Env.t} def get_identity_schema(connection, id, _opts \\ []) do %{} |> method(:get) |> url("/schemas/#{id}") |> Enum.into([]) |> (&Connection.request(connection, &1)).() |> evaluate_response([ { 200, %{}}, { 404, %Ory.Model.JsonError{}}, { 500, %Ory.Model.JsonError{}} ]) end @doc """ # Get a Project Get a projects you have access to by its ID. ## Parameters - connection (Ory.Connection): Connection to server - project_id (String.t): Project ID The project's ID. - opts (KeywordList): [optional] Optional parameters ## Returns {:ok, Ory.Model.Project.t} on success {:error, Tesla.Env.t} on failure """ @spec get_project(Tesla.Env.client, String.t, keyword()) :: {:ok, Ory.Model.Project.t} | {:ok, Ory.Model.GenericError.t} | {:error, Tesla.Env.t} def get_project(connection, project_id, _opts \\ []) do %{} |> method(:get) |> url("/projects/#{project_id}") |> Enum.into([]) |> (&Connection.request(connection, &1)).() |> evaluate_response([ { 200, %Ory.Model.Project{}}, { 401, %Ory.Model.GenericError{}}, { 403, %Ory.Model.GenericError{}}, { 404, %Ory.Model.GenericError{}}, { :default, %Ory.Model.GenericError{}} ]) end @doc """ Get all members associated with this project. This endpoint requires the user to be a member of the project with the role `OWNER` or `DEVELOPER`. ## Parameters - connection (Ory.Connection): Connection to server - project_id (String.t): Project ID The project's ID. - opts (KeywordList): [optional] Optional parameters ## Returns {:ok, [%CloudAccount{}, ...]} on success {:error, Tesla.Env.t} on failure """ @spec get_project_members(Tesla.Env.client, String.t, keyword()) :: {:ok, Ory.Model.GenericError.t} | {:ok, list(Ory.Model.CloudAccount.t)} | {:error, Tesla.Env.t} def get_project_members(connection, project_id, _opts \\ []) do %{} |> method(:get) |> url("/projects/#{project_id}/members") |> Enum.into([]) |> (&Connection.request(connection, &1)).() |> evaluate_response([ { 200, [%Ory.Model.CloudAccount{}]}, { 401, %Ory.Model.GenericError{}}, { 406, %Ory.Model.GenericError{}}, { 500, %Ory.Model.GenericError{}} ]) end @doc """ Get Self-Service Errors This endpoint returns the error associated with a user-facing self service errors. This endpoint supports stub values to help you implement the error UI: `?id=stub:500` - returns a stub 500 (Internal Server Error) error. More information can be found at [Ory Kratos User User Facing Error Documentation](https://www.ory.sh/docs/kratos/self-service/flows/user-facing-errors). ## Parameters - connection (Ory.Connection): Connection to server - id (String.t): Error is the error's ID - opts (KeywordList): [optional] Optional parameters ## Returns {:ok, Ory.Model.SelfServiceError.t} on success {:error, Tesla.Env.t} on failure """ @spec get_self_service_error(Tesla.Env.client, String.t, keyword()) :: {:ok, Ory.Model.JsonError.t} | {:ok, Ory.Model.SelfServiceError.t} | {:error, Tesla.Env.t} def get_self_service_error(connection, id, _opts \\ []) do %{} |> method(:get) |> url("/self-service/errors") |> add_param(:query, :id, id) |> Enum.into([]) |> (&Connection.request(connection, &1)).() |> evaluate_response([ { 200, %Ory.Model.SelfServiceError{}}, { 403, %Ory.Model.JsonError{}}, { 404, %Ory.Model.JsonError{}}, { 500, %Ory.Model.JsonError{}} ]) end @doc """ Get Login Flow This endpoint returns a login flow's context with, for example, error details and other information. Browser flows expect the anti-CSRF cookie to be included in the request's HTTP Cookie Header. For AJAX requests you must ensure that cookies are included in the request or requests will fail. If you use the browser-flow for server-side apps, the services need to run on a common top-level-domain and you need to forward the incoming HTTP Cookie header to this endpoint: ```js pseudo-code example router.get('/login', async function (req, res) { const flow = await client.getSelfServiceLoginFlow(req.header('cookie'), req.query['flow']) res.render('login', flow) }) ``` This request may fail due to several reasons. The `error.id` can be one of: `session_already_available`: The user is already signed in. `self_service_flow_expired`: The flow is expired and you should request a new one. More information can be found at [Ory Kratos User Login](https://www.ory.sh/docs/kratos/self-service/flows/user-login) and [User Registration Documentation](https://www.ory.sh/docs/kratos/self-service/flows/user-registration). ## Parameters - connection (Ory.Connection): Connection to server - id (String.t): The Login Flow ID The value for this parameter comes from `flow` URL Query parameter sent to your application (e.g. `/login?flow=abcde`). - opts (KeywordList): [optional] Optional parameters - :cookie (String.t): HTTP Cookies When using the SDK in a browser app, on the server side you must include the HTTP Cookie Header sent by the client to your server here. This ensures that CSRF and session cookies are respected. ## Returns {:ok, Ory.Model.SelfServiceLoginFlow.t} on success {:error, Tesla.Env.t} on failure """ @spec get_self_service_login_flow(Tesla.Env.client, String.t, keyword()) :: {:ok, Ory.Model.JsonError.t} | {:ok, Ory.Model.SelfServiceLoginFlow.t} | {:error, Tesla.Env.t} def get_self_service_login_flow(connection, id, opts \\ []) do optional_params = %{ :Cookie => :headers } %{} |> method(:get) |> url("/self-service/login/flows") |> add_param(:query, :id, id) |> add_optional_params(optional_params, opts) |> Enum.into([]) |> (&Connection.request(connection, &1)).() |> evaluate_response([ { 200, %Ory.Model.SelfServiceLoginFlow{}}, { 403, %Ory.Model.JsonError{}}, { 404, %Ory.Model.JsonError{}}, { 410, %Ory.Model.JsonError{}}, { 500, %Ory.Model.JsonError{}} ]) end @doc """ Get Recovery Flow This endpoint returns a recovery flow's context with, for example, error details and other information. Browser flows expect the anti-CSRF cookie to be included in the request's HTTP Cookie Header. For AJAX requests you must ensure that cookies are included in the request or requests will fail. If you use the browser-flow for server-side apps, the services need to run on a common top-level-domain and you need to forward the incoming HTTP Cookie header to this endpoint: ```js pseudo-code example router.get('/recovery', async function (req, res) { const flow = await client.getSelfServiceRecoveryFlow(req.header('Cookie'), req.query['flow']) res.render('recovery', flow) }) ``` More information can be found at [Ory Kratos Account Recovery Documentation](../self-service/flows/account-recovery). ## Parameters - connection (Ory.Connection): Connection to server - id (String.t): The Flow ID The value for this parameter comes from `request` URL Query parameter sent to your application (e.g. `/recovery?flow=abcde`). - opts (KeywordList): [optional] Optional parameters - :cookie (String.t): HTTP Cookies When using the SDK in a browser app, on the server side you must include the HTTP Cookie Header sent by the client to your server here. This ensures that CSRF and session cookies are respected. ## Returns {:ok, Ory.Model.SelfServiceRecoveryFlow.t} on success {:error, Tesla.Env.t} on failure """ @spec get_self_service_recovery_flow(Tesla.Env.client, String.t, keyword()) :: {:ok, Ory.Model.JsonError.t} | {:ok, Ory.Model.SelfServiceRecoveryFlow.t} | {:error, Tesla.Env.t} def get_self_service_recovery_flow(connection, id, opts \\ []) do optional_params = %{ :Cookie => :headers } %{} |> method(:get) |> url("/self-service/recovery/flows") |> add_param(:query, :id, id) |> add_optional_params(optional_params, opts) |> Enum.into([]) |> (&Connection.request(connection, &1)).() |> evaluate_response([ { 200, %Ory.Model.SelfServiceRecoveryFlow{}}, { 404, %Ory.Model.JsonError{}}, { 410, %Ory.Model.JsonError{}}, { 500, %Ory.Model.JsonError{}} ]) end @doc """ Get Registration Flow This endpoint returns a registration flow's context with, for example, error details and other information. Browser flows expect the anti-CSRF cookie to be included in the request's HTTP Cookie Header. For AJAX requests you must ensure that cookies are included in the request or requests will fail. If you use the browser-flow for server-side apps, the services need to run on a common top-level-domain and you need to forward the incoming HTTP Cookie header to this endpoint: ```js pseudo-code example router.get('/registration', async function (req, res) { const flow = await client.getSelfServiceRegistrationFlow(req.header('cookie'), req.query['flow']) res.render('registration', flow) }) ``` This request may fail due to several reasons. The `error.id` can be one of: `session_already_available`: The user is already signed in. `self_service_flow_expired`: The flow is expired and you should request a new one. More information can be found at [Ory Kratos User Login](https://www.ory.sh/docs/kratos/self-service/flows/user-login) and [User Registration Documentation](https://www.ory.sh/docs/kratos/self-service/flows/user-registration). ## Parameters - connection (Ory.Connection): Connection to server - id (String.t): The Registration Flow ID The value for this parameter comes from `flow` URL Query parameter sent to your application (e.g. `/registration?flow=abcde`). - opts (KeywordList): [optional] Optional parameters - :cookie (String.t): HTTP Cookies When using the SDK in a browser app, on the server side you must include the HTTP Cookie Header sent by the client to your server here. This ensures that CSRF and session cookies are respected. ## Returns {:ok, Ory.Model.SelfServiceRegistrationFlow.t} on success {:error, Tesla.Env.t} on failure """ @spec get_self_service_registration_flow(Tesla.Env.client, String.t, keyword()) :: {:ok, Ory.Model.JsonError.t} | {:ok, Ory.Model.SelfServiceRegistrationFlow.t} | {:error, Tesla.Env.t} def get_self_service_registration_flow(connection, id, opts \\ []) do optional_params = %{ :Cookie => :headers } %{} |> method(:get) |> url("/self-service/registration/flows") |> add_param(:query, :id, id) |> add_optional_params(optional_params, opts) |> Enum.into([]) |> (&Connection.request(connection, &1)).() |> evaluate_response([ { 200, %Ory.Model.SelfServiceRegistrationFlow{}}, { 403, %Ory.Model.JsonError{}}, { 404, %Ory.Model.JsonError{}}, { 410, %Ory.Model.JsonError{}}, { 500, %Ory.Model.JsonError{}} ]) end @doc """ Get Settings Flow When accessing this endpoint through Ory Kratos' Public API you must ensure that either the Ory Kratos Session Cookie or the Ory Kratos Session Token are set. Depending on your configuration this endpoint might return a 403 error if the session has a lower Authenticator Assurance Level (AAL) than is possible for the identity. This can happen if the identity has password + webauthn credentials (which would result in AAL2) but the session has only AAL1. If this error occurs, ask the user to sign in with the second factor or change the configuration. You can access this endpoint without credentials when using Ory Kratos' Admin API. If this endpoint is called via an AJAX request, the response contains the flow without a redirect. In the case of an error, the `error.id` of the JSON response body can be one of: `security_csrf_violation`: Unable to fetch the flow because a CSRF violation occurred. `session_inactive`: No Ory Session was found - sign in a user first. `security_identity_mismatch`: The flow was interrupted with `session_refresh_required` but apparently some other identity logged in instead. More information can be found at [Ory Kratos User Settings & Profile Management Documentation](../self-service/flows/user-settings). ## Parameters - connection (Ory.Connection): Connection to server - id (String.t): ID is the Settings Flow ID The value for this parameter comes from `flow` URL Query parameter sent to your application (e.g. `/settings?flow=abcde`). - opts (KeywordList): [optional] Optional parameters - :x_session_token (String.t): The Session Token When using the SDK in an app without a browser, please include the session token here. - :cookie (String.t): HTTP Cookies When using the SDK in a browser app, on the server side you must include the HTTP Cookie Header sent by the client to your server here. This ensures that CSRF and session cookies are respected. ## Returns {:ok, Ory.Model.SelfServiceSettingsFlow.t} on success {:error, Tesla.Env.t} on failure """ @spec get_self_service_settings_flow(Tesla.Env.client, String.t, keyword()) :: {:ok, Ory.Model.JsonError.t} | {:ok, Ory.Model.SelfServiceSettingsFlow.t} | {:error, Tesla.Env.t} def get_self_service_settings_flow(connection, id, opts \\ []) do optional_params = %{ :"X-Session-Token" => :headers, :Cookie => :headers } %{} |> method(:get) |> url("/self-service/settings/flows") |> add_param(:query, :id, id) |> add_optional_params(optional_params, opts) |> Enum.into([]) |> (&Connection.request(connection, &1)).() |> evaluate_response([ { 200, %Ory.Model.SelfServiceSettingsFlow{}}, { 401, %Ory.Model.JsonError{}}, { 403, %Ory.Model.JsonError{}}, { 404, %Ory.Model.JsonError{}}, { 410, %Ory.Model.JsonError{}}, { 500, %Ory.Model.JsonError{}} ]) end @doc """ # Get Verification Flow This endpoint returns a verification flow's context with, for example, error details and other information. Browser flows expect the anti-CSRF cookie to be included in the request's HTTP Cookie Header. For AJAX requests you must ensure that cookies are included in the request or requests will fail. If you use the browser-flow for server-side apps, the services need to run on a common top-level-domain and you need to forward the incoming HTTP Cookie header to this endpoint: ```js pseudo-code example router.get('/recovery', async function (req, res) { const flow = await client.getSelfServiceVerificationFlow(req.header('cookie'), req.query['flow']) res.render('verification', flow) }) More information can be found at [Ory Kratos Email and Phone Verification Documentation](https://www.ory.sh/docs/kratos/selfservice/flows/verify-email-account-activation). ## Parameters - connection (Ory.Connection): Connection to server - id (String.t): The Flow ID The value for this parameter comes from `request` URL Query parameter sent to your application (e.g. `/verification?flow=abcde`). - opts (KeywordList): [optional] Optional parameters - :cookie (String.t): HTTP Cookies When using the SDK on the server side you must include the HTTP Cookie Header originally sent to your HTTP handler here. ## Returns {:ok, Ory.Model.SelfServiceVerificationFlow.t} on success {:error, Tesla.Env.t} on failure """ @spec get_self_service_verification_flow(Tesla.Env.client, String.t, keyword()) :: {:ok, Ory.Model.JsonError.t} | {:ok, Ory.Model.SelfServiceVerificationFlow.t} | {:error, Tesla.Env.t} def get_self_service_verification_flow(connection, id, opts \\ []) do optional_params = %{ :cookie => :headers } %{} |> method(:get) |> url("/self-service/verification/flows") |> add_param(:query, :id, id) |> add_optional_params(optional_params, opts) |> Enum.into([]) |> (&Connection.request(connection, &1)).() |> evaluate_response([ { 200, %Ory.Model.SelfServiceVerificationFlow{}}, { 403, %Ory.Model.JsonError{}}, { 404, %Ory.Model.JsonError{}}, { 500, %Ory.Model.JsonError{}} ]) end @doc """ Get WebAuthn JavaScript This endpoint provides JavaScript which is needed in order to perform WebAuthn login and registration. If you are building a JavaScript Browser App (e.g. in ReactJS or AngularJS) you will need to load this file: ```html