|
| 1 | +<?php |
| 2 | + |
| 3 | +namespace Github\Api\Environment; |
| 4 | + |
| 5 | +use Github\Api\AbstractApi; |
| 6 | + |
| 7 | +/** |
| 8 | + * @link https://docs.github.com/en/rest/actions/variables?apiVersion=2022-11-28 |
| 9 | + */ |
| 10 | +class Variables extends AbstractApi |
| 11 | +{ |
| 12 | + /** |
| 13 | + * @link https://docs.github.com/en/rest/actions/variables?apiVersion=2022-11-28#list-environment-variables |
| 14 | + * |
| 15 | + * @param int $id |
| 16 | + * @param string $name |
| 17 | + * |
| 18 | + * @return array|string |
| 19 | + */ |
| 20 | + public function all(int $id, string $name) |
| 21 | + { |
| 22 | + return $this->get('/repositories/'.$id.'/environments/'.rawurlencode($name).'/variables'); |
| 23 | + } |
| 24 | + |
| 25 | + /** |
| 26 | + * @link https://docs.github.com/en/rest/actions/variables?apiVersion=2022-11-28#get-an-environment-variable |
| 27 | + * |
| 28 | + * @param int $id |
| 29 | + * @param string $name |
| 30 | + * @param string $variableName |
| 31 | + * |
| 32 | + * @return array|string |
| 33 | + */ |
| 34 | + public function show(int $id, string $name, string $variableName) |
| 35 | + { |
| 36 | + return $this->get('/repositories/'.$id.'/environments/'.rawurlencode($name).'/variables/'.rawurlencode($variableName)); |
| 37 | + } |
| 38 | + |
| 39 | + /** |
| 40 | + * @link https://docs.github.com/en/rest/actions/variables?apiVersion=2022-11-28#create-an-environment-variable |
| 41 | + * |
| 42 | + * @param int $id |
| 43 | + * @param string $name |
| 44 | + * @param array $parameters |
| 45 | + * |
| 46 | + * @return array|string |
| 47 | + */ |
| 48 | + public function create(int $id, string $name, array $parameters) |
| 49 | + { |
| 50 | + return $this->post('/repositories/'.$id.'/environments/'.rawurlencode($name).'/variables', $parameters); |
| 51 | + } |
| 52 | + |
| 53 | + /** |
| 54 | + * @link https://docs.github.com/en/rest/actions/variables?apiVersion=2022-11-28#update-an-environment-variable |
| 55 | + * |
| 56 | + * @param int $id |
| 57 | + * @param string $name |
| 58 | + * @param string $variableName |
| 59 | + * @param array $parameters |
| 60 | + * |
| 61 | + * @return array|string |
| 62 | + */ |
| 63 | + public function update(int $id, string $name, string $variableName, array $parameters) |
| 64 | + { |
| 65 | + return $this->patch('/repositories/'.$id.'/environments/'.rawurlencode($name).'/variables/'.rawurlencode($variableName), $parameters); |
| 66 | + } |
| 67 | + |
| 68 | + /** |
| 69 | + * @link https://docs.github.com/en/rest/actions/variables?apiVersion=2022-11-28#delete-an-environment-variable |
| 70 | + * |
| 71 | + * @param int $id |
| 72 | + * @param string $name |
| 73 | + * @param string $variableName |
| 74 | + * |
| 75 | + * @return array|string |
| 76 | + */ |
| 77 | + public function remove(int $id, string $name, string $variableName) |
| 78 | + { |
| 79 | + return $this->delete('/repositories/'.$id.'/environments/'.rawurlencode($name).'/variables/'.rawurlencode($variableName)); |
| 80 | + } |
| 81 | +} |
0 commit comments