@@ -12,194 +12,194 @@ |
||
| 12 | 12 | class Labels extends AbstractIssues |
| 13 | 13 | { |
| 14 | 14 | |
| 15 | - /** |
|
| 16 | - * List all labels for this repository |
|
| 17 | - * |
|
| 18 | - * @link https://developer.github.com/v3/issues/labels/#list-all-labels-for-this-repository |
|
| 19 | - * @return array |
|
| 20 | - */ |
|
| 21 | - public function listRepositoryLabels(): array |
|
| 22 | - { |
|
| 23 | - return $this->getApi()->request($this->getApi() |
|
| 24 | - ->sprintf('/repos/:owner/:repo/labels', $this->getIssues()->getOwner(), |
|
| 25 | - $this->getIssues()->getRepo())); |
|
| 26 | - } |
|
| 27 | - |
|
| 28 | - /** |
|
| 29 | - * Get a single label |
|
| 30 | - * |
|
| 31 | - * @link https://developer.github.com/v3/issues/labels/#get-a-single-label |
|
| 32 | - * |
|
| 33 | - * @param string $name |
|
| 34 | - * |
|
| 35 | - * @return array |
|
| 36 | - */ |
|
| 37 | - public function getLabel(string $name): array |
|
| 38 | - { |
|
| 39 | - return $this->getApi()->request($this->getApi()->sprintf('/repos/:owner/:repo/labels/:name', |
|
| 40 | - $this->getIssues()->getOwner(), $this->getIssues()->getRepo(), $name)); |
|
| 41 | - } |
|
| 42 | - |
|
| 43 | - /** |
|
| 44 | - * Create a label |
|
| 45 | - * |
|
| 46 | - * @link https://developer.github.com/v3/issues/labels/#create-a-label |
|
| 47 | - * |
|
| 48 | - * @param string $name |
|
| 49 | - * @param string $color |
|
| 50 | - * |
|
| 51 | - * @return array |
|
| 52 | - */ |
|
| 53 | - public function createLabel(string $name, string $color): array |
|
| 54 | - { |
|
| 55 | - return $this->getApi()->request($this->getApi() |
|
| 56 | - ->sprintf('/repos/:owner/:repo/labels', $this->getIssues()->getOwner(), |
|
| 57 | - $this->getIssues()->getRepo()), Request::METHOD_POST, [ |
|
| 58 | - 'name' => $name, |
|
| 59 | - 'color' => $color |
|
| 60 | - ]); |
|
| 61 | - } |
|
| 62 | - |
|
| 63 | - /** |
|
| 64 | - * Update a label |
|
| 65 | - * |
|
| 66 | - * @link https://developer.github.com/v3/issues/labels/#update-a-label |
|
| 67 | - * |
|
| 68 | - * @param string $name |
|
| 69 | - * @param string $color |
|
| 70 | - * |
|
| 71 | - * @return array |
|
| 72 | - */ |
|
| 73 | - public function updateLabel(string $name, string $color): array |
|
| 74 | - { |
|
| 75 | - return $this->getApi()->request($this->getApi()->sprintf('/repos/:owner/:repo/labels/:name', |
|
| 76 | - $this->getIssues()->getOwner(), $this->getIssues()->getRepo(), $name), Request::METHOD_PATCH, [ |
|
| 77 | - 'color' => $color |
|
| 78 | - ]); |
|
| 79 | - } |
|
| 80 | - |
|
| 81 | - /** |
|
| 82 | - * Delete a label |
|
| 83 | - * |
|
| 84 | - * @link https://developer.github.com/v3/issues/labels/#delete-a-label |
|
| 85 | - * |
|
| 86 | - * @param string $name |
|
| 87 | - * |
|
| 88 | - * @return bool |
|
| 89 | - */ |
|
| 90 | - public function deleteLabel(string $name): bool |
|
| 91 | - { |
|
| 92 | - $this->getApi()->request($this->getApi() |
|
| 93 | - ->sprintf('/repos/:owner/:repo/labels/:name', $this->getIssues()->getOwner(), |
|
| 94 | - $this->getIssues()->getRepo(), $name)); |
|
| 95 | - |
|
| 96 | - if ($this->getApi()->getHeaders()['Status'] == '204 No Content') { |
|
| 97 | - return true; |
|
| 98 | - } |
|
| 99 | - |
|
| 100 | - return false; |
|
| 101 | - } |
|
| 102 | - |
|
| 103 | - /** |
|
| 104 | - * List labels on an issue |
|
| 105 | - * |
|
| 106 | - * @link https://developer.github.com/v3/issues/labels/#list-labels-on-an-issue |
|
| 107 | - * |
|
| 108 | - * @param int $number |
|
| 109 | - * |
|
| 110 | - * @return array |
|
| 111 | - */ |
|
| 112 | - public function listIssueLabels(int $number): array |
|
| 113 | - { |
|
| 114 | - return $this->getApi()->request($this->getApi()->sprintf('/repos/:owner/:repo/issues/:number/labels', |
|
| 115 | - $this->getIssues()->getOwner(), $this->getIssues()->getRepo(), $number)); |
|
| 116 | - } |
|
| 117 | - |
|
| 118 | - /** |
|
| 119 | - * Add labels to an issue |
|
| 120 | - * |
|
| 121 | - * @link https://developer.github.com/v3/issues/labels/#add-labels-to-an-issue |
|
| 122 | - * |
|
| 123 | - * @param int $number |
|
| 124 | - * |
|
| 125 | - * @return array |
|
| 126 | - */ |
|
| 127 | - public function addIssueLabels(int $number): array |
|
| 128 | - { |
|
| 129 | - return $this->getApi()->request($this->getApi()->sprintf('/repos/:owner/:repo/issues/:number/labels', |
|
| 130 | - $this->getIssues()->getOwner(), $this->getIssues()->getRepo(), $number), Request::METHOD_POST); |
|
| 131 | - } |
|
| 132 | - |
|
| 133 | - /** |
|
| 134 | - * Remove a label from an issue |
|
| 135 | - * |
|
| 136 | - * @link https://developer.github.com/v3/issues/labels/#remove-a-label-from-an-issue |
|
| 137 | - * |
|
| 138 | - * @param int $number |
|
| 139 | - * @param string $name |
|
| 140 | - * |
|
| 141 | - * @return bool |
|
| 142 | - */ |
|
| 143 | - public function removeIssueLabel(int $number, string $name): bool |
|
| 144 | - { |
|
| 145 | - $this->getApi()->request($this->getApi()->sprintf('/repos/:owner/:repo/issues/:number/labels/:name', |
|
| 146 | - $this->getIssues()->getOwner(), $this->getIssues()->getRepo(), $number, $name), Request::METHOD_DELETE); |
|
| 147 | - |
|
| 148 | - if ($this->getApi()->getHeaders()['Status'] == '204 No Content') { |
|
| 149 | - return true; |
|
| 150 | - } |
|
| 151 | - |
|
| 152 | - return false; |
|
| 153 | - } |
|
| 154 | - |
|
| 155 | - /** |
|
| 156 | - * Replace all labels for an issue |
|
| 157 | - * |
|
| 158 | - * @link https://developer.github.com/v3/issues/labels/#replace-all-labels-for-an-issue |
|
| 159 | - * |
|
| 160 | - * @param int $number |
|
| 161 | - * |
|
| 162 | - * @return array |
|
| 163 | - */ |
|
| 164 | - public function replaceIssuesLabels(int $number): array |
|
| 165 | - { |
|
| 166 | - return $this->getApi()->request($this->getApi()->sprintf('/repos/:owner/:repo/issues/:number/labels', |
|
| 167 | - $this->getIssues()->getOwner(), $this->getIssues()->getRepo(), $number), Request::METHOD_PUT); |
|
| 168 | - } |
|
| 169 | - |
|
| 170 | - /** |
|
| 171 | - * Remove all labels from an issue |
|
| 172 | - * |
|
| 173 | - * @link https://developer.github.com/v3/issues/labels/#remove-all-labels-from-an-issue |
|
| 174 | - * |
|
| 175 | - * @param int $number |
|
| 176 | - * |
|
| 177 | - * @return bool |
|
| 178 | - */ |
|
| 179 | - public function removeIssueLabels(int $number): bool |
|
| 180 | - { |
|
| 181 | - $this->getApi()->request($this->getApi()->sprintf('/repos/:owner/:repo/issues/:number/labels', |
|
| 182 | - $this->getIssues()->getOwner(), $this->getIssues()->getRepo(), $number), Request::METHOD_DELETE); |
|
| 183 | - |
|
| 184 | - if ($this->getApi()->getHeaders()['Status'] == '204 No Content') { |
|
| 185 | - return true; |
|
| 186 | - } |
|
| 187 | - |
|
| 188 | - return false; |
|
| 189 | - } |
|
| 190 | - |
|
| 191 | - /** |
|
| 192 | - * Get labels for every issue in a milestone |
|
| 193 | - * |
|
| 194 | - * @link https://developer.github.com/v3/issues/labels/#get-labels-for-every-issue-in-a-milestone |
|
| 195 | - * |
|
| 196 | - * @param int $number |
|
| 197 | - * |
|
| 198 | - * @return array |
|
| 199 | - */ |
|
| 200 | - public function getIssueLabelsInMilestone(int $number): array |
|
| 201 | - { |
|
| 202 | - return $this->getApi()->request($this->getApi()->sprintf('/repos/:owner/:repo/milestones/:number/labels', |
|
| 203 | - $this->getIssues()->getOwner(), $this->getIssues()->getRepo(), $number)); |
|
| 204 | - } |
|
| 15 | + /** |
|
| 16 | + * List all labels for this repository |
|
| 17 | + * |
|
| 18 | + * @link https://developer.github.com/v3/issues/labels/#list-all-labels-for-this-repository |
|
| 19 | + * @return array |
|
| 20 | + */ |
|
| 21 | + public function listRepositoryLabels(): array |
|
| 22 | + { |
|
| 23 | + return $this->getApi()->request($this->getApi() |
|
| 24 | + ->sprintf('/repos/:owner/:repo/labels', $this->getIssues()->getOwner(), |
|
| 25 | + $this->getIssues()->getRepo())); |
|
| 26 | + } |
|
| 27 | + |
|
| 28 | + /** |
|
| 29 | + * Get a single label |
|
| 30 | + * |
|
| 31 | + * @link https://developer.github.com/v3/issues/labels/#get-a-single-label |
|
| 32 | + * |
|
| 33 | + * @param string $name |
|
| 34 | + * |
|
| 35 | + * @return array |
|
| 36 | + */ |
|
| 37 | + public function getLabel(string $name): array |
|
| 38 | + { |
|
| 39 | + return $this->getApi()->request($this->getApi()->sprintf('/repos/:owner/:repo/labels/:name', |
|
| 40 | + $this->getIssues()->getOwner(), $this->getIssues()->getRepo(), $name)); |
|
| 41 | + } |
|
| 42 | + |
|
| 43 | + /** |
|
| 44 | + * Create a label |
|
| 45 | + * |
|
| 46 | + * @link https://developer.github.com/v3/issues/labels/#create-a-label |
|
| 47 | + * |
|
| 48 | + * @param string $name |
|
| 49 | + * @param string $color |
|
| 50 | + * |
|
| 51 | + * @return array |
|
| 52 | + */ |
|
| 53 | + public function createLabel(string $name, string $color): array |
|
| 54 | + { |
|
| 55 | + return $this->getApi()->request($this->getApi() |
|
| 56 | + ->sprintf('/repos/:owner/:repo/labels', $this->getIssues()->getOwner(), |
|
| 57 | + $this->getIssues()->getRepo()), Request::METHOD_POST, [ |
|
| 58 | + 'name' => $name, |
|
| 59 | + 'color' => $color |
|
| 60 | + ]); |
|
| 61 | + } |
|
| 62 | + |
|
| 63 | + /** |
|
| 64 | + * Update a label |
|
| 65 | + * |
|
| 66 | + * @link https://developer.github.com/v3/issues/labels/#update-a-label |
|
| 67 | + * |
|
| 68 | + * @param string $name |
|
| 69 | + * @param string $color |
|
| 70 | + * |
|
| 71 | + * @return array |
|
| 72 | + */ |
|
| 73 | + public function updateLabel(string $name, string $color): array |
|
| 74 | + { |
|
| 75 | + return $this->getApi()->request($this->getApi()->sprintf('/repos/:owner/:repo/labels/:name', |
|
| 76 | + $this->getIssues()->getOwner(), $this->getIssues()->getRepo(), $name), Request::METHOD_PATCH, [ |
|
| 77 | + 'color' => $color |
|
| 78 | + ]); |
|
| 79 | + } |
|
| 80 | + |
|
| 81 | + /** |
|
| 82 | + * Delete a label |
|
| 83 | + * |
|
| 84 | + * @link https://developer.github.com/v3/issues/labels/#delete-a-label |
|
| 85 | + * |
|
| 86 | + * @param string $name |
|
| 87 | + * |
|
| 88 | + * @return bool |
|
| 89 | + */ |
|
| 90 | + public function deleteLabel(string $name): bool |
|
| 91 | + { |
|
| 92 | + $this->getApi()->request($this->getApi() |
|
| 93 | + ->sprintf('/repos/:owner/:repo/labels/:name', $this->getIssues()->getOwner(), |
|
| 94 | + $this->getIssues()->getRepo(), $name)); |
|
| 95 | + |
|
| 96 | + if ($this->getApi()->getHeaders()['Status'] == '204 No Content') { |
|
| 97 | + return true; |
|
| 98 | + } |
|
| 99 | + |
|
| 100 | + return false; |
|
| 101 | + } |
|
| 102 | + |
|
| 103 | + /** |
|
| 104 | + * List labels on an issue |
|
| 105 | + * |
|
| 106 | + * @link https://developer.github.com/v3/issues/labels/#list-labels-on-an-issue |
|
| 107 | + * |
|
| 108 | + * @param int $number |
|
| 109 | + * |
|
| 110 | + * @return array |
|
| 111 | + */ |
|
| 112 | + public function listIssueLabels(int $number): array |
|
| 113 | + { |
|
| 114 | + return $this->getApi()->request($this->getApi()->sprintf('/repos/:owner/:repo/issues/:number/labels', |
|
| 115 | + $this->getIssues()->getOwner(), $this->getIssues()->getRepo(), $number)); |
|
| 116 | + } |
|
| 117 | + |
|
| 118 | + /** |
|
| 119 | + * Add labels to an issue |
|
| 120 | + * |
|
| 121 | + * @link https://developer.github.com/v3/issues/labels/#add-labels-to-an-issue |
|
| 122 | + * |
|
| 123 | + * @param int $number |
|
| 124 | + * |
|
| 125 | + * @return array |
|
| 126 | + */ |
|
| 127 | + public function addIssueLabels(int $number): array |
|
| 128 | + { |
|
| 129 | + return $this->getApi()->request($this->getApi()->sprintf('/repos/:owner/:repo/issues/:number/labels', |
|
| 130 | + $this->getIssues()->getOwner(), $this->getIssues()->getRepo(), $number), Request::METHOD_POST); |
|
| 131 | + } |
|
| 132 | + |
|
| 133 | + /** |
|
| 134 | + * Remove a label from an issue |
|
| 135 | + * |
|
| 136 | + * @link https://developer.github.com/v3/issues/labels/#remove-a-label-from-an-issue |
|
| 137 | + * |
|
| 138 | + * @param int $number |
|
| 139 | + * @param string $name |
|
| 140 | + * |
|
| 141 | + * @return bool |
|
| 142 | + */ |
|
| 143 | + public function removeIssueLabel(int $number, string $name): bool |
|
| 144 | + { |
|
| 145 | + $this->getApi()->request($this->getApi()->sprintf('/repos/:owner/:repo/issues/:number/labels/:name', |
|
| 146 | + $this->getIssues()->getOwner(), $this->getIssues()->getRepo(), $number, $name), Request::METHOD_DELETE); |
|
| 147 | + |
|
| 148 | + if ($this->getApi()->getHeaders()['Status'] == '204 No Content') { |
|
| 149 | + return true; |
|
| 150 | + } |
|
| 151 | + |
|
| 152 | + return false; |
|
| 153 | + } |
|
| 154 | + |
|
| 155 | + /** |
|
| 156 | + * Replace all labels for an issue |
|
| 157 | + * |
|
| 158 | + * @link https://developer.github.com/v3/issues/labels/#replace-all-labels-for-an-issue |
|
| 159 | + * |
|
| 160 | + * @param int $number |
|
| 161 | + * |
|
| 162 | + * @return array |
|
| 163 | + */ |
|
| 164 | + public function replaceIssuesLabels(int $number): array |
|
| 165 | + { |
|
| 166 | + return $this->getApi()->request($this->getApi()->sprintf('/repos/:owner/:repo/issues/:number/labels', |
|
| 167 | + $this->getIssues()->getOwner(), $this->getIssues()->getRepo(), $number), Request::METHOD_PUT); |
|
| 168 | + } |
|
| 169 | + |
|
| 170 | + /** |
|
| 171 | + * Remove all labels from an issue |
|
| 172 | + * |
|
| 173 | + * @link https://developer.github.com/v3/issues/labels/#remove-all-labels-from-an-issue |
|
| 174 | + * |
|
| 175 | + * @param int $number |
|
| 176 | + * |
|
| 177 | + * @return bool |
|
| 178 | + */ |
|
| 179 | + public function removeIssueLabels(int $number): bool |
|
| 180 | + { |
|
| 181 | + $this->getApi()->request($this->getApi()->sprintf('/repos/:owner/:repo/issues/:number/labels', |
|
| 182 | + $this->getIssues()->getOwner(), $this->getIssues()->getRepo(), $number), Request::METHOD_DELETE); |
|
| 183 | + |
|
| 184 | + if ($this->getApi()->getHeaders()['Status'] == '204 No Content') { |
|
| 185 | + return true; |
|
| 186 | + } |
|
| 187 | + |
|
| 188 | + return false; |
|
| 189 | + } |
|
| 190 | + |
|
| 191 | + /** |
|
| 192 | + * Get labels for every issue in a milestone |
|
| 193 | + * |
|
| 194 | + * @link https://developer.github.com/v3/issues/labels/#get-labels-for-every-issue-in-a-milestone |
|
| 195 | + * |
|
| 196 | + * @param int $number |
|
| 197 | + * |
|
| 198 | + * @return array |
|
| 199 | + */ |
|
| 200 | + public function getIssueLabelsInMilestone(int $number): array |
|
| 201 | + { |
|
| 202 | + return $this->getApi()->request($this->getApi()->sprintf('/repos/:owner/:repo/milestones/:number/labels', |
|
| 203 | + $this->getIssues()->getOwner(), $this->getIssues()->getRepo(), $number)); |
|
| 204 | + } |
|
| 205 | 205 | } |
| 206 | 206 | \ No newline at end of file |
@@ -14,111 +14,111 @@ |
||
| 14 | 14 | class Milestones extends AbstractIssues |
| 15 | 15 | { |
| 16 | 16 | |
| 17 | - /** |
|
| 18 | - * List milestones for a repository |
|
| 19 | - * |
|
| 20 | - * @link https://developer.github.com/v3/issues/milestones/#list-milestones-for-a-repository |
|
| 21 | - * |
|
| 22 | - * @param string $state |
|
| 23 | - * @param string $sort |
|
| 24 | - * @param string $direction |
|
| 25 | - * |
|
| 26 | - * @return array |
|
| 27 | - */ |
|
| 28 | - public function listMilestones(string $state = AbstractApi::STATE_OPEN, string $sort = AbstractApi::SORT_DUE_DATE, |
|
| 29 | - string $direction = AbstractApi::DIRECTION_ASC): array |
|
| 30 | - { |
|
| 31 | - return $this->getApi()->request($this->getApi()->sprintf('/repos/:owner/:repo/milestones?:args', |
|
| 32 | - $this->getIssues()->getOwner(), $this->getIssues()->getRepo(), http_build_query([ |
|
| 33 | - 'state' => $state, |
|
| 34 | - 'sort' => $sort, |
|
| 35 | - 'direction' => $direction |
|
| 36 | - ]))); |
|
| 37 | - } |
|
| 17 | + /** |
|
| 18 | + * List milestones for a repository |
|
| 19 | + * |
|
| 20 | + * @link https://developer.github.com/v3/issues/milestones/#list-milestones-for-a-repository |
|
| 21 | + * |
|
| 22 | + * @param string $state |
|
| 23 | + * @param string $sort |
|
| 24 | + * @param string $direction |
|
| 25 | + * |
|
| 26 | + * @return array |
|
| 27 | + */ |
|
| 28 | + public function listMilestones(string $state = AbstractApi::STATE_OPEN, string $sort = AbstractApi::SORT_DUE_DATE, |
|
| 29 | + string $direction = AbstractApi::DIRECTION_ASC): array |
|
| 30 | + { |
|
| 31 | + return $this->getApi()->request($this->getApi()->sprintf('/repos/:owner/:repo/milestones?:args', |
|
| 32 | + $this->getIssues()->getOwner(), $this->getIssues()->getRepo(), http_build_query([ |
|
| 33 | + 'state' => $state, |
|
| 34 | + 'sort' => $sort, |
|
| 35 | + 'direction' => $direction |
|
| 36 | + ]))); |
|
| 37 | + } |
|
| 38 | 38 | |
| 39 | - /** |
|
| 40 | - * Get a single milestone |
|
| 41 | - * |
|
| 42 | - * @link https://developer.github.com/v3/issues/milestones/#get-a-single-milestone |
|
| 43 | - * |
|
| 44 | - * @param int $number |
|
| 45 | - * |
|
| 46 | - * @return array |
|
| 47 | - */ |
|
| 48 | - public function getMilestone(int $number): array |
|
| 49 | - { |
|
| 50 | - return $this->getApi()->request($this->getApi()->sprintf('/repos/:owner/:repo/milestones/:number', |
|
| 51 | - $this->getIssues()->getOwner(), $this->getIssues()->getRepo(), $number)); |
|
| 52 | - } |
|
| 39 | + /** |
|
| 40 | + * Get a single milestone |
|
| 41 | + * |
|
| 42 | + * @link https://developer.github.com/v3/issues/milestones/#get-a-single-milestone |
|
| 43 | + * |
|
| 44 | + * @param int $number |
|
| 45 | + * |
|
| 46 | + * @return array |
|
| 47 | + */ |
|
| 48 | + public function getMilestone(int $number): array |
|
| 49 | + { |
|
| 50 | + return $this->getApi()->request($this->getApi()->sprintf('/repos/:owner/:repo/milestones/:number', |
|
| 51 | + $this->getIssues()->getOwner(), $this->getIssues()->getRepo(), $number)); |
|
| 52 | + } |
|
| 53 | 53 | |
| 54 | - /** |
|
| 55 | - * Create a milestone |
|
| 56 | - * |
|
| 57 | - * @link https://developer.github.com/v3/issues/milestones/#create-a-milestone |
|
| 58 | - * |
|
| 59 | - * @param string $title |
|
| 60 | - * @param string $state |
|
| 61 | - * @param string $description |
|
| 62 | - * @param string $dueOn |
|
| 63 | - * |
|
| 64 | - * @return array |
|
| 65 | - */ |
|
| 66 | - public function createMilestone(string $title, string $state = AbstractApi::STATE_OPEN, string $description = '', |
|
| 67 | - string $dueOn = ''): array |
|
| 68 | - { |
|
| 69 | - return $this->getApi()->request($this->getApi() |
|
| 70 | - ->sprintf('/repos/:owner/:repo/milestones', $this->getIssues()->getOwner(), |
|
| 71 | - $this->getIssues()->getRepo()), Request::METHOD_POST, [ |
|
| 72 | - 'title' => $title, |
|
| 73 | - 'state' => $state, |
|
| 74 | - 'description' => $description, |
|
| 75 | - 'due_on' => (new DateTime($dueOn))->format(DateTime::ATOM) |
|
| 76 | - ]); |
|
| 77 | - } |
|
| 54 | + /** |
|
| 55 | + * Create a milestone |
|
| 56 | + * |
|
| 57 | + * @link https://developer.github.com/v3/issues/milestones/#create-a-milestone |
|
| 58 | + * |
|
| 59 | + * @param string $title |
|
| 60 | + * @param string $state |
|
| 61 | + * @param string $description |
|
| 62 | + * @param string $dueOn |
|
| 63 | + * |
|
| 64 | + * @return array |
|
| 65 | + */ |
|
| 66 | + public function createMilestone(string $title, string $state = AbstractApi::STATE_OPEN, string $description = '', |
|
| 67 | + string $dueOn = ''): array |
|
| 68 | + { |
|
| 69 | + return $this->getApi()->request($this->getApi() |
|
| 70 | + ->sprintf('/repos/:owner/:repo/milestones', $this->getIssues()->getOwner(), |
|
| 71 | + $this->getIssues()->getRepo()), Request::METHOD_POST, [ |
|
| 72 | + 'title' => $title, |
|
| 73 | + 'state' => $state, |
|
| 74 | + 'description' => $description, |
|
| 75 | + 'due_on' => (new DateTime($dueOn))->format(DateTime::ATOM) |
|
| 76 | + ]); |
|
| 77 | + } |
|
| 78 | 78 | |
| 79 | - /** |
|
| 80 | - * Update a milestone |
|
| 81 | - * |
|
| 82 | - * @link https://developer.github.com/v3/issues/milestones/#update-a-milestone |
|
| 83 | - * |
|
| 84 | - * @param int $number |
|
| 85 | - * @param string $title |
|
| 86 | - * @param string $state |
|
| 87 | - * @param string $description |
|
| 88 | - * @param string $dueOn |
|
| 89 | - * |
|
| 90 | - * @return array |
|
| 91 | - */ |
|
| 92 | - public function updateMilestone(int $number, string $title = '', string $state = AbstractApi::STATE_OPEN, |
|
| 93 | - string $description = '', string $dueOn = ''): array |
|
| 94 | - { |
|
| 95 | - return $this->getApi()->request($this->getApi()->sprintf('/repos/:owner/:repo/milestones/:number', |
|
| 96 | - $this->getIssues()->getOwner(), $this->getIssues()->getRepo(), $number), Request::METHOD_PATCH, [ |
|
| 97 | - 'title' => $title, |
|
| 98 | - 'state' => $state, |
|
| 99 | - 'description' => $description, |
|
| 100 | - 'due_on' => (new DateTime($dueOn))->format(DateTime::ATOM) |
|
| 101 | - ]); |
|
| 102 | - } |
|
| 79 | + /** |
|
| 80 | + * Update a milestone |
|
| 81 | + * |
|
| 82 | + * @link https://developer.github.com/v3/issues/milestones/#update-a-milestone |
|
| 83 | + * |
|
| 84 | + * @param int $number |
|
| 85 | + * @param string $title |
|
| 86 | + * @param string $state |
|
| 87 | + * @param string $description |
|
| 88 | + * @param string $dueOn |
|
| 89 | + * |
|
| 90 | + * @return array |
|
| 91 | + */ |
|
| 92 | + public function updateMilestone(int $number, string $title = '', string $state = AbstractApi::STATE_OPEN, |
|
| 93 | + string $description = '', string $dueOn = ''): array |
|
| 94 | + { |
|
| 95 | + return $this->getApi()->request($this->getApi()->sprintf('/repos/:owner/:repo/milestones/:number', |
|
| 96 | + $this->getIssues()->getOwner(), $this->getIssues()->getRepo(), $number), Request::METHOD_PATCH, [ |
|
| 97 | + 'title' => $title, |
|
| 98 | + 'state' => $state, |
|
| 99 | + 'description' => $description, |
|
| 100 | + 'due_on' => (new DateTime($dueOn))->format(DateTime::ATOM) |
|
| 101 | + ]); |
|
| 102 | + } |
|
| 103 | 103 | |
| 104 | - /** |
|
| 105 | - * Delete a milestone |
|
| 106 | - * |
|
| 107 | - * @link https://developer.github.com/v3/issues/milestones/#delete-a-milestone |
|
| 108 | - * |
|
| 109 | - * @param int $number |
|
| 110 | - * |
|
| 111 | - * @return bool |
|
| 112 | - */ |
|
| 113 | - public function deleteMilestone(int $number): bool |
|
| 114 | - { |
|
| 115 | - $this->getApi()->request($this->getApi()->sprintf('/repos/:owner/:repo/milestones/:number', |
|
| 116 | - $this->getIssues()->getOwner(), $this->getIssues()->getRepo(), $number), Request::METHOD_DELETE); |
|
| 104 | + /** |
|
| 105 | + * Delete a milestone |
|
| 106 | + * |
|
| 107 | + * @link https://developer.github.com/v3/issues/milestones/#delete-a-milestone |
|
| 108 | + * |
|
| 109 | + * @param int $number |
|
| 110 | + * |
|
| 111 | + * @return bool |
|
| 112 | + */ |
|
| 113 | + public function deleteMilestone(int $number): bool |
|
| 114 | + { |
|
| 115 | + $this->getApi()->request($this->getApi()->sprintf('/repos/:owner/:repo/milestones/:number', |
|
| 116 | + $this->getIssues()->getOwner(), $this->getIssues()->getRepo(), $number), Request::METHOD_DELETE); |
|
| 117 | 117 | |
| 118 | - if ($this->getApi()->getHeaders()['Status'] == '204 No Content') { |
|
| 119 | - return true; |
|
| 120 | - } |
|
| 118 | + if ($this->getApi()->getHeaders()['Status'] == '204 No Content') { |
|
| 119 | + return true; |
|
| 120 | + } |
|
| 121 | 121 | |
| 122 | - return false; |
|
| 123 | - } |
|
| 122 | + return false; |
|
| 123 | + } |
|
| 124 | 124 | } |
| 125 | 125 | \ No newline at end of file |
@@ -10,37 +10,37 @@ |
||
| 10 | 10 | class Assignees extends AbstractIssues |
| 11 | 11 | { |
| 12 | 12 | |
| 13 | - /** |
|
| 14 | - * List assignees |
|
| 15 | - * |
|
| 16 | - * @link https://developer.github.com/v3/issues/assignees/#list-assignees |
|
| 17 | - * @return array |
|
| 18 | - */ |
|
| 19 | - public function listAssignees(): array |
|
| 20 | - { |
|
| 21 | - return $this->getApi()->request($this->getApi() |
|
| 22 | - ->sprintf('/repos/:owner/:repo/assignees', $this->getIssues()->getOwner(), |
|
| 23 | - $this->getIssues()->getRepo())); |
|
| 24 | - } |
|
| 13 | + /** |
|
| 14 | + * List assignees |
|
| 15 | + * |
|
| 16 | + * @link https://developer.github.com/v3/issues/assignees/#list-assignees |
|
| 17 | + * @return array |
|
| 18 | + */ |
|
| 19 | + public function listAssignees(): array |
|
| 20 | + { |
|
| 21 | + return $this->getApi()->request($this->getApi() |
|
| 22 | + ->sprintf('/repos/:owner/:repo/assignees', $this->getIssues()->getOwner(), |
|
| 23 | + $this->getIssues()->getRepo())); |
|
| 24 | + } |
|
| 25 | 25 | |
| 26 | - /** |
|
| 27 | - * Check assignee |
|
| 28 | - * |
|
| 29 | - * @link https://developer.github.com/v3/issues/assignees/#check-assignee |
|
| 30 | - * |
|
| 31 | - * @param string $assignee |
|
| 32 | - * |
|
| 33 | - * @return bool |
|
| 34 | - */ |
|
| 35 | - public function checkAssignee(string $assignee): bool |
|
| 36 | - { |
|
| 37 | - $this->getApi()->request($this->getApi()->sprintf('/repos/:owner/:repo/assignees/:assignee', |
|
| 38 | - $this->getIssues()->getOwner(), $this->getIssues()->getRepo(), $assignee)); |
|
| 26 | + /** |
|
| 27 | + * Check assignee |
|
| 28 | + * |
|
| 29 | + * @link https://developer.github.com/v3/issues/assignees/#check-assignee |
|
| 30 | + * |
|
| 31 | + * @param string $assignee |
|
| 32 | + * |
|
| 33 | + * @return bool |
|
| 34 | + */ |
|
| 35 | + public function checkAssignee(string $assignee): bool |
|
| 36 | + { |
|
| 37 | + $this->getApi()->request($this->getApi()->sprintf('/repos/:owner/:repo/assignees/:assignee', |
|
| 38 | + $this->getIssues()->getOwner(), $this->getIssues()->getRepo(), $assignee)); |
|
| 39 | 39 | |
| 40 | - if ($this->getApi()->getHeaders()['Status'] == '204 No Content') { |
|
| 41 | - return true; |
|
| 42 | - } |
|
| 40 | + if ($this->getApi()->getHeaders()['Status'] == '204 No Content') { |
|
| 41 | + return true; |
|
| 42 | + } |
|
| 43 | 43 | |
| 44 | - return false; |
|
| 45 | - } |
|
| 44 | + return false; |
|
| 45 | + } |
|
| 46 | 46 | } |
| 47 | 47 | \ No newline at end of file |
@@ -10,14 +10,14 @@ |
||
| 10 | 10 | class License extends AbstractEnterprise |
| 11 | 11 | { |
| 12 | 12 | |
| 13 | - /** |
|
| 14 | - * Get license information |
|
| 15 | - * |
|
| 16 | - * @link https://developer.github.com/v3/enterprise/license/#get-license-information |
|
| 17 | - * @return array |
|
| 18 | - */ |
|
| 19 | - public function getLicenseInformation(): array |
|
| 20 | - { |
|
| 21 | - return $this->getApi()->request(sprintf('/enterprise/settings/license')); |
|
| 22 | - } |
|
| 13 | + /** |
|
| 14 | + * Get license information |
|
| 15 | + * |
|
| 16 | + * @link https://developer.github.com/v3/enterprise/license/#get-license-information |
|
| 17 | + * @return array |
|
| 18 | + */ |
|
| 19 | + public function getLicenseInformation(): array |
|
| 20 | + { |
|
| 21 | + return $this->getApi()->request(sprintf('/enterprise/settings/license')); |
|
| 22 | + } |
|
| 23 | 23 | } |
| 24 | 24 | \ No newline at end of file |
@@ -15,67 +15,67 @@ |
||
| 15 | 15 | class Ldap extends AbstractEnterprise |
| 16 | 16 | { |
| 17 | 17 | |
| 18 | - /** |
|
| 19 | - * Update LDAP mapping for a user |
|
| 20 | - * |
|
| 21 | - * @link https://developer.github.com/v3/enterprise/ldap/#update-ldap-mapping-for-a-user |
|
| 22 | - * |
|
| 23 | - * @param string $username |
|
| 24 | - * |
|
| 25 | - * @return array |
|
| 26 | - * @throws Exception |
|
| 27 | - */ |
|
| 28 | - public function updateMappingUser(string $username): array |
|
| 29 | - { |
|
| 30 | - return $this->getApi()->request($this->getApi()->sprintf('/admin/ldap/user/:username/mapping', $username), |
|
| 31 | - Request::METHOD_PATCH); |
|
| 32 | - } |
|
| 18 | + /** |
|
| 19 | + * Update LDAP mapping for a user |
|
| 20 | + * |
|
| 21 | + * @link https://developer.github.com/v3/enterprise/ldap/#update-ldap-mapping-for-a-user |
|
| 22 | + * |
|
| 23 | + * @param string $username |
|
| 24 | + * |
|
| 25 | + * @return array |
|
| 26 | + * @throws Exception |
|
| 27 | + */ |
|
| 28 | + public function updateMappingUser(string $username): array |
|
| 29 | + { |
|
| 30 | + return $this->getApi()->request($this->getApi()->sprintf('/admin/ldap/user/:username/mapping', $username), |
|
| 31 | + Request::METHOD_PATCH); |
|
| 32 | + } |
|
| 33 | 33 | |
| 34 | - /** |
|
| 35 | - * Sync LDAP mapping for a user |
|
| 36 | - * |
|
| 37 | - * @link https://developer.github.com/v3/enterprise/ldap/#sync-ldap-mapping-for-a-user |
|
| 38 | - * |
|
| 39 | - * @param int $userId |
|
| 40 | - * |
|
| 41 | - * @return array |
|
| 42 | - * @throws Exception |
|
| 43 | - */ |
|
| 44 | - public function syncMappingUser(int $userId): array |
|
| 45 | - { |
|
| 46 | - return $this->getApi()->request($this->getApi()->sprintf('/admin/ldap/user/:user_id/sync', (string)$userId), |
|
| 47 | - Request::METHOD_POST); |
|
| 48 | - } |
|
| 34 | + /** |
|
| 35 | + * Sync LDAP mapping for a user |
|
| 36 | + * |
|
| 37 | + * @link https://developer.github.com/v3/enterprise/ldap/#sync-ldap-mapping-for-a-user |
|
| 38 | + * |
|
| 39 | + * @param int $userId |
|
| 40 | + * |
|
| 41 | + * @return array |
|
| 42 | + * @throws Exception |
|
| 43 | + */ |
|
| 44 | + public function syncMappingUser(int $userId): array |
|
| 45 | + { |
|
| 46 | + return $this->getApi()->request($this->getApi()->sprintf('/admin/ldap/user/:user_id/sync', (string)$userId), |
|
| 47 | + Request::METHOD_POST); |
|
| 48 | + } |
|
| 49 | 49 | |
| 50 | - /** |
|
| 51 | - * Update LDAP mapping for a team |
|
| 52 | - * |
|
| 53 | - * @link https://developer.github.com/v3/enterprise/ldap/#update-ldap-mapping-for-a-team |
|
| 54 | - * |
|
| 55 | - * @param int $teamId |
|
| 56 | - * |
|
| 57 | - * @return array |
|
| 58 | - * @throws Exception |
|
| 59 | - */ |
|
| 60 | - public function updateMappingTeam(int $teamId): array |
|
| 61 | - { |
|
| 62 | - return $this->getApi()->request($this->getApi()->sprintf('/admin/ldap/teams/:team_id/mapping', (string)$teamId), |
|
| 63 | - Request::METHOD_PATCH); |
|
| 64 | - } |
|
| 50 | + /** |
|
| 51 | + * Update LDAP mapping for a team |
|
| 52 | + * |
|
| 53 | + * @link https://developer.github.com/v3/enterprise/ldap/#update-ldap-mapping-for-a-team |
|
| 54 | + * |
|
| 55 | + * @param int $teamId |
|
| 56 | + * |
|
| 57 | + * @return array |
|
| 58 | + * @throws Exception |
|
| 59 | + */ |
|
| 60 | + public function updateMappingTeam(int $teamId): array |
|
| 61 | + { |
|
| 62 | + return $this->getApi()->request($this->getApi()->sprintf('/admin/ldap/teams/:team_id/mapping', (string)$teamId), |
|
| 63 | + Request::METHOD_PATCH); |
|
| 64 | + } |
|
| 65 | 65 | |
| 66 | - /** |
|
| 67 | - * Sync LDAP mapping for a team |
|
| 68 | - * |
|
| 69 | - * @link https://developer.github.com/v3/enterprise/ldap/#sync-ldap-mapping-for-a-team |
|
| 70 | - * |
|
| 71 | - * @param int $teamId |
|
| 72 | - * |
|
| 73 | - * @return array |
|
| 74 | - * @throws Exception |
|
| 75 | - */ |
|
| 76 | - public function syncMappingTeam(int $teamId): array |
|
| 77 | - { |
|
| 78 | - return $this->getApi()->request($this->getApi()->sprintf('/admin/ldap/teams/:team_id/sync', (string)$teamId), |
|
| 79 | - Request::METHOD_POST); |
|
| 80 | - } |
|
| 66 | + /** |
|
| 67 | + * Sync LDAP mapping for a team |
|
| 68 | + * |
|
| 69 | + * @link https://developer.github.com/v3/enterprise/ldap/#sync-ldap-mapping-for-a-team |
|
| 70 | + * |
|
| 71 | + * @param int $teamId |
|
| 72 | + * |
|
| 73 | + * @return array |
|
| 74 | + * @throws Exception |
|
| 75 | + */ |
|
| 76 | + public function syncMappingTeam(int $teamId): array |
|
| 77 | + { |
|
| 78 | + return $this->getApi()->request($this->getApi()->sprintf('/admin/ldap/teams/:team_id/sync', (string)$teamId), |
|
| 79 | + Request::METHOD_POST); |
|
| 80 | + } |
|
| 81 | 81 | } |
| 82 | 82 | \ No newline at end of file |
@@ -12,206 +12,206 @@ |
||
| 12 | 12 | class ManagementConsole extends AbstractEnterprise |
| 13 | 13 | { |
| 14 | 14 | |
| 15 | - /** Properties */ |
|
| 16 | - protected $hostname = ''; |
|
| 17 | - protected $password = ''; |
|
| 18 | - |
|
| 19 | - /** |
|
| 20 | - * Get password |
|
| 21 | - * |
|
| 22 | - * @return string |
|
| 23 | - */ |
|
| 24 | - public function getPassword(): string |
|
| 25 | - { |
|
| 26 | - return $this->password; |
|
| 27 | - } |
|
| 28 | - |
|
| 29 | - /** |
|
| 30 | - * Set password |
|
| 31 | - * |
|
| 32 | - * @param string $password |
|
| 33 | - * |
|
| 34 | - * @return ManagementConsole |
|
| 35 | - */ |
|
| 36 | - public function setPassword(string $password): ManagementConsole |
|
| 37 | - { |
|
| 38 | - $this->password = $password; |
|
| 39 | - |
|
| 40 | - return $this; |
|
| 41 | - } |
|
| 42 | - |
|
| 43 | - /** |
|
| 44 | - * Get hostname |
|
| 45 | - * |
|
| 46 | - * @return string |
|
| 47 | - */ |
|
| 48 | - public function getHostname(): string |
|
| 49 | - { |
|
| 50 | - return $this->hostname; |
|
| 51 | - } |
|
| 52 | - |
|
| 53 | - /** |
|
| 54 | - * Set hostname |
|
| 55 | - * |
|
| 56 | - * @param string $hostname |
|
| 57 | - * |
|
| 58 | - * @return ManagementConsole |
|
| 59 | - */ |
|
| 60 | - public function setHostname(string $hostname): ManagementConsole |
|
| 61 | - { |
|
| 62 | - $this->hostname = $hostname; |
|
| 63 | - |
|
| 64 | - return $this; |
|
| 65 | - } |
|
| 66 | - |
|
| 67 | - /** |
|
| 68 | - * Upload a license and software package for the first time |
|
| 69 | - * |
|
| 70 | - * @link https://developer.github.com/v3/enterprise/management_console/#upload-a-license-and-software-package-for-the-first-time |
|
| 71 | - * |
|
| 72 | - * @param string $license |
|
| 73 | - * @param string $package |
|
| 74 | - * @param string $settings |
|
| 75 | - * |
|
| 76 | - * @return array |
|
| 77 | - */ |
|
| 78 | - public function upload(string $license, string $package, string $settings = ''): array |
|
| 79 | - { |
|
| 80 | - $this->getApi()->setApiUrl(sprintf('http://license:%s@%s', md5($license), $this->getHostname())); |
|
| 81 | - |
|
| 82 | - return $this->getApi()->request(sprintf('/setup/api/start -F package=@%s -F license=@%s -F settings=<%s', |
|
| 83 | - $package, $license, $settings), Request::METHOD_POST); |
|
| 84 | - } |
|
| 85 | - |
|
| 86 | - /** |
|
| 87 | - * Upgrade a license or software package |
|
| 88 | - * |
|
| 89 | - * @link https://developer.github.com/v3/enterprise/management_console/#upgrade-a-license-or-software-package |
|
| 90 | - * |
|
| 91 | - * @param string $license |
|
| 92 | - * @param string $package |
|
| 93 | - * |
|
| 94 | - * @return array |
|
| 95 | - */ |
|
| 96 | - public function upgrade(string $license = '', string $package = ''): array |
|
| 97 | - { |
|
| 98 | - $this->getApi()->setApiUrl(sprintf('http://license:%s@%s', md5($license), $this->getHostname())); |
|
| 99 | - |
|
| 100 | - return $this->getApi()->request(sprintf('/setup/api/upgrade -F package=@%s -F license=@%s', $package, $license), |
|
| 101 | - Request::METHOD_POST); |
|
| 102 | - } |
|
| 103 | - |
|
| 104 | - /** |
|
| 105 | - * Check configuration status |
|
| 106 | - * |
|
| 107 | - * @link https://developer.github.com/v3/enterprise/management_console/#check-configuration-status |
|
| 108 | - * @return array |
|
| 109 | - */ |
|
| 110 | - public function checkConfigurationStatus(): array |
|
| 111 | - { |
|
| 112 | - return $this->getApi()->request(sprintf('/setup/api/configcheck')); |
|
| 113 | - } |
|
| 114 | - |
|
| 115 | - /** |
|
| 116 | - * Start a configuration process |
|
| 117 | - * |
|
| 118 | - * @link https://developer.github.com/v3/enterprise/management_console/#start-a-configuration-process |
|
| 119 | - * @return array |
|
| 120 | - */ |
|
| 121 | - public function startConfigurationProcess(): array |
|
| 122 | - { |
|
| 123 | - return $this->getApi()->request(sprintf('/setup/api/configure'), Request::METHOD_POST); |
|
| 124 | - } |
|
| 125 | - |
|
| 126 | - /** |
|
| 127 | - * Retrieve settings |
|
| 128 | - * |
|
| 129 | - * @link https://developer.github.com/v3/enterprise/management_console/#retrieve-settings |
|
| 130 | - * @return array |
|
| 131 | - */ |
|
| 132 | - public function retrieveSettings(): array |
|
| 133 | - { |
|
| 134 | - return $this->getApi()->request(sprintf('/setup/api/settings')); |
|
| 135 | - } |
|
| 136 | - |
|
| 137 | - /** |
|
| 138 | - * Modify settings |
|
| 139 | - * |
|
| 140 | - * @link https://developer.github.com/v3/enterprise/management_console/#modify-settings |
|
| 141 | - * |
|
| 142 | - * @param $settings |
|
| 143 | - * |
|
| 144 | - * @return array |
|
| 145 | - */ |
|
| 146 | - public function modifySettings($settings): array |
|
| 147 | - { |
|
| 148 | - return $this->getApi()->request(sprintf('/setup/api/settings settings=%s', $settings), Request::METHOD_PUT); |
|
| 149 | - } |
|
| 150 | - |
|
| 151 | - /** |
|
| 152 | - * Check maintenance status |
|
| 153 | - * |
|
| 154 | - * @link https://developer.github.com/v3/enterprise/management_console/#check-maintenance-status |
|
| 155 | - * @return array |
|
| 156 | - */ |
|
| 157 | - public function checkMaintenanceStatus(): array |
|
| 158 | - { |
|
| 159 | - return $this->getApi()->request(sprintf('/setup/api/maintenance')); |
|
| 160 | - } |
|
| 161 | - |
|
| 162 | - /** |
|
| 163 | - * Enable or disable maintenance mode |
|
| 164 | - * |
|
| 165 | - * @link https://developer.github.com/v3/enterprise/management_console/#enable-or-disable-maintenance-mode |
|
| 166 | - * |
|
| 167 | - * @param string $maintenance |
|
| 168 | - * |
|
| 169 | - * @return array |
|
| 170 | - */ |
|
| 171 | - public function updateMaintenanceStatus(string $maintenance): array |
|
| 172 | - { |
|
| 173 | - return $this->getApi()->request(sprintf('/setup/api/maintenance -d maintenance=%s', $maintenance), |
|
| 174 | - Request::METHOD_POST); |
|
| 175 | - } |
|
| 176 | - |
|
| 177 | - /** |
|
| 178 | - * Retrieve authorized SSH keys |
|
| 179 | - * |
|
| 180 | - * @link https://developer.github.com/v3/enterprise/management_console/#retrieve-authorized-ssh-keys |
|
| 181 | - * @return array |
|
| 182 | - */ |
|
| 183 | - public function retrieveAuthorizedSshKeys(): array |
|
| 184 | - { |
|
| 185 | - return $this->getApi()->request(sprintf('/setup/api/settings/authorized-keys')); |
|
| 186 | - } |
|
| 187 | - |
|
| 188 | - /** |
|
| 189 | - * Add a new authorized SSH key |
|
| 190 | - * |
|
| 191 | - * @link https://developer.github.com/v3/enterprise/management_console/#add-a-new-authorized-ssh-key |
|
| 192 | - * |
|
| 193 | - * @param string $authorizedKey |
|
| 194 | - * |
|
| 195 | - * @return array |
|
| 196 | - */ |
|
| 197 | - public function addNewAuthorizedSshKeys(string $authorizedKey): array |
|
| 198 | - { |
|
| 199 | - return $this->getApi()->request(sprintf('/setup/api/settings/authorized-keys -F authorized_key=@%s', |
|
| 200 | - $authorizedKey), Request::METHOD_POST); |
|
| 201 | - } |
|
| 202 | - |
|
| 203 | - /** |
|
| 204 | - * Remove an authorized SSH key |
|
| 205 | - * |
|
| 206 | - * @link https://developer.github.com/v3/enterprise/management_console/#remove-an-authorized-ssh-key |
|
| 207 | - * |
|
| 208 | - * @param string $authorizedKey |
|
| 209 | - * |
|
| 210 | - * @return array |
|
| 211 | - */ |
|
| 212 | - public function removeAuthorizedSshKeys(string $authorizedKey): array |
|
| 213 | - { |
|
| 214 | - return $this->getApi()->request(sprintf('/setup/api/settings/authorized-keys -F authorized_key=@%s', |
|
| 215 | - $authorizedKey), Request::METHOD_DELETE); |
|
| 216 | - } |
|
| 15 | + /** Properties */ |
|
| 16 | + protected $hostname = ''; |
|
| 17 | + protected $password = ''; |
|
| 18 | + |
|
| 19 | + /** |
|
| 20 | + * Get password |
|
| 21 | + * |
|
| 22 | + * @return string |
|
| 23 | + */ |
|
| 24 | + public function getPassword(): string |
|
| 25 | + { |
|
| 26 | + return $this->password; |
|
| 27 | + } |
|
| 28 | + |
|
| 29 | + /** |
|
| 30 | + * Set password |
|
| 31 | + * |
|
| 32 | + * @param string $password |
|
| 33 | + * |
|
| 34 | + * @return ManagementConsole |
|
| 35 | + */ |
|
| 36 | + public function setPassword(string $password): ManagementConsole |
|
| 37 | + { |
|
| 38 | + $this->password = $password; |
|
| 39 | + |
|
| 40 | + return $this; |
|
| 41 | + } |
|
| 42 | + |
|
| 43 | + /** |
|
| 44 | + * Get hostname |
|
| 45 | + * |
|
| 46 | + * @return string |
|
| 47 | + */ |
|
| 48 | + public function getHostname(): string |
|
| 49 | + { |
|
| 50 | + return $this->hostname; |
|
| 51 | + } |
|
| 52 | + |
|
| 53 | + /** |
|
| 54 | + * Set hostname |
|
| 55 | + * |
|
| 56 | + * @param string $hostname |
|
| 57 | + * |
|
| 58 | + * @return ManagementConsole |
|
| 59 | + */ |
|
| 60 | + public function setHostname(string $hostname): ManagementConsole |
|
| 61 | + { |
|
| 62 | + $this->hostname = $hostname; |
|
| 63 | + |
|
| 64 | + return $this; |
|
| 65 | + } |
|
| 66 | + |
|
| 67 | + /** |
|
| 68 | + * Upload a license and software package for the first time |
|
| 69 | + * |
|
| 70 | + * @link https://developer.github.com/v3/enterprise/management_console/#upload-a-license-and-software-package-for-the-first-time |
|
| 71 | + * |
|
| 72 | + * @param string $license |
|
| 73 | + * @param string $package |
|
| 74 | + * @param string $settings |
|
| 75 | + * |
|
| 76 | + * @return array |
|
| 77 | + */ |
|
| 78 | + public function upload(string $license, string $package, string $settings = ''): array |
|
| 79 | + { |
|
| 80 | + $this->getApi()->setApiUrl(sprintf('http://license:%s@%s', md5($license), $this->getHostname())); |
|
| 81 | + |
|
| 82 | + return $this->getApi()->request(sprintf('/setup/api/start -F package=@%s -F license=@%s -F settings=<%s', |
|
| 83 | + $package, $license, $settings), Request::METHOD_POST); |
|
| 84 | + } |
|
| 85 | + |
|
| 86 | + /** |
|
| 87 | + * Upgrade a license or software package |
|
| 88 | + * |
|
| 89 | + * @link https://developer.github.com/v3/enterprise/management_console/#upgrade-a-license-or-software-package |
|
| 90 | + * |
|
| 91 | + * @param string $license |
|
| 92 | + * @param string $package |
|
| 93 | + * |
|
| 94 | + * @return array |
|
| 95 | + */ |
|
| 96 | + public function upgrade(string $license = '', string $package = ''): array |
|
| 97 | + { |
|
| 98 | + $this->getApi()->setApiUrl(sprintf('http://license:%s@%s', md5($license), $this->getHostname())); |
|
| 99 | + |
|
| 100 | + return $this->getApi()->request(sprintf('/setup/api/upgrade -F package=@%s -F license=@%s', $package, $license), |
|
| 101 | + Request::METHOD_POST); |
|
| 102 | + } |
|
| 103 | + |
|
| 104 | + /** |
|
| 105 | + * Check configuration status |
|
| 106 | + * |
|
| 107 | + * @link https://developer.github.com/v3/enterprise/management_console/#check-configuration-status |
|
| 108 | + * @return array |
|
| 109 | + */ |
|
| 110 | + public function checkConfigurationStatus(): array |
|
| 111 | + { |
|
| 112 | + return $this->getApi()->request(sprintf('/setup/api/configcheck')); |
|
| 113 | + } |
|
| 114 | + |
|
| 115 | + /** |
|
| 116 | + * Start a configuration process |
|
| 117 | + * |
|
| 118 | + * @link https://developer.github.com/v3/enterprise/management_console/#start-a-configuration-process |
|
| 119 | + * @return array |
|
| 120 | + */ |
|
| 121 | + public function startConfigurationProcess(): array |
|
| 122 | + { |
|
| 123 | + return $this->getApi()->request(sprintf('/setup/api/configure'), Request::METHOD_POST); |
|
| 124 | + } |
|
| 125 | + |
|
| 126 | + /** |
|
| 127 | + * Retrieve settings |
|
| 128 | + * |
|
| 129 | + * @link https://developer.github.com/v3/enterprise/management_console/#retrieve-settings |
|
| 130 | + * @return array |
|
| 131 | + */ |
|
| 132 | + public function retrieveSettings(): array |
|
| 133 | + { |
|
| 134 | + return $this->getApi()->request(sprintf('/setup/api/settings')); |
|
| 135 | + } |
|
| 136 | + |
|
| 137 | + /** |
|
| 138 | + * Modify settings |
|
| 139 | + * |
|
| 140 | + * @link https://developer.github.com/v3/enterprise/management_console/#modify-settings |
|
| 141 | + * |
|
| 142 | + * @param $settings |
|
| 143 | + * |
|
| 144 | + * @return array |
|
| 145 | + */ |
|
| 146 | + public function modifySettings($settings): array |
|
| 147 | + { |
|
| 148 | + return $this->getApi()->request(sprintf('/setup/api/settings settings=%s', $settings), Request::METHOD_PUT); |
|
| 149 | + } |
|
| 150 | + |
|
| 151 | + /** |
|
| 152 | + * Check maintenance status |
|
| 153 | + * |
|
| 154 | + * @link https://developer.github.com/v3/enterprise/management_console/#check-maintenance-status |
|
| 155 | + * @return array |
|
| 156 | + */ |
|
| 157 | + public function checkMaintenanceStatus(): array |
|
| 158 | + { |
|
| 159 | + return $this->getApi()->request(sprintf('/setup/api/maintenance')); |
|
| 160 | + } |
|
| 161 | + |
|
| 162 | + /** |
|
| 163 | + * Enable or disable maintenance mode |
|
| 164 | + * |
|
| 165 | + * @link https://developer.github.com/v3/enterprise/management_console/#enable-or-disable-maintenance-mode |
|
| 166 | + * |
|
| 167 | + * @param string $maintenance |
|
| 168 | + * |
|
| 169 | + * @return array |
|
| 170 | + */ |
|
| 171 | + public function updateMaintenanceStatus(string $maintenance): array |
|
| 172 | + { |
|
| 173 | + return $this->getApi()->request(sprintf('/setup/api/maintenance -d maintenance=%s', $maintenance), |
|
| 174 | + Request::METHOD_POST); |
|
| 175 | + } |
|
| 176 | + |
|
| 177 | + /** |
|
| 178 | + * Retrieve authorized SSH keys |
|
| 179 | + * |
|
| 180 | + * @link https://developer.github.com/v3/enterprise/management_console/#retrieve-authorized-ssh-keys |
|
| 181 | + * @return array |
|
| 182 | + */ |
|
| 183 | + public function retrieveAuthorizedSshKeys(): array |
|
| 184 | + { |
|
| 185 | + return $this->getApi()->request(sprintf('/setup/api/settings/authorized-keys')); |
|
| 186 | + } |
|
| 187 | + |
|
| 188 | + /** |
|
| 189 | + * Add a new authorized SSH key |
|
| 190 | + * |
|
| 191 | + * @link https://developer.github.com/v3/enterprise/management_console/#add-a-new-authorized-ssh-key |
|
| 192 | + * |
|
| 193 | + * @param string $authorizedKey |
|
| 194 | + * |
|
| 195 | + * @return array |
|
| 196 | + */ |
|
| 197 | + public function addNewAuthorizedSshKeys(string $authorizedKey): array |
|
| 198 | + { |
|
| 199 | + return $this->getApi()->request(sprintf('/setup/api/settings/authorized-keys -F authorized_key=@%s', |
|
| 200 | + $authorizedKey), Request::METHOD_POST); |
|
| 201 | + } |
|
| 202 | + |
|
| 203 | + /** |
|
| 204 | + * Remove an authorized SSH key |
|
| 205 | + * |
|
| 206 | + * @link https://developer.github.com/v3/enterprise/management_console/#remove-an-authorized-ssh-key |
|
| 207 | + * |
|
| 208 | + * @param string $authorizedKey |
|
| 209 | + * |
|
| 210 | + * @return array |
|
| 211 | + */ |
|
| 212 | + public function removeAuthorizedSshKeys(string $authorizedKey): array |
|
| 213 | + { |
|
| 214 | + return $this->getApi()->request(sprintf('/setup/api/settings/authorized-keys -F authorized_key=@%s', |
|
| 215 | + $authorizedKey), Request::METHOD_DELETE); |
|
| 216 | + } |
|
| 217 | 217 | } |
| 218 | 218 | \ No newline at end of file |
@@ -12,19 +12,19 @@ |
||
| 12 | 12 | class SearchIndexing extends AbstractEnterprise |
| 13 | 13 | { |
| 14 | 14 | |
| 15 | - /** |
|
| 16 | - * Queue an indexing job |
|
| 17 | - * |
|
| 18 | - * @link https://developer.github.com/v3/enterprise/search_indexing/#queue-an-indexing-job |
|
| 19 | - * |
|
| 20 | - * @param string $target |
|
| 21 | - * |
|
| 22 | - * @return array |
|
| 23 | - */ |
|
| 24 | - public function queueIndexingJob(string $target): array |
|
| 25 | - { |
|
| 26 | - return $this->getApi()->request(sprintf('/staff/indexing_jobs'), Request::METHOD_POST, [ |
|
| 27 | - 'target' => $target |
|
| 28 | - ]); |
|
| 29 | - } |
|
| 15 | + /** |
|
| 16 | + * Queue an indexing job |
|
| 17 | + * |
|
| 18 | + * @link https://developer.github.com/v3/enterprise/search_indexing/#queue-an-indexing-job |
|
| 19 | + * |
|
| 20 | + * @param string $target |
|
| 21 | + * |
|
| 22 | + * @return array |
|
| 23 | + */ |
|
| 24 | + public function queueIndexingJob(string $target): array |
|
| 25 | + { |
|
| 26 | + return $this->getApi()->request(sprintf('/staff/indexing_jobs'), Request::METHOD_POST, [ |
|
| 27 | + 'target' => $target |
|
| 28 | + ]); |
|
| 29 | + } |
|
| 30 | 30 | } |
| 31 | 31 | \ No newline at end of file |
@@ -10,17 +10,17 @@ |
||
| 10 | 10 | class AdminStats extends AbstractEnterprise |
| 11 | 11 | { |
| 12 | 12 | |
| 13 | - /** |
|
| 14 | - * Get statistics |
|
| 15 | - * |
|
| 16 | - * @link https://developer.github.com/v3/enterprise/admin_stats/#get-statistics |
|
| 17 | - * |
|
| 18 | - * @param string $type |
|
| 19 | - * |
|
| 20 | - * @return array |
|
| 21 | - */ |
|
| 22 | - public function getStatistics(string $type): array |
|
| 23 | - { |
|
| 24 | - return $this->getApi()->request($this->getApi()->sprintf('/enterprise/stats/:type', $type)); |
|
| 25 | - } |
|
| 13 | + /** |
|
| 14 | + * Get statistics |
|
| 15 | + * |
|
| 16 | + * @link https://developer.github.com/v3/enterprise/admin_stats/#get-statistics |
|
| 17 | + * |
|
| 18 | + * @param string $type |
|
| 19 | + * |
|
| 20 | + * @return array |
|
| 21 | + */ |
|
| 22 | + public function getStatistics(string $type): array |
|
| 23 | + { |
|
| 24 | + return $this->getApi()->request($this->getApi()->sprintf('/enterprise/stats/:type', $type)); |
|
| 25 | + } |
|
| 26 | 26 | } |
| 27 | 27 | \ No newline at end of file |
@@ -12,66 +12,66 @@ |
||
| 12 | 12 | abstract class AbstractEnterprise |
| 13 | 13 | { |
| 14 | 14 | |
| 15 | - /** Properties */ |
|
| 16 | - protected $enterprise; |
|
| 17 | - protected $api; |
|
| 15 | + /** Properties */ |
|
| 16 | + protected $enterprise; |
|
| 17 | + protected $api; |
|
| 18 | 18 | |
| 19 | - /** |
|
| 20 | - * Constructor |
|
| 21 | - * |
|
| 22 | - * @param Enterprise $enterprise |
|
| 23 | - */ |
|
| 24 | - public function __construct(Enterprise $enterprise) |
|
| 25 | - { |
|
| 26 | - $this->setEnterprise($enterprise); |
|
| 27 | - $this->setApi($enterprise->getApi()); |
|
| 28 | - } |
|
| 19 | + /** |
|
| 20 | + * Constructor |
|
| 21 | + * |
|
| 22 | + * @param Enterprise $enterprise |
|
| 23 | + */ |
|
| 24 | + public function __construct(Enterprise $enterprise) |
|
| 25 | + { |
|
| 26 | + $this->setEnterprise($enterprise); |
|
| 27 | + $this->setApi($enterprise->getApi()); |
|
| 28 | + } |
|
| 29 | 29 | |
| 30 | - /** |
|
| 31 | - * Get enterprise |
|
| 32 | - * |
|
| 33 | - * @return Enterprise |
|
| 34 | - */ |
|
| 35 | - public function getEnterprise(): Enterprise |
|
| 36 | - { |
|
| 37 | - return $this->enterprise; |
|
| 38 | - } |
|
| 30 | + /** |
|
| 31 | + * Get enterprise |
|
| 32 | + * |
|
| 33 | + * @return Enterprise |
|
| 34 | + */ |
|
| 35 | + public function getEnterprise(): Enterprise |
|
| 36 | + { |
|
| 37 | + return $this->enterprise; |
|
| 38 | + } |
|
| 39 | 39 | |
| 40 | - /** |
|
| 41 | - * Set enterprise |
|
| 42 | - * |
|
| 43 | - * @param Enterprise $enterprise |
|
| 44 | - * |
|
| 45 | - * @return AbstractEnterprise |
|
| 46 | - */ |
|
| 47 | - public function setEnterprise(Enterprise $enterprise): AbstractEnterprise |
|
| 48 | - { |
|
| 49 | - $this->enterprise = $enterprise; |
|
| 40 | + /** |
|
| 41 | + * Set enterprise |
|
| 42 | + * |
|
| 43 | + * @param Enterprise $enterprise |
|
| 44 | + * |
|
| 45 | + * @return AbstractEnterprise |
|
| 46 | + */ |
|
| 47 | + public function setEnterprise(Enterprise $enterprise): AbstractEnterprise |
|
| 48 | + { |
|
| 49 | + $this->enterprise = $enterprise; |
|
| 50 | 50 | |
| 51 | - return $this; |
|
| 52 | - } |
|
| 51 | + return $this; |
|
| 52 | + } |
|
| 53 | 53 | |
| 54 | - /** |
|
| 55 | - * Get api |
|
| 56 | - * |
|
| 57 | - * @return AbstractApi |
|
| 58 | - */ |
|
| 59 | - public function getApi(): AbstractApi |
|
| 60 | - { |
|
| 61 | - return $this->api; |
|
| 62 | - } |
|
| 54 | + /** |
|
| 55 | + * Get api |
|
| 56 | + * |
|
| 57 | + * @return AbstractApi |
|
| 58 | + */ |
|
| 59 | + public function getApi(): AbstractApi |
|
| 60 | + { |
|
| 61 | + return $this->api; |
|
| 62 | + } |
|
| 63 | 63 | |
| 64 | - /** |
|
| 65 | - * Set api |
|
| 66 | - * |
|
| 67 | - * @param AbstractApi $api |
|
| 68 | - * |
|
| 69 | - * @return AbstractEnterprise |
|
| 70 | - */ |
|
| 71 | - public function setApi(AbstractApi $api): AbstractEnterprise |
|
| 72 | - { |
|
| 73 | - $this->api = $api; |
|
| 64 | + /** |
|
| 65 | + * Set api |
|
| 66 | + * |
|
| 67 | + * @param AbstractApi $api |
|
| 68 | + * |
|
| 69 | + * @return AbstractEnterprise |
|
| 70 | + */ |
|
| 71 | + public function setApi(AbstractApi $api): AbstractEnterprise |
|
| 72 | + { |
|
| 73 | + $this->api = $api; |
|
| 74 | 74 | |
| 75 | - return $this; |
|
| 76 | - } |
|
| 75 | + return $this; |
|
| 76 | + } |
|
| 77 | 77 | } |
| 78 | 78 | \ No newline at end of file |