Browse Source

Updated read me

Joachim M. Giæver 6 years ago
parent
commit
025a09ff2c

+ 153 - 51
README.md

@@ -652,7 +652,7 @@ Parameters
 |---                     |---       |---                           |
 |string                  |$api_url  |The URL to the API.           |
 |string                  |$api_token|A token for an authorized user|
-|[Repo](#request-gogsapi)|$repo     |*None*                        |
+|[Repo](#request-gogsapi)|$repo     |Related repository            |
 ---
 
 
@@ -710,7 +710,7 @@ Parameters
 |---                     |---       |---                           |
 |string                  |$api_url  |The URL to the API.           |
 |string                  |$api_token|A token for an authorized user|
-|[Repo](#request-gogsapi)|$repo     |*None*                        |
+|[Repo](#request-gogsapi)|$repo     |The repository                |
 ---
 
 
@@ -847,7 +847,7 @@ Parameters
 |---                           |---       |---                           |
 |string                        |$api_url  |The URL to the API.           |
 |string                        |$api_token|A token for an authorized user|
-|[Collection](#request-gogsapi)|$other    |*None*                        |
+|[Collection](#request-gogsapi)|$other    |Collection to initialize from|
 ---
 
 
@@ -1020,9 +1020,9 @@ public function offset(int $off);
 
 Parameters
 
-| Type | Variable | Description |
-|---   |---       |---          |
-|int   |$off      |*None*       |
+| Type | Variable | Description             |
+|---   |---       |---                      |
+|int   |$off      |Offset from in collection|
 
 Returns: [Collection](#collection-gogslib)
 
@@ -1158,8 +1158,8 @@ Parameters
 |---                     |---       |---                           |
 |string                  |$api_url  |The URL to the API.           |
 |string                  |$api_token|A token for an authorized user|
-|[User](#request-gogsapi)|$owner    |*None*                        |
-|string                  |$oname    |*None*                        |
+|[User](#request-gogsapi)|$owner    |The owner of the organization|
+|string                  |$oname    |Organization name             |
 ---
 
 
@@ -1250,7 +1250,7 @@ Parameters
 |---                     |---       |---                           |
 |string                  |$api_url  |The URL to the API.           |
 |string                  |$api_token|A token for an authorized user|
-|[User](#request-gogsapi)|$owner    |*None*                        |
+|[User](#request-gogsapi)|$owner    |The user                      |
 ---
 
 
@@ -1408,6 +1408,8 @@ By now the following are supported:
 |[branches](#branches-gogsapirequestrepo)                  |[Branches](#branches-gogsapirequest)      |public   | Return branches for repository.                       |
 |[json_set_property](#json_set_property-gogsapirequestrepo)|[true](#true-gogsapirequest) ***v*** array|protected| Overrides Base method as this should set owner as well|
 |[create](#create-gogsapirequestrepo)                      |bool                                      |public   | Create a new repo                                     |
+|[migrate](#migrate-gogsapirequestrepo)                    |                                          |public   | Migrate a repository from other Git hosting sources.  |
+|[sync](#sync-gogsapirequestrepo)                          |bool                                      |public   | Add repo to sync queue.                               |
 
 #### Method details
 
@@ -1427,8 +1429,8 @@ Parameters
 |---                     |---       |---                           |
 |string                  |$api_url  |The URL to the API.           |
 |string                  |$api_token|A token for an authorized user|
-|[User](#request-gogsapi)|$owner    |*None*                        |
-|string                  |$name     |*None*                        |
+|[User](#request-gogsapi)|$owner    |The owner of the repo         |
+|string                  |$name     |The repo name                 |
 ---
 
 
@@ -1490,7 +1492,7 @@ public function create(... $args);
 
 Valid paramters:
 
- 1. name
+ 1. name, required
  2. description
  3. private (default: false)
  4. auto_init (default: false)
@@ -1513,6 +1515,56 @@ Returns: bool
 ---
 
 
+##### migrate `Gogs\API\Request\Repo`
+```php
+public function migrate(mixed $args);
+```
+ Migrate a repository from other Git hosting sources.
+
+Valid parameters:
+
+ 1. clone_addr, required
+ 3. repo_name, required
+ 4. auth_username
+ 5. auth_password
+ 6. mirror (default: false)
+ 7. private (default: false)
+ 8. description
+
+ **UID** will be set to `owner`. Either a User or an Organization.
+ **From API doc**: To migrate a repository for a organization,
+ the authenticated user must be a owner of the specified organization.
+
+ This reflects the API v1 documentation, but is in an order
+ where the required fields as first.
+
+
+Parameters
+
+| Type | Variable | Description |
+|---   |---       |---          |
+|mixed|$args     |*None*       |
+Throws: 
+
+* [RequestErrorException](#requesterrorexception-gogsapirequestexception "Exception: Gogs\API\Request\Exception\RequestErrorException")
+
+---
+
+
+##### sync `Gogs\API\Request\Repo`
+```php
+public function sync();
+```
+ Add repo to sync queue.
+
+Requires the repository to be a mirror.
+
+
+Returns: bool
+
+---
+
+
 ### Repos `Gogs\API\Request`
 
 
@@ -1721,11 +1773,11 @@ public function __construct(string $api_url, string $password, User $user);
 
 Parameters
 
-| Type                   | Variable | Description       |
-|---                     |---       |---                |
-|string                  |$api_url  |The URL to the API.|
-|string                  |$password|*None*             |
-|[User](#request-gogsapi)|$user     |*None*             |
+| Type                   | Variable | Description               |
+|---                     |---       |---                        |
+|string                  |$api_url  |The URL to the API.        |
+|string                  |$password|The users personal password|
+|[User](#request-gogsapi)|$user     |*None*                     |
 ---
 
 
@@ -1805,11 +1857,11 @@ public function __construct(string $api_url, string $password, User $user);
 
 Parameters
 
-| Type                   | Variable | Description       |
-|---                     |---       |---                |
-|string                  |$api_url  |The URL to the API.|
-|string                  |$password|*None*             |
-|[User](#request-gogsapi)|$user     |*None*             |
+| Type                   | Variable | Description            |
+|---                     |---       |---                     |
+|string                  |$api_url  |The URL to the API.     |
+|string                  |$password|User's personal password|
+|[User](#request-gogsapi)|$user     |Owner of tokens         |
 ---
 
 
@@ -1960,19 +2012,19 @@ A user can also list it's repos and organizations.
 
 #### Methods
 
-|Name                                              |Return                        |Access   |Description                                    |
-|:---                                              |:---                          |:---     |:---                                           |
-|[__construct](#__construct-gogsapirequestuser)    |                              |public   | Initialize an user object.                    |
-|[set_scope](#set_scope-gogsapirequestuser)        |bool                          |protected|                                               |
-|[authenticated](#authenticated-gogsapirequestuser)|bool                          |public   | Returns if the user is the authenticated user.|
-|[repos](#repos-gogsapirequestuser)                |[Repos](#repos-gogsapirequest)|public   | Returns every repo under user.                |
-|[repo](#repo-gogsapirequestuser)                  |[Repo](#repo-gogsapirequest)  |public   | Return a single repo.                         |
-|[organizations](#organizations-gogsapirequestuser)|[Orgs](#orgs-gogsapirequest)  |public   | Return every organization under user.         |
-|[orgs](#orgs-gogsapirequestuser)                  |                              |public   |                                               |
-|[organization](#organization-gogsapirequestuser)  |[Org](#org-gogsapirequest)    |public   | Return a single organization.                 |
-|[org](#org-gogsapirequestuser)                    |                              |public   |                                               |
-|[create](#create-gogsapirequestuser)              |bool                          |public   | Create a new user.                            |
-|[tokens](#tokens-gogsapirequestuser)              |                              |public   |                                               |
+|Name                                              |Return                          |Access   |Description                                    |
+|:---                                              |:---                            |:---     |:---                                           |
+|[__construct](#__construct-gogsapirequestuser)    |                                |public   | Initialize an user object.                    |
+|[set_scope](#set_scope-gogsapirequestuser)        |bool                            |protected|                                               |
+|[authenticated](#authenticated-gogsapirequestuser)|bool                            |public   | Returns if the user is the authenticated user.|
+|[repos](#repos-gogsapirequestuser)                |[Repos](#repos-gogsapirequest)  |public   | Returns every repo under user.                |
+|[repo](#repo-gogsapirequestuser)                  |[Repo](#repo-gogsapirequest)    |public   | Return a single repo.                         |
+|[organizations](#organizations-gogsapirequestuser)|[Orgs](#orgs-gogsapirequest)    |public   | Return every organization under user.         |
+|[orgs](#orgs-gogsapirequestuser)                  |                                |public   |                                               |
+|[organization](#organization-gogsapirequestuser)  |[Org](#org-gogsapirequest)      |public   | Return a single organization.                 |
+|[org](#org-gogsapirequestuser)                    |                                |public   |                                               |
+|[create](#create-gogsapirequestuser)              |bool                            |public   | Create a new user.                            |
+|[tokens](#tokens-gogsapirequestuser)              |[Tokens](#tokens-gogsapirequest)|public   | Returns user tokens                           |
 
 #### Method details
 
@@ -2144,12 +2196,17 @@ Returns: bool
 ```php
 public function tokens(string $password);
 ```
+ Returns user tokens
+
 
 Parameters
 
-| Type | Variable | Description |
-|---   |---       |---          |
-|string|$password|*None*       |
+| Type | Variable | Description           |
+|---   |---       |---                    |
+|string|$password|User personal password.|
+
+Returns: [Tokens](#tokens-gogsapirequest)
+
 ---
 
 
@@ -2621,9 +2678,9 @@ public function offset(int $off);
 
 Parameters
 
-| Type | Variable | Description |
-|---   |---       |---          |
-|int   |$off      |*None*       |
+| Type | Variable | Description             |
+|---   |---       |---                      |
+|int   |$off      |Offset from in collection|
 
 Returns: [Collection](#collection-gogslib)
 
@@ -2816,9 +2873,9 @@ public function offset(int $off);
 
 Parameters
 
-| Type | Variable | Description |
-|---   |---       |---          |
-|int   |$off      |*None*       |
+| Type | Variable | Description             |
+|---   |---       |---                      |
+|int   |$off      |Offset from in collection|
 
 Returns: [Collection](#collection-gogslib)
 
@@ -2864,18 +2921,20 @@ A trait used for every class referencing the api-url and token.
 
 #### Methods
 
-|Name                                       |Return|Access       |Description                                                                                                                                                                                                                                                                              |
-|:---                                       |:---  |:---         |:---                                                                                                                                                                                                                                                                                     |
-|[basic](#basic-gogslibcurlclient)          |      |public       | Basic sets the user for basic HTTP-authentication.                                                                                                                                                                                                                                      |
-|[method](#method-gogslibcurlclient)        |int   |protected    | Initializes a curl request of different kinds, dependingon the specified method. This can be                                                                                                                                                                                            |
-|[authorized](#authorized-gogslibcurlclient)|bool  |protected    | Checks if the user is authorized for the scope. Shouldn'tbe used frequently. One test for one scope should be enough,but if you know for sure thats you're programming with theuse of an authorized user you should leave this and justhandle the NotAuthorizedExeption whenever thrown.|
-|[get_log](#get_log-gogslibcurlclient)      |array|public static| Returns log entries for the client.                                                                                                                                                                                                                                                     |
+|Name                                             |Return|Access       |Description                                                                                                                                                                                                                                                                              |
+|:---                                             |:---  |:---         |:---                                                                                                                                                                                                                                                                                     |
+|[basic](#basic-gogslibcurlclient)                |      |protected    | Basic sets the user for basic HTTP-authentication.                                                                                                                                                                                                                                      |
+|[set_param](#set_param-gogslibcurlclient)        |      |protected    | Set param into array                                                                                                                                                                                                                                                                    |
+|[filter_params](#filter_params-gogslibcurlclient)|      |protected    | Filter out NULL values from parameters.                                                                                                                                                                                                                                                 |
+|[method](#method-gogslibcurlclient)              |int   |protected    | Initializes a curl request of different kinds, dependingon the specified method. This can be                                                                                                                                                                                            |
+|[authorized](#authorized-gogslibcurlclient)      |bool  |protected    | Checks if the user is authorized for the scope. Shouldn'tbe used frequently. One test for one scope should be enough,but if you know for sure thats you're programming with theuse of an authorized user you should leave this and justhandle the NotAuthorizedExeption whenever thrown.|
+|[get_log](#get_log-gogslibcurlclient)            |array|public static| Returns log entries for the client.                                                                                                                                                                                                                                                     |
 
 #### Method details
 
 ##### basic `Gogs\Lib\Curl\Client`
 ```php
-public function basic(string $user);
+protected function basic(string $user);
 ```
  Basic sets the user for basic HTTP-authentication.
 
@@ -2888,6 +2947,49 @@ Parameters
 ---
 
 
+##### set_param `Gogs\Lib\Curl\Client`
+```php
+protected function set_param(array $params, string $param_name, array $args, int $index, string $type, mixed $default = null, callable $f = null);
+```
+ Set param into array
+
+The specified callback will only run if the expected
+parameter is set. This callback can either overwrite
+paramtere as passing them as reference or throw an exception
+to indicate invalid data.
+
+
+Parameters
+
+| Type   | Variable | Description                         |
+|---     |---        |---                                  |
+|array   |$params    |&$params Array to insert to          |
+|string  |$param_name|Index in params-array                |
+|array   |$args      |Arguments array                      |
+|int     |$index     |Index in arguments array             |
+|string  |$type      |Expected type of data                |
+|mixed   |$default   |Default if not expected type on index|
+|callable|$f         |Callback method if param is set      |
+---
+
+
+##### filter_params `Gogs\Lib\Curl\Client`
+```php
+protected function filter_params(array $params);
+```
+ Filter out NULL values from parameters.
+
+Saves transferring size.
+
+
+Parameters
+
+| Type | Variable | Description       |
+|---   |---       |---                |
+|array|$params   |&$params Parameters|
+---
+
+
 ##### method `Gogs\Lib\Curl\Client`
 ```php
 protected function method(string $method, string $req, string $scope, array $params, bool $ret);

+ 3 - 1
src/API/Request/Branch.php

@@ -18,7 +18,9 @@ namespace Gogs\API\Request {
          * Initialize a branch for the given repository.
          *
          * @see Base
-         * @param Repo $repo 
+         * @param string $api_url The API URL
+         * @param string $api_token The API token
+         * @param Repo $repo Related repository
          */
         public function __construct(string $api_url, string $api_token, Repo $repo) {
             parent::__construct($api_url, $api_token);

+ 2 - 0
src/API/Request/Branches.php

@@ -17,6 +17,8 @@ namespace Gogs\API\Request {
         /** 
          * Initialize Brances for a given repo
          * 
+         * @param string $api_url The API URL
+         * @param string $api_token The API token
          * @param Repo $repo The repository
          */
         public function __construct(string $api_url, string $api_token, Repo $repo) {

+ 2 - 0
src/API/Request/Collection.php

@@ -17,6 +17,8 @@ namespace Gogs\API\Request {
          * Initialize a collection.
          *
          * @see Base
+         * @param string $api_url The API URL
+         * @param string $api_token The API token
          * @param Collection $other Collection to initialize from
          */
         public function __construct(string $api_url, string $api_token, Collection $other = null) {

+ 2 - 0
src/API/Request/Org.php

@@ -24,6 +24,8 @@ namespace Gogs\API\Request {
          * Initialize an organization.
          *
          * @see Base
+         * @param string $api_url The API URL
+         * @param string $api_token The API token
          * @param User $owner The owner of the organization
          * @param string $oname Organization name
          */

+ 2 - 0
src/API/Request/Orgs.php

@@ -15,6 +15,8 @@ namespace Gogs\API\Request {
          * Initialize an organization collection for user.
          * 
          * @see Base
+         * @param string $api_url The API URL
+         * @param string $api_token The API token
          * @param User $owner The user
          */
         public function __construct(string $api_url, string $api_token, User $owner) {

+ 2 - 0
src/API/Request/Repo.php

@@ -49,6 +49,8 @@ namespace Gogs\API\Request {
          * or any other class that inherits a user.
          *
          * @see Base
+         * @param string $api_url The API URL
+         * @param string $api_token The API token
          * @param User $owner The owner of the repo
          * @param string $name The repo name
          */

+ 2 - 0
src/API/Request/Token.php

@@ -25,6 +25,8 @@ namespace Gogs\API\Request {
          * Initializes a token
          * 
          * @see Base
+         * @param string $api_url The API URL
+         * @param string $password The users personal password
          * @param User $user 
          */
         public function __construct(string $api_url, string $password, User $user) {

+ 2 - 0
src/API/Request/Tokens.php

@@ -20,6 +20,8 @@ namespace Gogs\API\Request {
          * Initialize a token collection.
          * 
          * @see Base
+         * @param string $api_url The API URL
+         * @param string $password User's personal password
          * @param User $user Owner of tokens
          */
         public function __construct(string $api_url, string $password, User $user) {

+ 1 - 1
src/Lib/ArrayIterator.php

@@ -75,7 +75,7 @@ namespace Gogs\Lib {
         /**
          * Get from offset collection
          *
-         * @param int $offset Offset from in collection
+         * @param int $off Offset from in collection
          * @return Collection
          */
         public function offset(int $off);