Module: GitHub::Client::Orgs

Included in:
GitHub::Client
Defined in:
lib/github_api_v3/client/orgs.rb

Overview

Methods for the Orgs API.

Instance Method Summary collapse

Instance Method Details

#add_team_member(id, username) ⇒ Boolean Also known as: add_organization_member

Add a member to a team.

Requires authentication. The authenticated user must have ‘admin’ permissions to the team or be an owner of the org that the team is associated with.

Parameters:

  • id (Integer)

    The ID of the team.

  • username (String)

    The username of the user to add.

Returns:

  • (Boolean)

    True if successful, false if not.

See Also:



215
216
217
# File 'lib/github_api_v3/client/orgs.rb', line 215

def add_team_member(id, username)
  boolean_request :put, "/teams/#{id}/members/#{username}"
end

#add_team_repo(id, org, repo) ⇒ Boolean

Add a team repository.

Requires authentication. The authenticated user must be an owner of the org that the team is associated with. Also, the repo must be owned by the organization, or a direct fork of a repo owned by the organization.

Parameters:

  • id (Integer)

    The ID of the team.

  • org (String)

    The organization to add the team for.

  • repo (String)

    The repository name.

Returns:

  • (Boolean)

    True if successful, false if not.

See Also:



269
270
271
# File 'lib/github_api_v3/client/orgs.rb', line 269

def add_team_repo(id, org, repo)
  boolean_request :put, "/teams/#{id}/repos/#{org}/#{repo}"
end

#create_team(org, team_name, options = {}) ⇒ Hash

Create a team for an organization.

Requires authentication. The authenticated user must also be an owner of the specified organization.

Parameters:

  • org (String)

    Organization name.

  • team_name (String)

    The name of the new team.

  • options (Hash) (defaults to: {})

    Optional parameters.

Options Hash (options):

  • :name (String) — default: required
  • :repo_names (Array)

    Array of repo names as strings.

  • :permission (String)

    pull (default), push, or admin.

Returns:

  • (Hash)

    Team information.

See Also:



147
148
149
150
# File 'lib/github_api_v3/client/orgs.rb', line 147

def create_team(org, team_name, options={})
  options.merge!(name: team_name)
  post "/orgs/#{org}/teams", body: options
end

#delete_team(id) ⇒ Boolean

Delete a team.

Requires authentication. In order to delete a team, the authenticated user must be an owner of the org that the team is associated with.

Parameters:

  • id (Integer)

    The ID of the team.

Returns:

  • (Boolean)

    True if successful, false if not.

See Also:



176
177
178
# File 'lib/github_api_v3/client/orgs.rb', line 176

def delete_team(id)
  boolean_request :delete, "/teams/#{id}"
end

#edit_organization(org, options = {}) ⇒ Hash

Edit an organization.

Requires authentication.

Examples:

client.edit_organization('facebook',name:'faceeebooook',location:'California')

Parameters:

  • org (String)

    Organization name.

  • options (Hash) (defaults to: {})

    Optional parameters.

Options Hash (options):

  • :billing_email (String)

    Billing email address, is not publicized.

  • :company (String)
  • :email (String)

    Publicly visible email address

  • :location (String)
  • :name (String)

Returns:

  • (Hash)

    Repository information.

See Also:



35
36
37
# File 'lib/github_api_v3/client/orgs.rb', line 35

def edit_organization(org, options={})
  patch "/orgs/#{org}", body: options
end

#edit_team(id, team_name, options = {}) ⇒ Hash

Edit a team.

Requires authentication. In order to edit a team, the authenticated user must be an owner of the specified organization.

Parameters:

  • id (Integer)

    The ID of the team.

  • team_name (String)

    The (new) name of the team.

  • options (Hash) (defaults to: {})

    Optional parameters.

Options Hash (options):

  • :permission (String) — default: see create_team

Returns:

  • (Hash)

    Team information.

See Also:



163
164
165
166
# File 'lib/github_api_v3/client/orgs.rb', line 163

def edit_team(id, team_name, options={})
  options.merge!(name: team_name)
  patch "/teams/#{id}", body: options
end

#organization(org) ⇒ Hash

Get an organization.

Examples:

GitHub.organization('github')

Parameters:

  • org (String)

    Organization name.

Returns:

  • (Hash)

    Organization information.

See Also:



16
17
18
# File 'lib/github_api_v3/client/orgs.rb', line 16

def organization(org)
  get "/orgs/#{org}"
end

#organization_member?(org, username) ⇒ Boolean

Check if a user is, publicly or privately, a member of the organization.

Parameters:

  • org (String)

    Organization name.

  • username (String)

    User to check for.

Returns:

  • (Boolean)

    True if user is a member, false if not.

See Also:



54
55
56
# File 'lib/github_api_v3/client/orgs.rb', line 54

def organization_member?(org, username)
  boolean_request :get, "/orgs/#{org}/members/#{username}"
end

#organization_members(org) ⇒ Array

List all users who are members of an organization.

Parameters:

  • org (String)

    Organization name.

Returns:

  • (Array)

    Array of members.

See Also:



44
45
46
# File 'lib/github_api_v3/client/orgs.rb', line 44

def organization_members(org)
  get "/orgs/#{org}/members"
end

#organization_public_member?(org, username) ⇒ Array

Check if a user is publicly a member of the organization.

Parameters:

  • org (String)

    Organization name.

Returns:

  • (Array)

    Array of members.

See Also:



84
85
86
# File 'lib/github_api_v3/client/orgs.rb', line 84

def organization_public_member?(org, username)
  boolean_request :get, "/orgs/#{org}/public_members/#{username}"
end

#organization_public_members(org) ⇒ Array

Retrieve public members of an organization.

Parameters:

  • org (String)

    Organization name.

Returns:

  • (Array)

    Array of members.

See Also:



63
64
65
# File 'lib/github_api_v3/client/orgs.rb', line 63

def organization_public_members(org)
  get "/orgs/#{org}/public_members"
end

#publicize_membership(org, username) ⇒ Boolean

Make a user’s organization membership public.

Requires authentication.

Parameters:

  • org (String)

    Organization name.

  • username (String)

    Username of user to publicize.

Returns:

  • (Boolean)

    True if successful, false if not.

See Also:



96
97
98
# File 'lib/github_api_v3/client/orgs.rb', line 96

def publicize_membership(org, username)
  boolean_request :put, "/orgs/#{org}/public_members/#{username}"
end

#remove_organization_member(org, username) ⇒ Boolean

Remove member from an organization.

Requires authentication.

Parameters:

  • org (String)

    Organization name.

  • username (String)

    User to check for.

Returns:

  • (Boolean)

    True if user is a member, false if not.

See Also:



75
76
77
# File 'lib/github_api_v3/client/orgs.rb', line 75

def remove_organization_member(org, username)
  boolean_request :delete, "/orgs/#{org}/members/#{username}"
end

#remove_team_member(id, username) ⇒ Boolean

Remove a team member.

Requires authentication. The authenticated user must have ‘admin’ permissions to the team or be an owner of the org that the team is associated with.

Parameters:

  • id (Integer)

    The ID of the team.

  • username (String)

    The username of the user to remove.

Returns:

  • (Boolean)

    True if successful, false if not.

See Also:



229
230
231
# File 'lib/github_api_v3/client/orgs.rb', line 229

def remove_team_member(id, username)
  boolean_request :delete, "/teams/#{id}/members/#{username}"
end

#remove_team_repo(id, owner, repo) ⇒ Boolean

Remove a team repository.

Requires authentication. The authenticated user must be an owner of the org that the team is associated with. NOTE: This does not delete the repo, it just removes it from the team.

Parameters:

  • id (Integer)

    The ID of the team.

  • owner (String)

    The repository owner’s username.

  • repo (String)

    The repository name.

Returns:

  • (Boolean)

    True if successful, false if not.

See Also:



283
284
285
# File 'lib/github_api_v3/client/orgs.rb', line 283

def remove_team_repo(id, owner, repo)
  boolean_request :delete, "/teams/#{id}/repos/#{owner}/#{repo}"
end

#team(id) ⇒ Hash

Get a team by its ID.

Requires authentication.

Parameters:

  • id (Integer)

    The ID of the team to get.

Returns:

  • (Hash)

    Team information.

See Also:



130
131
132
# File 'lib/github_api_v3/client/orgs.rb', line 130

def team(id)
  get "/teams/#{id}"
end

#team_member?(id, username) ⇒ Boolean

Determine if a user is a team member.

Requires authentication. The authenticated user must be a member of the team.

Parameters:

  • id (Integer)

    The ID of the team.

  • username (String)

    The username of the user to check for.

Returns:

  • (Boolean)

    True if member, false if not.

See Also:



201
202
203
# File 'lib/github_api_v3/client/orgs.rb', line 201

def team_member?(id, username)
  boolean_request :get, "/teams/#{id}/members/#{username}"
end

#team_members(id) ⇒ Array

List team members

Requires authentication. In order to list members in a team, the authenticated user must be a member of the team.

Parameters:

  • id (Integer)

    The ID of the team.

Returns:

  • (Array)

    Array of members.

See Also:



188
189
190
# File 'lib/github_api_v3/client/orgs.rb', line 188

def team_members(id)
  get "/teams/#{id}/members"
end

#team_repo?(id, owner, repo) ⇒ Boolean

Determine if a repo is managed by a team.

Requires authentication.

Parameters:

  • id (Integer)

    The ID of the team.

  • owner (String)

    The repository owner’s username.

  • repo (String)

    The repository name.

Returns:

  • (Boolean)

    True if it is managed by the team, false if not.

See Also:



253
254
255
# File 'lib/github_api_v3/client/orgs.rb', line 253

def team_repo?(id, owner, repo)
  boolean_request :get, "/teams/#{id}/repos/#{owner}/#{repo}"
end

#team_repos(id) ⇒ Boolean

List all repositories for a team.

Requires authentication.

Parameters:

  • id (Integer)

    The ID of the team.

Returns:

  • (Boolean)

    True if successful, false if not.

See Also:



240
241
242
# File 'lib/github_api_v3/client/orgs.rb', line 240

def team_repos(id)
  get "/teams/#{id}/repos"
end

#teams(org) ⇒ Array

List an organizations teams.

Requires authentication.

Parameters:

  • org (String)

    Organization name.

Returns:

  • (Array)

    Array of teams.

See Also:



119
120
121
# File 'lib/github_api_v3/client/orgs.rb', line 119

def teams(org)
  get "/orgs/#{org}/teams"
end

#unpublicize_membership(org, username) ⇒ Boolean

Conceal a user’s organization membership.

Requires authentication.

Parameters:

  • org (String)

    Organization name.

  • username (String)

    Username of user to publicize.

Returns:

  • (Boolean)

    True if successful, false if not.

See Also:



108
109
110
# File 'lib/github_api_v3/client/orgs.rb', line 108

def unpublicize_membership(org, username)
  boolean_request :delete, "/orgs/#{org}/public_members/#{username}"
end