-
-
Notifications
You must be signed in to change notification settings - Fork 600
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Update list repositories methods in Teams and Apps API. #1067
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -137,16 +137,16 @@ public function removeInstallation($installationId) | |
* | ||
* @link https://developer.github.com/v3/apps/installations/#list-repositories | ||
* | ||
* @param int $userId | ||
* @param array $params list of extra parameters. | ||
* | ||
* @return array | ||
*/ | ||
public function listRepositories($userId = null) | ||
public function listRepositories(array $params = []) | ||
{ | ||
$parameters = []; | ||
if ($userId) { | ||
$parameters['user_id'] = $userId; | ||
} | ||
$parameters = array_merge([ | ||
'page' => 1, | ||
'per_page' => 30, | ||
], $params); | ||
Comment on lines
+146
to
+149
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This should not be needed as the |
||
|
||
$this->configurePreviewHeader(); | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -95,16 +95,49 @@ public function removeMember($team, $username, $organization) | |
return $this->delete('/orgs/'.rawurlencode($organization).'/teams/'.rawurlencode($team).'/memberships/'.rawurlencode($username)); | ||
} | ||
|
||
public function repositories($team) | ||
/** | ||
* List a team's repositories. | ||
* | ||
* @link https://docs.github.com/en/rest/teams/teams#list-team-repositories | ||
* | ||
* @param string $team team ID or slug of the team name | ||
* @param string $organization organization name | ||
* @param array $params list of extra parameters. | ||
* | ||
* @return array | ||
*/ | ||
public function repositories($team, $organization = '', $params = []) | ||
{ | ||
return $this->get('/teams/'.rawurlencode($team).'/repos'); | ||
$parameters = array_merge([ | ||
'page' => 1, | ||
'per_page' => 30, | ||
], $params); | ||
Comment on lines
+111
to
+114
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This should not be needed as the |
||
|
||
if (empty($organization)) { | ||
// Legacy endpoint support | ||
return $this->get('/teams/'.rawurlencode($team).'/repos', $parameters); | ||
} | ||
|
||
return $this->get('/orgs/'.rawurlencode($organization).'/teams/'.rawurlencode($team).'/repos', $parameters); | ||
} | ||
|
||
public function repository($team, $organization, $repository) | ||
{ | ||
return $this->get('/teams/'.rawurlencode($team).'/repos/'.rawurlencode($organization).'/'.rawurlencode($repository)); | ||
} | ||
|
||
/** | ||
* Add a repository to team or update team's permission on a repository. | ||
* | ||
* @link https://docs.github.com/en/rest/teams/teams#add-or-update-team-repository-permissions | ||
* | ||
* @param string $team the slug of the team name | ||
* @param string $organization organization name | ||
* @param string $repository repository name | ||
* @param string $params list of extra parameters. | ||
* | ||
* @return array|string | ||
*/ | ||
public function addRepository($team, $organization, $repository, $params = []) | ||
{ | ||
if (isset($params['permission']) && !in_array($params['permission'], ['pull', 'push', 'admin', 'maintain', 'triage'])) { | ||
|
@@ -114,6 +147,17 @@ public function addRepository($team, $organization, $repository, $params = []) | |
return $this->put('/orgs/'.rawurlencode($organization).'/teams/'.rawurlencode($team).'/repos/'.rawurlencode($organization).'/'.rawurlencode($repository), $params); | ||
} | ||
|
||
/** | ||
* Remove a repository from a team. | ||
* | ||
* @link https://docs.github.com/en/rest/teams/teams#remove-a-repository-from-a-team | ||
* | ||
* @param string $team the slug of the team name | ||
* @param string $organization organization name | ||
* @param string $repository repository name. | ||
* | ||
* @return array|string | ||
*/ | ||
public function removeRepository($team, $organization, $repository) | ||
{ | ||
return $this->delete('/orgs/'.rawurlencode($organization).'/teams/'.rawurlencode($team).'/repos/'.rawurlencode($organization).'/'.rawurlencode($repository)); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can't remove/replace parameters as this would be a BC break. If the user parameter is not required anymore this should be deprecated so that we can remove it in the next major version