Class v1.SecretManagerServiceClient (5.2.0)

Secret Manager Service

Manages secrets and operations using those secrets. Implements a REST model with the following objects:

* Secret * v1

Package

@google-cloud/secret-manager

Constructors

(constructor)(opts, gaxInstance)

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

Construct an instance of SecretManagerServiceClient.

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 SecretManagerServiceClient({fallback: true}, gax); ```

Properties

apiEndpoint

get apiEndpoint(): string;

The DNS address for this API service.

apiEndpoint

static get apiEndpoint(): string;

The DNS address for this API service - same as servicePath.

auth

auth: gax.GoogleAuth;

descriptors

descriptors: Descriptors;

innerApiCalls

innerApiCalls: {
        [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.

secretManagerServiceStub

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

servicePath

static get servicePath(): string;

The DNS address for this API service.

universeDomain

get universeDomain(): string;

warn

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

Methods

accessSecretVersion(request, options)

accessSecretVersion(request?: protos.google.cloud.secretmanager.v1.IAccessSecretVersionRequest, options?: CallOptions): Promise<[
        protos.google.cloud.secretmanager.v1.IAccessSecretVersionResponse,
        (protos.google.cloud.secretmanager.v1.IAccessSecretVersionRequest | undefined),
        {} | undefined
    ]>;

Accesses a . This call returns the secret data.

projects/* /secrets/* /versions/latest is an alias to the most recently created .

Parameters
NameDescription
request IAccessSecretVersionRequest

The request object that will be sent.

options CallOptions

Call options. See CallOptions for more details.

Returns
TypeDescription
Promise<[ protos.google.cloud.secretmanager.v1.IAccessSecretVersionResponse, (protos.google.cloud.secretmanager.v1.IAccessSecretVersionRequest | undefined), {} | undefined ]>

{Promise} - The promise which resolves to an array. The first element of the array is an object representing AccessSecretVersionResponse. 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 resource name of the SecretVersion google.cloud.secretmanager.v1.SecretVersion  in the format
   *  `projects/* /secrets/* /versions/*`.
   *  `projects/* /secrets/* /versions/latest` is an alias to the most recently
   *  created SecretVersion google.cloud.secretmanager.v1.SecretVersion.
   */
  // const name = 'abc123'

  // Imports the Secretmanager library
  const {SecretManagerServiceClient} = require('@google-cloud/secret-manager').v1;

  // Instantiates a client
  const secretmanagerClient = new SecretManagerServiceClient();

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

    // Run request
    const response = await secretmanagerClient.accessSecretVersion(request);
    console.log(response);
  }

  callAccessSecretVersion();

accessSecretVersion(request, options, callback)

accessSecretVersion(request: protos.google.cloud.secretmanager.v1.IAccessSecretVersionRequest, options: CallOptions, callback: Callback<protos.google.cloud.secretmanager.v1.IAccessSecretVersionResponse, protos.google.cloud.secretmanager.v1.IAccessSecretVersionRequest | null | undefined, {} | null | undefined>): void;
Parameters
NameDescription
request IAccessSecretVersionRequest
options CallOptions
callback Callback<protos.google.cloud.secretmanager.v1.IAccessSecretVersionResponse, protos.google.cloud.secretmanager.v1.IAccessSecretVersionRequest | null | undefined, {} | null | undefined>
Returns
TypeDescription
void

accessSecretVersion(request, callback)

accessSecretVersion(request: protos.google.cloud.secretmanager.v1.IAccessSecretVersionRequest, callback: Callback<protos.google.cloud.secretmanager.v1.IAccessSecretVersionResponse, protos.google.cloud.secretmanager.v1.IAccessSecretVersionRequest | null | undefined, {} | null | undefined>): void;
Parameters
NameDescription
request IAccessSecretVersionRequest
callback Callback<protos.google.cloud.secretmanager.v1.IAccessSecretVersionResponse, protos.google.cloud.secretmanager.v1.IAccessSecretVersionRequest | null | undefined, {} | null | undefined>
Returns
TypeDescription
void

addSecretVersion(request, options)

addSecretVersion(request?: protos.google.cloud.secretmanager.v1.IAddSecretVersionRequest, options?: CallOptions): Promise<[
        protos.google.cloud.secretmanager.v1.ISecretVersion,
        protos.google.cloud.secretmanager.v1.IAddSecretVersionRequest | undefined,
        {} | undefined
    ]>;

Creates a new containing secret data and attaches it to an existing Secret.

Parameters
NameDescription
request IAddSecretVersionRequest

The request object that will be sent.

options CallOptions

Call options. See CallOptions for more details.

Returns
TypeDescription
Promise<[ protos.google.cloud.secretmanager.v1.ISecretVersion, protos.google.cloud.secretmanager.v1.IAddSecretVersionRequest | 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. The resource name of the Secret google.cloud.secretmanager.v1.Secret  to associate with the
   *  SecretVersion google.cloud.secretmanager.v1.SecretVersion  in the format `projects/* /secrets/*`.
   */
  // const parent = 'abc123'
  /**
   *  Required. The secret payload of the SecretVersion google.cloud.secretmanager.v1.SecretVersion.
   */
  // const payload = {}

  // Imports the Secretmanager library
  const {SecretManagerServiceClient} = require('@google-cloud/secret-manager').v1;

  // Instantiates a client
  const secretmanagerClient = new SecretManagerServiceClient();

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

    // Run request
    const response = await secretmanagerClient.addSecretVersion(request);
    console.log(response);
  }

  callAddSecretVersion();

addSecretVersion(request, options, callback)

addSecretVersion(request: protos.google.cloud.secretmanager.v1.IAddSecretVersionRequest, options: CallOptions, callback: Callback<protos.google.cloud.secretmanager.v1.ISecretVersion, protos.google.cloud.secretmanager.v1.IAddSecretVersionRequest | null | undefined, {} | null | undefined>): void;
Parameters
NameDescription
request IAddSecretVersionRequest
options CallOptions
callback Callback<protos.google.cloud.secretmanager.v1.ISecretVersion, protos.google.cloud.secretmanager.v1.IAddSecretVersionRequest | null | undefined, {} | null | undefined>
Returns
TypeDescription
void

addSecretVersion(request, callback)

addSecretVersion(request: protos.google.cloud.secretmanager.v1.IAddSecretVersionRequest, callback: Callback<protos.google.cloud.secretmanager.v1.ISecretVersion, protos.google.cloud.secretmanager.v1.IAddSecretVersionRequest | null | undefined, {} | null | undefined>): void;
Parameters
NameDescription
request IAddSecretVersionRequest
callback Callback<protos.google.cloud.secretmanager.v1.ISecretVersion, protos.google.cloud.secretmanager.v1.IAddSecretVersionRequest | null | undefined, {} | null | undefined>
Returns
TypeDescription
void

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.

createSecret(request, options)

createSecret(request?: protos.google.cloud.secretmanager.v1.ICreateSecretRequest, options?: CallOptions): Promise<[
        protos.google.cloud.secretmanager.v1.ISecret,
        protos.google.cloud.secretmanager.v1.ICreateSecretRequest | undefined,
        {} | undefined
    ]>;

Creates a new Secret containing no .

Parameters
NameDescription
request ICreateSecretRequest

The request object that will be sent.

options CallOptions

Call options. See CallOptions for more details.

Returns
TypeDescription
Promise<[ protos.google.cloud.secretmanager.v1.ISecret, protos.google.cloud.secretmanager.v1.ICreateSecretRequest | undefined, {} | undefined ]>

{Promise} - The promise which resolves to an array. The first element of the array is an object representing Secret. 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 resource name of the project to associate with the
   *  Secret google.cloud.secretmanager.v1.Secret, in the format `projects/*`.
   */
  // const parent = 'abc123'
  /**
   *  Required. This must be unique within the project.
   *  A secret ID is a string with a maximum length of 255 characters and can
   *  contain uppercase and lowercase letters, numerals, and the hyphen (`-`) and
   *  underscore (`_`) characters.
   */
  // const secretId = 'abc123'
  /**
   *  Required. A Secret google.cloud.secretmanager.v1.Secret  with initial field values.
   */
  // const secret = {}

  // Imports the Secretmanager library
  const {SecretManagerServiceClient} = require('@google-cloud/secret-manager').v1;

  // Instantiates a client
  const secretmanagerClient = new SecretManagerServiceClient();

  async function callCreateSecret() {
    // Construct request
    const request = {
      parent,
      secretId,
      secret,
    };

    // Run request
    const response = await secretmanagerClient.createSecret(request);
    console.log(response);
  }

  callCreateSecret();

createSecret(request, options, callback)

createSecret(request: protos.google.cloud.secretmanager.v1.ICreateSecretRequest, options: CallOptions, callback: Callback<protos.google.cloud.secretmanager.v1.ISecret, protos.google.cloud.secretmanager.v1.ICreateSecretRequest | null | undefined, {} | null | undefined>): void;
Parameters
NameDescription
request ICreateSecretRequest
options CallOptions
callback Callback<protos.google.cloud.secretmanager.v1.ISecret, protos.google.cloud.secretmanager.v1.ICreateSecretRequest | null | undefined, {} | null | undefined>
Returns
TypeDescription
void

createSecret(request, callback)

createSecret(request: protos.google.cloud.secretmanager.v1.ICreateSecretRequest, callback: Callback<protos.google.cloud.secretmanager.v1.ISecret, protos.google.cloud.secretmanager.v1.ICreateSecretRequest | null | undefined, {} | null | undefined>): void;
Parameters
NameDescription
request ICreateSecretRequest
callback Callback<protos.google.cloud.secretmanager.v1.ISecret, protos.google.cloud.secretmanager.v1.ICreateSecretRequest | null | undefined, {} | null | undefined>
Returns
TypeDescription
void

deleteSecret(request, options)

deleteSecret(request?: protos.google.cloud.secretmanager.v1.IDeleteSecretRequest, options?: CallOptions): Promise<[
        protos.google.protobuf.IEmpty,
        protos.google.cloud.secretmanager.v1.IDeleteSecretRequest | undefined,
        {} | undefined
    ]>;

Deletes a Secret.

Parameters
NameDescription
request IDeleteSecretRequest

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.secretmanager.v1.IDeleteSecretRequest | 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. The resource name of the Secret google.cloud.secretmanager.v1.Secret  to delete in the format
   *  `projects/* /secrets/*`.
   */
  // const name = 'abc123'
  /**
   *  Optional. Etag of the Secret google.cloud.secretmanager.v1.Secret. The request succeeds if it matches
   *  the etag of the currently stored secret object. If the etag is omitted,
   *  the request succeeds.
   */
  // const etag = 'abc123'

  // Imports the Secretmanager library
  const {SecretManagerServiceClient} = require('@google-cloud/secret-manager').v1;

  // Instantiates a client
  const secretmanagerClient = new SecretManagerServiceClient();

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

    // Run request
    const response = await secretmanagerClient.deleteSecret(request);
    console.log(response);
  }

  callDeleteSecret();

deleteSecret(request, options, callback)

deleteSecret(request: protos.google.cloud.secretmanager.v1.IDeleteSecretRequest, options: CallOptions, callback: Callback<protos.google.protobuf.IEmpty, protos.google.cloud.secretmanager.v1.IDeleteSecretRequest | null | undefined, {} | null | undefined>): void;
Parameters
NameDescription
request IDeleteSecretRequest
options CallOptions
callback Callback<protos.google.protobuf.IEmpty, protos.google.cloud.secretmanager.v1.IDeleteSecretRequest | null | undefined, {} | null | undefined>
Returns
TypeDescription
void

deleteSecret(request, callback)

deleteSecret(request: protos.google.cloud.secretmanager.v1.IDeleteSecretRequest, callback: Callback<protos.google.protobuf.IEmpty, protos.google.cloud.secretmanager.v1.IDeleteSecretRequest | null | undefined, {} | null | undefined>): void;
Parameters
NameDescription
request IDeleteSecretRequest
callback Callback<protos.google.protobuf.IEmpty, protos.google.cloud.secretmanager.v1.IDeleteSecretRequest | null | undefined, {} | null | undefined>
Returns
TypeDescription
void

destroySecretVersion(request, options)

destroySecretVersion(request?: protos.google.cloud.secretmanager.v1.IDestroySecretVersionRequest, options?: CallOptions): Promise<[
        protos.google.cloud.secretmanager.v1.ISecretVersion,
        (protos.google.cloud.secretmanager.v1.IDestroySecretVersionRequest | undefined),
        {} | undefined
    ]>;

Destroys a .

Sets the of the to and irrevocably destroys the secret data.

Parameters
NameDescription
request IDestroySecretVersionRequest

The request object that will be sent.

options CallOptions

Call options. See CallOptions for more details.

Returns
TypeDescription
Promise<[ protos.google.cloud.secretmanager.v1.ISecretVersion, (protos.google.cloud.secretmanager.v1.IDestroySecretVersionRequest | 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. The resource name of the SecretVersion google.cloud.secretmanager.v1.SecretVersion  to destroy in the format
   *  `projects/* /secrets/* /versions/*`.
   */
  // const name = 'abc123'
  /**
   *  Optional. Etag of the SecretVersion google.cloud.secretmanager.v1.SecretVersion. The request succeeds if it matches
   *  the etag of the currently stored secret version object. If the etag is
   *  omitted, the request succeeds.
   */
  // const etag = 'abc123'

  // Imports the Secretmanager library
  const {SecretManagerServiceClient} = require('@google-cloud/secret-manager').v1;

  // Instantiates a client
  const secretmanagerClient = new SecretManagerServiceClient();

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

    // Run request
    const response = await secretmanagerClient.destroySecretVersion(request);
    console.log(response);
  }

  callDestroySecretVersion();

destroySecretVersion(request, options, callback)

destroySecretVersion(request: protos.google.cloud.secretmanager.v1.IDestroySecretVersionRequest, options: CallOptions, callback: Callback<protos.google.cloud.secretmanager.v1.ISecretVersion, protos.google.cloud.secretmanager.v1.IDestroySecretVersionRequest | null | undefined, {} | null | undefined>): void;
Parameters
NameDescription
request IDestroySecretVersionRequest
options CallOptions
callback Callback<protos.google.cloud.secretmanager.v1.ISecretVersion, protos.google.cloud.secretmanager.v1.IDestroySecretVersionRequest | null | undefined, {} | null | undefined>
Returns
TypeDescription
void

destroySecretVersion(request, callback)

destroySecretVersion(request: protos.google.cloud.secretmanager.v1.IDestroySecretVersionRequest, callback: Callback<protos.google.cloud.secretmanager.v1.ISecretVersion, protos.google.cloud.secretmanager.v1.IDestroySecretVersionRequest | null | undefined, {} | null | undefined>): void;
Parameters
NameDescription
request IDestroySecretVersionRequest
callback Callback<protos.google.cloud.secretmanager.v1.ISecretVersion, protos.google.cloud.secretmanager.v1.IDestroySecretVersionRequest | null | undefined, {} | null | undefined>
Returns
TypeDescription
void

disableSecretVersion(request, options)

disableSecretVersion(request?: protos.google.cloud.secretmanager.v1.IDisableSecretVersionRequest, options?: CallOptions): Promise<[
        protos.google.cloud.secretmanager.v1.ISecretVersion,
        (protos.google.cloud.secretmanager.v1.IDisableSecretVersionRequest | undefined),
        {} | undefined
    ]>;

Disables a .

Sets the of the to .

Parameters
NameDescription
request IDisableSecretVersionRequest

The request object that will be sent.

options CallOptions

Call options. See CallOptions for more details.

Returns
TypeDescription
Promise<[ protos.google.cloud.secretmanager.v1.ISecretVersion, (protos.google.cloud.secretmanager.v1.IDisableSecretVersionRequest | 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. The resource name of the SecretVersion google.cloud.secretmanager.v1.SecretVersion  to disable in the format
   *  `projects/* /secrets/* /versions/*`.
   */
  // const name = 'abc123'
  /**
   *  Optional. Etag of the SecretVersion google.cloud.secretmanager.v1.SecretVersion. The request succeeds if it matches
   *  the etag of the currently stored secret version object. If the etag is
   *  omitted, the request succeeds.
   */
  // const etag = 'abc123'

  // Imports the Secretmanager library
  const {SecretManagerServiceClient} = require('@google-cloud/secret-manager').v1;

  // Instantiates a client
  const secretmanagerClient = new SecretManagerServiceClient();

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

    // Run request
    const response = await secretmanagerClient.disableSecretVersion(request);
    console.log(response);
  }

  callDisableSecretVersion();

disableSecretVersion(request, options, callback)

disableSecretVersion(request: protos.google.cloud.secretmanager.v1.IDisableSecretVersionRequest, options: CallOptions, callback: Callback<protos.google.cloud.secretmanager.v1.ISecretVersion, protos.google.cloud.secretmanager.v1.IDisableSecretVersionRequest | null | undefined, {} | null | undefined>): void;
Parameters
NameDescription
request IDisableSecretVersionRequest
options CallOptions
callback Callback<protos.google.cloud.secretmanager.v1.ISecretVersion, protos.google.cloud.secretmanager.v1.IDisableSecretVersionRequest | null | undefined, {} | null | undefined>
Returns
TypeDescription
void

disableSecretVersion(request, callback)

disableSecretVersion(request: protos.google.cloud.secretmanager.v1.IDisableSecretVersionRequest, callback: Callback<protos.google.cloud.secretmanager.v1.ISecretVersion, protos.google.cloud.secretmanager.v1.IDisableSecretVersionRequest | null | undefined, {} | null | undefined>): void;
Parameters
NameDescription
request IDisableSecretVersionRequest
callback Callback<protos.google.cloud.secretmanager.v1.ISecretVersion, protos.google.cloud.secretmanager.v1.IDisableSecretVersionRequest | null | undefined, {} | null | undefined>
Returns
TypeDescription
void

enableSecretVersion(request, options)

enableSecretVersion(request?: protos.google.cloud.secretmanager.v1.IEnableSecretVersionRequest, options?: CallOptions): Promise<[
        protos.google.cloud.secretmanager.v1.ISecretVersion,
        (protos.google.cloud.secretmanager.v1.IEnableSecretVersionRequest | undefined),
        {} | undefined
    ]>;

Enables a .

Sets the of the to .

Parameters
NameDescription
request IEnableSecretVersionRequest

The request object that will be sent.

options CallOptions

Call options. See CallOptions for more details.

Returns
TypeDescription
Promise<[ protos.google.cloud.secretmanager.v1.ISecretVersion, (protos.google.cloud.secretmanager.v1.IEnableSecretVersionRequest | 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. The resource name of the SecretVersion google.cloud.secretmanager.v1.SecretVersion  to enable in the format
   *  `projects/* /secrets/* /versions/*`.
   */
  // const name = 'abc123'
  /**
   *  Optional. Etag of the SecretVersion google.cloud.secretmanager.v1.SecretVersion. The request succeeds if it matches
   *  the etag of the currently stored secret version object. If the etag is
   *  omitted, the request succeeds.
   */
  // const etag = 'abc123'

  // Imports the Secretmanager library
  const {SecretManagerServiceClient} = require('@google-cloud/secret-manager').v1;

  // Instantiates a client
  const secretmanagerClient = new SecretManagerServiceClient();

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

    // Run request
    const response = await secretmanagerClient.enableSecretVersion(request);
    console.log(response);
  }

  callEnableSecretVersion();

enableSecretVersion(request, options, callback)

enableSecretVersion(request: protos.google.cloud.secretmanager.v1.IEnableSecretVersionRequest, options: CallOptions, callback: Callback<protos.google.cloud.secretmanager.v1.ISecretVersion, protos.google.cloud.secretmanager.v1.IEnableSecretVersionRequest | null | undefined, {} | null | undefined>): void;
Parameters
NameDescription
request IEnableSecretVersionRequest
options CallOptions
callback Callback<protos.google.cloud.secretmanager.v1.ISecretVersion, protos.google.cloud.secretmanager.v1.IEnableSecretVersionRequest | null | undefined, {} | null | undefined>
Returns
TypeDescription
void

enableSecretVersion(request, callback)

enableSecretVersion(request: protos.google.cloud.secretmanager.v1.IEnableSecretVersionRequest, callback: Callback<protos.google.cloud.secretmanager.v1.ISecretVersion, protos.google.cloud.secretmanager.v1.IEnableSecretVersionRequest | null | undefined, {} | null | undefined>): void;
Parameters
NameDescription
request IEnableSecretVersionRequest
callback Callback<protos.google.cloud.secretmanager.v1.ISecretVersion, protos.google.cloud.secretmanager.v1.IEnableSecretVersionRequest | null | undefined, {} | null | undefined>
Returns
TypeDescription
void

getIamPolicy(request, options)

getIamPolicy(request?: protos.google.iam.v1.IGetIamPolicyRequest, options?: CallOptions): Promise<[
        protos.google.iam.v1.IPolicy,
        protos.google.iam.v1.IGetIamPolicyRequest | undefined,
        {} | undefined
    ]>;

Gets the access control policy for a secret. Returns empty policy if the secret exists and does not have a policy set.

Parameters
NameDescription
request IGetIamPolicyRequest

The request object that will be sent.

options CallOptions

Call options. See CallOptions for more details.

Returns
TypeDescription
Promise<[ protos.google.iam.v1.IPolicy, protos.google.iam.v1.IGetIamPolicyRequest | 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 resource for which the policy is being requested.
   *  See the operation documentation for the appropriate value for this field.
   */
  // const resource = 'abc123'
  /**
   *  OPTIONAL: A `GetPolicyOptions` object for specifying options to
   *  `GetIamPolicy`.
   */
  // const options = {}

  // Imports the Secretmanager library
  const {SecretManagerServiceClient} = require('@google-cloud/secret-manager').v1;

  // Instantiates a client
  const secretmanagerClient = new SecretManagerServiceClient();

  async function callGetIamPolicy() {
    // Construct request
    const request = {
      resource,
    };

    // Run request
    const response = await secretmanagerClient.getIamPolicy(request);
    console.log(response);
  }

  callGetIamPolicy();

getIamPolicy(request, options, callback)

getIamPolicy(request: protos.google.iam.v1.IGetIamPolicyRequest, options: CallOptions, callback: Callback<protos.google.iam.v1.IPolicy, protos.google.iam.v1.IGetIamPolicyRequest | null | undefined, {} | null | undefined>): void;
Parameters
NameDescription
request IGetIamPolicyRequest
options CallOptions
callback Callback<protos.google.iam.v1.IPolicy, protos.google.iam.v1.IGetIamPolicyRequest | null | undefined, {} | null | undefined>
Returns
TypeDescription
void

getIamPolicy(request, callback)

getIamPolicy(request: protos.google.iam.v1.IGetIamPolicyRequest, callback: Callback<protos.google.iam.v1.IPolicy, protos.google.iam.v1.IGetIamPolicyRequest | null | undefined, {} | null | undefined>): void;
Parameters
NameDescription
request IGetIamPolicyRequest
callback Callback<protos.google.iam.v1.IPolicy, protos.google.iam.v1.IGetIamPolicyRequest | 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

getSecret(request, options)

getSecret(request?: protos.google.cloud.secretmanager.v1.IGetSecretRequest, options?: CallOptions): Promise<[
        protos.google.cloud.secretmanager.v1.ISecret,
        protos.google.cloud.secretmanager.v1.IGetSecretRequest | undefined,
        {} | undefined
    ]>;

Gets metadata for a given Secret.

Parameters
NameDescription
request IGetSecretRequest

The request object that will be sent.

options CallOptions

Call options. See CallOptions for more details.

Returns
TypeDescription
Promise<[ protos.google.cloud.secretmanager.v1.ISecret, protos.google.cloud.secretmanager.v1.IGetSecretRequest | undefined, {} | undefined ]>

{Promise} - The promise which resolves to an array. The first element of the array is an object representing Secret. 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 resource name of the Secret google.cloud.secretmanager.v1.Secret, in the format `projects/* /secrets/*`.
   */
  // const name = 'abc123'

  // Imports the Secretmanager library
  const {SecretManagerServiceClient} = require('@google-cloud/secret-manager').v1;

  // Instantiates a client
  const secretmanagerClient = new SecretManagerServiceClient();

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

    // Run request
    const response = await secretmanagerClient.getSecret(request);
    console.log(response);
  }

  callGetSecret();

getSecret(request, options, callback)

getSecret(request: protos.google.cloud.secretmanager.v1.IGetSecretRequest, options: CallOptions, callback: Callback<protos.google.cloud.secretmanager.v1.ISecret, protos.google.cloud.secretmanager.v1.IGetSecretRequest | null | undefined, {} | null | undefined>): void;
Parameters
NameDescription
request IGetSecretRequest
options CallOptions
callback Callback<protos.google.cloud.secretmanager.v1.ISecret, protos.google.cloud.secretmanager.v1.IGetSecretRequest | null | undefined, {} | null | undefined>
Returns
TypeDescription
void

getSecret(request, callback)

getSecret(request: protos.google.cloud.secretmanager.v1.IGetSecretRequest, callback: Callback<protos.google.cloud.secretmanager.v1.ISecret, protos.google.cloud.secretmanager.v1.IGetSecretRequest | null | undefined, {} | null | undefined>): void;
Parameters
NameDescription
request IGetSecretRequest
callback Callback<protos.google.cloud.secretmanager.v1.ISecret, protos.google.cloud.secretmanager.v1.IGetSecretRequest | null | undefined, {} | null | undefined>
Returns
TypeDescription
void

getSecretVersion(request, options)

getSecretVersion(request?: protos.google.cloud.secretmanager.v1.IGetSecretVersionRequest, options?: CallOptions): Promise<[
        protos.google.cloud.secretmanager.v1.ISecretVersion,
        protos.google.cloud.secretmanager.v1.IGetSecretVersionRequest | undefined,
        {} | undefined
    ]>;

Gets metadata for a .

projects/* /secrets/* /versions/latest is an alias to the most recently created .

Parameters
NameDescription
request IGetSecretVersionRequest

The request object that will be sent.

options CallOptions

Call options. See CallOptions for more details.

Returns
TypeDescription
Promise<[ protos.google.cloud.secretmanager.v1.ISecretVersion, protos.google.cloud.secretmanager.v1.IGetSecretVersionRequest | 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. The resource name of the SecretVersion google.cloud.secretmanager.v1.SecretVersion  in the format
   *  `projects/* /secrets/* /versions/*`.
   *  `projects/* /secrets/* /versions/latest` is an alias to the most recently
   *  created SecretVersion google.cloud.secretmanager.v1.SecretVersion.
   */
  // const name = 'abc123'

  // Imports the Secretmanager library
  const {SecretManagerServiceClient} = require('@google-cloud/secret-manager').v1;

  // Instantiates a client
  const secretmanagerClient = new SecretManagerServiceClient();

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

    // Run request
    const response = await secretmanagerClient.getSecretVersion(request);
    console.log(response);
  }

  callGetSecretVersion();

getSecretVersion(request, options, callback)

getSecretVersion(request: protos.google.cloud.secretmanager.v1.IGetSecretVersionRequest, options: CallOptions, callback: Callback<protos.google.cloud.secretmanager.v1.ISecretVersion, protos.google.cloud.secretmanager.v1.IGetSecretVersionRequest | null | undefined, {} | null | undefined>): void;
Parameters
NameDescription
request IGetSecretVersionRequest
options CallOptions
callback Callback<protos.google.cloud.secretmanager.v1.ISecretVersion, protos.google.cloud.secretmanager.v1.IGetSecretVersionRequest | null | undefined, {} | null | undefined>
Returns
TypeDescription
void

getSecretVersion(request, callback)

getSecretVersion(request: protos.google.cloud.secretmanager.v1.IGetSecretVersionRequest, callback: Callback<protos.google.cloud.secretmanager.v1.ISecretVersion, protos.google.cloud.secretmanager.v1.IGetSecretVersionRequest | null | undefined, {} | null | undefined>): void;
Parameters
NameDescription
request IGetSecretVersionRequest
callback Callback<protos.google.cloud.secretmanager.v1.ISecretVersion, protos.google.cloud.secretmanager.v1.IGetSecretVersionRequest | null | undefined, {} | null | 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.

listSecrets(request, options)

listSecrets(request?: protos.google.cloud.secretmanager.v1.IListSecretsRequest, options?: CallOptions): Promise<[
        protos.google.cloud.secretmanager.v1.ISecret[],
        protos.google.cloud.secretmanager.v1.IListSecretsRequest | null,
        protos.google.cloud.secretmanager.v1.IListSecretsResponse
    ]>;

Lists Secrets.

Parameters
NameDescription
request IListSecretsRequest

The request object that will be sent.

options CallOptions

Call options. See CallOptions for more details.

Returns
TypeDescription
Promise<[ protos.google.cloud.secretmanager.v1.ISecret[], protos.google.cloud.secretmanager.v1.IListSecretsRequest | null, protos.google.cloud.secretmanager.v1.IListSecretsResponse ]>

{Promise} - The promise which resolves to an array. The first element of the array is Array of Secret. 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 listSecretsAsync() method described below for async iteration which you can stop as needed. Please see the documentation for more details and examples.

listSecrets(request, options, callback)

listSecrets(request: protos.google.cloud.secretmanager.v1.IListSecretsRequest, options: CallOptions, callback: PaginationCallback<protos.google.cloud.secretmanager.v1.IListSecretsRequest, protos.google.cloud.secretmanager.v1.IListSecretsResponse | null | undefined, protos.google.cloud.secretmanager.v1.ISecret>): void;
Parameters
NameDescription
request IListSecretsRequest
options CallOptions
callback PaginationCallback<protos.google.cloud.secretmanager.v1.IListSecretsRequest, protos.google.cloud.secretmanager.v1.IListSecretsResponse | null | undefined, protos.google.cloud.secretmanager.v1.ISecret>
Returns
TypeDescription
void

listSecrets(request, callback)

listSecrets(request: protos.google.cloud.secretmanager.v1.IListSecretsRequest, callback: PaginationCallback<protos.google.cloud.secretmanager.v1.IListSecretsRequest, protos.google.cloud.secretmanager.v1.IListSecretsResponse | null | undefined, protos.google.cloud.secretmanager.v1.ISecret>): void;
Parameters
NameDescription
request IListSecretsRequest
callback PaginationCallback<protos.google.cloud.secretmanager.v1.IListSecretsRequest, protos.google.cloud.secretmanager.v1.IListSecretsResponse | null | undefined, protos.google.cloud.secretmanager.v1.ISecret>
Returns
TypeDescription
void

listSecretsAsync(request, options)

listSecretsAsync(request?: protos.google.cloud.secretmanager.v1.IListSecretsRequest, options?: CallOptions): AsyncIterable<protos.google.cloud.secretmanager.v1.ISecret>;

Equivalent to listSecrets, but returns an iterable object.

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

Parameters
NameDescription
request IListSecretsRequest

The request object that will be sent.

options CallOptions

Call options. See CallOptions for more details.

Returns
TypeDescription
AsyncIterable<protos.google.cloud.secretmanager.v1.ISecret>

{Object} An iterable Object that allows async iteration. When you iterate the returned iterable, each element will be an object representing Secret. 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 resource name of the project associated with the
   *  Secrets google.cloud.secretmanager.v1.Secret, in the format `projects/*`.
   */
  // const parent = 'abc123'
  /**
   *  Optional. The maximum number of results to be returned in a single page. If
   *  set to 0, the server decides the number of results to return. If the
   *  number is greater than 25000, it is capped at 25000.
   */
  // const pageSize = 1234
  /**
   *  Optional. Pagination token, returned earlier via
   *  ListSecretsResponse.next_page_token google.cloud.secretmanager.v1.ListSecretsResponse.next_page_token.
   */
  // const pageToken = 'abc123'
  /**
   *  Optional. Filter string, adhering to the rules in
   *  List-operation
   *  filtering (https://cloud.google.com/secret-manager/docs/filtering). List
   *  only secrets matching the filter. If filter is empty, all secrets are
   *  listed.
   */
  // const filter = 'abc123'

  // Imports the Secretmanager library
  const {SecretManagerServiceClient} =
    require('@google-cloud/secret-manager').v1;

  // Instantiates a client
  const secretmanagerClient = new SecretManagerServiceClient();

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

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

  callListSecrets();

listSecretsStream(request, options)

listSecretsStream(request?: protos.google.cloud.secretmanager.v1.IListSecretsRequest, options?: CallOptions): Transform;

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

Parameters
NameDescription
request IListSecretsRequest

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 Secret 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 listSecretsAsync() method described below for async iteration which you can stop as needed. Please see the documentation for more details and examples.

listSecretVersions(request, options)

listSecretVersions(request?: protos.google.cloud.secretmanager.v1.IListSecretVersionsRequest, options?: CallOptions): Promise<[
        protos.google.cloud.secretmanager.v1.ISecretVersion[],
        protos.google.cloud.secretmanager.v1.IListSecretVersionsRequest | null,
        protos.google.cloud.secretmanager.v1.IListSecretVersionsResponse
    ]>;

Lists . This call does not return secret data.

Parameters
NameDescription
request IListSecretVersionsRequest

The request object that will be sent.

options CallOptions

Call options. See CallOptions for more details.

Returns
TypeDescription
Promise<[ protos.google.cloud.secretmanager.v1.ISecretVersion[], protos.google.cloud.secretmanager.v1.IListSecretVersionsRequest | null, protos.google.cloud.secretmanager.v1.IListSecretVersionsResponse ]>

{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 listSecretVersionsAsync() method described below for async iteration which you can stop as needed. Please see the documentation for more details and examples.

listSecretVersions(request, options, callback)

listSecretVersions(request: protos.google.cloud.secretmanager.v1.IListSecretVersionsRequest, options: CallOptions, callback: PaginationCallback<protos.google.cloud.secretmanager.v1.IListSecretVersionsRequest, protos.google.cloud.secretmanager.v1.IListSecretVersionsResponse | null | undefined, protos.google.cloud.secretmanager.v1.ISecretVersion>): void;
Parameters
NameDescription
request IListSecretVersionsRequest
options CallOptions
callback PaginationCallback<protos.google.cloud.secretmanager.v1.IListSecretVersionsRequest, protos.google.cloud.secretmanager.v1.IListSecretVersionsResponse | null | undefined, protos.google.cloud.secretmanager.v1.ISecretVersion>
Returns
TypeDescription
void

listSecretVersions(request, callback)

listSecretVersions(request: protos.google.cloud.secretmanager.v1.IListSecretVersionsRequest, callback: PaginationCallback<protos.google.cloud.secretmanager.v1.IListSecretVersionsRequest, protos.google.cloud.secretmanager.v1.IListSecretVersionsResponse | null | undefined, protos.google.cloud.secretmanager.v1.ISecretVersion>): void;
Parameters
NameDescription
request IListSecretVersionsRequest
callback PaginationCallback<protos.google.cloud.secretmanager.v1.IListSecretVersionsRequest, protos.google.cloud.secretmanager.v1.IListSecretVersionsResponse | null | undefined, protos.google.cloud.secretmanager.v1.ISecretVersion>
Returns
TypeDescription
void

listSecretVersionsAsync(request, options)

listSecretVersionsAsync(request?: protos.google.cloud.secretmanager.v1.IListSecretVersionsRequest, options?: CallOptions): AsyncIterable<protos.google.cloud.secretmanager.v1.ISecretVersion>;

Equivalent to listSecretVersions, but returns an iterable object.

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

Parameters
NameDescription
request IListSecretVersionsRequest

The request object that will be sent.

options CallOptions

Call options. See CallOptions for more details.

Returns
TypeDescription
AsyncIterable<protos.google.cloud.secretmanager.v1.ISecretVersion>

{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 resource name of the Secret google.cloud.secretmanager.v1.Secret  associated with the
   *  SecretVersions google.cloud.secretmanager.v1.SecretVersion  to list, in the format
   *  `projects/* /secrets/*`.
   */
  // const parent = 'abc123'
  /**
   *  Optional. The maximum number of results to be returned in a single page. If
   *  set to 0, the server decides the number of results to return. If the
   *  number is greater than 25000, it is capped at 25000.
   */
  // const pageSize = 1234
  /**
   *  Optional. Pagination token, returned earlier via
   *  ListSecretVersionsResponse.next_page_token .
   */
  // const pageToken = 'abc123'
  /**
   *  Optional. Filter string, adhering to the rules in
   *  List-operation
   *  filtering (https://cloud.google.com/secret-manager/docs/filtering). List
   *  only secret versions matching the filter. If filter is empty, all secret
   *  versions are listed.
   */
  // const filter = 'abc123'

  // Imports the Secretmanager library
  const {SecretManagerServiceClient} = require('@google-cloud/secret-manager').v1;

  // Instantiates a client
  const secretmanagerClient = new SecretManagerServiceClient();

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

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

  callListSecretVersions();

listSecretVersionsStream(request, options)

listSecretVersionsStream(request?: protos.google.cloud.secretmanager.v1.IListSecretVersionsRequest, options?: CallOptions): Transform;

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

Parameters
NameDescription
request IListSecretVersionsRequest

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 listSecretVersionsAsync() method described below for async iteration which you can stop as needed. Please see the documentation for more details and examples.

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.

matchProjectFromSecretName(secretName)

matchProjectFromSecretName(secretName: string): string | number;

Parse the project from Secret resource.

Parameter
NameDescription
secretName string

A fully-qualified path representing Secret resource.

Returns
TypeDescription
string | number

{string} A string representing the project.

matchProjectFromSecretVersionName(secretVersionName)

matchProjectFromSecretVersionName(secretVersionName: string): string | number;

Parse the project from SecretVersion resource.

Parameter
NameDescription
secretVersionName string

A fully-qualified path representing SecretVersion resource.

Returns
TypeDescription
string | number

{string} A string representing the project.

matchProjectFromTopicName(topicName)

matchProjectFromTopicName(topicName: string): string | number;

Parse the project from Topic resource.

Parameter
NameDescription
topicName string

A fully-qualified path representing Topic resource.

Returns
TypeDescription
string | number

{string} A string representing the project.

matchSecretFromSecretName(secretName)

matchSecretFromSecretName(secretName: string): string | number;

Parse the secret from Secret resource.

Parameter
NameDescription
secretName string

A fully-qualified path representing Secret resource.

Returns
TypeDescription
string | number

{string} A string representing the secret.

matchSecretFromSecretVersionName(secretVersionName)

matchSecretFromSecretVersionName(secretVersionName: string): string | number;

Parse the secret from SecretVersion resource.

Parameter
NameDescription
secretVersionName string

A fully-qualified path representing SecretVersion resource.

Returns
TypeDescription
string | number

{string} A string representing the secret.

matchSecretVersionFromSecretVersionName(secretVersionName)

matchSecretVersionFromSecretVersionName(secretVersionName: string): string | number;

Parse the secret_version from SecretVersion resource.

Parameter
NameDescription
secretVersionName string

A fully-qualified path representing SecretVersion resource.

Returns
TypeDescription
string | number

{string} A string representing the secret_version.

matchTopicFromTopicName(topicName)

matchTopicFromTopicName(topicName: string): string | number;

Parse the topic from Topic resource.

Parameter
NameDescription
topicName string

A fully-qualified path representing Topic resource.

Returns
TypeDescription
string | number

{string} A string representing the topic.

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.

secretPath(project, secret)

secretPath(project: string, secret: string): string;

Return a fully-qualified secret resource name string.

Parameters
NameDescription
project string
secret string
Returns
TypeDescription
string

{string} Resource name string.

secretVersionPath(project, secret, secretVersion)

secretVersionPath(project: string, secret: string, secretVersion: string): string;

Return a fully-qualified secretVersion resource name string.

Parameters
NameDescription
project string
secret string
secretVersion string
Returns
TypeDescription
string

{string} Resource name string.

setIamPolicy(request, options)

setIamPolicy(request?: protos.google.iam.v1.ISetIamPolicyRequest, options?: CallOptions): Promise<[
        protos.google.iam.v1.IPolicy,
        protos.google.iam.v1.ISetIamPolicyRequest | undefined,
        {} | undefined
    ]>;

Sets the access control policy on the specified secret. Replaces any existing policy.

Permissions on are enforced according to the policy set on the associated Secret.

Parameters
NameDescription
request ISetIamPolicyRequest

The request object that will be sent.

options CallOptions

Call options. See CallOptions for more details.

Returns
TypeDescription
Promise<[ protos.google.iam.v1.IPolicy, protos.google.iam.v1.ISetIamPolicyRequest | 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 resource for which the policy is being specified.
   *  See the operation documentation for the appropriate value for this field.
   */
  // const resource = 'abc123'
  /**
   *  REQUIRED: The complete policy to be applied to the `resource`. The size of
   *  the policy is limited to a few 10s of KB. An empty policy is a
   *  valid policy but certain Cloud Platform services (such as Projects)
   *  might reject them.
   */
  // const policy = {}
  /**
   *  OPTIONAL: A FieldMask specifying which fields of the policy to modify. Only
   *  the fields in the mask will be modified. If no mask is provided, the
   *  following default mask is used:
   *  `paths: "bindings, etag"`
   */
  // const updateMask = {}

  // Imports the Secretmanager library
  const {SecretManagerServiceClient} = require('@google-cloud/secret-manager').v1;

  // Instantiates a client
  const secretmanagerClient = new SecretManagerServiceClient();

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

    // Run request
    const response = await secretmanagerClient.setIamPolicy(request);
    console.log(response);
  }

  callSetIamPolicy();

setIamPolicy(request, options, callback)

setIamPolicy(request: protos.google.iam.v1.ISetIamPolicyRequest, options: CallOptions, callback: Callback<protos.google.iam.v1.IPolicy, protos.google.iam.v1.ISetIamPolicyRequest | null | undefined, {} | null | undefined>): void;
Parameters
NameDescription
request ISetIamPolicyRequest
options CallOptions
callback Callback<protos.google.iam.v1.IPolicy, protos.google.iam.v1.ISetIamPolicyRequest | null | undefined, {} | null | undefined>
Returns
TypeDescription
void

setIamPolicy(request, callback)

setIamPolicy(request: protos.google.iam.v1.ISetIamPolicyRequest, callback: Callback<protos.google.iam.v1.IPolicy, protos.google.iam.v1.ISetIamPolicyRequest | null | undefined, {} | null | undefined>): void;
Parameters
NameDescription
request ISetIamPolicyRequest
callback Callback<protos.google.iam.v1.IPolicy, protos.google.iam.v1.ISetIamPolicyRequest | null | undefined, {} | null | undefined>
Returns
TypeDescription
void

testIamPermissions(request, options)

testIamPermissions(request?: protos.google.iam.v1.ITestIamPermissionsRequest, options?: CallOptions): Promise<[
        protos.google.iam.v1.ITestIamPermissionsResponse,
        protos.google.iam.v1.ITestIamPermissionsRequest | undefined,
        {} | undefined
    ]>;

Returns permissions that a caller has for the specified secret. If the secret does not exist, this call returns an empty set of permissions, not a NOT_FOUND error.

Note: This operation is designed to be used for building permission-aware UIs and command-line tools, not for authorization checking. This operation may "fail open" without warning.

Parameters
NameDescription
request ITestIamPermissionsRequest

The request object that will be sent.

options CallOptions

Call options. See CallOptions for more details.

Returns
TypeDescription
Promise<[ protos.google.iam.v1.ITestIamPermissionsResponse, protos.google.iam.v1.ITestIamPermissionsRequest | undefined, {} | undefined ]>

{Promise} - The promise which resolves to an array. The first element of the array is an object representing TestIamPermissionsResponse. 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 resource for which the policy detail is being requested.
   *  See the operation documentation for the appropriate value for this field.
   */
  // const resource = 'abc123'
  /**
   *  The set of permissions to check for the `resource`. Permissions with
   *  wildcards (such as '*' or 'storage.*') are not allowed. For more
   *  information see
   *  IAM Overview (https://cloud.google.com/iam/docs/overview#permissions).
   */
  // const permissions = ['abc','def']

  // Imports the Secretmanager library
  const {SecretManagerServiceClient} = require('@google-cloud/secret-manager').v1;

  // Instantiates a client
  const secretmanagerClient = new SecretManagerServiceClient();

  async function callTestIamPermissions() {
    // Construct request
    const request = {
      resource,
      permissions,
    };

    // Run request
    const response = await secretmanagerClient.testIamPermissions(request);
    console.log(response);
  }

  callTestIamPermissions();

testIamPermissions(request, options, callback)

testIamPermissions(request: protos.google.iam.v1.ITestIamPermissionsRequest, options: CallOptions, callback: Callback<protos.google.iam.v1.ITestIamPermissionsResponse, protos.google.iam.v1.ITestIamPermissionsRequest | null | undefined, {} | null | undefined>): void;
Parameters
NameDescription
request ITestIamPermissionsRequest
options CallOptions
callback Callback<protos.google.iam.v1.ITestIamPermissionsResponse, protos.google.iam.v1.ITestIamPermissionsRequest | null | undefined, {} | null | undefined>
Returns
TypeDescription
void

testIamPermissions(request, callback)

testIamPermissions(request: protos.google.iam.v1.ITestIamPermissionsRequest, callback: Callback<protos.google.iam.v1.ITestIamPermissionsResponse, protos.google.iam.v1.ITestIamPermissionsRequest | null | undefined, {} | null | undefined>): void;
Parameters
NameDescription
request ITestIamPermissionsRequest
callback Callback<protos.google.iam.v1.ITestIamPermissionsResponse, protos.google.iam.v1.ITestIamPermissionsRequest | null | undefined, {} | null | undefined>
Returns
TypeDescription
void

topicPath(project, topic)

topicPath(project: string, topic: string): string;

Return a fully-qualified topic resource name string.

Parameters
NameDescription
project string
topic string
Returns
TypeDescription
string

{string} Resource name string.

updateSecret(request, options)

updateSecret(request?: protos.google.cloud.secretmanager.v1.IUpdateSecretRequest, options?: CallOptions): Promise<[
        protos.google.cloud.secretmanager.v1.ISecret,
        protos.google.cloud.secretmanager.v1.IUpdateSecretRequest | undefined,
        {} | undefined
    ]>;

Updates metadata of an existing Secret.

Parameters
NameDescription
request IUpdateSecretRequest

The request object that will be sent.

options CallOptions

Call options. See CallOptions for more details.

Returns
TypeDescription
Promise<[ protos.google.cloud.secretmanager.v1.ISecret, protos.google.cloud.secretmanager.v1.IUpdateSecretRequest | undefined, {} | undefined ]>

{Promise} - The promise which resolves to an array. The first element of the array is an object representing Secret. 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. Secret google.cloud.secretmanager.v1.Secret  with updated field values.
   */
  // const secret = {}
  /**
   *  Required. Specifies the fields to be updated.
   */
  // const updateMask = {}

  // Imports the Secretmanager library
  const {SecretManagerServiceClient} = require('@google-cloud/secret-manager').v1;

  // Instantiates a client
  const secretmanagerClient = new SecretManagerServiceClient();

  async function callUpdateSecret() {
    // Construct request
    const request = {
      secret,
      updateMask,
    };

    // Run request
    const response = await secretmanagerClient.updateSecret(request);
    console.log(response);
  }

  callUpdateSecret();

updateSecret(request, options, callback)

updateSecret(request: protos.google.cloud.secretmanager.v1.IUpdateSecretRequest, options: CallOptions, callback: Callback<protos.google.cloud.secretmanager.v1.ISecret, protos.google.cloud.secretmanager.v1.IUpdateSecretRequest | null | undefined, {} | null | undefined>): void;
Parameters
NameDescription
request IUpdateSecretRequest
options CallOptions
callback Callback<protos.google.cloud.secretmanager.v1.ISecret, protos.google.cloud.secretmanager.v1.IUpdateSecretRequest | null | undefined, {} | null | undefined>
Returns
TypeDescription
void

updateSecret(request, callback)

updateSecret(request: protos.google.cloud.secretmanager.v1.IUpdateSecretRequest, callback: Callback<protos.google.cloud.secretmanager.v1.ISecret, protos.google.cloud.secretmanager.v1.IUpdateSecretRequest | null | undefined, {} | null | undefined>): void;
Parameters
NameDescription
request IUpdateSecretRequest
callback Callback<protos.google.cloud.secretmanager.v1.ISecret, protos.google.cloud.secretmanager.v1.IUpdateSecretRequest | null | undefined, {} | null | undefined>
Returns
TypeDescription
void