Class v2.OrgPolicyClient

An interface for managing organization policies.

The Cloud Org Policy service provides a simple mechanism for organizations to restrict the allowed configurations across their entire Cloud Resource hierarchy.

You can use a policy to configure restrictions in Cloud resources. For example, you can enforce a policy that restricts which Google Cloud Platform 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)

constructor(opts?: ClientOptions);

Construct an instance of OrgPolicyClient.

Parameter
NameDescription
opts ClientOptions

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.

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 Cloud resource.

Parameters
NameDescription
request protos.google.cloud.orgpolicy.v2.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](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) for more details and examples.

Example

  /**
   * TODO(developer): Uncomment these variables before running the sample.
   */
  /**
   *  Required. The 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 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>
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 protos.google.cloud.orgpolicy.v2.ICreatePolicyRequest
callback Callback<protos.google.cloud.orgpolicy.v2.IPolicy, protos.google.cloud.orgpolicy.v2.ICreatePolicyRequest | 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 Org Policy does not exist.

Parameters
NameDescription
request protos.google.cloud.orgpolicy.v2.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](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) for more details and examples.

Example

  /**
   * TODO(developer): Uncomment these variables before running the sample.
   */
  /**
   *  Required. Name of the policy to delete.
   *  See `Policy` 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 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 protos.google.cloud.orgpolicy.v2.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 protos.google.cloud.orgpolicy.v2.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.

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 a computed Policy across multiple resources. Subtrees of Resource Manager resource hierarchy with 'under:' prefix will not be expanded.

Parameters
NameDescription
request protos.google.cloud.orgpolicy.v2.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](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) for more details and examples.

Example

  /**
   * TODO(developer): Uncomment these variables before running the sample.
   */
  /**
   *  Required. The effective policy to compute. See `Policy` 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 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 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>
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 protos.google.cloud.orgpolicy.v2.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 protos.google.cloud.orgpolicy.v2.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](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) for more details and examples.

Example

  /**
   * TODO(developer): Uncomment these variables before running the sample.
   */
  /**
   *  Required. Resource name of the policy. See `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 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>
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 protos.google.cloud.orgpolicy.v2.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 protos.google.cloud.orgpolicy.v2.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 [Constraint]. 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](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) 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 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>
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 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>
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 protos.google.cloud.orgpolicy.v2.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](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols). When you iterate the returned iterable, each element will be an object representing [Constraint]. 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](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) for more details and examples.

Example

  /**
   * TODO(developer): Uncomment these variables before running the sample.
   */
  /**
   *  Required. The 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 protos.google.cloud.orgpolicy.v2.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 [Constraint] 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](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) 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 protos.google.cloud.orgpolicy.v2.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](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) 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 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>
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 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>
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 protos.google.cloud.orgpolicy.v2.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](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols). 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](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) for more details and examples.

Example

  /**
   * TODO(developer): Uncomment these variables before running the sample.
   */
  /**
   *  Required. The target 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 protos.google.cloud.orgpolicy.v2.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](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) 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.

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.

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.

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.

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.

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 protos.google.cloud.orgpolicy.v2.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](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) for more details and examples.

Example

  /**
   * TODO(developer): Uncomment these variables before running the sample.
   */
  /**
   *  Required. `Policy` to update.
   */
  // const policy = {}

  // 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 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>
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 protos.google.cloud.orgpolicy.v2.IUpdatePolicyRequest
callback Callback<protos.google.cloud.orgpolicy.v2.IPolicy, protos.google.cloud.orgpolicy.v2.IUpdatePolicyRequest | null | undefined, {} | null | undefined>
Returns
TypeDescription
void