Skip to content

Commit 4336882

Browse files
authored
fix(typescript): make SetLabelOptions optional (#766)
* test(bucket): location type system tests * docs(bucket): add verbiage about deprecated storage classes
1 parent 99e3b17 commit 4336882

File tree

2 files changed

+45
-4
lines changed

2 files changed

+45
-4
lines changed

src/bucket.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2599,7 +2599,7 @@ class Bucket extends ServiceObject {
25992599

26002600
setLabels(
26012601
labels: Labels,
2602-
options: SetLabelsOptions
2602+
options?: SetLabelsOptions
26032603
): Promise<SetLabelsResponse>;
26042604
setLabels(labels: Labels, callback: SetLabelsCallback): void;
26052605
setLabels(
@@ -2752,9 +2752,10 @@ class Bucket extends ServiceObject {
27522752
*
27532753
* @see [Storage Classes]{@link https://cloud.google.com/storage/docs/storage-classes}
27542754
*
2755-
* @param {string} storageClass The new storage class. (`multi_regional`,
2756-
* `regional`, `standard`, `nearline`, `coldline`, or
2757-
* `durable_reduced_availability`)
2755+
* @param {string} storageClass The new storage class. (`standard`,
2756+
* `nearline`, `coldline`, or `durable_reduced_availability`).
2757+
* **Note:** The legacy storage classes `multi_regional` and `regional`
2758+
* have been deprecated.
27582759
* @param {object} [options] Configuration options.
27592760
* @param {string} [options.userProject] - The ID of the project which will be
27602761
* billed for the request.

system-test/storage.ts

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -959,6 +959,46 @@ describe('storage', () => {
959959
assert.strictEqual(metadata.storageClass, 'MULTI_REGIONAL');
960960
});
961961

962+
describe('locationType', () => {
963+
const types = ['multi-region', 'region', 'dual-region'];
964+
965+
beforeEach(() => {
966+
delete bucket.metadata;
967+
});
968+
969+
it('should be available from getting a bucket', async () => {
970+
const [metadata] = await bucket.getMetadata();
971+
assert(types.includes(metadata.locationType));
972+
});
973+
974+
it('should be available from creating a bucket', async () => {
975+
const [bucket] = await storage.createBucket(generateName());
976+
assert(types.includes(bucket.metadata.locationType));
977+
return bucket.delete();
978+
});
979+
980+
it('should be available from listing buckets', async () => {
981+
const [buckets] = await storage.getBuckets();
982+
983+
assert(buckets.length > 0);
984+
985+
buckets.forEach(bucket => {
986+
assert(types.includes(bucket.metadata.locationType));
987+
});
988+
});
989+
990+
it('should be available from setting retention policy', async () => {
991+
await bucket.setRetentionPeriod(RETENTION_DURATION_SECONDS);
992+
assert(types.includes(bucket.metadata.locationType));
993+
await bucket.removeRetentionPeriod();
994+
});
995+
996+
it('should be available from updating a bucket', async () => {
997+
await bucket.setLabels({a: 'b'});
998+
assert(types.includes(bucket.metadata.locationType));
999+
});
1000+
});
1001+
9621002
describe('labels', () => {
9631003
const LABELS = {
9641004
label: 'labelvalue', // no caps or spaces allowed (?)

0 commit comments

Comments
 (0)