# 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.Codespaces do @moduledoc """ GitHub `codespaces` API. """ import Noizu.Github @doc """ Add a selected repository to a user secret @see https://docs.github.com/rest/codespaces/secrets#add-a-selected-repository-to-a-user-secret """ def add_repository_for_secret_for_authenticated_user( secret_name, repository_id, body, options \\ nil ) do url = github_base() <> "/user/codespaces/secrets/#{secret_name}/repositories/#{repository_id}" body = body api_call(:put, url, body, Noizu.Github.Raw, options) end @doc """ Add selected repository to an organization secret @see https://docs.github.com/rest/codespaces/organization-secrets#add-selected-repository-to-an-organization-secret """ def add_selected_repo_to_org_secret(org, secret_name, repository_id, body, options \\ nil) do url = github_base() <> "/orgs/#{org}/codespaces/secrets/#{secret_name}/repositories/#{repository_id}" body = body api_call(:put, url, body, Noizu.Github.Raw, options) end @doc """ Check if permissions defined by a devcontainer have been accepted by the authenticated user @see https://docs.github.com/rest/codespaces/codespaces#check-if-permissions-defined-by-a-devcontainer-have-been-accepted-by-the-authenticated-user """ def check_permissions_for_devcontainer(options \\ nil) do owner = repo_owner(options) repo = repo_name(options) url = ( query = [ get_field(:ref, options, nil), get_field(:devcontainer_path, options, nil) ] |> Enum.filter(& &1) qs = if query == [], do: "", else: "?" <> Enum.join(query, "&") github_base() <> "/repos/#{owner}/#{repo}/codespaces/permissions_check" <> qs ) body = %{} api_call(:get, url, body, Noizu.Github.CodespacesPermissionsCheckForDevcontainer, options) end @doc """ List machine types for a codespace @see https://docs.github.com/rest/codespaces/machines#list-machine-types-for-a-codespace """ def codespace_machines_for_authenticated_user(codespace_name, options \\ nil) do url = github_base() <> "/user/codespaces/#{codespace_name}/machines" body = %{} api_call(:get, url, body, Noizu.Github.Raw, options) end @doc """ Create a codespace for the authenticated user @see https://docs.github.com/rest/codespaces/codespaces#create-a-codespace-for-the-authenticated-user """ def create_for_authenticated_user(body, options \\ nil) do url = github_base() <> "/user/codespaces" body = body api_call(:post, url, body, Noizu.Github.Codespace, options) end @doc """ Create or update an organization secret @see https://docs.github.com/rest/codespaces/organization-secrets#create-or-update-an-organization-secret """ def create_or_update_org_secret(org, secret_name, body, options \\ nil) do url = github_base() <> "/orgs/#{org}/codespaces/secrets/#{secret_name}" body = body api_call(:put, url, body, Noizu.Github.Raw, options) end @doc """ Create or update a repository secret @see https://docs.github.com/rest/codespaces/repository-secrets#create-or-update-a-repository-secret """ def create_or_update_repo_secret(secret_name, body, options \\ nil) do owner = repo_owner(options) repo = repo_name(options) url = github_base() <> "/repos/#{owner}/#{repo}/codespaces/secrets/#{secret_name}" body = body api_call(:put, url, body, Noizu.Github.Raw, options) end @doc """ Create or update a secret for the authenticated user @see https://docs.github.com/rest/codespaces/secrets#create-or-update-a-secret-for-the-authenticated-user """ def create_or_update_secret_for_authenticated_user(secret_name, body, options \\ nil) do url = github_base() <> "/user/codespaces/secrets/#{secret_name}" body = body api_call(:put, url, body, Noizu.Github.Raw, options) end @doc """ Create a codespace from a pull request @see https://docs.github.com/rest/codespaces/codespaces#create-a-codespace-from-a-pull-request """ def create_with_pr_for_authenticated_user(pull_number, body, options \\ nil) do owner = repo_owner(options) repo = repo_name(options) url = github_base() <> "/repos/#{owner}/#{repo}/pulls/#{pull_number}/codespaces" body = body api_call(:post, url, body, Noizu.Github.Codespace, options) end @doc """ Create a codespace in a repository @see https://docs.github.com/rest/codespaces/codespaces#create-a-codespace-in-a-repository """ def create_with_repo_for_authenticated_user(body, options \\ nil) do owner = repo_owner(options) repo = repo_name(options) url = github_base() <> "/repos/#{owner}/#{repo}/codespaces" body = body api_call(:post, url, body, Noizu.Github.Codespace, options) end @doc """ Remove users from Codespaces access for an organization @see https://docs.github.com/rest/codespaces/organizations#remove-users-from-codespaces-access-for-an-organization """ def delete_codespaces_access_users(org, body, options \\ nil) do url = github_base() <> "/orgs/#{org}/codespaces/access/selected_users" body = body api_call(:delete, url, body, Noizu.Github.Raw, options) end @doc """ Delete a codespace for the authenticated user @see https://docs.github.com/rest/codespaces/codespaces#delete-a-codespace-for-the-authenticated-user """ def delete_for_authenticated_user(codespace_name, options \\ nil) do url = github_base() <> "/user/codespaces/#{codespace_name}" body = %{} api_call(:delete, url, body, Noizu.Github.Raw, options) end @doc """ Delete a codespace from the organization @see https://docs.github.com/rest/codespaces/organizations#delete-a-codespace-from-the-organization """ def delete_from_organization(org, username, codespace_name, options \\ nil) do url = github_base() <> "/orgs/#{org}/members/#{username}/codespaces/#{codespace_name}" body = %{} api_call(:delete, url, body, Noizu.Github.Raw, options) end @doc """ Delete an organization secret @see https://docs.github.com/rest/codespaces/organization-secrets#delete-an-organization-secret """ def delete_org_secret(org, secret_name, options \\ nil) do url = github_base() <> "/orgs/#{org}/codespaces/secrets/#{secret_name}" body = %{} api_call(:delete, url, body, Noizu.Github.Raw, options) end @doc """ Delete a repository secret @see https://docs.github.com/rest/codespaces/repository-secrets#delete-a-repository-secret """ def delete_repo_secret(secret_name, options \\ nil) do owner = repo_owner(options) repo = repo_name(options) url = github_base() <> "/repos/#{owner}/#{repo}/codespaces/secrets/#{secret_name}" body = %{} api_call(:delete, url, body, Noizu.Github.Raw, options) end @doc """ Delete a secret for the authenticated user @see https://docs.github.com/rest/codespaces/secrets#delete-a-secret-for-the-authenticated-user """ def delete_secret_for_authenticated_user(secret_name, options \\ nil) do url = github_base() <> "/user/codespaces/secrets/#{secret_name}" body = %{} api_call(:delete, url, body, Noizu.Github.Raw, options) end @doc """ Export a codespace for the authenticated user @see https://docs.github.com/rest/codespaces/codespaces#export-a-codespace-for-the-authenticated-user """ def export_for_authenticated_user(codespace_name, body, options \\ nil) do url = github_base() <> "/user/codespaces/#{codespace_name}/exports" body = body api_call(:post, url, body, Noizu.Github.CodespaceExportDetails, options) end @doc """ List codespaces for a user in organization @see https://docs.github.com/rest/codespaces/organizations#list-codespaces-for-a-user-in-organization """ def get_codespaces_for_user_in_org(org, username, 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}/members/#{username}/codespaces" <> qs ) body = %{} api_call(:get, url, body, Noizu.Github.Raw, options) end @doc """ Get details about a codespace export @see https://docs.github.com/rest/codespaces/codespaces#get-details-about-a-codespace-export """ def get_export_details_for_authenticated_user(codespace_name, export_id, options \\ nil) do url = github_base() <> "/user/codespaces/#{codespace_name}/exports/#{export_id}" body = %{} api_call(:get, url, body, Noizu.Github.CodespaceExportDetails, options) end @doc """ Get a codespace for the authenticated user @see https://docs.github.com/rest/codespaces/codespaces#get-a-codespace-for-the-authenticated-user """ def get_for_authenticated_user(codespace_name, options \\ nil) do url = github_base() <> "/user/codespaces/#{codespace_name}" body = %{} api_call(:get, url, body, Noizu.Github.Codespace, options) end @doc """ Get an organization public key @see https://docs.github.com/rest/codespaces/organization-secrets#get-an-organization-public-key """ def get_org_public_key(org, options \\ nil) do url = github_base() <> "/orgs/#{org}/codespaces/secrets/public-key" body = %{} api_call(:get, url, body, Noizu.Github.CodespacesPublicKey, options) end @doc """ Get an organization secret @see https://docs.github.com/rest/codespaces/organization-secrets#get-an-organization-secret """ def get_org_secret(org, secret_name, options \\ nil) do url = github_base() <> "/orgs/#{org}/codespaces/secrets/#{secret_name}" body = %{} api_call(:get, url, body, Noizu.Github.CodespacesOrgSecret, options) end @doc """ Get public key for the authenticated user @see https://docs.github.com/rest/codespaces/secrets#get-public-key-for-the-authenticated-user """ def get_public_key_for_authenticated_user(options \\ nil) do url = github_base() <> "/user/codespaces/secrets/public-key" body = %{} api_call(:get, url, body, Noizu.Github.CodespacesUserPublicKey, options) end @doc """ Get a repository public key @see https://docs.github.com/rest/codespaces/repository-secrets#get-a-repository-public-key """ def get_repo_public_key(options \\ nil) do owner = repo_owner(options) repo = repo_name(options) url = github_base() <> "/repos/#{owner}/#{repo}/codespaces/secrets/public-key" body = %{} api_call(:get, url, body, Noizu.Github.CodespacesPublicKey, options) end @doc """ Get a repository secret @see https://docs.github.com/rest/codespaces/repository-secrets#get-a-repository-secret """ def get_repo_secret(secret_name, options \\ nil) do owner = repo_owner(options) repo = repo_name(options) url = github_base() <> "/repos/#{owner}/#{repo}/codespaces/secrets/#{secret_name}" body = %{} api_call(:get, url, body, Noizu.Github.RepoCodespacesSecret, options) end @doc """ Get a secret for the authenticated user @see https://docs.github.com/rest/codespaces/secrets#get-a-secret-for-the-authenticated-user """ def get_secret_for_authenticated_user(secret_name, options \\ nil) do url = github_base() <> "/user/codespaces/secrets/#{secret_name}" body = %{} api_call(:get, url, body, Noizu.Github.CodespacesSecret, options) end @doc """ List devcontainer configurations in a repository for the authenticated user @see https://docs.github.com/rest/codespaces/codespaces#list-devcontainer-configurations-in-a-repository-for-the-authenticated-user """ def list_devcontainers_in_repository_for_authenticated_user(options \\ nil) do owner = repo_owner(options) repo = repo_name(options) 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() <> "/repos/#{owner}/#{repo}/codespaces/devcontainers" <> qs ) body = %{} api_call(:get, url, body, Noizu.Github.Raw, options) end @doc """ List codespaces for the authenticated user @see https://docs.github.com/rest/codespaces/codespaces#list-codespaces-for-the-authenticated-user """ def list_for_authenticated_user(options \\ nil) do url = ( query = [ get_field(:per_page, options, nil), get_field(:page, options, nil), get_field(:repository_id, options, nil) ] |> Enum.filter(& &1) qs = if query == [], do: "", else: "?" <> Enum.join(query, "&") github_base() <> "/user/codespaces" <> qs ) body = %{} api_call(:get, url, body, Noizu.Github.Raw, options) end @doc """ List codespaces for the organization @see https://docs.github.com/rest/codespaces/organizations#list-codespaces-for-the-organization """ def list_in_organization(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}/codespaces" <> qs ) body = %{} api_call(:get, url, body, Noizu.Github.Raw, options) end @doc """ List codespaces in a repository for the authenticated user @see https://docs.github.com/rest/codespaces/codespaces#list-codespaces-in-a-repository-for-the-authenticated-user """ def list_in_repository_for_authenticated_user(options \\ nil) do owner = repo_owner(options) repo = repo_name(options) 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() <> "/repos/#{owner}/#{repo}/codespaces" <> qs ) body = %{} api_call(:get, url, body, Noizu.Github.Raw, options) end @doc """ List organization secrets @see https://docs.github.com/rest/codespaces/organization-secrets#list-organization-secrets """ def list_org_secrets(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}/codespaces/secrets" <> qs ) body = %{} api_call(:get, url, body, Noizu.Github.Raw, options) end @doc """ List repository secrets @see https://docs.github.com/rest/codespaces/repository-secrets#list-repository-secrets """ def list_repo_secrets(options \\ nil) do owner = repo_owner(options) repo = repo_name(options) 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() <> "/repos/#{owner}/#{repo}/codespaces/secrets" <> qs ) body = %{} api_call(:get, url, body, Noizu.Github.Raw, options) end @doc """ List selected repositories for a user secret @see https://docs.github.com/rest/codespaces/secrets#list-selected-repositories-for-a-user-secret """ def list_repositories_for_secret_for_authenticated_user(secret_name, options \\ nil) do url = github_base() <> "/user/codespaces/secrets/#{secret_name}/repositories" body = %{} api_call(:get, url, body, Noizu.Github.Raw, options) end @doc """ List secrets for the authenticated user @see https://docs.github.com/rest/codespaces/secrets#list-secrets-for-the-authenticated-user """ def list_secrets_for_authenticated_user(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() <> "/user/codespaces/secrets" <> qs ) body = %{} api_call(:get, url, body, Noizu.Github.Raw, options) end @doc """ List selected repositories for an organization secret @see https://docs.github.com/rest/codespaces/organization-secrets#list-selected-repositories-for-an-organization-secret """ def list_selected_repos_for_org_secret(org, secret_name, options \\ nil) do url = ( query = [ get_field(:page, options, nil), get_field(:per_page, options, nil) ] |> Enum.filter(& &1) qs = if query == [], do: "", else: "?" <> Enum.join(query, "&") github_base() <> "/orgs/#{org}/codespaces/secrets/#{secret_name}/repositories" <> qs ) body = %{} api_call(:get, url, body, Noizu.Github.Raw, options) end @doc """ Get default attributes for a codespace @see https://docs.github.com/rest/codespaces/codespaces#get-default-attributes-for-a-codespace """ def pre_flight_with_repo_for_authenticated_user(options \\ nil) do owner = repo_owner(options) repo = repo_name(options) url = ( query = [ get_field(:ref, options, nil), get_field(:client_ip, options, nil) ] |> Enum.filter(& &1) qs = if query == [], do: "", else: "?" <> Enum.join(query, "&") github_base() <> "/repos/#{owner}/#{repo}/codespaces/new" <> qs ) body = %{} api_call(:get, url, body, Noizu.Github.Raw, options) end @doc """ Create a repository from an unpublished codespace @see https://docs.github.com/rest/codespaces/codespaces#create-a-repository-from-an-unpublished-codespace """ def publish_for_authenticated_user(codespace_name, body, options \\ nil) do url = github_base() <> "/user/codespaces/#{codespace_name}/publish" body = body api_call(:post, url, body, Noizu.Github.CodespaceWithFullRepository, options) end @doc """ Remove a selected repository from a user secret @see https://docs.github.com/rest/codespaces/secrets#remove-a-selected-repository-from-a-user-secret """ def remove_repository_for_secret_for_authenticated_user( secret_name, repository_id, options \\ nil ) do url = github_base() <> "/user/codespaces/secrets/#{secret_name}/repositories/#{repository_id}" body = %{} api_call(:delete, url, body, Noizu.Github.Raw, options) end @doc """ Remove selected repository from an organization secret @see https://docs.github.com/rest/codespaces/organization-secrets#remove-selected-repository-from-an-organization-secret """ def remove_selected_repo_from_org_secret(org, secret_name, repository_id, options \\ nil) do url = github_base() <> "/orgs/#{org}/codespaces/secrets/#{secret_name}/repositories/#{repository_id}" body = %{} api_call(:delete, url, body, Noizu.Github.Raw, options) end @doc """ List available machine types for a repository @see https://docs.github.com/rest/codespaces/machines#list-available-machine-types-for-a-repository """ def repo_machines_for_authenticated_user(options \\ nil) do owner = repo_owner(options) repo = repo_name(options) url = ( query = [ get_field(:location, options, nil), get_field(:client_ip, options, nil), get_field(:ref, options, nil) ] |> Enum.filter(& &1) qs = if query == [], do: "", else: "?" <> Enum.join(query, "&") github_base() <> "/repos/#{owner}/#{repo}/codespaces/machines" <> qs ) body = %{} api_call(:get, url, body, Noizu.Github.Raw, options) end @doc """ Manage access control for organization codespaces @see https://docs.github.com/rest/codespaces/organizations#manage-access-control-for-organization-codespaces """ def set_codespaces_access(org, body, options \\ nil) do url = github_base() <> "/orgs/#{org}/codespaces/access" body = body api_call(:put, url, body, Noizu.Github.Raw, options) end @doc """ Add users to Codespaces access for an organization @see https://docs.github.com/rest/codespaces/organizations#add-users-to-codespaces-access-for-an-organization """ def set_codespaces_access_users(org, body, options \\ nil) do url = github_base() <> "/orgs/#{org}/codespaces/access/selected_users" body = body api_call(:post, url, body, Noizu.Github.Raw, options) end @doc """ Set selected repositories for a user secret @see https://docs.github.com/rest/codespaces/secrets#set-selected-repositories-for-a-user-secret """ def set_repositories_for_secret_for_authenticated_user(secret_name, body, options \\ nil) do url = github_base() <> "/user/codespaces/secrets/#{secret_name}/repositories" body = body api_call(:put, url, body, Noizu.Github.Raw, options) end @doc """ Set selected repositories for an organization secret @see https://docs.github.com/rest/codespaces/organization-secrets#set-selected-repositories-for-an-organization-secret """ def set_selected_repos_for_org_secret(org, secret_name, body, options \\ nil) do url = github_base() <> "/orgs/#{org}/codespaces/secrets/#{secret_name}/repositories" body = body api_call(:put, url, body, Noizu.Github.Raw, options) end @doc """ Start a codespace for the authenticated user @see https://docs.github.com/rest/codespaces/codespaces#start-a-codespace-for-the-authenticated-user """ def start_for_authenticated_user(codespace_name, body, options \\ nil) do url = github_base() <> "/user/codespaces/#{codespace_name}/start" body = body api_call(:post, url, body, Noizu.Github.Codespace, options) end @doc """ Stop a codespace for the authenticated user @see https://docs.github.com/rest/codespaces/codespaces#stop-a-codespace-for-the-authenticated-user """ def stop_for_authenticated_user(codespace_name, body, options \\ nil) do url = github_base() <> "/user/codespaces/#{codespace_name}/stop" body = body api_call(:post, url, body, Noizu.Github.Codespace, options) end @doc """ Stop a codespace for an organization user @see https://docs.github.com/rest/codespaces/organizations#stop-a-codespace-for-an-organization-user """ def stop_in_organization(org, username, codespace_name, body, options \\ nil) do url = github_base() <> "/orgs/#{org}/members/#{username}/codespaces/#{codespace_name}/stop" body = body api_call(:post, url, body, Noizu.Github.Codespace, options) end @doc """ Update a codespace for the authenticated user @see https://docs.github.com/rest/codespaces/codespaces#update-a-codespace-for-the-authenticated-user """ def update_for_authenticated_user(codespace_name, body, options \\ nil) do url = github_base() <> "/user/codespaces/#{codespace_name}" body = body api_call(:patch, url, body, Noizu.Github.Codespace, options) end end