Skip to main content

lib/api/copilot_spaces/copilot_spaces.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.CopilotSpaces do
  @moduledoc """
  GitHub `copilot-spaces` API.
  """
  import Noizu.Github

  @doc """
  Add a collaborator to an organization Copilot Space

  @see https://docs.github.com/rest/copilot-spaces/collaborators#add-a-collaborator-to-an-organization-copilot-space
  """
  def add_collaborator_for_org(org, space_number, body, options \\ nil) do
    url = github_base() <> "/orgs/#{org}/copilot-spaces/#{space_number}/collaborators"
    body = body
    api_call(:post, url, body, Noizu.Github.Raw, options)
  end

  @doc """
  Add a collaborator to a Copilot Space for a user

  @see https://docs.github.com/rest/copilot-spaces/collaborators#add-a-collaborator-to-a-copilot-space-for-a-user
  """
  def add_collaborator_for_user(username, space_number, body, options \\ nil) do
    url = github_base() <> "/users/#{username}/copilot-spaces/#{space_number}/collaborators"
    body = body
    api_call(:post, url, body, Noizu.Github.Raw, options)
  end

  @doc """
  Create an organization Copilot Space

  @see https://docs.github.com/rest/copilot-spaces/copilot-spaces#create-an-organization-copilot-space
  """
  def create_for_org(org, body, options \\ nil) do
    url = github_base() <> "/orgs/#{org}/copilot-spaces"
    body = body
    api_call(:post, url, body, Noizu.Github.CopilotSpace, options)
  end

  @doc """
  Create a Copilot Space for a user

  @see https://docs.github.com/rest/copilot-spaces/copilot-spaces#create-a-copilot-space-for-a-user
  """
  def create_for_user(username, body, options \\ nil) do
    url = github_base() <> "/users/#{username}/copilot-spaces"
    body = body
    api_call(:post, url, body, Noizu.Github.CopilotSpace, options)
  end

  @doc """
  Create a resource for an organization Copilot Space

  @see https://docs.github.com/rest/copilot-spaces/resources#create-a-resource-for-an-organization-copilot-space
  """
  def create_resource_for_org(org, space_number, body, options \\ nil) do
    url = github_base() <> "/orgs/#{org}/copilot-spaces/#{space_number}/resources"
    body = body
    api_call(:post, url, body, Noizu.Github.CopilotSpaceResource, options)
  end

  @doc """
  Create a resource for a Copilot Space for a user

  @see https://docs.github.com/rest/copilot-spaces/resources#create-a-resource-for-a-copilot-space-for-a-user
  """
  def create_resource_for_user(username, space_number, body, options \\ nil) do
    url = github_base() <> "/users/#{username}/copilot-spaces/#{space_number}/resources"
    body = body
    api_call(:post, url, body, Noizu.Github.CopilotSpaceResource, options)
  end

  @doc """
  Delete an organization Copilot Space

  @see https://docs.github.com/rest/copilot-spaces/copilot-spaces#delete-an-organization-copilot-space
  """
  def delete_for_org(org, space_number, options \\ nil) do
    url = github_base() <> "/orgs/#{org}/copilot-spaces/#{space_number}"
    body = %{}
    api_call(:delete, url, body, Noizu.Github.Raw, options)
  end

  @doc """
  Delete a Copilot Space for a user

  @see https://docs.github.com/rest/copilot-spaces/copilot-spaces#delete-a-copilot-space-for-a-user
  """
  def delete_for_user(username, space_number, options \\ nil) do
    url = github_base() <> "/users/#{username}/copilot-spaces/#{space_number}"
    body = %{}
    api_call(:delete, url, body, Noizu.Github.Raw, options)
  end

  @doc """
  Delete a resource from an organization Copilot Space

  @see https://docs.github.com/rest/copilot-spaces/resources#delete-a-resource-from-an-organization-copilot-space
  """
  def delete_resource_for_org(org, space_number, space_resource_id, options \\ nil) do
    url =
      github_base() <>
        "/orgs/#{org}/copilot-spaces/#{space_number}/resources/#{space_resource_id}"

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

  @doc """
  Delete a resource from a Copilot Space for a user

  @see https://docs.github.com/rest/copilot-spaces/resources#delete-a-resource-from-a-copilot-space-for-a-user
  """
  def delete_resource_for_user(username, space_number, space_resource_id, options \\ nil) do
    url =
      github_base() <>
        "/users/#{username}/copilot-spaces/#{space_number}/resources/#{space_resource_id}"

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

  @doc """
  Get an organization Copilot Space

  @see https://docs.github.com/rest/copilot-spaces/copilot-spaces#get-an-organization-copilot-space
  """
  def get_for_org(org, space_number, options \\ nil) do
    url = github_base() <> "/orgs/#{org}/copilot-spaces/#{space_number}"
    body = %{}
    api_call(:get, url, body, Noizu.Github.CopilotSpace, options)
  end

  @doc """
  Get a Copilot Space for a user

  @see https://docs.github.com/rest/copilot-spaces/copilot-spaces#get-a-copilot-space-for-a-user
  """
  def get_for_user(username, space_number, options \\ nil) do
    url = github_base() <> "/users/#{username}/copilot-spaces/#{space_number}"
    body = %{}
    api_call(:get, url, body, Noizu.Github.CopilotSpace, options)
  end

  @doc """
  Get a resource for an organization Copilot Space

  @see https://docs.github.com/rest/copilot-spaces/resources#get-a-resource-for-an-organization-copilot-space
  """
  def get_resource_for_org(org, space_number, space_resource_id, options \\ nil) do
    url =
      github_base() <>
        "/orgs/#{org}/copilot-spaces/#{space_number}/resources/#{space_resource_id}"

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

  @doc """
  Get a resource for a Copilot Space for a user

  @see https://docs.github.com/rest/copilot-spaces/resources#get-a-resource-for-a-copilot-space-for-a-user
  """
  def get_resource_for_user(username, space_number, space_resource_id, options \\ nil) do
    url =
      github_base() <>
        "/users/#{username}/copilot-spaces/#{space_number}/resources/#{space_resource_id}"

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

  @doc """
  List collaborators for an organization Copilot Space

  @see https://docs.github.com/rest/copilot-spaces/collaborators#list-collaborators-for-an-organization-copilot-space
  """
  def list_collaborators_for_org(org, space_number, options \\ nil) do
    url = github_base() <> "/orgs/#{org}/copilot-spaces/#{space_number}/collaborators"
    body = %{}
    api_call(:get, url, body, Noizu.Github.Raw, options)
  end

  @doc """
  List collaborators for a Copilot Space for a user

  @see https://docs.github.com/rest/copilot-spaces/collaborators#list-collaborators-for-a-copilot-space-for-a-user
  """
  def list_collaborators_for_user(username, space_number, options \\ nil) do
    url = github_base() <> "/users/#{username}/copilot-spaces/#{space_number}/collaborators"
    body = %{}
    api_call(:get, url, body, Noizu.Github.Raw, options)
  end

  @doc """
  List organization Copilot Spaces

  @see https://docs.github.com/rest/copilot-spaces/copilot-spaces#list-organization-copilot-spaces
  """
  def list_for_org(org, options \\ nil) do
    url =
      (
        query =
          [
            get_field(:per_page, options, nil),
            get_field(:before, options, nil),
            get_field(:after, options, nil)
          ]
          |> Enum.filter(& &1)

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

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

  @doc """
  List Copilot Spaces for a user

  @see https://docs.github.com/rest/copilot-spaces/copilot-spaces#list-copilot-spaces-for-a-user
  """
  def list_for_user(username, options \\ nil) do
    url =
      (
        query =
          [
            get_field(:per_page, options, nil),
            get_field(:before, options, nil),
            get_field(:after, options, nil)
          ]
          |> Enum.filter(& &1)

        qs = if query == [], do: "", else: "?" <> Enum.join(query, "&")
        github_base() <> "/users/#{username}/copilot-spaces" <> qs
      )

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

  @doc """
  List resources for an organization Copilot Space

  @see https://docs.github.com/rest/copilot-spaces/resources#list-resources-for-an-organization-copilot-space
  """
  def list_resources_for_org(org, space_number, options \\ nil) do
    url = github_base() <> "/orgs/#{org}/copilot-spaces/#{space_number}/resources"
    body = %{}
    api_call(:get, url, body, Noizu.Github.Raw, options)
  end

  @doc """
  List resources for a Copilot Space for a user

  @see https://docs.github.com/rest/copilot-spaces/resources#list-resources-for-a-copilot-space-for-a-user
  """
  def list_resources_for_user(username, space_number, options \\ nil) do
    url = github_base() <> "/users/#{username}/copilot-spaces/#{space_number}/resources"
    body = %{}
    api_call(:get, url, body, Noizu.Github.Raw, options)
  end

  @doc """
  Remove a collaborator from an organization Copilot Space

  @see https://docs.github.com/rest/copilot-spaces/collaborators#remove-a-collaborator-from-an-organization-copilot-space
  """
  def remove_collaborator_for_org(org, space_number, actor_type, actor_identifier, options \\ nil) do
    url =
      github_base() <>
        "/orgs/#{org}/copilot-spaces/#{space_number}/collaborators/#{actor_type}/#{actor_identifier}"

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

  @doc """
  Remove a collaborator from a Copilot Space for a user

  @see https://docs.github.com/rest/copilot-spaces/collaborators#remove-a-collaborator-from-a-copilot-space-for-a-user
  """
  def remove_collaborator_for_user(
        username,
        space_number,
        actor_type,
        actor_identifier,
        options \\ nil
      ) do
    url =
      github_base() <>
        "/users/#{username}/copilot-spaces/#{space_number}/collaborators/#{actor_type}/#{actor_identifier}"

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

  @doc """
  Set a collaborator role for an organization Copilot Space

  @see https://docs.github.com/rest/copilot-spaces/collaborators#set-a-collaborator-role-for-an-organization-copilot-space
  """
  def update_collaborator_for_org(
        org,
        space_number,
        actor_type,
        actor_identifier,
        body,
        options \\ nil
      ) do
    url =
      github_base() <>
        "/orgs/#{org}/copilot-spaces/#{space_number}/collaborators/#{actor_type}/#{actor_identifier}"

    body = body
    api_call(:put, url, body, Noizu.Github.Raw, options)
  end

  @doc """
  Set a collaborator role for a Copilot Space for a user

  @see https://docs.github.com/rest/copilot-spaces/collaborators#set-a-collaborator-role-for-a-copilot-space-for-a-user
  """
  def update_collaborator_for_user(
        username,
        space_number,
        actor_type,
        actor_identifier,
        body,
        options \\ nil
      ) do
    url =
      github_base() <>
        "/users/#{username}/copilot-spaces/#{space_number}/collaborators/#{actor_type}/#{actor_identifier}"

    body = body
    api_call(:put, url, body, Noizu.Github.Raw, options)
  end

  @doc """
  Set an organization Copilot Space

  @see https://docs.github.com/rest/copilot-spaces/copilot-spaces#set-an-organization-copilot-space
  """
  def update_for_org(org, space_number, body, options \\ nil) do
    url = github_base() <> "/orgs/#{org}/copilot-spaces/#{space_number}"
    body = body
    api_call(:put, url, body, Noizu.Github.CopilotSpace, options)
  end

  @doc """
  Set a Copilot Space for a user

  @see https://docs.github.com/rest/copilot-spaces/copilot-spaces#set-a-copilot-space-for-a-user
  """
  def update_for_user(username, space_number, body, options \\ nil) do
    url = github_base() <> "/users/#{username}/copilot-spaces/#{space_number}"
    body = body
    api_call(:put, url, body, Noizu.Github.CopilotSpace, options)
  end

  @doc """
  Set a resource for an organization Copilot Space

  @see https://docs.github.com/rest/copilot-spaces/resources#set-a-resource-for-an-organization-copilot-space
  """
  def update_resource_for_org(org, space_number, space_resource_id, body, options \\ nil) do
    url =
      github_base() <>
        "/orgs/#{org}/copilot-spaces/#{space_number}/resources/#{space_resource_id}"

    body = body
    api_call(:put, url, body, Noizu.Github.CopilotSpaceResource, options)
  end

  @doc """
  Set a resource for a Copilot Space for a user

  @see https://docs.github.com/rest/copilot-spaces/resources#set-a-resource-for-a-copilot-space-for-a-user
  """
  def update_resource_for_user(username, space_number, space_resource_id, body, options \\ nil) do
    url =
      github_base() <>
        "/users/#{username}/copilot-spaces/#{space_number}/resources/#{space_resource_id}"

    body = body
    api_call(:put, url, body, Noizu.Github.CopilotSpaceResource, options)
  end
end