users()->search(array("name" => "bje007")); $me = $client->user()->load(); var_dump($me, $users); #try { # // Create new repo under authorized user # $repo = $me->repos()->new( # /*name*/ "gogs-php-api-client-test", # /*desc*/ "Repository created from test file.", # /*private*/ false, # /*auto init*/ true, # /*git ignore*/ "Vim", # /*license*/ "MIT License" # /* default read me */ # ); # echo "New repo '" . $repo->rfull_name . "' created!\n"; #} catch(\Lib\HTTPUnexpectedResponse $e) { # // Repo exists, get it! # $repo = $me->repo("gogs-php-api-client-test"); # // Delete it (it will now be created on reload!) # $repo->delete(); # echo "Repo '" . $repo->rfull_name . "' deleted\n"; #} //$orgs = $me->organizations(); // Requires ADMIN rights to the authenticated user #try { // Create new user "tester2" # $user = $client->users()->new("tester2", "git@git.giaever.org"); # echo "New user '" . $user->uusername . "' created!\n"; // And a new repository under this user # $repo = $user->repos()->new( # /*name*/ "gogs-php-api-client-auth-test", # /*desc*/ "Repository created from test file.", # /*private*/ false, # /*auto init*/ true, # /*git ignore*/ "Vim", # /*license*/ "MIT License" # /* default read me */ # ); # echo "New repo '" . $repo->rfull_name . "' created\n"; # $org = $user->organizations()->new( # /*username*/ "tester-org", # /*full name*/ "Tester's organization", # /*desc*/ "Just a test organization", # /*website*/ "https://git.giaever.org/", # /*location*/ "Norway" # ); #}catch (\Lib\NotAuthorizedException $e) { # echo "User (me) '" . $me->uusername . "' not authorized for this action: " . $e->getMessage(); #} catch (\Lib\HTTPUnexpectedResponse $e) { // Most likely user exist; then delete it # $user = $client->users()->get("tester2"); // Delete it's repositories # foreach ($user->repos()->load()->all() as $repo) # $repo->delete(); # foreach ($user->organizations()->load()->all() as $org) # $org->delete(); # $user->delete(); # echo "User '" . $user->uusername . "' deleted!\n"; #} var_dump($me->organizations()->load()->all()["FlyViking"]->repos()->create( "test-repo-for-org", "this is desc." )); } catch (ApiException\NotAuthorizedException $e) { die("NOT AUTH: " . $e->getMessage()); } catch (ApiException\HTTPUnexpectedResponse $e) { die($e); } catch (Exception $e) { die($e); } ?>