# 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.Teams do @moduledoc """ GitHub `teams` API. """ import Noizu.Github @doc """ Add team member (Legacy) @see https://docs.github.com/rest/teams/members#add-team-member-legacy """ def add_member_legacy(team_id, username, body, options \\ nil) do url = github_base() <> "/teams/#{team_id}/members/#{username}" body = body api_call(:put, url, body, Noizu.Github.Raw, options) end @doc """ Add or update team membership for a user @see https://docs.github.com/rest/teams/members#add-or-update-team-membership-for-a-user """ def add_or_update_membership_for_user_in_org(org, team_slug, username, body, options \\ nil) do url = github_base() <> "/orgs/#{org}/teams/#{team_slug}/memberships/#{username}" body = body api_call(:put, url, body, Noizu.Github.TeamMembership, options) end @doc """ Add or update team membership for a user (Legacy) @see https://docs.github.com/rest/teams/members#add-or-update-team-membership-for-a-user-legacy """ def add_or_update_membership_for_user_legacy(team_id, username, body, options \\ nil) do url = github_base() <> "/teams/#{team_id}/memberships/#{username}" body = body api_call(:put, url, body, Noizu.Github.TeamMembership, options) end @doc """ Add or update team repository permissions @see https://docs.github.com/rest/teams/teams#add-or-update-team-repository-permissions """ def add_or_update_repo_permissions_in_org(org, team_slug, body, options \\ nil) do owner = repo_owner(options) repo = repo_name(options) url = github_base() <> "/orgs/#{org}/teams/#{team_slug}/repos/#{owner}/#{repo}" body = body api_call(:put, url, body, Noizu.Github.Raw, options) end @doc """ Add or update team repository permissions (Legacy) @see https://docs.github.com/rest/teams/teams#add-or-update-team-repository-permissions-legacy """ def add_or_update_repo_permissions_legacy(team_id, body, options \\ nil) do owner = repo_owner(options) repo = repo_name(options) url = github_base() <> "/teams/#{team_id}/repos/#{owner}/#{repo}" body = body api_call(:put, url, body, Noizu.Github.Raw, options) end @doc """ Check team permissions for a repository @see https://docs.github.com/rest/teams/teams#check-team-permissions-for-a-repository """ def check_permissions_for_repo_in_org(org, team_slug, options \\ nil) do owner = repo_owner(options) repo = repo_name(options) url = github_base() <> "/orgs/#{org}/teams/#{team_slug}/repos/#{owner}/#{repo}" body = %{} api_call(:get, url, body, Noizu.Github.TeamRepository, options) end @doc """ Check team permissions for a repository (Legacy) @see https://docs.github.com/rest/teams/teams#check-team-permissions-for-a-repository-legacy """ def check_permissions_for_repo_legacy(team_id, options \\ nil) do owner = repo_owner(options) repo = repo_name(options) url = github_base() <> "/teams/#{team_id}/repos/#{owner}/#{repo}" body = %{} api_call(:get, url, body, Noizu.Github.TeamRepository, options) end @doc """ Create a team @see https://docs.github.com/rest/teams/teams#create-a-team """ def create(org, body, options \\ nil) do url = github_base() <> "/orgs/#{org}/teams" body = body api_call(:post, url, body, Noizu.Github.TeamFull, options) end @doc """ Delete a team @see https://docs.github.com/rest/teams/teams#delete-a-team """ def delete_in_org(org, team_slug, options \\ nil) do url = github_base() <> "/orgs/#{org}/teams/#{team_slug}" body = %{} api_call(:delete, url, body, Noizu.Github.Raw, options) end @doc """ Delete a team (Legacy) @see https://docs.github.com/rest/teams/teams#delete-a-team-legacy """ def delete_legacy(team_id, options \\ nil) do url = github_base() <> "/teams/#{team_id}" body = %{} api_call(:delete, url, body, Noizu.Github.Raw, options) end @doc """ Get a team by name @see https://docs.github.com/rest/teams/teams#get-a-team-by-name """ def get_by_name(org, team_slug, options \\ nil) do url = github_base() <> "/orgs/#{org}/teams/#{team_slug}" body = %{} api_call(:get, url, body, Noizu.Github.TeamFull, options) end @doc """ Get a team (Legacy) @see https://docs.github.com/rest/teams/teams#get-a-team-legacy """ def get_legacy(team_id, options \\ nil) do url = github_base() <> "/teams/#{team_id}" body = %{} api_call(:get, url, body, Noizu.Github.TeamFull, options) end @doc """ Get team member (Legacy) @see https://docs.github.com/rest/teams/members#get-team-member-legacy """ def get_member_legacy(team_id, username, options \\ nil) do url = github_base() <> "/teams/#{team_id}/members/#{username}" body = %{} api_call(:get, url, body, Noizu.Github.Raw, options) end @doc """ Get team membership for a user @see https://docs.github.com/rest/teams/members#get-team-membership-for-a-user """ def get_membership_for_user_in_org(org, team_slug, username, options \\ nil) do url = github_base() <> "/orgs/#{org}/teams/#{team_slug}/memberships/#{username}" body = %{} api_call(:get, url, body, Noizu.Github.TeamMembership, options) end @doc """ Get team membership for a user (Legacy) @see https://docs.github.com/rest/teams/members#get-team-membership-for-a-user-legacy """ def get_membership_for_user_legacy(team_id, username, options \\ nil) do url = github_base() <> "/teams/#{team_id}/memberships/#{username}" body = %{} api_call(:get, url, body, Noizu.Github.TeamMembership, options) end @doc """ List teams @see https://docs.github.com/rest/teams/teams#list-teams """ def list(org, options \\ nil) do url = ( query = [ get_field(:per_page, options, nil), get_field(:page, options, nil), get_field(:team_type, options, nil) ] |> Enum.filter(& &1) qs = if query == [], do: "", else: "?" <> Enum.join(query, "&") github_base() <> "/orgs/#{org}/teams" <> qs ) body = %{} api_call(:get, url, body, Noizu.Github.Collection.Team, options) end @doc """ List child teams @see https://docs.github.com/rest/teams/teams#list-child-teams """ def list_child_in_org(org, team_slug, 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}/teams/#{team_slug}/teams" <> qs ) body = %{} api_call(:get, url, body, Noizu.Github.Collection.Team, options) end @doc """ List child teams (Legacy) @see https://docs.github.com/rest/teams/teams#list-child-teams-legacy """ def list_child_legacy(team_id, 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() <> "/teams/#{team_id}/teams" <> qs ) body = %{} api_call(:get, url, body, Noizu.Github.Collection.Team, options) end @doc """ List teams for the authenticated user @see https://docs.github.com/rest/teams/teams#list-teams-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) ] |> Enum.filter(& &1) qs = if query == [], do: "", else: "?" <> Enum.join(query, "&") github_base() <> "/user/teams" <> qs ) body = %{} api_call(:get, url, body, Noizu.Github.Collection.TeamFull, options) end @doc """ List team members @see https://docs.github.com/rest/teams/members#list-team-members """ def list_members_in_org(org, team_slug, options \\ nil) do url = ( query = [ get_field(:role, options, nil), 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}/teams/#{team_slug}/members" <> qs ) body = %{} api_call(:get, url, body, Noizu.Github.Collection.SimpleUser, options) end @doc """ List team members (Legacy) @see https://docs.github.com/rest/teams/members#list-team-members-legacy """ def list_members_legacy(team_id, options \\ nil) do url = ( query = [ get_field(:role, options, nil), get_field(:per_page, options, nil), get_field(:page, options, nil) ] |> Enum.filter(& &1) qs = if query == [], do: "", else: "?" <> Enum.join(query, "&") github_base() <> "/teams/#{team_id}/members" <> qs ) body = %{} api_call(:get, url, body, Noizu.Github.Collection.SimpleUser, options) end @doc """ List pending team invitations @see https://docs.github.com/rest/teams/members#list-pending-team-invitations """ def list_pending_invitations_in_org(org, team_slug, 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}/teams/#{team_slug}/invitations" <> qs ) body = %{} api_call(:get, url, body, Noizu.Github.Collection.OrganizationInvitation, options) end @doc """ List pending team invitations (Legacy) @see https://docs.github.com/rest/teams/members#list-pending-team-invitations-legacy """ def list_pending_invitations_legacy(team_id, 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() <> "/teams/#{team_id}/invitations" <> qs ) body = %{} api_call(:get, url, body, Noizu.Github.Collection.OrganizationInvitation, options) end @doc """ List team repositories @see https://docs.github.com/rest/teams/teams#list-team-repositories """ def list_repos_in_org(org, team_slug, 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}/teams/#{team_slug}/repos" <> qs ) body = %{} api_call(:get, url, body, Noizu.Github.Collection.MinimalRepository, options) end @doc """ List team repositories (Legacy) @see https://docs.github.com/rest/teams/teams#list-team-repositories-legacy """ def list_repos_legacy(team_id, 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() <> "/teams/#{team_id}/repos" <> qs ) body = %{} api_call(:get, url, body, Noizu.Github.Collection.MinimalRepository, options) end @doc """ Remove team member (Legacy) @see https://docs.github.com/rest/teams/members#remove-team-member-legacy """ def remove_member_legacy(team_id, username, options \\ nil) do url = github_base() <> "/teams/#{team_id}/members/#{username}" body = %{} api_call(:delete, url, body, Noizu.Github.Raw, options) end @doc """ Remove team membership for a user @see https://docs.github.com/rest/teams/members#remove-team-membership-for-a-user """ def remove_membership_for_user_in_org(org, team_slug, username, options \\ nil) do url = github_base() <> "/orgs/#{org}/teams/#{team_slug}/memberships/#{username}" body = %{} api_call(:delete, url, body, Noizu.Github.Raw, options) end @doc """ Remove team membership for a user (Legacy) @see https://docs.github.com/rest/teams/members#remove-team-membership-for-a-user-legacy """ def remove_membership_for_user_legacy(team_id, username, options \\ nil) do url = github_base() <> "/teams/#{team_id}/memberships/#{username}" body = %{} api_call(:delete, url, body, Noizu.Github.Raw, options) end @doc """ Remove a repository from a team @see https://docs.github.com/rest/teams/teams#remove-a-repository-from-a-team """ def remove_repo_in_org(org, team_slug, options \\ nil) do owner = repo_owner(options) repo = repo_name(options) url = github_base() <> "/orgs/#{org}/teams/#{team_slug}/repos/#{owner}/#{repo}" body = %{} api_call(:delete, url, body, Noizu.Github.Raw, options) end @doc """ Remove a repository from a team (Legacy) @see https://docs.github.com/rest/teams/teams#remove-a-repository-from-a-team-legacy """ def remove_repo_legacy(team_id, options \\ nil) do owner = repo_owner(options) repo = repo_name(options) url = github_base() <> "/teams/#{team_id}/repos/#{owner}/#{repo}" body = %{} api_call(:delete, url, body, Noizu.Github.Raw, options) end @doc """ Update a team @see https://docs.github.com/rest/teams/teams#update-a-team """ def update_in_org(org, team_slug, body, options \\ nil) do url = github_base() <> "/orgs/#{org}/teams/#{team_slug}" body = body api_call(:patch, url, body, Noizu.Github.TeamFull, options) end @doc """ Update a team (Legacy) @see https://docs.github.com/rest/teams/teams#update-a-team-legacy """ def update_legacy(team_id, body, options \\ nil) do url = github_base() <> "/teams/#{team_id}" body = body api_call(:patch, url, body, Noizu.Github.TeamFull, options) end end