Skip to content

Commit 2706f6e

Browse files
docs(samples): add auto-generated samples for Node with api short name in region tag (#520)
PiperOrigin-RevId: 399287285 Source-Link: googleapis/googleapis@1575986 Source-Link: googleapis/googleapis-gen@b27fff6 Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiYjI3ZmZmNjIzYTVkOGQ1ODZiNzAzYjVlNDkxOTg1NmFiZTdjMmViMyJ9 See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md Co-authored-by: Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com> Co-authored-by: Benjamin E. Coe <[email protected]>
1 parent 8b4837c commit 2706f6e

20 files changed

+1198
-4
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
// Copyright 2021 Google LLC
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
15+
'use strict';
16+
17+
function main(parent, gatewayId, deviceId) {
18+
// [START cloudiot_v1_generated_DeviceManager_BindDeviceToGateway_async]
19+
/**
20+
* TODO(developer): Uncomment these variables before running the sample.
21+
*/
22+
/**
23+
* Required. The name of the registry. For example,
24+
* `projects/example-project/locations/us-central1/registries/my-registry`.
25+
*/
26+
// const parent = 'abc123'
27+
/**
28+
* Required. The value of `gateway_id` can be either the device numeric ID or the
29+
* user-defined device identifier.
30+
*/
31+
// const gatewayId = 'abc123'
32+
/**
33+
* Required. The device to associate with the specified gateway. The value of
34+
* `device_id` can be either the device numeric ID or the user-defined device
35+
* identifier.
36+
*/
37+
// const deviceId = 'abc123'
38+
39+
// Imports the Iot library
40+
const {DeviceManagerClient} = require('@google-cloud/iot').v1;
41+
42+
// Instantiates a client
43+
const iotClient = new DeviceManagerClient();
44+
45+
async function bindDeviceToGateway() {
46+
// Construct request
47+
const request = {
48+
parent,
49+
gatewayId,
50+
deviceId,
51+
};
52+
53+
// Run request
54+
const response = await iotClient.bindDeviceToGateway(request);
55+
console.log(response);
56+
}
57+
58+
bindDeviceToGateway();
59+
// [END cloudiot_v1_generated_DeviceManager_BindDeviceToGateway_async]
60+
}
61+
62+
process.on('unhandledRejection', err => {
63+
console.error(err.message);
64+
process.exitCode = 1;
65+
});
66+
main(...process.argv.slice(2));
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
// Copyright 2021 Google LLC
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
15+
'use strict';
16+
17+
function main(parent, device) {
18+
// [START cloudiot_v1_generated_DeviceManager_CreateDevice_async]
19+
/**
20+
* TODO(developer): Uncomment these variables before running the sample.
21+
*/
22+
/**
23+
* Required. The name of the device registry where this device should be created.
24+
* For example,
25+
* `projects/example-project/locations/us-central1/registries/my-registry`.
26+
*/
27+
// const parent = 'abc123'
28+
/**
29+
* Required. The device registration details. The field `name` must be empty. The server
30+
* generates `name` from the device registry `id` and the
31+
* `parent` field.
32+
*/
33+
// const device = ''
34+
35+
// Imports the Iot library
36+
const {DeviceManagerClient} = require('@google-cloud/iot').v1;
37+
38+
// Instantiates a client
39+
const iotClient = new DeviceManagerClient();
40+
41+
async function createDevice() {
42+
// Construct request
43+
const request = {
44+
parent,
45+
device,
46+
};
47+
48+
// Run request
49+
const response = await iotClient.createDevice(request);
50+
console.log(response);
51+
}
52+
53+
createDevice();
54+
// [END cloudiot_v1_generated_DeviceManager_CreateDevice_async]
55+
}
56+
57+
process.on('unhandledRejection', err => {
58+
console.error(err.message);
59+
process.exitCode = 1;
60+
});
61+
main(...process.argv.slice(2));
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
// Copyright 2021 Google LLC
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
15+
'use strict';
16+
17+
function main(parent, deviceRegistry) {
18+
// [START cloudiot_v1_generated_DeviceManager_CreateDeviceRegistry_async]
19+
/**
20+
* TODO(developer): Uncomment these variables before running the sample.
21+
*/
22+
/**
23+
* Required. The project and cloud region where this device registry must be created.
24+
* For example, `projects/example-project/locations/us-central1`.
25+
*/
26+
// const parent = 'abc123'
27+
/**
28+
* Required. The device registry. The field `name` must be empty. The server will
29+
* generate that field from the device registry `id` provided and the
30+
* `parent` field.
31+
*/
32+
// const deviceRegistry = ''
33+
34+
// Imports the Iot library
35+
const {DeviceManagerClient} = require('@google-cloud/iot').v1;
36+
37+
// Instantiates a client
38+
const iotClient = new DeviceManagerClient();
39+
40+
async function createDeviceRegistry() {
41+
// Construct request
42+
const request = {
43+
parent,
44+
deviceRegistry,
45+
};
46+
47+
// Run request
48+
const response = await iotClient.createDeviceRegistry(request);
49+
console.log(response);
50+
}
51+
52+
createDeviceRegistry();
53+
// [END cloudiot_v1_generated_DeviceManager_CreateDeviceRegistry_async]
54+
}
55+
56+
process.on('unhandledRejection', err => {
57+
console.error(err.message);
58+
process.exitCode = 1;
59+
});
60+
main(...process.argv.slice(2));
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
// Copyright 2021 Google LLC
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
15+
'use strict';
16+
17+
function main(name) {
18+
// [START cloudiot_v1_generated_DeviceManager_DeleteDevice_async]
19+
/**
20+
* TODO(developer): Uncomment these variables before running the sample.
21+
*/
22+
/**
23+
* Required. The name of the device. For example,
24+
* `projects/p0/locations/us-central1/registries/registry0/devices/device0` or
25+
* `projects/p0/locations/us-central1/registries/registry0/devices/{num_id}`.
26+
*/
27+
// const name = 'abc123'
28+
29+
// Imports the Iot library
30+
const {DeviceManagerClient} = require('@google-cloud/iot').v1;
31+
32+
// Instantiates a client
33+
const iotClient = new DeviceManagerClient();
34+
35+
async function deleteDevice() {
36+
// Construct request
37+
const request = {
38+
name,
39+
};
40+
41+
// Run request
42+
const response = await iotClient.deleteDevice(request);
43+
console.log(response);
44+
}
45+
46+
deleteDevice();
47+
// [END cloudiot_v1_generated_DeviceManager_DeleteDevice_async]
48+
}
49+
50+
process.on('unhandledRejection', err => {
51+
console.error(err.message);
52+
process.exitCode = 1;
53+
});
54+
main(...process.argv.slice(2));
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
// Copyright 2021 Google LLC
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
15+
'use strict';
16+
17+
function main(name) {
18+
// [START cloudiot_v1_generated_DeviceManager_DeleteDeviceRegistry_async]
19+
/**
20+
* TODO(developer): Uncomment these variables before running the sample.
21+
*/
22+
/**
23+
* Required. The name of the device registry. For example,
24+
* `projects/example-project/locations/us-central1/registries/my-registry`.
25+
*/
26+
// const name = 'abc123'
27+
28+
// Imports the Iot library
29+
const {DeviceManagerClient} = require('@google-cloud/iot').v1;
30+
31+
// Instantiates a client
32+
const iotClient = new DeviceManagerClient();
33+
34+
async function deleteDeviceRegistry() {
35+
// Construct request
36+
const request = {
37+
name,
38+
};
39+
40+
// Run request
41+
const response = await iotClient.deleteDeviceRegistry(request);
42+
console.log(response);
43+
}
44+
45+
deleteDeviceRegistry();
46+
// [END cloudiot_v1_generated_DeviceManager_DeleteDeviceRegistry_async]
47+
}
48+
49+
process.on('unhandledRejection', err => {
50+
console.error(err.message);
51+
process.exitCode = 1;
52+
});
53+
main(...process.argv.slice(2));
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
// Copyright 2021 Google LLC
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
15+
'use strict';
16+
17+
function main(name) {
18+
// [START cloudiot_v1_generated_DeviceManager_GetDevice_async]
19+
/**
20+
* TODO(developer): Uncomment these variables before running the sample.
21+
*/
22+
/**
23+
* Required. The name of the device. For example,
24+
* `projects/p0/locations/us-central1/registries/registry0/devices/device0` or
25+
* `projects/p0/locations/us-central1/registries/registry0/devices/{num_id}`.
26+
*/
27+
// const name = 'abc123'
28+
/**
29+
* The fields of the `Device` resource to be returned in the response. If the
30+
* field mask is unset or empty, all fields are returned. Fields have to be
31+
* provided in snake_case format, for example: `last_heartbeat_time`.
32+
*/
33+
// const fieldMask = ''
34+
35+
// Imports the Iot library
36+
const {DeviceManagerClient} = require('@google-cloud/iot').v1;
37+
38+
// Instantiates a client
39+
const iotClient = new DeviceManagerClient();
40+
41+
async function getDevice() {
42+
// Construct request
43+
const request = {
44+
name,
45+
};
46+
47+
// Run request
48+
const response = await iotClient.getDevice(request);
49+
console.log(response);
50+
}
51+
52+
getDevice();
53+
// [END cloudiot_v1_generated_DeviceManager_GetDevice_async]
54+
}
55+
56+
process.on('unhandledRejection', err => {
57+
console.error(err.message);
58+
process.exitCode = 1;
59+
});
60+
main(...process.argv.slice(2));

0 commit comments

Comments
 (0)