-
-
Notifications
You must be signed in to change notification settings - Fork 596
Releases and assets #79
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
Merged
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
0005d74
Add Class for releases.
matthewsimo 08e7c7c
Docs & a comment
matthewsimo 9e40d8b
Merge remote-tracking branch '1/releases-class' into feature/gh-api-r…
5bae94f
Add tests, add more release apis, add assets api, update docs
111ac77
Add manifold preview media type
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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,30 @@ | ||
| ## Repo / Releases API | ||
| [Back to the "Repos API"](../repos.md) | [Back to the navigation](../index.md) | ||
|
|
||
| ### List all assets by release | ||
|
|
||
| ```php | ||
| $assets = $client->api('repo')->releases()->assets()->all('twbs', 'bootstrap', $releaseId); | ||
| ``` | ||
|
|
||
| ### List one asset | ||
|
|
||
| ```php | ||
| $asset = $client->api('repo')->releases()->assets()->show('twbs', 'bootstrap', $assetId); | ||
| ``` | ||
|
|
||
| ### Create an asset | ||
|
|
||
| This feature is not implemented because require usage of `uploads.github.com` subdomain. | ||
|
|
||
| ### Edit an asset | ||
|
|
||
| ```php | ||
| $asset = $client->api('repo')->releases()->assets()->edit('twbs', 'bootstrap', $assetId, array('name' => 'New name')); | ||
| ``` | ||
|
|
||
| ### Remove an asset | ||
|
|
||
| ```php | ||
| $asset = $client->api('repo')->releases()->assets()->remove('twbs', 'bootstrap', $assetId); | ||
| ``` |
This file contains hidden or 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,35 @@ | ||
| ## Repo / Releases API | ||
| [Back to the "Repos API"](../repos.md) | [Back to the navigation](../index.md) | ||
|
|
||
| This Github API Endpoint is currently undocumented because it's new, but works just fine. | ||
|
|
||
|
|
||
| ### List all releases | ||
|
|
||
| ```php | ||
| $releases = $client->api('repo')->releases()->all('twbs', 'bootstrap'); | ||
| ``` | ||
|
|
||
| ### List one release | ||
|
|
||
| ```php | ||
| $release = $client->api('repo')->releases()->show('twbs', 'bootstrap', $id); | ||
| ``` | ||
|
|
||
| ### Create a release | ||
| ```php | ||
| $release = $client->api('repo')->releases()->create('twbs', 'bootstrap', array('tag_name' => 'v1.1')); | ||
| ``` | ||
|
|
||
| ### Edit a release | ||
| ```php | ||
| $release = $client->api('repo')->releases()->edit('twbs', 'bootstrap', $id, array('name' => 'New release name')); | ||
| ``` | ||
|
|
||
| ### Remove a release | ||
|
|
||
| This works, but isn't thoroughly tested, use at your own risk. | ||
|
|
||
| ```php | ||
| $response = $client->api('repo')->releases()->remove('twbs', 'bootstrap', $id); | ||
| ``` |
This file contains hidden or 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 hidden or 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,90 @@ | ||
| <?php | ||
|
|
||
| namespace Github\Api\Repository; | ||
|
|
||
| use Github\Api\AbstractApi; | ||
| use Github\Exception\MissingArgumentException; | ||
|
|
||
| /** | ||
| * @link http://developer.github.com/v3/repos/releases/ | ||
| * @author Evgeniy Guseletov <[email protected]> | ||
| */ | ||
| class Assets extends AbstractApi | ||
| { | ||
| /** | ||
| * @deprecated Will be removed as soon as gh releases api gets stable | ||
| */ | ||
| public function configure() | ||
| { | ||
| $this->client->setHeaders(array( | ||
| 'Accept: application/vnd.github.manifold-preview' | ||
| )); | ||
| } | ||
|
|
||
| /** | ||
| * Get all release's assets in selected repository | ||
| * GET /repos/:owner/:repo/releases/:id/assets | ||
| * | ||
| * @param string $username the user who owns the repo | ||
| * @param string $repository the name of the repo | ||
| * @param integer $id the id of the release | ||
| * | ||
| * @return array | ||
| */ | ||
| public function all($username, $repository, $id) | ||
| { | ||
| return $this->get('repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/releases/'.rawurlencode($id).'/assets'); | ||
| } | ||
|
|
||
| /** | ||
| * Get an asset in selected repository's release | ||
| * GET /repos/:owner/:repo/releases/assets/:id | ||
| * | ||
| * @param string $username the user who owns the repo | ||
| * @param string $repository the name of the repo | ||
| * @param integer $id the id of the asset | ||
| * | ||
| * @return array | ||
| */ | ||
| public function show($username, $repository, $id) | ||
| { | ||
| return $this->get('repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/releases/assets/'.rawurlencode($id)); | ||
| } | ||
|
|
||
| /** | ||
| * Edit an asset in selected repository's release | ||
| * PATCH /repos/:owner/:repo/releases/assets/:id | ||
| * | ||
| * @param string $username the user who owns the repo | ||
| * @param string $repository the name of the repo | ||
| * @param integer $id the id of the asset | ||
| * @param array $params request parameters | ||
| * | ||
| * @throws MissingArgumentException | ||
| * | ||
| * @return array | ||
| */ | ||
| public function edit($username, $repository, $id, array $params) | ||
| { | ||
| if (!isset($params['name'])) { | ||
| throw new MissingArgumentException('name'); | ||
| } | ||
|
|
||
| return $this->patch('repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/releases/assets/'.rawurlencode($id), $params); | ||
| } | ||
|
|
||
| /** | ||
| * Delete an asset in selected repository's release | ||
| * DELETE /repos/:owner/:repo/releases/assets/:id | ||
| * | ||
| * @param string $username the user who owns the repo | ||
| * @param string $repository the name of the repo | ||
| * @param integer $id the id of the asset | ||
| * | ||
| * @return array | ||
| */ | ||
| public function remove($username, $repository, $id) | ||
| { | ||
| return $this->delete('repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/releases/assets/'.rawurlencode($id)); | ||
| } | ||
| } | ||
This file contains hidden or 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,108 @@ | ||
| <?php | ||
|
|
||
| namespace Github\Api\Repository; | ||
|
|
||
| use Github\Api\AbstractApi; | ||
| use Github\Exception\MissingArgumentException; | ||
|
|
||
| /** | ||
| * @link http://developer.github.com/v3/repos/releases/ | ||
| * @author Matthew Simo <[email protected]> | ||
| * @author Evgeniy Guseletov <[email protected]> | ||
| */ | ||
| class Releases extends AbstractApi | ||
|
Contributor
Author
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. add |
||
| { | ||
| /** | ||
| * @deprecated Will be removed as soon as gh releases api gets stable | ||
| */ | ||
| public function configure() | ||
| { | ||
| $this->client->setHeaders(array( | ||
| 'Accept: application/vnd.github.manifold-preview' | ||
| )); | ||
| } | ||
|
|
||
| /** | ||
| * List releases in selected repository | ||
| * | ||
| * @param string $username the user who owns the repo | ||
| * @param string $repository the name of the repo | ||
| * | ||
| * @return array | ||
| */ | ||
| public function all($username, $repository) | ||
| { | ||
| return $this->get('repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/releases'); | ||
| } | ||
|
|
||
| /** | ||
| * Get a release in selected repository | ||
| * | ||
| * @param string $username the user who owns the repo | ||
| * @param string $repository the name of the repo | ||
| * @param integer $id the id of the release | ||
| * | ||
| * @return array | ||
| */ | ||
| public function show($username, $repository, $id) | ||
| { | ||
| return $this->get('repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/releases/'.rawurlencode($id)); | ||
| } | ||
|
|
||
| /** | ||
| * Create new release in selected repository | ||
| * | ||
| * @param string $username | ||
| * @param string $repository | ||
| * @param array $params | ||
| * | ||
| * @throws MissingArgumentException | ||
| * | ||
| * @return array | ||
| */ | ||
| public function create($username, $repository, array $params) | ||
| { | ||
| if (!isset($params['tag_name'])) { | ||
| throw new MissingArgumentException('tag_name'); | ||
| } | ||
|
|
||
| return $this->post('repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/releases', $params); | ||
| } | ||
|
|
||
| /** | ||
| * Edit release in selected repository | ||
| * | ||
| * @param string $username | ||
| * @param string $repository | ||
| * @param integer $id | ||
| * @param array $params | ||
| * | ||
| * @return array | ||
| */ | ||
| public function edit($username, $repository, $id, array $params) | ||
| { | ||
| return $this->patch('repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/releases/'.rawurlencode($id), $params); | ||
| } | ||
|
|
||
| /** | ||
| * Delete a release in selected repository (Not thoroughly tested!) | ||
| * | ||
| * @param string $username the user who owns the repo | ||
| * @param string $repository the name of the repo | ||
| * @param integer $id the id of the release | ||
| * | ||
| * @return array | ||
| */ | ||
| public function remove($username, $repository, $id) | ||
| { | ||
| return $this->delete('repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/releases/'.rawurlencode($id)); | ||
| } | ||
|
|
||
| /** | ||
| * @return Assets | ||
| */ | ||
| public function assets() | ||
| { | ||
| return new Assets($this->client); | ||
| } | ||
| } | ||
This file contains hidden or 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.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
add
application/vnd.github.manifold-previewheader withconfigure