Class: Github::Orgs::Teams
Constant Summary collapse
- VALID_TEAM_PARAM_NAMES =
All actions against teams require at a minimum an authenticated user who is a member of the owner’s team in the :org being managed. Api calls that require explicit permissions are noted.
%w[ name repo_names permission ].freeze
- VALID_TEAM_PARAM_VALUES =
{ 'permission' => %w[ pull push admin ].freeze }
Constants included from Request
Request::METHODS, Request::METHODS_WITH_BODIES
Constants included from Connection
Constants included from Constants
Constants::ACCEPT, Constants::ACCEPTED_OAUTH_SCOPES, Constants::ACCEPT_CHARSET, Constants::CACHE_CONTROL, Constants::CONTENT_LENGTH, Constants::CONTENT_TYPE, Constants::DATE, Constants::ETAG, Constants::HEADER_LAST, Constants::HEADER_LINK, Constants::HEADER_NEXT, Constants::LOCATION, Constants::META_FIRST, Constants::META_LAST, Constants::META_NEXT, Constants::META_PREV, Constants::META_REL, Constants::OAUTH_SCOPES, Constants::PARAM_PAGE, Constants::PARAM_PER_PAGE, Constants::PARAM_START_PAGE, Constants::RATELIMIT_LIMIT, Constants::RATELIMIT_REMAINING, Constants::SERVER, Constants::USER_AGENT
Constants included from MimeType
Instance Attribute Summary
Attributes inherited from API
Attributes included from Authorization
Instance Method Summary collapse
-
#add_member(*args) ⇒ Object
(also: #add_team_member)
Add a team member In order to add a user to a team, the authenticated user must have ‘admin’ permissions to the team or be an owner of the org that the team is associated with.
-
#add_repo(*args) ⇒ Object
(also: #add_repository)
Add a team repository.
-
#create(*args) ⇒ Object
Create a team.
-
#delete(*args) ⇒ Object
(also: #remove)
Delete a team In order to delete a team, the authenticated user must be an owner of the org that the team is associated with.
-
#edit(*args) ⇒ Object
Edit a team In order to edit a team, the authenticated user must be an owner of the org that the team is associated with.
-
#get(*args) ⇒ Object
(also: #find)
Get a team.
-
#list(*args) ⇒ Object
(also: #all)
List teams.
-
#list_members(*args) ⇒ Object
(also: #all_members)
List team members In order to list members in a team, the authenticated user must be a member of the team.
-
#list_repos(*args) ⇒ Object
(also: #repos)
List team repositories.
-
#remove_member(*args) ⇒ Object
(also: #remove_team_member)
Remove a team member.
-
#remove_repo(*args) ⇒ Object
(also: #remove_repository)
Remove a team repository.
-
#team_member?(*args) ⇒ Boolean
Check if a user is a member of a team.
-
#team_repo?(*args) ⇒ Boolean
(also: #team_repository?)
Check if a repository belongs to a team.
Methods inherited from API
#api_methods_in, #append_arguments, #arguments, inherited, #initialize, #method_missing, #process_basic_auth, #set, #setup, #with, #yield_or_eval
Methods included from RateLimit
#ratelimit, #ratelimit_remaining
Methods included from Request
#delete_request, #get_request, #patch_request, #post_request, #put_request, #request
Methods included from Connection
#caching?, #clear_cache, #connection, #default_middleware, #default_options, #stack
Methods included from MimeType
Methods included from Authorization
#auth_code, #authenticated?, #authentication, #authorize_url, #basic_authed?, #client, #get_token
Constructor Details
This class inherits a constructor from Github::API
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class Github::API
Instance Method Details
#add_member(*args) ⇒ Object Also known as: add_team_member
151 152 153 154 155 |
# File 'lib/github_api/orgs/teams.rb', line 151 def add_member(*args) arguments(args, :required => [:team_id, :user]) put_request("/teams/#{team_id}/members/#{user}", arguments.params) end |
#add_repo(*args) ⇒ Object Also known as: add_repository
Add a team repository
In order to add a repo to a team, 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 for of a repo owned by the organization.
Examples
github = Github.new :oauth_token => '...'
github.orgs.teams.add_repo 'team-id', 'user-name', 'repo-name'
218 219 220 221 222 |
# File 'lib/github_api/orgs/teams.rb', line 218 def add_repo(*args) arguments(args, :required => [:team_id, :user, :repo]) put_request("/teams/#{team_id}/repos/#{user}/#{repo}", arguments.params) end |
#create(*args) ⇒ Object
Create a team
In order to create a team, the authenticated user must be an owner of:org
.
Inputs
<tt>:name</tt> - Required string
<tt>:repo_names</tt> - Optional array of strings
<tt>:permission</tt> - Optional string
* <tt>pull</tt> - team members can pull, but not push or administor this repositories. Default
* <tt>push</tt> - team members can pull and push, but not administor this repositores.
* <tt>admin</tt> - team members can pull, push and administor these repositories.
Examples
github = Github.new :oauth_token => '...'
github.orgs.teams.create 'org-name',
"name" => "new team",
"permission" => "push",
"repo_names" => [
"github/dotfiles"
]
62 63 64 65 66 67 68 69 70 |
# File 'lib/github_api/orgs/teams.rb', line 62 def create(*args) arguments(args, :required => [:org_name]) do sift VALID_TEAM_PARAM_NAMES assert_values VALID_TEAM_PARAM_VALUES assert_required %w[name] end post_request("/orgs/#{org_name}/teams", arguments.params) end |
#delete(*args) ⇒ Object Also known as: remove
105 106 107 108 109 |
# File 'lib/github_api/orgs/teams.rb', line 105 def delete(*args) arguments(args, :required => [:team_id]) delete_request("/teams/#{team_id}", arguments.params) end |
#edit(*args) ⇒ Object
Edit a team In order to edit a team, the authenticated user must be an owner of the org that the team is associated with.
Inputs
<tt>:name</tt> - Required string
<tt>:permission</tt> - Optional string
* <tt>pull</tt> - team members can pull, but not push or administor this repositories. Default
* <tt>push</tt> - team members can pull and push, but not administor this repositores.
* <tt>admin</tt> - team members can pull, push and administor these repositories.
Examples
github = Github.new :oauth_token => '...'
github.orgs.teams.edit 'team-id',
"name" => "new team name",
"permission" => "push"
88 89 90 91 92 93 94 95 96 |
# File 'lib/github_api/orgs/teams.rb', line 88 def edit(*args) arguments(args, :required => [:team_id]) do sift VALID_TEAM_PARAM_NAMES assert_values VALID_TEAM_PARAM_VALUES assert_required %w[name] end patch_request("/teams/#{team_id}", arguments.params) end |
#get(*args) ⇒ Object Also known as: find
35 36 37 38 39 |
# File 'lib/github_api/orgs/teams.rb', line 35 def get(*args) arguments(args, :required => [:team_id]) get_request("/teams/#{team_id}", arguments.params) end |
#list(*args) ⇒ Object Also known as: all
20 21 22 23 24 25 26 |
# File 'lib/github_api/orgs/teams.rb', line 20 def list(*args) arguments(args, :required => [:org_name]) response = get_request("/orgs/#{org_name}/teams", arguments.params) return response unless block_given? response.each { |el| yield el } end |
#list_members(*args) ⇒ Object Also known as: all_members
List team members In order to list members in a team, the authenticated user must be a member of the team.
Examples
github = Github.new :oauth_token => '...'
github.orgs.teams.list_members 'team-id'
github.orgs.teams.list_members 'team-id' { |member| ... }
120 121 122 123 124 125 126 |
# File 'lib/github_api/orgs/teams.rb', line 120 def list_members(*args) arguments(args, :required => [:team_id]) response = get_request("/teams/#{team_id}/members", arguments.params) return response unless block_given? response.each { |el| yield el } end |
#list_repos(*args) ⇒ Object Also known as: repos
182 183 184 185 186 187 188 |
# File 'lib/github_api/orgs/teams.rb', line 182 def list_repos(*args) arguments(args, :required => [:team_id]) response = get_request("/teams/#{team_id}/repos", arguments.params) return response unless block_given? response.each { |el| yield el } end |
#remove_member(*args) ⇒ Object Also known as: remove_team_member
Remove a team member
In order to remove a user from a team, the authenticated user must have ‘admin’ permissions to the team or be an owner of the org that the team is associated with. note: This does not delete the user, it just remove them from the team.
Examples
github = Github.new :oauth_token => '...'
github.orgs.teams.remove_member 'team-id', 'user-name'
169 170 171 172 173 |
# File 'lib/github_api/orgs/teams.rb', line 169 def remove_member(*args) arguments(args, :required => [:team_id, :user]) delete_request("/teams/#{team_id}/members/#{user}", arguments.params) end |
#remove_repo(*args) ⇒ Object Also known as: remove_repository
Remove a team repository
In order to add a repo to a team, 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.
Examples
github = Github.new :oauth_token => '...'
github.orgs.teams.remove_repo 'team-id', 'user-name', 'repo-name'
235 236 237 238 239 |
# File 'lib/github_api/orgs/teams.rb', line 235 def remove_repo(*args) arguments(args, :required => [:team_id, :user, :repo]) delete_request("/teams/#{team_id}/repos/#{user}/#{repo}", arguments.params) end |
#team_member?(*args) ⇒ Boolean
135 136 137 138 139 140 141 142 |
# File 'lib/github_api/orgs/teams.rb', line 135 def team_member?(*args) arguments(args, :required => [:team_id, :user]) response = get_request("/teams/#{team_id}/members/#{user}", arguments.params) response.status == 204 rescue Github::Error::NotFound false end |
#team_repo?(*args) ⇒ Boolean Also known as: team_repository?
197 198 199 200 201 202 203 204 |
# File 'lib/github_api/orgs/teams.rb', line 197 def team_repo?(*args) arguments(args, :required => [:team_id, :user, :repo]) response = get_request("/teams/#{team_id}/repos/#{user}/#{repo}", arguments.params) response.status == 204 rescue Github::Error::NotFound false end |