Organization Policy v2 API - Class OrgPolicyClient (2.5.0)

public abstract class OrgPolicyClient

Reference documentation and code samples for the Organization Policy v2 API class OrgPolicyClient.

OrgPolicy client wrapper, for convenient use.

Inheritance

object > OrgPolicyClient

Derived Types

Namespace

Google.Cloud.OrgPolicy.V2

Assembly

Google.Cloud.OrgPolicy.V2.dll

Remarks

An interface for managing organization policies.

The Organization Policy Service provides a simple mechanism for organizations to restrict the allowed configurations across their entire resource hierarchy.

You can use a policy to configure restrictions on resources. For example, you can enforce a policy that restricts which Google Cloud APIs can be activated in a certain part of your resource hierarchy, or prevents serial port access to VM instances in a particular folder.

Policies are inherited down through the resource hierarchy. A policy applied to a parent resource automatically applies to all its child resources unless overridden with a policy lower in the hierarchy.

A constraint defines an aspect of a resource's configuration that can be controlled by an organization's policy administrator. Policies are a collection of constraints that defines their allowable configuration on a particular resource and its child resources.

Properties

DefaultEndpoint

public static string DefaultEndpoint { get; }

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

Property Value
Type Description
string

DefaultScopes

public static IReadOnlyList<string> DefaultScopes { get; }

The default OrgPolicy scopes.

Property Value
Type Description
IReadOnlyListstring
Remarks

The default OrgPolicy scopes are:

GrpcClient

public virtual OrgPolicy.OrgPolicyClient GrpcClient { get; }

The underlying gRPC OrgPolicy client

Property Value
Type Description
OrgPolicyOrgPolicyClient

ServiceMetadata

public static ServiceMetadata ServiceMetadata { get; }

The service metadata associated with this client type.

Property Value
Type Description
ServiceMetadata

Methods

Create()

public static OrgPolicyClient Create()

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

Returns
Type Description
OrgPolicyClient

The created OrgPolicyClient.

CreateAsync(CancellationToken)

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

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

Parameter
Name Description
cancellationToken CancellationToken

The CancellationToken to use while creating the client.

Returns
Type Description
TaskOrgPolicyClient

The task representing the created OrgPolicyClient.

CreateCustomConstraint(OrganizationName, CustomConstraint, CallSettings)

public virtual CustomConstraint CreateCustomConstraint(OrganizationName parent, CustomConstraint customConstraint, CallSettings callSettings = null)

Creates a custom constraint.

Returns a google.rpc.Status with google.rpc.Code.NOT_FOUND if the organization does not exist. Returns a google.rpc.Status with google.rpc.Code.ALREADY_EXISTS if the constraint already exists on the given organization.

Parameters
Name Description
parent OrganizationName

Required. Must be in the following form:

  • organizations/{organization_id}
customConstraint CustomConstraint

Required. Custom constraint to create.

callSettings CallSettings

If not null, applies overrides to this RPC call.

Returns
Type Description
CustomConstraint

The RPC response.

Example
// Create client
OrgPolicyClient orgPolicyClient = OrgPolicyClient.Create();
// Initialize request argument(s)
OrganizationName parent = OrganizationName.FromOrganization("[ORGANIZATION]");
CustomConstraint customConstraint = new CustomConstraint();
// Make the request
CustomConstraint response = orgPolicyClient.CreateCustomConstraint(parent, customConstraint);

CreateCustomConstraint(CreateCustomConstraintRequest, CallSettings)

public virtual CustomConstraint CreateCustomConstraint(CreateCustomConstraintRequest request, CallSettings callSettings = null)

Creates a custom constraint.

Returns a google.rpc.Status with google.rpc.Code.NOT_FOUND if the organization does not exist. Returns a google.rpc.Status with google.rpc.Code.ALREADY_EXISTS if the constraint already exists on the given organization.

Parameters
Name Description
request CreateCustomConstraintRequest

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
CustomConstraint

The RPC response.

Example
// Create client
OrgPolicyClient orgPolicyClient = OrgPolicyClient.Create();
// Initialize request argument(s)
CreateCustomConstraintRequest request = new CreateCustomConstraintRequest
{
    ParentAsOrganizationName = OrganizationName.FromOrganization("[ORGANIZATION]"),
    CustomConstraint = new CustomConstraint(),
};
// Make the request
CustomConstraint response = orgPolicyClient.CreateCustomConstraint(request);

CreateCustomConstraint(string, CustomConstraint, CallSettings)

public virtual CustomConstraint CreateCustomConstraint(string parent, CustomConstraint customConstraint, CallSettings callSettings = null)

Creates a custom constraint.

Returns a google.rpc.Status with google.rpc.Code.NOT_FOUND if the organization does not exist. Returns a google.rpc.Status with google.rpc.Code.ALREADY_EXISTS if the constraint already exists on the given organization.

Parameters
Name Description
parent string

Required. Must be in the following form:

  • organizations/{organization_id}
customConstraint CustomConstraint

Required. Custom constraint to create.

callSettings CallSettings

If not null, applies overrides to this RPC call.

Returns
Type Description
CustomConstraint

The RPC response.

Example
// Create client
OrgPolicyClient orgPolicyClient = OrgPolicyClient.Create();
// Initialize request argument(s)
string parent = "organizations/[ORGANIZATION]";
CustomConstraint customConstraint = new CustomConstraint();
// Make the request
CustomConstraint response = orgPolicyClient.CreateCustomConstraint(parent, customConstraint);

CreateCustomConstraintAsync(OrganizationName, CustomConstraint, CallSettings)

public virtual Task<CustomConstraint> CreateCustomConstraintAsync(OrganizationName parent, CustomConstraint customConstraint, CallSettings callSettings = null)

Creates a custom constraint.

Returns a google.rpc.Status with google.rpc.Code.NOT_FOUND if the organization does not exist. Returns a google.rpc.Status with google.rpc.Code.ALREADY_EXISTS if the constraint already exists on the given organization.

Parameters
Name Description
parent OrganizationName

Required. Must be in the following form:

  • organizations/{organization_id}
customConstraint CustomConstraint

Required. Custom constraint to create.

callSettings CallSettings

If not null, applies overrides to this RPC call.

Returns
Type Description
TaskCustomConstraint

A Task containing the RPC response.

Example
// Create client
OrgPolicyClient orgPolicyClient = await OrgPolicyClient.CreateAsync();
// Initialize request argument(s)
OrganizationName parent = OrganizationName.FromOrganization("[ORGANIZATION]");
CustomConstraint customConstraint = new CustomConstraint();
// Make the request
CustomConstraint response = await orgPolicyClient.CreateCustomConstraintAsync(parent, customConstraint);

CreateCustomConstraintAsync(OrganizationName, CustomConstraint, CancellationToken)

public virtual Task<CustomConstraint> CreateCustomConstraintAsync(OrganizationName parent, CustomConstraint customConstraint, CancellationToken cancellationToken)

Creates a custom constraint.

Returns a google.rpc.Status with google.rpc.Code.NOT_FOUND if the organization does not exist. Returns a google.rpc.Status with google.rpc.Code.ALREADY_EXISTS if the constraint already exists on the given organization.

Parameters
Name Description
parent OrganizationName

Required. Must be in the following form:

  • organizations/{organization_id}
customConstraint CustomConstraint

Required. Custom constraint to create.

cancellationToken CancellationToken

A CancellationToken to use for this RPC.

Returns
Type Description
TaskCustomConstraint

A Task containing the RPC response.

Example
// Create client
OrgPolicyClient orgPolicyClient = await OrgPolicyClient.CreateAsync();
// Initialize request argument(s)
OrganizationName parent = OrganizationName.FromOrganization("[ORGANIZATION]");
CustomConstraint customConstraint = new CustomConstraint();
// Make the request
CustomConstraint response = await orgPolicyClient.CreateCustomConstraintAsync(parent, customConstraint);

CreateCustomConstraintAsync(CreateCustomConstraintRequest, CallSettings)

public virtual Task<CustomConstraint> CreateCustomConstraintAsync(CreateCustomConstraintRequest request, CallSettings callSettings = null)

Creates a custom constraint.

Returns a google.rpc.Status with google.rpc.Code.NOT_FOUND if the organization does not exist. Returns a google.rpc.Status with google.rpc.Code.ALREADY_EXISTS if the constraint already exists on the given organization.

Parameters
Name Description
request CreateCustomConstraintRequest

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
TaskCustomConstraint

A Task containing the RPC response.

Example
// Create client
OrgPolicyClient orgPolicyClient = await OrgPolicyClient.CreateAsync();
// Initialize request argument(s)
CreateCustomConstraintRequest request = new CreateCustomConstraintRequest
{
    ParentAsOrganizationName = OrganizationName.FromOrganization("[ORGANIZATION]"),
    CustomConstraint = new CustomConstraint(),
};
// Make the request
CustomConstraint response = await orgPolicyClient.CreateCustomConstraintAsync(request);

CreateCustomConstraintAsync(CreateCustomConstraintRequest, CancellationToken)

public virtual Task<CustomConstraint> CreateCustomConstraintAsync(CreateCustomConstraintRequest request, CancellationToken cancellationToken)

Creates a custom constraint.

Returns a google.rpc.Status with google.rpc.Code.NOT_FOUND if the organization does not exist. Returns a google.rpc.Status with google.rpc.Code.ALREADY_EXISTS if the constraint already exists on the given organization.

Parameters
Name Description
request CreateCustomConstraintRequest

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

cancellationToken CancellationToken

A CancellationToken to use for this RPC.

Returns
Type Description
TaskCustomConstraint

A Task containing the RPC response.

Example
// Create client
OrgPolicyClient orgPolicyClient = await OrgPolicyClient.CreateAsync();
// Initialize request argument(s)
CreateCustomConstraintRequest request = new CreateCustomConstraintRequest
{
    ParentAsOrganizationName = OrganizationName.FromOrganization("[ORGANIZATION]"),
    CustomConstraint = new CustomConstraint(),
};
// Make the request
CustomConstraint response = await orgPolicyClient.CreateCustomConstraintAsync(request);

CreateCustomConstraintAsync(string, CustomConstraint, CallSettings)

public virtual Task<CustomConstraint> CreateCustomConstraintAsync(string parent, CustomConstraint customConstraint, CallSettings callSettings = null)

Creates a custom constraint.

Returns a google.rpc.Status with google.rpc.Code.NOT_FOUND if the organization does not exist. Returns a google.rpc.Status with google.rpc.Code.ALREADY_EXISTS if the constraint already exists on the given organization.

Parameters
Name Description
parent string

Required. Must be in the following form:

  • organizations/{organization_id}
customConstraint CustomConstraint

Required. Custom constraint to create.

callSettings CallSettings

If not null, applies overrides to this RPC call.

Returns
Type Description
TaskCustomConstraint

A Task containing the RPC response.

Example
// Create client
OrgPolicyClient orgPolicyClient = await OrgPolicyClient.CreateAsync();
// Initialize request argument(s)
string parent = "organizations/[ORGANIZATION]";
CustomConstraint customConstraint = new CustomConstraint();
// Make the request
CustomConstraint response = await orgPolicyClient.CreateCustomConstraintAsync(parent, customConstraint);

CreateCustomConstraintAsync(string, CustomConstraint, CancellationToken)

public virtual Task<CustomConstraint> CreateCustomConstraintAsync(string parent, CustomConstraint customConstraint, CancellationToken cancellationToken)

Creates a custom constraint.

Returns a google.rpc.Status with google.rpc.Code.NOT_FOUND if the organization does not exist. Returns a google.rpc.Status with google.rpc.Code.ALREADY_EXISTS if the constraint already exists on the given organization.

Parameters
Name Description
parent string

Required. Must be in the following form:

  • organizations/{organization_id}
customConstraint CustomConstraint

Required. Custom constraint to create.

cancellationToken CancellationToken

A CancellationToken to use for this RPC.

Returns
Type Description
TaskCustomConstraint

A Task containing the RPC response.

Example
// Create client
OrgPolicyClient orgPolicyClient = await OrgPolicyClient.CreateAsync();
// Initialize request argument(s)
string parent = "organizations/[ORGANIZATION]";
CustomConstraint customConstraint = new CustomConstraint();
// Make the request
CustomConstraint response = await orgPolicyClient.CreateCustomConstraintAsync(parent, customConstraint);

CreatePolicy(FolderName, Policy, CallSettings)

public virtual Policy CreatePolicy(FolderName parent, Policy policy, CallSettings callSettings = null)

Creates a policy.

Returns a google.rpc.Status with google.rpc.Code.NOT_FOUND if the constraint does not exist. Returns a google.rpc.Status with google.rpc.Code.ALREADY_EXISTS if the policy already exists on the given Google Cloud resource.

Parameters
Name Description
parent FolderName

Required. The Google Cloud resource that will parent the new policy. Must be in one of the following forms:

  • projects/{project_number}
  • projects/{project_id}
  • folders/{folder_id}
  • organizations/{organization_id}
policy Policy

Required. Policy to create.

callSettings CallSettings

If not null, applies overrides to this RPC call.

Returns
Type Description
Policy

The RPC response.

Example
// Create client
OrgPolicyClient orgPolicyClient = OrgPolicyClient.Create();
// Initialize request argument(s)
FolderName parent = FolderName.FromFolder("[FOLDER]");
Policy policy = new Policy();
// Make the request
Policy response = orgPolicyClient.CreatePolicy(parent, policy);

CreatePolicy(OrganizationName, Policy, CallSettings)

public virtual Policy CreatePolicy(OrganizationName parent, Policy policy, CallSettings callSettings = null)

Creates a policy.

Returns a google.rpc.Status with google.rpc.Code.NOT_FOUND if the constraint does not exist. Returns a google.rpc.Status with google.rpc.Code.ALREADY_EXISTS if the policy already exists on the given Google Cloud resource.

Parameters
Name Description
parent OrganizationName

Required. The Google Cloud resource that will parent the new policy. Must be in one of the following forms:

  • projects/{project_number}
  • projects/{project_id}
  • folders/{folder_id}
  • organizations/{organization_id}
policy Policy

Required. Policy to create.

callSettings CallSettings

If not null, applies overrides to this RPC call.

Returns
Type Description
Policy

The RPC response.

Example
// Create client
OrgPolicyClient orgPolicyClient = OrgPolicyClient.Create();
// Initialize request argument(s)
OrganizationName parent = OrganizationName.FromOrganization("[ORGANIZATION]");
Policy policy = new Policy();
// Make the request
Policy response = orgPolicyClient.CreatePolicy(parent, policy);

CreatePolicy(ProjectName, Policy, CallSettings)

public virtual Policy CreatePolicy(ProjectName parent, Policy policy, CallSettings callSettings = null)

Creates a policy.

Returns a google.rpc.Status with google.rpc.Code.NOT_FOUND if the constraint does not exist. Returns a google.rpc.Status with google.rpc.Code.ALREADY_EXISTS if the policy already exists on the given Google Cloud resource.

Parameters
Name Description
parent ProjectName

Required. The Google Cloud resource that will parent the new policy. Must be in one of the following forms:

  • projects/{project_number}
  • projects/{project_id}
  • folders/{folder_id}
  • organizations/{organization_id}
policy Policy

Required. Policy to create.

callSettings CallSettings

If not null, applies overrides to this RPC call.

Returns
Type Description
Policy

The RPC response.

Example
// Create client
OrgPolicyClient orgPolicyClient = OrgPolicyClient.Create();
// Initialize request argument(s)
ProjectName parent = ProjectName.FromProject("[PROJECT]");
Policy policy = new Policy();
// Make the request
Policy response = orgPolicyClient.CreatePolicy(parent, policy);

CreatePolicy(CreatePolicyRequest, CallSettings)

public virtual Policy CreatePolicy(CreatePolicyRequest request, CallSettings callSettings = null)

Creates a policy.

Returns a google.rpc.Status with google.rpc.Code.NOT_FOUND if the constraint does not exist. Returns a google.rpc.Status with google.rpc.Code.ALREADY_EXISTS if the policy already exists on the given Google Cloud resource.

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
Policy

The RPC response.

Example
// Create client
OrgPolicyClient orgPolicyClient = OrgPolicyClient.Create();
// Initialize request argument(s)
CreatePolicyRequest request = new CreatePolicyRequest
{
    ParentAsProjectName = ProjectName.FromProject("[PROJECT]"),
    Policy = new Policy(),
};
// Make the request
Policy response = orgPolicyClient.CreatePolicy(request);

CreatePolicy(string, Policy, CallSettings)

public virtual Policy CreatePolicy(string parent, Policy policy, CallSettings callSettings = null)

Creates a policy.

Returns a google.rpc.Status with google.rpc.Code.NOT_FOUND if the constraint does not exist. Returns a google.rpc.Status with google.rpc.Code.ALREADY_EXISTS if the policy already exists on the given Google Cloud resource.

Parameters
Name Description
parent string

Required. The Google Cloud resource that will parent the new policy. Must be in one of the following forms:

  • projects/{project_number}
  • projects/{project_id}
  • folders/{folder_id}
  • organizations/{organization_id}
policy Policy

Required. Policy to create.

callSettings CallSettings

If not null, applies overrides to this RPC call.

Returns
Type Description
Policy

The RPC response.

Example
// Create client
OrgPolicyClient orgPolicyClient = OrgPolicyClient.Create();
// Initialize request argument(s)
string parent = "projects/[PROJECT]";
Policy policy = new Policy();
// Make the request
Policy response = orgPolicyClient.CreatePolicy(parent, policy);

CreatePolicyAsync(FolderName, Policy, CallSettings)

public virtual Task<Policy> CreatePolicyAsync(FolderName parent, Policy policy, CallSettings callSettings = null)

Creates a policy.

Returns a google.rpc.Status with google.rpc.Code.NOT_FOUND if the constraint does not exist. Returns a google.rpc.Status with google.rpc.Code.ALREADY_EXISTS if the policy already exists on the given Google Cloud resource.

Parameters
Name Description
parent FolderName

Required. The Google Cloud resource that will parent the new policy. Must be in one of the following forms:

  • projects/{project_number}
  • projects/{project_id}
  • folders/{folder_id}
  • organizations/{organization_id}
policy Policy

Required. Policy to create.

callSettings CallSettings

If not null, applies overrides to this RPC call.

Returns
Type Description
TaskPolicy

A Task containing the RPC response.

Example
// Create client
OrgPolicyClient orgPolicyClient = await OrgPolicyClient.CreateAsync();
// Initialize request argument(s)
FolderName parent = FolderName.FromFolder("[FOLDER]");
Policy policy = new Policy();
// Make the request
Policy response = await orgPolicyClient.CreatePolicyAsync(parent, policy);

CreatePolicyAsync(FolderName, Policy, CancellationToken)

public virtual Task<Policy> CreatePolicyAsync(FolderName parent, Policy policy, CancellationToken cancellationToken)

Creates a policy.

Returns a google.rpc.Status with google.rpc.Code.NOT_FOUND if the constraint does not exist. Returns a google.rpc.Status with google.rpc.Code.ALREADY_EXISTS if the policy already exists on the given Google Cloud resource.

Parameters
Name Description
parent FolderName

Required. The Google Cloud resource that will parent the new policy. Must be in one of the following forms:

  • projects/{project_number}
  • projects/{project_id}
  • folders/{folder_id}
  • organizations/{organization_id}
policy Policy

Required. Policy to create.

cancellationToken CancellationToken

A CancellationToken to use for this RPC.

Returns
Type Description
TaskPolicy

A Task containing the RPC response.

Example
// Create client
OrgPolicyClient orgPolicyClient = await OrgPolicyClient.CreateAsync();
// Initialize request argument(s)
FolderName parent = FolderName.FromFolder("[FOLDER]");
Policy policy = new Policy();
// Make the request
Policy response = await orgPolicyClient.CreatePolicyAsync(parent, policy);

CreatePolicyAsync(OrganizationName, Policy, CallSettings)

public virtual Task<Policy> CreatePolicyAsync(OrganizationName parent, Policy policy, CallSettings callSettings = null)

Creates a policy.

Returns a google.rpc.Status with google.rpc.Code.NOT_FOUND if the constraint does not exist. Returns a google.rpc.Status with google.rpc.Code.ALREADY_EXISTS if the policy already exists on the given Google Cloud resource.

Parameters
Name Description
parent OrganizationName

Required. The Google Cloud resource that will parent the new policy. Must be in one of the following forms:

  • projects/{project_number}
  • projects/{project_id}
  • folders/{folder_id}
  • organizations/{organization_id}
policy Policy

Required. Policy to create.

callSettings CallSettings

If not null, applies overrides to this RPC call.

Returns
Type Description
TaskPolicy

A Task containing the RPC response.

Example
// Create client
OrgPolicyClient orgPolicyClient = await OrgPolicyClient.CreateAsync();
// Initialize request argument(s)
OrganizationName parent = OrganizationName.FromOrganization("[ORGANIZATION]");
Policy policy = new Policy();
// Make the request
Policy response = await orgPolicyClient.CreatePolicyAsync(parent, policy);

CreatePolicyAsync(OrganizationName, Policy, CancellationToken)

public virtual Task<Policy> CreatePolicyAsync(OrganizationName parent, Policy policy, CancellationToken cancellationToken)

Creates a policy.

Returns a google.rpc.Status with google.rpc.Code.NOT_FOUND if the constraint does not exist. Returns a google.rpc.Status with google.rpc.Code.ALREADY_EXISTS if the policy already exists on the given Google Cloud resource.

Parameters
Name Description
parent OrganizationName

Required. The Google Cloud resource that will parent the new policy. Must be in one of the following forms:

  • projects/{project_number}
  • projects/{project_id}
  • folders/{folder_id}
  • organizations/{organization_id}
policy Policy

Required. Policy to create.

cancellationToken CancellationToken

A CancellationToken to use for this RPC.

Returns
Type Description
TaskPolicy

A Task containing the RPC response.

Example
// Create client
OrgPolicyClient orgPolicyClient = await OrgPolicyClient.CreateAsync();
// Initialize request argument(s)
OrganizationName parent = OrganizationName.FromOrganization("[ORGANIZATION]");
Policy policy = new Policy();
// Make the request
Policy response = await orgPolicyClient.CreatePolicyAsync(parent, policy);

CreatePolicyAsync(ProjectName, Policy, CallSettings)

public virtual Task<Policy> CreatePolicyAsync(ProjectName parent, Policy policy, CallSettings callSettings = null)

Creates a policy.

Returns a google.rpc.Status with google.rpc.Code.NOT_FOUND if the constraint does not exist. Returns a google.rpc.Status with google.rpc.Code.ALREADY_EXISTS if the policy already exists on the given Google Cloud resource.

Parameters
Name Description
parent ProjectName

Required. The Google Cloud resource that will parent the new policy. Must be in one of the following forms:

  • projects/{project_number}
  • projects/{project_id}
  • folders/{folder_id}
  • organizations/{organization_id}
policy Policy

Required. Policy to create.

callSettings CallSettings

If not null, applies overrides to this RPC call.

Returns
Type Description
TaskPolicy

A Task containing the RPC response.

Example
// Create client
OrgPolicyClient orgPolicyClient = await OrgPolicyClient.CreateAsync();
// Initialize request argument(s)
ProjectName parent = ProjectName.FromProject("[PROJECT]");
Policy policy = new Policy();
// Make the request
Policy response = await orgPolicyClient.CreatePolicyAsync(parent, policy);

CreatePolicyAsync(ProjectName, Policy, CancellationToken)

public virtual Task<Policy> CreatePolicyAsync(ProjectName parent, Policy policy, CancellationToken cancellationToken)

Creates a policy.

Returns a google.rpc.Status with google.rpc.Code.NOT_FOUND if the constraint does not exist. Returns a google.rpc.Status with google.rpc.Code.ALREADY_EXISTS if the policy already exists on the given Google Cloud resource.

Parameters
Name Description
parent ProjectName

Required. The Google Cloud resource that will parent the new policy. Must be in one of the following forms:

  • projects/{project_number}
  • projects/{project_id}
  • folders/{folder_id}
  • organizations/{organization_id}
policy Policy

Required. Policy to create.

cancellationToken CancellationToken

A CancellationToken to use for this RPC.

Returns
Type Description
TaskPolicy

A Task containing the RPC response.

Example
// Create client
OrgPolicyClient orgPolicyClient = await OrgPolicyClient.CreateAsync();
// Initialize request argument(s)
ProjectName parent = ProjectName.FromProject("[PROJECT]");
Policy policy = new Policy();
// Make the request
Policy response = await orgPolicyClient.CreatePolicyAsync(parent, policy);

CreatePolicyAsync(CreatePolicyRequest, CallSettings)

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

Creates a policy.

Returns a google.rpc.Status with google.rpc.Code.NOT_FOUND if the constraint does not exist. Returns a google.rpc.Status with google.rpc.Code.ALREADY_EXISTS if the policy already exists on the given Google Cloud resource.

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
TaskPolicy

A Task containing the RPC response.

Example
// Create client
OrgPolicyClient orgPolicyClient = await OrgPolicyClient.CreateAsync();
// Initialize request argument(s)
CreatePolicyRequest request = new CreatePolicyRequest
{
    ParentAsProjectName = ProjectName.FromProject("[PROJECT]"),
    Policy = new Policy(),
};
// Make the request
Policy response = await orgPolicyClient.CreatePolicyAsync(request);

CreatePolicyAsync(CreatePolicyRequest, CancellationToken)

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

Creates a policy.

Returns a google.rpc.Status with google.rpc.Code.NOT_FOUND if the constraint does not exist. Returns a google.rpc.Status with google.rpc.Code.ALREADY_EXISTS if the policy already exists on the given Google Cloud resource.

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
TaskPolicy

A Task containing the RPC response.

Example
// Create client
OrgPolicyClient orgPolicyClient = await OrgPolicyClient.CreateAsync();
// Initialize request argument(s)
CreatePolicyRequest request = new CreatePolicyRequest
{
    ParentAsProjectName = ProjectName.FromProject("[PROJECT]"),
    Policy = new Policy(),
};
// Make the request
Policy response = await orgPolicyClient.CreatePolicyAsync(request);

CreatePolicyAsync(string, Policy, CallSettings)

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

Creates a policy.

Returns a google.rpc.Status with google.rpc.Code.NOT_FOUND if the constraint does not exist. Returns a google.rpc.Status with google.rpc.Code.ALREADY_EXISTS if the policy already exists on the given Google Cloud resource.

Parameters
Name Description
parent string

Required. The Google Cloud resource that will parent the new policy. Must be in one of the following forms:

  • projects/{project_number}
  • projects/{project_id}
  • folders/{folder_id}
  • organizations/{organization_id}
policy Policy

Required. Policy to create.

callSettings CallSettings

If not null, applies overrides to this RPC call.

Returns
Type Description
TaskPolicy

A Task containing the RPC response.

Example
// Create client
OrgPolicyClient orgPolicyClient = await OrgPolicyClient.CreateAsync();
// Initialize request argument(s)
string parent = "projects/[PROJECT]";
Policy policy = new Policy();
// Make the request
Policy response = await orgPolicyClient.CreatePolicyAsync(parent, policy);

CreatePolicyAsync(string, Policy, CancellationToken)

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

Creates a policy.

Returns a google.rpc.Status with google.rpc.Code.NOT_FOUND if the constraint does not exist. Returns a google.rpc.Status with google.rpc.Code.ALREADY_EXISTS if the policy already exists on the given Google Cloud resource.

Parameters
Name Description
parent string

Required. The Google Cloud resource that will parent the new policy. Must be in one of the following forms:

  • projects/{project_number}
  • projects/{project_id}
  • folders/{folder_id}
  • organizations/{organization_id}
policy Policy

Required. Policy to create.

cancellationToken CancellationToken

A CancellationToken to use for this RPC.

Returns
Type Description
TaskPolicy

A Task containing the RPC response.

Example
// Create client
OrgPolicyClient orgPolicyClient = await OrgPolicyClient.CreateAsync();
// Initialize request argument(s)
string parent = "projects/[PROJECT]";
Policy policy = new Policy();
// Make the request
Policy response = await orgPolicyClient.CreatePolicyAsync(parent, policy);

DeleteCustomConstraint(CustomConstraintName, CallSettings)

public virtual void DeleteCustomConstraint(CustomConstraintName name, CallSettings callSettings = null)

Deletes a custom constraint.

Returns a google.rpc.Status with google.rpc.Code.NOT_FOUND if the constraint does not exist.

Parameters
Name Description
name CustomConstraintName

Required. Name of the custom constraint to delete. See the custom constraint entry for naming rules.

callSettings CallSettings

If not null, applies overrides to this RPC call.

Example
// Create client
OrgPolicyClient orgPolicyClient = OrgPolicyClient.Create();
// Initialize request argument(s)
CustomConstraintName name = CustomConstraintName.FromOrganizationCustomConstraint("[ORGANIZATION]", "[CUSTOM_CONSTRAINT]");
// Make the request
orgPolicyClient.DeleteCustomConstraint(name);

DeleteCustomConstraint(DeleteCustomConstraintRequest, CallSettings)

public virtual void DeleteCustomConstraint(DeleteCustomConstraintRequest request, CallSettings callSettings = null)

Deletes a custom constraint.

Returns a google.rpc.Status with google.rpc.Code.NOT_FOUND if the constraint does not exist.

Parameters
Name Description
request DeleteCustomConstraintRequest

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

callSettings CallSettings

If not null, applies overrides to this RPC call.

Example
// Create client
OrgPolicyClient orgPolicyClient = OrgPolicyClient.Create();
// Initialize request argument(s)
DeleteCustomConstraintRequest request = new DeleteCustomConstraintRequest
{
    CustomConstraintName = CustomConstraintName.FromOrganizationCustomConstraint("[ORGANIZATION]", "[CUSTOM_CONSTRAINT]"),
};
// Make the request
orgPolicyClient.DeleteCustomConstraint(request);

DeleteCustomConstraint(string, CallSettings)

public virtual void DeleteCustomConstraint(string name, CallSettings callSettings = null)

Deletes a custom constraint.

Returns a google.rpc.Status with google.rpc.Code.NOT_FOUND if the constraint does not exist.

Parameters
Name Description
name string

Required. Name of the custom constraint to delete. See the custom constraint entry for naming rules.

callSettings CallSettings

If not null, applies overrides to this RPC call.

Example
// Create client
OrgPolicyClient orgPolicyClient = OrgPolicyClient.Create();
// Initialize request argument(s)
string name = "organizations/[ORGANIZATION]/customConstraints/[CUSTOM_CONSTRAINT]";
// Make the request
orgPolicyClient.DeleteCustomConstraint(name);

DeleteCustomConstraintAsync(CustomConstraintName, CallSettings)

public virtual Task DeleteCustomConstraintAsync(CustomConstraintName name, CallSettings callSettings = null)

Deletes a custom constraint.

Returns a google.rpc.Status with google.rpc.Code.NOT_FOUND if the constraint does not exist.

Parameters
Name Description
name CustomConstraintName

Required. Name of the custom constraint to delete. See the custom constraint entry for naming rules.

callSettings CallSettings

If not null, applies overrides to this RPC call.

Returns
Type Description
Task

A Task containing the RPC response.

Example
// Create client
OrgPolicyClient orgPolicyClient = await OrgPolicyClient.CreateAsync();
// Initialize request argument(s)
CustomConstraintName name = CustomConstraintName.FromOrganizationCustomConstraint("[ORGANIZATION]", "[CUSTOM_CONSTRAINT]");
// Make the request
await orgPolicyClient.DeleteCustomConstraintAsync(name);

DeleteCustomConstraintAsync(CustomConstraintName, CancellationToken)

public virtual Task DeleteCustomConstraintAsync(CustomConstraintName name, CancellationToken cancellationToken)

Deletes a custom constraint.

Returns a google.rpc.Status with google.rpc.Code.NOT_FOUND if the constraint does not exist.

Parameters
Name Description
name CustomConstraintName

Required. Name of the custom constraint to delete. See the custom constraint entry for naming rules.

cancellationToken CancellationToken

A CancellationToken to use for this RPC.

Returns
Type Description
Task

A Task containing the RPC response.

Example
// Create client
OrgPolicyClient orgPolicyClient = await OrgPolicyClient.CreateAsync();
// Initialize request argument(s)
CustomConstraintName name = CustomConstraintName.FromOrganizationCustomConstraint("[ORGANIZATION]", "[CUSTOM_CONSTRAINT]");
// Make the request
await orgPolicyClient.DeleteCustomConstraintAsync(name);

DeleteCustomConstraintAsync(DeleteCustomConstraintRequest, CallSettings)

public virtual Task DeleteCustomConstraintAsync(DeleteCustomConstraintRequest request, CallSettings callSettings = null)

Deletes a custom constraint.

Returns a google.rpc.Status with google.rpc.Code.NOT_FOUND if the constraint does not exist.

Parameters
Name Description
request DeleteCustomConstraintRequest

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
Task

A Task containing the RPC response.

Example
// Create client
OrgPolicyClient orgPolicyClient = await OrgPolicyClient.CreateAsync();
// Initialize request argument(s)
DeleteCustomConstraintRequest request = new DeleteCustomConstraintRequest
{
    CustomConstraintName = CustomConstraintName.FromOrganizationCustomConstraint("[ORGANIZATION]", "[CUSTOM_CONSTRAINT]"),
};
// Make the request
await orgPolicyClient.DeleteCustomConstraintAsync(request);

DeleteCustomConstraintAsync(DeleteCustomConstraintRequest, CancellationToken)

public virtual Task DeleteCustomConstraintAsync(DeleteCustomConstraintRequest request, CancellationToken cancellationToken)

Deletes a custom constraint.

Returns a google.rpc.Status with google.rpc.Code.NOT_FOUND if the constraint does not exist.

Parameters
Name Description
request DeleteCustomConstraintRequest

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

cancellationToken CancellationToken

A CancellationToken to use for this RPC.

Returns
Type Description
Task

A Task containing the RPC response.

Example
// Create client
OrgPolicyClient orgPolicyClient = await OrgPolicyClient.CreateAsync();
// Initialize request argument(s)
DeleteCustomConstraintRequest request = new DeleteCustomConstraintRequest
{
    CustomConstraintName = CustomConstraintName.FromOrganizationCustomConstraint("[ORGANIZATION]", "[CUSTOM_CONSTRAINT]"),
};
// Make the request
await orgPolicyClient.DeleteCustomConstraintAsync(request);

DeleteCustomConstraintAsync(string, CallSettings)

public virtual Task DeleteCustomConstraintAsync(string name, CallSettings callSettings = null)

Deletes a custom constraint.

Returns a google.rpc.Status with google.rpc.Code.NOT_FOUND if the constraint does not exist.

Parameters
Name Description
name string

Required. Name of the custom constraint to delete. See the custom constraint entry for naming rules.

callSettings CallSettings

If not null, applies overrides to this RPC call.

Returns
Type Description
Task

A Task containing the RPC response.

Example
// Create client
OrgPolicyClient orgPolicyClient = await OrgPolicyClient.CreateAsync();
// Initialize request argument(s)
string name = "organizations/[ORGANIZATION]/customConstraints/[CUSTOM_CONSTRAINT]";
// Make the request
await orgPolicyClient.DeleteCustomConstraintAsync(name);

DeleteCustomConstraintAsync(string, CancellationToken)

public virtual Task DeleteCustomConstraintAsync(string name, CancellationToken cancellationToken)

Deletes a custom constraint.

Returns a google.rpc.Status with google.rpc.Code.NOT_FOUND if the constraint does not exist.

Parameters
Name Description
name string

Required. Name of the custom constraint to delete. See the custom constraint entry for naming rules.

cancellationToken CancellationToken

A CancellationToken to use for this RPC.

Returns
Type Description
Task

A Task containing the RPC response.

Example
// Create client
OrgPolicyClient orgPolicyClient = await OrgPolicyClient.CreateAsync();
// Initialize request argument(s)
string name = "organizations/[ORGANIZATION]/customConstraints/[CUSTOM_CONSTRAINT]";
// Make the request
await orgPolicyClient.DeleteCustomConstraintAsync(name);

DeletePolicy(DeletePolicyRequest, CallSettings)

public virtual void DeletePolicy(DeletePolicyRequest request, CallSettings callSettings = null)

Deletes a policy.

Returns a google.rpc.Status with google.rpc.Code.NOT_FOUND if the constraint or organization policy does not exist.

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.

Example
// Create client
OrgPolicyClient orgPolicyClient = OrgPolicyClient.Create();
// Initialize request argument(s)
DeletePolicyRequest request = new DeletePolicyRequest
{
    PolicyName = PolicyName.FromProjectPolicy("[PROJECT]", "[POLICY]"),
    Etag = "",
};
// Make the request
orgPolicyClient.DeletePolicy(request);

DeletePolicy(PolicyName, CallSettings)

public virtual void DeletePolicy(PolicyName name, CallSettings callSettings = null)

Deletes a policy.

Returns a google.rpc.Status with google.rpc.Code.NOT_FOUND if the constraint or organization policy does not exist.

Parameters
Name Description
name PolicyName

Required. Name of the policy to delete. See the policy entry for naming rules.

callSettings CallSettings

If not null, applies overrides to this RPC call.

Example
// Create client
OrgPolicyClient orgPolicyClient = OrgPolicyClient.Create();
// Initialize request argument(s)
PolicyName name = PolicyName.FromProjectPolicy("[PROJECT]", "[POLICY]");
// Make the request
orgPolicyClient.DeletePolicy(name);

DeletePolicy(string, CallSettings)

public virtual void DeletePolicy(string name, CallSettings callSettings = null)

Deletes a policy.

Returns a google.rpc.Status with google.rpc.Code.NOT_FOUND if the constraint or organization policy does not exist.

Parameters
Name Description
name string

Required. Name of the policy to delete. See the policy entry for naming rules.

callSettings CallSettings

If not null, applies overrides to this RPC call.

Example
// Create client
OrgPolicyClient orgPolicyClient = OrgPolicyClient.Create();
// Initialize request argument(s)
string name = "projects/[PROJECT]/policies/[POLICY]";
// Make the request
orgPolicyClient.DeletePolicy(name);

DeletePolicyAsync(DeletePolicyRequest, CallSettings)

public virtual Task DeletePolicyAsync(DeletePolicyRequest request, CallSettings callSettings = null)

Deletes a policy.

Returns a google.rpc.Status with google.rpc.Code.NOT_FOUND if the constraint or organization policy does not exist.

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
Task

A Task containing the RPC response.

Example
// Create client
OrgPolicyClient orgPolicyClient = await OrgPolicyClient.CreateAsync();
// Initialize request argument(s)
DeletePolicyRequest request = new DeletePolicyRequest
{
    PolicyName = PolicyName.FromProjectPolicy("[PROJECT]", "[POLICY]"),
    Etag = "",
};
// Make the request
await orgPolicyClient.DeletePolicyAsync(request);

DeletePolicyAsync(DeletePolicyRequest, CancellationToken)

public virtual Task DeletePolicyAsync(DeletePolicyRequest request, CancellationToken cancellationToken)

Deletes a policy.

Returns a google.rpc.Status with google.rpc.Code.NOT_FOUND if the constraint or organization policy does not exist.

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
Task

A Task containing the RPC response.

Example
// Create client
OrgPolicyClient orgPolicyClient = await OrgPolicyClient.CreateAsync();
// Initialize request argument(s)
DeletePolicyRequest request = new DeletePolicyRequest
{
    PolicyName = PolicyName.FromProjectPolicy("[PROJECT]", "[POLICY]"),
    Etag = "",
};
// Make the request
await orgPolicyClient.DeletePolicyAsync(request);

DeletePolicyAsync(PolicyName, CallSettings)

public virtual Task DeletePolicyAsync(PolicyName name, CallSettings callSettings = null)

Deletes a policy.

Returns a google.rpc.Status with google.rpc.Code.NOT_FOUND if the constraint or organization policy does not exist.

Parameters
Name Description
name PolicyName

Required. Name of the policy to delete. See the policy entry for naming rules.

callSettings CallSettings

If not null, applies overrides to this RPC call.

Returns
Type Description
Task

A Task containing the RPC response.

Example
// Create client
OrgPolicyClient orgPolicyClient = await OrgPolicyClient.CreateAsync();
// Initialize request argument(s)
PolicyName name = PolicyName.FromProjectPolicy("[PROJECT]", "[POLICY]");
// Make the request
await orgPolicyClient.DeletePolicyAsync(name);

DeletePolicyAsync(PolicyName, CancellationToken)

public virtual Task DeletePolicyAsync(PolicyName name, CancellationToken cancellationToken)

Deletes a policy.

Returns a google.rpc.Status with google.rpc.Code.NOT_FOUND if the constraint or organization policy does not exist.

Parameters
Name Description
name PolicyName

Required. Name of the policy to delete. See the policy entry for naming rules.

cancellationToken CancellationToken

A CancellationToken to use for this RPC.

Returns
Type Description
Task

A Task containing the RPC response.

Example
// Create client
OrgPolicyClient orgPolicyClient = await OrgPolicyClient.CreateAsync();
// Initialize request argument(s)
PolicyName name = PolicyName.FromProjectPolicy("[PROJECT]", "[POLICY]");
// Make the request
await orgPolicyClient.DeletePolicyAsync(name);

DeletePolicyAsync(string, CallSettings)

public virtual Task DeletePolicyAsync(string name, CallSettings callSettings = null)

Deletes a policy.

Returns a google.rpc.Status with google.rpc.Code.NOT_FOUND if the constraint or organization policy does not exist.

Parameters
Name Description
name string

Required. Name of the policy to delete. See the policy entry for naming rules.

callSettings CallSettings

If not null, applies overrides to this RPC call.

Returns
Type Description
Task

A Task containing the RPC response.

Example
// Create client
OrgPolicyClient orgPolicyClient = await OrgPolicyClient.CreateAsync();
// Initialize request argument(s)
string name = "projects/[PROJECT]/policies/[POLICY]";
// Make the request
await orgPolicyClient.DeletePolicyAsync(name);

DeletePolicyAsync(string, CancellationToken)

public virtual Task DeletePolicyAsync(string name, CancellationToken cancellationToken)

Deletes a policy.

Returns a google.rpc.Status with google.rpc.Code.NOT_FOUND if the constraint or organization policy does not exist.

Parameters
Name Description
name string

Required. Name of the policy to delete. See the policy entry for naming rules.

cancellationToken CancellationToken

A CancellationToken to use for this RPC.

Returns
Type Description
Task

A Task containing the RPC response.

Example
// Create client
OrgPolicyClient orgPolicyClient = await OrgPolicyClient.CreateAsync();
// Initialize request argument(s)
string name = "projects/[PROJECT]/policies/[POLICY]";
// Make the request
await orgPolicyClient.DeletePolicyAsync(name);

GetCustomConstraint(CustomConstraintName, CallSettings)

public virtual CustomConstraint GetCustomConstraint(CustomConstraintName name, CallSettings callSettings = null)

Gets a custom constraint.

Returns a google.rpc.Status with google.rpc.Code.NOT_FOUND if the custom constraint does not exist.

Parameters
Name Description
name CustomConstraintName

Required. Resource name of the custom constraint. See the custom constraint entry for naming requirements.

callSettings CallSettings

If not null, applies overrides to this RPC call.

Returns
Type Description
CustomConstraint

The RPC response.

Example
// Create client
OrgPolicyClient orgPolicyClient = OrgPolicyClient.Create();
// Initialize request argument(s)
CustomConstraintName name = CustomConstraintName.FromOrganizationCustomConstraint("[ORGANIZATION]", "[CUSTOM_CONSTRAINT]");
// Make the request
CustomConstraint response = orgPolicyClient.GetCustomConstraint(name);

GetCustomConstraint(GetCustomConstraintRequest, CallSettings)

public virtual CustomConstraint GetCustomConstraint(GetCustomConstraintRequest request, CallSettings callSettings = null)

Gets a custom constraint.

Returns a google.rpc.Status with google.rpc.Code.NOT_FOUND if the custom constraint does not exist.

Parameters
Name Description
request GetCustomConstraintRequest

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
CustomConstraint

The RPC response.

Example
// Create client
OrgPolicyClient orgPolicyClient = OrgPolicyClient.Create();
// Initialize request argument(s)
GetCustomConstraintRequest request = new GetCustomConstraintRequest
{
    CustomConstraintName = CustomConstraintName.FromOrganizationCustomConstraint("[ORGANIZATION]", "[CUSTOM_CONSTRAINT]"),
};
// Make the request
CustomConstraint response = orgPolicyClient.GetCustomConstraint(request);

GetCustomConstraint(string, CallSettings)

public virtual CustomConstraint GetCustomConstraint(string name, CallSettings callSettings = null)

Gets a custom constraint.

Returns a google.rpc.Status with google.rpc.Code.NOT_FOUND if the custom constraint does not exist.

Parameters
Name Description
name string

Required. Resource name of the custom constraint. See the custom constraint entry for naming requirements.

callSettings CallSettings

If not null, applies overrides to this RPC call.

Returns
Type Description
CustomConstraint

The RPC response.

Example
// Create client
OrgPolicyClient orgPolicyClient = OrgPolicyClient.Create();
// Initialize request argument(s)
string name = "organizations/[ORGANIZATION]/customConstraints/[CUSTOM_CONSTRAINT]";
// Make the request
CustomConstraint response = orgPolicyClient.GetCustomConstraint(name);

GetCustomConstraintAsync(CustomConstraintName, CallSettings)

public virtual Task<CustomConstraint> GetCustomConstraintAsync(CustomConstraintName name, CallSettings callSettings = null)

Gets a custom constraint.

Returns a google.rpc.Status with google.rpc.Code.NOT_FOUND if the custom constraint does not exist.

Parameters
Name Description
name CustomConstraintName

Required. Resource name of the custom constraint. See the custom constraint entry for naming requirements.

callSettings CallSettings

If not null, applies overrides to this RPC call.

Returns
Type Description
TaskCustomConstraint

A Task containing the RPC response.

Example
// Create client
OrgPolicyClient orgPolicyClient = await OrgPolicyClient.CreateAsync();
// Initialize request argument(s)
CustomConstraintName name = CustomConstraintName.FromOrganizationCustomConstraint("[ORGANIZATION]", "[CUSTOM_CONSTRAINT]");
// Make the request
CustomConstraint response = await orgPolicyClient.GetCustomConstraintAsync(name);

GetCustomConstraintAsync(CustomConstraintName, CancellationToken)

public virtual Task<CustomConstraint> GetCustomConstraintAsync(CustomConstraintName name, CancellationToken cancellationToken)

Gets a custom constraint.

Returns a google.rpc.Status with google.rpc.Code.NOT_FOUND if the custom constraint does not exist.

Parameters
Name Description
name CustomConstraintName

Required. Resource name of the custom constraint. See the custom constraint entry for naming requirements.

cancellationToken CancellationToken

A CancellationToken to use for this RPC.

Returns
Type Description
TaskCustomConstraint

A Task containing the RPC response.

Example
// Create client
OrgPolicyClient orgPolicyClient = await OrgPolicyClient.CreateAsync();
// Initialize request argument(s)
CustomConstraintName name = CustomConstraintName.FromOrganizationCustomConstraint("[ORGANIZATION]", "[CUSTOM_CONSTRAINT]");
// Make the request
CustomConstraint response = await orgPolicyClient.GetCustomConstraintAsync(name);

GetCustomConstraintAsync(GetCustomConstraintRequest, CallSettings)

public virtual Task<CustomConstraint> GetCustomConstraintAsync(GetCustomConstraintRequest request, CallSettings callSettings = null)

Gets a custom constraint.

Returns a google.rpc.Status with google.rpc.Code.NOT_FOUND if the custom constraint does not exist.

Parameters
Name Description
request GetCustomConstraintRequest

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
TaskCustomConstraint

A Task containing the RPC response.

Example
// Create client
OrgPolicyClient orgPolicyClient = await OrgPolicyClient.CreateAsync();
// Initialize request argument(s)
GetCustomConstraintRequest request = new GetCustomConstraintRequest
{
    CustomConstraintName = CustomConstraintName.FromOrganizationCustomConstraint("[ORGANIZATION]", "[CUSTOM_CONSTRAINT]"),
};
// Make the request
CustomConstraint response = await orgPolicyClient.GetCustomConstraintAsync(request);

GetCustomConstraintAsync(GetCustomConstraintRequest, CancellationToken)

public virtual Task<CustomConstraint> GetCustomConstraintAsync(GetCustomConstraintRequest request, CancellationToken cancellationToken)

Gets a custom constraint.

Returns a google.rpc.Status with google.rpc.Code.NOT_FOUND if the custom constraint does not exist.

Parameters
Name Description
request GetCustomConstraintRequest

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

cancellationToken CancellationToken

A CancellationToken to use for this RPC.

Returns
Type Description
TaskCustomConstraint

A Task containing the RPC response.

Example
// Create client
OrgPolicyClient orgPolicyClient = await OrgPolicyClient.CreateAsync();
// Initialize request argument(s)
GetCustomConstraintRequest request = new GetCustomConstraintRequest
{
    CustomConstraintName = CustomConstraintName.FromOrganizationCustomConstraint("[ORGANIZATION]", "[CUSTOM_CONSTRAINT]"),
};
// Make the request
CustomConstraint response = await orgPolicyClient.GetCustomConstraintAsync(request);

GetCustomConstraintAsync(string, CallSettings)

public virtual Task<CustomConstraint> GetCustomConstraintAsync(string name, CallSettings callSettings = null)

Gets a custom constraint.

Returns a google.rpc.Status with google.rpc.Code.NOT_FOUND if the custom constraint does not exist.

Parameters
Name Description
name string

Required. Resource name of the custom constraint. See the custom constraint entry for naming requirements.

callSettings CallSettings

If not null, applies overrides to this RPC call.

Returns
Type Description
TaskCustomConstraint

A Task containing the RPC response.

Example
// Create client
OrgPolicyClient orgPolicyClient = await OrgPolicyClient.CreateAsync();
// Initialize request argument(s)
string name = "organizations/[ORGANIZATION]/customConstraints/[CUSTOM_CONSTRAINT]";
// Make the request
CustomConstraint response = await orgPolicyClient.GetCustomConstraintAsync(name);

GetCustomConstraintAsync(string, CancellationToken)

public virtual Task<CustomConstraint> GetCustomConstraintAsync(string name, CancellationToken cancellationToken)

Gets a custom constraint.

Returns a google.rpc.Status with google.rpc.Code.NOT_FOUND if the custom constraint does not exist.

Parameters
Name Description
name string

Required. Resource name of the custom constraint. See the custom constraint entry for naming requirements.

cancellationToken CancellationToken

A CancellationToken to use for this RPC.

Returns
Type Description
TaskCustomConstraint

A Task containing the RPC response.

Example
// Create client
OrgPolicyClient orgPolicyClient = await OrgPolicyClient.CreateAsync();
// Initialize request argument(s)
string name = "organizations/[ORGANIZATION]/customConstraints/[CUSTOM_CONSTRAINT]";
// Make the request
CustomConstraint response = await orgPolicyClient.GetCustomConstraintAsync(name);

GetEffectivePolicy(GetEffectivePolicyRequest, CallSettings)

public virtual Policy GetEffectivePolicy(GetEffectivePolicyRequest request, CallSettings callSettings = null)

Gets the effective policy on a resource. This is the result of merging policies in the resource hierarchy and evaluating conditions. The returned policy will not have an etag or condition set because it is an evaluated policy across multiple resources. Subtrees of Resource Manager resource hierarchy with 'under:' prefix will not be expanded.

Parameters
Name Description
request GetEffectivePolicyRequest

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
OrgPolicyClient orgPolicyClient = OrgPolicyClient.Create();
// Initialize request argument(s)
GetEffectivePolicyRequest request = new GetEffectivePolicyRequest
{
    PolicyName = PolicyName.FromProjectPolicy("[PROJECT]", "[POLICY]"),
};
// Make the request
Policy response = orgPolicyClient.GetEffectivePolicy(request);

GetEffectivePolicy(PolicyName, CallSettings)

public virtual Policy GetEffectivePolicy(PolicyName name, CallSettings callSettings = null)

Gets the effective policy on a resource. This is the result of merging policies in the resource hierarchy and evaluating conditions. The returned policy will not have an etag or condition set because it is an evaluated policy across multiple resources. Subtrees of Resource Manager resource hierarchy with 'under:' prefix will not be expanded.

Parameters
Name Description
name PolicyName

Required. The effective policy to compute. See [Policy][google.cloud.orgpolicy.v2.Policy] for naming requirements.

callSettings CallSettings

If not null, applies overrides to this RPC call.

Returns
Type Description
Policy

The RPC response.

Example
// Create client
OrgPolicyClient orgPolicyClient = OrgPolicyClient.Create();
// Initialize request argument(s)
PolicyName name = PolicyName.FromProjectPolicy("[PROJECT]", "[POLICY]");
// Make the request
Policy response = orgPolicyClient.GetEffectivePolicy(name);

GetEffectivePolicy(string, CallSettings)

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

Gets the effective policy on a resource. This is the result of merging policies in the resource hierarchy and evaluating conditions. The returned policy will not have an etag or condition set because it is an evaluated policy across multiple resources. Subtrees of Resource Manager resource hierarchy with 'under:' prefix will not be expanded.

Parameters
Name Description
name string

Required. The effective policy to compute. See [Policy][google.cloud.orgpolicy.v2.Policy] for naming requirements.

callSettings CallSettings

If not null, applies overrides to this RPC call.

Returns
Type Description
Policy

The RPC response.

Example
// Create client
OrgPolicyClient orgPolicyClient = OrgPolicyClient.Create();
// Initialize request argument(s)
string name = "projects/[PROJECT]/policies/[POLICY]";
// Make the request
Policy response = orgPolicyClient.GetEffectivePolicy(name);

GetEffectivePolicyAsync(GetEffectivePolicyRequest, CallSettings)

public virtual Task<Policy> GetEffectivePolicyAsync(GetEffectivePolicyRequest request, CallSettings callSettings = null)

Gets the effective policy on a resource. This is the result of merging policies in the resource hierarchy and evaluating conditions. The returned policy will not have an etag or condition set because it is an evaluated policy across multiple resources. Subtrees of Resource Manager resource hierarchy with 'under:' prefix will not be expanded.

Parameters
Name Description
request GetEffectivePolicyRequest

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
OrgPolicyClient orgPolicyClient = await OrgPolicyClient.CreateAsync();
// Initialize request argument(s)
GetEffectivePolicyRequest request = new GetEffectivePolicyRequest
{
    PolicyName = PolicyName.FromProjectPolicy("[PROJECT]", "[POLICY]"),
};
// Make the request
Policy response = await orgPolicyClient.GetEffectivePolicyAsync(request);

GetEffectivePolicyAsync(GetEffectivePolicyRequest, CancellationToken)

public virtual Task<Policy> GetEffectivePolicyAsync(GetEffectivePolicyRequest request, CancellationToken cancellationToken)

Gets the effective policy on a resource. This is the result of merging policies in the resource hierarchy and evaluating conditions. The returned policy will not have an etag or condition set because it is an evaluated policy across multiple resources. Subtrees of Resource Manager resource hierarchy with 'under:' prefix will not be expanded.

Parameters
Name Description
request GetEffectivePolicyRequest

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
OrgPolicyClient orgPolicyClient = await OrgPolicyClient.CreateAsync();
// Initialize request argument(s)
GetEffectivePolicyRequest request = new GetEffectivePolicyRequest
{
    PolicyName = PolicyName.FromProjectPolicy("[PROJECT]", "[POLICY]"),
};
// Make the request
Policy response = await orgPolicyClient.GetEffectivePolicyAsync(request);

GetEffectivePolicyAsync(PolicyName, CallSettings)

public virtual Task<Policy> GetEffectivePolicyAsync(PolicyName name, CallSettings callSettings = null)

Gets the effective policy on a resource. This is the result of merging policies in the resource hierarchy and evaluating conditions. The returned policy will not have an etag or condition set because it is an evaluated policy across multiple resources. Subtrees of Resource Manager resource hierarchy with 'under:' prefix will not be expanded.

Parameters
Name Description
name PolicyName

Required. The effective policy to compute. See [Policy][google.cloud.orgpolicy.v2.Policy] for naming requirements.

callSettings CallSettings

If not null, applies overrides to this RPC call.

Returns
Type Description
TaskPolicy

A Task containing the RPC response.

Example
// Create client
OrgPolicyClient orgPolicyClient = await OrgPolicyClient.CreateAsync();
// Initialize request argument(s)
PolicyName name = PolicyName.FromProjectPolicy("[PROJECT]", "[POLICY]");
// Make the request
Policy response = await orgPolicyClient.GetEffectivePolicyAsync(name);

GetEffectivePolicyAsync(PolicyName, CancellationToken)

public virtual Task<Policy> GetEffectivePolicyAsync(PolicyName name, CancellationToken cancellationToken)

Gets the effective policy on a resource. This is the result of merging policies in the resource hierarchy and evaluating conditions. The returned policy will not have an etag or condition set because it is an evaluated policy across multiple resources. Subtrees of Resource Manager resource hierarchy with 'under:' prefix will not be expanded.

Parameters
Name Description
name PolicyName

Required. The effective policy to compute. See [Policy][google.cloud.orgpolicy.v2.Policy] for naming requirements.

cancellationToken CancellationToken

A CancellationToken to use for this RPC.

Returns
Type Description
TaskPolicy

A Task containing the RPC response.

Example
// Create client
OrgPolicyClient orgPolicyClient = await OrgPolicyClient.CreateAsync();
// Initialize request argument(s)
PolicyName name = PolicyName.FromProjectPolicy("[PROJECT]", "[POLICY]");
// Make the request
Policy response = await orgPolicyClient.GetEffectivePolicyAsync(name);

GetEffectivePolicyAsync(string, CallSettings)

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

Gets the effective policy on a resource. This is the result of merging policies in the resource hierarchy and evaluating conditions. The returned policy will not have an etag or condition set because it is an evaluated policy across multiple resources. Subtrees of Resource Manager resource hierarchy with 'under:' prefix will not be expanded.

Parameters
Name Description
name string

Required. The effective policy to compute. See [Policy][google.cloud.orgpolicy.v2.Policy] for naming requirements.

callSettings CallSettings

If not null, applies overrides to this RPC call.

Returns
Type Description
TaskPolicy

A Task containing the RPC response.

Example
// Create client
OrgPolicyClient orgPolicyClient = await OrgPolicyClient.CreateAsync();
// Initialize request argument(s)
string name = "projects/[PROJECT]/policies/[POLICY]";
// Make the request
Policy response = await orgPolicyClient.GetEffectivePolicyAsync(name);

GetEffectivePolicyAsync(string, CancellationToken)

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

Gets the effective policy on a resource. This is the result of merging policies in the resource hierarchy and evaluating conditions. The returned policy will not have an etag or condition set because it is an evaluated policy across multiple resources. Subtrees of Resource Manager resource hierarchy with 'under:' prefix will not be expanded.

Parameters
Name Description
name string

Required. The effective policy to compute. See [Policy][google.cloud.orgpolicy.v2.Policy] for naming requirements.

cancellationToken CancellationToken

A CancellationToken to use for this RPC.

Returns
Type Description
TaskPolicy

A Task containing the RPC response.

Example
// Create client
OrgPolicyClient orgPolicyClient = await OrgPolicyClient.CreateAsync();
// Initialize request argument(s)
string name = "projects/[PROJECT]/policies/[POLICY]";
// Make the request
Policy response = await orgPolicyClient.GetEffectivePolicyAsync(name);

GetPolicy(GetPolicyRequest, CallSettings)

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

Gets a policy on a resource.

If no policy is set on the resource, NOT_FOUND is returned. The etag value can be used with UpdatePolicy() to update a policy during read-modify-write.

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
OrgPolicyClient orgPolicyClient = OrgPolicyClient.Create();
// Initialize request argument(s)
GetPolicyRequest request = new GetPolicyRequest
{
    PolicyName = PolicyName.FromProjectPolicy("[PROJECT]", "[POLICY]"),
};
// Make the request
Policy response = orgPolicyClient.GetPolicy(request);

GetPolicy(PolicyName, CallSettings)

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

Gets a policy on a resource.

If no policy is set on the resource, NOT_FOUND is returned. The etag value can be used with UpdatePolicy() to update a policy during read-modify-write.

Parameters
Name Description
name PolicyName

Required. Resource name of the policy. See [Policy][google.cloud.orgpolicy.v2.Policy] for naming requirements.

callSettings CallSettings

If not null, applies overrides to this RPC call.

Returns
Type Description
Policy

The RPC response.

Example
// Create client
OrgPolicyClient orgPolicyClient = OrgPolicyClient.Create();
// Initialize request argument(s)
PolicyName name = PolicyName.FromProjectPolicy("[PROJECT]", "[POLICY]");
// Make the request
Policy response = orgPolicyClient.GetPolicy(name);

GetPolicy(string, CallSettings)

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

Gets a policy on a resource.

If no policy is set on the resource, NOT_FOUND is returned. The etag value can be used with UpdatePolicy() to update a policy during read-modify-write.

Parameters
Name Description
name string

Required. Resource name of the policy. See [Policy][google.cloud.orgpolicy.v2.Policy] for naming requirements.

callSettings CallSettings

If not null, applies overrides to this RPC call.

Returns
Type Description
Policy

The RPC response.

Example
// Create client
OrgPolicyClient orgPolicyClient = OrgPolicyClient.Create();
// Initialize request argument(s)
string name = "projects/[PROJECT]/policies/[POLICY]";
// Make the request
Policy response = orgPolicyClient.GetPolicy(name);

GetPolicyAsync(GetPolicyRequest, CallSettings)

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

Gets a policy on a resource.

If no policy is set on the resource, NOT_FOUND is returned. The etag value can be used with UpdatePolicy() to update a policy during read-modify-write.

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
OrgPolicyClient orgPolicyClient = await OrgPolicyClient.CreateAsync();
// Initialize request argument(s)
GetPolicyRequest request = new GetPolicyRequest
{
    PolicyName = PolicyName.FromProjectPolicy("[PROJECT]", "[POLICY]"),
};
// Make the request
Policy response = await orgPolicyClient.GetPolicyAsync(request);

GetPolicyAsync(GetPolicyRequest, CancellationToken)

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

Gets a policy on a resource.

If no policy is set on the resource, NOT_FOUND is returned. The etag value can be used with UpdatePolicy() to update a policy during read-modify-write.

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
OrgPolicyClient orgPolicyClient = await OrgPolicyClient.CreateAsync();
// Initialize request argument(s)
GetPolicyRequest request = new GetPolicyRequest
{
    PolicyName = PolicyName.FromProjectPolicy("[PROJECT]", "[POLICY]"),
};
// Make the request
Policy response = await orgPolicyClient.GetPolicyAsync(request);

GetPolicyAsync(PolicyName, CallSettings)

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

Gets a policy on a resource.

If no policy is set on the resource, NOT_FOUND is returned. The etag value can be used with UpdatePolicy() to update a policy during read-modify-write.

Parameters
Name Description
name PolicyName

Required. Resource name of the policy. See [Policy][google.cloud.orgpolicy.v2.Policy] for naming requirements.

callSettings CallSettings

If not null, applies overrides to this RPC call.

Returns
Type Description
TaskPolicy

A Task containing the RPC response.

Example
// Create client
OrgPolicyClient orgPolicyClient = await OrgPolicyClient.CreateAsync();
// Initialize request argument(s)
PolicyName name = PolicyName.FromProjectPolicy("[PROJECT]", "[POLICY]");
// Make the request
Policy response = await orgPolicyClient.GetPolicyAsync(name);

GetPolicyAsync(PolicyName, CancellationToken)

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

Gets a policy on a resource.

If no policy is set on the resource, NOT_FOUND is returned. The etag value can be used with UpdatePolicy() to update a policy during read-modify-write.

Parameters
Name Description
name PolicyName

Required. Resource name of the policy. See [Policy][google.cloud.orgpolicy.v2.Policy] for naming requirements.

cancellationToken CancellationToken

A CancellationToken to use for this RPC.

Returns
Type Description
TaskPolicy

A Task containing the RPC response.

Example
// Create client
OrgPolicyClient orgPolicyClient = await OrgPolicyClient.CreateAsync();
// Initialize request argument(s)
PolicyName name = PolicyName.FromProjectPolicy("[PROJECT]", "[POLICY]");
// Make the request
Policy response = await orgPolicyClient.GetPolicyAsync(name);

GetPolicyAsync(string, CallSettings)

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

Gets a policy on a resource.

If no policy is set on the resource, NOT_FOUND is returned. The etag value can be used with UpdatePolicy() to update a policy during read-modify-write.

Parameters
Name Description
name string

Required. Resource name of the policy. See [Policy][google.cloud.orgpolicy.v2.Policy] for naming requirements.

callSettings CallSettings

If not null, applies overrides to this RPC call.

Returns
Type Description
TaskPolicy

A Task containing the RPC response.

Example
// Create client
OrgPolicyClient orgPolicyClient = await OrgPolicyClient.CreateAsync();
// Initialize request argument(s)
string name = "projects/[PROJECT]/policies/[POLICY]";
// Make the request
Policy response = await orgPolicyClient.GetPolicyAsync(name);

GetPolicyAsync(string, CancellationToken)

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

Gets a policy on a resource.

If no policy is set on the resource, NOT_FOUND is returned. The etag value can be used with UpdatePolicy() to update a policy during read-modify-write.

Parameters
Name Description
name string

Required. Resource name of the policy. See [Policy][google.cloud.orgpolicy.v2.Policy] for naming requirements.

cancellationToken CancellationToken

A CancellationToken to use for this RPC.

Returns
Type Description
TaskPolicy

A Task containing the RPC response.

Example
// Create client
OrgPolicyClient orgPolicyClient = await OrgPolicyClient.CreateAsync();
// Initialize request argument(s)
string name = "projects/[PROJECT]/policies/[POLICY]";
// Make the request
Policy response = await orgPolicyClient.GetPolicyAsync(name);

ListConstraints(FolderName, string, int?, CallSettings)

public virtual PagedEnumerable<ListConstraintsResponse, Constraint> ListConstraints(FolderName parent, string pageToken = null, int? pageSize = null, CallSettings callSettings = null)

Lists constraints that could be applied on the specified resource.

Parameters
Name Description
parent FolderName

Required. The Google Cloud resource that parents the constraint. Must be in one of the following forms:

  • projects/{project_number}
  • projects/{project_id}
  • folders/{folder_id}
  • organizations/{organization_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
PagedEnumerableListConstraintsResponseConstraint

A pageable sequence of Constraint resources.

Example
// Create client
OrgPolicyClient orgPolicyClient = OrgPolicyClient.Create();
// Initialize request argument(s)
FolderName parent = FolderName.FromFolder("[FOLDER]");
// Make the request
PagedEnumerable<ListConstraintsResponse, Constraint> response = orgPolicyClient.ListConstraints(parent);

// Iterate over all response items, lazily performing RPCs as required
foreach (Constraint 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 (ListConstraintsResponse page in response.AsRawResponses())
{
    // Do something with each page of items
    Console.WriteLine("A page of results:");
    foreach (Constraint 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<Constraint> 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 (Constraint 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;

ListConstraints(OrganizationName, string, int?, CallSettings)

public virtual PagedEnumerable<ListConstraintsResponse, Constraint> ListConstraints(OrganizationName parent, string pageToken = null, int? pageSize = null, CallSettings callSettings = null)

Lists constraints that could be applied on the specified resource.

Parameters
Name Description
parent OrganizationName

Required. The Google Cloud resource that parents the constraint. Must be in one of the following forms:

  • projects/{project_number}
  • projects/{project_id}
  • folders/{folder_id}
  • organizations/{organization_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
PagedEnumerableListConstraintsResponseConstraint

A pageable sequence of Constraint resources.

Example
// Create client
OrgPolicyClient orgPolicyClient = OrgPolicyClient.Create();
// Initialize request argument(s)
OrganizationName parent = OrganizationName.FromOrganization("[ORGANIZATION]");
// Make the request
PagedEnumerable<ListConstraintsResponse, Constraint> response = orgPolicyClient.ListConstraints(parent);

// Iterate over all response items, lazily performing RPCs as required
foreach (Constraint 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 (ListConstraintsResponse page in response.AsRawResponses())
{
    // Do something with each page of items
    Console.WriteLine("A page of results:");
    foreach (Constraint 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<Constraint> 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 (Constraint 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;

ListConstraints(ProjectName, string, int?, CallSettings)

public virtual PagedEnumerable<ListConstraintsResponse, Constraint> ListConstraints(ProjectName parent, string pageToken = null, int? pageSize = null, CallSettings callSettings = null)

Lists constraints that could be applied on the specified resource.

Parameters
Name Description
parent ProjectName

Required. The Google Cloud resource that parents the constraint. Must be in one of the following forms:

  • projects/{project_number}
  • projects/{project_id}
  • folders/{folder_id}
  • organizations/{organization_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
PagedEnumerableListConstraintsResponseConstraint

A pageable sequence of Constraint resources.

Example
// Create client
OrgPolicyClient orgPolicyClient = OrgPolicyClient.Create();
// Initialize request argument(s)
ProjectName parent = ProjectName.FromProject("[PROJECT]");
// Make the request
PagedEnumerable<ListConstraintsResponse, Constraint> response = orgPolicyClient.ListConstraints(parent);

// Iterate over all response items, lazily performing RPCs as required
foreach (Constraint 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 (ListConstraintsResponse page in response.AsRawResponses())
{
    // Do something with each page of items
    Console.WriteLine("A page of results:");
    foreach (Constraint 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<Constraint> 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 (Constraint 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;

ListConstraints(ListConstraintsRequest, CallSettings)

public virtual PagedEnumerable<ListConstraintsResponse, Constraint> ListConstraints(ListConstraintsRequest request, CallSettings callSettings = null)

Lists constraints that could be applied on the specified resource.

Parameters
Name Description
request ListConstraintsRequest

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
PagedEnumerableListConstraintsResponseConstraint

A pageable sequence of Constraint resources.

Example
// Create client
OrgPolicyClient orgPolicyClient = OrgPolicyClient.Create();
// Initialize request argument(s)
ListConstraintsRequest request = new ListConstraintsRequest
{
    ParentAsProjectName = ProjectName.FromProject("[PROJECT]"),
};
// Make the request
PagedEnumerable<ListConstraintsResponse, Constraint> response = orgPolicyClient.ListConstraints(request);

// Iterate over all response items, lazily performing RPCs as required
foreach (Constraint 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 (ListConstraintsResponse page in response.AsRawResponses())
{
    // Do something with each page of items
    Console.WriteLine("A page of results:");
    foreach (Constraint 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<Constraint> 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 (Constraint 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;

ListConstraints(string, string, int?, CallSettings)

public virtual PagedEnumerable<ListConstraintsResponse, Constraint> ListConstraints(string parent, string pageToken = null, int? pageSize = null, CallSettings callSettings = null)

Lists constraints that could be applied on the specified resource.

Parameters
Name Description
parent string

Required. The Google Cloud resource that parents the constraint. Must be in one of the following forms:

  • projects/{project_number}
  • projects/{project_id}
  • folders/{folder_id}
  • organizations/{organization_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
PagedEnumerableListConstraintsResponseConstraint

A pageable sequence of Constraint resources.

Example
// Create client
OrgPolicyClient orgPolicyClient = OrgPolicyClient.Create();
// Initialize request argument(s)
string parent = "projects/[PROJECT]";
// Make the request
PagedEnumerable<ListConstraintsResponse, Constraint> response = orgPolicyClient.ListConstraints(parent);

// Iterate over all response items, lazily performing RPCs as required
foreach (Constraint 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 (ListConstraintsResponse page in response.AsRawResponses())
{
    // Do something with each page of items
    Console.WriteLine("A page of results:");
    foreach (Constraint 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<Constraint> 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 (Constraint 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;

ListConstraintsAsync(FolderName, string, int?, CallSettings)

public virtual PagedAsyncEnumerable<ListConstraintsResponse, Constraint> ListConstraintsAsync(FolderName parent, string pageToken = null, int? pageSize = null, CallSettings callSettings = null)

Lists constraints that could be applied on the specified resource.

Parameters
Name Description
parent FolderName

Required. The Google Cloud resource that parents the constraint. Must be in one of the following forms:

  • projects/{project_number}
  • projects/{project_id}
  • folders/{folder_id}
  • organizations/{organization_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
PagedAsyncEnumerableListConstraintsResponseConstraint

A pageable asynchronous sequence of Constraint resources.

Example
// Create client
OrgPolicyClient orgPolicyClient = await OrgPolicyClient.CreateAsync();
// Initialize request argument(s)
FolderName parent = FolderName.FromFolder("[FOLDER]");
// Make the request
PagedAsyncEnumerable<ListConstraintsResponse, Constraint> response = orgPolicyClient.ListConstraintsAsync(parent);

// Iterate over all response items, lazily performing RPCs as required
await response.ForEachAsync((Constraint 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((ListConstraintsResponse page) =>
{
    // Do something with each page of items
    Console.WriteLine("A page of results:");
    foreach (Constraint 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<Constraint> 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 (Constraint 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;

ListConstraintsAsync(OrganizationName, string, int?, CallSettings)

public virtual PagedAsyncEnumerable<ListConstraintsResponse, Constraint> ListConstraintsAsync(OrganizationName parent, string pageToken = null, int? pageSize = null, CallSettings callSettings = null)

Lists constraints that could be applied on the specified resource.

Parameters
Name Description
parent OrganizationName

Required. The Google Cloud resource that parents the constraint. Must be in one of the following forms:

  • projects/{project_number}
  • projects/{project_id}
  • folders/{folder_id}
  • organizations/{organization_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
PagedAsyncEnumerableListConstraintsResponseConstraint

A pageable asynchronous sequence of Constraint resources.

Example
// Create client
OrgPolicyClient orgPolicyClient = await OrgPolicyClient.CreateAsync();
// Initialize request argument(s)
OrganizationName parent = OrganizationName.FromOrganization("[ORGANIZATION]");
// Make the request
PagedAsyncEnumerable<ListConstraintsResponse, Constraint> response = orgPolicyClient.ListConstraintsAsync(parent);

// Iterate over all response items, lazily performing RPCs as required
await response.ForEachAsync((Constraint 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((ListConstraintsResponse page) =>
{
    // Do something with each page of items
    Console.WriteLine("A page of results:");
    foreach (Constraint 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<Constraint> 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 (Constraint 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;

ListConstraintsAsync(ProjectName, string, int?, CallSettings)

public virtual PagedAsyncEnumerable<ListConstraintsResponse, Constraint> ListConstraintsAsync(ProjectName parent, string pageToken = null, int? pageSize = null, CallSettings callSettings = null)

Lists constraints that could be applied on the specified resource.

Parameters
Name Description
parent ProjectName

Required. The Google Cloud resource that parents the constraint. Must be in one of the following forms:

  • projects/{project_number}
  • projects/{project_id}
  • folders/{folder_id}
  • organizations/{organization_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
PagedAsyncEnumerableListConstraintsResponseConstraint

A pageable asynchronous sequence of Constraint resources.

Example
// Create client
OrgPolicyClient orgPolicyClient = await OrgPolicyClient.CreateAsync();
// Initialize request argument(s)
ProjectName parent = ProjectName.FromProject("[PROJECT]");
// Make the request
PagedAsyncEnumerable<ListConstraintsResponse, Constraint> response = orgPolicyClient.ListConstraintsAsync(parent);

// Iterate over all response items, lazily performing RPCs as required
await response.ForEachAsync((Constraint 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((ListConstraintsResponse page) =>
{
    // Do something with each page of items
    Console.WriteLine("A page of results:");
    foreach (Constraint 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<Constraint> 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 (Constraint 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;

ListConstraintsAsync(ListConstraintsRequest, CallSettings)

public virtual PagedAsyncEnumerable<ListConstraintsResponse, Constraint> ListConstraintsAsync(ListConstraintsRequest request, CallSettings callSettings = null)

Lists constraints that could be applied on the specified resource.

Parameters
Name Description
request ListConstraintsRequest

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
PagedAsyncEnumerableListConstraintsResponseConstraint

A pageable asynchronous sequence of Constraint resources.

Example
// Create client
OrgPolicyClient orgPolicyClient = await OrgPolicyClient.CreateAsync();
// Initialize request argument(s)
ListConstraintsRequest request = new ListConstraintsRequest
{
    ParentAsProjectName = ProjectName.FromProject("[PROJECT]"),
};
// Make the request
PagedAsyncEnumerable<ListConstraintsResponse, Constraint> response = orgPolicyClient.ListConstraintsAsync(request);

// Iterate over all response items, lazily performing RPCs as required
await response.ForEachAsync((Constraint 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((ListConstraintsResponse page) =>
{
    // Do something with each page of items
    Console.WriteLine("A page of results:");
    foreach (Constraint 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<Constraint> 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 (Constraint 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;

ListConstraintsAsync(string, string, int?, CallSettings)

public virtual PagedAsyncEnumerable<ListConstraintsResponse, Constraint> ListConstraintsAsync(string parent, string pageToken = null, int? pageSize = null, CallSettings callSettings = null)

Lists constraints that could be applied on the specified resource.

Parameters
Name Description
parent string

Required. The Google Cloud resource that parents the constraint. Must be in one of the following forms:

  • projects/{project_number}
  • projects/{project_id}
  • folders/{folder_id}
  • organizations/{organization_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
PagedAsyncEnumerableListConstraintsResponseConstraint

A pageable asynchronous sequence of Constraint resources.

Example
// Create client
OrgPolicyClient orgPolicyClient = await OrgPolicyClient.CreateAsync();
// Initialize request argument(s)
string parent = "projects/[PROJECT]";
// Make the request
PagedAsyncEnumerable<ListConstraintsResponse, Constraint> response = orgPolicyClient.ListConstraintsAsync(parent);

// Iterate over all response items, lazily performing RPCs as required
await response.ForEachAsync((Constraint 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((ListConstraintsResponse page) =>
{
    // Do something with each page of items
    Console.WriteLine("A page of results:");
    foreach (Constraint 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<Constraint> 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 (Constraint 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;

ListCustomConstraints(OrganizationName, string, int?, CallSettings)

public virtual PagedEnumerable<ListCustomConstraintsResponse, CustomConstraint> ListCustomConstraints(OrganizationName parent, string pageToken = null, int? pageSize = null, CallSettings callSettings = null)

Retrieves all of the custom constraints that exist on a particular organization resource.

Parameters
Name Description
parent OrganizationName

Required. The target Google Cloud resource that parents the set of custom constraints that will be returned from this call. Must be in one of the following forms:

  • organizations/{organization_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
PagedEnumerableListCustomConstraintsResponseCustomConstraint

A pageable sequence of CustomConstraint resources.

Example
// Create client
OrgPolicyClient orgPolicyClient = OrgPolicyClient.Create();
// Initialize request argument(s)
OrganizationName parent = OrganizationName.FromOrganization("[ORGANIZATION]");
// Make the request
PagedEnumerable<ListCustomConstraintsResponse, CustomConstraint> response = orgPolicyClient.ListCustomConstraints(parent);

// Iterate over all response items, lazily performing RPCs as required
foreach (CustomConstraint 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 (ListCustomConstraintsResponse page in response.AsRawResponses())
{
    // Do something with each page of items
    Console.WriteLine("A page of results:");
    foreach (CustomConstraint 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<CustomConstraint> 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 (CustomConstraint 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;

ListCustomConstraints(ListCustomConstraintsRequest, CallSettings)

public virtual PagedEnumerable<ListCustomConstraintsResponse, CustomConstraint> ListCustomConstraints(ListCustomConstraintsRequest request, CallSettings callSettings = null)

Retrieves all of the custom constraints that exist on a particular organization resource.

Parameters
Name Description
request ListCustomConstraintsRequest

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
PagedEnumerableListCustomConstraintsResponseCustomConstraint

A pageable sequence of CustomConstraint resources.

Example
// Create client
OrgPolicyClient orgPolicyClient = OrgPolicyClient.Create();
// Initialize request argument(s)
ListCustomConstraintsRequest request = new ListCustomConstraintsRequest
{
    ParentAsOrganizationName = OrganizationName.FromOrganization("[ORGANIZATION]"),
};
// Make the request
PagedEnumerable<ListCustomConstraintsResponse, CustomConstraint> response = orgPolicyClient.ListCustomConstraints(request);

// Iterate over all response items, lazily performing RPCs as required
foreach (CustomConstraint 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 (ListCustomConstraintsResponse page in response.AsRawResponses())
{
    // Do something with each page of items
    Console.WriteLine("A page of results:");
    foreach (CustomConstraint 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<CustomConstraint> 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 (CustomConstraint 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;

ListCustomConstraints(string, string, int?, CallSettings)

public virtual PagedEnumerable<ListCustomConstraintsResponse, CustomConstraint> ListCustomConstraints(string parent, string pageToken = null, int? pageSize = null, CallSettings callSettings = null)

Retrieves all of the custom constraints that exist on a particular organization resource.

Parameters
Name Description
parent string

Required. The target Google Cloud resource that parents the set of custom constraints that will be returned from this call. Must be in one of the following forms:

  • organizations/{organization_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
PagedEnumerableListCustomConstraintsResponseCustomConstraint

A pageable sequence of CustomConstraint resources.

Example
// Create client
OrgPolicyClient orgPolicyClient = OrgPolicyClient.Create();
// Initialize request argument(s)
string parent = "organizations/[ORGANIZATION]";
// Make the request
PagedEnumerable<ListCustomConstraintsResponse, CustomConstraint> response = orgPolicyClient.ListCustomConstraints(parent);

// Iterate over all response items, lazily performing RPCs as required
foreach (CustomConstraint 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 (ListCustomConstraintsResponse page in response.AsRawResponses())
{
    // Do something with each page of items
    Console.WriteLine("A page of results:");
    foreach (CustomConstraint 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<CustomConstraint> 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 (CustomConstraint 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;

ListCustomConstraintsAsync(OrganizationName, string, int?, CallSettings)

public virtual PagedAsyncEnumerable<ListCustomConstraintsResponse, CustomConstraint> ListCustomConstraintsAsync(OrganizationName parent, string pageToken = null, int? pageSize = null, CallSettings callSettings = null)

Retrieves all of the custom constraints that exist on a particular organization resource.

Parameters
Name Description
parent OrganizationName

Required. The target Google Cloud resource that parents the set of custom constraints that will be returned from this call. Must be in one of the following forms:

  • organizations/{organization_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
PagedAsyncEnumerableListCustomConstraintsResponseCustomConstraint

A pageable asynchronous sequence of CustomConstraint resources.

Example
// Create client
OrgPolicyClient orgPolicyClient = await OrgPolicyClient.CreateAsync();
// Initialize request argument(s)
OrganizationName parent = OrganizationName.FromOrganization("[ORGANIZATION]");
// Make the request
PagedAsyncEnumerable<ListCustomConstraintsResponse, CustomConstraint> response = orgPolicyClient.ListCustomConstraintsAsync(parent);

// Iterate over all response items, lazily performing RPCs as required
await response.ForEachAsync((CustomConstraint 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((ListCustomConstraintsResponse page) =>
{
    // Do something with each page of items
    Console.WriteLine("A page of results:");
    foreach (CustomConstraint 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<CustomConstraint> 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 (CustomConstraint 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;

ListCustomConstraintsAsync(ListCustomConstraintsRequest, CallSettings)

public virtual PagedAsyncEnumerable<ListCustomConstraintsResponse, CustomConstraint> ListCustomConstraintsAsync(ListCustomConstraintsRequest request, CallSettings callSettings = null)

Retrieves all of the custom constraints that exist on a particular organization resource.

Parameters
Name Description
request ListCustomConstraintsRequest

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
PagedAsyncEnumerableListCustomConstraintsResponseCustomConstraint

A pageable asynchronous sequence of CustomConstraint resources.

Example
// Create client
OrgPolicyClient orgPolicyClient = await OrgPolicyClient.CreateAsync();
// Initialize request argument(s)
ListCustomConstraintsRequest request = new ListCustomConstraintsRequest
{
    ParentAsOrganizationName = OrganizationName.FromOrganization("[ORGANIZATION]"),
};
// Make the request
PagedAsyncEnumerable<ListCustomConstraintsResponse, CustomConstraint> response = orgPolicyClient.ListCustomConstraintsAsync(request);

// Iterate over all response items, lazily performing RPCs as required
await response.ForEachAsync((CustomConstraint 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((ListCustomConstraintsResponse page) =>
{
    // Do something with each page of items
    Console.WriteLine("A page of results:");
    foreach (CustomConstraint 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<CustomConstraint> 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 (CustomConstraint 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;

ListCustomConstraintsAsync(string, string, int?, CallSettings)

public virtual PagedAsyncEnumerable<ListCustomConstraintsResponse, CustomConstraint> ListCustomConstraintsAsync(string parent, string pageToken = null, int? pageSize = null, CallSettings callSettings = null)

Retrieves all of the custom constraints that exist on a particular organization resource.

Parameters
Name Description
parent string

Required. The target Google Cloud resource that parents the set of custom constraints that will be returned from this call. Must be in one of the following forms:

  • organizations/{organization_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
PagedAsyncEnumerableListCustomConstraintsResponseCustomConstraint

A pageable asynchronous sequence of CustomConstraint resources.

Example
// Create client
OrgPolicyClient orgPolicyClient = await OrgPolicyClient.CreateAsync();
// Initialize request argument(s)
string parent = "organizations/[ORGANIZATION]";
// Make the request
PagedAsyncEnumerable<ListCustomConstraintsResponse, CustomConstraint> response = orgPolicyClient.ListCustomConstraintsAsync(parent);

// Iterate over all response items, lazily performing RPCs as required
await response.ForEachAsync((CustomConstraint 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((ListCustomConstraintsResponse page) =>
{
    // Do something with each page of items
    Console.WriteLine("A page of results:");
    foreach (CustomConstraint 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<CustomConstraint> 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 (CustomConstraint 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(FolderName, string, int?, CallSettings)

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

Retrieves all of the policies that exist on a particular resource.

Parameters
Name Description
parent FolderName

Required. The target Google Cloud resource that parents the set of constraints and policies that will be returned from this call. Must be in one of the following forms:

  • projects/{project_number}
  • projects/{project_id}
  • folders/{folder_id}
  • organizations/{organization_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
OrgPolicyClient orgPolicyClient = OrgPolicyClient.Create();
// Initialize request argument(s)
FolderName parent = FolderName.FromFolder("[FOLDER]");
// Make the request
PagedEnumerable<ListPoliciesResponse, Policy> response = orgPolicyClient.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;

ListPolicies(OrganizationName, string, int?, CallSettings)

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

Retrieves all of the policies that exist on a particular resource.

Parameters
Name Description
parent OrganizationName

Required. The target Google Cloud resource that parents the set of constraints and policies that will be returned from this call. Must be in one of the following forms:

  • projects/{project_number}
  • projects/{project_id}
  • folders/{folder_id}
  • organizations/{organization_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
OrgPolicyClient orgPolicyClient = OrgPolicyClient.Create();
// Initialize request argument(s)
OrganizationName parent = OrganizationName.FromOrganization("[ORGANIZATION]");
// Make the request
PagedEnumerable<ListPoliciesResponse, Policy> response = orgPolicyClient.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;

ListPolicies(ProjectName, string, int?, CallSettings)

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

Retrieves all of the policies that exist on a particular resource.

Parameters
Name Description
parent ProjectName

Required. The target Google Cloud resource that parents the set of constraints and policies that will be returned from this call. Must be in one of the following forms:

  • projects/{project_number}
  • projects/{project_id}
  • folders/{folder_id}
  • organizations/{organization_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
OrgPolicyClient orgPolicyClient = OrgPolicyClient.Create();
// Initialize request argument(s)
ProjectName parent = ProjectName.FromProject("[PROJECT]");
// Make the request
PagedEnumerable<ListPoliciesResponse, Policy> response = orgPolicyClient.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;

ListPolicies(ListPoliciesRequest, CallSettings)

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

Retrieves all of the policies that exist on a particular resource.

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
OrgPolicyClient orgPolicyClient = OrgPolicyClient.Create();
// Initialize request argument(s)
ListPoliciesRequest request = new ListPoliciesRequest
{
    ParentAsProjectName = ProjectName.FromProject("[PROJECT]"),
};
// Make the request
PagedEnumerable<ListPoliciesResponse, Policy> response = orgPolicyClient.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 all of the policies that exist on a particular resource.

Parameters
Name Description
parent string

Required. The target Google Cloud resource that parents the set of constraints and policies that will be returned from this call. Must be in one of the following forms:

  • projects/{project_number}
  • projects/{project_id}
  • folders/{folder_id}
  • organizations/{organization_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
OrgPolicyClient orgPolicyClient = OrgPolicyClient.Create();
// Initialize request argument(s)
string parent = "projects/[PROJECT]";
// Make the request
PagedEnumerable<ListPoliciesResponse, Policy> response = orgPolicyClient.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(FolderName, string, int?, CallSettings)

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

Retrieves all of the policies that exist on a particular resource.

Parameters
Name Description
parent FolderName

Required. The target Google Cloud resource that parents the set of constraints and policies that will be returned from this call. Must be in one of the following forms:

  • projects/{project_number}
  • projects/{project_id}
  • folders/{folder_id}
  • organizations/{organization_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
OrgPolicyClient orgPolicyClient = await OrgPolicyClient.CreateAsync();
// Initialize request argument(s)
FolderName parent = FolderName.FromFolder("[FOLDER]");
// Make the request
PagedAsyncEnumerable<ListPoliciesResponse, Policy> response = orgPolicyClient.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;

ListPoliciesAsync(OrganizationName, string, int?, CallSettings)

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

Retrieves all of the policies that exist on a particular resource.

Parameters
Name Description
parent OrganizationName

Required. The target Google Cloud resource that parents the set of constraints and policies that will be returned from this call. Must be in one of the following forms:

  • projects/{project_number}
  • projects/{project_id}
  • folders/{folder_id}
  • organizations/{organization_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
OrgPolicyClient orgPolicyClient = await OrgPolicyClient.CreateAsync();
// Initialize request argument(s)
OrganizationName parent = OrganizationName.FromOrganization("[ORGANIZATION]");
// Make the request
PagedAsyncEnumerable<ListPoliciesResponse, Policy> response = orgPolicyClient.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;

ListPoliciesAsync(ProjectName, string, int?, CallSettings)

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

Retrieves all of the policies that exist on a particular resource.

Parameters
Name Description
parent ProjectName

Required. The target Google Cloud resource that parents the set of constraints and policies that will be returned from this call. Must be in one of the following forms:

  • projects/{project_number}
  • projects/{project_id}
  • folders/{folder_id}
  • organizations/{organization_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
OrgPolicyClient orgPolicyClient = await OrgPolicyClient.CreateAsync();
// Initialize request argument(s)
ProjectName parent = ProjectName.FromProject("[PROJECT]");
// Make the request
PagedAsyncEnumerable<ListPoliciesResponse, Policy> response = orgPolicyClient.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;

ListPoliciesAsync(ListPoliciesRequest, CallSettings)

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

Retrieves all of the policies that exist on a particular resource.

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
OrgPolicyClient orgPolicyClient = await OrgPolicyClient.CreateAsync();
// Initialize request argument(s)
ListPoliciesRequest request = new ListPoliciesRequest
{
    ParentAsProjectName = ProjectName.FromProject("[PROJECT]"),
};
// Make the request
PagedAsyncEnumerable<ListPoliciesResponse, Policy> response = orgPolicyClient.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 all of the policies that exist on a particular resource.

Parameters
Name Description
parent string

Required. The target Google Cloud resource that parents the set of constraints and policies that will be returned from this call. Must be in one of the following forms:

  • projects/{project_number}
  • projects/{project_id}
  • folders/{folder_id}
  • organizations/{organization_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
OrgPolicyClient orgPolicyClient = await OrgPolicyClient.CreateAsync();
// Initialize request argument(s)
string parent = "projects/[PROJECT]";
// Make the request
PagedAsyncEnumerable<ListPoliciesResponse, Policy> response = orgPolicyClient.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;

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.

UpdateCustomConstraint(CustomConstraint, CallSettings)

public virtual CustomConstraint UpdateCustomConstraint(CustomConstraint customConstraint, CallSettings callSettings = null)

Updates a custom constraint.

Returns a google.rpc.Status with google.rpc.Code.NOT_FOUND if the constraint does not exist.

Note: the supplied policy will perform a full overwrite of all fields.

Parameters
Name Description
customConstraint CustomConstraint

Required. CustomConstraint to update.

callSettings CallSettings

If not null, applies overrides to this RPC call.

Returns
Type Description
CustomConstraint

The RPC response.

Example
// Create client
OrgPolicyClient orgPolicyClient = OrgPolicyClient.Create();
// Initialize request argument(s)
CustomConstraint customConstraint = new CustomConstraint();
// Make the request
CustomConstraint response = orgPolicyClient.UpdateCustomConstraint(customConstraint);

UpdateCustomConstraint(UpdateCustomConstraintRequest, CallSettings)

public virtual CustomConstraint UpdateCustomConstraint(UpdateCustomConstraintRequest request, CallSettings callSettings = null)

Updates a custom constraint.

Returns a google.rpc.Status with google.rpc.Code.NOT_FOUND if the constraint does not exist.

Note: the supplied policy will perform a full overwrite of all fields.

Parameters
Name Description
request UpdateCustomConstraintRequest

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
CustomConstraint

The RPC response.

Example
// Create client
OrgPolicyClient orgPolicyClient = OrgPolicyClient.Create();
// Initialize request argument(s)
UpdateCustomConstraintRequest request = new UpdateCustomConstraintRequest
{
    CustomConstraint = new CustomConstraint(),
};
// Make the request
CustomConstraint response = orgPolicyClient.UpdateCustomConstraint(request);

UpdateCustomConstraintAsync(CustomConstraint, CallSettings)

public virtual Task<CustomConstraint> UpdateCustomConstraintAsync(CustomConstraint customConstraint, CallSettings callSettings = null)

Updates a custom constraint.

Returns a google.rpc.Status with google.rpc.Code.NOT_FOUND if the constraint does not exist.

Note: the supplied policy will perform a full overwrite of all fields.

Parameters
Name Description
customConstraint CustomConstraint

Required. CustomConstraint to update.

callSettings CallSettings

If not null, applies overrides to this RPC call.

Returns
Type Description
TaskCustomConstraint

A Task containing the RPC response.

Example
// Create client
OrgPolicyClient orgPolicyClient = await OrgPolicyClient.CreateAsync();
// Initialize request argument(s)
CustomConstraint customConstraint = new CustomConstraint();
// Make the request
CustomConstraint response = await orgPolicyClient.UpdateCustomConstraintAsync(customConstraint);

UpdateCustomConstraintAsync(CustomConstraint, CancellationToken)

public virtual Task<CustomConstraint> UpdateCustomConstraintAsync(CustomConstraint customConstraint, CancellationToken cancellationToken)

Updates a custom constraint.

Returns a google.rpc.Status with google.rpc.Code.NOT_FOUND if the constraint does not exist.

Note: the supplied policy will perform a full overwrite of all fields.

Parameters
Name Description
customConstraint CustomConstraint

Required. CustomConstraint to update.

cancellationToken CancellationToken

A CancellationToken to use for this RPC.

Returns
Type Description
TaskCustomConstraint

A Task containing the RPC response.

Example
// Create client
OrgPolicyClient orgPolicyClient = await OrgPolicyClient.CreateAsync();
// Initialize request argument(s)
CustomConstraint customConstraint = new CustomConstraint();
// Make the request
CustomConstraint response = await orgPolicyClient.UpdateCustomConstraintAsync(customConstraint);

UpdateCustomConstraintAsync(UpdateCustomConstraintRequest, CallSettings)

public virtual Task<CustomConstraint> UpdateCustomConstraintAsync(UpdateCustomConstraintRequest request, CallSettings callSettings = null)

Updates a custom constraint.

Returns a google.rpc.Status with google.rpc.Code.NOT_FOUND if the constraint does not exist.

Note: the supplied policy will perform a full overwrite of all fields.

Parameters
Name Description
request UpdateCustomConstraintRequest

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
TaskCustomConstraint

A Task containing the RPC response.

Example
// Create client
OrgPolicyClient orgPolicyClient = await OrgPolicyClient.CreateAsync();
// Initialize request argument(s)
UpdateCustomConstraintRequest request = new UpdateCustomConstraintRequest
{
    CustomConstraint = new CustomConstraint(),
};
// Make the request
CustomConstraint response = await orgPolicyClient.UpdateCustomConstraintAsync(request);

UpdateCustomConstraintAsync(UpdateCustomConstraintRequest, CancellationToken)

public virtual Task<CustomConstraint> UpdateCustomConstraintAsync(UpdateCustomConstraintRequest request, CancellationToken cancellationToken)

Updates a custom constraint.

Returns a google.rpc.Status with google.rpc.Code.NOT_FOUND if the constraint does not exist.

Note: the supplied policy will perform a full overwrite of all fields.

Parameters
Name Description
request UpdateCustomConstraintRequest

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

cancellationToken CancellationToken

A CancellationToken to use for this RPC.

Returns
Type Description
TaskCustomConstraint

A Task containing the RPC response.

Example
// Create client
OrgPolicyClient orgPolicyClient = await OrgPolicyClient.CreateAsync();
// Initialize request argument(s)
UpdateCustomConstraintRequest request = new UpdateCustomConstraintRequest
{
    CustomConstraint = new CustomConstraint(),
};
// Make the request
CustomConstraint response = await orgPolicyClient.UpdateCustomConstraintAsync(request);

UpdatePolicy(Policy, CallSettings)

public virtual Policy UpdatePolicy(Policy policy, CallSettings callSettings = null)

Updates a policy.

Returns a google.rpc.Status with google.rpc.Code.NOT_FOUND if the constraint or the policy do not exist. Returns a google.rpc.Status with google.rpc.Code.ABORTED if the etag supplied in the request does not match the persisted etag of the policy

Note: the supplied policy will perform a full overwrite of all fields.

Parameters
Name Description
policy Policy

Required. Policy to update.

callSettings CallSettings

If not null, applies overrides to this RPC call.

Returns
Type Description
Policy

The RPC response.

Example
// Create client
OrgPolicyClient orgPolicyClient = OrgPolicyClient.Create();
// Initialize request argument(s)
Policy policy = new Policy();
// Make the request
Policy response = orgPolicyClient.UpdatePolicy(policy);

UpdatePolicy(UpdatePolicyRequest, CallSettings)

public virtual Policy UpdatePolicy(UpdatePolicyRequest request, CallSettings callSettings = null)

Updates a policy.

Returns a google.rpc.Status with google.rpc.Code.NOT_FOUND if the constraint or the policy do not exist. Returns a google.rpc.Status with google.rpc.Code.ABORTED if the etag supplied in the request does not match the persisted etag of the policy

Note: the supplied policy will perform a full overwrite of all fields.

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
Policy

The RPC response.

Example
// Create client
OrgPolicyClient orgPolicyClient = OrgPolicyClient.Create();
// Initialize request argument(s)
UpdatePolicyRequest request = new UpdatePolicyRequest
{
    Policy = new Policy(),
    UpdateMask = new FieldMask(),
};
// Make the request
Policy response = orgPolicyClient.UpdatePolicy(request);

UpdatePolicyAsync(Policy, CallSettings)

public virtual Task<Policy> UpdatePolicyAsync(Policy policy, CallSettings callSettings = null)

Updates a policy.

Returns a google.rpc.Status with google.rpc.Code.NOT_FOUND if the constraint or the policy do not exist. Returns a google.rpc.Status with google.rpc.Code.ABORTED if the etag supplied in the request does not match the persisted etag of the policy

Note: the supplied policy will perform a full overwrite of all fields.

Parameters
Name Description
policy Policy

Required. Policy to update.

callSettings CallSettings

If not null, applies overrides to this RPC call.

Returns
Type Description
TaskPolicy

A Task containing the RPC response.

Example
// Create client
OrgPolicyClient orgPolicyClient = await OrgPolicyClient.CreateAsync();
// Initialize request argument(s)
Policy policy = new Policy();
// Make the request
Policy response = await orgPolicyClient.UpdatePolicyAsync(policy);

UpdatePolicyAsync(Policy, CancellationToken)

public virtual Task<Policy> UpdatePolicyAsync(Policy policy, CancellationToken cancellationToken)

Updates a policy.

Returns a google.rpc.Status with google.rpc.Code.NOT_FOUND if the constraint or the policy do not exist. Returns a google.rpc.Status with google.rpc.Code.ABORTED if the etag supplied in the request does not match the persisted etag of the policy

Note: the supplied policy will perform a full overwrite of all fields.

Parameters
Name Description
policy Policy

Required. Policy to update.

cancellationToken CancellationToken

A CancellationToken to use for this RPC.

Returns
Type Description
TaskPolicy

A Task containing the RPC response.

Example
// Create client
OrgPolicyClient orgPolicyClient = await OrgPolicyClient.CreateAsync();
// Initialize request argument(s)
Policy policy = new Policy();
// Make the request
Policy response = await orgPolicyClient.UpdatePolicyAsync(policy);

UpdatePolicyAsync(UpdatePolicyRequest, CallSettings)

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

Updates a policy.

Returns a google.rpc.Status with google.rpc.Code.NOT_FOUND if the constraint or the policy do not exist. Returns a google.rpc.Status with google.rpc.Code.ABORTED if the etag supplied in the request does not match the persisted etag of the policy

Note: the supplied policy will perform a full overwrite of all fields.

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
TaskPolicy

A Task containing the RPC response.

Example
// Create client
OrgPolicyClient orgPolicyClient = await OrgPolicyClient.CreateAsync();
// Initialize request argument(s)
UpdatePolicyRequest request = new UpdatePolicyRequest
{
    Policy = new Policy(),
    UpdateMask = new FieldMask(),
};
// Make the request
Policy response = await orgPolicyClient.UpdatePolicyAsync(request);

UpdatePolicyAsync(UpdatePolicyRequest, CancellationToken)

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

Updates a policy.

Returns a google.rpc.Status with google.rpc.Code.NOT_FOUND if the constraint or the policy do not exist. Returns a google.rpc.Status with google.rpc.Code.ABORTED if the etag supplied in the request does not match the persisted etag of the policy

Note: the supplied policy will perform a full overwrite of all fields.

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
TaskPolicy

A Task containing the RPC response.

Example
// Create client
OrgPolicyClient orgPolicyClient = await OrgPolicyClient.CreateAsync();
// Initialize request argument(s)
UpdatePolicyRequest request = new UpdatePolicyRequest
{
    Policy = new Policy(),
    UpdateMask = new FieldMask(),
};
// Make the request
Policy response = await orgPolicyClient.UpdatePolicyAsync(request);