lib/chat_kitty/api/runtime.ex

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

defmodule ChatKitty.Api.Runtime do
  @moduledoc """
  API calls for all endpoints tagged `Runtime`.
  """

  alias ChatKitty.Connection
  import ChatKitty.RequestBuilder


  @doc """
  Create a NodeJS chat runtime function
  Creates a NodeJS chat function for this runtime

  ## Parameters

  - connection (ChatKitty.Connection): Connection to server
  - create_chat_function_resource (CreateChatFunctionResource): 
  - opts (KeywordList): [optional] Optional parameters
  ## Returns

  {:ok, ChatKitty.Model.ChatFunctionResource.t} on success
  {:error, Tesla.Env.t} on failure
  """
  @spec create_nodejs_runtime_function(Tesla.Env.client, ChatKitty.Model.CreateChatFunctionResource.t, keyword()) :: {:ok, ChatKitty.Model.ApiError.t} | {:ok, ChatKitty.Model.AuthenticationError.t} | {:ok, ChatKitty.Model.ChatFunctionResource.t} | {:error, Tesla.Env.t}
  def create_nodejs_runtime_function(connection, create_chat_function_resource, _opts \\ []) do
    %{}
    |> method(:post)
    |> url("/v1/runtimes/nodejs/functions")
    |> add_param(:body, :body, create_chat_function_resource)
    |> Enum.into([])
    |> (&Connection.request(connection, &1)).()
    |> evaluate_response([
      { 403, %ChatKitty.Model.AuthenticationError{}},
      { 400, %ChatKitty.Model.ApiError{}},
      { 401, %ChatKitty.Model.AuthenticationError{}},
      { 404, %ChatKitty.Model.ApiError{}},
      { 200, %ChatKitty.Model.ChatFunctionResource{}}
    ])
  end

  @doc """
  List NodeJS chat runtime functions
  Returns a page of functions for this application's NodeJS chat runtime

  ## Parameters

  - connection (ChatKitty.Connection): Connection to server
  - opts (KeywordList): [optional] Optional parameters
    - :page (integer()): Zero-based page index (0..N)
    - :size (integer()): The size of the page to be returned
    - :sort ([String.t]): Sorting criteria in the format: property,(asc|desc). Default sort order is ascending. Multiple sort criteria are supported.
  ## Returns

  {:ok, ChatKitty.Model.PagedModelChatFunctionResource.t} on success
  {:error, Tesla.Env.t} on failure
  """
  @spec list_nodejs_runtime_functions(Tesla.Env.client, keyword()) :: {:ok, ChatKitty.Model.ApiError.t} | {:ok, ChatKitty.Model.AuthenticationError.t} | {:ok, ChatKitty.Model.PagedModelChatFunctionResource.t} | {:error, Tesla.Env.t}
  def list_nodejs_runtime_functions(connection, opts \\ []) do
    optional_params = %{
      :"page" => :query,
      :"size" => :query,
      :"sort" => :query
    }
    %{}
    |> method(:get)
    |> url("/v1/runtimes/nodejs/functions")
    |> add_optional_params(optional_params, opts)
    |> Enum.into([])
    |> (&Connection.request(connection, &1)).()
    |> evaluate_response([
      { 403, %ChatKitty.Model.AuthenticationError{}},
      { 400, %ChatKitty.Model.ApiError{}},
      { 401, %ChatKitty.Model.AuthenticationError{}},
      { 404, %ChatKitty.Model.ApiError{}},
      { 200, %ChatKitty.Model.PagedModelChatFunctionResource{}}
    ])
  end

  @doc """
  Retrieve NodeJS chat runtime
  Return this application's NodeJS chat runtime

  ## Parameters

  - connection (ChatKitty.Connection): Connection to server
  - opts (KeywordList): [optional] Optional parameters
  ## Returns

  {:ok, ChatKitty.Model.ChatRuntimeResource.t} on success
  {:error, Tesla.Env.t} on failure
  """
  @spec retrieve_nodejs_runtime(Tesla.Env.client, keyword()) :: {:ok, ChatKitty.Model.ApiError.t} | {:ok, ChatKitty.Model.AuthenticationError.t} | {:ok, ChatKitty.Model.ChatRuntimeResource.t} | {:error, Tesla.Env.t}
  def retrieve_nodejs_runtime(connection, _opts \\ []) do
    %{}
    |> method(:get)
    |> url("/v1/runtimes/nodejs")
    |> Enum.into([])
    |> (&Connection.request(connection, &1)).()
    |> evaluate_response([
      { 403, %ChatKitty.Model.AuthenticationError{}},
      { 400, %ChatKitty.Model.ApiError{}},
      { 401, %ChatKitty.Model.AuthenticationError{}},
      { 404, %ChatKitty.Model.ApiError{}},
      { 200, %ChatKitty.Model.ChatRuntimeResource{}}
    ])
  end

  @doc """
  Update NodeJS chat runtime NPM dependencies
  Updates the NPM dependencies for this application's NodeJS chat runtime

  ## Parameters

  - connection (ChatKitty.Connection): Connection to server
  - chat_runtime_dependency_properties ([ChatKitty.Model.ChatRuntimeDependencyProperties.t]): 
  - opts (KeywordList): [optional] Optional parameters
  ## Returns

  {:ok, ChatKitty.Model.ChatRuntimeResource.t} on success
  {:error, Tesla.Env.t} on failure
  """
  @spec update_nodejs_runtime_dependencies(Tesla.Env.client, list(ChatKitty.Model.ChatRuntimeDependencyProperties.t), keyword()) :: {:ok, ChatKitty.Model.ApiError.t} | {:ok, ChatKitty.Model.AuthenticationError.t} | {:ok, ChatKitty.Model.ChatRuntimeResource.t} | {:error, Tesla.Env.t}
  def update_nodejs_runtime_dependencies(connection, chat_runtime_dependency_properties, _opts \\ []) do
    %{}
    |> method(:put)
    |> url("/v1/runtimes/nodejs/dependencies")
    |> add_param(:body, :body, chat_runtime_dependency_properties)
    |> Enum.into([])
    |> (&Connection.request(connection, &1)).()
    |> evaluate_response([
      { 403, %ChatKitty.Model.AuthenticationError{}},
      { 400, %ChatKitty.Model.ApiError{}},
      { 401, %ChatKitty.Model.AuthenticationError{}},
      { 404, %ChatKitty.Model.ApiError{}},
      { 200, %ChatKitty.Model.ChatRuntimeResource{}}
    ])
  end

  @doc """
  Update NodeJS chat runtime environment variables
  Updates the runtime environment variables of this application's NodeJS chat runtime

  ## Parameters

  - connection (ChatKitty.Connection): Connection to server
  - request_body (%{optional(String.t) => String.t}): 
  - opts (KeywordList): [optional] Optional parameters
  ## Returns

  {:ok, ChatKitty.Model.ChatRuntimeResource.t} on success
  {:error, Tesla.Env.t} on failure
  """
  @spec update_nodejs_runtime_environment_variables(Tesla.Env.client, %{optional(String.t) => String.t}, keyword()) :: {:ok, ChatKitty.Model.ApiError.t} | {:ok, ChatKitty.Model.AuthenticationError.t} | {:ok, ChatKitty.Model.ChatRuntimeResource.t} | {:error, Tesla.Env.t}
  def update_nodejs_runtime_environment_variables(connection, request_body, _opts \\ []) do
    %{}
    |> method(:put)
    |> url("/v1/runtimes/nodejs/environment-variables")
    |> add_param(:body, :body, request_body)
    |> Enum.into([])
    |> (&Connection.request(connection, &1)).()
    |> evaluate_response([
      { 403, %ChatKitty.Model.AuthenticationError{}},
      { 400, %ChatKitty.Model.ApiError{}},
      { 401, %ChatKitty.Model.AuthenticationError{}},
      { 404, %ChatKitty.Model.ApiError{}},
      { 200, %ChatKitty.Model.ChatRuntimeResource{}}
    ])
  end

  @doc """
  Update NodeJS chat runtime initialization script
  Updates the initialization script for this application's NodeJS chat runtime

  ## Parameters

  - connection (ChatKitty.Connection): Connection to server
  - chat_runtime_script_properties (ChatRuntimeScriptProperties): 
  - opts (KeywordList): [optional] Optional parameters
  ## Returns

  {:ok, ChatKitty.Model.ChatRuntimeResource.t} on success
  {:error, Tesla.Env.t} on failure
  """
  @spec update_nodejs_runtime_initialization_script(Tesla.Env.client, ChatKitty.Model.ChatRuntimeScriptProperties.t, keyword()) :: {:ok, ChatKitty.Model.ApiError.t} | {:ok, ChatKitty.Model.AuthenticationError.t} | {:ok, ChatKitty.Model.ChatRuntimeResource.t} | {:error, Tesla.Env.t}
  def update_nodejs_runtime_initialization_script(connection, chat_runtime_script_properties, _opts \\ []) do
    %{}
    |> method(:put)
    |> url("/v1/runtimes/nodejs/initialization-script")
    |> add_param(:body, :body, chat_runtime_script_properties)
    |> Enum.into([])
    |> (&Connection.request(connection, &1)).()
    |> evaluate_response([
      { 403, %ChatKitty.Model.AuthenticationError{}},
      { 400, %ChatKitty.Model.ApiError{}},
      { 401, %ChatKitty.Model.AuthenticationError{}},
      { 404, %ChatKitty.Model.ApiError{}},
      { 200, %ChatKitty.Model.ChatRuntimeResource{}}
    ])
  end
end