-
-
Notifications
You must be signed in to change notification settings - Fork 598
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feature #1106 Added Org & Repository variables (Froxz)
This PR was squashed before being merged into the 3.10.x-dev branch. Discussion ---------- Commits ------- ff0fb37 Added Org & Repository varaibles 4a50d98 fixed type hint 7569055 Fixes 37e12a6 added repo variables test 1da518f StyleCI fixes 9f90a4a Removed params validation
- Loading branch information
Showing
11 changed files
with
705 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
## Organization / Variables API | ||
[Back to the "Organization API"](../organization.md) | [Back to the navigation](../README.md) | ||
|
||
### List organization variables | ||
|
||
https://docs.github.com/en/rest/actions/variables?apiVersion=2022-11-28#list-organization-variables | ||
|
||
```php | ||
$variables = $client->organization()->variables()->all('KnpLabs'); | ||
``` | ||
|
||
### Get an organization variable | ||
|
||
https://docs.github.com/en/rest/reference/actions#get-an-organization-secret | ||
|
||
```php | ||
$variable = $client->organization()->variables()->show('KnpLabs', $variableName); | ||
``` | ||
|
||
### Create an organization variable | ||
|
||
https://docs.github.com/en/rest/actions/variables?apiVersion=2022-11-28#create-an-organization-variable | ||
|
||
```php | ||
$client->organization()->variables()->create('KnpLabs', [ | ||
'name' => $name, | ||
'value' => $value, | ||
'visibility' => $visibility, | ||
'selected_repository_ids' => $selectedRepositoryIds, | ||
]); | ||
``` | ||
|
||
### Update an organization variable | ||
|
||
https://docs.github.com/en/rest/actions/variables?apiVersion=2022-11-28#update-an-organization-variable | ||
|
||
```php | ||
$client->organization()->variables()->update('KnpLabs', $variableName, [ | ||
'name' => $name, | ||
'value' => $value, | ||
'visibility' => $visibility, | ||
'selected_repository_ids' => $selectedRepositoryIds | ||
]); | ||
``` | ||
|
||
### Delete an organization variable | ||
|
||
https://docs.github.com/en/rest/actions/variables?apiVersion=2022-11-28#delete-an-organization-variable | ||
|
||
```php | ||
$client->organization()->variables()->remove('KnpLabs', $variableName); | ||
``` | ||
|
||
### List selected repositories for organization variable | ||
|
||
https://docs.github.com/en/rest/actions/variables?apiVersion=2022-11-28#list-selected-repositories-for-an-organization-variable | ||
|
||
```php | ||
$client->organization()->variables()->selectedRepositories('KnpLabs', $variableName); | ||
``` | ||
|
||
### Set selected repositories for an organization variable | ||
|
||
https://docs.github.com/en/rest/actions/variables?apiVersion=2022-11-28#set-selected-repositories-for-an-organization-variable | ||
|
||
```php | ||
$client->organization()->variables()->setSelectedRepositories('KnpLabs', 'variableName', [ | ||
'selected_repository_ids' => [1, 2, 3], | ||
]); | ||
``` | ||
|
||
### Add selected repository to an organization variable | ||
|
||
https://docs.github.com/en/rest/actions/variables?apiVersion=2022-11-28#add-selected-repository-to-an-organization-variable | ||
|
||
```php | ||
$client->organization()->variables()->addRepository('KnpLabs', $repositoryId, $variableName); | ||
``` | ||
|
||
### Remove selected repository from an organization variable | ||
|
||
https://docs.github.com/en/rest/actions/variables?apiVersion=2022-11-28#remove-selected-repository-from-an-organization-variable | ||
|
||
```php | ||
$client->organization()->variables()->removeRepository('KnpLabs', $repositoryId, $variableName); | ||
``` | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
## Repo / Actions / Variables API | ||
[Back to the "Repos API"](../../repos.md) | [Back to the navigation](../../README.md) | ||
|
||
### List repository variables | ||
|
||
https://docs.github.com/en/rest/actions/variables?apiVersion=2022-11-28#list-repository-variables | ||
|
||
```php | ||
$variables = $client->api('repo')->variables()->all('KnpLabs', 'php-github-api'); | ||
``` | ||
|
||
### Get a repository variable | ||
|
||
https://docs.github.com/en/rest/actions/variables?apiVersion=2022-11-28#get-a-repository-variable | ||
|
||
```php | ||
$variable = $client->api('repo')->variables()->show('KnpLabs', 'php-github-api', $variableName); | ||
``` | ||
|
||
### Create a repository variable | ||
|
||
https://docs.github.com/en/rest/actions/variables?apiVersion=2022-11-28#create-a-repository-variable | ||
|
||
```php | ||
$client->api('repo')->variables()->create('KnpLabs', 'php-github-api', [ | ||
'name' => $name, | ||
'value' => $value, | ||
]); | ||
``` | ||
|
||
### Update a repository variable | ||
|
||
https://docs.github.com/en/rest/actions/variables?apiVersion=2022-11-28#update-a-repository-variable | ||
|
||
```php | ||
$client->api('repo')->variables()->update('KnpLabs', 'php-github-api', $variableName, [ | ||
'name' => $name, | ||
'value' => $value, | ||
]); | ||
``` | ||
|
||
### Delete a repository variable | ||
|
||
https://docs.github.com/en/rest/actions/variables?apiVersion=2022-11-28#delete-a-repository-variable | ||
|
||
```php | ||
$client->api('repo')->variables()->remove('KnpLabs', 'php-github-api', $variableName); | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,131 @@ | ||
<?php | ||
|
||
namespace Github\Api\Organization\Actions; | ||
|
||
use Github\Api\AbstractApi; | ||
|
||
/** | ||
* @link https://docs.github.com/en/rest/reference/actions#variables | ||
*/ | ||
class Variables extends AbstractApi | ||
{ | ||
/** | ||
* @link https://docs.github.com/en/rest/actions/variables?apiVersion=2022-11-28#list-organization-variables | ||
* | ||
* @param string $organization | ||
* | ||
* @return array|string | ||
*/ | ||
public function all(string $organization) | ||
{ | ||
return $this->get('/orgs/'.rawurlencode($organization).'/actions/variables'); | ||
} | ||
|
||
/** | ||
* @link https://docs.github.com/en/rest/reference/actions#get-an-organization-secret | ||
* | ||
* @param string $organization | ||
* @param string $variableName | ||
* | ||
* @return array|string | ||
*/ | ||
public function show(string $organization, string $variableName) | ||
{ | ||
return $this->get('/orgs/'.rawurlencode($organization).'/actions/variables/'.rawurlencode($variableName)); | ||
} | ||
|
||
/** | ||
* @link https://docs.github.com/en/rest/actions/variables?apiVersion=2022-11-28#create-an-organization-variable | ||
* | ||
* @param string $organization | ||
* @param array $parameters | ||
* | ||
* @return array|string | ||
*/ | ||
public function create(string $organization, array $parameters) | ||
{ | ||
return $this->post('/orgs/'.rawurlencode($organization).'/actions/variables', $parameters); | ||
} | ||
|
||
/** | ||
* @link https://docs.github.com/en/rest/actions/variables?apiVersion=2022-11-28#update-an-organization-variable | ||
* | ||
* @param string $organization | ||
* @param string $variableName | ||
* @param array $parameters | ||
* | ||
* @return array|string | ||
*/ | ||
public function update(string $organization, string $variableName, array $parameters = []) | ||
{ | ||
return $this->patch('/orgs/'.rawurlencode($organization).'/actions/variables/'.rawurlencode($variableName), $parameters); | ||
} | ||
|
||
/** | ||
* @link https://docs.github.com/en/rest/actions/variables?apiVersion=2022-11-28#delete-an-organization-variable | ||
* | ||
* @param string $organization | ||
* @param string $variableName | ||
* | ||
* @return array|string | ||
*/ | ||
public function remove(string $organization, string $variableName) | ||
{ | ||
return $this->delete('/orgs/'.rawurlencode($organization).'/actions/variables/'.rawurlencode($variableName)); | ||
} | ||
|
||
/** | ||
* @link https://docs.github.com/en/rest/actions/variables?apiVersion=2022-11-28#list-selected-repositories-for-an-organization-variable | ||
* | ||
* @param string $organization | ||
* @param string $variableName | ||
* | ||
* @return array|string | ||
*/ | ||
public function selectedRepositories(string $organization, string $variableName) | ||
{ | ||
return $this->get('/orgs/'.rawurlencode($organization).'/actions/variables/'.rawurlencode($variableName).'/repositories'); | ||
} | ||
|
||
/** | ||
* @link https://docs.github.com/en/rest/actions/variables?apiVersion=2022-11-28#set-selected-repositories-for-an-organization-variable | ||
* | ||
* @param string $organization | ||
* @param string $variableName | ||
* @param array $parameters | ||
* | ||
* @return array|string | ||
*/ | ||
public function setSelectedRepositories(string $organization, string $variableName, array $parameters = []) | ||
{ | ||
return $this->put('/orgs/'.rawurlencode($organization).'/actions/variables/'.rawurlencode($variableName).'/repositories', $parameters); | ||
} | ||
|
||
/** | ||
* @link https://docs.github.com/en/rest/actions/variables?apiVersion=2022-11-28#add-selected-repository-to-an-organization-variable | ||
* | ||
* @param string $organization | ||
* @param int $repositoryId | ||
* @param string $variableName | ||
* | ||
* @return array|string | ||
*/ | ||
public function addRepository(string $organization, int $repositoryId, string $variableName) | ||
{ | ||
return $this->put('/orgs/'.rawurlencode($organization).'/actions/variables/'.rawurlencode($variableName).'/repositories/'.$repositoryId); | ||
} | ||
|
||
/** | ||
* @link https://docs.github.com/en/rest/actions/variables?apiVersion=2022-11-28#remove-selected-repository-from-an-organization-variable | ||
* | ||
* @param string $organization | ||
* @param int $repositoryId | ||
* @param string $variableName | ||
* | ||
* @return array|string | ||
*/ | ||
public function removeRepository(string $organization, int $repositoryId, string $variableName) | ||
{ | ||
return $this->delete('/orgs/'.rawurlencode($organization).'/actions/variables/'.rawurlencode($variableName).'/repositories/'.$repositoryId); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.