|
72 | 72 | * [List all customers with access to a package](#list-all-customers-with-access-to-a-package) |
73 | 73 | * [Create an artifact package file](#create-an-artifact-package-file) |
74 | 74 | * [Create an artifact package](#create-an-artifact-package) |
75 | | - * [Update artifact files of a package](#update-artifact-files-of-a-package) |
| 75 | + * [Add an artifact file to an existing package](#add-an-artifact-file-to-an-existing-package) |
| 76 | + * [Update or replace artifact files of a package](#update-or-replace-artifact-files-of-a-package) |
76 | 77 | * [Credential](#credential) |
77 | 78 | * [List an organization's credentials](#list-an-organizations-credentials) |
78 | 79 | * [Show a credential](#show-a-credential) |
|
98 | 99 | * [Validate incoming webhook payloads](#validate-incoming-webhook-payloads) |
99 | 100 | * [License](#license) |
100 | 101 |
|
101 | | -<!-- Added by: wissem, at: Tue Jul 21 10:32:47 CEST 2020 --> |
| 102 | +<!-- Added by: wissem, at: Fri Oct 16 14:23:54 CEST 2020 --> |
102 | 103 |
|
103 | 104 | <!--te--> |
104 | 105 |
|
@@ -597,13 +598,34 @@ $response = $client->packages()->artifacts()->create($file, 'application/zip', $ |
597 | 598 | $artifactId = $response['id']; |
598 | 599 | $client->packages()->createArtifactPackage([$artifactId]); |
599 | 600 | ``` |
600 | | -#### Update artifact files of a package |
| 601 | +#### Add an artifact file to an existing package |
601 | 602 |
|
602 | 603 | ```php |
603 | | -$result = $client->packages()->artifacts()->showPackageArtifacts('acme-website/package'); // get artifact files details for a package |
604 | | -$artifactFileIds = [42, 43]; |
605 | | -$client->packages()->editArtifactPackage('acme-website/package', $artifactFileIds); |
| 604 | +$packageName = 'acme/artifact'; |
| 605 | +$fileName = 'package1.zip'; |
| 606 | +$file = file_get_contents($fileName); |
| 607 | +$client->packages()->artifacts()->add($packageName, $file, 'application/zip', $fileName); |
606 | 608 | ``` |
| 609 | +#### Update or replace artifact files of a package |
| 610 | + |
| 611 | +```php |
| 612 | +// in case you want to replace the artifact file with a newly uploaded one |
| 613 | +// 1. get current artifact ids |
| 614 | +$result = $client->packages()->artifacts()->showPackageArtifacts('acme-website/package'); |
| 615 | +$artifactIds = array_column($result, 'id'); // [41, 42] |
| 616 | + |
| 617 | +// 2. upload the new artifact file |
| 618 | +$fileName = 'package1.zip'; |
| 619 | +$file = file_get_contents($fileName); |
| 620 | +$response = $client->packages()->artifacts()->create($file, 'application/zip', $fileName); |
| 621 | +$newArtifactId = $response['id']; |
| 622 | + |
| 623 | +// 3. let's say we don't want to have the artifact file id = 41 and use the newly uploaded file instead |
| 624 | +$artifactIds = array_shift($artifactIds); |
| 625 | +$artifactIds[] = $newArtifactId; |
| 626 | +$client->packages()->editArtifactPackage('acme-website/package', $artifactIds); |
| 627 | +``` |
| 628 | + |
607 | 629 | ### Credential |
608 | 630 |
|
609 | 631 | #### List an organization's credentials |
|
0 commit comments