Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions src/Storage/Bucket.php
Original file line number Diff line number Diff line change
Expand Up @@ -532,6 +532,7 @@ public function delete(array $options = [])
* ```
*
* @see https://cloud.google.com/storage/docs/json_api/v1/buckets/patch Buckets patch API documentation.
* @see https://cloud.google.com/storage/docs/key-terms#bucket-labels Bucket Labels
*
* @param array $options [optional] {
* Configuration options.
Expand Down Expand Up @@ -571,6 +572,9 @@ public function delete(array $options = [])
* `"STANDARD"` and `"DURABLE_REDUCED_AVAILABILITY"`.
* @type array $versioning The bucket's versioning configuration.
* @type array $website The bucket's website configuration.
* @type array $labels The Bucket labels. Labels are represented as an
* array of keys and values. To remove an existing label, set its
* value to `null`.
* }
* @return array
*/
Expand Down
8 changes: 8 additions & 0 deletions src/Storage/Connection/ServiceDefinition/storage-v1.json
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,14 @@
"description": "The kind of item this is. For buckets, this is always storage#bucket.",
"default": "storage#bucket"
},
"labels": {
"type": "object",
"description": "User-provided labels, in key/value pairs.",
"additionalProperties": {
"type": "string",
"description": "An individual label entry."
}
},
"lifecycle": {
"type": "object",
"description": "The bucket's lifecycle configuration. See lifecycle management for more information.",
Expand Down
36 changes: 36 additions & 0 deletions tests/system/Storage/ManageBucketsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

/**
* @group storage
* @group storage-bucket
*/
class ManageBucketsTest extends StorageTestCase
{
Expand Down Expand Up @@ -122,4 +123,39 @@ public function testIam()
$test = $iam->testPermissions($permissions);
$this->assertEquals($permissions, $test);
}

public function testLabels()
{
$bucket = self::$bucket;

$bucket->update([
'labels' => [
'foo' => 'bar'
]
]);

$bucket->reload();

$this->assertEquals($bucket->info()['labels']['foo'], 'bar');

$bucket->update([
'labels' => [
'foo' => 'bat'
]
]);

$bucket->reload();

$this->assertEquals($bucket->info()['labels']['foo'], 'bat');

$bucket->update([
'labels' => [
'foo' => null
]
]);

$bucket->reload();

$this->assertFalse(isset($bucket->info()['labels']['foo']));
}
}