Module: Octokit::Client::Organizations
- Included in:
- Octokit::Client
- Defined in:
- lib/octokit/client/organizations.rb
Instance Method Summary collapse
-
#add_team_member(team_id, user, options = {}) ⇒ Boolean
Add team member.
-
#add_team_repository(team_id, repo, options = {}) ⇒ Boolean
(also: #add_team_repo)
Add team repository.
-
#create_team(org, options = {}) ⇒ Hashie::Mash
Create team.
-
#delete_team(team_id, options = {}) ⇒ Boolean
Delete team.
-
#organization(org, options = {}) ⇒ Hashie::Mash
(also: #org)
Get an organization.
-
#organization_members(org, options = {}) ⇒ Array<Hashie::Mash>
(also: #org_members)
Get organization members.
-
#organization_repositories(org, options = {}) ⇒ Array<Hashie::Mash>
(also: #org_repositories, #org_repos)
List organization repositories.
-
#organization_teams(org, options = {}) ⇒ Array<Hashie::Mash>
(also: #org_teams)
List teams.
-
#organizations(user = nil, options = {}) ⇒ Array<Hashie::Mash>
(also: #list_organizations, #list_orgs, #orgs)
Get organizations for a user.
-
#publicize_membership(org, user, options = {}) ⇒ Boolean
Publicize a user’s membership of an organization.
-
#remove_organization_member(org, user, options = {}) ⇒ Boolean
(also: #remove_org_member)
Remove organization member.
-
#remove_team_member(team_id, user, options = {}) ⇒ Boolean
Remove team member.
-
#remove_team_repository(team_id, repo, options = {}) ⇒ Boolean
(also: #remove_team_repo)
Remove team repository.
-
#team(team_id, options = {}) ⇒ Hashie::Mash
Get team.
-
#team_members(team_id, options = {}) ⇒ Array<Hashie::Mash>
List team members.
-
#team_repositories(team_id, options = {}) ⇒ Array<Hashie::Mash>
(also: #team_repos)
List team repositories.
-
#unpublicize_membership(org, user, options = {}) ⇒ Boolean
(also: #conceal_membership)
Conceal a user’s membership of an organization.
-
#update_organization(org, values, options = {}) ⇒ Hashie::Mash
(also: #update_org)
Update an organization.
-
#update_team(team_id, options = {}) ⇒ Hashie::Mash
Update team.
Instance Method Details
#add_team_member(team_id, user, options = {}) ⇒ Boolean
Add team member
Requires authenticated organization owner or member with team ‘admin` permission.
252 253 254 255 256 257 |
# File 'lib/octokit/client/organizations.rb', line 252 def add_team_member(team_id, user, ={}) # There's a bug in this API call. The docs say to leave the body blank, # but it fails if the body is both blank and the content-length header # is not 0. put("teams/#{team_id}/members/#{user}", .merge({:name => user}), 3, true, raw=true).status == 204 end |
#add_team_repository(team_id, repo, options = {}) ⇒ Boolean Also known as: add_team_repo
Add team repository
Requires authenticated user to be an owner of the organization that the team is associated with. Also, the repo must be owned by the organization, or a direct form of a repo owned by the organization.
308 309 310 |
# File 'lib/octokit/client/organizations.rb', line 308 def add_team_repository(team_id, repo, ={}) put("teams/#{team_id}/repos/#{Repository.new(repo)}", .merge(:name => Repository.new(repo)), 3, true, raw=true).status == 204 end |
#create_team(org, options = {}) ⇒ Hashie::Mash
Create team
Requires authenticated organization owner.
171 172 173 |
# File 'lib/octokit/client/organizations.rb', line 171 def create_team(org, ={}) post("orgs/#{org}/teams", , 3) end |
#delete_team(team_id, options = {}) ⇒ Boolean
Delete team
Requires authenticated organization owner.
222 223 224 |
# File 'lib/octokit/client/organizations.rb', line 222 def delete_team(team_id, ={}) delete("teams/#{team_id}", , 3, true, true) end |
#organization(org, options = {}) ⇒ Hashie::Mash Also known as: org
Get an organization
13 14 15 |
# File 'lib/octokit/client/organizations.rb', line 13 def organization(org, ={}) get("orgs/#{org}", , 3) end |
#organization_members(org, options = {}) ⇒ Array<Hashie::Mash> Also known as: org_members
Get organization members
Public members of the organization are returned by default. An authenticated client that is a member of the GitHub organization is required to get private members.
127 128 129 |
# File 'lib/octokit/client/organizations.rb', line 127 def organization_members(org, ={}) get("orgs/#{org}/members", , 3) end |
#organization_repositories(org, options = {}) ⇒ Array<Hashie::Mash> Also known as: org_repositories, org_repos
List organization repositories
Public repositories are available without authentication. Private repos require authenticated organization member.
105 106 107 |
# File 'lib/octokit/client/organizations.rb', line 105 def organization_repositories(org, ={}) get("orgs/#{org}/repos", , 3) end |
#organization_teams(org, options = {}) ⇒ Array<Hashie::Mash> Also known as: org_teams
List teams
Requires authenticated organization member.
144 145 146 |
# File 'lib/octokit/client/organizations.rb', line 144 def organization_teams(org, ={}) get("orgs/#{org}/teams", , 3) end |
#organizations(user = nil, options = {}) ⇒ Array<Hashie::Mash> Also known as: list_organizations, list_orgs, orgs
Get organizations for a user.
Nonauthenticated calls to this method will return organizations that the user is a public member.
Use an authenicated client to get both public and private organizations for a user.
Calling this method on a ‘@client` will return that users organizations. Private organizations are included only if the `@client` is authenticated.
74 75 76 77 78 79 80 |
# File 'lib/octokit/client/organizations.rb', line 74 def organizations(user=nil, ={}) if user get("users/#{user}/orgs", , 3) else get("user/orgs", , 3) end end |
#publicize_membership(org, user, options = {}) ⇒ Boolean
Publicize a user’s membership of an organization
Requires authenticated organization owner.
365 366 367 |
# File 'lib/octokit/client/organizations.rb', line 365 def publicize_membership(org, user, ={}) put("orgs/#{org}/public_members/#{user}", , 3, true, raw=true).status == 204 end |
#remove_organization_member(org, user, options = {}) ⇒ Boolean Also known as: remove_org_member
Remove organization member
Requires authenticated organization owner or member with team ‘admin` access.
347 348 349 350 351 |
# File 'lib/octokit/client/organizations.rb', line 347 def remove_organization_member(org, user, ={}) # this is a synonym for: for team in org.teams: remove_team_member(team.id, user) # provided in the GH API v3 delete("orgs/#{org}/members/#{user}", , 3, true, raw=true).status == 204 end |
#remove_team_member(team_id, user, options = {}) ⇒ Boolean
Remove team member
Requires authenticated organization owner or member with team ‘admin` permission.
271 272 273 |
# File 'lib/octokit/client/organizations.rb', line 271 def remove_team_member(team_id, user, ={}) delete("teams/#{team_id}/members/#{user}", , 3, true, raw=true).status == 204 end |
#remove_team_repository(team_id, repo, options = {}) ⇒ Boolean Also known as: remove_team_repo
Remove team repository
Removes repository from team. Does not delete the repository.
Requires authenticated organization owner.
329 330 331 |
# File 'lib/octokit/client/organizations.rb', line 329 def remove_team_repository(team_id, repo, ={}) delete("teams/#{team_id}/repos/#{Repository.new(repo)}", , 3, true, raw=true).status == 204 end |
#team(team_id, options = {}) ⇒ Hashie::Mash
Get team
Requires authenticated organization member.
185 186 187 |
# File 'lib/octokit/client/organizations.rb', line 185 def team(team_id, ={}) get("teams/#{team_id}", , 3) end |
#team_members(team_id, options = {}) ⇒ Array<Hashie::Mash>
List team members
Requires authenticated organization member.
236 237 238 |
# File 'lib/octokit/client/organizations.rb', line 236 def team_members(team_id, ={}) get("teams/#{team_id}/members", , 3) end |
#team_repositories(team_id, options = {}) ⇒ Array<Hashie::Mash> Also known as: team_repos
List team repositories
Requires authenticated organization member.
287 288 289 |
# File 'lib/octokit/client/organizations.rb', line 287 def team_repositories(team_id, ={}) get("teams/#{team_id}/repos", , 3) end |
#unpublicize_membership(org, user, options = {}) ⇒ Boolean Also known as: conceal_membership
Conceal a user’s membership of an organization.
Requires authenticated organization owner.
382 383 384 |
# File 'lib/octokit/client/organizations.rb', line 382 def unpublicize_membership(org, user, ={}) delete("orgs/#{org}/public_members/#{user}", , 3, true, raw=true).status == 204 end |
#update_organization(org, values, options = {}) ⇒ Hashie::Mash Also known as: update_org
Update an organization.
Requires authenticated client with proper organization permissions.
42 43 44 |
# File 'lib/octokit/client/organizations.rb', line 42 def update_organization(org, values, ={}) patch("orgs/#{org}", .merge({:organization => values}), 3) end |
#update_team(team_id, options = {}) ⇒ Hashie::Mash
Update team
Requires authenticated organization owner.
208 209 210 |
# File 'lib/octokit/client/organizations.rb', line 208 def update_team(team_id, ={}) patch("teams/#{team_id}", , 3) end |