An interface for managing Identity and Access Management (IAM) policies. v2
Package
@google-cloud/iamConstructors
(constructor)(opts, gaxInstance)
constructor(opts?: ClientOptions, gaxInstance?: typeof gax | typeof gax.fallback);
Construct an instance of PoliciesClient.
Parameters | |
---|---|
Name | Description |
opts |
ClientOptions
|
gaxInstance |
typeof gax | typeof gax.fallback
: loaded instance of |
Properties
apiEndpoint
static get apiEndpoint(): string;
The DNS address for this API service - same as servicePath(), exists for compatibility reasons.
auth
auth: gax.GoogleAuth;
descriptors
descriptors: Descriptors;
innerApiCalls
innerApiCalls: {
[name: string]: Function;
};
operationsClient
operationsClient: gax.OperationsClient;
policiesStub
policiesStub?: Promise<{
[name: string]: Function;
}>;
port
static get port(): number;
The port for this API service.
scopes
static get scopes(): string[];
The scopes needed to make gRPC calls for every method defined in this service.
servicePath
static get servicePath(): string;
The DNS address for this API service.
warn
warn: (code: string, message: string, warnType?: string) => void;
Methods
cancelOperation(request, options, callback)
cancelOperation(request: protos.google.longrunning.CancelOperationRequest, options?: gax.CallOptions | Callback<protos.google.protobuf.Empty, protos.google.longrunning.CancelOperationRequest, {} | undefined | null>, callback?: Callback<protos.google.longrunning.CancelOperationRequest, protos.google.protobuf.Empty, {} | undefined | null>): Promise<protos.google.protobuf.Empty>;
Starts asynchronous cancellation on a long-running operation. The server makes a best effort to cancel the operation, but success is not guaranteed. If the server doesn't support this method, it returns google.rpc.Code.UNIMPLEMENTED
. Clients can use or other methods to check whether the cancellation succeeded or whether the operation completed despite cancellation. On successful cancellation, the operation is not deleted; instead, it becomes an operation with an value with a of 1, corresponding to Code.CANCELLED
.
Parameters | |
---|---|
Name | Description |
request |
protos.google.longrunning.CancelOperationRequest
The request object that will be sent. |
options |
gax.CallOptions | Callback<protos.google.protobuf.Empty, protos.google.longrunning.CancelOperationRequest, {} | undefined | null>
Optional parameters. You can override the default settings for this call, e.g, timeout, retries, paginations, etc. See gax.CallOptions for the details. |
callback |
Callback<protos.google.longrunning.CancelOperationRequest, protos.google.protobuf.Empty, {} | undefined | null>
The function which will be called with the result of the API call. {Promise} - The promise which resolves when API call finishes. The promise has a method named "cancel" which cancels the ongoing API call. |
Returns | |
---|---|
Type | Description |
Promise<protos.google.protobuf.Empty> |
const client = longrunning.operationsClient();
await client.cancelOperation({name: ''});
checkCreatePolicyProgress(name)
checkCreatePolicyProgress(name: string): Promise<LROperation<protos.google.iam.v2.Policy, protos.google.iam.v2.PolicyOperationMetadata>>;
Check the status of the long running operation returned by createPolicy()
.
Parameter | |
---|---|
Name | Description |
name |
string
The operation name that will be passed. |
Returns | |
---|---|
Type | Description |
Promise<LROperation<protos.google.iam.v2.Policy, protos.google.iam.v2.PolicyOperationMetadata>> | {Promise} - The promise which resolves to an object. The decoded operation object has result and metadata field to get information from. Please see the [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) for more details and examples. |
/**
* This snippet has been automatically generated and should be regarded as a code template only.
* It will require modifications to work.
* It may require correct/in-range values for request initialization.
* TODO(developer): Uncomment these variables before running the sample.
*/
/**
* Required. The resource that the policy is attached to, along with the kind of policy
* to create. Format: `policies/{attachment_point}/denypolicies`
* The attachment point is identified by its URL-encoded full resource name,
* which means that the forward-slash character, `/`, must be written as
* `%2F`. For example,
* `policies/cloudresourcemanager.googleapis.com%2Fprojects%2Fmy-project/denypolicies`.
* For organizations and folders, use the numeric ID in the full resource
* name. For projects, you can use the alphanumeric or the numeric ID.
*/
// const parent = 'abc123'
/**
* Required. The policy to create.
*/
// const policy = {}
/**
* The ID to use for this policy, which will become the final component of
* the policy's resource name. The ID must contain 3 to 63 characters. It can
* contain lowercase letters and numbers, as well as dashes (`-`) and periods
* (`.`). The first character must be a lowercase letter.
*/
// const policyId = 'abc123'
// Imports the Iam library
const {PoliciesClient} = require('@google-cloud/iam').v2;
// Instantiates a client
const iamClient = new PoliciesClient();
async function callCreatePolicy() {
// Construct request
const request = {
parent,
policy,
};
// Run request
const [operation] = await iamClient.createPolicy(request);
const [response] = await operation.promise();
console.log(response);
}
callCreatePolicy();
checkDeletePolicyProgress(name)
checkDeletePolicyProgress(name: string): Promise<LROperation<protos.google.iam.v2.Policy, protos.google.iam.v2.PolicyOperationMetadata>>;
Check the status of the long running operation returned by deletePolicy()
.
Parameter | |
---|---|
Name | Description |
name |
string
The operation name that will be passed. |
Returns | |
---|---|
Type | Description |
Promise<LROperation<protos.google.iam.v2.Policy, protos.google.iam.v2.PolicyOperationMetadata>> | {Promise} - The promise which resolves to an object. The decoded operation object has result and metadata field to get information from. Please see the [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) for more details and examples. |
/**
* This snippet has been automatically generated and should be regarded as a code template only.
* It will require modifications to work.
* It may require correct/in-range values for request initialization.
* TODO(developer): Uncomment these variables before running the sample.
*/
/**
* Required. The resource name of the policy to delete. Format:
* `policies/{attachment_point}/denypolicies/{policy_id}`
* Use the URL-encoded full resource name, which means that the forward-slash
* character, `/`, must be written as `%2F`. For example,
* `policies/cloudresourcemanager.googleapis.com%2Fprojects%2Fmy-project/denypolicies/my-policy`.
* For organizations and folders, use the numeric ID in the full resource
* name. For projects, you can use the alphanumeric or the numeric ID.
*/
// const name = 'abc123'
/**
* Optional. The expected `etag` of the policy to delete. If the value does not match
* the value that is stored in IAM, the request fails with a `409` error code
* and `ABORTED` status.
* If you omit this field, the policy is deleted regardless of its current
* `etag`.
*/
// const etag = 'abc123'
// Imports the Iam library
const {PoliciesClient} = require('@google-cloud/iam').v2;
// Instantiates a client
const iamClient = new PoliciesClient();
async function callDeletePolicy() {
// Construct request
const request = {
name,
};
// Run request
const [operation] = await iamClient.deletePolicy(request);
const [response] = await operation.promise();
console.log(response);
}
callDeletePolicy();
checkUpdatePolicyProgress(name)
checkUpdatePolicyProgress(name: string): Promise<LROperation<protos.google.iam.v2.Policy, protos.google.iam.v2.PolicyOperationMetadata>>;
Check the status of the long running operation returned by updatePolicy()
.
Parameter | |
---|---|
Name | Description |
name |
string
The operation name that will be passed. |
Returns | |
---|---|
Type | Description |
Promise<LROperation<protos.google.iam.v2.Policy, protos.google.iam.v2.PolicyOperationMetadata>> | {Promise} - The promise which resolves to an object. The decoded operation object has result and metadata field to get information from. Please see the [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) for more details and examples. |
/**
* This snippet has been automatically generated and should be regarded as a code template only.
* It will require modifications to work.
* It may require correct/in-range values for request initialization.
* TODO(developer): Uncomment these variables before running the sample.
*/
/**
* Required. The policy to update.
* To prevent conflicting updates, the `etag` value must match the value that
* is stored in IAM. If the `etag` values do not match, the request fails with
* a `409` error code and `ABORTED` status.
*/
// const policy = {}
// Imports the Iam library
const {PoliciesClient} = require('@google-cloud/iam').v2;
// Instantiates a client
const iamClient = new PoliciesClient();
async function callUpdatePolicy() {
// Construct request
const request = {
policy,
};
// Run request
const [operation] = await iamClient.updatePolicy(request);
const [response] = await operation.promise();
console.log(response);
}
callUpdatePolicy();
close()
close(): Promise<void>;
Terminate the gRPC channel and close the client.
The client will no longer be usable and all future behavior is undefined.
Returns | |
---|---|
Type | Description |
Promise<void> | {Promise} A promise that resolves when the client is closed. |
createPolicy(request, options)
createPolicy(request?: protos.google.iam.v2.ICreatePolicyRequest, options?: CallOptions): Promise<[
LROperation<protos.google.iam.v2.IPolicy, protos.google.iam.v2.IPolicyOperationMetadata>,
protos.google.longrunning.IOperation | undefined,
{} | undefined
]>;
Creates a policy.
Parameters | |
---|---|
Name | Description |
request |
protos.google.iam.v2.ICreatePolicyRequest
The request object that will be sent. |
options |
CallOptions
Call options. See CallOptions for more details. |
Returns | |
---|---|
Type | Description |
Promise<[
LROperation<protos.google.iam.v2.IPolicy, protos.google.iam.v2.IPolicyOperationMetadata>,
protos.google.longrunning.IOperation | undefined,
{} | undefined
]> | {Promise} - The promise which resolves to an array. The first element of the array is an object representing a long running operation. Its |
/**
* This snippet has been automatically generated and should be regarded as a code template only.
* It will require modifications to work.
* It may require correct/in-range values for request initialization.
* TODO(developer): Uncomment these variables before running the sample.
*/
/**
* Required. The resource that the policy is attached to, along with the kind of policy
* to create. Format: `policies/{attachment_point}/denypolicies`
* The attachment point is identified by its URL-encoded full resource name,
* which means that the forward-slash character, `/`, must be written as
* `%2F`. For example,
* `policies/cloudresourcemanager.googleapis.com%2Fprojects%2Fmy-project/denypolicies`.
* For organizations and folders, use the numeric ID in the full resource
* name. For projects, you can use the alphanumeric or the numeric ID.
*/
// const parent = 'abc123'
/**
* Required. The policy to create.
*/
// const policy = {}
/**
* The ID to use for this policy, which will become the final component of
* the policy's resource name. The ID must contain 3 to 63 characters. It can
* contain lowercase letters and numbers, as well as dashes (`-`) and periods
* (`.`). The first character must be a lowercase letter.
*/
// const policyId = 'abc123'
// Imports the Iam library
const {PoliciesClient} = require('@google-cloud/iam').v2;
// Instantiates a client
const iamClient = new PoliciesClient();
async function callCreatePolicy() {
// Construct request
const request = {
parent,
policy,
};
// Run request
const [operation] = await iamClient.createPolicy(request);
const [response] = await operation.promise();
console.log(response);
}
callCreatePolicy();
createPolicy(request, options, callback)
createPolicy(request: protos.google.iam.v2.ICreatePolicyRequest, options: CallOptions, callback: Callback<LROperation<protos.google.iam.v2.IPolicy, protos.google.iam.v2.IPolicyOperationMetadata>, protos.google.longrunning.IOperation | null | undefined, {} | null | undefined>): void;
Parameters | |
---|---|
Name | Description |
request |
protos.google.iam.v2.ICreatePolicyRequest
|
options |
CallOptions
|
callback |
Callback<LROperation<protos.google.iam.v2.IPolicy, protos.google.iam.v2.IPolicyOperationMetadata>, protos.google.longrunning.IOperation | null | undefined, {} | null | undefined>
|
Returns | |
---|---|
Type | Description |
void |
createPolicy(request, callback)
createPolicy(request: protos.google.iam.v2.ICreatePolicyRequest, callback: Callback<LROperation<protos.google.iam.v2.IPolicy, protos.google.iam.v2.IPolicyOperationMetadata>, protos.google.longrunning.IOperation | null | undefined, {} | null | undefined>): void;
Parameters | |
---|---|
Name | Description |
request |
protos.google.iam.v2.ICreatePolicyRequest
|
callback |
Callback<LROperation<protos.google.iam.v2.IPolicy, protos.google.iam.v2.IPolicyOperationMetadata>, protos.google.longrunning.IOperation | null | undefined, {} | null | undefined>
|
Returns | |
---|---|
Type | Description |
void |
deleteOperation(request, options, callback)
deleteOperation(request: protos.google.longrunning.DeleteOperationRequest, options?: gax.CallOptions | Callback<protos.google.protobuf.Empty, protos.google.longrunning.DeleteOperationRequest, {} | null | undefined>, callback?: Callback<protos.google.protobuf.Empty, protos.google.longrunning.DeleteOperationRequest, {} | null | undefined>): Promise<protos.google.protobuf.Empty>;
Deletes a long-running operation. This method indicates that the client is no longer interested in the operation result. It does not cancel the operation. If the server doesn't support this method, it returns google.rpc.Code.UNIMPLEMENTED
.
Parameters | |
---|---|
Name | Description |
request |
protos.google.longrunning.DeleteOperationRequest
The request object that will be sent. |
options |
gax.CallOptions | Callback<protos.google.protobuf.Empty, protos.google.longrunning.DeleteOperationRequest, {} | null | undefined>
Optional parameters. You can override the default settings for this call, e.g, timeout, retries, paginations, etc. See gax.CallOptions for the details. |
callback |
Callback<protos.google.protobuf.Empty, protos.google.longrunning.DeleteOperationRequest, {} | null | undefined>
The function which will be called with the result of the API call. {Promise} - The promise which resolves when API call finishes. The promise has a method named "cancel" which cancels the ongoing API call. |
Returns | |
---|---|
Type | Description |
Promise<protos.google.protobuf.Empty> |
const client = longrunning.operationsClient();
await client.deleteOperation({name: ''});
deletePolicy(request, options)
deletePolicy(request?: protos.google.iam.v2.IDeletePolicyRequest, options?: CallOptions): Promise<[
LROperation<protos.google.iam.v2.IPolicy, protos.google.iam.v2.IPolicyOperationMetadata>,
protos.google.longrunning.IOperation | undefined,
{} | undefined
]>;
Deletes a policy. This action is permanent.
Parameters | |
---|---|
Name | Description |
request |
protos.google.iam.v2.IDeletePolicyRequest
The request object that will be sent. |
options |
CallOptions
Call options. See CallOptions for more details. |
Returns | |
---|---|
Type | Description |
Promise<[
LROperation<protos.google.iam.v2.IPolicy, protos.google.iam.v2.IPolicyOperationMetadata>,
protos.google.longrunning.IOperation | undefined,
{} | undefined
]> | {Promise} - The promise which resolves to an array. The first element of the array is an object representing a long running operation. Its |
/**
* This snippet has been automatically generated and should be regarded as a code template only.
* It will require modifications to work.
* It may require correct/in-range values for request initialization.
* TODO(developer): Uncomment these variables before running the sample.
*/
/**
* Required. The resource name of the policy to delete. Format:
* `policies/{attachment_point}/denypolicies/{policy_id}`
* Use the URL-encoded full resource name, which means that the forward-slash
* character, `/`, must be written as `%2F`. For example,
* `policies/cloudresourcemanager.googleapis.com%2Fprojects%2Fmy-project/denypolicies/my-policy`.
* For organizations and folders, use the numeric ID in the full resource
* name. For projects, you can use the alphanumeric or the numeric ID.
*/
// const name = 'abc123'
/**
* Optional. The expected `etag` of the policy to delete. If the value does not match
* the value that is stored in IAM, the request fails with a `409` error code
* and `ABORTED` status.
* If you omit this field, the policy is deleted regardless of its current
* `etag`.
*/
// const etag = 'abc123'
// Imports the Iam library
const {PoliciesClient} = require('@google-cloud/iam').v2;
// Instantiates a client
const iamClient = new PoliciesClient();
async function callDeletePolicy() {
// Construct request
const request = {
name,
};
// Run request
const [operation] = await iamClient.deletePolicy(request);
const [response] = await operation.promise();
console.log(response);
}
callDeletePolicy();
deletePolicy(request, options, callback)
deletePolicy(request: protos.google.iam.v2.IDeletePolicyRequest, options: CallOptions, callback: Callback<LROperation<protos.google.iam.v2.IPolicy, protos.google.iam.v2.IPolicyOperationMetadata>, protos.google.longrunning.IOperation | null | undefined, {} | null | undefined>): void;
Parameters | |
---|---|
Name | Description |
request |
protos.google.iam.v2.IDeletePolicyRequest
|
options |
CallOptions
|
callback |
Callback<LROperation<protos.google.iam.v2.IPolicy, protos.google.iam.v2.IPolicyOperationMetadata>, protos.google.longrunning.IOperation | null | undefined, {} | null | undefined>
|
Returns | |
---|---|
Type | Description |
void |
deletePolicy(request, callback)
deletePolicy(request: protos.google.iam.v2.IDeletePolicyRequest, callback: Callback<LROperation<protos.google.iam.v2.IPolicy, protos.google.iam.v2.IPolicyOperationMetadata>, protos.google.longrunning.IOperation | null | undefined, {} | null | undefined>): void;
Parameters | |
---|---|
Name | Description |
request |
protos.google.iam.v2.IDeletePolicyRequest
|
callback |
Callback<LROperation<protos.google.iam.v2.IPolicy, protos.google.iam.v2.IPolicyOperationMetadata>, protos.google.longrunning.IOperation | null | undefined, {} | null | undefined>
|
Returns | |
---|---|
Type | Description |
void |
getOperation(request, options, callback)
getOperation(request: protos.google.longrunning.GetOperationRequest, options?: gax.CallOptions | Callback<protos.google.longrunning.Operation, protos.google.longrunning.GetOperationRequest, {} | null | undefined>, callback?: Callback<protos.google.longrunning.Operation, protos.google.longrunning.GetOperationRequest, {} | null | undefined>): Promise<[protos.google.longrunning.Operation]>;
Gets the latest state of a long-running operation. Clients can use this method to poll the operation result at intervals as recommended by the API service.
Parameters | |
---|---|
Name | Description |
request |
protos.google.longrunning.GetOperationRequest
The request object that will be sent. |
options |
gax.CallOptions | Callback<protos.google.longrunning.Operation, protos.google.longrunning.GetOperationRequest, {} | null | undefined>
Optional parameters. You can override the default settings for this call, e.g, timeout, retries, paginations, etc. See gax.CallOptions for the details. |
callback |
Callback<protos.google.longrunning.Operation, protos.google.longrunning.GetOperationRequest, {} | null | undefined>
The function which will be called with the result of the API call. The second parameter to the callback is an object representing . {Promise} - The promise which resolves to an array. The first element of the array is an object representing . The promise has a method named "cancel" which cancels the ongoing API call. |
Returns | |
---|---|
Type | Description |
Promise<[protos.google.longrunning.Operation]> |
const client = longrunning.operationsClient();
const name = '';
const [response] = await client.getOperation({name});
// doThingsWith(response)
getPolicy(request, options)
getPolicy(request?: protos.google.iam.v2.IGetPolicyRequest, options?: CallOptions): Promise<[
protos.google.iam.v2.IPolicy,
protos.google.iam.v2.IGetPolicyRequest | undefined,
{} | undefined
]>;
Gets a policy.
Parameters | |
---|---|
Name | Description |
request |
protos.google.iam.v2.IGetPolicyRequest
The request object that will be sent. |
options |
CallOptions
Call options. See CallOptions for more details. |
Returns | |
---|---|
Type | Description |
Promise<[
protos.google.iam.v2.IPolicy,
protos.google.iam.v2.IGetPolicyRequest | undefined,
{} | undefined
]> | {Promise} - The promise which resolves to an array. The first element of the array is an object representing . Please see the [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) for more details and examples. |
/**
* This snippet has been automatically generated and should be regarded as a code template only.
* It will require modifications to work.
* It may require correct/in-range values for request initialization.
* TODO(developer): Uncomment these variables before running the sample.
*/
/**
* Required. The resource name of the policy to retrieve. Format:
* `policies/{attachment_point}/denypolicies/{policy_id}`
* Use the URL-encoded full resource name, which means that the forward-slash
* character, `/`, must be written as `%2F`. For example,
* `policies/cloudresourcemanager.googleapis.com%2Fprojects%2Fmy-project/denypolicies/my-policy`.
* For organizations and folders, use the numeric ID in the full resource
* name. For projects, you can use the alphanumeric or the numeric ID.
*/
// const name = 'abc123'
// Imports the Iam library
const {PoliciesClient} = require('@google-cloud/iam').v2;
// Instantiates a client
const iamClient = new PoliciesClient();
async function callGetPolicy() {
// Construct request
const request = {
name,
};
// Run request
const response = await iamClient.getPolicy(request);
console.log(response);
}
callGetPolicy();
getPolicy(request, options, callback)
getPolicy(request: protos.google.iam.v2.IGetPolicyRequest, options: CallOptions, callback: Callback<protos.google.iam.v2.IPolicy, protos.google.iam.v2.IGetPolicyRequest | null | undefined, {} | null | undefined>): void;
Parameters | |
---|---|
Name | Description |
request |
protos.google.iam.v2.IGetPolicyRequest
|
options |
CallOptions
|
callback |
Callback<protos.google.iam.v2.IPolicy, protos.google.iam.v2.IGetPolicyRequest | null | undefined, {} | null | undefined>
|
Returns | |
---|---|
Type | Description |
void |
getPolicy(request, callback)
getPolicy(request: protos.google.iam.v2.IGetPolicyRequest, callback: Callback<protos.google.iam.v2.IPolicy, protos.google.iam.v2.IGetPolicyRequest | null | undefined, {} | null | undefined>): void;
Parameters | |
---|---|
Name | Description |
request |
protos.google.iam.v2.IGetPolicyRequest
|
callback |
Callback<protos.google.iam.v2.IPolicy, protos.google.iam.v2.IGetPolicyRequest | null | undefined, {} | null | undefined>
|
Returns | |
---|---|
Type | Description |
void |
getProjectId()
getProjectId(): Promise<string>;
Returns | |
---|---|
Type | Description |
Promise<string> |
getProjectId(callback)
getProjectId(callback: Callback<string, undefined, undefined>): void;
Parameter | |
---|---|
Name | Description |
callback |
Callback<string, undefined, undefined>
|
Returns | |
---|---|
Type | Description |
void |
initialize()
initialize(): Promise<{
[name: string]: Function;
}>;
Initialize the client. Performs asynchronous operations (such as authentication) and prepares the client. This function will be called automatically when any class method is called for the first time, but if you need to initialize it before calling an actual method, feel free to call initialize() directly.
You can await on this method if you want to make sure the client is initialized.
Returns | |
---|---|
Type | Description |
Promise<{
[name: string]: Function;
}> | {Promise} A promise that resolves to an authenticated service stub. |
listOperationsAsync(request, options)
listOperationsAsync(request: protos.google.longrunning.ListOperationsRequest, options?: gax.CallOptions): AsyncIterable<protos.google.longrunning.ListOperationsResponse>;
Lists operations that match the specified filter in the request. If the server doesn't support this method, it returns UNIMPLEMENTED
. Returns an iterable object.
For-await-of syntax is used with the iterable to recursively get response element on-demand.
Parameters | |
---|---|
Name | Description |
request |
protos.google.longrunning.ListOperationsRequest
The request object that will be sent. |
options |
gax.CallOptions
Optional parameters. You can override the default settings for this call, e.g, timeout, retries, paginations, etc. See gax.CallOptions for the details. |
Returns | |
---|---|
Type | Description |
AsyncIterable<protos.google.longrunning.ListOperationsResponse> | {Object} An iterable Object that conforms to iteration protocols. |
const client = longrunning.operationsClient();
for await (const response of client.listOperationsAsync(request));
// doThingsWith(response)
listPolicies(request, options)
listPolicies(request?: protos.google.iam.v2.IListPoliciesRequest, options?: CallOptions): Promise<[
protos.google.iam.v2.IPolicy[],
protos.google.iam.v2.IListPoliciesRequest | null,
protos.google.iam.v2.IListPoliciesResponse
]>;
Retrieves the policies of the specified kind that are attached to a resource.
The response lists only policy metadata. In particular, policy rules are omitted.
Parameters | |
---|---|
Name | Description |
request |
protos.google.iam.v2.IListPoliciesRequest
The request object that will be sent. |
options |
CallOptions
Call options. See CallOptions for more details. |
Returns | |
---|---|
Type | Description |
Promise<[
protos.google.iam.v2.IPolicy[],
protos.google.iam.v2.IListPoliciesRequest | null,
protos.google.iam.v2.IListPoliciesResponse
]> | {Promise} - The promise which resolves to an array. The first element of the array is Array of . The client library will perform auto-pagination by default: it will call the API as many times as needed and will merge results from all the pages into this array. Note that it can affect your quota. We recommend using |
listPolicies(request, options, callback)
listPolicies(request: protos.google.iam.v2.IListPoliciesRequest, options: CallOptions, callback: PaginationCallback<protos.google.iam.v2.IListPoliciesRequest, protos.google.iam.v2.IListPoliciesResponse | null | undefined, protos.google.iam.v2.IPolicy>): void;
Parameters | |
---|---|
Name | Description |
request |
protos.google.iam.v2.IListPoliciesRequest
|
options |
CallOptions
|
callback |
PaginationCallback<protos.google.iam.v2.IListPoliciesRequest, protos.google.iam.v2.IListPoliciesResponse | null | undefined, protos.google.iam.v2.IPolicy>
|
Returns | |
---|---|
Type | Description |
void |
listPolicies(request, callback)
listPolicies(request: protos.google.iam.v2.IListPoliciesRequest, callback: PaginationCallback<protos.google.iam.v2.IListPoliciesRequest, protos.google.iam.v2.IListPoliciesResponse | null | undefined, protos.google.iam.v2.IPolicy>): void;
Parameters | |
---|---|
Name | Description |
request |
protos.google.iam.v2.IListPoliciesRequest
|
callback |
PaginationCallback<protos.google.iam.v2.IListPoliciesRequest, protos.google.iam.v2.IListPoliciesResponse | null | undefined, protos.google.iam.v2.IPolicy>
|
Returns | |
---|---|
Type | Description |
void |
listPoliciesAsync(request, options)
listPoliciesAsync(request?: protos.google.iam.v2.IListPoliciesRequest, options?: CallOptions): AsyncIterable<protos.google.iam.v2.IPolicy>;
Equivalent to listPolicies
, but returns an iterable object.
for
-await
-of
syntax is used with the iterable to get response elements on-demand.
Parameters | |
---|---|
Name | Description |
request |
protos.google.iam.v2.IListPoliciesRequest
The request object that will be sent. |
options |
CallOptions
Call options. See CallOptions for more details. |
Returns | |
---|---|
Type | Description |
AsyncIterable<protos.google.iam.v2.IPolicy> | {Object} An iterable Object that allows [async iteration](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols). When you iterate the returned iterable, each element will be an object representing . The API will be called under the hood as needed, once per the page, so you can stop the iteration when you don't need more results. Please see the [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) for more details and examples. |
/**
* This snippet has been automatically generated and should be regarded as a code template only.
* It will require modifications to work.
* It may require correct/in-range values for request initialization.
* TODO(developer): Uncomment these variables before running the sample.
*/
/**
* Required. The resource that the policy is attached to, along with the kind of policy
* to list. Format:
* `policies/{attachment_point}/denypolicies`
* The attachment point is identified by its URL-encoded full resource name,
* which means that the forward-slash character, `/`, must be written as
* `%2F`. For example,
* `policies/cloudresourcemanager.googleapis.com%2Fprojects%2Fmy-project/denypolicies`.
* For organizations and folders, use the numeric ID in the full resource
* name. For projects, you can use the alphanumeric or the numeric ID.
*/
// const parent = 'abc123'
/**
* The maximum number of policies to return. IAM ignores this value and uses
* the value 1000.
*/
// const pageSize = 1234
/**
* A page token received in a ListPoliciesResponse google.iam.v2.ListPoliciesResponse. Provide this token to
* retrieve the next page.
*/
// const pageToken = 'abc123'
// Imports the Iam library
const {PoliciesClient} = require('@google-cloud/iam').v2;
// Instantiates a client
const iamClient = new PoliciesClient();
async function callListPolicies() {
// Construct request
const request = {
parent,
};
// Run request
const iterable = await iamClient.listPoliciesAsync(request);
for await (const response of iterable) {
console.log(response);
}
}
callListPolicies();
listPoliciesStream(request, options)
listPoliciesStream(request?: protos.google.iam.v2.IListPoliciesRequest, options?: CallOptions): Transform;
Equivalent to method.name.toCamelCase()
, but returns a NodeJS Stream object.
Parameters | |
---|---|
Name | Description |
request |
protos.google.iam.v2.IListPoliciesRequest
The request object that will be sent. |
options |
CallOptions
Call options. See CallOptions for more details. |
Returns | |
---|---|
Type | Description |
Transform | {Stream} An object stream which emits an object representing on 'data' event. The client library will perform auto-pagination by default: it will call the API as many times as needed. Note that it can affect your quota. We recommend using |
updatePolicy(request, options)
updatePolicy(request?: protos.google.iam.v2.IUpdatePolicyRequest, options?: CallOptions): Promise<[
LROperation<protos.google.iam.v2.IPolicy, protos.google.iam.v2.IPolicyOperationMetadata>,
protos.google.longrunning.IOperation | undefined,
{} | undefined
]>;
Updates the specified policy.
You can update only the rules and the display name for the policy.
To update a policy, you should use a read-modify-write loop:
- Use to read the current version of the policy. 2. Modify the policy as needed. 3. Use
UpdatePolicy
to write the updated policy.
This pattern helps prevent conflicts between concurrent updates.
Parameters | |
---|---|
Name | Description |
request |
protos.google.iam.v2.IUpdatePolicyRequest
The request object that will be sent. |
options |
CallOptions
Call options. See CallOptions for more details. |
Returns | |
---|---|
Type | Description |
Promise<[
LROperation<protos.google.iam.v2.IPolicy, protos.google.iam.v2.IPolicyOperationMetadata>,
protos.google.longrunning.IOperation | undefined,
{} | undefined
]> | {Promise} - The promise which resolves to an array. The first element of the array is an object representing a long running operation. Its |
/**
* This snippet has been automatically generated and should be regarded as a code template only.
* It will require modifications to work.
* It may require correct/in-range values for request initialization.
* TODO(developer): Uncomment these variables before running the sample.
*/
/**
* Required. The policy to update.
* To prevent conflicting updates, the `etag` value must match the value that
* is stored in IAM. If the `etag` values do not match, the request fails with
* a `409` error code and `ABORTED` status.
*/
// const policy = {}
// Imports the Iam library
const {PoliciesClient} = require('@google-cloud/iam').v2;
// Instantiates a client
const iamClient = new PoliciesClient();
async function callUpdatePolicy() {
// Construct request
const request = {
policy,
};
// Run request
const [operation] = await iamClient.updatePolicy(request);
const [response] = await operation.promise();
console.log(response);
}
callUpdatePolicy();
updatePolicy(request, options, callback)
updatePolicy(request: protos.google.iam.v2.IUpdatePolicyRequest, options: CallOptions, callback: Callback<LROperation<protos.google.iam.v2.IPolicy, protos.google.iam.v2.IPolicyOperationMetadata>, protos.google.longrunning.IOperation | null | undefined, {} | null | undefined>): void;
Parameters | |
---|---|
Name | Description |
request |
protos.google.iam.v2.IUpdatePolicyRequest
|
options |
CallOptions
|
callback |
Callback<LROperation<protos.google.iam.v2.IPolicy, protos.google.iam.v2.IPolicyOperationMetadata>, protos.google.longrunning.IOperation | null | undefined, {} | null | undefined>
|
Returns | |
---|---|
Type | Description |
void |
updatePolicy(request, callback)
updatePolicy(request: protos.google.iam.v2.IUpdatePolicyRequest, callback: Callback<LROperation<protos.google.iam.v2.IPolicy, protos.google.iam.v2.IPolicyOperationMetadata>, protos.google.longrunning.IOperation | null | undefined, {} | null | undefined>): void;
Parameters | |
---|---|
Name | Description |
request |
protos.google.iam.v2.IUpdatePolicyRequest
|
callback |
Callback<LROperation<protos.google.iam.v2.IPolicy, protos.google.iam.v2.IPolicyOperationMetadata>, protos.google.longrunning.IOperation | null | undefined, {} | null | undefined>
|
Returns | |
---|---|
Type | Description |
void |