Skip to content

Commit f9d2df8

Browse files
author
Thibaud Fabre
committed
Add doc for Contents API
1 parent b402495 commit f9d2df8

File tree

2 files changed

+57
-0
lines changed

2 files changed

+57
-0
lines changed

doc/index.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ APIs:
1515
* [Pull Requests](pull_requests.md)
1616
* [Comments](pull_request/comments.md)
1717
* [Repositories](repos.md)
18+
* [Contents](repo/contents.md)
1819
* [Releases](repo/releases.md)
1920
* [Assets](repo/assets.md)
2021
* [Users](users.md)

doc/repo/contents.md

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
## Repo / Contents API
2+
[Back to the "Repos API"](../repos.md) | [Back to the navigation](../index.md)
3+
4+
### Get a repository's README
5+
6+
```php
7+
$readme = $client->api('repo')->contents()->readme('knp-labs', 'php-github-api', $reference);
8+
```
9+
10+
### Get information about a repository file or directory
11+
12+
```php
13+
$fileInfo = $client->api('repo')->contents()->show('knp-labs', 'php-github-api', $path, $reference);
14+
```
15+
16+
### Check that a file or directory exists in the repository
17+
```php
18+
$fileExists = $client->api('repo')->contents()->exists('knp-labs', 'php-github-api', $path, $reference);
19+
```
20+
21+
### Create a file
22+
```php
23+
$committer = array('name' => 'KnpLabs', 'email' => '[email protected]');
24+
25+
$fileInfo = $client->api('repo')->contents()->create('knp-labs', 'php-github-api', $path, $content, $commitMessage, $branch, $committer);
26+
```
27+
28+
### Update a file
29+
30+
```php
31+
$committer = array('name' => 'KnpLabs', 'email' => '[email protected]');
32+
$oldFile = $client->api('repo')->contents()->show('knp-labs', 'php-github-api', $path, $branch);
33+
34+
$fileInfo = $client->api('repo')->contents()->create('knp-labs', 'php-github-api', $path, $content, $commitMessage, $oldFile['sha'], $branch, $committer);
35+
```
36+
37+
### Remove a file
38+
39+
```php
40+
$committer = array('name' => 'KnpLabs', 'email' => '[email protected]');
41+
$oldFile = $client->api('repo')->contents()->show('knp-labs', 'php-github-api', $path, $branch);
42+
43+
$fileInfo = $client->api('repo')->contents()->rm('knp-labs', 'php-github-api', $path, $commitMessage, $oldFile['sha'], $branch, $committer);
44+
```
45+
46+
### Get repository archive
47+
48+
```php
49+
// @todo Document
50+
```
51+
52+
### Download a file
53+
54+
```php
55+
$fileContent = $client->api('repo')->contents()->download('knp-labs', 'php-github-api', $path, $reference);
56+
```

0 commit comments

Comments
 (0)