A client to query Gogs (https://gogs.io) API from PHP.
A guide on how to use will come shortly!
Clone the repo. Set the API_URL
and API_TOKEN
in the index-file.
$client = new \Client\GogsAPI(API_URL, API_TOKEN);
$me = $client->user();
$other = $client->user("username");
$repos = $me->get("/repos")->load();
// Loop through every repo
for($repo = $repos->current(); $repo != false; $repo = $repos->next())
var_dump($repo);
GET /users/search
$users = $client->users()->search(array("name" => /* username */));
The array-param can be
Returns a CollectionResult
, e.g
foreach ($users as $user)
echo $user->ufull_name . "\n";
GET /user
$me = $client->user(); // alt: $client->users()->get()
GET /users/:username
$user = $client->user("username"); // alt: $client->users()->get("username")
POST /admin/users
$user = $clients->users()->new(
"new user", "users@email.com"
);
The params should be in the order
Requires the authenticated user to have admin rights.
DELETE /admin/users/:username
$user->delete();
Requires the authenticated user to have admin rights.
GET /user/repos
or
GET /users/:username/repos
$repos = $user->repos()->load();
GET /repos/:owner/:repo
$repo = $user->repo( /* repo */ );
POST /user/repos
or
POST /admin/users/:username/repos
$user->repos()->new(
"name"
);
The params should be in the order
Requires the authenticated user to have admin rights to be able to create repos for other users than itself.
DELETE /repos/:owner/:repo
$repo->delete();
Requires the authenticated user to have admin rights to be able to delete repos for other users than itself.
GET /user/orgs
or
GET /users/:username/orgs
$orgs = $user->organizations();
GET /orgs/:orgname/repos
$org = $user->organizations()->load()->current();
$repos = $org->repos();