From 9647308fc0a5ccaef8b2b71e001dd5c9fd1fa423 Mon Sep 17 00:00:00 2001 From: Cosmin Lupu Date: Thu, 13 Jul 2017 17:27:05 +0200 Subject: [PATCH] Added documentation for GitData API --- doc/README.md | 6 ++++++ doc/gitdata/blobs.md | 14 +++++++++++++ doc/gitdata/commits.md | 15 +++++++++++++ doc/gitdata/references.md | 44 +++++++++++++++++++++++++++++++++++++++ doc/gitdata/tags.md | 32 ++++++++++++++++++++++++++++ doc/gitdata/trees.md | 25 ++++++++++++++++++++++ 6 files changed, 136 insertions(+) create mode 100644 doc/gitdata/blobs.md create mode 100644 doc/gitdata/commits.md create mode 100644 doc/gitdata/references.md create mode 100644 doc/gitdata/tags.md create mode 100644 doc/gitdata/trees.md diff --git a/doc/README.md b/doc/README.md index b1c99e97b22..772dbb3e645 100644 --- a/doc/README.md +++ b/doc/README.md @@ -14,6 +14,12 @@ v3 APIs: * [Enterprise](enterprise.md) * [Gists](gists.md) * [Comments](gists/comments.md) +* GitData + * [Blobs](gitdata/blobs.md) + * [Commits](gitdata/commits.md) + * [References](gitdata/references.md) + * [Tags](gitdata/tags.md) + * [Trees](gitdata/trees.md) * [GraphQL](graphql.md) * [Issues](issues.md) * [Assignees](issue/assignees.md) diff --git a/doc/gitdata/blobs.md b/doc/gitdata/blobs.md new file mode 100644 index 00000000000..78a79ac0810 --- /dev/null +++ b/doc/gitdata/blobs.md @@ -0,0 +1,14 @@ +## Blobs API +[Back to the navigation](../README.md) + +### Show a blob + +```php +$blob = $client->api('gitData')->blobs()->show('KnpLabs', 'php-github-api', '839e5185da9434753db47959bee16642bb4f2ce4'); +``` + +### Create a blob + +```php +$blob = $client->api('gitData')->blobs()->create('KnpLabs', 'php-github-api', ['content' => 'Test content', 'encoding' => 'utf-8']); +``` \ No newline at end of file diff --git a/doc/gitdata/commits.md b/doc/gitdata/commits.md new file mode 100644 index 00000000000..07584e49929 --- /dev/null +++ b/doc/gitdata/commits.md @@ -0,0 +1,15 @@ +## Commits API +[Back to the navigation](../README.md) + +### Show a commit + +```php +$commit = $client->api('gitData')->commits()->show('KnpLabs', 'php-github-api', '839e5185da9434753db47959bee16642bb4f2ce4'); +``` + +### Create a commit + +```php +$commitData = ['message' => 'Upgrading documentation', 'tree' => $treeSHA, 'parents' => [$parentCommitSHA]]; +$commit = $client->api('gitData')->commits()->create('KnpLabs', 'php-github-api', $commitData); +``` \ No newline at end of file diff --git a/doc/gitdata/references.md b/doc/gitdata/references.md new file mode 100644 index 00000000000..cc4ee25eb7c --- /dev/null +++ b/doc/gitdata/references.md @@ -0,0 +1,44 @@ +## References API +[Back to the navigation](../README.md) + + +### List all references +```php +$references = $client->api('gitData')->references()->all('KnpLabs', 'php-github-api'); +``` + +### Show a reference + +```php +$reference = $client->api('gitData')->references()->show('KnpLabs', 'php-github-api', 'heads/featureA'); +``` + +### Create a reference + +```php +$referenceData = ['ref' => 'refs/heads/featureA', 'sha' => '839e5185da9434753db47959bee16642bb4f2ce4']; +$reference = $client->api('gitData')->references()->create('KnpLabs', 'php-github-api', $referenceData); +``` + +### Update a reference + +```php +$referenceData = ['sha' => '839e5185da9434753db47959bee16642bb4f2ce4', 'force' => false ]; //Force is default false +$reference = $client->api('gitData')->references()->update('KnpLabs', 'php-github-api', 'heads/featureA', $referenceData); +``` + +### Delete a reference + +```php +$client->api('gitData')->references()->remove('KnpLabs', 'php-github-api', 'heads/featureA'); +``` + +### List all branches +```php +$references = $client->api('gitData')->references()->branches('KnpLabs', 'php-github-api'); +``` + +### List all tags +```php +$references = $client->api('gitData')->references()->tags('KnpLabs', 'php-github-api'); +``` \ No newline at end of file diff --git a/doc/gitdata/tags.md b/doc/gitdata/tags.md new file mode 100644 index 00000000000..36b323e5c74 --- /dev/null +++ b/doc/gitdata/tags.md @@ -0,0 +1,32 @@ +## Tags API +[Back to the navigation](../README.md) + +### Show all tags + +```php +$tags = $client->api('gitData')->tags()->all('KnpLabs', 'php-github-api'); +``` + +### Show a tag + +```php +$tag = $client->api('gitData')->tags()->show('KnpLabs', 'php-github-api', '839e5185da9434753db47959bee16642bb4f2ce4'); +``` + +### Create a tag + +```php +$tagData = [ + 'tag' => 'v0.0.1', + 'message' => 'initial version', + 'object' => 'c3d0be41ecbe669545ee3e94d31ed9a4bc91ee3c', + 'type' => 'commit', + 'tagger' => [ + 'name' => 'KnpLabs', + 'email' => 'hello@knplabs.com', + 'date' => '2017-06-17T14:53:35-07:00' + ] +]; + +$tag = $client->api('gitData')->tags()->create('KnpLabs', 'php-github-api', $tagData); +``` \ No newline at end of file diff --git a/doc/gitdata/trees.md b/doc/gitdata/trees.md new file mode 100644 index 00000000000..dcdd0b49c08 --- /dev/null +++ b/doc/gitdata/trees.md @@ -0,0 +1,25 @@ +## Trees API +[Back to the navigation](../README.md) + +### Show a tree + +```php +$tree = $client->api('gitData')->trees()->show('KnpLabs', 'php-github-api', '839e5185da9434753db47959bee16642bb4f2ce4'); +``` + +### Create a tree + +```php +$treeData = [ + 'base_tree' => '839e5185da9434753db47959bee16642bb4f2ce4', + 'tree' => [ + [ + 'path' => 'README.md', + 'mode' => '100644', + 'type' => 'blob', + 'content' => 'Updated Readme file' + ] + ] +]; +$tree = $client->api('gitData')->trees()->create('KnpLabs', 'php-github-api', $treeData); +``` \ No newline at end of file