-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #82 from packagist/suborganization-rename
Add suborganization API and deprecated subrepository API
- Loading branch information
Showing
17 changed files
with
1,033 additions
and
142 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
<?php | ||
|
||
/** | ||
* (c) Packagist Conductors GmbH <[email protected]> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
namespace PrivatePackagist\ApiClient\Api; | ||
|
||
use PrivatePackagist\ApiClient\Exception\InvalidArgumentException; | ||
|
||
class Suborganizations extends AbstractApi | ||
{ | ||
public function all() | ||
{ | ||
return $this->get('/suborganizations/'); | ||
} | ||
|
||
public function show($suborganizationName) | ||
{ | ||
return $this->get(sprintf('/suborganizations/%s/', $suborganizationName)); | ||
} | ||
|
||
public function create($name) | ||
{ | ||
return $this->post('/suborganizations/', ['name' => $name]); | ||
} | ||
|
||
public function remove($suborganizationName) | ||
{ | ||
return $this->delete(sprintf('/suborganizations/%s/', $suborganizationName)); | ||
} | ||
|
||
public function listTeams($suborganizationName) | ||
{ | ||
return $this->get(sprintf('/suborganizations/%s/teams/', $suborganizationName)); | ||
} | ||
|
||
public function addOrEditTeams($suborganizationName, array $teams) | ||
{ | ||
foreach ($teams as $team) { | ||
if (!isset($team['id'])) { | ||
throw new InvalidArgumentException('Parameter "id" is required.'); | ||
} | ||
|
||
if (!isset($team['permission'])) { | ||
throw new InvalidArgumentException('Parameter "permission" is required.'); | ||
} | ||
} | ||
|
||
return $this->post(sprintf('/suborganizations/%s/teams/', $suborganizationName), $teams); | ||
} | ||
|
||
public function removeTeam($suborganizationName, $teamId) | ||
{ | ||
return $this->delete(sprintf('/suborganizations/%s/teams/%s/', $suborganizationName, $teamId)); | ||
} | ||
|
||
public function listTokens($suborganizationName) | ||
{ | ||
return $this->get(sprintf('/suborganizations/%s/tokens/', $suborganizationName)); | ||
} | ||
|
||
public function createToken($suborganizationName, array $tokenData) | ||
{ | ||
return $this->post(sprintf('/suborganizations/%s/tokens/', $suborganizationName), $tokenData); | ||
} | ||
|
||
public function removeToken($suborganizationName, $tokenId) | ||
{ | ||
return $this->delete(sprintf('/suborganizations/%s/tokens/%s/', $suborganizationName, $tokenId)); | ||
} | ||
|
||
public function regenerateToken($suborganizationName, $tokenId, array $confirmation) | ||
{ | ||
if (!isset($confirmation['IConfirmOldTokenWillStopWorkingImmediately'])) { | ||
throw new InvalidArgumentException('Confirmation is required to regenerate the Composer repository token.'); | ||
} | ||
|
||
return $this->post(sprintf('/suborganizations/%s/tokens/%s/regenerate', $suborganizationName, $tokenId), $confirmation); | ||
} | ||
|
||
public function packages() | ||
{ | ||
return new Suborganizations\Packages($this->client); | ||
} | ||
|
||
public function mirroredRepositories() | ||
{ | ||
return new Suborganizations\MirroredRepositories($this->client); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
<?php | ||
|
||
/** | ||
* (c) Packagist Conductors GmbH <[email protected]> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
namespace PrivatePackagist\ApiClient\Api\Suborganizations; | ||
|
||
use PrivatePackagist\ApiClient\Api\AbstractApi; | ||
use PrivatePackagist\ApiClient\Exception\InvalidArgumentException; | ||
|
||
class MirroredRepositories extends AbstractApi | ||
{ | ||
public function all($suborganizationName) | ||
{ | ||
return $this->get(sprintf('/suborganizations/%s/mirrored-repositories/', $suborganizationName)); | ||
} | ||
|
||
public function add($suborganizationName, array $mirroredRepositories) | ||
{ | ||
foreach ($mirroredRepositories as $mirroredRepository) { | ||
if (!isset($mirroredRepository['id'], $mirroredRepository['mirroringBehavior'])) { | ||
throw new InvalidArgumentException('The "id" and the "mirroringBehavior" are required to add a mirrored repository to a project'); | ||
} | ||
} | ||
|
||
return $this->post(sprintf('/suborganizations/%s/mirrored-repositories/', $suborganizationName), $mirroredRepositories); | ||
} | ||
|
||
public function show($suborganizationName, $mirroredRepositoryId) | ||
{ | ||
return $this->get(sprintf('/suborganizations/%s/mirrored-repositories/%s/', $suborganizationName, $mirroredRepositoryId)); | ||
} | ||
|
||
public function edit($suborganizationName, $mirroredRepositoryId, $mirroringBehavior) | ||
{ | ||
return $this->put(sprintf('/suborganizations/%s/mirrored-repositories/%s/', $suborganizationName, $mirroredRepositoryId), [ | ||
'mirroringBehavior' => $mirroringBehavior, | ||
]); | ||
} | ||
|
||
public function remove($suborganizationName, $mirroredRepositoryId) | ||
{ | ||
return $this->delete(sprintf('/suborganizations/%s/mirrored-repositories/%s/', $suborganizationName, $mirroredRepositoryId)); | ||
} | ||
|
||
public function listPackages($suborganizationName, $mirroredRepositoryId) | ||
{ | ||
return $this->get(sprintf('/suborganizations/%s/mirrored-repositories/%s/packages/', $suborganizationName, $mirroredRepositoryId)); | ||
} | ||
|
||
public function addPackages($suborganizationName, $mirroredRepositoryId, array $packages) | ||
{ | ||
return $this->post(sprintf('/suborganizations/%s/mirrored-repositories/%s/packages/', $suborganizationName, $mirroredRepositoryId), $packages); | ||
} | ||
|
||
public function removePackages($suborganizationName, $mirroredRepositoryId) | ||
{ | ||
return $this->delete(sprintf('/suborganizations/%s/mirrored-repositories/%s/packages/', $suborganizationName, $mirroredRepositoryId)); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
<?php | ||
|
||
/** | ||
* (c) Packagist Conductors GmbH <[email protected]> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
namespace PrivatePackagist\ApiClient\Api\Suborganizations; | ||
|
||
use PrivatePackagist\ApiClient\Api\AbstractApi; | ||
use PrivatePackagist\ApiClient\Exception\InvalidArgumentException; | ||
use PrivatePackagist\ApiClient\Payload\CustomPackageConfig; | ||
use PrivatePackagist\ApiClient\Payload\VcsPackageConfig; | ||
|
||
class Packages extends AbstractApi | ||
{ | ||
public function all($suborganizationName, array $filters = []) | ||
{ | ||
if (isset($filters['origin']) && !in_array($filters['origin'], \PrivatePackagist\ApiClient\Api\Packages::AVAILABLE_ORIGINS, true)) { | ||
throw new InvalidArgumentException('Filter "origin" has to be one of: "' . implode('", "', \PrivatePackagist\ApiClient\Api\Packages::AVAILABLE_ORIGINS) . '".'); | ||
} | ||
|
||
return $this->get(sprintf('/suborganizations/%s/packages/', $suborganizationName), $filters); | ||
} | ||
|
||
public function show($suborganizationName, $packageIdOrName) | ||
{ | ||
return $this->get(sprintf('/suborganizations/%s/packages/%s', $suborganizationName, $packageIdOrName)); | ||
} | ||
|
||
public function createVcsPackage($suborganizationName, $url, $credentialId = null, $type = 'vcs', $defaultSuborganizationAccess = null) | ||
{ | ||
$data = new VcsPackageConfig($url, $credentialId, $type, $defaultSuborganizationAccess); | ||
|
||
return $this->post(sprintf('/suborganizations/%s/packages/', $suborganizationName), $data->toParameters()); | ||
} | ||
|
||
public function createCustomPackage($suborganizationName, $customJson, $credentialId = null, $defaultSuborganizationAccess = null) | ||
{ | ||
$data = new CustomPackageConfig($customJson, $credentialId, $defaultSuborganizationAccess); | ||
|
||
return $this->post(sprintf('/suborganizations/%s/packages/', $suborganizationName), $data->toParameters()); | ||
} | ||
|
||
public function editVcsPackage($suborganizationName, $packageIdOrName, $url, $credentialId = null, $type = 'vcs', $defaultSuborganizationAccess = null) | ||
{ | ||
$data = new VcsPackageConfig($url, $credentialId, $type, $defaultSuborganizationAccess); | ||
|
||
return $this->put(sprintf('/suborganizations/%s/packages/%s/', $suborganizationName, $packageIdOrName), $data->toParameters()); | ||
} | ||
|
||
public function editCustomPackage($suborganizationName, $packageIdOrName, $customJson, $credentialId = null, $defaultSuborganizationAccess = null) | ||
{ | ||
$data = new CustomPackageConfig($customJson, $credentialId, $defaultSuborganizationAccess); | ||
|
||
return $this->put(sprintf('/suborganizations/%s/packages/%s/', $suborganizationName, $packageIdOrName), $data->toParameters()); | ||
} | ||
|
||
public function remove($suborganizationName, $packageIdOrName) | ||
{ | ||
return $this->delete(sprintf('/suborganizations/%s/packages/%s/', $suborganizationName, $packageIdOrName)); | ||
} | ||
|
||
public function listDependents($suborganizationName, $packageIdOrName) | ||
{ | ||
return $this->get(sprintf('/suborganizations/%s/packages/%s/dependents/', $suborganizationName, $packageIdOrName)); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.