-
-
Notifications
You must be signed in to change notification settings - Fork 597
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #79 from KnpLabs/feature/releases-assets
Releases and assets
- Loading branch information
Showing
10 changed files
with
511 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
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,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 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 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,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 <d46k16@gmail.com> | ||
*/ | ||
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 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 <matthew.a.simo@gmail.com> | ||
* @author Evgeniy Guseletov <d46k16@gmail.com> | ||
*/ | ||
class Releases 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' | ||
)); | ||
} | ||
|
||
/** | ||
* 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 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.