mirror of
https://github.com/zhigang1992/DefinitelyTyped.git
synced 2026-04-09 22:40:18 +08:00
@google-cloud/storage - Added IAM typings (#18892)
This commit is contained in:
committed by
Mohamed Hegazy
parent
f6472a30b3
commit
d3baee33f2
@@ -396,3 +396,20 @@ export class TestFile {
|
||||
return this.file.setMetadata(metadata);
|
||||
}
|
||||
}
|
||||
|
||||
const testStorage = new TestStorage().bucket("examplebucketname");
|
||||
|
||||
testStorage.iam.getPolicy();
|
||||
|
||||
testStorage.iam.setPolicy({
|
||||
bindings: [
|
||||
{
|
||||
role: "roles/storage.admin",
|
||||
members: ['serviceAccount:myotherproject@appspot.gserviceaccount.com']
|
||||
}
|
||||
]
|
||||
});
|
||||
|
||||
testStorage.iam.testPermissions('storage.buckets.delete');
|
||||
|
||||
testStorage.iam.testPermissions(['storage.buckets.delete', 'storage.buckets.get']);
|
||||
|
||||
23
types/google-cloud__storage/index.d.ts
vendored
23
types/google-cloud__storage/index.d.ts
vendored
@@ -1,6 +1,7 @@
|
||||
// Type definitions for @google-cloud/storage 1.1
|
||||
// Project: https://github.com/GoogleCloudPlatform/google-cloud-node/tree/master/packages/storage
|
||||
// Definitions by: Brian Love <https://github.com/blove>
|
||||
// Nathan Brooker Perry <https://github.com/nbperry>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
/// <reference types="node" />
|
||||
@@ -28,6 +29,7 @@ declare namespace Storage {
|
||||
getFilesStream(query?: BucketQuery): ReadStream;
|
||||
getMetadata(): Promise<[BucketMetadata, Storage.ApiResponse]>;
|
||||
id: string;
|
||||
iam: Iam;
|
||||
makePrivate(options?: BucketPrivacyOptions): Promise<[File[]]>;
|
||||
makePublic(options?: BucketPrivacyOptions): Promise<[File[]]>;
|
||||
metadata: BucketMetadata;
|
||||
@@ -337,6 +339,27 @@ declare namespace Storage {
|
||||
interface ChannelConfig {
|
||||
address: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* This class allows you to get Identity Access Management information.
|
||||
*/
|
||||
class Iam {
|
||||
getPolicy(): Promise<IamPolicy>;
|
||||
setPolicy(policy: IamPolicy): Promise<[IamPolicy, ApiResponse]>;
|
||||
testPermissions(permission: string | string[]): Promise<[{[key: string]: boolean}, ApiResponse]>;
|
||||
}
|
||||
|
||||
/**
|
||||
* IAM policy
|
||||
*/
|
||||
interface IamPolicy {
|
||||
bindings: IamBinding[];
|
||||
}
|
||||
|
||||
interface IamBinding {
|
||||
role: string;
|
||||
members: string[];
|
||||
}
|
||||
}
|
||||
|
||||
declare function Storage(config?: Storage.ConfigurationObject): Storage.Storage;
|
||||
|
||||
Reference in New Issue
Block a user