Google Cloud Identity and Access Management (IAM) v2 API - Class PoliciesClient (1.3.0)

public abstract class PoliciesClient

Reference documentation and code samples for the Google Cloud Identity and Access Management (IAM) v2 API class PoliciesClient.

Policies client wrapper, for convenient use.

Inheritance

object > PoliciesClient

Derived Types

Namespace

Google.Cloud.Iam.V2

Assembly

Google.Cloud.Iam.V2.dll

Remarks

An interface for managing Identity and Access Management (IAM) policies.

Properties

CreatePolicyOperationsClient

public virtual OperationsClient CreatePolicyOperationsClient { get; }

The long-running operations client for CreatePolicy.

Property Value
Type Description
OperationsClient

DefaultEndpoint

public static string DefaultEndpoint { get; }

The default endpoint for the Policies service, which is a host of "iam.googleapis.com" and a port of 443.

Property Value
Type Description
string

DefaultScopes

public static IReadOnlyList<string> DefaultScopes { get; }

The default Policies scopes.

Property Value
Type Description
IReadOnlyListstring
Remarks

The default Policies scopes are:

DeletePolicyOperationsClient

public virtual OperationsClient DeletePolicyOperationsClient { get; }

The long-running operations client for DeletePolicy.

Property Value
Type Description
OperationsClient

GrpcClient

public virtual Policies.PoliciesClient GrpcClient { get; }

The underlying gRPC Policies client

Property Value
Type Description
PoliciesPoliciesClient

ServiceMetadata

public static ServiceMetadata ServiceMetadata { get; }

The service metadata associated with this client type.

Property Value
Type Description
ServiceMetadata

UpdatePolicyOperationsClient

public virtual OperationsClient UpdatePolicyOperationsClient { get; }

The long-running operations client for UpdatePolicy.

Property Value
Type Description
OperationsClient

Methods

Create()

public static PoliciesClient Create()

Synchronously creates a PoliciesClient using the default credentials, endpoint and settings. To specify custom credentials or other settings, use PoliciesClientBuilder.

Returns
Type Description
PoliciesClient

The created PoliciesClient.

CreateAsync(CancellationToken)

public static Task<PoliciesClient> CreateAsync(CancellationToken cancellationToken = default)

Asynchronously creates a PoliciesClient using the default credentials, endpoint and settings. To specify custom credentials or other settings, use PoliciesClientBuilder.

Parameter
Name Description
cancellationToken CancellationToken

The CancellationToken to use while creating the client.

Returns
Type Description
TaskPoliciesClient

The task representing the created PoliciesClient.

CreatePolicy(CreatePolicyRequest, CallSettings)

public virtual Operation<Policy, PolicyOperationMetadata> CreatePolicy(CreatePolicyRequest request, CallSettings callSettings = null)

Creates a policy.

Parameters
Name Description
request CreatePolicyRequest

The request object containing all of the parameters for the API call.

callSettings CallSettings

If not null, applies overrides to this RPC call.

Returns
Type Description
OperationPolicyPolicyOperationMetadata

The RPC response.

Example
// Create client
PoliciesClient policiesClient = PoliciesClient.Create();
// Initialize request argument(s)
CreatePolicyRequest request = new CreatePolicyRequest
{
    Parent = "",
    Policy = new Policy(),
    PolicyId = "",
};
// Make the request
Operation<Policy, PolicyOperationMetadata> response = policiesClient.CreatePolicy(request);

// Poll until the returned long-running operation is complete
Operation<Policy, PolicyOperationMetadata> completedResponse = response.PollUntilCompleted();
// Retrieve the operation result
Policy result = completedResponse.Result;

// Or get the name of the operation
string operationName = response.Name;
// This name can be stored, then the long-running operation retrieved later by name
Operation<Policy, PolicyOperationMetadata> retrievedResponse = policiesClient.PollOnceCreatePolicy(operationName);
// Check if the retrieved long-running operation has completed
if (retrievedResponse.IsCompleted)
{
    // If it has completed, then access the result
    Policy retrievedResult = retrievedResponse.Result;
}

CreatePolicy(string, Policy, string, CallSettings)

public virtual Operation<Policy, PolicyOperationMetadata> CreatePolicy(string parent, Policy policy, string policyId, CallSettings callSettings = null)

Creates a policy.

Parameters
Name Description
parent string

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.

policy Policy

Required. The policy to create.

policyId string

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.

callSettings CallSettings

If not null, applies overrides to this RPC call.

Returns
Type Description
OperationPolicyPolicyOperationMetadata

The RPC response.

Example
// Create client
PoliciesClient policiesClient = PoliciesClient.Create();
// Initialize request argument(s)
string parent = "";
Policy policy = new Policy();
string policyId = "";
// Make the request
Operation<Policy, PolicyOperationMetadata> response = policiesClient.CreatePolicy(parent, policy, policyId);

// Poll until the returned long-running operation is complete
Operation<Policy, PolicyOperationMetadata> completedResponse = response.PollUntilCompleted();
// Retrieve the operation result
Policy result = completedResponse.Result;

// Or get the name of the operation
string operationName = response.Name;
// This name can be stored, then the long-running operation retrieved later by name
Operation<Policy, PolicyOperationMetadata> retrievedResponse = policiesClient.PollOnceCreatePolicy(operationName);
// Check if the retrieved long-running operation has completed
if (retrievedResponse.IsCompleted)
{
    // If it has completed, then access the result
    Policy retrievedResult = retrievedResponse.Result;
}

CreatePolicyAsync(CreatePolicyRequest, CallSettings)

public virtual Task<Operation<Policy, PolicyOperationMetadata>> CreatePolicyAsync(CreatePolicyRequest request, CallSettings callSettings = null)

Creates a policy.

Parameters
Name Description
request CreatePolicyRequest

The request object containing all of the parameters for the API call.

callSettings CallSettings

If not null, applies overrides to this RPC call.

Returns
Type Description
TaskOperationPolicyPolicyOperationMetadata

A Task containing the RPC response.

Example
// Create client
PoliciesClient policiesClient = await PoliciesClient.CreateAsync();
// Initialize request argument(s)
CreatePolicyRequest request = new CreatePolicyRequest
{
    Parent = "",
    Policy = new Policy(),
    PolicyId = "",
};
// Make the request
Operation<Policy, PolicyOperationMetadata> response = await policiesClient.CreatePolicyAsync(request);

// Poll until the returned long-running operation is complete
Operation<Policy, PolicyOperationMetadata> completedResponse = await response.PollUntilCompletedAsync();
// Retrieve the operation result
Policy result = completedResponse.Result;

// Or get the name of the operation
string operationName = response.Name;
// This name can be stored, then the long-running operation retrieved later by name
Operation<Policy, PolicyOperationMetadata> retrievedResponse = await policiesClient.PollOnceCreatePolicyAsync(operationName);
// Check if the retrieved long-running operation has completed
if (retrievedResponse.IsCompleted)
{
    // If it has completed, then access the result
    Policy retrievedResult = retrievedResponse.Result;
}

CreatePolicyAsync(CreatePolicyRequest, CancellationToken)

public virtual Task<Operation<Policy, PolicyOperationMetadata>> CreatePolicyAsync(CreatePolicyRequest request, CancellationToken cancellationToken)

Creates a policy.

Parameters
Name Description
request CreatePolicyRequest

The request object containing all of the parameters for the API call.

cancellationToken CancellationToken

A CancellationToken to use for this RPC.

Returns
Type Description
TaskOperationPolicyPolicyOperationMetadata

A Task containing the RPC response.

Example
// Create client
PoliciesClient policiesClient = await PoliciesClient.CreateAsync();
// Initialize request argument(s)
CreatePolicyRequest request = new CreatePolicyRequest
{
    Parent = "",
    Policy = new Policy(),
    PolicyId = "",
};
// Make the request
Operation<Policy, PolicyOperationMetadata> response = await policiesClient.CreatePolicyAsync(request);

// Poll until the returned long-running operation is complete
Operation<Policy, PolicyOperationMetadata> completedResponse = await response.PollUntilCompletedAsync();
// Retrieve the operation result
Policy result = completedResponse.Result;

// Or get the name of the operation
string operationName = response.Name;
// This name can be stored, then the long-running operation retrieved later by name
Operation<Policy, PolicyOperationMetadata> retrievedResponse = await policiesClient.PollOnceCreatePolicyAsync(operationName);
// Check if the retrieved long-running operation has completed
if (retrievedResponse.IsCompleted)
{
    // If it has completed, then access the result
    Policy retrievedResult = retrievedResponse.Result;
}

CreatePolicyAsync(string, Policy, string, CallSettings)

public virtual Task<Operation<Policy, PolicyOperationMetadata>> CreatePolicyAsync(string parent, Policy policy, string policyId, CallSettings callSettings = null)

Creates a policy.

Parameters
Name Description
parent string

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.

policy Policy

Required. The policy to create.

policyId string

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.

callSettings CallSettings

If not null, applies overrides to this RPC call.

Returns
Type Description
TaskOperationPolicyPolicyOperationMetadata

A Task containing the RPC response.

Example
// Create client
PoliciesClient policiesClient = await PoliciesClient.CreateAsync();
// Initialize request argument(s)
string parent = "";
Policy policy = new Policy();
string policyId = "";
// Make the request
Operation<Policy, PolicyOperationMetadata> response = await policiesClient.CreatePolicyAsync(parent, policy, policyId);

// Poll until the returned long-running operation is complete
Operation<Policy, PolicyOperationMetadata> completedResponse = await response.PollUntilCompletedAsync();
// Retrieve the operation result
Policy result = completedResponse.Result;

// Or get the name of the operation
string operationName = response.Name;
// This name can be stored, then the long-running operation retrieved later by name
Operation<Policy, PolicyOperationMetadata> retrievedResponse = await policiesClient.PollOnceCreatePolicyAsync(operationName);
// Check if the retrieved long-running operation has completed
if (retrievedResponse.IsCompleted)
{
    // If it has completed, then access the result
    Policy retrievedResult = retrievedResponse.Result;
}

CreatePolicyAsync(string, Policy, string, CancellationToken)

public virtual Task<Operation<Policy, PolicyOperationMetadata>> CreatePolicyAsync(string parent, Policy policy, string policyId, CancellationToken cancellationToken)

Creates a policy.

Parameters
Name Description
parent string

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.

policy Policy

Required. The policy to create.

policyId string

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.

cancellationToken CancellationToken

A CancellationToken to use for this RPC.

Returns
Type Description
TaskOperationPolicyPolicyOperationMetadata

A Task containing the RPC response.

Example
// Create client
PoliciesClient policiesClient = await PoliciesClient.CreateAsync();
// Initialize request argument(s)
string parent = "";
Policy policy = new Policy();
string policyId = "";
// Make the request
Operation<Policy, PolicyOperationMetadata> response = await policiesClient.CreatePolicyAsync(parent, policy, policyId);

// Poll until the returned long-running operation is complete
Operation<Policy, PolicyOperationMetadata> completedResponse = await response.PollUntilCompletedAsync();
// Retrieve the operation result
Policy result = completedResponse.Result;

// Or get the name of the operation
string operationName = response.Name;
// This name can be stored, then the long-running operation retrieved later by name
Operation<Policy, PolicyOperationMetadata> retrievedResponse = await policiesClient.PollOnceCreatePolicyAsync(operationName);
// Check if the retrieved long-running operation has completed
if (retrievedResponse.IsCompleted)
{
    // If it has completed, then access the result
    Policy retrievedResult = retrievedResponse.Result;
}

DeletePolicy(DeletePolicyRequest, CallSettings)

public virtual Operation<Policy, PolicyOperationMetadata> DeletePolicy(DeletePolicyRequest request, CallSettings callSettings = null)

Deletes a policy. This action is permanent.

Parameters
Name Description
request DeletePolicyRequest

The request object containing all of the parameters for the API call.

callSettings CallSettings

If not null, applies overrides to this RPC call.

Returns
Type Description
OperationPolicyPolicyOperationMetadata

The RPC response.

Example
// Create client
PoliciesClient policiesClient = PoliciesClient.Create();
// Initialize request argument(s)
DeletePolicyRequest request = new DeletePolicyRequest { Name = "", Etag = "", };
// Make the request
Operation<Policy, PolicyOperationMetadata> response = policiesClient.DeletePolicy(request);

// Poll until the returned long-running operation is complete
Operation<Policy, PolicyOperationMetadata> completedResponse = response.PollUntilCompleted();
// Retrieve the operation result
Policy result = completedResponse.Result;

// Or get the name of the operation
string operationName = response.Name;
// This name can be stored, then the long-running operation retrieved later by name
Operation<Policy, PolicyOperationMetadata> retrievedResponse = policiesClient.PollOnceDeletePolicy(operationName);
// Check if the retrieved long-running operation has completed
if (retrievedResponse.IsCompleted)
{
    // If it has completed, then access the result
    Policy retrievedResult = retrievedResponse.Result;
}

DeletePolicy(string, CallSettings)

public virtual Operation<Policy, PolicyOperationMetadata> DeletePolicy(string name, CallSettings callSettings = null)

Deletes a policy. This action is permanent.

Parameters
Name Description
name string

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.

callSettings CallSettings

If not null, applies overrides to this RPC call.

Returns
Type Description
OperationPolicyPolicyOperationMetadata

The RPC response.

Example
// Create client
PoliciesClient policiesClient = PoliciesClient.Create();
// Initialize request argument(s)
string name = "";
// Make the request
Operation<Policy, PolicyOperationMetadata> response = policiesClient.DeletePolicy(name);

// Poll until the returned long-running operation is complete
Operation<Policy, PolicyOperationMetadata> completedResponse = response.PollUntilCompleted();
// Retrieve the operation result
Policy result = completedResponse.Result;

// Or get the name of the operation
string operationName = response.Name;
// This name can be stored, then the long-running operation retrieved later by name
Operation<Policy, PolicyOperationMetadata> retrievedResponse = policiesClient.PollOnceDeletePolicy(operationName);
// Check if the retrieved long-running operation has completed
if (retrievedResponse.IsCompleted)
{
    // If it has completed, then access the result
    Policy retrievedResult = retrievedResponse.Result;
}

DeletePolicyAsync(DeletePolicyRequest, CallSettings)

public virtual Task<Operation<Policy, PolicyOperationMetadata>> DeletePolicyAsync(DeletePolicyRequest request, CallSettings callSettings = null)

Deletes a policy. This action is permanent.

Parameters
Name Description
request DeletePolicyRequest

The request object containing all of the parameters for the API call.

callSettings CallSettings

If not null, applies overrides to this RPC call.

Returns
Type Description
TaskOperationPolicyPolicyOperationMetadata

A Task containing the RPC response.

Example
// Create client
PoliciesClient policiesClient = await PoliciesClient.CreateAsync();
// Initialize request argument(s)
DeletePolicyRequest request = new DeletePolicyRequest { Name = "", Etag = "", };
// Make the request
Operation<Policy, PolicyOperationMetadata> response = await policiesClient.DeletePolicyAsync(request);

// Poll until the returned long-running operation is complete
Operation<Policy, PolicyOperationMetadata> completedResponse = await response.PollUntilCompletedAsync();
// Retrieve the operation result
Policy result = completedResponse.Result;

// Or get the name of the operation
string operationName = response.Name;
// This name can be stored, then the long-running operation retrieved later by name
Operation<Policy, PolicyOperationMetadata> retrievedResponse = await policiesClient.PollOnceDeletePolicyAsync(operationName);
// Check if the retrieved long-running operation has completed
if (retrievedResponse.IsCompleted)
{
    // If it has completed, then access the result
    Policy retrievedResult = retrievedResponse.Result;
}

DeletePolicyAsync(DeletePolicyRequest, CancellationToken)

public virtual Task<Operation<Policy, PolicyOperationMetadata>> DeletePolicyAsync(DeletePolicyRequest request, CancellationToken cancellationToken)

Deletes a policy. This action is permanent.

Parameters
Name Description
request DeletePolicyRequest

The request object containing all of the parameters for the API call.

cancellationToken CancellationToken

A CancellationToken to use for this RPC.

Returns
Type Description
TaskOperationPolicyPolicyOperationMetadata

A Task containing the RPC response.

Example
// Create client
PoliciesClient policiesClient = await PoliciesClient.CreateAsync();
// Initialize request argument(s)
DeletePolicyRequest request = new DeletePolicyRequest { Name = "", Etag = "", };
// Make the request
Operation<Policy, PolicyOperationMetadata> response = await policiesClient.DeletePolicyAsync(request);

// Poll until the returned long-running operation is complete
Operation<Policy, PolicyOperationMetadata> completedResponse = await response.PollUntilCompletedAsync();
// Retrieve the operation result
Policy result = completedResponse.Result;

// Or get the name of the operation
string operationName = response.Name;
// This name can be stored, then the long-running operation retrieved later by name
Operation<Policy, PolicyOperationMetadata> retrievedResponse = await policiesClient.PollOnceDeletePolicyAsync(operationName);
// Check if the retrieved long-running operation has completed
if (retrievedResponse.IsCompleted)
{
    // If it has completed, then access the result
    Policy retrievedResult = retrievedResponse.Result;
}

DeletePolicyAsync(string, CallSettings)

public virtual Task<Operation<Policy, PolicyOperationMetadata>> DeletePolicyAsync(string name, CallSettings callSettings = null)

Deletes a policy. This action is permanent.

Parameters
Name Description
name string

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.

callSettings CallSettings

If not null, applies overrides to this RPC call.

Returns
Type Description
TaskOperationPolicyPolicyOperationMetadata

A Task containing the RPC response.

Example
// Create client
PoliciesClient policiesClient = await PoliciesClient.CreateAsync();
// Initialize request argument(s)
string name = "";
// Make the request
Operation<Policy, PolicyOperationMetadata> response = await policiesClient.DeletePolicyAsync(name);

// Poll until the returned long-running operation is complete
Operation<Policy, PolicyOperationMetadata> completedResponse = await response.PollUntilCompletedAsync();
// Retrieve the operation result
Policy result = completedResponse.Result;

// Or get the name of the operation
string operationName = response.Name;
// This name can be stored, then the long-running operation retrieved later by name
Operation<Policy, PolicyOperationMetadata> retrievedResponse = await policiesClient.PollOnceDeletePolicyAsync(operationName);
// Check if the retrieved long-running operation has completed
if (retrievedResponse.IsCompleted)
{
    // If it has completed, then access the result
    Policy retrievedResult = retrievedResponse.Result;
}

DeletePolicyAsync(string, CancellationToken)

public virtual Task<Operation<Policy, PolicyOperationMetadata>> DeletePolicyAsync(string name, CancellationToken cancellationToken)

Deletes a policy. This action is permanent.

Parameters
Name Description
name string

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.

cancellationToken CancellationToken

A CancellationToken to use for this RPC.

Returns
Type Description
TaskOperationPolicyPolicyOperationMetadata

A Task containing the RPC response.

Example
// Create client
PoliciesClient policiesClient = await PoliciesClient.CreateAsync();
// Initialize request argument(s)
string name = "";
// Make the request
Operation<Policy, PolicyOperationMetadata> response = await policiesClient.DeletePolicyAsync(name);

// Poll until the returned long-running operation is complete
Operation<Policy, PolicyOperationMetadata> completedResponse = await response.PollUntilCompletedAsync();
// Retrieve the operation result
Policy result = completedResponse.Result;

// Or get the name of the operation
string operationName = response.Name;
// This name can be stored, then the long-running operation retrieved later by name
Operation<Policy, PolicyOperationMetadata> retrievedResponse = await policiesClient.PollOnceDeletePolicyAsync(operationName);
// Check if the retrieved long-running operation has completed
if (retrievedResponse.IsCompleted)
{
    // If it has completed, then access the result
    Policy retrievedResult = retrievedResponse.Result;
}

GetPolicy(GetPolicyRequest, CallSettings)

public virtual Policy GetPolicy(GetPolicyRequest request, CallSettings callSettings = null)

Gets a policy.

Parameters
Name Description
request GetPolicyRequest

The request object containing all of the parameters for the API call.

callSettings CallSettings

If not null, applies overrides to this RPC call.

Returns
Type Description
Policy

The RPC response.

Example
// Create client
PoliciesClient policiesClient = PoliciesClient.Create();
// Initialize request argument(s)
GetPolicyRequest request = new GetPolicyRequest { Name = "", };
// Make the request
Policy response = policiesClient.GetPolicy(request);

GetPolicy(string, CallSettings)

public virtual Policy GetPolicy(string name, CallSettings callSettings = null)

Gets a policy.

Parameters
Name Description
name string

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.

callSettings CallSettings

If not null, applies overrides to this RPC call.

Returns
Type Description
Policy

The RPC response.

Example
// Create client
PoliciesClient policiesClient = PoliciesClient.Create();
// Initialize request argument(s)
string name = "";
// Make the request
Policy response = policiesClient.GetPolicy(name);

GetPolicyAsync(GetPolicyRequest, CallSettings)

public virtual Task<Policy> GetPolicyAsync(GetPolicyRequest request, CallSettings callSettings = null)

Gets a policy.

Parameters
Name Description
request GetPolicyRequest

The request object containing all of the parameters for the API call.

callSettings CallSettings

If not null, applies overrides to this RPC call.

Returns
Type Description
TaskPolicy

A Task containing the RPC response.

Example
// Create client
PoliciesClient policiesClient = await PoliciesClient.CreateAsync();
// Initialize request argument(s)
GetPolicyRequest request = new GetPolicyRequest { Name = "", };
// Make the request
Policy response = await policiesClient.GetPolicyAsync(request);

GetPolicyAsync(GetPolicyRequest, CancellationToken)

public virtual Task<Policy> GetPolicyAsync(GetPolicyRequest request, CancellationToken cancellationToken)

Gets a policy.

Parameters
Name Description
request GetPolicyRequest

The request object containing all of the parameters for the API call.

cancellationToken CancellationToken

A CancellationToken to use for this RPC.

Returns
Type Description
TaskPolicy

A Task containing the RPC response.

Example
// Create client
PoliciesClient policiesClient = await PoliciesClient.CreateAsync();
// Initialize request argument(s)
GetPolicyRequest request = new GetPolicyRequest { Name = "", };
// Make the request
Policy response = await policiesClient.GetPolicyAsync(request);

GetPolicyAsync(string, CallSettings)

public virtual Task<Policy> GetPolicyAsync(string name, CallSettings callSettings = null)

Gets a policy.

Parameters
Name Description
name string

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.

callSettings CallSettings

If not null, applies overrides to this RPC call.

Returns
Type Description
TaskPolicy

A Task containing the RPC response.

Example
// Create client
PoliciesClient policiesClient = await PoliciesClient.CreateAsync();
// Initialize request argument(s)
string name = "";
// Make the request
Policy response = await policiesClient.GetPolicyAsync(name);

GetPolicyAsync(string, CancellationToken)

public virtual Task<Policy> GetPolicyAsync(string name, CancellationToken cancellationToken)

Gets a policy.

Parameters
Name Description
name string

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.

cancellationToken CancellationToken

A CancellationToken to use for this RPC.

Returns
Type Description
TaskPolicy

A Task containing the RPC response.

Example
// Create client
PoliciesClient policiesClient = await PoliciesClient.CreateAsync();
// Initialize request argument(s)
string name = "";
// Make the request
Policy response = await policiesClient.GetPolicyAsync(name);

ListPolicies(ListPoliciesRequest, CallSettings)

public virtual PagedEnumerable<ListPoliciesResponse, Policy> ListPolicies(ListPoliciesRequest request, CallSettings callSettings = null)

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 ListPoliciesRequest

The request object containing all of the parameters for the API call.

callSettings CallSettings

If not null, applies overrides to this RPC call.

Returns
Type Description
PagedEnumerableListPoliciesResponsePolicy

A pageable sequence of Policy resources.

Example
// Create client
PoliciesClient policiesClient = PoliciesClient.Create();
// Initialize request argument(s)
ListPoliciesRequest request = new ListPoliciesRequest { Parent = "", };
// Make the request
PagedEnumerable<ListPoliciesResponse, Policy> response = policiesClient.ListPolicies(request);

// Iterate over all response items, lazily performing RPCs as required
foreach (Policy item in response)
{
    // Do something with each item
    Console.WriteLine(item);
}

// Or iterate over pages (of server-defined size), performing one RPC per page
foreach (ListPoliciesResponse page in response.AsRawResponses())
{
    // Do something with each page of items
    Console.WriteLine("A page of results:");
    foreach (Policy item in page)
    {
        // Do something with each item
        Console.WriteLine(item);
    }
}

// Or retrieve a single page of known size (unless it's the final page), performing as many RPCs as required
int pageSize = 10;
Page<Policy> singlePage = response.ReadPage(pageSize);
// Do something with the page of items
Console.WriteLine($"A page of {pageSize} results (unless it's the final page):");
foreach (Policy item in singlePage)
{
    // Do something with each item
    Console.WriteLine(item);
}
// Store the pageToken, for when the next page is required.
string nextPageToken = singlePage.NextPageToken;

ListPolicies(string, string, int?, CallSettings)

public virtual PagedEnumerable<ListPoliciesResponse, Policy> ListPolicies(string parent, string pageToken = null, int? pageSize = null, CallSettings callSettings = null)

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
parent string

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.

pageToken string

The token returned from the previous request. A value of null or an empty string retrieves the first page.

pageSize int

The size of page to request. The response will not be larger than this, but may be smaller. A value of null or 0 uses a server-defined page size.

callSettings CallSettings

If not null, applies overrides to this RPC call.

Returns
Type Description
PagedEnumerableListPoliciesResponsePolicy

A pageable sequence of Policy resources.

Example
// Create client
PoliciesClient policiesClient = PoliciesClient.Create();
// Initialize request argument(s)
string parent = "";
// Make the request
PagedEnumerable<ListPoliciesResponse, Policy> response = policiesClient.ListPolicies(parent);

// Iterate over all response items, lazily performing RPCs as required
foreach (Policy item in response)
{
    // Do something with each item
    Console.WriteLine(item);
}

// Or iterate over pages (of server-defined size), performing one RPC per page
foreach (ListPoliciesResponse page in response.AsRawResponses())
{
    // Do something with each page of items
    Console.WriteLine("A page of results:");
    foreach (Policy item in page)
    {
        // Do something with each item
        Console.WriteLine(item);
    }
}

// Or retrieve a single page of known size (unless it's the final page), performing as many RPCs as required
int pageSize = 10;
Page<Policy> singlePage = response.ReadPage(pageSize);
// Do something with the page of items
Console.WriteLine($"A page of {pageSize} results (unless it's the final page):");
foreach (Policy item in singlePage)
{
    // Do something with each item
    Console.WriteLine(item);
}
// Store the pageToken, for when the next page is required.
string nextPageToken = singlePage.NextPageToken;

ListPoliciesAsync(ListPoliciesRequest, CallSettings)

public virtual PagedAsyncEnumerable<ListPoliciesResponse, Policy> ListPoliciesAsync(ListPoliciesRequest request, CallSettings callSettings = null)

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 ListPoliciesRequest

The request object containing all of the parameters for the API call.

callSettings CallSettings

If not null, applies overrides to this RPC call.

Returns
Type Description
PagedAsyncEnumerableListPoliciesResponsePolicy

A pageable asynchronous sequence of Policy resources.

Example
// Create client
PoliciesClient policiesClient = await PoliciesClient.CreateAsync();
// Initialize request argument(s)
ListPoliciesRequest request = new ListPoliciesRequest { Parent = "", };
// Make the request
PagedAsyncEnumerable<ListPoliciesResponse, Policy> response = policiesClient.ListPoliciesAsync(request);

// Iterate over all response items, lazily performing RPCs as required
await response.ForEachAsync((Policy item) =>
{
    // Do something with each item
    Console.WriteLine(item);
});

// Or iterate over pages (of server-defined size), performing one RPC per page
await response.AsRawResponses().ForEachAsync((ListPoliciesResponse page) =>
{
    // Do something with each page of items
    Console.WriteLine("A page of results:");
    foreach (Policy item in page)
    {
        // Do something with each item
        Console.WriteLine(item);
    }
});

// Or retrieve a single page of known size (unless it's the final page), performing as many RPCs as required
int pageSize = 10;
Page<Policy> singlePage = await response.ReadPageAsync(pageSize);
// Do something with the page of items
Console.WriteLine($"A page of {pageSize} results (unless it's the final page):");
foreach (Policy item in singlePage)
{
    // Do something with each item
    Console.WriteLine(item);
}
// Store the pageToken, for when the next page is required.
string nextPageToken = singlePage.NextPageToken;

ListPoliciesAsync(string, string, int?, CallSettings)

public virtual PagedAsyncEnumerable<ListPoliciesResponse, Policy> ListPoliciesAsync(string parent, string pageToken = null, int? pageSize = null, CallSettings callSettings = null)

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
parent string

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.

pageToken string

The token returned from the previous request. A value of null or an empty string retrieves the first page.

pageSize int

The size of page to request. The response will not be larger than this, but may be smaller. A value of null or 0 uses a server-defined page size.

callSettings CallSettings

If not null, applies overrides to this RPC call.

Returns
Type Description
PagedAsyncEnumerableListPoliciesResponsePolicy

A pageable asynchronous sequence of Policy resources.

Example
// Create client
PoliciesClient policiesClient = await PoliciesClient.CreateAsync();
// Initialize request argument(s)
string parent = "";
// Make the request
PagedAsyncEnumerable<ListPoliciesResponse, Policy> response = policiesClient.ListPoliciesAsync(parent);

// Iterate over all response items, lazily performing RPCs as required
await response.ForEachAsync((Policy item) =>
{
    // Do something with each item
    Console.WriteLine(item);
});

// Or iterate over pages (of server-defined size), performing one RPC per page
await response.AsRawResponses().ForEachAsync((ListPoliciesResponse page) =>
{
    // Do something with each page of items
    Console.WriteLine("A page of results:");
    foreach (Policy item in page)
    {
        // Do something with each item
        Console.WriteLine(item);
    }
});

// Or retrieve a single page of known size (unless it's the final page), performing as many RPCs as required
int pageSize = 10;
Page<Policy> singlePage = await response.ReadPageAsync(pageSize);
// Do something with the page of items
Console.WriteLine($"A page of {pageSize} results (unless it's the final page):");
foreach (Policy item in singlePage)
{
    // Do something with each item
    Console.WriteLine(item);
}
// Store the pageToken, for when the next page is required.
string nextPageToken = singlePage.NextPageToken;

PollOnceCreatePolicy(string, CallSettings)

public virtual Operation<Policy, PolicyOperationMetadata> PollOnceCreatePolicy(string operationName, CallSettings callSettings = null)

Poll an operation once, using an operationName from a previous invocation of CreatePolicy.

Parameters
Name Description
operationName string

The name of a previously invoked operation. Must not be null or empty.

callSettings CallSettings

If not null, applies overrides to this RPC call.

Returns
Type Description
OperationPolicyPolicyOperationMetadata

The result of polling the operation.

PollOnceCreatePolicyAsync(string, CallSettings)

public virtual Task<Operation<Policy, PolicyOperationMetadata>> PollOnceCreatePolicyAsync(string operationName, CallSettings callSettings = null)

Asynchronously poll an operation once, using an operationName from a previous invocation of CreatePolicy.

Parameters
Name Description
operationName string

The name of a previously invoked operation. Must not be null or empty.

callSettings CallSettings

If not null, applies overrides to this RPC call.

Returns
Type Description
TaskOperationPolicyPolicyOperationMetadata

A task representing the result of polling the operation.

PollOnceDeletePolicy(string, CallSettings)

public virtual Operation<Policy, PolicyOperationMetadata> PollOnceDeletePolicy(string operationName, CallSettings callSettings = null)

Poll an operation once, using an operationName from a previous invocation of DeletePolicy.

Parameters
Name Description
operationName string

The name of a previously invoked operation. Must not be null or empty.

callSettings CallSettings

If not null, applies overrides to this RPC call.

Returns
Type Description
OperationPolicyPolicyOperationMetadata

The result of polling the operation.

PollOnceDeletePolicyAsync(string, CallSettings)

public virtual Task<Operation<Policy, PolicyOperationMetadata>> PollOnceDeletePolicyAsync(string operationName, CallSettings callSettings = null)

Asynchronously poll an operation once, using an operationName from a previous invocation of DeletePolicy.

Parameters
Name Description
operationName string

The name of a previously invoked operation. Must not be null or empty.

callSettings CallSettings

If not null, applies overrides to this RPC call.

Returns
Type Description
TaskOperationPolicyPolicyOperationMetadata

A task representing the result of polling the operation.

PollOnceUpdatePolicy(string, CallSettings)

public virtual Operation<Policy, PolicyOperationMetadata> PollOnceUpdatePolicy(string operationName, CallSettings callSettings = null)

Poll an operation once, using an operationName from a previous invocation of UpdatePolicy.

Parameters
Name Description
operationName string

The name of a previously invoked operation. Must not be null or empty.

callSettings CallSettings

If not null, applies overrides to this RPC call.

Returns
Type Description
OperationPolicyPolicyOperationMetadata

The result of polling the operation.

PollOnceUpdatePolicyAsync(string, CallSettings)

public virtual Task<Operation<Policy, PolicyOperationMetadata>> PollOnceUpdatePolicyAsync(string operationName, CallSettings callSettings = null)

Asynchronously poll an operation once, using an operationName from a previous invocation of UpdatePolicy.

Parameters
Name Description
operationName string

The name of a previously invoked operation. Must not be null or empty.

callSettings CallSettings

If not null, applies overrides to this RPC call.

Returns
Type Description
TaskOperationPolicyPolicyOperationMetadata

A task representing the result of polling the operation.

ShutdownDefaultChannelsAsync()

public static Task ShutdownDefaultChannelsAsync()

Shuts down any channels automatically created by Create() and CreateAsync(CancellationToken). Channels which weren't automatically created are not affected.

Returns
Type Description
Task

A task representing the asynchronous shutdown operation.

Remarks

After calling this method, further calls to Create() and CreateAsync(CancellationToken) will create new channels, which could in turn be shut down by another call to this method.

UpdatePolicy(UpdatePolicyRequest, CallSettings)

public virtual Operation<Policy, PolicyOperationMetadata> UpdatePolicy(UpdatePolicyRequest request, CallSettings callSettings = null)

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:

  1. Use [GetPolicy][google.iam.v2.Policies.GetPolicy] 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 UpdatePolicyRequest

The request object containing all of the parameters for the API call.

callSettings CallSettings

If not null, applies overrides to this RPC call.

Returns
Type Description
OperationPolicyPolicyOperationMetadata

The RPC response.

Example
// Create client
PoliciesClient policiesClient = PoliciesClient.Create();
// Initialize request argument(s)
UpdatePolicyRequest request = new UpdatePolicyRequest
{
    Policy = new Policy(),
};
// Make the request
Operation<Policy, PolicyOperationMetadata> response = policiesClient.UpdatePolicy(request);

// Poll until the returned long-running operation is complete
Operation<Policy, PolicyOperationMetadata> completedResponse = response.PollUntilCompleted();
// Retrieve the operation result
Policy result = completedResponse.Result;

// Or get the name of the operation
string operationName = response.Name;
// This name can be stored, then the long-running operation retrieved later by name
Operation<Policy, PolicyOperationMetadata> retrievedResponse = policiesClient.PollOnceUpdatePolicy(operationName);
// Check if the retrieved long-running operation has completed
if (retrievedResponse.IsCompleted)
{
    // If it has completed, then access the result
    Policy retrievedResult = retrievedResponse.Result;
}

UpdatePolicyAsync(UpdatePolicyRequest, CallSettings)

public virtual Task<Operation<Policy, PolicyOperationMetadata>> UpdatePolicyAsync(UpdatePolicyRequest request, CallSettings callSettings = null)

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:

  1. Use [GetPolicy][google.iam.v2.Policies.GetPolicy] 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 UpdatePolicyRequest

The request object containing all of the parameters for the API call.

callSettings CallSettings

If not null, applies overrides to this RPC call.

Returns
Type Description
TaskOperationPolicyPolicyOperationMetadata

A Task containing the RPC response.

Example
// Create client
PoliciesClient policiesClient = await PoliciesClient.CreateAsync();
// Initialize request argument(s)
UpdatePolicyRequest request = new UpdatePolicyRequest
{
    Policy = new Policy(),
};
// Make the request
Operation<Policy, PolicyOperationMetadata> response = await policiesClient.UpdatePolicyAsync(request);

// Poll until the returned long-running operation is complete
Operation<Policy, PolicyOperationMetadata> completedResponse = await response.PollUntilCompletedAsync();
// Retrieve the operation result
Policy result = completedResponse.Result;

// Or get the name of the operation
string operationName = response.Name;
// This name can be stored, then the long-running operation retrieved later by name
Operation<Policy, PolicyOperationMetadata> retrievedResponse = await policiesClient.PollOnceUpdatePolicyAsync(operationName);
// Check if the retrieved long-running operation has completed
if (retrievedResponse.IsCompleted)
{
    // If it has completed, then access the result
    Policy retrievedResult = retrievedResponse.Result;
}

UpdatePolicyAsync(UpdatePolicyRequest, CancellationToken)

public virtual Task<Operation<Policy, PolicyOperationMetadata>> UpdatePolicyAsync(UpdatePolicyRequest request, CancellationToken cancellationToken)

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:

  1. Use [GetPolicy][google.iam.v2.Policies.GetPolicy] 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 UpdatePolicyRequest

The request object containing all of the parameters for the API call.

cancellationToken CancellationToken

A CancellationToken to use for this RPC.

Returns
Type Description
TaskOperationPolicyPolicyOperationMetadata

A Task containing the RPC response.

Example
// Create client
PoliciesClient policiesClient = await PoliciesClient.CreateAsync();
// Initialize request argument(s)
UpdatePolicyRequest request = new UpdatePolicyRequest
{
    Policy = new Policy(),
};
// Make the request
Operation<Policy, PolicyOperationMetadata> response = await policiesClient.UpdatePolicyAsync(request);

// Poll until the returned long-running operation is complete
Operation<Policy, PolicyOperationMetadata> completedResponse = await response.PollUntilCompletedAsync();
// Retrieve the operation result
Policy result = completedResponse.Result;

// Or get the name of the operation
string operationName = response.Name;
// This name can be stored, then the long-running operation retrieved later by name
Operation<Policy, PolicyOperationMetadata> retrievedResponse = await policiesClient.PollOnceUpdatePolicyAsync(operationName);
// Check if the retrieved long-running operation has completed
if (retrievedResponse.IsCompleted)
{
    // If it has completed, then access the result
    Policy retrievedResult = retrievedResponse.Result;
}