Skip to content

Commit

Permalink
docs(samples): add auto-generated samples for Node with api short nam…
Browse files Browse the repository at this point in the history
…e in region tag (#221)

- [ ] Regenerate this pull request now.

PiperOrigin-RevId: 399287285

Source-Link: googleapis/googleapis@1575986

Source-Link: googleapis/googleapis-gen@b27fff6
Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiYjI3ZmZmNjIzYTVkOGQ1ODZiNzAzYjVlNDkxOTg1NmFiZTdjMmViMyJ9
  • Loading branch information
gcf-owl-bot[bot] authored Sep 28, 2021
1 parent 53effa4 commit 4c17fbc
Show file tree
Hide file tree
Showing 7 changed files with 305 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
// Copyright 2021 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

'use strict';

function main(parent, dashboard) {
// [START monitoring_v1_generated_DashboardsService_CreateDashboard_async]
/**
* 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 createDashboard() {
// Construct request
const request = {
parent,
dashboard,
};

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

createDashboard();
// [END monitoring_v1_generated_DashboardsService_CreateDashboard_async]
}

process.on('unhandledRejection', err => {
console.error(err.message);
process.exitCode = 1;
});
main(...process.argv.slice(2));
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
// Copyright 2021 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

'use strict';

function main(name) {
// [START monitoring_v1_generated_DashboardsService_DeleteDashboard_async]
/**
* 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 deleteDashboard() {
// Construct request
const request = {
name,
};

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

deleteDashboard();
// [END monitoring_v1_generated_DashboardsService_DeleteDashboard_async]
}

process.on('unhandledRejection', err => {
console.error(err.message);
process.exitCode = 1;
});
main(...process.argv.slice(2));
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
// Copyright 2021 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

'use strict';

function main(name) {
// [START monitoring_v1_generated_DashboardsService_GetDashboard_async]
/**
* 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 getDashboard() {
// Construct request
const request = {
name,
};

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

getDashboard();
// [END monitoring_v1_generated_DashboardsService_GetDashboard_async]
}

process.on('unhandledRejection', err => {
console.error(err.message);
process.exitCode = 1;
});
main(...process.argv.slice(2));
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
// Copyright 2021 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

'use strict';

function main(parent) {
// [START monitoring_v1_generated_DashboardsService_ListDashboards_async]
/**
* 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 listDashboards() {
// Construct request
const request = {
parent,
};

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

listDashboards();
// [END monitoring_v1_generated_DashboardsService_ListDashboards_async]
}

process.on('unhandledRejection', err => {
console.error(err.message);
process.exitCode = 1;
});
main(...process.argv.slice(2));
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
// Copyright 2021 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

'use strict';

function main(dashboard) {
// [START monitoring_v1_generated_DashboardsService_UpdateDashboard_async]
/**
* 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 updateDashboard() {
// Construct request
const request = {
dashboard,
};

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

updateDashboard();
// [END monitoring_v1_generated_DashboardsService_UpdateDashboard_async]
}

process.on('unhandledRejection', err => {
console.error(err.message);
process.exitCode = 1;
});
main(...process.argv.slice(2));
2 changes: 1 addition & 1 deletion packages/google-monitoring-dashboard/samples/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"license": "Apache-2.0",
"author": "Google LLC",
"engines": {
"node": ">=8"
"node": ">=10"
},
"files": [
"*.js"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -873,7 +873,8 @@ export class DashboardsServiceClient {
gax.routingHeader.fromParams({
parent: request.parent || '',
});
const callSettings = new gax.CallSettings(options);
const defaultCallSettings = this._defaults['listDashboards'];
const callSettings = defaultCallSettings.merge(options);
this.initialize();
return this.descriptors.page.listDashboards.createStream(
this.innerApiCalls.listDashboards as gax.GaxCall,
Expand Down Expand Up @@ -928,7 +929,8 @@ export class DashboardsServiceClient {
parent: request.parent || '',
});
options = options || {};
const callSettings = new gax.CallSettings(options);
const defaultCallSettings = this._defaults['listDashboards'];
const callSettings = defaultCallSettings.merge(options);
this.initialize();
return this.descriptors.page.listDashboards.asyncIterate(
this.innerApiCalls['listDashboards'] as GaxCall,
Expand Down

0 comments on commit 4c17fbc

Please sign in to comment.