@google-cloud/storage - Added IAM typings (#18892)

This commit is contained in:
Nathan Perry
2017-08-14 14:50:33 -04:00
committed by Mohamed Hegazy
parent f6472a30b3
commit d3baee33f2
2 changed files with 40 additions and 0 deletions

View File

@@ -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']);

View File

@@ -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;