Class v2.OrgPolicyClient (3.1.0)

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. v2

Package

@google-cloud/org-policy

Constructors

(constructor)(opts, gaxInstance)

constructor(opts?: ClientOptions, gaxInstance?: typeof gax | typeof gax.fallback);

Construct an instance of OrgPolicyClient.

Parameters
NameDescription
opts ClientOptions
gaxInstance typeof gax | typeof fallback

: loaded instance of google-gax. Useful if you need to avoid loading the default gRPC version and want to use the fallback HTTP implementation. Load only fallback version and pass it to the constructor: ``` const gax = require('google-gax/build/src/fallback'); // avoids loading google-gax with gRPC const client = new OrgPolicyClient({fallback: true}, gax); ```

Properties

apiEndpoint

static get apiEndpoint(): string;

The DNS address for this API service - same as servicePath(), exists for compatibility reasons.

auth

auth: gax.GoogleAuth;

descriptors

descriptors: Descriptors;

innerApiCalls

innerApiCalls: {
        [name: string]: Function;
    };

orgPolicyStub

orgPolicyStub?: Promise<{
        [name: string]: Function;
    }>;

pathTemplates

pathTemplates: {
        [name: string]: gax.PathTemplate;
    };

port

static get port(): number;

The port for this API service.

scopes

static get scopes(): string[];

The scopes needed to make gRPC calls for every method defined in this service.

servicePath

static get servicePath(): string;

The DNS address for this API service.

warn

warn: (code: string, message: string, warnType?: string) => void;

Methods

close()

close(): Promise<void>;

Terminate the gRPC channel and close the client.

The client will no longer be usable and all future behavior is undefined.

Returns
TypeDescription
Promise<void>

{Promise} A promise that resolves when the client is closed.

createCustomConstraint(request, options)

createCustomConstraint(request?: protos.google.cloud.orgpolicy.v2.ICreateCustomConstraintRequest, options?: CallOptions): Promise<[
        protos.google.cloud.orgpolicy.v2.ICustomConstraint,
        (protos.google.cloud.orgpolicy.v2.ICreateCustomConstraintRequest | undefined),
        {} | undefined
    ]>;

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
request ICreateCustomConstraintRequest

The request object that will be sent.

options CallOptions

Call options. See CallOptions for more details.

Returns
TypeDescription
Promise<[ protos.google.cloud.orgpolicy.v2.ICustomConstraint, (protos.google.cloud.orgpolicy.v2.ICreateCustomConstraintRequest | undefined), {} | undefined ]>

{Promise} - The promise which resolves to an array. The first element of the array is an object representing . Please see the documentation for more details and examples.

Example

  /**
   * This snippet has been automatically generated and should be regarded as a code template only.
   * It will require modifications to work.
   * It may require correct/in-range values for request initialization.
   * TODO(developer): Uncomment these variables before running the sample.
   */
  /**
   *  Required. Must be in the following form:
   *  * `organizations/{organization_id}`
   */
  // const parent = 'abc123'
  /**
   *  Required. Custom constraint to create.
   */
  // const customConstraint = {}

  // Imports the Orgpolicy library
  const {OrgPolicyClient} = require('@google-cloud/org-policy').v2;

  // Instantiates a client
  const orgpolicyClient = new OrgPolicyClient();

  async function callCreateCustomConstraint() {
    // Construct request
    const request = {
      parent,
      customConstraint,
    };

    // Run request
    const response = await orgpolicyClient.createCustomConstraint(request);
    console.log(response);
  }

  callCreateCustomConstraint();

createCustomConstraint(request, options, callback)

createCustomConstraint(request: protos.google.cloud.orgpolicy.v2.ICreateCustomConstraintRequest, options: CallOptions, callback: Callback<protos.google.cloud.orgpolicy.v2.ICustomConstraint, protos.google.cloud.orgpolicy.v2.ICreateCustomConstraintRequest | null | undefined, {} | null | undefined>): void;
Parameters
NameDescription
request ICreateCustomConstraintRequest
options CallOptions
callback Callback<protos.google.cloud.orgpolicy.v2.ICustomConstraint, protos.google.cloud.orgpolicy.v2.ICreateCustomConstraintRequest | null | undefined, {} | null | undefined>
Returns
TypeDescription
void

createCustomConstraint(request, callback)

createCustomConstraint(request: protos.google.cloud.orgpolicy.v2.ICreateCustomConstraintRequest, callback: Callback<protos.google.cloud.orgpolicy.v2.ICustomConstraint, protos.google.cloud.orgpolicy.v2.ICreateCustomConstraintRequest | null | undefined, {} | null | undefined>): void;
Parameters
NameDescription
request ICreateCustomConstraintRequest
callback Callback<protos.google.cloud.orgpolicy.v2.ICustomConstraint, protos.google.cloud.orgpolicy.v2.ICreateCustomConstraintRequest | null | undefined, {} | null | undefined>
Returns
TypeDescription
void

createPolicy(request, options)

createPolicy(request?: protos.google.cloud.orgpolicy.v2.ICreatePolicyRequest, options?: CallOptions): Promise<[
        protos.google.cloud.orgpolicy.v2.IPolicy,
        protos.google.cloud.orgpolicy.v2.ICreatePolicyRequest | undefined,
        {} | undefined
    ]>;

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
request ICreatePolicyRequest

The request object that will be sent.

options CallOptions

Call options. See CallOptions for more details.

Returns
TypeDescription
Promise<[ protos.google.cloud.orgpolicy.v2.IPolicy, protos.google.cloud.orgpolicy.v2.ICreatePolicyRequest | undefined, {} | undefined ]>

{Promise} - The promise which resolves to an array. The first element of the array is an object representing Policy. Please see the documentation for more details and examples.

Example

  /**
   * This snippet has been automatically generated and should be regarded as a code template only.
   * It will require modifications to work.
   * It may require correct/in-range values for request initialization.
   * TODO(developer): Uncomment these variables before running the sample.
   */
  /**
   *  Required. The 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}`
   */
  // const parent = 'abc123'
  /**
   *  Required. Policy to create.
   */
  // const policy = {}

  // Imports the Orgpolicy library
  const {OrgPolicyClient} = require('@google-cloud/org-policy').v2;

  // Instantiates a client
  const orgpolicyClient = new OrgPolicyClient();

  async function callCreatePolicy() {
    // Construct request
    const request = {
      parent,
      policy,
    };

    // Run request
    const response = await orgpolicyClient.createPolicy(request);
    console.log(response);
  }

  callCreatePolicy();

createPolicy(request, options, callback)

createPolicy(request: protos.google.cloud.orgpolicy.v2.ICreatePolicyRequest, options: CallOptions, callback: Callback<protos.google.cloud.orgpolicy.v2.IPolicy, protos.google.cloud.orgpolicy.v2.ICreatePolicyRequest | null | undefined, {} | null | undefined>): void;
Parameters
NameDescription
request ICreatePolicyRequest
options CallOptions
callback Callback<protos.google.cloud.orgpolicy.v2.IPolicy, protos.google.cloud.orgpolicy.v2.ICreatePolicyRequest | null | undefined, {} | null | undefined>
Returns
TypeDescription
void

createPolicy(request, callback)

createPolicy(request: protos.google.cloud.orgpolicy.v2.ICreatePolicyRequest, callback: Callback<protos.google.cloud.orgpolicy.v2.IPolicy, protos.google.cloud.orgpolicy.v2.ICreatePolicyRequest | null | undefined, {} | null | undefined>): void;
Parameters
NameDescription
request ICreatePolicyRequest
callback Callback<protos.google.cloud.orgpolicy.v2.IPolicy, protos.google.cloud.orgpolicy.v2.ICreatePolicyRequest | null | undefined, {} | null | undefined>
Returns
TypeDescription
void

customConstraintPath(organization, customConstraint)

customConstraintPath(organization: string, customConstraint: string): string;

Return a fully-qualified customConstraint resource name string.

Parameters
NameDescription
organization string
customConstraint string
Returns
TypeDescription
string

{string} Resource name string.

deleteCustomConstraint(request, options)

deleteCustomConstraint(request?: protos.google.cloud.orgpolicy.v2.IDeleteCustomConstraintRequest, options?: CallOptions): Promise<[
        protos.google.protobuf.IEmpty,
        (protos.google.cloud.orgpolicy.v2.IDeleteCustomConstraintRequest | undefined),
        {} | undefined
    ]>;

Deletes a custom constraint.

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

Parameters
NameDescription
request IDeleteCustomConstraintRequest

The request object that will be sent.

options CallOptions

Call options. See CallOptions for more details.

Returns
TypeDescription
Promise<[ protos.google.protobuf.IEmpty, (protos.google.cloud.orgpolicy.v2.IDeleteCustomConstraintRequest | undefined), {} | undefined ]>

{Promise} - The promise which resolves to an array. The first element of the array is an object representing Empty. Please see the documentation for more details and examples.

Example

  /**
   * This snippet has been automatically generated and should be regarded as a code template only.
   * It will require modifications to work.
   * It may require correct/in-range values for request initialization.
   * TODO(developer): Uncomment these variables before running the sample.
   */
  /**
   *  Required. Name of the custom constraint to delete.
   *  See the custom constraint entry for naming rules.
   */
  // const name = 'abc123'

  // Imports the Orgpolicy library
  const {OrgPolicyClient} = require('@google-cloud/org-policy').v2;

  // Instantiates a client
  const orgpolicyClient = new OrgPolicyClient();

  async function callDeleteCustomConstraint() {
    // Construct request
    const request = {
      name,
    };

    // Run request
    const response = await orgpolicyClient.deleteCustomConstraint(request);
    console.log(response);
  }

  callDeleteCustomConstraint();

deleteCustomConstraint(request, options, callback)

deleteCustomConstraint(request: protos.google.cloud.orgpolicy.v2.IDeleteCustomConstraintRequest, options: CallOptions, callback: Callback<protos.google.protobuf.IEmpty, protos.google.cloud.orgpolicy.v2.IDeleteCustomConstraintRequest | null | undefined, {} | null | undefined>): void;
Parameters
NameDescription
request IDeleteCustomConstraintRequest
options CallOptions
callback Callback<protos.google.protobuf.IEmpty, protos.google.cloud.orgpolicy.v2.IDeleteCustomConstraintRequest | null | undefined, {} | null | undefined>
Returns
TypeDescription
void

deleteCustomConstraint(request, callback)

deleteCustomConstraint(request: protos.google.cloud.orgpolicy.v2.IDeleteCustomConstraintRequest, callback: Callback<protos.google.protobuf.IEmpty, protos.google.cloud.orgpolicy.v2.IDeleteCustomConstraintRequest | null | undefined, {} | null | undefined>): void;
Parameters
NameDescription
request IDeleteCustomConstraintRequest
callback Callback<protos.google.protobuf.IEmpty, protos.google.cloud.orgpolicy.v2.IDeleteCustomConstraintRequest | null | undefined, {} | null | undefined>
Returns
TypeDescription
void

deletePolicy(request, options)

deletePolicy(request?: protos.google.cloud.orgpolicy.v2.IDeletePolicyRequest, options?: CallOptions): Promise<[
        protos.google.protobuf.IEmpty,
        protos.google.cloud.orgpolicy.v2.IDeletePolicyRequest | undefined,
        {} | undefined
    ]>;

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
request IDeletePolicyRequest

The request object that will be sent.

options CallOptions

Call options. See CallOptions for more details.

Returns
TypeDescription
Promise<[ protos.google.protobuf.IEmpty, protos.google.cloud.orgpolicy.v2.IDeletePolicyRequest | undefined, {} | undefined ]>

{Promise} - The promise which resolves to an array. The first element of the array is an object representing Empty. Please see the documentation for more details and examples.

Example

  /**
   * This snippet has been automatically generated and should be regarded as a code template only.
   * It will require modifications to work.
   * It may require correct/in-range values for request initialization.
   * TODO(developer): Uncomment these variables before running the sample.
   */
  /**
   *  Required. Name of the policy to delete.
   *  See the policy entry for naming rules.
   */
  // const name = 'abc123'
  /**
   *  Optional. The current etag of policy. If an etag is provided and does not
   *  match the current etag of the policy, deletion will be blocked and an
   *  ABORTED error will be returned.
   */
  // const etag = 'abc123'

  // Imports the Orgpolicy library
  const {OrgPolicyClient} = require('@google-cloud/org-policy').v2;

  // Instantiates a client
  const orgpolicyClient = new OrgPolicyClient();

  async function callDeletePolicy() {
    // Construct request
    const request = {
      name,
    };

    // Run request
    const response = await orgpolicyClient.deletePolicy(request);
    console.log(response);
  }

  callDeletePolicy();

deletePolicy(request, options, callback)

deletePolicy(request: protos.google.cloud.orgpolicy.v2.IDeletePolicyRequest, options: CallOptions, callback: Callback<protos.google.protobuf.IEmpty, protos.google.cloud.orgpolicy.v2.IDeletePolicyRequest | null | undefined, {} | null | undefined>): void;
Parameters
NameDescription
request IDeletePolicyRequest
options CallOptions
callback Callback<protos.google.protobuf.IEmpty, protos.google.cloud.orgpolicy.v2.IDeletePolicyRequest | null | undefined, {} | null | undefined>
Returns
TypeDescription
void

deletePolicy(request, callback)

deletePolicy(request: protos.google.cloud.orgpolicy.v2.IDeletePolicyRequest, callback: Callback<protos.google.protobuf.IEmpty, protos.google.cloud.orgpolicy.v2.IDeletePolicyRequest | null | undefined, {} | null | undefined>): void;
Parameters
NameDescription
request IDeletePolicyRequest
callback Callback<protos.google.protobuf.IEmpty, protos.google.cloud.orgpolicy.v2.IDeletePolicyRequest | null | undefined, {} | null | undefined>
Returns
TypeDescription
void

folderConstraintPath(folder, constraint)

folderConstraintPath(folder: string, constraint: string): string;

Return a fully-qualified folderConstraint resource name string.

Parameters
NameDescription
folder string
constraint string
Returns
TypeDescription
string

{string} Resource name string.

folderPolicyPath(folder, policy)

folderPolicyPath(folder: string, policy: string): string;

Return a fully-qualified folderPolicy resource name string.

Parameters
NameDescription
folder string
policy string
Returns
TypeDescription
string

{string} Resource name string.

getCustomConstraint(request, options)

getCustomConstraint(request?: protos.google.cloud.orgpolicy.v2.IGetCustomConstraintRequest, options?: CallOptions): Promise<[
        protos.google.cloud.orgpolicy.v2.ICustomConstraint,
        protos.google.cloud.orgpolicy.v2.IGetCustomConstraintRequest | undefined,
        {} | undefined
    ]>;

Gets a custom constraint.

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

Parameters
NameDescription
request IGetCustomConstraintRequest

The request object that will be sent.

options CallOptions

Call options. See CallOptions for more details.

Returns
TypeDescription
Promise<[ protos.google.cloud.orgpolicy.v2.ICustomConstraint, protos.google.cloud.orgpolicy.v2.IGetCustomConstraintRequest | undefined, {} | undefined ]>

{Promise} - The promise which resolves to an array. The first element of the array is an object representing . Please see the documentation for more details and examples.

Example

  /**
   * This snippet has been automatically generated and should be regarded as a code template only.
   * It will require modifications to work.
   * It may require correct/in-range values for request initialization.
   * TODO(developer): Uncomment these variables before running the sample.
   */
  /**
   *  Required. Resource name of the custom constraint. See the custom constraint
   *  entry for naming requirements.
   */
  // const name = 'abc123'

  // Imports the Orgpolicy library
  const {OrgPolicyClient} = require('@google-cloud/org-policy').v2;

  // Instantiates a client
  const orgpolicyClient = new OrgPolicyClient();

  async function callGetCustomConstraint() {
    // Construct request
    const request = {
      name,
    };

    // Run request
    const response = await orgpolicyClient.getCustomConstraint(request);
    console.log(response);
  }

  callGetCustomConstraint();

getCustomConstraint(request, options, callback)

getCustomConstraint(request: protos.google.cloud.orgpolicy.v2.IGetCustomConstraintRequest, options: CallOptions, callback: Callback<protos.google.cloud.orgpolicy.v2.ICustomConstraint, protos.google.cloud.orgpolicy.v2.IGetCustomConstraintRequest | null | undefined, {} | null | undefined>): void;
Parameters
NameDescription
request IGetCustomConstraintRequest
options CallOptions
callback Callback<protos.google.cloud.orgpolicy.v2.ICustomConstraint, protos.google.cloud.orgpolicy.v2.IGetCustomConstraintRequest | null | undefined, {} | null | undefined>
Returns
TypeDescription
void

getCustomConstraint(request, callback)

getCustomConstraint(request: protos.google.cloud.orgpolicy.v2.IGetCustomConstraintRequest, callback: Callback<protos.google.cloud.orgpolicy.v2.ICustomConstraint, protos.google.cloud.orgpolicy.v2.IGetCustomConstraintRequest | null | undefined, {} | null | undefined>): void;
Parameters
NameDescription
request IGetCustomConstraintRequest
callback Callback<protos.google.cloud.orgpolicy.v2.ICustomConstraint, protos.google.cloud.orgpolicy.v2.IGetCustomConstraintRequest | null | undefined, {} | null | undefined>
Returns
TypeDescription
void

getEffectivePolicy(request, options)

getEffectivePolicy(request?: protos.google.cloud.orgpolicy.v2.IGetEffectivePolicyRequest, options?: CallOptions): Promise<[
        protos.google.cloud.orgpolicy.v2.IPolicy,
        protos.google.cloud.orgpolicy.v2.IGetEffectivePolicyRequest | undefined,
        {} | undefined
    ]>;

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
request IGetEffectivePolicyRequest

The request object that will be sent.

options CallOptions

Call options. See CallOptions for more details.

Returns
TypeDescription
Promise<[ protos.google.cloud.orgpolicy.v2.IPolicy, protos.google.cloud.orgpolicy.v2.IGetEffectivePolicyRequest | undefined, {} | undefined ]>

{Promise} - The promise which resolves to an array. The first element of the array is an object representing Policy. Please see the documentation for more details and examples.

Example

  /**
   * This snippet has been automatically generated and should be regarded as a code template only.
   * It will require modifications to work.
   * It may require correct/in-range values for request initialization.
   * TODO(developer): Uncomment these variables before running the sample.
   */
  /**
   *  Required. The effective policy to compute. See
   *  Policy google.cloud.orgpolicy.v2.Policy  for naming requirements.
   */
  // const name = 'abc123'

  // Imports the Orgpolicy library
  const {OrgPolicyClient} = require('@google-cloud/org-policy').v2;

  // Instantiates a client
  const orgpolicyClient = new OrgPolicyClient();

  async function callGetEffectivePolicy() {
    // Construct request
    const request = {
      name,
    };

    // Run request
    const response = await orgpolicyClient.getEffectivePolicy(request);
    console.log(response);
  }

  callGetEffectivePolicy();

getEffectivePolicy(request, options, callback)

getEffectivePolicy(request: protos.google.cloud.orgpolicy.v2.IGetEffectivePolicyRequest, options: CallOptions, callback: Callback<protos.google.cloud.orgpolicy.v2.IPolicy, protos.google.cloud.orgpolicy.v2.IGetEffectivePolicyRequest | null | undefined, {} | null | undefined>): void;
Parameters
NameDescription
request IGetEffectivePolicyRequest
options CallOptions
callback Callback<protos.google.cloud.orgpolicy.v2.IPolicy, protos.google.cloud.orgpolicy.v2.IGetEffectivePolicyRequest | null | undefined, {} | null | undefined>
Returns
TypeDescription
void

getEffectivePolicy(request, callback)

getEffectivePolicy(request: protos.google.cloud.orgpolicy.v2.IGetEffectivePolicyRequest, callback: Callback<protos.google.cloud.orgpolicy.v2.IPolicy, protos.google.cloud.orgpolicy.v2.IGetEffectivePolicyRequest | null | undefined, {} | null | undefined>): void;
Parameters
NameDescription
request IGetEffectivePolicyRequest
callback Callback<protos.google.cloud.orgpolicy.v2.IPolicy, protos.google.cloud.orgpolicy.v2.IGetEffectivePolicyRequest | null | undefined, {} | null | undefined>
Returns
TypeDescription
void

getPolicy(request, options)

getPolicy(request?: protos.google.cloud.orgpolicy.v2.IGetPolicyRequest, options?: CallOptions): Promise<[
        protos.google.cloud.orgpolicy.v2.IPolicy,
        protos.google.cloud.orgpolicy.v2.IGetPolicyRequest | undefined,
        {} | undefined
    ]>;

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
request IGetPolicyRequest

The request object that will be sent.

options CallOptions

Call options. See CallOptions for more details.

Returns
TypeDescription
Promise<[ protos.google.cloud.orgpolicy.v2.IPolicy, protos.google.cloud.orgpolicy.v2.IGetPolicyRequest | undefined, {} | undefined ]>

{Promise} - The promise which resolves to an array. The first element of the array is an object representing Policy. Please see the documentation for more details and examples.

Example

  /**
   * This snippet has been automatically generated and should be regarded as a code template only.
   * It will require modifications to work.
   * It may require correct/in-range values for request initialization.
   * TODO(developer): Uncomment these variables before running the sample.
   */
  /**
   *  Required. Resource name of the policy. See
   *  Policy google.cloud.orgpolicy.v2.Policy  for naming requirements.
   */
  // const name = 'abc123'

  // Imports the Orgpolicy library
  const {OrgPolicyClient} = require('@google-cloud/org-policy').v2;

  // Instantiates a client
  const orgpolicyClient = new OrgPolicyClient();

  async function callGetPolicy() {
    // Construct request
    const request = {
      name,
    };

    // Run request
    const response = await orgpolicyClient.getPolicy(request);
    console.log(response);
  }

  callGetPolicy();

getPolicy(request, options, callback)

getPolicy(request: protos.google.cloud.orgpolicy.v2.IGetPolicyRequest, options: CallOptions, callback: Callback<protos.google.cloud.orgpolicy.v2.IPolicy, protos.google.cloud.orgpolicy.v2.IGetPolicyRequest | null | undefined, {} | null | undefined>): void;
Parameters
NameDescription
request IGetPolicyRequest
options CallOptions
callback Callback<protos.google.cloud.orgpolicy.v2.IPolicy, protos.google.cloud.orgpolicy.v2.IGetPolicyRequest | null | undefined, {} | null | undefined>
Returns
TypeDescription
void

getPolicy(request, callback)

getPolicy(request: protos.google.cloud.orgpolicy.v2.IGetPolicyRequest, callback: Callback<protos.google.cloud.orgpolicy.v2.IPolicy, protos.google.cloud.orgpolicy.v2.IGetPolicyRequest | null | undefined, {} | null | undefined>): void;
Parameters
NameDescription
request IGetPolicyRequest
callback Callback<protos.google.cloud.orgpolicy.v2.IPolicy, protos.google.cloud.orgpolicy.v2.IGetPolicyRequest | null | undefined, {} | null | undefined>
Returns
TypeDescription
void

getProjectId()

getProjectId(): Promise<string>;
Returns
TypeDescription
Promise<string>

getProjectId(callback)

getProjectId(callback: Callback<string, undefined, undefined>): void;
Parameter
NameDescription
callback Callback<string, undefined, undefined>
Returns
TypeDescription
void

initialize()

initialize(): Promise<{
        [name: string]: Function;
    }>;

Initialize the client. Performs asynchronous operations (such as authentication) and prepares the client. This function will be called automatically when any class method is called for the first time, but if you need to initialize it before calling an actual method, feel free to call initialize() directly.

You can await on this method if you want to make sure the client is initialized.

Returns
TypeDescription
Promise<{ [name: string]: Function; }>

{Promise} A promise that resolves to an authenticated service stub.

listConstraints(request, options)

listConstraints(request?: protos.google.cloud.orgpolicy.v2.IListConstraintsRequest, options?: CallOptions): Promise<[
        protos.google.cloud.orgpolicy.v2.IConstraint[],
        protos.google.cloud.orgpolicy.v2.IListConstraintsRequest | null,
        protos.google.cloud.orgpolicy.v2.IListConstraintsResponse
    ]>;

Lists constraints that could be applied on the specified resource.

Parameters
NameDescription
request IListConstraintsRequest

The request object that will be sent.

options CallOptions

Call options. See CallOptions for more details.

Returns
TypeDescription
Promise<[ protos.google.cloud.orgpolicy.v2.IConstraint[], protos.google.cloud.orgpolicy.v2.IListConstraintsRequest | null, protos.google.cloud.orgpolicy.v2.IListConstraintsResponse ]>

{Promise} - The promise which resolves to an array. The first element of the array is Array of . The client library will perform auto-pagination by default: it will call the API as many times as needed and will merge results from all the pages into this array. Note that it can affect your quota. We recommend using listConstraintsAsync() method described below for async iteration which you can stop as needed. Please see the documentation for more details and examples.

listConstraints(request, options, callback)

listConstraints(request: protos.google.cloud.orgpolicy.v2.IListConstraintsRequest, options: CallOptions, callback: PaginationCallback<protos.google.cloud.orgpolicy.v2.IListConstraintsRequest, protos.google.cloud.orgpolicy.v2.IListConstraintsResponse | null | undefined, protos.google.cloud.orgpolicy.v2.IConstraint>): void;
Parameters
NameDescription
request IListConstraintsRequest
options CallOptions
callback PaginationCallback<protos.google.cloud.orgpolicy.v2.IListConstraintsRequest, protos.google.cloud.orgpolicy.v2.IListConstraintsResponse | null | undefined, protos.google.cloud.orgpolicy.v2.IConstraint>
Returns
TypeDescription
void

listConstraints(request, callback)

listConstraints(request: protos.google.cloud.orgpolicy.v2.IListConstraintsRequest, callback: PaginationCallback<protos.google.cloud.orgpolicy.v2.IListConstraintsRequest, protos.google.cloud.orgpolicy.v2.IListConstraintsResponse | null | undefined, protos.google.cloud.orgpolicy.v2.IConstraint>): void;
Parameters
NameDescription
request IListConstraintsRequest
callback PaginationCallback<protos.google.cloud.orgpolicy.v2.IListConstraintsRequest, protos.google.cloud.orgpolicy.v2.IListConstraintsResponse | null | undefined, protos.google.cloud.orgpolicy.v2.IConstraint>
Returns
TypeDescription
void

listConstraintsAsync(request, options)

listConstraintsAsync(request?: protos.google.cloud.orgpolicy.v2.IListConstraintsRequest, options?: CallOptions): AsyncIterable<protos.google.cloud.orgpolicy.v2.IConstraint>;

Equivalent to listConstraints, but returns an iterable object.

for-await-of syntax is used with the iterable to get response elements on-demand.

Parameters
NameDescription
request IListConstraintsRequest

The request object that will be sent.

options CallOptions

Call options. See CallOptions for more details.

Returns
TypeDescription
AsyncIterable<protos.google.cloud.orgpolicy.v2.IConstraint>

{Object} An iterable Object that allows async iteration. When you iterate the returned iterable, each element will be an object representing . The API will be called under the hood as needed, once per the page, so you can stop the iteration when you don't need more results. Please see the documentation for more details and examples.

Example

  /**
   * This snippet has been automatically generated and should be regarded as a code template only.
   * It will require modifications to work.
   * It may require correct/in-range values for request initialization.
   * TODO(developer): Uncomment these variables before running the sample.
   */
  /**
   *  Required. The 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}`
   */
  // const parent = 'abc123'
  /**
   *  Size of the pages to be returned. This is currently unsupported and will
   *  be ignored. The server may at any point start using this field to limit
   *  page size.
   */
  // const pageSize = 1234
  /**
   *  Page token used to retrieve the next page. This is currently unsupported
   *  and will be ignored. The server may at any point start using this field.
   */
  // const pageToken = 'abc123'

  // Imports the Orgpolicy library
  const {OrgPolicyClient} = require('@google-cloud/org-policy').v2;

  // Instantiates a client
  const orgpolicyClient = new OrgPolicyClient();

  async function callListConstraints() {
    // Construct request
    const request = {
      parent,
    };

    // Run request
    const iterable = await orgpolicyClient.listConstraintsAsync(request);
    for await (const response of iterable) {
        console.log(response);
    }
  }

  callListConstraints();

listConstraintsStream(request, options)

listConstraintsStream(request?: protos.google.cloud.orgpolicy.v2.IListConstraintsRequest, options?: CallOptions): Transform;

Equivalent to method.name.toCamelCase(), but returns a NodeJS Stream object.

Parameters
NameDescription
request IListConstraintsRequest

The request object that will be sent.

options CallOptions

Call options. See CallOptions for more details.

Returns
TypeDescription
Transform

{Stream} An object stream which emits an object representing on 'data' event. The client library will perform auto-pagination by default: it will call the API as many times as needed. Note that it can affect your quota. We recommend using listConstraintsAsync() method described below for async iteration which you can stop as needed. Please see the documentation for more details and examples.

listCustomConstraints(request, options)

listCustomConstraints(request?: protos.google.cloud.orgpolicy.v2.IListCustomConstraintsRequest, options?: CallOptions): Promise<[
        protos.google.cloud.orgpolicy.v2.ICustomConstraint[],
        protos.google.cloud.orgpolicy.v2.IListCustomConstraintsRequest | null,
        protos.google.cloud.orgpolicy.v2.IListCustomConstraintsResponse
    ]>;

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

Parameters
NameDescription
request IListCustomConstraintsRequest

The request object that will be sent.

options CallOptions

Call options. See CallOptions for more details.

Returns
TypeDescription
Promise<[ protos.google.cloud.orgpolicy.v2.ICustomConstraint[], protos.google.cloud.orgpolicy.v2.IListCustomConstraintsRequest | null, protos.google.cloud.orgpolicy.v2.IListCustomConstraintsResponse ]>

{Promise} - The promise which resolves to an array. The first element of the array is Array of . The client library will perform auto-pagination by default: it will call the API as many times as needed and will merge results from all the pages into this array. Note that it can affect your quota. We recommend using listCustomConstraintsAsync() method described below for async iteration which you can stop as needed. Please see the documentation for more details and examples.

listCustomConstraints(request, options, callback)

listCustomConstraints(request: protos.google.cloud.orgpolicy.v2.IListCustomConstraintsRequest, options: CallOptions, callback: PaginationCallback<protos.google.cloud.orgpolicy.v2.IListCustomConstraintsRequest, protos.google.cloud.orgpolicy.v2.IListCustomConstraintsResponse | null | undefined, protos.google.cloud.orgpolicy.v2.ICustomConstraint>): void;
Parameters
NameDescription
request IListCustomConstraintsRequest
options CallOptions
callback PaginationCallback<protos.google.cloud.orgpolicy.v2.IListCustomConstraintsRequest, protos.google.cloud.orgpolicy.v2.IListCustomConstraintsResponse | null | undefined, protos.google.cloud.orgpolicy.v2.ICustomConstraint>
Returns
TypeDescription
void

listCustomConstraints(request, callback)

listCustomConstraints(request: protos.google.cloud.orgpolicy.v2.IListCustomConstraintsRequest, callback: PaginationCallback<protos.google.cloud.orgpolicy.v2.IListCustomConstraintsRequest, protos.google.cloud.orgpolicy.v2.IListCustomConstraintsResponse | null | undefined, protos.google.cloud.orgpolicy.v2.ICustomConstraint>): void;
Parameters
NameDescription
request IListCustomConstraintsRequest
callback PaginationCallback<protos.google.cloud.orgpolicy.v2.IListCustomConstraintsRequest, protos.google.cloud.orgpolicy.v2.IListCustomConstraintsResponse | null | undefined, protos.google.cloud.orgpolicy.v2.ICustomConstraint>
Returns
TypeDescription
void

listCustomConstraintsAsync(request, options)

listCustomConstraintsAsync(request?: protos.google.cloud.orgpolicy.v2.IListCustomConstraintsRequest, options?: CallOptions): AsyncIterable<protos.google.cloud.orgpolicy.v2.ICustomConstraint>;

Equivalent to listCustomConstraints, but returns an iterable object.

for-await-of syntax is used with the iterable to get response elements on-demand.

Parameters
NameDescription
request IListCustomConstraintsRequest

The request object that will be sent.

options CallOptions

Call options. See CallOptions for more details.

Returns
TypeDescription
AsyncIterable<protos.google.cloud.orgpolicy.v2.ICustomConstraint>

{Object} An iterable Object that allows async iteration. When you iterate the returned iterable, each element will be an object representing . The API will be called under the hood as needed, once per the page, so you can stop the iteration when you don't need more results. Please see the documentation for more details and examples.

Example

  /**
   * This snippet has been automatically generated and should be regarded as a code template only.
   * It will require modifications to work.
   * It may require correct/in-range values for request initialization.
   * TODO(developer): Uncomment these variables before running the sample.
   */
  /**
   *  Required. The 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}`
   */
  // const parent = 'abc123'
  /**
   *  Size of the pages to be returned. This is currently unsupported and will
   *  be ignored. The server may at any point start using this field to limit
   *  page size.
   */
  // const pageSize = 1234
  /**
   *  Page token used to retrieve the next page. This is currently unsupported
   *  and will be ignored. The server may at any point start using this field.
   */
  // const pageToken = 'abc123'

  // Imports the Orgpolicy library
  const {OrgPolicyClient} = require('@google-cloud/org-policy').v2;

  // Instantiates a client
  const orgpolicyClient = new OrgPolicyClient();

  async function callListCustomConstraints() {
    // Construct request
    const request = {
      parent,
    };

    // Run request
    const iterable = await orgpolicyClient.listCustomConstraintsAsync(request);
    for await (const response of iterable) {
        console.log(response);
    }
  }

  callListCustomConstraints();

listCustomConstraintsStream(request, options)

listCustomConstraintsStream(request?: protos.google.cloud.orgpolicy.v2.IListCustomConstraintsRequest, options?: CallOptions): Transform;

Equivalent to method.name.toCamelCase(), but returns a NodeJS Stream object.

Parameters
NameDescription
request IListCustomConstraintsRequest

The request object that will be sent.

options CallOptions

Call options. See CallOptions for more details.

Returns
TypeDescription
Transform

{Stream} An object stream which emits an object representing on 'data' event. The client library will perform auto-pagination by default: it will call the API as many times as needed. Note that it can affect your quota. We recommend using listCustomConstraintsAsync() method described below for async iteration which you can stop as needed. Please see the documentation for more details and examples.

listPolicies(request, options)

listPolicies(request?: protos.google.cloud.orgpolicy.v2.IListPoliciesRequest, options?: CallOptions): Promise<[
        protos.google.cloud.orgpolicy.v2.IPolicy[],
        protos.google.cloud.orgpolicy.v2.IListPoliciesRequest | null,
        protos.google.cloud.orgpolicy.v2.IListPoliciesResponse
    ]>;

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

Parameters
NameDescription
request IListPoliciesRequest

The request object that will be sent.

options CallOptions

Call options. See CallOptions for more details.

Returns
TypeDescription
Promise<[ protos.google.cloud.orgpolicy.v2.IPolicy[], protos.google.cloud.orgpolicy.v2.IListPoliciesRequest | null, protos.google.cloud.orgpolicy.v2.IListPoliciesResponse ]>

{Promise} - The promise which resolves to an array. The first element of the array is Array of Policy. The client library will perform auto-pagination by default: it will call the API as many times as needed and will merge results from all the pages into this array. Note that it can affect your quota. We recommend using listPoliciesAsync() method described below for async iteration which you can stop as needed. Please see the documentation for more details and examples.

listPolicies(request, options, callback)

listPolicies(request: protos.google.cloud.orgpolicy.v2.IListPoliciesRequest, options: CallOptions, callback: PaginationCallback<protos.google.cloud.orgpolicy.v2.IListPoliciesRequest, protos.google.cloud.orgpolicy.v2.IListPoliciesResponse | null | undefined, protos.google.cloud.orgpolicy.v2.IPolicy>): void;
Parameters
NameDescription
request IListPoliciesRequest
options CallOptions
callback PaginationCallback<protos.google.cloud.orgpolicy.v2.IListPoliciesRequest, protos.google.cloud.orgpolicy.v2.IListPoliciesResponse | null | undefined, protos.google.cloud.orgpolicy.v2.IPolicy>
Returns
TypeDescription
void

listPolicies(request, callback)

listPolicies(request: protos.google.cloud.orgpolicy.v2.IListPoliciesRequest, callback: PaginationCallback<protos.google.cloud.orgpolicy.v2.IListPoliciesRequest, protos.google.cloud.orgpolicy.v2.IListPoliciesResponse | null | undefined, protos.google.cloud.orgpolicy.v2.IPolicy>): void;
Parameters
NameDescription
request IListPoliciesRequest
callback PaginationCallback<protos.google.cloud.orgpolicy.v2.IListPoliciesRequest, protos.google.cloud.orgpolicy.v2.IListPoliciesResponse | null | undefined, protos.google.cloud.orgpolicy.v2.IPolicy>
Returns
TypeDescription
void

listPoliciesAsync(request, options)

listPoliciesAsync(request?: protos.google.cloud.orgpolicy.v2.IListPoliciesRequest, options?: CallOptions): AsyncIterable<protos.google.cloud.orgpolicy.v2.IPolicy>;

Equivalent to listPolicies, but returns an iterable object.

for-await-of syntax is used with the iterable to get response elements on-demand.

Parameters
NameDescription
request IListPoliciesRequest

The request object that will be sent.

options CallOptions

Call options. See CallOptions for more details.

Returns
TypeDescription
AsyncIterable<protos.google.cloud.orgpolicy.v2.IPolicy>

{Object} An iterable Object that allows async iteration. When you iterate the returned iterable, each element will be an object representing Policy. The API will be called under the hood as needed, once per the page, so you can stop the iteration when you don't need more results. Please see the documentation for more details and examples.

Example

  /**
   * This snippet has been automatically generated and should be regarded as a code template only.
   * It will require modifications to work.
   * It may require correct/in-range values for request initialization.
   * TODO(developer): Uncomment these variables before running the sample.
   */
  /**
   *  Required. The 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}`
   */
  // const parent = 'abc123'
  /**
   *  Size of the pages to be returned. This is currently unsupported and will
   *  be ignored. The server may at any point start using this field to limit
   *  page size.
   */
  // const pageSize = 1234
  /**
   *  Page token used to retrieve the next page. This is currently unsupported
   *  and will be ignored. The server may at any point start using this field.
   */
  // const pageToken = 'abc123'

  // Imports the Orgpolicy library
  const {OrgPolicyClient} = require('@google-cloud/org-policy').v2;

  // Instantiates a client
  const orgpolicyClient = new OrgPolicyClient();

  async function callListPolicies() {
    // Construct request
    const request = {
      parent,
    };

    // Run request
    const iterable = await orgpolicyClient.listPoliciesAsync(request);
    for await (const response of iterable) {
        console.log(response);
    }
  }

  callListPolicies();

listPoliciesStream(request, options)

listPoliciesStream(request?: protos.google.cloud.orgpolicy.v2.IListPoliciesRequest, options?: CallOptions): Transform;

Equivalent to method.name.toCamelCase(), but returns a NodeJS Stream object.

Parameters
NameDescription
request IListPoliciesRequest

The request object that will be sent.

options CallOptions

Call options. See CallOptions for more details.

Returns
TypeDescription
Transform

{Stream} An object stream which emits an object representing Policy on 'data' event. The client library will perform auto-pagination by default: it will call the API as many times as needed. Note that it can affect your quota. We recommend using listPoliciesAsync() method described below for async iteration which you can stop as needed. Please see the documentation for more details and examples.

matchConstraintFromFolderConstraintName(folderConstraintName)

matchConstraintFromFolderConstraintName(folderConstraintName: string): string | number;

Parse the constraint from FolderConstraint resource.

Parameter
NameDescription
folderConstraintName string

A fully-qualified path representing folder_constraint resource.

Returns
TypeDescription
string | number

{string} A string representing the constraint.

matchConstraintFromOrganizationConstraintName(organizationConstraintName)

matchConstraintFromOrganizationConstraintName(organizationConstraintName: string): string | number;

Parse the constraint from OrganizationConstraint resource.

Parameter
NameDescription
organizationConstraintName string

A fully-qualified path representing organization_constraint resource.

Returns
TypeDescription
string | number

{string} A string representing the constraint.

matchConstraintFromProjectConstraintName(projectConstraintName)

matchConstraintFromProjectConstraintName(projectConstraintName: string): string | number;

Parse the constraint from ProjectConstraint resource.

Parameter
NameDescription
projectConstraintName string

A fully-qualified path representing project_constraint resource.

Returns
TypeDescription
string | number

{string} A string representing the constraint.

matchCustomConstraintFromCustomConstraintName(customConstraintName)

matchCustomConstraintFromCustomConstraintName(customConstraintName: string): string | number;

Parse the custom_constraint from CustomConstraint resource.

Parameter
NameDescription
customConstraintName string

A fully-qualified path representing CustomConstraint resource.

Returns
TypeDescription
string | number

{string} A string representing the custom_constraint.

matchFolderFromFolderConstraintName(folderConstraintName)

matchFolderFromFolderConstraintName(folderConstraintName: string): string | number;

Parse the folder from FolderConstraint resource.

Parameter
NameDescription
folderConstraintName string

A fully-qualified path representing folder_constraint resource.

Returns
TypeDescription
string | number

{string} A string representing the folder.

matchFolderFromFolderPolicyName(folderPolicyName)

matchFolderFromFolderPolicyName(folderPolicyName: string): string | number;

Parse the folder from FolderPolicy resource.

Parameter
NameDescription
folderPolicyName string

A fully-qualified path representing folder_policy resource.

Returns
TypeDescription
string | number

{string} A string representing the folder.

matchOrganizationFromCustomConstraintName(customConstraintName)

matchOrganizationFromCustomConstraintName(customConstraintName: string): string | number;

Parse the organization from CustomConstraint resource.

Parameter
NameDescription
customConstraintName string

A fully-qualified path representing CustomConstraint resource.

Returns
TypeDescription
string | number

{string} A string representing the organization.

matchOrganizationFromOrganizationConstraintName(organizationConstraintName)

matchOrganizationFromOrganizationConstraintName(organizationConstraintName: string): string | number;

Parse the organization from OrganizationConstraint resource.

Parameter
NameDescription
organizationConstraintName string

A fully-qualified path representing organization_constraint resource.

Returns
TypeDescription
string | number

{string} A string representing the organization.

matchOrganizationFromOrganizationName(organizationName)

matchOrganizationFromOrganizationName(organizationName: string): string | number;

Parse the organization from Organization resource.

Parameter
NameDescription
organizationName string

A fully-qualified path representing Organization resource.

Returns
TypeDescription
string | number

{string} A string representing the organization.

matchOrganizationFromOrganizationPolicyName(organizationPolicyName)

matchOrganizationFromOrganizationPolicyName(organizationPolicyName: string): string | number;

Parse the organization from OrganizationPolicy resource.

Parameter
NameDescription
organizationPolicyName string

A fully-qualified path representing organization_policy resource.

Returns
TypeDescription
string | number

{string} A string representing the organization.

matchPolicyFromFolderPolicyName(folderPolicyName)

matchPolicyFromFolderPolicyName(folderPolicyName: string): string | number;

Parse the policy from FolderPolicy resource.

Parameter
NameDescription
folderPolicyName string

A fully-qualified path representing folder_policy resource.

Returns
TypeDescription
string | number

{string} A string representing the policy.

matchPolicyFromOrganizationPolicyName(organizationPolicyName)

matchPolicyFromOrganizationPolicyName(organizationPolicyName: string): string | number;

Parse the policy from OrganizationPolicy resource.

Parameter
NameDescription
organizationPolicyName string

A fully-qualified path representing organization_policy resource.

Returns
TypeDescription
string | number

{string} A string representing the policy.

matchPolicyFromProjectPolicyName(projectPolicyName)

matchPolicyFromProjectPolicyName(projectPolicyName: string): string | number;

Parse the policy from ProjectPolicy resource.

Parameter
NameDescription
projectPolicyName string

A fully-qualified path representing project_policy resource.

Returns
TypeDescription
string | number

{string} A string representing the policy.

matchProjectFromProjectConstraintName(projectConstraintName)

matchProjectFromProjectConstraintName(projectConstraintName: string): string | number;

Parse the project from ProjectConstraint resource.

Parameter
NameDescription
projectConstraintName string

A fully-qualified path representing project_constraint resource.

Returns
TypeDescription
string | number

{string} A string representing the project.

matchProjectFromProjectName(projectName)

matchProjectFromProjectName(projectName: string): string | number;

Parse the project from Project resource.

Parameter
NameDescription
projectName string

A fully-qualified path representing Project resource.

Returns
TypeDescription
string | number

{string} A string representing the project.

matchProjectFromProjectPolicyName(projectPolicyName)

matchProjectFromProjectPolicyName(projectPolicyName: string): string | number;

Parse the project from ProjectPolicy resource.

Parameter
NameDescription
projectPolicyName string

A fully-qualified path representing project_policy resource.

Returns
TypeDescription
string | number

{string} A string representing the project.

organizationConstraintPath(organization, constraint)

organizationConstraintPath(organization: string, constraint: string): string;

Return a fully-qualified organizationConstraint resource name string.

Parameters
NameDescription
organization string
constraint string
Returns
TypeDescription
string

{string} Resource name string.

organizationPath(organization)

organizationPath(organization: string): string;

Return a fully-qualified organization resource name string.

Parameter
NameDescription
organization string
Returns
TypeDescription
string

{string} Resource name string.

organizationPolicyPath(organization, policy)

organizationPolicyPath(organization: string, policy: string): string;

Return a fully-qualified organizationPolicy resource name string.

Parameters
NameDescription
organization string
policy string
Returns
TypeDescription
string

{string} Resource name string.

projectConstraintPath(project, constraint)

projectConstraintPath(project: string, constraint: string): string;

Return a fully-qualified projectConstraint resource name string.

Parameters
NameDescription
project string
constraint string
Returns
TypeDescription
string

{string} Resource name string.

projectPath(project)

projectPath(project: string): string;

Return a fully-qualified project resource name string.

Parameter
NameDescription
project string
Returns
TypeDescription
string

{string} Resource name string.

projectPolicyPath(project, policy)

projectPolicyPath(project: string, policy: string): string;

Return a fully-qualified projectPolicy resource name string.

Parameters
NameDescription
project string
policy string
Returns
TypeDescription
string

{string} Resource name string.

updateCustomConstraint(request, options)

updateCustomConstraint(request?: protos.google.cloud.orgpolicy.v2.IUpdateCustomConstraintRequest, options?: CallOptions): Promise<[
        protos.google.cloud.orgpolicy.v2.ICustomConstraint,
        (protos.google.cloud.orgpolicy.v2.IUpdateCustomConstraintRequest | undefined),
        {} | undefined
    ]>;

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
NameDescription
request IUpdateCustomConstraintRequest

The request object that will be sent.

options CallOptions

Call options. See CallOptions for more details.

Returns
TypeDescription
Promise<[ protos.google.cloud.orgpolicy.v2.ICustomConstraint, (protos.google.cloud.orgpolicy.v2.IUpdateCustomConstraintRequest | undefined), {} | undefined ]>

{Promise} - The promise which resolves to an array. The first element of the array is an object representing . Please see the documentation for more details and examples.

Example

  /**
   * This snippet has been automatically generated and should be regarded as a code template only.
   * It will require modifications to work.
   * It may require correct/in-range values for request initialization.
   * TODO(developer): Uncomment these variables before running the sample.
   */
  /**
   *  Required. `CustomConstraint` to update.
   */
  // const customConstraint = {}

  // Imports the Orgpolicy library
  const {OrgPolicyClient} = require('@google-cloud/org-policy').v2;

  // Instantiates a client
  const orgpolicyClient = new OrgPolicyClient();

  async function callUpdateCustomConstraint() {
    // Construct request
    const request = {
      customConstraint,
    };

    // Run request
    const response = await orgpolicyClient.updateCustomConstraint(request);
    console.log(response);
  }

  callUpdateCustomConstraint();

updateCustomConstraint(request, options, callback)

updateCustomConstraint(request: protos.google.cloud.orgpolicy.v2.IUpdateCustomConstraintRequest, options: CallOptions, callback: Callback<protos.google.cloud.orgpolicy.v2.ICustomConstraint, protos.google.cloud.orgpolicy.v2.IUpdateCustomConstraintRequest | null | undefined, {} | null | undefined>): void;
Parameters
NameDescription
request IUpdateCustomConstraintRequest
options CallOptions
callback Callback<protos.google.cloud.orgpolicy.v2.ICustomConstraint, protos.google.cloud.orgpolicy.v2.IUpdateCustomConstraintRequest | null | undefined, {} | null | undefined>
Returns
TypeDescription
void

updateCustomConstraint(request, callback)

updateCustomConstraint(request: protos.google.cloud.orgpolicy.v2.IUpdateCustomConstraintRequest, callback: Callback<protos.google.cloud.orgpolicy.v2.ICustomConstraint, protos.google.cloud.orgpolicy.v2.IUpdateCustomConstraintRequest | null | undefined, {} | null | undefined>): void;
Parameters
NameDescription
request IUpdateCustomConstraintRequest
callback Callback<protos.google.cloud.orgpolicy.v2.ICustomConstraint, protos.google.cloud.orgpolicy.v2.IUpdateCustomConstraintRequest | null | undefined, {} | null | undefined>
Returns
TypeDescription
void

updatePolicy(request, options)

updatePolicy(request?: protos.google.cloud.orgpolicy.v2.IUpdatePolicyRequest, options?: CallOptions): Promise<[
        protos.google.cloud.orgpolicy.v2.IPolicy,
        protos.google.cloud.orgpolicy.v2.IUpdatePolicyRequest | undefined,
        {} | undefined
    ]>;

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
NameDescription
request IUpdatePolicyRequest

The request object that will be sent.

options CallOptions

Call options. See CallOptions for more details.

Returns
TypeDescription
Promise<[ protos.google.cloud.orgpolicy.v2.IPolicy, protos.google.cloud.orgpolicy.v2.IUpdatePolicyRequest | undefined, {} | undefined ]>

{Promise} - The promise which resolves to an array. The first element of the array is an object representing Policy. Please see the documentation for more details and examples.

Example

  /**
   * This snippet has been automatically generated and should be regarded as a code template only.
   * It will require modifications to work.
   * It may require correct/in-range values for request initialization.
   * TODO(developer): Uncomment these variables before running the sample.
   */
  /**
   *  Required. Policy to update.
   */
  // const policy = {}
  /**
   *  Field mask used to specify the fields to be overwritten in the policy
   *  by the set. The fields specified in the update_mask are relative to the
   *  policy, not the full request.
   */
  // const updateMask = {}

  // Imports the Orgpolicy library
  const {OrgPolicyClient} = require('@google-cloud/org-policy').v2;

  // Instantiates a client
  const orgpolicyClient = new OrgPolicyClient();

  async function callUpdatePolicy() {
    // Construct request
    const request = {
      policy,
    };

    // Run request
    const response = await orgpolicyClient.updatePolicy(request);
    console.log(response);
  }

  callUpdatePolicy();

updatePolicy(request, options, callback)

updatePolicy(request: protos.google.cloud.orgpolicy.v2.IUpdatePolicyRequest, options: CallOptions, callback: Callback<protos.google.cloud.orgpolicy.v2.IPolicy, protos.google.cloud.orgpolicy.v2.IUpdatePolicyRequest | null | undefined, {} | null | undefined>): void;
Parameters
NameDescription
request IUpdatePolicyRequest
options CallOptions
callback Callback<protos.google.cloud.orgpolicy.v2.IPolicy, protos.google.cloud.orgpolicy.v2.IUpdatePolicyRequest | null | undefined, {} | null | undefined>
Returns
TypeDescription
void

updatePolicy(request, callback)

updatePolicy(request: protos.google.cloud.orgpolicy.v2.IUpdatePolicyRequest, callback: Callback<protos.google.cloud.orgpolicy.v2.IPolicy, protos.google.cloud.orgpolicy.v2.IUpdatePolicyRequest | null | undefined, {} | null | undefined>): void;
Parameters
NameDescription
request IUpdatePolicyRequest
callback Callback<protos.google.cloud.orgpolicy.v2.IPolicy, protos.google.cloud.orgpolicy.v2.IUpdatePolicyRequest | null | undefined, {} | null | undefined>
Returns
TypeDescription
void