Organization Policy v2 API - Class OrgPolicyClient (2.4.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
TypeDescription
string

DefaultScopes

public static IReadOnlyList<string> DefaultScopes { get; }

The default OrgPolicy scopes.

Property Value
TypeDescription
IReadOnlyListstring
Remarks

The default OrgPolicy scopes are:

GrpcClient

public virtual OrgPolicy.OrgPolicyClient GrpcClient { get; }

The underlying gRPC OrgPolicy client

Property Value
TypeDescription
OrgPolicyOrgPolicyClient

ServiceMetadata

public static ServiceMetadata ServiceMetadata { get; }

The service metadata associated with this client type.

Property Value
TypeDescription
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
TypeDescription
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
NameDescription
cancellationTokenCancellationToken

The CancellationToken to use while creating the client.

Returns
TypeDescription
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
NameDescription
parentOrganizationName

Required. Must be in the following form:

  • organizations/{organization_id}
customConstraintCustomConstraint

Required. Custom constraint to create.

callSettingsCallSettings

If not null, applies overrides to this RPC call.

Returns
TypeDescription
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
NameDescription
requestCreateCustomConstraintRequest

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

callSettingsCallSettings

If not null, applies overrides to this RPC call.

Returns
TypeDescription
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
NameDescription
parentstring

Required. Must be in the following form:

  • organizations/{organization_id}
customConstraintCustomConstraint

Required. Custom constraint to create.

callSettingsCallSettings

If not null, applies overrides to this RPC call.

Returns
TypeDescription
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
NameDescription
parentOrganizationName

Required. Must be in the following form:

  • organizations/{organization_id}
customConstraintCustomConstraint

Required. Custom constraint to create.

callSettingsCallSettings

If not null, applies overrides to this RPC call.

Returns
TypeDescription
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
NameDescription
parentOrganizationName

Required. Must be in the following form:

  • organizations/{organization_id}
customConstraintCustomConstraint

Required. Custom constraint to create.

cancellationTokenCancellationToken

A CancellationToken to use for this RPC.

Returns
TypeDescription
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
NameDescription
requestCreateCustomConstraintRequest

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

callSettingsCallSettings

If not null, applies overrides to this RPC call.

Returns
TypeDescription
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
NameDescription
requestCreateCustomConstraintRequest

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

cancellationTokenCancellationToken

A CancellationToken to use for this RPC.

Returns
TypeDescription
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
NameDescription
parentstring

Required. Must be in the following form:

  • organizations/{organization_id}
customConstraintCustomConstraint

Required. Custom constraint to create.

callSettingsCallSettings

If not null, applies overrides to this RPC call.

Returns
TypeDescription
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
NameDescription
parentstring

Required. Must be in the following form:

  • organizations/{organization_id}
customConstraintCustomConstraint

Required. Custom constraint to create.

cancellationTokenCancellationToken

A CancellationToken to use for this RPC.

Returns
TypeDescription
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
NameDescription
parentFolderName

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}
policyPolicy

Required. Policy to create.

callSettingsCallSettings

If not null, applies overrides to this RPC call.

Returns
TypeDescription
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
NameDescription
parentOrganizationName

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}
policyPolicy

Required. Policy to create.

callSettingsCallSettings

If not null, applies overrides to this RPC call.

Returns
TypeDescription
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
NameDescription
parentProjectName

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}
policyPolicy

Required. Policy to create.

callSettingsCallSettings

If not null, applies overrides to this RPC call.

Returns
TypeDescription
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
NameDescription
requestCreatePolicyRequest

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

callSettingsCallSettings

If not null, applies overrides to this RPC call.

Returns
TypeDescription
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
NameDescription
parentstring

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}
policyPolicy

Required. Policy to create.

callSettingsCallSettings

If not null, applies overrides to this RPC call.

Returns
TypeDescription
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
NameDescription
parentFolderName

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}
policyPolicy

Required. Policy to create.

callSettingsCallSettings

If not null, applies overrides to this RPC call.

Returns
TypeDescription
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
NameDescription
parentFolderName

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}
policyPolicy

Required. Policy to create.

cancellationTokenCancellationToken

A CancellationToken to use for this RPC.

Returns
TypeDescription
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
NameDescription
parentOrganizationName

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}
policyPolicy

Required. Policy to create.

callSettingsCallSettings

If not null, applies overrides to this RPC call.

Returns
TypeDescription
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
NameDescription
parentOrganizationName

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}
policyPolicy

Required. Policy to create.

cancellationTokenCancellationToken

A CancellationToken to use for this RPC.

Returns
TypeDescription
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
NameDescription
parentProjectName

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}
policyPolicy

Required. Policy to create.

callSettingsCallSettings

If not null, applies overrides to this RPC call.

Returns
TypeDescription
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
NameDescription
parentProjectName

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}
policyPolicy

Required. Policy to create.

cancellationTokenCancellationToken

A CancellationToken to use for this RPC.

Returns
TypeDescription
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
NameDescription
requestCreatePolicyRequest

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

callSettingsCallSettings

If not null, applies overrides to this RPC call.

Returns
TypeDescription
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
NameDescription
requestCreatePolicyRequest

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

cancellationTokenCancellationToken

A CancellationToken to use for this RPC.

Returns
TypeDescription
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
NameDescription
parentstring

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}
policyPolicy

Required. Policy to create.

callSettingsCallSettings

If not null, applies overrides to this RPC call.

Returns
TypeDescription
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
NameDescription
parentstring

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}
policyPolicy

Required. Policy to create.

cancellationTokenCancellationToken

A CancellationToken to use for this RPC.

Returns
TypeDescription
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
NameDescription
nameCustomConstraintName

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

callSettingsCallSettings

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
NameDescription
requestDeleteCustomConstraintRequest

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

callSettingsCallSettings

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
NameDescription
namestring

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

callSettingsCallSettings

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
NameDescription
nameCustomConstraintName

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

callSettingsCallSettings

If not null, applies overrides to this RPC call.

Returns
TypeDescription
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
NameDescription
nameCustomConstraintName

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

cancellationTokenCancellationToken

A CancellationToken to use for this RPC.

Returns
TypeDescription
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
NameDescription
requestDeleteCustomConstraintRequest

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

callSettingsCallSettings

If not null, applies overrides to this RPC call.

Returns
TypeDescription
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
NameDescription
requestDeleteCustomConstraintRequest

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

cancellationTokenCancellationToken

A CancellationToken to use for this RPC.

Returns
TypeDescription
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
NameDescription
namestring

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

callSettingsCallSettings

If not null, applies overrides to this RPC call.

Returns
TypeDescription
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
NameDescription
namestring

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

cancellationTokenCancellationToken

A CancellationToken to use for this RPC.

Returns
TypeDescription
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
NameDescription
requestDeletePolicyRequest

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

callSettingsCallSettings

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
NameDescription
namePolicyName

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

callSettingsCallSettings

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
NameDescription
namestring

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

callSettingsCallSettings

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
NameDescription
requestDeletePolicyRequest

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

callSettingsCallSettings

If not null, applies overrides to this RPC call.

Returns
TypeDescription
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
NameDescription
requestDeletePolicyRequest

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

cancellationTokenCancellationToken

A CancellationToken to use for this RPC.

Returns
TypeDescription
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
NameDescription
namePolicyName

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

callSettingsCallSettings

If not null, applies overrides to this RPC call.

Returns
TypeDescription
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
NameDescription
namePolicyName

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

cancellationTokenCancellationToken

A CancellationToken to use for this RPC.

Returns
TypeDescription
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
NameDescription
namestring

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

callSettingsCallSettings

If not null, applies overrides to this RPC call.

Returns
TypeDescription
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
NameDescription
namestring

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

cancellationTokenCancellationToken

A CancellationToken to use for this RPC.

Returns
TypeDescription
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
NameDescription
nameCustomConstraintName

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

callSettingsCallSettings

If not null, applies overrides to this RPC call.

Returns
TypeDescription
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
NameDescription
requestGetCustomConstraintRequest

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

callSettingsCallSettings

If not null, applies overrides to this RPC call.

Returns
TypeDescription
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
NameDescription
namestring

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

callSettingsCallSettings

If not null, applies overrides to this RPC call.

Returns
TypeDescription
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
NameDescription
nameCustomConstraintName

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

callSettingsCallSettings

If not null, applies overrides to this RPC call.

Returns
TypeDescription
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
NameDescription
nameCustomConstraintName

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

cancellationTokenCancellationToken

A CancellationToken to use for this RPC.

Returns
TypeDescription
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
NameDescription
requestGetCustomConstraintRequest

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

callSettingsCallSettings

If not null, applies overrides to this RPC call.

Returns
TypeDescription
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
NameDescription
requestGetCustomConstraintRequest

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

cancellationTokenCancellationToken

A CancellationToken to use for this RPC.

Returns
TypeDescription
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
NameDescription
namestring

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

callSettingsCallSettings

If not null, applies overrides to this RPC call.

Returns
TypeDescription
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
NameDescription
namestring

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

cancellationTokenCancellationToken

A CancellationToken to use for this RPC.

Returns
TypeDescription
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
NameDescription
requestGetEffectivePolicyRequest

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

callSettingsCallSettings

If not null, applies overrides to this RPC call.

Returns
TypeDescription
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
NameDescription
namePolicyName

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

callSettingsCallSettings

If not null, applies overrides to this RPC call.

Returns
TypeDescription
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
NameDescription
namestring

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

callSettingsCallSettings

If not null, applies overrides to this RPC call.

Returns
TypeDescription
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
NameDescription
requestGetEffectivePolicyRequest

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

callSettingsCallSettings

If not null, applies overrides to this RPC call.

Returns
TypeDescription
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
NameDescription
requestGetEffectivePolicyRequest

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

cancellationTokenCancellationToken

A CancellationToken to use for this RPC.

Returns
TypeDescription
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
NameDescription
namePolicyName

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

callSettingsCallSettings

If not null, applies overrides to this RPC call.

Returns
TypeDescription
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
NameDescription
namePolicyName

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

cancellationTokenCancellationToken

A CancellationToken to use for this RPC.

Returns
TypeDescription
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
NameDescription
namestring

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

callSettingsCallSettings

If not null, applies overrides to this RPC call.

Returns
TypeDescription
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
NameDescription
namestring

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

cancellationTokenCancellationToken

A CancellationToken to use for this RPC.

Returns
TypeDescription
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
NameDescription
requestGetPolicyRequest

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

callSettingsCallSettings

If not null, applies overrides to this RPC call.

Returns
TypeDescription
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
NameDescription
namePolicyName

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

callSettingsCallSettings

If not null, applies overrides to this RPC call.

Returns
TypeDescription
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
NameDescription
namestring

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

callSettingsCallSettings

If not null, applies overrides to this RPC call.

Returns
TypeDescription
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
NameDescription
requestGetPolicyRequest

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

callSettingsCallSettings

If not null, applies overrides to this RPC call.

Returns
TypeDescription
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
NameDescription
requestGetPolicyRequest

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

cancellationTokenCancellationToken

A CancellationToken to use for this RPC.

Returns