lib/ory/api/health.ex

# NOTE: This file is auto generated by OpenAPI Generator 6.2.1 (https://openapi-generator.tech).
# Do not edit this file manually.

defmodule Ory.Api.Health do
  @moduledoc """
  API calls for all endpoints tagged `Health`.
  """

  alias Ory.Connection
  import Ory.RequestBuilder

  @doc """
  Check alive status
  This endpoint returns a 200 status code when the HTTP server is up running. This status does currently not include checks whether the database connection is working.  If the service supports TLS Edge Termination, this endpoint does not require the `X-Forwarded-Proto` header to be set.  Be aware that if you are running multiple nodes of this service, the health status will never refer to the cluster state, only to a single instance.

  ### Parameters

  - `connection` (Ory.Connection): Connection to server
  - `opts` (keyword): Optional parameters

  ### Returns

  - `{:ok, Ory.Model.HealthStatus.t}` on success
  - `{:error, Tesla.Env.t}` on failure
  """
  @spec is_instance_alive(Tesla.Env.client, keyword()) :: {:ok, Ory.Model.GenericError.t} | {:ok, Ory.Model.HealthStatus.t} | {:error, Tesla.Env.t}
  def is_instance_alive(connection, _opts \\ []) do
    request =
      %{}
      |> method(:get)
      |> url("/health/alive")
      |> Enum.into([])

    connection
    |> Connection.request(request)
    |> evaluate_response([
      {200, %Ory.Model.HealthStatus{}},
      {500, %Ory.Model.GenericError{}}
    ])
  end

  @doc """
  Check readiness status
  This endpoint returns a 200 status code when the HTTP server is up running and the environment dependencies (e.g. the database) are responsive as well.  If the service supports TLS Edge Termination, this endpoint does not require the `X-Forwarded-Proto` header to be set.  Be aware that if you are running multiple nodes of this service, the health status will never refer to the cluster state, only to a single instance.

  ### Parameters

  - `connection` (Ory.Connection): Connection to server
  - `opts` (keyword): Optional parameters

  ### Returns

  - `{:ok, Ory.Model.HealthStatus.t}` on success
  - `{:error, Tesla.Env.t}` on failure
  """
  @spec is_instance_ready(Tesla.Env.client, keyword()) :: {:ok, Ory.Model.HealthNotReadyStatus.t} | {:ok, Ory.Model.HealthStatus.t} | {:error, Tesla.Env.t}
  def is_instance_ready(connection, _opts \\ []) do
    request =
      %{}
      |> method(:get)
      |> url("/health/ready")
      |> Enum.into([])

    connection
    |> Connection.request(request)
    |> evaluate_response([
      {200, %Ory.Model.HealthStatus{}},
      {503, %Ory.Model.HealthNotReadyStatus{}}
    ])
  end
end