Skip to content

Commit

Permalink
fix: make CreateBucketRequest extend from BucketMetadata to allow all… (
Browse files Browse the repository at this point in the history
#2489)

* fix: make CreateBucketRequest extend from BucketMetadata to allow all fields to be set

* add internal-tooling to .eslintignore

* 🦉 Updates from OwlBot post-processor

See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md

---------

Co-authored-by: Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com>
  • Loading branch information
ddelgrosso1 and gcf-owl-bot[bot] authored Jul 8, 2024
1 parent c2e555c commit 013a5a4
Showing 1 changed file with 48 additions and 20 deletions.
68 changes: 48 additions & 20 deletions src/storage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,23 @@ export interface GetServiceAccountCallback {
}

export interface CreateBucketQuery {
enableObjectRetention: boolean;
predefinedAcl?:
| 'authenticatedRead'
| 'private'
| 'projectPrivate'
| 'publicRead'
| 'publicReadWrite';
predefinedDefaultObjectAcl?:
| 'authenticatedRead'
| 'bucketOwnerFullControl'
| 'bucketOwnerRead'
| 'private'
| 'projectPrivate'
| 'publicRead';
project: string;
projection?: 'full' | 'noAcl';
userProject: string;
enableObjectRetention: boolean;
}

export enum IdempotencyStrategy {
Expand Down Expand Up @@ -117,30 +131,30 @@ export interface AutoclassConfig {
terminalStorageClass?: 'NEARLINE' | 'ARCHIVE';
}

export interface CreateBucketRequest {
export interface CreateBucketRequest extends BucketMetadata {
archive?: boolean;
autoclass?: AutoclassConfig;
coldline?: boolean;
cors?: Cors[];
customPlacementConfig?: CustomPlacementConfig;
dataLocations?: string[];
dra?: boolean;
enableObjectRetention?: boolean;
hierarchicalNamespace?: {
enabled?: boolean;
};
iamConfiguration?: {
publicAccessPrevention?: string;
uniformBucketLevelAccess?: {
enabled?: boolean;
lockedTime?: string;
};
};
location?: string;
multiRegional?: boolean;
nearline?: boolean;
predefinedAcl?:
| 'authenticatedRead'
| 'private'
| 'projectPrivate'
| 'publicRead'
| 'publicReadWrite';
predefinedDefaultObjectAcl?:
| 'authenticatedRead'
| 'bucketOwnerFullControl'
| 'bucketOwnerRead'
| 'private'
| 'projectPrivate'
| 'publicRead';
projection?: 'full' | 'noAcl';
regional?: boolean;
requesterPays?: boolean;
retentionPolicy?: object;
rpo?: string;
standard?: boolean;
storageClass?: string;
Expand Down Expand Up @@ -887,8 +901,7 @@ export class Storage extends Service {
* Multi-Regional.
* @property {boolean} [nearline=false] Specify the storage class as Nearline.
* @property {boolean} [regional=false] Specify the storage class as Regional.
* @property {boolean} [requesterPays=false] **Early Access Testers Only**
* Force the use of the User Project metadata field to assign operational
* @property {boolean} [requesterPays=false] Force the use of the User Project metadata field to assign operational
* costs when an operation is made on a Bucket and its objects.
* @property {string} [rpo] For dual-region buckets, controls whether turbo
* replication is enabled (`ASYNC_TURBO`) or disabled (`DEFAULT`).
Expand Down Expand Up @@ -995,7 +1008,7 @@ export class Storage extends Service {
metadata = metadataOrCallback as CreateBucketRequest;
}

const body: CreateBucketRequest & {[index: string]: string | {}} = {
const body: CreateBucketRequest & {[index: string]: string | {} | null} = {
...metadata,
name,
};
Expand Down Expand Up @@ -1046,6 +1059,21 @@ export class Storage extends Service {
delete body.enableObjectRetention;
}

if (body.predefinedAcl) {
query.predefinedAcl = body.predefinedAcl;
delete body.predefinedAcl;
}

if (body.predefinedDefaultObjectAcl) {
query.predefinedDefaultObjectAcl = body.predefinedDefaultObjectAcl;
delete body.predefinedDefaultObjectAcl;
}

if (body.projection) {
query.projection = body.projection;
delete body.projection;
}

this.request(
{
method: 'POST',
Expand Down

0 comments on commit 013a5a4

Please sign in to comment.