-
-
Notifications
You must be signed in to change notification settings - Fork 598
/
Copy pathTeams.php
128 lines (109 loc) · 4.39 KB
/
Teams.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
<?php
namespace Github\Api\Organization;
use Github\Api\AbstractApi;
use Github\Exception\MissingArgumentException;
/**
* @link http://developer.github.com/v3/orgs/teams/
*
* @author Joseph Bielawski <[email protected]>
*/
class Teams extends AbstractApi
{
public function all($organization, array $params = [])
{
return $this->get('/orgs/'.rawurlencode($organization).'/teams', $params);
}
public function create($organization, array $params)
{
if (!isset($params['name'])) {
throw new MissingArgumentException('name');
}
if (isset($params['repo_names']) && !is_array($params['repo_names'])) {
$params['repo_names'] = [$params['repo_names']];
}
if (isset($params['permission']) && !in_array($params['permission'], ['pull', 'push', 'admin'])) {
$params['permission'] = 'pull';
}
return $this->post('/orgs/'.rawurlencode($organization).'/teams', $params);
}
/**
* @link https://developer.github.com/v3/teams/#list-teams
*/
public function show($team, $organization)
{
return $this->get('/orgs/'.rawurlencode($organization).'/teams/'.rawurlencode($team));
}
/**
* @link https://developer.github.com/v3/teams/#edit-team
*/
public function update($team, array $params, $organization)
{
if (!isset($params['name'])) {
throw new MissingArgumentException('name');
}
if (isset($params['permission']) && !in_array($params['permission'], ['pull', 'push', 'admin'])) {
$params['permission'] = 'pull';
}
return $this->patch('/orgs/'.rawurlencode($organization).'/teams/'.rawurlencode($team), $params);
}
/**
* @link https://developer.github.com/v3/teams/#delete-team
*/
public function remove($team, $organization)
{
return $this->delete('/orgs/'.rawurlencode($organization).'/teams/'.rawurlencode($team));
}
/**
* @link https://developer.github.com/v3/teams/members/#list-team-members
*/
public function members($team, $organization)
{
return $this->get('/orgs/'.rawurlencode($organization).'/teams/'.rawurlencode($team).'/members');
}
/**
* @link https://developer.github.com/v3/teams/members/#get-team-membership
*/
public function check($team, $username, $organization)
{
return $this->get('/orgs/'.rawurlencode($organization).'/teams/'.rawurlencode($team).'/memberships/'.rawurlencode($username));
}
/**
* @link https://developer.github.com/v3/teams/members/#add-or-update-team-membership
*/
public function addMember($team, $username, $organization)
{
return $this->put('/orgs/'.rawurlencode($organization).'/teams/'.rawurlencode($team).'/memberships/'.rawurlencode($username));
}
/**
* @link https://developer.github.com/v3/teams/members/#remove-team-membership
*/
public function removeMember($team, $username, $organization)
{
return $this->delete('/orgs/'.rawurlencode($organization).'/teams/'.rawurlencode($team).'/memberships/'.rawurlencode($username));
}
/**
* @link https://docs.github.com/en/rest/teams/teams#list-team-repositories
*/
public function repositories($team, $organization = '')
{
if (empty($organization)) {
return $this->get('/teams/'.rawurlencode($team).'/repos');
}
return $this->get('/orgs/'.rawurlencode($organization).'/teams/'.rawurlencode($team).'/repos');
}
public function repository($team, $organization, $repository)
{
return $this->get('/teams/'.rawurlencode($team).'/repos/'.rawurlencode($organization).'/'.rawurlencode($repository));
}
public function addRepository($team, $organization, $repository, $params = [])
{
if (isset($params['permission']) && !in_array($params['permission'], ['pull', 'push', 'admin', 'maintain', 'triage'])) {
$params['permission'] = 'pull';
}
return $this->put('/orgs/'.rawurlencode($organization).'/teams/'.rawurlencode($team).'/repos/'.rawurlencode($organization).'/'.rawurlencode($repository), $params);
}
public function removeRepository($team, $organization, $repository)
{
return $this->delete('/orgs/'.rawurlencode($organization).'/teams/'.rawurlencode($team).'/repos/'.rawurlencode($organization).'/'.rawurlencode($repository));
}
}