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.
opts
ClientOptions
gaxInstance
typeof gax
| typeof fallback
: loaded instance of google-gax
. Useful if you need to avoid loading the default gRPC version and want to use the fallback HTTP implementation. Load only fallback version and pass it to the constructor: ``` const gax = require('google-gax/build/src/fallback'); // avoids loading google-gax with gRPC const client = new PoliciesClient({fallback: true}, gax); ```
Properties
apiEndpoint
get
apiEndpoint
()
:
string
;
The DNS address for this API service.
apiEndpoint
static
get
apiEndpoint
()
:
string
;
The DNS address for this API service - same as servicePath.
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.
universeDomain
get
universeDomain
()
:
string
;
warn
warn
:
(
code
:
string
,
message
:
string
,
warnType
?:
string
)
=
>
void
;
Methods
cancelOperation(request, optionsOrCallback, callback)
cancelOperation
(
request
:
protos
.
google
.
longrunning
.
CancelOperationRequest
,
optionsOrCallback
?:
gax
.
CallOptions
|
Callback<protos
.
google
.
longrunning
.
CancelOperationRequest
,
protos
.
google
.
protobuf
.
Empty
,
{}
|
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
.
request
optionsOrCallback
CallOptions
| Callback
< protos.google.longrunning.CancelOperationRequest
, protos.google.protobuf.Empty
, {} | undefined | null>
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.
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()
.
name
string
The operation name that will be passed.
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 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()
.
name
string
The operation name that will be passed.
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 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()
.
name
string
The operation name that will be passed.
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 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.
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.
request
options
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 promise()
method returns a promise you can await
for. Please see the documentation
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
();
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
;
request
options
CallOptions
callback
Callback
< LROperation
< protos.google.iam.v2.IPolicy
, protos.google.iam.v2.IPolicyOperationMetadata
>, protos.google.longrunning.IOperation
| null | undefined, {} | null | undefined>
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
;
request
callback
Callback
< LROperation
< protos.google.iam.v2.IPolicy
, protos.google.iam.v2.IPolicyOperationMetadata
>, protos.google.longrunning.IOperation
| null | undefined, {} | null | undefined>
void
deleteOperation(request, optionsOrCallback, callback)
deleteOperation
(
request
:
protos
.
google
.
longrunning
.
DeleteOperationRequest
,
optionsOrCallback
?:
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
.
request
optionsOrCallback
CallOptions
| Callback
< protos.google.protobuf.Empty
, protos.google.longrunning.DeleteOperationRequest
, {} | null | undefined>
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.
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.
request
options
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 promise()
method returns a promise you can await
for. Please see the documentation
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
();
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
;
request
options
CallOptions
callback
Callback
< LROperation
< protos.google.iam.v2.IPolicy
, protos.google.iam.v2.IPolicyOperationMetadata
>, protos.google.longrunning.IOperation
| null | undefined, {} | null | undefined>
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
;
request
callback
Callback
< LROperation
< protos.google.iam.v2.IPolicy
, protos.google.iam.v2.IPolicyOperationMetadata
>, protos.google.longrunning.IOperation
| null | undefined, {} | null | undefined>
void
getOperation(request, optionsOrCallback, callback)
getOperation
(
request
:
protos
.
google
.
longrunning
.
GetOperationRequest
,
optionsOrCallback
?:
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.
request
optionsOrCallback
CallOptions
| Callback
< protos.google.longrunning.Operation
, protos.google.longrunning.GetOperationRequest
, {} | null | undefined>
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.
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.
request
options
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 Policy . Please see the documentation 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
;
request
options
CallOptions
callback
Callback
< protos.google.iam.v2.IPolicy
, protos.google.iam.v2.IGetPolicyRequest
| null | undefined, {} | null | undefined>
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
;
request
callback
Callback
< protos.google.iam.v2.IPolicy
, protos.google.iam.v2.IGetPolicyRequest
| null | undefined, {} | null | undefined>
void
getProjectId()
getProjectId
()
:
Promise<string>
;
Promise
<string>
getProjectId(callback)
getProjectId
(
callback
:
Callback<string
,
undefined
,
undefined
> )
:
void
;
callback
Callback
<string, undefined, undefined>
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.
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
.
IOperation
> ;
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.
request
options
CallOptions
Optional parameters. You can override the default settings for this call, e.g, timeout, retries, paginations, etc. See gax.CallOptions for the details.
AsyncIterable
< protos.google.longrunning.IOperation
>
{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.
request
options
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 Policy
. 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 listPoliciesAsync()
method described below for async iteration which you can stop as needed. Please see the documentation
for more details and examples.
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
;
request
options
CallOptions
callback
PaginationCallback
< protos.google.iam.v2.IListPoliciesRequest
, protos.google.iam.v2.IListPoliciesResponse
| null | undefined, protos.google.iam.v2.IPolicy
>
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
;
request
callback
PaginationCallback
< protos.google.iam.v2.IListPoliciesRequest
, protos.google.iam.v2.IListPoliciesResponse
| null | undefined, protos.google.iam.v2.IPolicy
>
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.
request
options
AsyncIterable
< protos.google.iam.v2.IPolicy
>
{Object} An iterable Object that allows async iteration . When you iterate the returned iterable, each element will be an object representing Policy . 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 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
=
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 listPolicies
, but returns a NodeJS Stream object.
request
options
Transform
{Stream} An object stream which emits an object representing Policy
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 listPoliciesAsync()
method described below for async iteration which you can stop as needed. Please see the documentation
for more details and examples.
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.
request
options
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 promise()
method returns a promise you can await
for. Please see the documentation
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
();
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
;
request
options
CallOptions
callback
Callback
< LROperation
< protos.google.iam.v2.IPolicy
, protos.google.iam.v2.IPolicyOperationMetadata
>, protos.google.longrunning.IOperation
| null | undefined, {} | null | undefined>
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
;
request
callback
Callback
< LROperation
< protos.google.iam.v2.IPolicy
, protos.google.iam.v2.IPolicyOperationMetadata
>, protos.google.longrunning.IOperation
| null | undefined, {} | null | undefined>
void