1 | /*!
|
2 | * Copyright 2014 Google Inc. All Rights Reserved.
|
3 | *
|
4 | * Licensed under the Apache License, Version 2.0 (the "License");
|
5 | * you may not use this file except in compliance with the License.
|
6 | * You may obtain a copy of the License at
|
7 | *
|
8 | * http://www.apache.org/licenses/LICENSE-2.0
|
9 | *
|
10 | * Unless required by applicable law or agreed to in writing, software
|
11 | * distributed under the License is distributed on an "AS IS" BASIS,
|
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
13 | * See the License for the specific language governing permissions and
|
14 | * limitations under the License.
|
15 | */
|
16 | /// <reference types="node" />
|
17 | import { CallOptions, IamProtos } from 'google-gax';
|
18 | import { Omit, PubSub, RequestCallback, ResourceCallback } from './pubsub';
|
19 | export declare type Policy = {
|
20 | etag?: string | Buffer;
|
21 | } & Omit<IamProtos.google.iam.v1.IPolicy, 'etag'>;
|
22 | export declare type GetPolicyCallback = RequestCallback<Policy>;
|
23 | export declare type SetPolicyCallback = RequestCallback<Policy>;
|
24 | export declare type SetPolicyResponse = [Policy];
|
25 | export declare type GetPolicyResponse = [Policy];
|
26 | /**
|
27 | * Shows which IAM permissions is allowed.
|
28 | * The key to this object are the IAM permissions (string) and the values are
|
29 | * booleans, true if permissions are granted to the corresponding key.
|
30 | */
|
31 | export interface IamPermissionsMap {
|
32 | [key: string]: boolean;
|
33 | }
|
34 | export declare type TestIamPermissionsResponse = [IamPermissionsMap, IamProtos.google.iam.v1.ITestIamPermissionsResponse];
|
35 | export declare type TestIamPermissionsCallback = ResourceCallback<IamPermissionsMap, IamProtos.google.iam.v1.ITestIamPermissionsResponse>;
|
36 | /**
|
37 | * [IAM (Identity and Access
|
38 | * Management)](https://cloud.google.com/pubsub/access_control) allows you to
|
39 | * set permissions on individual resources and offers a wider range of roles:
|
40 | * editor, owner, publisher, subscriber, and viewer. This gives you greater
|
41 | * flexibility and allows you to set more fine-grained access control.
|
42 | *
|
43 | * For example:
|
44 | * * Grant access on a per-topic or per-subscription basis, rather than for
|
45 | * the whole Cloud project.
|
46 | * * Grant access with limited capabilities, such as to only publish messages
|
47 | * to a topic, or to only to consume messages from a subscription, but not
|
48 | * to delete the topic or subscription.
|
49 | *
|
50 | *
|
51 | * *The IAM access control features described in this document are Beta,
|
52 | * including the API methods to get and set IAM policies, and to test IAM
|
53 | * permissions. Cloud Pub/Sub's use of IAM features is not covered by any
|
54 | * SLA or deprecation policy, and may be subject to backward-incompatible
|
55 | * changes.*
|
56 | *
|
57 | * @class
|
58 | * @param {PubSub} pubsub PubSub Object.
|
59 | * @param {string} id The name of the topic or subscription.
|
60 | *
|
61 | * @see [Access Control Overview]{@link https://cloud.google.com/pubsub/access_control}
|
62 | * @see [What is Cloud IAM?]{@link https://cloud.google.com/iam/}
|
63 | *
|
64 | * @example
|
65 | * const {PubSub} = require('@google-cloud/pubsub');
|
66 | * const pubsub = new PubSub();
|
67 | *
|
68 | * const topic = pubsub.topic('my-topic');
|
69 | * // topic.iam
|
70 | *
|
71 | * const subscription = pubsub.subscription('my-subscription');
|
72 | * // subscription.iam
|
73 | */
|
74 | export declare class IAM {
|
75 | pubsub: PubSub;
|
76 | request: typeof PubSub.prototype.request;
|
77 | id: string;
|
78 | constructor(pubsub: PubSub, id: string);
|
79 | getPolicy(gaxOpts?: CallOptions): Promise<GetPolicyResponse>;
|
80 | getPolicy(callback: GetPolicyCallback): void;
|
81 | getPolicy(gaxOpts: CallOptions, callback: GetPolicyCallback): void;
|
82 | setPolicy(policy: Policy, gaxOpts?: CallOptions): Promise<SetPolicyResponse>;
|
83 | setPolicy(policy: Policy, gaxOpts: CallOptions, callback: SetPolicyCallback): void;
|
84 | setPolicy(policy: Policy, callback: SetPolicyCallback): void;
|
85 | testPermissions(permissions: string | string[], gaxOpts?: CallOptions): Promise<TestIamPermissionsResponse>;
|
86 | testPermissions(permissions: string | string[], gaxOpts: CallOptions, callback: TestIamPermissionsCallback): void;
|
87 | testPermissions(permissions: string | string[], callback: TestIamPermissionsCallback): void;
|
88 | }
|