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

defmodule Nuon.Api.Installers do
  @moduledoc """
  API calls for all endpoints tagged `Installers`.
  """

  alias Nuon.Connection
  import Nuon.RequestBuilder

  @doc """
  create an installer

  ### Parameters

  - `connection` (Nuon.Connection): Connection to server
  - `service_create_installer_request` (ServiceCreateInstallerRequest): Input
  - `opts` (keyword): Optional parameters

  ### Returns

  - `{:ok, Nuon.Model.AppInstaller.t}` on success
  - `{:error, Tesla.Env.t}` on failure
  """
  @spec create_installer(Tesla.Env.client, Nuon.Model.ServiceCreateInstallerRequest.t, keyword()) :: {:ok, Nuon.Model.StderrErrResponse.t} | {:ok, Nuon.Model.AppInstaller.t} | {:error, Tesla.Env.t}
  def create_installer(connection, service_create_installer_request, _opts \\ []) do
    request =
      %{}
      |> method(:post)
      |> url("/v1/installers")
      |> add_param(:body, :body, service_create_installer_request)
      |> Enum.into([])

    connection
    |> Connection.request(request)
    |> evaluate_response([
      {201, Nuon.Model.AppInstaller},
      {400, Nuon.Model.StderrErrResponse},
      {401, Nuon.Model.StderrErrResponse},
      {403, Nuon.Model.StderrErrResponse},
      {404, Nuon.Model.StderrErrResponse},
      {500, Nuon.Model.StderrErrResponse}
    ])
  end

  @doc """
  delete an installer

  ### Parameters

  - `connection` (Nuon.Connection): Connection to server
  - `installer_id` (String.t): installer ID
  - `opts` (keyword): Optional parameters

  ### Returns

  - `{:ok, boolean()}` on success
  - `{:error, Tesla.Env.t}` on failure
  """
  @spec delete_installer(Tesla.Env.client, String.t, keyword()) :: {:ok, Nuon.Model.StderrErrResponse.t} | {:ok, boolean()} | {:error, Tesla.Env.t}
  def delete_installer(connection, installer_id, _opts \\ []) do
    request =
      %{}
      |> method(:delete)
      |> url("/v1/installers/#{installer_id}")
      |> Enum.into([])

    connection
    |> Connection.request(request)
    |> evaluate_response([
      {200, false},
      {400, Nuon.Model.StderrErrResponse},
      {401, Nuon.Model.StderrErrResponse},
      {403, Nuon.Model.StderrErrResponse},
      {404, Nuon.Model.StderrErrResponse},
      {500, Nuon.Model.StderrErrResponse}
    ])
  end

  @doc """
  get an installer

  ### Parameters

  - `connection` (Nuon.Connection): Connection to server
  - `installer_id` (String.t): installer ID
  - `opts` (keyword): Optional parameters

  ### Returns

  - `{:ok, Nuon.Model.AppInstaller.t}` on success
  - `{:error, Tesla.Env.t}` on failure
  """
  @spec get_installer(Tesla.Env.client, String.t, keyword()) :: {:ok, Nuon.Model.StderrErrResponse.t} | {:ok, Nuon.Model.AppInstaller.t} | {:error, Tesla.Env.t}
  def get_installer(connection, installer_id, _opts \\ []) do
    request =
      %{}
      |> method(:get)
      |> url("/v1/installers/#{installer_id}")
      |> Enum.into([])

    connection
    |> Connection.request(request)
    |> evaluate_response([
      {200, Nuon.Model.AppInstaller},
      {400, Nuon.Model.StderrErrResponse},
      {401, Nuon.Model.StderrErrResponse},
      {403, Nuon.Model.StderrErrResponse},
      {404, Nuon.Model.StderrErrResponse},
      {500, Nuon.Model.StderrErrResponse}
    ])
  end

  @doc """
  get installers for current org
  Return all installers for the current org. 

  ### Parameters

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

  ### Returns

  - `{:ok, [%AppInstaller{}, ...]}` on success
  - `{:error, Tesla.Env.t}` on failure
  """
  @spec get_installers(Tesla.Env.client, keyword()) :: {:ok, Nuon.Model.StderrErrResponse.t} | {:ok, [Nuon.Model.AppInstaller.t]} | {:error, Tesla.Env.t}
  def get_installers(connection, _opts \\ []) do
    request =
      %{}
      |> method(:get)
      |> url("/v1/installers")
      |> Enum.into([])

    connection
    |> Connection.request(request)
    |> evaluate_response([
      {200, Nuon.Model.AppInstaller},
      {400, Nuon.Model.StderrErrResponse},
      {401, Nuon.Model.StderrErrResponse},
      {403, Nuon.Model.StderrErrResponse},
      {404, Nuon.Model.StderrErrResponse},
      {500, Nuon.Model.StderrErrResponse}
    ])
  end

  @doc """
  render an installer

  ### Parameters

  - `connection` (Nuon.Connection): Connection to server
  - `installer_id` (String.t): installer ID
  - `opts` (keyword): Optional parameters

  ### Returns

  - `{:ok, Nuon.Model.ServiceRenderedInstaller.t}` on success
  - `{:error, Tesla.Env.t}` on failure
  """
  @spec render_installer(Tesla.Env.client, String.t, keyword()) :: {:ok, Nuon.Model.StderrErrResponse.t} | {:ok, Nuon.Model.ServiceRenderedInstaller.t} | {:error, Tesla.Env.t}
  def render_installer(connection, installer_id, _opts \\ []) do
    request =
      %{}
      |> method(:get)
      |> url("/v1/installer/#{installer_id}/render")
      |> Enum.into([])

    connection
    |> Connection.request(request)
    |> evaluate_response([
      {200, Nuon.Model.ServiceRenderedInstaller},
      {400, Nuon.Model.StderrErrResponse},
      {401, Nuon.Model.StderrErrResponse},
      {403, Nuon.Model.StderrErrResponse},
      {404, Nuon.Model.StderrErrResponse},
      {500, Nuon.Model.StderrErrResponse}
    ])
  end

  @doc """
  update an installer

  ### Parameters

  - `connection` (Nuon.Connection): Connection to server
  - `installer_id` (String.t): installer ID
  - `service_update_installer_request` (ServiceUpdateInstallerRequest): Input
  - `opts` (keyword): Optional parameters

  ### Returns

  - `{:ok, Nuon.Model.AppInstaller.t}` on success
  - `{:error, Tesla.Env.t}` on failure
  """
  @spec update_installer(Tesla.Env.client, String.t, Nuon.Model.ServiceUpdateInstallerRequest.t, keyword()) :: {:ok, Nuon.Model.StderrErrResponse.t} | {:ok, Nuon.Model.AppInstaller.t} | {:error, Tesla.Env.t}
  def update_installer(connection, installer_id, service_update_installer_request, _opts \\ []) do
    request =
      %{}
      |> method(:patch)
      |> url("/v1/installers/#{installer_id}")
      |> add_param(:body, :body, service_update_installer_request)
      |> Enum.into([])

    connection
    |> Connection.request(request)
    |> evaluate_response([
      {201, Nuon.Model.AppInstaller},
      {400, Nuon.Model.StderrErrResponse},
      {401, Nuon.Model.StderrErrResponse},
      {403, Nuon.Model.StderrErrResponse},
      {404, Nuon.Model.StderrErrResponse},
      {500, Nuon.Model.StderrErrResponse}
    ])
  end
end
