Class v1.DashboardsServiceClient (2.9.2)

Manages Stackdriver dashboards. A dashboard is an arrangement of data display widgets in a specific layout. v1

Package

@google-cloud/monitoring-dashboards

Constructors

(constructor)(opts, gaxInstance)

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

Construct an instance of DashboardsServiceClient.

Parameters
NameDescription
opts ClientOptions
gaxInstance typeof gax | typeof gax.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 DashboardsServiceClient({fallback: 'rest'}, gax); ```

Properties

apiEndpoint

static get apiEndpoint(): string;

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

auth

auth: gax.GoogleAuth;

dashboardsServiceStub

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

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.

servicePath

static get servicePath(): string;

The DNS address for this API service.

warn

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

Methods

alertPolicyPath(project, alertPolicy)

alertPolicyPath(project: string, alertPolicy: string): string;

Return a fully-qualified alertPolicy resource name string.

Parameters
NameDescription
project string
alertPolicy string
Returns
TypeDescription
string

{string} Resource name string.

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.

createDashboard(request, options)

createDashboard(request?: protos.google.monitoring.dashboard.v1.ICreateDashboardRequest, options?: CallOptions): Promise<[
        protos.google.monitoring.dashboard.v1.IDashboard,
        protos.google.monitoring.dashboard.v1.ICreateDashboardRequest | undefined,
        {} | undefined
    ]>;

Creates a new custom dashboard. For examples on how you can use this API to create dashboards, see [Managing dashboards by API](https://cloud.google.com/monitoring/dashboards/api-dashboard). This method requires the monitoring.dashboards.create permission on the specified project. For more information about permissions, see [Cloud Identity and Access Management](https://cloud.google.com/iam).

Parameters
NameDescription
request protos.google.monitoring.dashboard.v1.ICreateDashboardRequest

The request object that will be sent.

options CallOptions

Call options. See CallOptions for more details.

Returns
TypeDescription
Promise<[ protos.google.monitoring.dashboard.v1.IDashboard, protos.google.monitoring.dashboard.v1.ICreateDashboardRequest | undefined, {} | undefined ]>

{Promise} - The promise which resolves to an array. The first element of the array is an object representing . Please see the [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) 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 project on which to execute the request. The format is:
   *      projects/[PROJECT_ID_OR_NUMBER]
   *  The `[PROJECT_ID_OR_NUMBER]` must match the dashboard resource name.
   */
  // const parent = 'abc123'
  /**
   *  Required. The initial dashboard specification.
   */
  // const dashboard = {}
  /**
   *  If set, validate the request and preview the review, but do not actually
   *  save it.
   */
  // const validateOnly = true

  // Imports the Dashboard library
  const {DashboardsServiceClient} = require('@google-cloud/monitoring-dashboards').v1;

  // Instantiates a client
  const dashboardClient = new DashboardsServiceClient();

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

    // Run request
    const response = await dashboardClient.createDashboard(request);
    console.log(response);
  }

  callCreateDashboard();

createDashboard(request, options, callback)

createDashboard(request: protos.google.monitoring.dashboard.v1.ICreateDashboardRequest, options: CallOptions, callback: Callback<protos.google.monitoring.dashboard.v1.IDashboard, protos.google.monitoring.dashboard.v1.ICreateDashboardRequest | null | undefined, {} | null | undefined>): void;
Parameters
NameDescription
request protos.google.monitoring.dashboard.v1.ICreateDashboardRequest
options CallOptions
callback Callback<protos.google.monitoring.dashboard.v1.IDashboard, protos.google.monitoring.dashboard.v1.ICreateDashboardRequest | null | undefined, {} | null | undefined>
Returns
TypeDescription
void

createDashboard(request, callback)

createDashboard(request: protos.google.monitoring.dashboard.v1.ICreateDashboardRequest, callback: Callback<protos.google.monitoring.dashboard.v1.IDashboard, protos.google.monitoring.dashboard.v1.ICreateDashboardRequest | null | undefined, {} | null | undefined>): void;
Parameters
NameDescription
request protos.google.monitoring.dashboard.v1.ICreateDashboardRequest
callback Callback<protos.google.monitoring.dashboard.v1.IDashboard, protos.google.monitoring.dashboard.v1.ICreateDashboardRequest | null | undefined, {} | null | undefined>
Returns
TypeDescription
void

dashboardPath(project, dashboard)

dashboardPath(project: string, dashboard: string): string;

Return a fully-qualified dashboard resource name string.

Parameters
NameDescription
project string
dashboard string
Returns
TypeDescription
string

{string} Resource name string.

deleteDashboard(request, options)

deleteDashboard(request?: protos.google.monitoring.dashboard.v1.IDeleteDashboardRequest, options?: CallOptions): Promise<[
        protos.google.protobuf.IEmpty,
        protos.google.monitoring.dashboard.v1.IDeleteDashboardRequest | undefined,
        {} | undefined
    ]>;

Deletes an existing custom dashboard.

This method requires the monitoring.dashboards.delete permission on the specified dashboard. For more information, see [Cloud Identity and Access Management](https://cloud.google.com/iam).

Parameters
NameDescription
request protos.google.monitoring.dashboard.v1.IDeleteDashboardRequest

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.monitoring.dashboard.v1.IDeleteDashboardRequest | undefined, {} | undefined ]>

{Promise} - The promise which resolves to an array. The first element of the array is an object representing . Please see the [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) 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 Dashboard. The format is:
   *      projects/[PROJECT_ID_OR_NUMBER]/dashboards/[DASHBOARD_ID]
   */
  // const name = 'abc123'

  // Imports the Dashboard library
  const {DashboardsServiceClient} = require('@google-cloud/monitoring-dashboards').v1;

  // Instantiates a client
  const dashboardClient = new DashboardsServiceClient();

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

    // Run request
    const response = await dashboardClient.deleteDashboard(request);
    console.log(response);
  }

  callDeleteDashboard();

deleteDashboard(request, options, callback)

deleteDashboard(request: protos.google.monitoring.dashboard.v1.IDeleteDashboardRequest, options: CallOptions, callback: Callback<protos.google.protobuf.IEmpty, protos.google.monitoring.dashboard.v1.IDeleteDashboardRequest | null | undefined, {} | null | undefined>): void;
Parameters
NameDescription
request protos.google.monitoring.dashboard.v1.IDeleteDashboardRequest
options CallOptions
callback Callback<protos.google.protobuf.IEmpty, protos.google.monitoring.dashboard.v1.IDeleteDashboardRequest | null | undefined, {} | null | undefined>
Returns
TypeDescription
void

deleteDashboard(request, callback)

deleteDashboard(request: protos.google.monitoring.dashboard.v1.IDeleteDashboardRequest, callback: Callback<protos.google.protobuf.IEmpty, protos.google.monitoring.dashboard.v1.IDeleteDashboardRequest | null | undefined, {} | null | undefined>): void;
Parameters
NameDescription
request protos.google.monitoring.dashboard.v1.IDeleteDashboardRequest
callback Callback<protos.google.protobuf.IEmpty, protos.google.monitoring.dashboard.v1.IDeleteDashboardRequest | null | undefined, {} | null | undefined>
Returns
TypeDescription
void

getDashboard(request, options)

getDashboard(request?: protos.google.monitoring.dashboard.v1.IGetDashboardRequest, options?: CallOptions): Promise<[
        protos.google.monitoring.dashboard.v1.IDashboard,
        protos.google.monitoring.dashboard.v1.IGetDashboardRequest | undefined,
        {} | undefined
    ]>;

Fetches a specific dashboard.

This method requires the monitoring.dashboards.get permission on the specified dashboard. For more information, see [Cloud Identity and Access Management](https://cloud.google.com/iam).

Parameters
NameDescription
request protos.google.monitoring.dashboard.v1.IGetDashboardRequest

The request object that will be sent.

options CallOptions

Call options. See CallOptions for more details.

Returns
TypeDescription
Promise<[ protos.google.monitoring.dashboard.v1.IDashboard, protos.google.monitoring.dashboard.v1.IGetDashboardRequest | undefined, {} | undefined ]>

{Promise} - The promise which resolves to an array. The first element of the array is an object representing . Please see the [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) 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 Dashboard. The format is one of:
   *   -  `dashboards/[DASHBOARD_ID]` (for system dashboards)
   *   -  `projects/[PROJECT_ID_OR_NUMBER]/dashboards/[DASHBOARD_ID]`
   *        (for custom dashboards).
   */
  // const name = 'abc123'

  // Imports the Dashboard library
  const {DashboardsServiceClient} = require('@google-cloud/monitoring-dashboards').v1;

  // Instantiates a client
  const dashboardClient = new DashboardsServiceClient();

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

    // Run request
    const response = await dashboardClient.getDashboard(request);
    console.log(response);
  }

  callGetDashboard();

getDashboard(request, options, callback)

getDashboard(request: protos.google.monitoring.dashboard.v1.IGetDashboardRequest, options: CallOptions, callback: Callback<protos.google.monitoring.dashboard.v1.IDashboard, protos.google.monitoring.dashboard.v1.IGetDashboardRequest | null | undefined, {} | null | undefined>): void;
Parameters
NameDescription
request protos.google.monitoring.dashboard.v1.IGetDashboardRequest
options CallOptions
callback Callback<protos.google.monitoring.dashboard.v1.IDashboard, protos.google.monitoring.dashboard.v1.IGetDashboardRequest | null | undefined, {} | null | undefined>
Returns
TypeDescription
void

getDashboard(request, callback)

getDashboard(request: protos.google.monitoring.dashboard.v1.IGetDashboardRequest, callback: Callback<protos.google.monitoring.dashboard.v1.IDashboard, protos.google.monitoring.dashboard.v1.IGetDashboardRequest | null | undefined, {} | null | undefined>): void;
Parameters
NameDescription
request protos.google.monitoring.dashboard.v1.IGetDashboardRequest
callback Callback<protos.google.monitoring.dashboard.v1.IDashboard, protos.google.monitoring.dashboard.v1.IGetDashboardRequest | 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.

listDashboards(request, options)

listDashboards(request?: protos.google.monitoring.dashboard.v1.IListDashboardsRequest, options?: CallOptions): Promise<[
        protos.google.monitoring.dashboard.v1.IDashboard[],
        protos.google.monitoring.dashboard.v1.IListDashboardsRequest | null,
        protos.google.monitoring.dashboard.v1.IListDashboardsResponse
    ]>;

Lists the existing dashboards.

This method requires the monitoring.dashboards.list permission on the specified project. For more information, see [Cloud Identity and Access Management](https://cloud.google.com/iam).

Parameters
NameDescription
request protos.google.monitoring.dashboard.v1.IListDashboardsRequest

The request object that will be sent.

options CallOptions

Call options. See CallOptions for more details.

Returns
TypeDescription
Promise<[ protos.google.monitoring.dashboard.v1.IDashboard[], protos.google.monitoring.dashboard.v1.IListDashboardsRequest | null, protos.google.monitoring.dashboard.v1.IListDashboardsResponse ]>

{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 listDashboardsAsync() 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.

listDashboards(request, options, callback)

listDashboards(request: protos.google.monitoring.dashboard.v1.IListDashboardsRequest, options: CallOptions, callback: PaginationCallback<protos.google.monitoring.dashboard.v1.IListDashboardsRequest, protos.google.monitoring.dashboard.v1.IListDashboardsResponse | null | undefined, protos.google.monitoring.dashboard.v1.IDashboard>): void;
Parameters
NameDescription
request protos.google.monitoring.dashboard.v1.IListDashboardsRequest
options CallOptions
callback PaginationCallback<protos.google.monitoring.dashboard.v1.IListDashboardsRequest, protos.google.monitoring.dashboard.v1.IListDashboardsResponse | null | undefined, protos.google.monitoring.dashboard.v1.IDashboard>
Returns
TypeDescription
void

listDashboards(request, callback)

listDashboards(request: protos.google.monitoring.dashboard.v1.IListDashboardsRequest, callback: PaginationCallback<protos.google.monitoring.dashboard.v1.IListDashboardsRequest, protos.google.monitoring.dashboard.v1.IListDashboardsResponse | null | undefined, protos.google.monitoring.dashboard.v1.IDashboard>): void;
Parameters
NameDescription
request protos.google.monitoring.dashboard.v1.IListDashboardsRequest
callback PaginationCallback<protos.google.monitoring.dashboard.v1.IListDashboardsRequest, protos.google.monitoring.dashboard.v1.IListDashboardsResponse | null | undefined, protos.google.monitoring.dashboard.v1.IDashboard>
Returns
TypeDescription
void

listDashboardsAsync(request, options)

listDashboardsAsync(request?: protos.google.monitoring.dashboard.v1.IListDashboardsRequest, options?: CallOptions): AsyncIterable<protos.google.monitoring.dashboard.v1.IDashboard>;

Equivalent to listDashboards, 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.monitoring.dashboard.v1.IListDashboardsRequest

The request object that will be sent.

options CallOptions

Call options. See CallOptions for more details.

Returns
TypeDescription
AsyncIterable<protos.google.monitoring.dashboard.v1.IDashboard>

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

  /**
   * 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 scope of the dashboards to list. The format is:
   *      projects/[PROJECT_ID_OR_NUMBER]
   */
  // const parent = 'abc123'
  /**
   *  A positive number that is the maximum number of results to return.
   *  If unspecified, a default of 1000 is used.
   */
  // const pageSize = 1234
  /**
   *  If this field is not empty then it must contain the `nextPageToken` value
   *  returned by a previous call to this method.  Using this field causes the
   *  method to return additional results from the previous method call.
   */
  // const pageToken = 'abc123'

  // Imports the Dashboard library
  const {DashboardsServiceClient} = require('@google-cloud/monitoring-dashboards').v1;

  // Instantiates a client
  const dashboardClient = new DashboardsServiceClient();

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

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

  callListDashboards();

listDashboardsStream(request, options)

listDashboardsStream(request?: protos.google.monitoring.dashboard.v1.IListDashboardsRequest, options?: CallOptions): Transform;

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

Parameters
NameDescription
request protos.google.monitoring.dashboard.v1.IListDashboardsRequest

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 listDashboardsAsync() 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.

matchAlertPolicyFromAlertPolicyName(alertPolicyName)

matchAlertPolicyFromAlertPolicyName(alertPolicyName: string): string | number;

Parse the alert_policy from AlertPolicy resource.

Parameter
NameDescription
alertPolicyName string

A fully-qualified path representing AlertPolicy resource.

Returns
TypeDescription
string | number

{string} A string representing the alert_policy.

matchDashboardFromDashboardName(dashboardName)

matchDashboardFromDashboardName(dashboardName: string): string | number;

Parse the dashboard from Dashboard resource.

Parameter
NameDescription
dashboardName string

A fully-qualified path representing Dashboard resource.

Returns
TypeDescription
string | number

{string} A string representing the dashboard.

matchProjectFromAlertPolicyName(alertPolicyName)

matchProjectFromAlertPolicyName(alertPolicyName: string): string | number;

Parse the project from AlertPolicy resource.

Parameter
NameDescription
alertPolicyName string

A fully-qualified path representing AlertPolicy resource.

Returns
TypeDescription
string | number

{string} A string representing the project.

matchProjectFromDashboardName(dashboardName)

matchProjectFromDashboardName(dashboardName: string): string | number;

Parse the project from Dashboard resource.

Parameter
NameDescription
dashboardName string

A fully-qualified path representing Dashboard 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.

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.

updateDashboard(request, options)

updateDashboard(request?: protos.google.monitoring.dashboard.v1.IUpdateDashboardRequest, options?: CallOptions): Promise<[
        protos.google.monitoring.dashboard.v1.IDashboard,
        protos.google.monitoring.dashboard.v1.IUpdateDashboardRequest | undefined,
        {} | undefined
    ]>;

Replaces an existing custom dashboard with a new definition.

This method requires the monitoring.dashboards.update permission on the specified dashboard. For more information, see [Cloud Identity and Access Management](https://cloud.google.com/iam).

Parameters
NameDescription
request protos.google.monitoring.dashboard.v1.IUpdateDashboardRequest

The request object that will be sent.

options CallOptions

Call options. See CallOptions for more details.

Returns
TypeDescription
Promise<[ protos.google.monitoring.dashboard.v1.IDashboard, protos.google.monitoring.dashboard.v1.IUpdateDashboardRequest | undefined, {} | undefined ]>

{Promise} - The promise which resolves to an array. The first element of the array is an object representing . Please see the [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) 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 dashboard that will replace the existing dashboard.
   */
  // const dashboard = {}
  /**
   *  If set, validate the request and preview the review, but do not actually
   *  save it.
   */
  // const validateOnly = true

  // Imports the Dashboard library
  const {DashboardsServiceClient} = require('@google-cloud/monitoring-dashboards').v1;

  // Instantiates a client
  const dashboardClient = new DashboardsServiceClient();

  async function callUpdateDashboard() {
    // Construct request
    const request = {
      dashboard,
    };

    // Run request
    const response = await dashboardClient.updateDashboard(request);
    console.log(response);
  }

  callUpdateDashboard();

updateDashboard(request, options, callback)

updateDashboard(request: protos.google.monitoring.dashboard.v1.IUpdateDashboardRequest, options: CallOptions, callback: Callback<protos.google.monitoring.dashboard.v1.IDashboard, protos.google.monitoring.dashboard.v1.IUpdateDashboardRequest | null | undefined, {} | null | undefined>): void;
Parameters
NameDescription
request protos.google.monitoring.dashboard.v1.IUpdateDashboardRequest
options CallOptions
callback Callback<protos.google.monitoring.dashboard.v1.IDashboard, protos.google.monitoring.dashboard.v1.IUpdateDashboardRequest | null | undefined, {} | null | undefined>
Returns
TypeDescription
void

updateDashboard(request, callback)

updateDashboard(request: protos.google.monitoring.dashboard.v1.IUpdateDashboardRequest, callback: Callback<protos.google.monitoring.dashboard.v1.IDashboard, protos.google.monitoring.dashboard.v1.IUpdateDashboardRequest | null | undefined, {} | null | undefined>): void;
Parameters
NameDescription
request protos.google.monitoring.dashboard.v1.IUpdateDashboardRequest
callback Callback<protos.google.monitoring.dashboard.v1.IDashboard, protos.google.monitoring.dashboard.v1.IUpdateDashboardRequest | null | undefined, {} | null | undefined>
Returns
TypeDescription
void