Skip to main content

lib/api/hosted_compute/hosted_compute.ex

# Generated by `mix github.gen` from docs/github-api/api.github.com.json.
# Do not edit by hand; re-run the task instead.

defmodule Noizu.Github.Api.HostedCompute do
  @moduledoc """
  GitHub `hosted-compute` API.
  """
  import Noizu.Github

  @doc """
  Create a hosted compute network configuration for an organization

  @see https://docs.github.com/rest/orgs/network-configurations#create-a-hosted-compute-network-configuration-for-an-organization
  """
  def create_network_configuration_for_org(org, body, options \\ nil) do
    url = github_base() <> "/orgs/#{org}/settings/network-configurations"
    body = body
    api_call(:post, url, body, Noizu.Github.NetworkConfiguration, options)
  end

  @doc """
  Delete a hosted compute network configuration from an organization

  @see https://docs.github.com/rest/orgs/network-configurations#delete-a-hosted-compute-network-configuration-from-an-organization
  """
  def delete_network_configuration_from_org(org, network_configuration_id, options \\ nil) do
    url =
      github_base() <> "/orgs/#{org}/settings/network-configurations/#{network_configuration_id}"

    body = %{}
    api_call(:delete, url, body, Noizu.Github.Raw, options)
  end

  @doc """
  Get a hosted compute network configuration for an organization

  @see https://docs.github.com/rest/orgs/network-configurations#get-a-hosted-compute-network-configuration-for-an-organization
  """
  def get_network_configuration_for_org(org, network_configuration_id, options \\ nil) do
    url =
      github_base() <> "/orgs/#{org}/settings/network-configurations/#{network_configuration_id}"

    body = %{}
    api_call(:get, url, body, Noizu.Github.NetworkConfiguration, options)
  end

  @doc """
  Get a hosted compute network settings resource for an organization

  @see https://docs.github.com/rest/orgs/network-configurations#get-a-hosted-compute-network-settings-resource-for-an-organization
  """
  def get_network_settings_for_org(org, network_settings_id, options \\ nil) do
    url = github_base() <> "/orgs/#{org}/settings/network-settings/#{network_settings_id}"
    body = %{}
    api_call(:get, url, body, Noizu.Github.NetworkSettings, options)
  end

  @doc """
  List hosted compute network configurations for an organization

  @see https://docs.github.com/rest/orgs/network-configurations#list-hosted-compute-network-configurations-for-an-organization
  """
  def list_network_configurations_for_org(org, options \\ nil) do
    url =
      (
        query =
          [
            get_field(:per_page, options, nil),
            get_field(:page, options, nil)
          ]
          |> Enum.filter(& &1)

        qs = if query == [], do: "", else: "?" <> Enum.join(query, "&")
        github_base() <> "/orgs/#{org}/settings/network-configurations" <> qs
      )

    body = %{}
    api_call(:get, url, body, Noizu.Github.Raw, options)
  end

  @doc """
  Update a hosted compute network configuration for an organization

  @see https://docs.github.com/rest/orgs/network-configurations#update-a-hosted-compute-network-configuration-for-an-organization
  """
  def update_network_configuration_for_org(org, network_configuration_id, body, options \\ nil) do
    url =
      github_base() <> "/orgs/#{org}/settings/network-configurations/#{network_configuration_id}"

    body = body
    api_call(:patch, url, body, Noizu.Github.NetworkConfiguration, options)
  end
end