Skip to content

Commit

Permalink
Merge pull request #79 from packagist/mention-package-id-changes
Browse files Browse the repository at this point in the history
Mention package id changes
  • Loading branch information
glaubinix authored Aug 21, 2024
2 parents f41925f + 234fc88 commit bca533e
Show file tree
Hide file tree
Showing 5 changed files with 50 additions and 30 deletions.
22 changes: 21 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -287,13 +287,19 @@ $packages = $client->teams()->packages($teamId);
Returns an array of packages.

#### Grant a team access to a list of private packages

You pass an array of packages to give access to. The values of the array can be either package ID or package name.

```php
$teamId = 1;
$packages = $client->teams()->addPackages($teamId, ['acme-website/package']);
$packages = $client->teams()->addPackages($teamId, ['acme-website/package', 1]);
```
Returns an array of packages.

#### Remove access for a package from a team

You can use the package ID or package name as a reference.

```php
$teamId = 1;
$packages = $client->teams()->removePackage($teamId, 'acme-website/package');
Expand Down Expand Up @@ -429,6 +435,9 @@ $packages = $client->customers()->addOrEditPackages($customerId, $packages);
Returns an array of all added or edited customer packages.

#### Revoke access to a package from a customer

You can reference the package by its ID or name.

```php
$customerId = 42;
$packageName = 'acme-website/package';
Expand Down Expand Up @@ -533,6 +542,9 @@ $packages = $client->vendorBundles()->packages()->addOrEditPackages($vendorBundl
Returns an array of all added or edited customer packages.

#### Remove a package from a vendor bundle

You can reference the package by its ID or name.

```php
$vendorBundleId = 42;
$packageName = 'acme-website/package';
Expand Down Expand Up @@ -772,6 +784,8 @@ $client->subrepositories()->mirroredRepositories()->removePackages($subrepositor

### Package

You can reference a package by its name or ID.

#### List an organization's packages
```php
$filters = [
Expand All @@ -784,7 +798,10 @@ Returns an array of packages.

#### Show a package
```php
// Either use package name:
$package = $client->packages()->show('acme-website/package');
// Or the package ID:
$package = $client->packages()->show(123);
```
Returns the package.

Expand Down Expand Up @@ -847,6 +864,9 @@ $client->packages()->listDependents('acme-website/package');
Returns a list of packages.

#### List all customers with access to a package

Pass either package ID or package name as argument.

```php
$client->packages()->listCustomers('acme-website/package');
```
Expand Down
8 changes: 4 additions & 4 deletions src/Api/Customers.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,9 @@ public function listPackages($customerIdOrUrlName)
return $this->get(sprintf('/customers/%s/packages/', $customerIdOrUrlName));
}

public function showPackage($customerIdOrUrlName, $packageName)
public function showPackage($customerIdOrUrlName, $packageIdOrName)
{
return $this->get(sprintf('/customers/%s/packages/%s/', $customerIdOrUrlName, $packageName));
return $this->get(sprintf('/customers/%s/packages/%s/', $customerIdOrUrlName, $packageIdOrName));
}

/**
Expand Down Expand Up @@ -104,9 +104,9 @@ public function addPackages($customerIdOrUrlName, array $packages)
return $this->addOrEditPackages($customerIdOrUrlName, $packages);
}

public function removePackage($customerIdOrUrlName, $packageName)
public function removePackage($customerIdOrUrlName, $packageIdOrName)
{
return $this->delete(sprintf('/customers/%s/packages/%s/', $customerIdOrUrlName, $packageName));
return $this->delete(sprintf('/customers/%s/packages/%s/', $customerIdOrUrlName, $packageIdOrName));
}

public function regenerateToken($customerIdOrUrlName, array $confirmation)
Expand Down
36 changes: 18 additions & 18 deletions src/Api/Packages.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,9 @@ public function all(array $filters = [])
return $this->get('/packages/', $filters);
}

public function show($packageName)
public function show($packageIdOrName)
{
return $this->get(sprintf('/packages/%s/', $packageName));
return $this->get(sprintf('/packages/%s/', $packageIdOrName));
}

public function createVcsPackage($url, $credentialId = null, $type = 'vcs', $defaultSubrepositoryAccess = null)
Expand Down Expand Up @@ -87,18 +87,18 @@ public function updateVcsPackage($packageName, $url, $credentialId = null)
return $this->editVcsPackage($packageName, $url, $credentialId);
}

public function editVcsPackage($packageName, $url, $credentialId = null, $type = 'vcs', $defaultSubrepositoryAccess = null)
public function editVcsPackage($packageIdOrName, $url, $credentialId = null, $type = 'vcs', $defaultSubrepositoryAccess = null)
{
$data = new VcsPackageConfig($url, $credentialId, $type, $defaultSubrepositoryAccess);

return $this->put(sprintf('/packages/%s/', $packageName), $data->toParameters());
return $this->put(sprintf('/packages/%s/', $packageIdOrName), $data->toParameters());
}

public function editArtifactPackage($packageName, array $artifactPackageFileIds, $defaultSubrepositoryAccess = null)
public function editArtifactPackage($packageIdOrName, array $artifactPackageFileIds, $defaultSubrepositoryAccess = null)
{
$data = new ArtifactPackageConfig($artifactPackageFileIds, $defaultSubrepositoryAccess);

return $this->put(sprintf('/packages/%s/', $packageName), $data->toParameters());
return $this->put(sprintf('/packages/%s/', $packageIdOrName), $data->toParameters());
}

/**
Expand All @@ -109,41 +109,41 @@ public function updateCustomPackage($packageName, $customJson, $credentialId = n
return $this->editCustomPackage($packageName, $customJson, $credentialId);
}

public function editCustomPackage($packageName, $customJson, $credentialId = null, $defaultSubrepositoryAccess = null)
public function editCustomPackage($packageIdOrName, $customJson, $credentialId = null, $defaultSubrepositoryAccess = null)
{
$data = new CustomPackageConfig($customJson, $credentialId, $defaultSubrepositoryAccess);

return $this->put(sprintf('/packages/%s/', $packageName), $data->toParameters());
return $this->put(sprintf('/packages/%s/', $packageIdOrName), $data->toParameters());
}

public function remove($packageName)
public function remove($packageIdOrName)
{
return $this->delete(sprintf('/packages/%s/', $packageName));
return $this->delete(sprintf('/packages/%s/', $packageIdOrName));
}

public function listCustomers($packageName)
public function listCustomers($packageIdOrName)
{
return $this->get(sprintf('/packages/%s/customers/', $packageName));
return $this->get(sprintf('/packages/%s/customers/', $packageIdOrName));
}

public function listDependents($packageName)
{
return $this->get(sprintf('/packages/%s/dependents/', $packageName));
}

public function listSecurityIssues($packageName, array $filters = [])
public function listSecurityIssues($packageIdOrName, array $filters = [])
{
return $this->get(sprintf('/packages/%s/security-issues/', $packageName), $filters);
return $this->get(sprintf('/packages/%s/security-issues/', $packageIdOrName), $filters);
}

public function showSecurityMonitoringConfig($packageName)
public function showSecurityMonitoringConfig($packageIdOrName)
{
return $this->get(sprintf('/packages/%s/security-monitoring/', $packageName));
return $this->get(sprintf('/packages/%s/security-monitoring/', $packageIdOrName));
}

public function editSecurityMonitoringConfig($packageName, array $config)
public function editSecurityMonitoringConfig($packageIdOrName, array $config)
{
return $this->put(sprintf('/packages/%s/security-monitoring/', $packageName), $config);
return $this->put(sprintf('/packages/%s/security-monitoring/', $packageIdOrName), $config);
}

public function artifacts()
Expand Down
8 changes: 4 additions & 4 deletions src/Api/Packages/Artifacts.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@ public function create($file, $contentType, $fileName)
]));
}

public function add($packageName, $file, $contentType, $fileName)
public function add($packageIdOrName, $file, $contentType, $fileName)
{
return $this->postFile('/packages/'.$packageName.'/artifacts/', $file, array_filter([
return $this->postFile('/packages/'.$packageIdOrName.'/artifacts/', $file, array_filter([
'Content-Type' => $contentType,
'X-FILENAME' => $fileName
]));
Expand All @@ -34,8 +34,8 @@ public function show($artifactId)
return $this->get(sprintf('/packages/artifacts/%s/', $artifactId));
}

public function showPackageArtifacts($packageName)
public function showPackageArtifacts($packageIdOrName)
{
return $this->get(sprintf('/packages/%s/artifacts/', $packageName));
return $this->get(sprintf('/packages/%s/artifacts/', $packageIdOrName));
}
}
6 changes: 3 additions & 3 deletions src/Api/VendorBundles/Packages.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,10 @@ public function addOrEditPackages($vendorBundleId, array $packages)

/**
* @param int $vendorBundleId
* @param string $packageName
* @param string|int $packageIdOrName
*/
public function removePackage($vendorBundleId, $packageName)
public function removePackage($vendorBundleId, $packageIdOrName)
{
return $this->delete(sprintf('/vendor-bundles/%s/packages/%s/', $vendorBundleId, $packageName));
return $this->delete(sprintf('/vendor-bundles/%s/packages/%s/', $vendorBundleId, $packageIdOrName));
}
}

0 comments on commit bca533e

Please sign in to comment.