Skip to main content

lib/api/interactions/interactions.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.Interactions do
  @moduledoc """
  GitHub `interactions` API.
  """
  import Noizu.Github

  @doc """
  Get pull request creation cap bypass list for a repository

  @see https://docs.github.com/rest/interactions/repos#get-pull-request-creation-cap-bypass-list-for-a-repository
  """
  def get_pull_request_bypass_list_for_repo(options \\ nil) do
    owner = repo_owner(options)
    repo = repo_name(options)
    url = github_base() <> "/repos/#{owner}/#{repo}/interaction-limits/pulls/bypass-list"
    body = %{}
    api_call(:get, url, body, Noizu.Github.Collection.SimpleUser, options)
  end

  @doc """
  Get interaction restrictions for your public repositories

  @see https://docs.github.com/rest/interactions/user#get-interaction-restrictions-for-your-public-repositories
  """
  def get_restrictions_for_authenticated_user(options \\ nil) do
    url = github_base() <> "/user/interaction-limits"
    body = %{}
    api_call(:get, url, body, Noizu.Github.Raw, options)
  end

  @doc """
  Get interaction restrictions for an organization

  @see https://docs.github.com/rest/interactions/orgs#get-interaction-restrictions-for-an-organization
  """
  def get_restrictions_for_org(org, options \\ nil) do
    url = github_base() <> "/orgs/#{org}/interaction-limits"
    body = %{}
    api_call(:get, url, body, Noizu.Github.Raw, options)
  end

  @doc """
  Get interaction restrictions for a repository

  @see https://docs.github.com/rest/interactions/repos#get-interaction-restrictions-for-a-repository
  """
  def get_restrictions_for_repo(options \\ nil) do
    owner = repo_owner(options)
    repo = repo_name(options)
    url = github_base() <> "/repos/#{owner}/#{repo}/interaction-limits"
    body = %{}
    api_call(:get, url, body, Noizu.Github.Raw, options)
  end

  @doc """
  Remove users from the pull request creation cap bypass list for a repository

  @see https://docs.github.com/rest/interactions/repos#remove-users-from-the-pull-request-creation-cap-bypass-list-for-a-repository
  """
  def remove_pull_request_bypass_list_for_repo(body, options \\ nil) do
    owner = repo_owner(options)
    repo = repo_name(options)
    url = github_base() <> "/repos/#{owner}/#{repo}/interaction-limits/pulls/bypass-list"
    body = body
    api_call(:delete, url, body, Noizu.Github.Raw, options)
  end

  @doc """
  Remove interaction restrictions from your public repositories

  @see https://docs.github.com/rest/interactions/user#remove-interaction-restrictions-from-your-public-repositories
  """
  def remove_restrictions_for_authenticated_user(options \\ nil) do
    url = github_base() <> "/user/interaction-limits"
    body = %{}
    api_call(:delete, url, body, Noizu.Github.Raw, options)
  end

  @doc """
  Remove interaction restrictions for an organization

  @see https://docs.github.com/rest/interactions/orgs#remove-interaction-restrictions-for-an-organization
  """
  def remove_restrictions_for_org(org, options \\ nil) do
    url = github_base() <> "/orgs/#{org}/interaction-limits"
    body = %{}
    api_call(:delete, url, body, Noizu.Github.Raw, options)
  end

  @doc """
  Remove interaction restrictions for a repository

  @see https://docs.github.com/rest/interactions/repos#remove-interaction-restrictions-for-a-repository
  """
  def remove_restrictions_for_repo(options \\ nil) do
    owner = repo_owner(options)
    repo = repo_name(options)
    url = github_base() <> "/repos/#{owner}/#{repo}/interaction-limits"
    body = %{}
    api_call(:delete, url, body, Noizu.Github.Raw, options)
  end

  @doc """
  Add users to the pull request creation cap bypass list for a repository

  @see https://docs.github.com/rest/interactions/repos#add-users-to-the-pull-request-creation-cap-bypass-list-for-a-repository
  """
  def set_pull_request_bypass_list_for_repo(body, options \\ nil) do
    owner = repo_owner(options)
    repo = repo_name(options)
    url = github_base() <> "/repos/#{owner}/#{repo}/interaction-limits/pulls/bypass-list"
    body = body
    api_call(:put, url, body, Noizu.Github.Raw, options)
  end

  @doc """
  Set interaction restrictions for your public repositories

  @see https://docs.github.com/rest/interactions/user#set-interaction-restrictions-for-your-public-repositories
  """
  def set_restrictions_for_authenticated_user(body, options \\ nil) do
    url = github_base() <> "/user/interaction-limits"
    body = body
    api_call(:put, url, body, Noizu.Github.InteractionLimitResponse, options)
  end

  @doc """
  Set interaction restrictions for an organization

  @see https://docs.github.com/rest/interactions/orgs#set-interaction-restrictions-for-an-organization
  """
  def set_restrictions_for_org(org, body, options \\ nil) do
    url = github_base() <> "/orgs/#{org}/interaction-limits"
    body = body
    api_call(:put, url, body, Noizu.Github.InteractionLimitResponse, options)
  end

  @doc """
  Set interaction restrictions for a repository

  @see https://docs.github.com/rest/interactions/repos#set-interaction-restrictions-for-a-repository
  """
  def set_restrictions_for_repo(body, options \\ nil) do
    owner = repo_owner(options)
    repo = repo_name(options)
    url = github_base() <> "/repos/#{owner}/#{repo}/interaction-limits"
    body = body
    api_call(:put, url, body, Noizu.Github.InteractionLimitResponse, options)
  end
end