From 68d152f78a263a1cfc3be55340d4a7f68283bd27 Mon Sep 17 00:00:00 2001 From: "gcf-owl-bot[bot]" <78513119+gcf-owl-bot[bot]@users.noreply.github.com> Date: Thu, 23 Jun 2022 21:10:18 +0000 Subject: [PATCH] feat: Enable REST transport for most of Java and Go clients (#734) - [ ] Regenerate this pull request now. PiperOrigin-RevId: 456641589 Source-Link: https://github.com/googleapis/googleapis/commit/8a251f5225b789b2383207ffd978f6aa3d77fcf7 Source-Link: https://github.com/googleapis/googleapis-gen/commit/4ca52a529cf01308d9714950edffbea3560cfbdb Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiNGNhNTJhNTI5Y2YwMTMwOGQ5NzE0OTUwZWRmZmJlYTM1NjBjZmJkYiJ9 --- java-iot/README.md | 4 +- java-iot/google-cloud-iot/pom.xml | 16 + .../cloud/iot/v1/DeviceManagerClient.java | 14 + .../cloud/iot/v1/DeviceManagerSettings.java | 23 +- .../v1/stub/DeviceManagerStubSettings.java | 53 +- .../HttpJsonDeviceManagerCallableFactory.java | 105 + .../v1/stub/HttpJsonDeviceManagerStub.java | 1248 ++++++++++ .../v1/DeviceManagerClientHttpJsonTest.java | 2008 +++++++++++++++++ .../AsyncBindDeviceToGateway.java | 49 + .../SyncBindDeviceToGateway.java | 45 + ...viceToGatewayRegistrynameStringString.java | 42 + ...BindDeviceToGatewayStringStringString.java | 42 + .../SyncCreateSetCredentialsProvider.java | 41 + .../SyncCreateSetCredentialsProvider1.java | 40 + .../create/SyncCreateSetEndpoint.java | 38 + .../createdevice/AsyncCreateDevice.java | 47 + .../createdevice/SyncCreateDevice.java | 44 + .../SyncCreateDeviceRegistrynameDevice.java | 40 + .../SyncCreateDeviceStringDevice.java | 40 + .../AsyncCreateDeviceRegistry.java | 48 + .../SyncCreateDeviceRegistry.java | 44 + ...iceRegistryLocationnameDeviceregistry.java | 40 + ...ateDeviceRegistryStringDeviceregistry.java | 40 + .../deletedevice/AsyncDeleteDevice.java | 47 + .../deletedevice/SyncDeleteDevice.java | 43 + .../SyncDeleteDeviceDevicename.java | 38 + .../deletedevice/SyncDeleteDeviceString.java | 38 + .../AsyncDeleteDeviceRegistry.java | 47 + .../SyncDeleteDeviceRegistry.java | 42 + .../SyncDeleteDeviceRegistryRegistryname.java | 38 + .../SyncDeleteDeviceRegistryString.java | 38 + .../getdevice/AsyncGetDevice.java | 49 + .../getdevice/SyncGetDevice.java | 46 + .../getdevice/SyncGetDeviceDevicename.java | 39 + .../getdevice/SyncGetDeviceString.java | 39 + .../AsyncGetDeviceRegistry.java | 47 + .../SyncGetDeviceRegistry.java | 43 + .../SyncGetDeviceRegistryRegistryname.java | 39 + .../SyncGetDeviceRegistryString.java | 39 + .../getiampolicy/AsyncGetIamPolicy.java | 48 + .../getiampolicy/SyncGetIamPolicy.java | 45 + .../SyncGetIamPolicyResourcename.java | 40 + .../getiampolicy/SyncGetIamPolicyString.java | 40 + .../AsyncListDeviceConfigVersions.java | 49 + .../SyncListDeviceConfigVersions.java | 46 + ...yncListDeviceConfigVersionsDevicename.java | 40 + .../SyncListDeviceConfigVersionsString.java | 40 + .../AsyncListDeviceRegistries.java | 51 + .../AsyncListDeviceRegistriesPaged.java | 59 + .../SyncListDeviceRegistries.java | 48 + .../SyncListDeviceRegistriesLocationname.java | 41 + .../SyncListDeviceRegistriesString.java | 41 + .../listdevices/AsyncListDevices.java | 57 + .../listdevices/AsyncListDevicesPaged.java | 65 + .../listdevices/SyncListDevices.java | 54 + .../SyncListDevicesRegistryname.java | 41 + .../listdevices/SyncListDevicesString.java | 41 + .../AsyncListDeviceStates.java | 49 + .../SyncListDeviceStates.java | 45 + .../SyncListDeviceStatesDevicename.java | 39 + .../SyncListDeviceStatesString.java | 39 + .../AsyncModifyCloudToDeviceConfig.java | 51 + .../SyncModifyCloudToDeviceConfig.java | 47 + ...oudToDeviceConfigDevicenameBytestring.java | 41 + ...fyCloudToDeviceConfigStringBytestring.java | 41 + .../AsyncSendCommandToDevice.java | 51 + .../SyncSendCommandToDevice.java | 47 + ...ndCommandToDeviceDevicenameBytestring.java | 42 + ...andToDeviceDevicenameBytestringString.java | 43 + ...ncSendCommandToDeviceStringBytestring.java | 42 + ...CommandToDeviceStringBytestringString.java | 43 + .../setiampolicy/AsyncSetIamPolicy.java | 49 + .../setiampolicy/SyncSetIamPolicy.java | 46 + .../SyncSetIamPolicyResourcenamePolicy.java | 41 + .../SyncSetIamPolicyStringPolicy.java | 41 + .../AsyncTestIamPermissions.java | 49 + .../SyncTestIamPermissions.java | 45 + ...tIamPermissionsResourcenameListstring.java | 44 + ...yncTestIamPermissionsStringListstring.java | 44 + .../AsyncUnbindDeviceFromGateway.java | 49 + .../SyncUnbindDeviceFromGateway.java | 46 + ...ceFromGatewayRegistrynameStringString.java | 43 + ...ndDeviceFromGatewayStringStringString.java | 42 + .../updatedevice/AsyncUpdateDevice.java | 47 + .../updatedevice/SyncUpdateDevice.java | 44 + .../SyncUpdateDeviceDeviceFieldmask.java | 40 + .../AsyncUpdateDeviceRegistry.java | 48 + .../SyncUpdateDeviceRegistry.java | 44 + ...DeviceRegistryDeviceregistryFieldmask.java | 41 + .../SyncCreateDeviceRegistry.java | 45 + .../SyncCreateDeviceRegistry.java | 46 + 91 files changed, 7136 insertions(+), 7 deletions(-) create mode 100644 java-iot/google-cloud-iot/src/main/java/com/google/cloud/iot/v1/stub/HttpJsonDeviceManagerCallableFactory.java create mode 100644 java-iot/google-cloud-iot/src/main/java/com/google/cloud/iot/v1/stub/HttpJsonDeviceManagerStub.java create mode 100644 java-iot/google-cloud-iot/src/test/java/com/google/cloud/iot/v1/DeviceManagerClientHttpJsonTest.java create mode 100644 java-iot/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/binddevicetogateway/AsyncBindDeviceToGateway.java create mode 100644 java-iot/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/binddevicetogateway/SyncBindDeviceToGateway.java create mode 100644 java-iot/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/binddevicetogateway/SyncBindDeviceToGatewayRegistrynameStringString.java create mode 100644 java-iot/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/binddevicetogateway/SyncBindDeviceToGatewayStringStringString.java create mode 100644 java-iot/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/create/SyncCreateSetCredentialsProvider.java create mode 100644 java-iot/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/create/SyncCreateSetCredentialsProvider1.java create mode 100644 java-iot/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/create/SyncCreateSetEndpoint.java create mode 100644 java-iot/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/createdevice/AsyncCreateDevice.java create mode 100644 java-iot/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/createdevice/SyncCreateDevice.java create mode 100644 java-iot/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/createdevice/SyncCreateDeviceRegistrynameDevice.java create mode 100644 java-iot/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/createdevice/SyncCreateDeviceStringDevice.java create mode 100644 java-iot/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/createdeviceregistry/AsyncCreateDeviceRegistry.java create mode 100644 java-iot/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/createdeviceregistry/SyncCreateDeviceRegistry.java create mode 100644 java-iot/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/createdeviceregistry/SyncCreateDeviceRegistryLocationnameDeviceregistry.java create mode 100644 java-iot/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/createdeviceregistry/SyncCreateDeviceRegistryStringDeviceregistry.java create mode 100644 java-iot/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/deletedevice/AsyncDeleteDevice.java create mode 100644 java-iot/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/deletedevice/SyncDeleteDevice.java create mode 100644 java-iot/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/deletedevice/SyncDeleteDeviceDevicename.java create mode 100644 java-iot/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/deletedevice/SyncDeleteDeviceString.java create mode 100644 java-iot/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/deletedeviceregistry/AsyncDeleteDeviceRegistry.java create mode 100644 java-iot/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/deletedeviceregistry/SyncDeleteDeviceRegistry.java create mode 100644 java-iot/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/deletedeviceregistry/SyncDeleteDeviceRegistryRegistryname.java create mode 100644 java-iot/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/deletedeviceregistry/SyncDeleteDeviceRegistryString.java create mode 100644 java-iot/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/getdevice/AsyncGetDevice.java create mode 100644 java-iot/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/getdevice/SyncGetDevice.java create mode 100644 java-iot/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/getdevice/SyncGetDeviceDevicename.java create mode 100644 java-iot/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/getdevice/SyncGetDeviceString.java create mode 100644 java-iot/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/getdeviceregistry/AsyncGetDeviceRegistry.java create mode 100644 java-iot/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/getdeviceregistry/SyncGetDeviceRegistry.java create mode 100644 java-iot/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/getdeviceregistry/SyncGetDeviceRegistryRegistryname.java create mode 100644 java-iot/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/getdeviceregistry/SyncGetDeviceRegistryString.java create mode 100644 java-iot/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/getiampolicy/AsyncGetIamPolicy.java create mode 100644 java-iot/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/getiampolicy/SyncGetIamPolicy.java create mode 100644 java-iot/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/getiampolicy/SyncGetIamPolicyResourcename.java create mode 100644 java-iot/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/getiampolicy/SyncGetIamPolicyString.java create mode 100644 java-iot/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/listdeviceconfigversions/AsyncListDeviceConfigVersions.java create mode 100644 java-iot/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/listdeviceconfigversions/SyncListDeviceConfigVersions.java create mode 100644 java-iot/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/listdeviceconfigversions/SyncListDeviceConfigVersionsDevicename.java create mode 100644 java-iot/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/listdeviceconfigversions/SyncListDeviceConfigVersionsString.java create mode 100644 java-iot/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/listdeviceregistries/AsyncListDeviceRegistries.java create mode 100644 java-iot/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/listdeviceregistries/AsyncListDeviceRegistriesPaged.java create mode 100644 java-iot/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/listdeviceregistries/SyncListDeviceRegistries.java create mode 100644 java-iot/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/listdeviceregistries/SyncListDeviceRegistriesLocationname.java create mode 100644 java-iot/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/listdeviceregistries/SyncListDeviceRegistriesString.java create mode 100644 java-iot/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/listdevices/AsyncListDevices.java create mode 100644 java-iot/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/listdevices/AsyncListDevicesPaged.java create mode 100644 java-iot/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/listdevices/SyncListDevices.java create mode 100644 java-iot/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/listdevices/SyncListDevicesRegistryname.java create mode 100644 java-iot/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/listdevices/SyncListDevicesString.java create mode 100644 java-iot/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/listdevicestates/AsyncListDeviceStates.java create mode 100644 java-iot/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/listdevicestates/SyncListDeviceStates.java create mode 100644 java-iot/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/listdevicestates/SyncListDeviceStatesDevicename.java create mode 100644 java-iot/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/listdevicestates/SyncListDeviceStatesString.java create mode 100644 java-iot/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/modifycloudtodeviceconfig/AsyncModifyCloudToDeviceConfig.java create mode 100644 java-iot/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/modifycloudtodeviceconfig/SyncModifyCloudToDeviceConfig.java create mode 100644 java-iot/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/modifycloudtodeviceconfig/SyncModifyCloudToDeviceConfigDevicenameBytestring.java create mode 100644 java-iot/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/modifycloudtodeviceconfig/SyncModifyCloudToDeviceConfigStringBytestring.java create mode 100644 java-iot/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/sendcommandtodevice/AsyncSendCommandToDevice.java create mode 100644 java-iot/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/sendcommandtodevice/SyncSendCommandToDevice.java create mode 100644 java-iot/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/sendcommandtodevice/SyncSendCommandToDeviceDevicenameBytestring.java create mode 100644 java-iot/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/sendcommandtodevice/SyncSendCommandToDeviceDevicenameBytestringString.java create mode 100644 java-iot/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/sendcommandtodevice/SyncSendCommandToDeviceStringBytestring.java create mode 100644 java-iot/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/sendcommandtodevice/SyncSendCommandToDeviceStringBytestringString.java create mode 100644 java-iot/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/setiampolicy/AsyncSetIamPolicy.java create mode 100644 java-iot/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/setiampolicy/SyncSetIamPolicy.java create mode 100644 java-iot/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/setiampolicy/SyncSetIamPolicyResourcenamePolicy.java create mode 100644 java-iot/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/setiampolicy/SyncSetIamPolicyStringPolicy.java create mode 100644 java-iot/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/testiampermissions/AsyncTestIamPermissions.java create mode 100644 java-iot/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/testiampermissions/SyncTestIamPermissions.java create mode 100644 java-iot/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/testiampermissions/SyncTestIamPermissionsResourcenameListstring.java create mode 100644 java-iot/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/testiampermissions/SyncTestIamPermissionsStringListstring.java create mode 100644 java-iot/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/unbinddevicefromgateway/AsyncUnbindDeviceFromGateway.java create mode 100644 java-iot/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/unbinddevicefromgateway/SyncUnbindDeviceFromGateway.java create mode 100644 java-iot/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/unbinddevicefromgateway/SyncUnbindDeviceFromGatewayRegistrynameStringString.java create mode 100644 java-iot/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/unbinddevicefromgateway/SyncUnbindDeviceFromGatewayStringStringString.java create mode 100644 java-iot/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/updatedevice/AsyncUpdateDevice.java create mode 100644 java-iot/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/updatedevice/SyncUpdateDevice.java create mode 100644 java-iot/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/updatedevice/SyncUpdateDeviceDeviceFieldmask.java create mode 100644 java-iot/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/updatedeviceregistry/AsyncUpdateDeviceRegistry.java create mode 100644 java-iot/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/updatedeviceregistry/SyncUpdateDeviceRegistry.java create mode 100644 java-iot/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/updatedeviceregistry/SyncUpdateDeviceRegistryDeviceregistryFieldmask.java create mode 100644 java-iot/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagersettings/createdeviceregistry/SyncCreateDeviceRegistry.java create mode 100644 java-iot/samples/snippets/generated/com/google/cloud/iot/v1/stub/devicemanagerstubsettings/createdeviceregistry/SyncCreateDeviceRegistry.java diff --git a/java-iot/README.md b/java-iot/README.md index cb686b8d5f10..dfba32e25fad 100644 --- a/java-iot/README.md +++ b/java-iot/README.md @@ -56,13 +56,13 @@ implementation 'com.google.cloud:google-cloud-iot' If you are using Gradle without BOM, add this to your dependencies ```Groovy -implementation 'com.google.cloud:google-cloud-iot:2.2.0' +implementation 'com.google.cloud:google-cloud-iot:2.2.1' ``` If you are using SBT, add this to your dependencies ```Scala -libraryDependencies += "com.google.cloud" % "google-cloud-iot" % "2.2.0" +libraryDependencies += "com.google.cloud" % "google-cloud-iot" % "2.2.1" ``` ## Authentication diff --git a/java-iot/google-cloud-iot/pom.xml b/java-iot/google-cloud-iot/pom.xml index baa5cdcfefcc..1595cb6ef04f 100644 --- a/java-iot/google-cloud-iot/pom.xml +++ b/java-iot/google-cloud-iot/pom.xml @@ -62,6 +62,10 @@ com.google.api gax-grpc + + com.google.api + gax-httpjson + org.threeten threetenbp @@ -85,12 +89,24 @@ test + + com.google.api + gax + testlib + test + com.google.api gax-grpc testlib test + + com.google.api + gax-httpjson + testlib + test + diff --git a/java-iot/google-cloud-iot/src/main/java/com/google/cloud/iot/v1/DeviceManagerClient.java b/java-iot/google-cloud-iot/src/main/java/com/google/cloud/iot/v1/DeviceManagerClient.java index c3ffaea1ea26..f1a877c145f5 100644 --- a/java-iot/google-cloud-iot/src/main/java/com/google/cloud/iot/v1/DeviceManagerClient.java +++ b/java-iot/google-cloud-iot/src/main/java/com/google/cloud/iot/v1/DeviceManagerClient.java @@ -106,6 +106,20 @@ * DeviceManagerClient deviceManagerClient = DeviceManagerClient.create(deviceManagerSettings); * } * + *

To use REST (HTTP1.1/JSON) transport (instead of gRPC) for sending and receiving requests over + * the wire: + * + *

{@code
+ * // This snippet has been automatically generated for illustrative purposes only.
+ * // It may require modifications to work in your environment.
+ * DeviceManagerSettings deviceManagerSettings =
+ *     DeviceManagerSettings.newBuilder()
+ *         .setTransportChannelProvider(
+ *             DeviceManagerSettings.defaultHttpJsonTransportProviderBuilder().build())
+ *         .build();
+ * DeviceManagerClient deviceManagerClient = DeviceManagerClient.create(deviceManagerSettings);
+ * }
+ * *

Please refer to the GitHub repository's samples for more quickstart code snippets. */ @Generated("by gapic-generator-java") diff --git a/java-iot/google-cloud-iot/src/main/java/com/google/cloud/iot/v1/DeviceManagerSettings.java b/java-iot/google-cloud-iot/src/main/java/com/google/cloud/iot/v1/DeviceManagerSettings.java index ff603de02a4d..85fb689154e4 100644 --- a/java-iot/google-cloud-iot/src/main/java/com/google/cloud/iot/v1/DeviceManagerSettings.java +++ b/java-iot/google-cloud-iot/src/main/java/com/google/cloud/iot/v1/DeviceManagerSettings.java @@ -24,6 +24,7 @@ import com.google.api.gax.core.GoogleCredentialsProvider; import com.google.api.gax.core.InstantiatingExecutorProvider; import com.google.api.gax.grpc.InstantiatingGrpcChannelProvider; +import com.google.api.gax.httpjson.InstantiatingHttpJsonChannelProvider; import com.google.api.gax.rpc.ApiClientHeaderProvider; import com.google.api.gax.rpc.ClientContext; import com.google.api.gax.rpc.ClientSettings; @@ -211,11 +212,18 @@ public static GoogleCredentialsProvider.Builder defaultCredentialsProviderBuilde return DeviceManagerStubSettings.defaultCredentialsProviderBuilder(); } - /** Returns a builder for the default ChannelProvider for this service. */ + /** Returns a builder for the default gRPC ChannelProvider for this service. */ public static InstantiatingGrpcChannelProvider.Builder defaultGrpcTransportProviderBuilder() { return DeviceManagerStubSettings.defaultGrpcTransportProviderBuilder(); } + /** Returns a builder for the default REST ChannelProvider for this service. */ + @BetaApi + public static InstantiatingHttpJsonChannelProvider.Builder + defaultHttpJsonTransportProviderBuilder() { + return DeviceManagerStubSettings.defaultHttpJsonTransportProviderBuilder(); + } + public static TransportChannelProvider defaultTransportChannelProvider() { return DeviceManagerStubSettings.defaultTransportChannelProvider(); } @@ -225,11 +233,17 @@ public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuil return DeviceManagerStubSettings.defaultApiClientHeaderProviderBuilder(); } - /** Returns a new builder for this class. */ + /** Returns a new gRPC builder for this class. */ public static Builder newBuilder() { return Builder.createDefault(); } + /** Returns a new REST builder for this class. */ + @BetaApi + public static Builder newHttpJsonBuilder() { + return Builder.createHttpJsonDefault(); + } + /** Returns a new builder for this class. */ public static Builder newBuilder(ClientContext clientContext) { return new Builder(clientContext); @@ -267,6 +281,11 @@ private static Builder createDefault() { return new Builder(DeviceManagerStubSettings.newBuilder()); } + @BetaApi + private static Builder createHttpJsonDefault() { + return new Builder(DeviceManagerStubSettings.newHttpJsonBuilder()); + } + public DeviceManagerStubSettings.Builder getStubSettingsBuilder() { return ((DeviceManagerStubSettings.Builder) getStubSettings()); } diff --git a/java-iot/google-cloud-iot/src/main/java/com/google/cloud/iot/v1/stub/DeviceManagerStubSettings.java b/java-iot/google-cloud-iot/src/main/java/com/google/cloud/iot/v1/stub/DeviceManagerStubSettings.java index 8bb5b5225d3f..008ea98c719f 100644 --- a/java-iot/google-cloud-iot/src/main/java/com/google/cloud/iot/v1/stub/DeviceManagerStubSettings.java +++ b/java-iot/google-cloud-iot/src/main/java/com/google/cloud/iot/v1/stub/DeviceManagerStubSettings.java @@ -28,6 +28,9 @@ import com.google.api.gax.grpc.GaxGrpcProperties; import com.google.api.gax.grpc.GrpcTransportChannel; import com.google.api.gax.grpc.InstantiatingGrpcChannelProvider; +import com.google.api.gax.httpjson.GaxHttpJsonProperties; +import com.google.api.gax.httpjson.HttpJsonTransportChannel; +import com.google.api.gax.httpjson.InstantiatingHttpJsonChannelProvider; import com.google.api.gax.retrying.RetrySettings; import com.google.api.gax.rpc.ApiCallContext; import com.google.api.gax.rpc.ApiClientHeaderProvider; @@ -391,6 +394,11 @@ public DeviceManagerStub createStub() throws IOException { .equals(GrpcTransportChannel.getGrpcTransportName())) { return GrpcDeviceManagerStub.create(this); } + if (getTransportChannelProvider() + .getTransportName() + .equals(HttpJsonTransportChannel.getHttpJsonTransportName())) { + return HttpJsonDeviceManagerStub.create(this); + } throw new UnsupportedOperationException( String.format( "Transport not supported: %s", getTransportChannelProvider().getTransportName())); @@ -423,18 +431,25 @@ public static GoogleCredentialsProvider.Builder defaultCredentialsProviderBuilde .setUseJwtAccessWithScope(true); } - /** Returns a builder for the default ChannelProvider for this service. */ + /** Returns a builder for the default gRPC ChannelProvider for this service. */ public static InstantiatingGrpcChannelProvider.Builder defaultGrpcTransportProviderBuilder() { return InstantiatingGrpcChannelProvider.newBuilder() .setMaxInboundMessageSize(Integer.MAX_VALUE); } + /** Returns a builder for the default REST ChannelProvider for this service. */ + @BetaApi + public static InstantiatingHttpJsonChannelProvider.Builder + defaultHttpJsonTransportProviderBuilder() { + return InstantiatingHttpJsonChannelProvider.newBuilder(); + } + public static TransportChannelProvider defaultTransportChannelProvider() { return defaultGrpcTransportProviderBuilder().build(); } @BetaApi("The surface for customizing headers is not stable yet and may change in the future.") - public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuilder() { + public static ApiClientHeaderProvider.Builder defaultGrpcApiClientHeaderProviderBuilder() { return ApiClientHeaderProvider.newBuilder() .setGeneratedLibToken( "gapic", GaxProperties.getLibraryVersion(DeviceManagerStubSettings.class)) @@ -442,11 +457,30 @@ public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuil GaxGrpcProperties.getGrpcTokenName(), GaxGrpcProperties.getGrpcVersion()); } - /** Returns a new builder for this class. */ + @BetaApi("The surface for customizing headers is not stable yet and may change in the future.") + public static ApiClientHeaderProvider.Builder defaultHttpJsonApiClientHeaderProviderBuilder() { + return ApiClientHeaderProvider.newBuilder() + .setGeneratedLibToken( + "gapic", GaxProperties.getLibraryVersion(DeviceManagerStubSettings.class)) + .setTransportToken( + GaxHttpJsonProperties.getHttpJsonTokenName(), + GaxHttpJsonProperties.getHttpJsonVersion()); + } + + public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuilder() { + return DeviceManagerStubSettings.defaultGrpcApiClientHeaderProviderBuilder(); + } + + /** Returns a new gRPC builder for this class. */ public static Builder newBuilder() { return Builder.createDefault(); } + /** Returns a new REST builder for this class. */ + public static Builder newHttpJsonBuilder() { + return Builder.createHttpJsonDefault(); + } + /** Returns a new builder for this class. */ public static Builder newBuilder(ClientContext clientContext) { return new Builder(clientContext); @@ -694,6 +728,19 @@ private static Builder createDefault() { return initDefaults(builder); } + private static Builder createHttpJsonDefault() { + Builder builder = new Builder(((ClientContext) null)); + + builder.setTransportChannelProvider(defaultHttpJsonTransportProviderBuilder().build()); + builder.setCredentialsProvider(defaultCredentialsProviderBuilder().build()); + builder.setInternalHeaderProvider(defaultHttpJsonApiClientHeaderProviderBuilder().build()); + builder.setEndpoint(getDefaultEndpoint()); + builder.setMtlsEndpoint(getDefaultMtlsEndpoint()); + builder.setSwitchToMtlsEndpointAllowed(true); + + return initDefaults(builder); + } + private static Builder initDefaults(Builder builder) { builder .createDeviceRegistrySettings() diff --git a/java-iot/google-cloud-iot/src/main/java/com/google/cloud/iot/v1/stub/HttpJsonDeviceManagerCallableFactory.java b/java-iot/google-cloud-iot/src/main/java/com/google/cloud/iot/v1/stub/HttpJsonDeviceManagerCallableFactory.java new file mode 100644 index 000000000000..58d6577e08af --- /dev/null +++ b/java-iot/google-cloud-iot/src/main/java/com/google/cloud/iot/v1/stub/HttpJsonDeviceManagerCallableFactory.java @@ -0,0 +1,105 @@ +/* + * Copyright 2022 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 + * + * https://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. + */ + +package com.google.cloud.iot.v1.stub; + +import com.google.api.core.BetaApi; +import com.google.api.gax.httpjson.HttpJsonCallSettings; +import com.google.api.gax.httpjson.HttpJsonCallableFactory; +import com.google.api.gax.httpjson.HttpJsonOperationSnapshotCallable; +import com.google.api.gax.httpjson.HttpJsonStubCallableFactory; +import com.google.api.gax.httpjson.longrunning.stub.OperationsStub; +import com.google.api.gax.rpc.BatchingCallSettings; +import com.google.api.gax.rpc.ClientContext; +import com.google.api.gax.rpc.OperationCallSettings; +import com.google.api.gax.rpc.OperationCallable; +import com.google.api.gax.rpc.PagedCallSettings; +import com.google.api.gax.rpc.ServerStreamingCallSettings; +import com.google.api.gax.rpc.ServerStreamingCallable; +import com.google.api.gax.rpc.UnaryCallSettings; +import com.google.api.gax.rpc.UnaryCallable; +import com.google.longrunning.Operation; +import javax.annotation.Generated; + +// AUTO-GENERATED DOCUMENTATION AND CLASS. +/** + * REST callable factory implementation for the DeviceManager service API. + * + *

This class is for advanced usage. + */ +@Generated("by gapic-generator-java") +@BetaApi +public class HttpJsonDeviceManagerCallableFactory + implements HttpJsonStubCallableFactory { + + @Override + public UnaryCallable createUnaryCallable( + HttpJsonCallSettings httpJsonCallSettings, + UnaryCallSettings callSettings, + ClientContext clientContext) { + return HttpJsonCallableFactory.createUnaryCallable( + httpJsonCallSettings, callSettings, clientContext); + } + + @Override + public + UnaryCallable createPagedCallable( + HttpJsonCallSettings httpJsonCallSettings, + PagedCallSettings callSettings, + ClientContext clientContext) { + return HttpJsonCallableFactory.createPagedCallable( + httpJsonCallSettings, callSettings, clientContext); + } + + @Override + public UnaryCallable createBatchingCallable( + HttpJsonCallSettings httpJsonCallSettings, + BatchingCallSettings callSettings, + ClientContext clientContext) { + return HttpJsonCallableFactory.createBatchingCallable( + httpJsonCallSettings, callSettings, clientContext); + } + + @BetaApi( + "The surface for long-running operations is not stable yet and may change in the future.") + @Override + public + OperationCallable createOperationCallable( + HttpJsonCallSettings httpJsonCallSettings, + OperationCallSettings callSettings, + ClientContext clientContext, + OperationsStub operationsStub) { + UnaryCallable innerCallable = + HttpJsonCallableFactory.createBaseUnaryCallable( + httpJsonCallSettings, callSettings.getInitialCallSettings(), clientContext); + HttpJsonOperationSnapshotCallable initialCallable = + new HttpJsonOperationSnapshotCallable( + innerCallable, + httpJsonCallSettings.getMethodDescriptor().getOperationSnapshotFactory()); + return HttpJsonCallableFactory.createOperationCallable( + callSettings, clientContext, operationsStub.longRunningClient(), initialCallable); + } + + @Override + public + ServerStreamingCallable createServerStreamingCallable( + HttpJsonCallSettings httpJsonCallSettings, + ServerStreamingCallSettings callSettings, + ClientContext clientContext) { + return HttpJsonCallableFactory.createServerStreamingCallable( + httpJsonCallSettings, callSettings, clientContext); + } +} diff --git a/java-iot/google-cloud-iot/src/main/java/com/google/cloud/iot/v1/stub/HttpJsonDeviceManagerStub.java b/java-iot/google-cloud-iot/src/main/java/com/google/cloud/iot/v1/stub/HttpJsonDeviceManagerStub.java new file mode 100644 index 000000000000..1506c3f92888 --- /dev/null +++ b/java-iot/google-cloud-iot/src/main/java/com/google/cloud/iot/v1/stub/HttpJsonDeviceManagerStub.java @@ -0,0 +1,1248 @@ +/* + * Copyright 2022 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 + * + * https://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. + */ + +package com.google.cloud.iot.v1.stub; + +import static com.google.cloud.iot.v1.DeviceManagerClient.ListDeviceRegistriesPagedResponse; +import static com.google.cloud.iot.v1.DeviceManagerClient.ListDevicesPagedResponse; + +import com.google.api.core.BetaApi; +import com.google.api.core.InternalApi; +import com.google.api.gax.core.BackgroundResource; +import com.google.api.gax.core.BackgroundResourceAggregation; +import com.google.api.gax.httpjson.ApiMethodDescriptor; +import com.google.api.gax.httpjson.HttpJsonCallSettings; +import com.google.api.gax.httpjson.HttpJsonStubCallableFactory; +import com.google.api.gax.httpjson.ProtoMessageRequestFormatter; +import com.google.api.gax.httpjson.ProtoMessageResponseParser; +import com.google.api.gax.httpjson.ProtoRestSerializer; +import com.google.api.gax.rpc.ClientContext; +import com.google.api.gax.rpc.UnaryCallable; +import com.google.cloud.iot.v1.BindDeviceToGatewayRequest; +import com.google.cloud.iot.v1.BindDeviceToGatewayResponse; +import com.google.cloud.iot.v1.CreateDeviceRegistryRequest; +import com.google.cloud.iot.v1.CreateDeviceRequest; +import com.google.cloud.iot.v1.DeleteDeviceRegistryRequest; +import com.google.cloud.iot.v1.DeleteDeviceRequest; +import com.google.cloud.iot.v1.Device; +import com.google.cloud.iot.v1.DeviceConfig; +import com.google.cloud.iot.v1.DeviceRegistry; +import com.google.cloud.iot.v1.GetDeviceRegistryRequest; +import com.google.cloud.iot.v1.GetDeviceRequest; +import com.google.cloud.iot.v1.ListDeviceConfigVersionsRequest; +import com.google.cloud.iot.v1.ListDeviceConfigVersionsResponse; +import com.google.cloud.iot.v1.ListDeviceRegistriesRequest; +import com.google.cloud.iot.v1.ListDeviceRegistriesResponse; +import com.google.cloud.iot.v1.ListDeviceStatesRequest; +import com.google.cloud.iot.v1.ListDeviceStatesResponse; +import com.google.cloud.iot.v1.ListDevicesRequest; +import com.google.cloud.iot.v1.ListDevicesResponse; +import com.google.cloud.iot.v1.ModifyCloudToDeviceConfigRequest; +import com.google.cloud.iot.v1.SendCommandToDeviceRequest; +import com.google.cloud.iot.v1.SendCommandToDeviceResponse; +import com.google.cloud.iot.v1.UnbindDeviceFromGatewayRequest; +import com.google.cloud.iot.v1.UnbindDeviceFromGatewayResponse; +import com.google.cloud.iot.v1.UpdateDeviceRegistryRequest; +import com.google.cloud.iot.v1.UpdateDeviceRequest; +import com.google.iam.v1.GetIamPolicyRequest; +import com.google.iam.v1.Policy; +import com.google.iam.v1.SetIamPolicyRequest; +import com.google.iam.v1.TestIamPermissionsRequest; +import com.google.iam.v1.TestIamPermissionsResponse; +import com.google.protobuf.Empty; +import com.google.protobuf.TypeRegistry; +import java.io.IOException; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.concurrent.TimeUnit; +import javax.annotation.Generated; + +// AUTO-GENERATED DOCUMENTATION AND CLASS. +/** + * REST stub implementation for the DeviceManager service API. + * + *

This class is for advanced usage and reflects the underlying API directly. + */ +@Generated("by gapic-generator-java") +@BetaApi +public class HttpJsonDeviceManagerStub extends DeviceManagerStub { + private static final TypeRegistry typeRegistry = TypeRegistry.newBuilder().build(); + + private static final ApiMethodDescriptor + createDeviceRegistryMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.iot.v1.DeviceManager/CreateDeviceRegistry") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/{parent=projects/*/locations/*}/registries", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "parent", request.getParent()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create() + .toBody("deviceRegistry", request.getDeviceRegistry())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(DeviceRegistry.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + getDeviceRegistryMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.iot.v1.DeviceManager/GetDeviceRegistry") + .setHttpMethod("GET") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/{name=projects/*/locations/*/registries/*}", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "name", request.getName()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor(request -> null) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(DeviceRegistry.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + updateDeviceRegistryMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.iot.v1.DeviceManager/UpdateDeviceRegistry") + .setHttpMethod("PATCH") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/{deviceRegistry.name=projects/*/locations/*/registries/*}", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam( + fields, + "deviceRegistry.name", + request.getDeviceRegistry().getName()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putQueryParam(fields, "updateMask", request.getUpdateMask()); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create() + .toBody("deviceRegistry", request.getDeviceRegistry())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(DeviceRegistry.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + deleteDeviceRegistryMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.iot.v1.DeviceManager/DeleteDeviceRegistry") + .setHttpMethod("DELETE") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/{name=projects/*/locations/*/registries/*}", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "name", request.getName()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor(request -> null) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Empty.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor< + ListDeviceRegistriesRequest, ListDeviceRegistriesResponse> + listDeviceRegistriesMethodDescriptor = + ApiMethodDescriptor + .newBuilder() + .setFullMethodName("google.cloud.iot.v1.DeviceManager/ListDeviceRegistries") + .setHttpMethod("GET") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/{parent=projects/*/locations/*}/registries", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "parent", request.getParent()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putQueryParam(fields, "pageSize", request.getPageSize()); + serializer.putQueryParam(fields, "pageToken", request.getPageToken()); + return fields; + }) + .setRequestBodyExtractor(request -> null) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(ListDeviceRegistriesResponse.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + createDeviceMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.iot.v1.DeviceManager/CreateDevice") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/{parent=projects/*/locations/*/registries/*}/devices", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "parent", request.getParent()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create().toBody("device", request.getDevice())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Device.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor getDeviceMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.iot.v1.DeviceManager/GetDevice") + .setHttpMethod("GET") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/{name=projects/*/locations/*/registries/*/devices/*}", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "name", request.getName()); + return fields; + }) + .setAdditionalPaths( + "/v1/{name=projects/*/locations/*/registries/*/groups/*/devices/*}") + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putQueryParam(fields, "fieldMask", request.getFieldMask()); + return fields; + }) + .setRequestBodyExtractor(request -> null) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Device.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + updateDeviceMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.iot.v1.DeviceManager/UpdateDevice") + .setHttpMethod("PATCH") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/{device.name=projects/*/locations/*/registries/*/devices/*}", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam( + fields, "device.name", request.getDevice().getName()); + return fields; + }) + .setAdditionalPaths( + "/v1/{device.name=projects/*/locations/*/registries/*/groups/*/devices/*}") + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putQueryParam(fields, "updateMask", request.getUpdateMask()); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create().toBody("device", request.getDevice())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Device.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + deleteDeviceMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.iot.v1.DeviceManager/DeleteDevice") + .setHttpMethod("DELETE") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/{name=projects/*/locations/*/registries/*/devices/*}", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "name", request.getName()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor(request -> null) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Empty.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + listDevicesMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.iot.v1.DeviceManager/ListDevices") + .setHttpMethod("GET") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/{parent=projects/*/locations/*/registries/*}/devices", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "parent", request.getParent()); + return fields; + }) + .setAdditionalPaths( + "/v1/{parent=projects/*/locations/*/registries/*/groups/*}/devices") + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putQueryParam( + fields, "deviceIds", request.getDeviceIdsList()); + serializer.putQueryParam( + fields, "deviceNumIds", request.getDeviceNumIdsList()); + serializer.putQueryParam(fields, "fieldMask", request.getFieldMask()); + serializer.putQueryParam( + fields, "gatewayListOptions", request.getGatewayListOptions()); + serializer.putQueryParam(fields, "pageSize", request.getPageSize()); + serializer.putQueryParam(fields, "pageToken", request.getPageToken()); + return fields; + }) + .setRequestBodyExtractor(request -> null) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(ListDevicesResponse.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + modifyCloudToDeviceConfigMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.iot.v1.DeviceManager/ModifyCloudToDeviceConfig") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/{name=projects/*/locations/*/registries/*/devices/*}:modifyCloudToDeviceConfig", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "name", request.getName()); + return fields; + }) + .setAdditionalPaths( + "/v1/{name=projects/*/locations/*/registries/*/groups/*/devices/*}:modifyCloudToDeviceConfig") + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create() + .toBody("*", request.toBuilder().clearName().build())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(DeviceConfig.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor< + ListDeviceConfigVersionsRequest, ListDeviceConfigVersionsResponse> + listDeviceConfigVersionsMethodDescriptor = + ApiMethodDescriptor + .newBuilder() + .setFullMethodName("google.cloud.iot.v1.DeviceManager/ListDeviceConfigVersions") + .setHttpMethod("GET") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/{name=projects/*/locations/*/registries/*/devices/*}/configVersions", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "name", request.getName()); + return fields; + }) + .setAdditionalPaths( + "/v1/{name=projects/*/locations/*/registries/*/groups/*/devices/*}/configVersions") + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putQueryParam( + fields, "numVersions", request.getNumVersions()); + return fields; + }) + .setRequestBodyExtractor(request -> null) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(ListDeviceConfigVersionsResponse.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + listDeviceStatesMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.iot.v1.DeviceManager/ListDeviceStates") + .setHttpMethod("GET") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/{name=projects/*/locations/*/registries/*/devices/*}/states", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "name", request.getName()); + return fields; + }) + .setAdditionalPaths( + "/v1/{name=projects/*/locations/*/registries/*/groups/*/devices/*}/states") + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putQueryParam(fields, "numStates", request.getNumStates()); + return fields; + }) + .setRequestBodyExtractor(request -> null) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(ListDeviceStatesResponse.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + setIamPolicyMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.iot.v1.DeviceManager/SetIamPolicy") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/{resource=projects/*/locations/*/registries/*}:setIamPolicy", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "resource", request.getResource()); + return fields; + }) + .setAdditionalPaths( + "/v1/{resource=projects/*/locations/*/registries/*/groups/*}:setIamPolicy") + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create() + .toBody("*", request.toBuilder().clearResource().build())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Policy.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + getIamPolicyMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.iot.v1.DeviceManager/GetIamPolicy") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/{resource=projects/*/locations/*/registries/*}:getIamPolicy", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "resource", request.getResource()); + return fields; + }) + .setAdditionalPaths( + "/v1/{resource=projects/*/locations/*/registries/*/groups/*}:getIamPolicy") + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create() + .toBody("*", request.toBuilder().clearResource().build())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Policy.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + testIamPermissionsMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.iot.v1.DeviceManager/TestIamPermissions") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/{resource=projects/*/locations/*/registries/*}:testIamPermissions", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "resource", request.getResource()); + return fields; + }) + .setAdditionalPaths( + "/v1/{resource=projects/*/locations/*/registries/*/groups/*}:testIamPermissions") + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create() + .toBody("*", request.toBuilder().clearResource().build())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(TestIamPermissionsResponse.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + sendCommandToDeviceMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.iot.v1.DeviceManager/SendCommandToDevice") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/{name=projects/*/locations/*/registries/*/devices/*}:sendCommandToDevice", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "name", request.getName()); + return fields; + }) + .setAdditionalPaths( + "/v1/{name=projects/*/locations/*/registries/*/groups/*/devices/*}:sendCommandToDevice") + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create() + .toBody("*", request.toBuilder().clearName().build())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(SendCommandToDeviceResponse.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + bindDeviceToGatewayMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.iot.v1.DeviceManager/BindDeviceToGateway") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/{parent=projects/*/locations/*/registries/*}:bindDeviceToGateway", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "parent", request.getParent()); + return fields; + }) + .setAdditionalPaths( + "/v1/{parent=projects/*/locations/*/registries/*/groups/*}:bindDeviceToGateway") + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create() + .toBody("*", request.toBuilder().clearParent().build())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(BindDeviceToGatewayResponse.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor< + UnbindDeviceFromGatewayRequest, UnbindDeviceFromGatewayResponse> + unbindDeviceFromGatewayMethodDescriptor = + ApiMethodDescriptor + .newBuilder() + .setFullMethodName("google.cloud.iot.v1.DeviceManager/UnbindDeviceFromGateway") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/{parent=projects/*/locations/*/registries/*}:unbindDeviceFromGateway", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "parent", request.getParent()); + return fields; + }) + .setAdditionalPaths( + "/v1/{parent=projects/*/locations/*/registries/*/groups/*}:unbindDeviceFromGateway") + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create() + .toBody("*", request.toBuilder().clearParent().build())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(UnbindDeviceFromGatewayResponse.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private final UnaryCallable + createDeviceRegistryCallable; + private final UnaryCallable getDeviceRegistryCallable; + private final UnaryCallable + updateDeviceRegistryCallable; + private final UnaryCallable deleteDeviceRegistryCallable; + private final UnaryCallable + listDeviceRegistriesCallable; + private final UnaryCallable + listDeviceRegistriesPagedCallable; + private final UnaryCallable createDeviceCallable; + private final UnaryCallable getDeviceCallable; + private final UnaryCallable updateDeviceCallable; + private final UnaryCallable deleteDeviceCallable; + private final UnaryCallable listDevicesCallable; + private final UnaryCallable + listDevicesPagedCallable; + private final UnaryCallable + modifyCloudToDeviceConfigCallable; + private final UnaryCallable + listDeviceConfigVersionsCallable; + private final UnaryCallable + listDeviceStatesCallable; + private final UnaryCallable setIamPolicyCallable; + private final UnaryCallable getIamPolicyCallable; + private final UnaryCallable + testIamPermissionsCallable; + private final UnaryCallable + sendCommandToDeviceCallable; + private final UnaryCallable + bindDeviceToGatewayCallable; + private final UnaryCallable + unbindDeviceFromGatewayCallable; + + private final BackgroundResource backgroundResources; + private final HttpJsonStubCallableFactory callableFactory; + + public static final HttpJsonDeviceManagerStub create(DeviceManagerStubSettings settings) + throws IOException { + return new HttpJsonDeviceManagerStub(settings, ClientContext.create(settings)); + } + + public static final HttpJsonDeviceManagerStub create(ClientContext clientContext) + throws IOException { + return new HttpJsonDeviceManagerStub( + DeviceManagerStubSettings.newHttpJsonBuilder().build(), clientContext); + } + + public static final HttpJsonDeviceManagerStub create( + ClientContext clientContext, HttpJsonStubCallableFactory callableFactory) throws IOException { + return new HttpJsonDeviceManagerStub( + DeviceManagerStubSettings.newHttpJsonBuilder().build(), clientContext, callableFactory); + } + + /** + * Constructs an instance of HttpJsonDeviceManagerStub, using the given settings. This is + * protected so that it is easy to make a subclass, but otherwise, the static factory methods + * should be preferred. + */ + protected HttpJsonDeviceManagerStub( + DeviceManagerStubSettings settings, ClientContext clientContext) throws IOException { + this(settings, clientContext, new HttpJsonDeviceManagerCallableFactory()); + } + + /** + * Constructs an instance of HttpJsonDeviceManagerStub, using the given settings. This is + * protected so that it is easy to make a subclass, but otherwise, the static factory methods + * should be preferred. + */ + protected HttpJsonDeviceManagerStub( + DeviceManagerStubSettings settings, + ClientContext clientContext, + HttpJsonStubCallableFactory callableFactory) + throws IOException { + this.callableFactory = callableFactory; + + HttpJsonCallSettings + createDeviceRegistryTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(createDeviceRegistryMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings + getDeviceRegistryTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(getDeviceRegistryMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings + updateDeviceRegistryTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(updateDeviceRegistryMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings deleteDeviceRegistryTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(deleteDeviceRegistryMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings + listDeviceRegistriesTransportSettings = + HttpJsonCallSettings + .newBuilder() + .setMethodDescriptor(listDeviceRegistriesMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings createDeviceTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(createDeviceMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings getDeviceTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(getDeviceMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings updateDeviceTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(updateDeviceMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings deleteDeviceTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(deleteDeviceMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings listDevicesTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(listDevicesMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings + modifyCloudToDeviceConfigTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(modifyCloudToDeviceConfigMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings + listDeviceConfigVersionsTransportSettings = + HttpJsonCallSettings + .newBuilder() + .setMethodDescriptor(listDeviceConfigVersionsMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings + listDeviceStatesTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(listDeviceStatesMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings setIamPolicyTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(setIamPolicyMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings getIamPolicyTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(getIamPolicyMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings + testIamPermissionsTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(testIamPermissionsMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings + sendCommandToDeviceTransportSettings = + HttpJsonCallSettings + .newBuilder() + .setMethodDescriptor(sendCommandToDeviceMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings + bindDeviceToGatewayTransportSettings = + HttpJsonCallSettings + .newBuilder() + .setMethodDescriptor(bindDeviceToGatewayMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings + unbindDeviceFromGatewayTransportSettings = + HttpJsonCallSettings + .newBuilder() + .setMethodDescriptor(unbindDeviceFromGatewayMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + + this.createDeviceRegistryCallable = + callableFactory.createUnaryCallable( + createDeviceRegistryTransportSettings, + settings.createDeviceRegistrySettings(), + clientContext); + this.getDeviceRegistryCallable = + callableFactory.createUnaryCallable( + getDeviceRegistryTransportSettings, + settings.getDeviceRegistrySettings(), + clientContext); + this.updateDeviceRegistryCallable = + callableFactory.createUnaryCallable( + updateDeviceRegistryTransportSettings, + settings.updateDeviceRegistrySettings(), + clientContext); + this.deleteDeviceRegistryCallable = + callableFactory.createUnaryCallable( + deleteDeviceRegistryTransportSettings, + settings.deleteDeviceRegistrySettings(), + clientContext); + this.listDeviceRegistriesCallable = + callableFactory.createUnaryCallable( + listDeviceRegistriesTransportSettings, + settings.listDeviceRegistriesSettings(), + clientContext); + this.listDeviceRegistriesPagedCallable = + callableFactory.createPagedCallable( + listDeviceRegistriesTransportSettings, + settings.listDeviceRegistriesSettings(), + clientContext); + this.createDeviceCallable = + callableFactory.createUnaryCallable( + createDeviceTransportSettings, settings.createDeviceSettings(), clientContext); + this.getDeviceCallable = + callableFactory.createUnaryCallable( + getDeviceTransportSettings, settings.getDeviceSettings(), clientContext); + this.updateDeviceCallable = + callableFactory.createUnaryCallable( + updateDeviceTransportSettings, settings.updateDeviceSettings(), clientContext); + this.deleteDeviceCallable = + callableFactory.createUnaryCallable( + deleteDeviceTransportSettings, settings.deleteDeviceSettings(), clientContext); + this.listDevicesCallable = + callableFactory.createUnaryCallable( + listDevicesTransportSettings, settings.listDevicesSettings(), clientContext); + this.listDevicesPagedCallable = + callableFactory.createPagedCallable( + listDevicesTransportSettings, settings.listDevicesSettings(), clientContext); + this.modifyCloudToDeviceConfigCallable = + callableFactory.createUnaryCallable( + modifyCloudToDeviceConfigTransportSettings, + settings.modifyCloudToDeviceConfigSettings(), + clientContext); + this.listDeviceConfigVersionsCallable = + callableFactory.createUnaryCallable( + listDeviceConfigVersionsTransportSettings, + settings.listDeviceConfigVersionsSettings(), + clientContext); + this.listDeviceStatesCallable = + callableFactory.createUnaryCallable( + listDeviceStatesTransportSettings, settings.listDeviceStatesSettings(), clientContext); + this.setIamPolicyCallable = + callableFactory.createUnaryCallable( + setIamPolicyTransportSettings, settings.setIamPolicySettings(), clientContext); + this.getIamPolicyCallable = + callableFactory.createUnaryCallable( + getIamPolicyTransportSettings, settings.getIamPolicySettings(), clientContext); + this.testIamPermissionsCallable = + callableFactory.createUnaryCallable( + testIamPermissionsTransportSettings, + settings.testIamPermissionsSettings(), + clientContext); + this.sendCommandToDeviceCallable = + callableFactory.createUnaryCallable( + sendCommandToDeviceTransportSettings, + settings.sendCommandToDeviceSettings(), + clientContext); + this.bindDeviceToGatewayCallable = + callableFactory.createUnaryCallable( + bindDeviceToGatewayTransportSettings, + settings.bindDeviceToGatewaySettings(), + clientContext); + this.unbindDeviceFromGatewayCallable = + callableFactory.createUnaryCallable( + unbindDeviceFromGatewayTransportSettings, + settings.unbindDeviceFromGatewaySettings(), + clientContext); + + this.backgroundResources = + new BackgroundResourceAggregation(clientContext.getBackgroundResources()); + } + + @InternalApi + public static List getMethodDescriptors() { + List methodDescriptors = new ArrayList<>(); + methodDescriptors.add(createDeviceRegistryMethodDescriptor); + methodDescriptors.add(getDeviceRegistryMethodDescriptor); + methodDescriptors.add(updateDeviceRegistryMethodDescriptor); + methodDescriptors.add(deleteDeviceRegistryMethodDescriptor); + methodDescriptors.add(listDeviceRegistriesMethodDescriptor); + methodDescriptors.add(createDeviceMethodDescriptor); + methodDescriptors.add(getDeviceMethodDescriptor); + methodDescriptors.add(updateDeviceMethodDescriptor); + methodDescriptors.add(deleteDeviceMethodDescriptor); + methodDescriptors.add(listDevicesMethodDescriptor); + methodDescriptors.add(modifyCloudToDeviceConfigMethodDescriptor); + methodDescriptors.add(listDeviceConfigVersionsMethodDescriptor); + methodDescriptors.add(listDeviceStatesMethodDescriptor); + methodDescriptors.add(setIamPolicyMethodDescriptor); + methodDescriptors.add(getIamPolicyMethodDescriptor); + methodDescriptors.add(testIamPermissionsMethodDescriptor); + methodDescriptors.add(sendCommandToDeviceMethodDescriptor); + methodDescriptors.add(bindDeviceToGatewayMethodDescriptor); + methodDescriptors.add(unbindDeviceFromGatewayMethodDescriptor); + return methodDescriptors; + } + + @Override + public UnaryCallable createDeviceRegistryCallable() { + return createDeviceRegistryCallable; + } + + @Override + public UnaryCallable getDeviceRegistryCallable() { + return getDeviceRegistryCallable; + } + + @Override + public UnaryCallable updateDeviceRegistryCallable() { + return updateDeviceRegistryCallable; + } + + @Override + public UnaryCallable deleteDeviceRegistryCallable() { + return deleteDeviceRegistryCallable; + } + + @Override + public UnaryCallable + listDeviceRegistriesCallable() { + return listDeviceRegistriesCallable; + } + + @Override + public UnaryCallable + listDeviceRegistriesPagedCallable() { + return listDeviceRegistriesPagedCallable; + } + + @Override + public UnaryCallable createDeviceCallable() { + return createDeviceCallable; + } + + @Override + public UnaryCallable getDeviceCallable() { + return getDeviceCallable; + } + + @Override + public UnaryCallable updateDeviceCallable() { + return updateDeviceCallable; + } + + @Override + public UnaryCallable deleteDeviceCallable() { + return deleteDeviceCallable; + } + + @Override + public UnaryCallable listDevicesCallable() { + return listDevicesCallable; + } + + @Override + public UnaryCallable listDevicesPagedCallable() { + return listDevicesPagedCallable; + } + + @Override + public UnaryCallable + modifyCloudToDeviceConfigCallable() { + return modifyCloudToDeviceConfigCallable; + } + + @Override + public UnaryCallable + listDeviceConfigVersionsCallable() { + return listDeviceConfigVersionsCallable; + } + + @Override + public UnaryCallable + listDeviceStatesCallable() { + return listDeviceStatesCallable; + } + + @Override + public UnaryCallable setIamPolicyCallable() { + return setIamPolicyCallable; + } + + @Override + public UnaryCallable getIamPolicyCallable() { + return getIamPolicyCallable; + } + + @Override + public UnaryCallable + testIamPermissionsCallable() { + return testIamPermissionsCallable; + } + + @Override + public UnaryCallable + sendCommandToDeviceCallable() { + return sendCommandToDeviceCallable; + } + + @Override + public UnaryCallable + bindDeviceToGatewayCallable() { + return bindDeviceToGatewayCallable; + } + + @Override + public UnaryCallable + unbindDeviceFromGatewayCallable() { + return unbindDeviceFromGatewayCallable; + } + + @Override + public final void close() { + try { + backgroundResources.close(); + } catch (RuntimeException e) { + throw e; + } catch (Exception e) { + throw new IllegalStateException("Failed to close resource", e); + } + } + + @Override + public void shutdown() { + backgroundResources.shutdown(); + } + + @Override + public boolean isShutdown() { + return backgroundResources.isShutdown(); + } + + @Override + public boolean isTerminated() { + return backgroundResources.isTerminated(); + } + + @Override + public void shutdownNow() { + backgroundResources.shutdownNow(); + } + + @Override + public boolean awaitTermination(long duration, TimeUnit unit) throws InterruptedException { + return backgroundResources.awaitTermination(duration, unit); + } +} diff --git a/java-iot/google-cloud-iot/src/test/java/com/google/cloud/iot/v1/DeviceManagerClientHttpJsonTest.java b/java-iot/google-cloud-iot/src/test/java/com/google/cloud/iot/v1/DeviceManagerClientHttpJsonTest.java new file mode 100644 index 000000000000..5878f0fb1813 --- /dev/null +++ b/java-iot/google-cloud-iot/src/test/java/com/google/cloud/iot/v1/DeviceManagerClientHttpJsonTest.java @@ -0,0 +1,2008 @@ +/* + * Copyright 2022 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 + * + * https://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. + */ + +package com.google.cloud.iot.v1; + +import static com.google.cloud.iot.v1.DeviceManagerClient.ListDeviceRegistriesPagedResponse; +import static com.google.cloud.iot.v1.DeviceManagerClient.ListDevicesPagedResponse; + +import com.google.api.gax.core.NoCredentialsProvider; +import com.google.api.gax.httpjson.GaxHttpJsonProperties; +import com.google.api.gax.httpjson.testing.MockHttpService; +import com.google.api.gax.rpc.ApiClientHeaderProvider; +import com.google.api.gax.rpc.ApiException; +import com.google.api.gax.rpc.ApiExceptionFactory; +import com.google.api.gax.rpc.InvalidArgumentException; +import com.google.api.gax.rpc.StatusCode; +import com.google.api.gax.rpc.testing.FakeStatusCode; +import com.google.api.resourcenames.ResourceName; +import com.google.cloud.iot.v1.stub.HttpJsonDeviceManagerStub; +import com.google.common.collect.Lists; +import com.google.iam.v1.AuditConfig; +import com.google.iam.v1.Binding; +import com.google.iam.v1.Policy; +import com.google.iam.v1.TestIamPermissionsResponse; +import com.google.protobuf.ByteString; +import com.google.protobuf.Empty; +import com.google.protobuf.FieldMask; +import com.google.protobuf.Timestamp; +import com.google.rpc.Status; +import java.io.IOException; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.HashMap; +import java.util.List; +import javax.annotation.Generated; +import org.junit.After; +import org.junit.AfterClass; +import org.junit.Assert; +import org.junit.Before; +import org.junit.BeforeClass; +import org.junit.Test; + +@Generated("by gapic-generator-java") +public class DeviceManagerClientHttpJsonTest { + private static MockHttpService mockService; + private static DeviceManagerClient client; + + @BeforeClass + public static void startStaticServer() throws IOException { + mockService = + new MockHttpService( + HttpJsonDeviceManagerStub.getMethodDescriptors(), + DeviceManagerSettings.getDefaultEndpoint()); + DeviceManagerSettings settings = + DeviceManagerSettings.newHttpJsonBuilder() + .setTransportChannelProvider( + DeviceManagerSettings.defaultHttpJsonTransportProviderBuilder() + .setHttpTransport(mockService) + .build()) + .setCredentialsProvider(NoCredentialsProvider.create()) + .build(); + client = DeviceManagerClient.create(settings); + } + + @AfterClass + public static void stopServer() { + client.close(); + } + + @Before + public void setUp() {} + + @After + public void tearDown() throws Exception { + mockService.reset(); + } + + @Test + public void createDeviceRegistryTest() throws Exception { + DeviceRegistry expectedResponse = + DeviceRegistry.newBuilder() + .setId("id3355") + .setName(RegistryName.of("[PROJECT]", "[LOCATION]", "[REGISTRY]").toString()) + .addAllEventNotificationConfigs(new ArrayList()) + .setStateNotificationConfig(StateNotificationConfig.newBuilder().build()) + .setMqttConfig(MqttConfig.newBuilder().build()) + .setHttpConfig(HttpConfig.newBuilder().build()) + .setLogLevel(LogLevel.forNumber(0)) + .addAllCredentials(new ArrayList()) + .build(); + mockService.addResponse(expectedResponse); + + LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]"); + DeviceRegistry deviceRegistry = DeviceRegistry.newBuilder().build(); + + DeviceRegistry actualResponse = client.createDeviceRegistry(parent, deviceRegistry); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void createDeviceRegistryExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]"); + DeviceRegistry deviceRegistry = DeviceRegistry.newBuilder().build(); + client.createDeviceRegistry(parent, deviceRegistry); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void createDeviceRegistryTest2() throws Exception { + DeviceRegistry expectedResponse = + DeviceRegistry.newBuilder() + .setId("id3355") + .setName(RegistryName.of("[PROJECT]", "[LOCATION]", "[REGISTRY]").toString()) + .addAllEventNotificationConfigs(new ArrayList()) + .setStateNotificationConfig(StateNotificationConfig.newBuilder().build()) + .setMqttConfig(MqttConfig.newBuilder().build()) + .setHttpConfig(HttpConfig.newBuilder().build()) + .setLogLevel(LogLevel.forNumber(0)) + .addAllCredentials(new ArrayList()) + .build(); + mockService.addResponse(expectedResponse); + + String parent = "projects/project-5833/locations/location-5833"; + DeviceRegistry deviceRegistry = DeviceRegistry.newBuilder().build(); + + DeviceRegistry actualResponse = client.createDeviceRegistry(parent, deviceRegistry); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void createDeviceRegistryExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String parent = "projects/project-5833/locations/location-5833"; + DeviceRegistry deviceRegistry = DeviceRegistry.newBuilder().build(); + client.createDeviceRegistry(parent, deviceRegistry); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void getDeviceRegistryTest() throws Exception { + DeviceRegistry expectedResponse = + DeviceRegistry.newBuilder() + .setId("id3355") + .setName(RegistryName.of("[PROJECT]", "[LOCATION]", "[REGISTRY]").toString()) + .addAllEventNotificationConfigs(new ArrayList()) + .setStateNotificationConfig(StateNotificationConfig.newBuilder().build()) + .setMqttConfig(MqttConfig.newBuilder().build()) + .setHttpConfig(HttpConfig.newBuilder().build()) + .setLogLevel(LogLevel.forNumber(0)) + .addAllCredentials(new ArrayList()) + .build(); + mockService.addResponse(expectedResponse); + + RegistryName name = RegistryName.of("[PROJECT]", "[LOCATION]", "[REGISTRY]"); + + DeviceRegistry actualResponse = client.getDeviceRegistry(name); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void getDeviceRegistryExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + RegistryName name = RegistryName.of("[PROJECT]", "[LOCATION]", "[REGISTRY]"); + client.getDeviceRegistry(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void getDeviceRegistryTest2() throws Exception { + DeviceRegistry expectedResponse = + DeviceRegistry.newBuilder() + .setId("id3355") + .setName(RegistryName.of("[PROJECT]", "[LOCATION]", "[REGISTRY]").toString()) + .addAllEventNotificationConfigs(new ArrayList()) + .setStateNotificationConfig(StateNotificationConfig.newBuilder().build()) + .setMqttConfig(MqttConfig.newBuilder().build()) + .setHttpConfig(HttpConfig.newBuilder().build()) + .setLogLevel(LogLevel.forNumber(0)) + .addAllCredentials(new ArrayList()) + .build(); + mockService.addResponse(expectedResponse); + + String name = "projects/project-5653/locations/location-5653/registries/registrie-5653"; + + DeviceRegistry actualResponse = client.getDeviceRegistry(name); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void getDeviceRegistryExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String name = "projects/project-5653/locations/location-5653/registries/registrie-5653"; + client.getDeviceRegistry(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void updateDeviceRegistryTest() throws Exception { + DeviceRegistry expectedResponse = + DeviceRegistry.newBuilder() + .setId("id3355") + .setName(RegistryName.of("[PROJECT]", "[LOCATION]", "[REGISTRY]").toString()) + .addAllEventNotificationConfigs(new ArrayList()) + .setStateNotificationConfig(StateNotificationConfig.newBuilder().build()) + .setMqttConfig(MqttConfig.newBuilder().build()) + .setHttpConfig(HttpConfig.newBuilder().build()) + .setLogLevel(LogLevel.forNumber(0)) + .addAllCredentials(new ArrayList()) + .build(); + mockService.addResponse(expectedResponse); + + DeviceRegistry deviceRegistry = + DeviceRegistry.newBuilder() + .setId("id3355") + .setName(RegistryName.of("[PROJECT]", "[LOCATION]", "[REGISTRY]").toString()) + .addAllEventNotificationConfigs(new ArrayList()) + .setStateNotificationConfig(StateNotificationConfig.newBuilder().build()) + .setMqttConfig(MqttConfig.newBuilder().build()) + .setHttpConfig(HttpConfig.newBuilder().build()) + .setLogLevel(LogLevel.forNumber(0)) + .addAllCredentials(new ArrayList()) + .build(); + FieldMask updateMask = FieldMask.newBuilder().build(); + + DeviceRegistry actualResponse = client.updateDeviceRegistry(deviceRegistry, updateMask); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void updateDeviceRegistryExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + DeviceRegistry deviceRegistry = + DeviceRegistry.newBuilder() + .setId("id3355") + .setName(RegistryName.of("[PROJECT]", "[LOCATION]", "[REGISTRY]").toString()) + .addAllEventNotificationConfigs(new ArrayList()) + .setStateNotificationConfig(StateNotificationConfig.newBuilder().build()) + .setMqttConfig(MqttConfig.newBuilder().build()) + .setHttpConfig(HttpConfig.newBuilder().build()) + .setLogLevel(LogLevel.forNumber(0)) + .addAllCredentials(new ArrayList()) + .build(); + FieldMask updateMask = FieldMask.newBuilder().build(); + client.updateDeviceRegistry(deviceRegistry, updateMask); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void deleteDeviceRegistryTest() throws Exception { + Empty expectedResponse = Empty.newBuilder().build(); + mockService.addResponse(expectedResponse); + + RegistryName name = RegistryName.of("[PROJECT]", "[LOCATION]", "[REGISTRY]"); + + client.deleteDeviceRegistry(name); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void deleteDeviceRegistryExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + RegistryName name = RegistryName.of("[PROJECT]", "[LOCATION]", "[REGISTRY]"); + client.deleteDeviceRegistry(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void deleteDeviceRegistryTest2() throws Exception { + Empty expectedResponse = Empty.newBuilder().build(); + mockService.addResponse(expectedResponse); + + String name = "projects/project-5653/locations/location-5653/registries/registrie-5653"; + + client.deleteDeviceRegistry(name); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void deleteDeviceRegistryExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String name = "projects/project-5653/locations/location-5653/registries/registrie-5653"; + client.deleteDeviceRegistry(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void listDeviceRegistriesTest() throws Exception { + DeviceRegistry responsesElement = DeviceRegistry.newBuilder().build(); + ListDeviceRegistriesResponse expectedResponse = + ListDeviceRegistriesResponse.newBuilder() + .setNextPageToken("") + .addAllDeviceRegistries(Arrays.asList(responsesElement)) + .build(); + mockService.addResponse(expectedResponse); + + LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]"); + + ListDeviceRegistriesPagedResponse pagedListResponse = client.listDeviceRegistries(parent); + + List resources = Lists.newArrayList(pagedListResponse.iterateAll()); + + Assert.assertEquals(1, resources.size()); + Assert.assertEquals(expectedResponse.getDeviceRegistriesList().get(0), resources.get(0)); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void listDeviceRegistriesExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]"); + client.listDeviceRegistries(parent); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void listDeviceRegistriesTest2() throws Exception { + DeviceRegistry responsesElement = DeviceRegistry.newBuilder().build(); + ListDeviceRegistriesResponse expectedResponse = + ListDeviceRegistriesResponse.newBuilder() + .setNextPageToken("") + .addAllDeviceRegistries(Arrays.asList(responsesElement)) + .build(); + mockService.addResponse(expectedResponse); + + String parent = "projects/project-5833/locations/location-5833"; + + ListDeviceRegistriesPagedResponse pagedListResponse = client.listDeviceRegistries(parent); + + List resources = Lists.newArrayList(pagedListResponse.iterateAll()); + + Assert.assertEquals(1, resources.size()); + Assert.assertEquals(expectedResponse.getDeviceRegistriesList().get(0), resources.get(0)); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void listDeviceRegistriesExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String parent = "projects/project-5833/locations/location-5833"; + client.listDeviceRegistries(parent); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void createDeviceTest() throws Exception { + Device expectedResponse = + Device.newBuilder() + .setId("id3355") + .setName(DeviceName.of("[PROJECT]", "[LOCATION]", "[REGISTRY]", "[DEVICE]").toString()) + .setNumId(-1034366860) + .addAllCredentials(new ArrayList()) + .setLastHeartbeatTime(Timestamp.newBuilder().build()) + .setLastEventTime(Timestamp.newBuilder().build()) + .setLastStateTime(Timestamp.newBuilder().build()) + .setLastConfigAckTime(Timestamp.newBuilder().build()) + .setLastConfigSendTime(Timestamp.newBuilder().build()) + .setBlocked(true) + .setLastErrorTime(Timestamp.newBuilder().build()) + .setLastErrorStatus(Status.newBuilder().build()) + .setConfig(DeviceConfig.newBuilder().build()) + .setState(DeviceState.newBuilder().build()) + .setLogLevel(LogLevel.forNumber(0)) + .putAllMetadata(new HashMap()) + .setGatewayConfig(GatewayConfig.newBuilder().build()) + .build(); + mockService.addResponse(expectedResponse); + + RegistryName parent = RegistryName.of("[PROJECT]", "[LOCATION]", "[REGISTRY]"); + Device device = Device.newBuilder().build(); + + Device actualResponse = client.createDevice(parent, device); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void createDeviceExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + RegistryName parent = RegistryName.of("[PROJECT]", "[LOCATION]", "[REGISTRY]"); + Device device = Device.newBuilder().build(); + client.createDevice(parent, device); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void createDeviceTest2() throws Exception { + Device expectedResponse = + Device.newBuilder() + .setId("id3355") + .setName(DeviceName.of("[PROJECT]", "[LOCATION]", "[REGISTRY]", "[DEVICE]").toString()) + .setNumId(-1034366860) + .addAllCredentials(new ArrayList()) + .setLastHeartbeatTime(Timestamp.newBuilder().build()) + .setLastEventTime(Timestamp.newBuilder().build()) + .setLastStateTime(Timestamp.newBuilder().build()) + .setLastConfigAckTime(Timestamp.newBuilder().build()) + .setLastConfigSendTime(Timestamp.newBuilder().build()) + .setBlocked(true) + .setLastErrorTime(Timestamp.newBuilder().build()) + .setLastErrorStatus(Status.newBuilder().build()) + .setConfig(DeviceConfig.newBuilder().build()) + .setState(DeviceState.newBuilder().build()) + .setLogLevel(LogLevel.forNumber(0)) + .putAllMetadata(new HashMap()) + .setGatewayConfig(GatewayConfig.newBuilder().build()) + .build(); + mockService.addResponse(expectedResponse); + + String parent = "projects/project-6316/locations/location-6316/registries/registrie-6316"; + Device device = Device.newBuilder().build(); + + Device actualResponse = client.createDevice(parent, device); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void createDeviceExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String parent = "projects/project-6316/locations/location-6316/registries/registrie-6316"; + Device device = Device.newBuilder().build(); + client.createDevice(parent, device); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void getDeviceTest() throws Exception { + Device expectedResponse = + Device.newBuilder() + .setId("id3355") + .setName(DeviceName.of("[PROJECT]", "[LOCATION]", "[REGISTRY]", "[DEVICE]").toString()) + .setNumId(-1034366860) + .addAllCredentials(new ArrayList()) + .setLastHeartbeatTime(Timestamp.newBuilder().build()) + .setLastEventTime(Timestamp.newBuilder().build()) + .setLastStateTime(Timestamp.newBuilder().build()) + .setLastConfigAckTime(Timestamp.newBuilder().build()) + .setLastConfigSendTime(Timestamp.newBuilder().build()) + .setBlocked(true) + .setLastErrorTime(Timestamp.newBuilder().build()) + .setLastErrorStatus(Status.newBuilder().build()) + .setConfig(DeviceConfig.newBuilder().build()) + .setState(DeviceState.newBuilder().build()) + .setLogLevel(LogLevel.forNumber(0)) + .putAllMetadata(new HashMap()) + .setGatewayConfig(GatewayConfig.newBuilder().build()) + .build(); + mockService.addResponse(expectedResponse); + + DeviceName name = DeviceName.of("[PROJECT]", "[LOCATION]", "[REGISTRY]", "[DEVICE]"); + + Device actualResponse = client.getDevice(name); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void getDeviceExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + DeviceName name = DeviceName.of("[PROJECT]", "[LOCATION]", "[REGISTRY]", "[DEVICE]"); + client.getDevice(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void getDeviceTest2() throws Exception { + Device expectedResponse = + Device.newBuilder() + .setId("id3355") + .setName(DeviceName.of("[PROJECT]", "[LOCATION]", "[REGISTRY]", "[DEVICE]").toString()) + .setNumId(-1034366860) + .addAllCredentials(new ArrayList()) + .setLastHeartbeatTime(Timestamp.newBuilder().build()) + .setLastEventTime(Timestamp.newBuilder().build()) + .setLastStateTime(Timestamp.newBuilder().build()) + .setLastConfigAckTime(Timestamp.newBuilder().build()) + .setLastConfigSendTime(Timestamp.newBuilder().build()) + .setBlocked(true) + .setLastErrorTime(Timestamp.newBuilder().build()) + .setLastErrorStatus(Status.newBuilder().build()) + .setConfig(DeviceConfig.newBuilder().build()) + .setState(DeviceState.newBuilder().build()) + .setLogLevel(LogLevel.forNumber(0)) + .putAllMetadata(new HashMap()) + .setGatewayConfig(GatewayConfig.newBuilder().build()) + .build(); + mockService.addResponse(expectedResponse); + + String name = + "projects/project-6436/locations/location-6436/registries/registrie-6436/devices/device-6436"; + + Device actualResponse = client.getDevice(name); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void getDeviceExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String name = + "projects/project-6436/locations/location-6436/registries/registrie-6436/devices/device-6436"; + client.getDevice(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void updateDeviceTest() throws Exception { + Device expectedResponse = + Device.newBuilder() + .setId("id3355") + .setName(DeviceName.of("[PROJECT]", "[LOCATION]", "[REGISTRY]", "[DEVICE]").toString()) + .setNumId(-1034366860) + .addAllCredentials(new ArrayList()) + .setLastHeartbeatTime(Timestamp.newBuilder().build()) + .setLastEventTime(Timestamp.newBuilder().build()) + .setLastStateTime(Timestamp.newBuilder().build()) + .setLastConfigAckTime(Timestamp.newBuilder().build()) + .setLastConfigSendTime(Timestamp.newBuilder().build()) + .setBlocked(true) + .setLastErrorTime(Timestamp.newBuilder().build()) + .setLastErrorStatus(Status.newBuilder().build()) + .setConfig(DeviceConfig.newBuilder().build()) + .setState(DeviceState.newBuilder().build()) + .setLogLevel(LogLevel.forNumber(0)) + .putAllMetadata(new HashMap()) + .setGatewayConfig(GatewayConfig.newBuilder().build()) + .build(); + mockService.addResponse(expectedResponse); + + Device device = + Device.newBuilder() + .setId("id3355") + .setName(DeviceName.of("[PROJECT]", "[LOCATION]", "[REGISTRY]", "[DEVICE]").toString()) + .setNumId(-1034366860) + .addAllCredentials(new ArrayList()) + .setLastHeartbeatTime(Timestamp.newBuilder().build()) + .setLastEventTime(Timestamp.newBuilder().build()) + .setLastStateTime(Timestamp.newBuilder().build()) + .setLastConfigAckTime(Timestamp.newBuilder().build()) + .setLastConfigSendTime(Timestamp.newBuilder().build()) + .setBlocked(true) + .setLastErrorTime(Timestamp.newBuilder().build()) + .setLastErrorStatus(Status.newBuilder().build()) + .setConfig(DeviceConfig.newBuilder().build()) + .setState(DeviceState.newBuilder().build()) + .setLogLevel(LogLevel.forNumber(0)) + .putAllMetadata(new HashMap()) + .setGatewayConfig(GatewayConfig.newBuilder().build()) + .build(); + FieldMask updateMask = FieldMask.newBuilder().build(); + + Device actualResponse = client.updateDevice(device, updateMask); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void updateDeviceExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + Device device = + Device.newBuilder() + .setId("id3355") + .setName( + DeviceName.of("[PROJECT]", "[LOCATION]", "[REGISTRY]", "[DEVICE]").toString()) + .setNumId(-1034366860) + .addAllCredentials(new ArrayList()) + .setLastHeartbeatTime(Timestamp.newBuilder().build()) + .setLastEventTime(Timestamp.newBuilder().build()) + .setLastStateTime(Timestamp.newBuilder().build()) + .setLastConfigAckTime(Timestamp.newBuilder().build()) + .setLastConfigSendTime(Timestamp.newBuilder().build()) + .setBlocked(true) + .setLastErrorTime(Timestamp.newBuilder().build()) + .setLastErrorStatus(Status.newBuilder().build()) + .setConfig(DeviceConfig.newBuilder().build()) + .setState(DeviceState.newBuilder().build()) + .setLogLevel(LogLevel.forNumber(0)) + .putAllMetadata(new HashMap()) + .setGatewayConfig(GatewayConfig.newBuilder().build()) + .build(); + FieldMask updateMask = FieldMask.newBuilder().build(); + client.updateDevice(device, updateMask); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void deleteDeviceTest() throws Exception { + Empty expectedResponse = Empty.newBuilder().build(); + mockService.addResponse(expectedResponse); + + DeviceName name = DeviceName.of("[PROJECT]", "[LOCATION]", "[REGISTRY]", "[DEVICE]"); + + client.deleteDevice(name); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void deleteDeviceExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + DeviceName name = DeviceName.of("[PROJECT]", "[LOCATION]", "[REGISTRY]", "[DEVICE]"); + client.deleteDevice(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void deleteDeviceTest2() throws Exception { + Empty expectedResponse = Empty.newBuilder().build(); + mockService.addResponse(expectedResponse); + + String name = + "projects/project-6436/locations/location-6436/registries/registrie-6436/devices/device-6436"; + + client.deleteDevice(name); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void deleteDeviceExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String name = + "projects/project-6436/locations/location-6436/registries/registrie-6436/devices/device-6436"; + client.deleteDevice(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void listDevicesTest() throws Exception { + Device responsesElement = Device.newBuilder().build(); + ListDevicesResponse expectedResponse = + ListDevicesResponse.newBuilder() + .setNextPageToken("") + .addAllDevices(Arrays.asList(responsesElement)) + .build(); + mockService.addResponse(expectedResponse); + + RegistryName parent = RegistryName.of("[PROJECT]", "[LOCATION]", "[REGISTRY]"); + + ListDevicesPagedResponse pagedListResponse = client.listDevices(parent); + + List resources = Lists.newArrayList(pagedListResponse.iterateAll()); + + Assert.assertEquals(1, resources.size()); + Assert.assertEquals(expectedResponse.getDevicesList().get(0), resources.get(0)); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void listDevicesExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + RegistryName parent = RegistryName.of("[PROJECT]", "[LOCATION]", "[REGISTRY]"); + client.listDevices(parent); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void listDevicesTest2() throws Exception { + Device responsesElement = Device.newBuilder().build(); + ListDevicesResponse expectedResponse = + ListDevicesResponse.newBuilder() + .setNextPageToken("") + .addAllDevices(Arrays.asList(responsesElement)) + .build(); + mockService.addResponse(expectedResponse); + + String parent = "projects/project-6316/locations/location-6316/registries/registrie-6316"; + + ListDevicesPagedResponse pagedListResponse = client.listDevices(parent); + + List resources = Lists.newArrayList(pagedListResponse.iterateAll()); + + Assert.assertEquals(1, resources.size()); + Assert.assertEquals(expectedResponse.getDevicesList().get(0), resources.get(0)); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void listDevicesExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String parent = "projects/project-6316/locations/location-6316/registries/registrie-6316"; + client.listDevices(parent); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void modifyCloudToDeviceConfigTest() throws Exception { + DeviceConfig expectedResponse = + DeviceConfig.newBuilder() + .setVersion(351608024) + .setCloudUpdateTime(Timestamp.newBuilder().build()) + .setDeviceAckTime(Timestamp.newBuilder().build()) + .setBinaryData(ByteString.EMPTY) + .build(); + mockService.addResponse(expectedResponse); + + DeviceName name = DeviceName.of("[PROJECT]", "[LOCATION]", "[REGISTRY]", "[DEVICE]"); + ByteString binaryData = ByteString.EMPTY; + + DeviceConfig actualResponse = client.modifyCloudToDeviceConfig(name, binaryData); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void modifyCloudToDeviceConfigExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + DeviceName name = DeviceName.of("[PROJECT]", "[LOCATION]", "[REGISTRY]", "[DEVICE]"); + ByteString binaryData = ByteString.EMPTY; + client.modifyCloudToDeviceConfig(name, binaryData); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void modifyCloudToDeviceConfigTest2() throws Exception { + DeviceConfig expectedResponse = + DeviceConfig.newBuilder() + .setVersion(351608024) + .setCloudUpdateTime(Timestamp.newBuilder().build()) + .setDeviceAckTime(Timestamp.newBuilder().build()) + .setBinaryData(ByteString.EMPTY) + .build(); + mockService.addResponse(expectedResponse); + + String name = + "projects/project-6436/locations/location-6436/registries/registrie-6436/devices/device-6436"; + ByteString binaryData = ByteString.EMPTY; + + DeviceConfig actualResponse = client.modifyCloudToDeviceConfig(name, binaryData); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void modifyCloudToDeviceConfigExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String name = + "projects/project-6436/locations/location-6436/registries/registrie-6436/devices/device-6436"; + ByteString binaryData = ByteString.EMPTY; + client.modifyCloudToDeviceConfig(name, binaryData); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void listDeviceConfigVersionsTest() throws Exception { + ListDeviceConfigVersionsResponse expectedResponse = + ListDeviceConfigVersionsResponse.newBuilder() + .addAllDeviceConfigs(new ArrayList()) + .build(); + mockService.addResponse(expectedResponse); + + DeviceName name = DeviceName.of("[PROJECT]", "[LOCATION]", "[REGISTRY]", "[DEVICE]"); + + ListDeviceConfigVersionsResponse actualResponse = client.listDeviceConfigVersions(name); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void listDeviceConfigVersionsExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + DeviceName name = DeviceName.of("[PROJECT]", "[LOCATION]", "[REGISTRY]", "[DEVICE]"); + client.listDeviceConfigVersions(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void listDeviceConfigVersionsTest2() throws Exception { + ListDeviceConfigVersionsResponse expectedResponse = + ListDeviceConfigVersionsResponse.newBuilder() + .addAllDeviceConfigs(new ArrayList()) + .build(); + mockService.addResponse(expectedResponse); + + String name = + "projects/project-6436/locations/location-6436/registries/registrie-6436/devices/device-6436"; + + ListDeviceConfigVersionsResponse actualResponse = client.listDeviceConfigVersions(name); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void listDeviceConfigVersionsExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String name = + "projects/project-6436/locations/location-6436/registries/registrie-6436/devices/device-6436"; + client.listDeviceConfigVersions(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void listDeviceStatesTest() throws Exception { + ListDeviceStatesResponse expectedResponse = + ListDeviceStatesResponse.newBuilder() + .addAllDeviceStates(new ArrayList()) + .build(); + mockService.addResponse(expectedResponse); + + DeviceName name = DeviceName.of("[PROJECT]", "[LOCATION]", "[REGISTRY]", "[DEVICE]"); + + ListDeviceStatesResponse actualResponse = client.listDeviceStates(name); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void listDeviceStatesExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + DeviceName name = DeviceName.of("[PROJECT]", "[LOCATION]", "[REGISTRY]", "[DEVICE]"); + client.listDeviceStates(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void listDeviceStatesTest2() throws Exception { + ListDeviceStatesResponse expectedResponse = + ListDeviceStatesResponse.newBuilder() + .addAllDeviceStates(new ArrayList()) + .build(); + mockService.addResponse(expectedResponse); + + String name = + "projects/project-6436/locations/location-6436/registries/registrie-6436/devices/device-6436"; + + ListDeviceStatesResponse actualResponse = client.listDeviceStates(name); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void listDeviceStatesExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String name = + "projects/project-6436/locations/location-6436/registries/registrie-6436/devices/device-6436"; + client.listDeviceStates(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void setIamPolicyTest() throws Exception { + Policy expectedResponse = + Policy.newBuilder() + .setVersion(351608024) + .addAllBindings(new ArrayList()) + .addAllAuditConfigs(new ArrayList()) + .setEtag(ByteString.EMPTY) + .build(); + mockService.addResponse(expectedResponse); + + ResourceName resource = RegistryName.of("[PROJECT]", "[LOCATION]", "[REGISTRY]"); + Policy policy = Policy.newBuilder().build(); + + Policy actualResponse = client.setIamPolicy(resource, policy); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void setIamPolicyExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + ResourceName resource = RegistryName.of("[PROJECT]", "[LOCATION]", "[REGISTRY]"); + Policy policy = Policy.newBuilder().build(); + client.setIamPolicy(resource, policy); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void setIamPolicyTest2() throws Exception { + Policy expectedResponse = + Policy.newBuilder() + .setVersion(351608024) + .addAllBindings(new ArrayList()) + .addAllAuditConfigs(new ArrayList()) + .setEtag(ByteString.EMPTY) + .build(); + mockService.addResponse(expectedResponse); + + String resource = "projects/project-6248/locations/location-6248/registries/registrie-6248"; + Policy policy = Policy.newBuilder().build(); + + Policy actualResponse = client.setIamPolicy(resource, policy); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void setIamPolicyExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String resource = "projects/project-6248/locations/location-6248/registries/registrie-6248"; + Policy policy = Policy.newBuilder().build(); + client.setIamPolicy(resource, policy); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void getIamPolicyTest() throws Exception { + Policy expectedResponse = + Policy.newBuilder() + .setVersion(351608024) + .addAllBindings(new ArrayList()) + .addAllAuditConfigs(new ArrayList()) + .setEtag(ByteString.EMPTY) + .build(); + mockService.addResponse(expectedResponse); + + ResourceName resource = RegistryName.of("[PROJECT]", "[LOCATION]", "[REGISTRY]"); + + Policy actualResponse = client.getIamPolicy(resource); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void getIamPolicyExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + ResourceName resource = RegistryName.of("[PROJECT]", "[LOCATION]", "[REGISTRY]"); + client.getIamPolicy(resource); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void getIamPolicyTest2() throws Exception { + Policy expectedResponse = + Policy.newBuilder() + .setVersion(351608024) + .addAllBindings(new ArrayList()) + .addAllAuditConfigs(new ArrayList()) + .setEtag(ByteString.EMPTY) + .build(); + mockService.addResponse(expectedResponse); + + String resource = "projects/project-6248/locations/location-6248/registries/registrie-6248"; + + Policy actualResponse = client.getIamPolicy(resource); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void getIamPolicyExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String resource = "projects/project-6248/locations/location-6248/registries/registrie-6248"; + client.getIamPolicy(resource); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void testIamPermissionsTest() throws Exception { + TestIamPermissionsResponse expectedResponse = + TestIamPermissionsResponse.newBuilder().addAllPermissions(new ArrayList()).build(); + mockService.addResponse(expectedResponse); + + ResourceName resource = RegistryName.of("[PROJECT]", "[LOCATION]", "[REGISTRY]"); + List permissions = new ArrayList<>(); + + TestIamPermissionsResponse actualResponse = client.testIamPermissions(resource, permissions); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void testIamPermissionsExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + ResourceName resource = RegistryName.of("[PROJECT]", "[LOCATION]", "[REGISTRY]"); + List permissions = new ArrayList<>(); + client.testIamPermissions(resource, permissions); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void testIamPermissionsTest2() throws Exception { + TestIamPermissionsResponse expectedResponse = + TestIamPermissionsResponse.newBuilder().addAllPermissions(new ArrayList()).build(); + mockService.addResponse(expectedResponse); + + String resource = "projects/project-6248/locations/location-6248/registries/registrie-6248"; + List permissions = new ArrayList<>(); + + TestIamPermissionsResponse actualResponse = client.testIamPermissions(resource, permissions); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void testIamPermissionsExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String resource = "projects/project-6248/locations/location-6248/registries/registrie-6248"; + List permissions = new ArrayList<>(); + client.testIamPermissions(resource, permissions); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void sendCommandToDeviceTest() throws Exception { + SendCommandToDeviceResponse expectedResponse = SendCommandToDeviceResponse.newBuilder().build(); + mockService.addResponse(expectedResponse); + + DeviceName name = DeviceName.of("[PROJECT]", "[LOCATION]", "[REGISTRY]", "[DEVICE]"); + ByteString binaryData = ByteString.EMPTY; + + SendCommandToDeviceResponse actualResponse = client.sendCommandToDevice(name, binaryData); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void sendCommandToDeviceExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + DeviceName name = DeviceName.of("[PROJECT]", "[LOCATION]", "[REGISTRY]", "[DEVICE]"); + ByteString binaryData = ByteString.EMPTY; + client.sendCommandToDevice(name, binaryData); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void sendCommandToDeviceTest2() throws Exception { + SendCommandToDeviceResponse expectedResponse = SendCommandToDeviceResponse.newBuilder().build(); + mockService.addResponse(expectedResponse); + + String name = + "projects/project-6436/locations/location-6436/registries/registrie-6436/devices/device-6436"; + ByteString binaryData = ByteString.EMPTY; + + SendCommandToDeviceResponse actualResponse = client.sendCommandToDevice(name, binaryData); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void sendCommandToDeviceExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String name = + "projects/project-6436/locations/location-6436/registries/registrie-6436/devices/device-6436"; + ByteString binaryData = ByteString.EMPTY; + client.sendCommandToDevice(name, binaryData); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void sendCommandToDeviceTest3() throws Exception { + SendCommandToDeviceResponse expectedResponse = SendCommandToDeviceResponse.newBuilder().build(); + mockService.addResponse(expectedResponse); + + DeviceName name = DeviceName.of("[PROJECT]", "[LOCATION]", "[REGISTRY]", "[DEVICE]"); + ByteString binaryData = ByteString.EMPTY; + String subfolder = "subfolder153561774"; + + SendCommandToDeviceResponse actualResponse = + client.sendCommandToDevice(name, binaryData, subfolder); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void sendCommandToDeviceExceptionTest3() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + DeviceName name = DeviceName.of("[PROJECT]", "[LOCATION]", "[REGISTRY]", "[DEVICE]"); + ByteString binaryData = ByteString.EMPTY; + String subfolder = "subfolder153561774"; + client.sendCommandToDevice(name, binaryData, subfolder); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void sendCommandToDeviceTest4() throws Exception { + SendCommandToDeviceResponse expectedResponse = SendCommandToDeviceResponse.newBuilder().build(); + mockService.addResponse(expectedResponse); + + String name = + "projects/project-6436/locations/location-6436/registries/registrie-6436/devices/device-6436"; + ByteString binaryData = ByteString.EMPTY; + String subfolder = "subfolder153561774"; + + SendCommandToDeviceResponse actualResponse = + client.sendCommandToDevice(name, binaryData, subfolder); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void sendCommandToDeviceExceptionTest4() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String name = + "projects/project-6436/locations/location-6436/registries/registrie-6436/devices/device-6436"; + ByteString binaryData = ByteString.EMPTY; + String subfolder = "subfolder153561774"; + client.sendCommandToDevice(name, binaryData, subfolder); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void bindDeviceToGatewayTest() throws Exception { + BindDeviceToGatewayResponse expectedResponse = BindDeviceToGatewayResponse.newBuilder().build(); + mockService.addResponse(expectedResponse); + + RegistryName parent = RegistryName.of("[PROJECT]", "[LOCATION]", "[REGISTRY]"); + String gatewayId = "gatewayId-1354641793"; + String deviceId = "deviceId1109191185"; + + BindDeviceToGatewayResponse actualResponse = + client.bindDeviceToGateway(parent, gatewayId, deviceId); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void bindDeviceToGatewayExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + RegistryName parent = RegistryName.of("[PROJECT]", "[LOCATION]", "[REGISTRY]"); + String gatewayId = "gatewayId-1354641793"; + String deviceId = "deviceId1109191185"; + client.bindDeviceToGateway(parent, gatewayId, deviceId); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void bindDeviceToGatewayTest2() throws Exception { + BindDeviceToGatewayResponse expectedResponse = BindDeviceToGatewayResponse.newBuilder().build(); + mockService.addResponse(expectedResponse); + + String parent = "projects/project-6316/locations/location-6316/registries/registrie-6316"; + String gatewayId = "gatewayId-1354641793"; + String deviceId = "deviceId1109191185"; + + BindDeviceToGatewayResponse actualResponse = + client.bindDeviceToGateway(parent, gatewayId, deviceId); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void bindDeviceToGatewayExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String parent = "projects/project-6316/locations/location-6316/registries/registrie-6316"; + String gatewayId = "gatewayId-1354641793"; + String deviceId = "deviceId1109191185"; + client.bindDeviceToGateway(parent, gatewayId, deviceId); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void unbindDeviceFromGatewayTest() throws Exception { + UnbindDeviceFromGatewayResponse expectedResponse = + UnbindDeviceFromGatewayResponse.newBuilder().build(); + mockService.addResponse(expectedResponse); + + RegistryName parent = RegistryName.of("[PROJECT]", "[LOCATION]", "[REGISTRY]"); + String gatewayId = "gatewayId-1354641793"; + String deviceId = "deviceId1109191185"; + + UnbindDeviceFromGatewayResponse actualResponse = + client.unbindDeviceFromGateway(parent, gatewayId, deviceId); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void unbindDeviceFromGatewayExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + RegistryName parent = RegistryName.of("[PROJECT]", "[LOCATION]", "[REGISTRY]"); + String gatewayId = "gatewayId-1354641793"; + String deviceId = "deviceId1109191185"; + client.unbindDeviceFromGateway(parent, gatewayId, deviceId); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void unbindDeviceFromGatewayTest2() throws Exception { + UnbindDeviceFromGatewayResponse expectedResponse = + UnbindDeviceFromGatewayResponse.newBuilder().build(); + mockService.addResponse(expectedResponse); + + String parent = "projects/project-6316/locations/location-6316/registries/registrie-6316"; + String gatewayId = "gatewayId-1354641793"; + String deviceId = "deviceId1109191185"; + + UnbindDeviceFromGatewayResponse actualResponse = + client.unbindDeviceFromGateway(parent, gatewayId, deviceId); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void unbindDeviceFromGatewayExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String parent = "projects/project-6316/locations/location-6316/registries/registrie-6316"; + String gatewayId = "gatewayId-1354641793"; + String deviceId = "deviceId1109191185"; + client.unbindDeviceFromGateway(parent, gatewayId, deviceId); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } +} diff --git a/java-iot/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/binddevicetogateway/AsyncBindDeviceToGateway.java b/java-iot/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/binddevicetogateway/AsyncBindDeviceToGateway.java new file mode 100644 index 000000000000..e51f2e80e0f9 --- /dev/null +++ b/java-iot/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/binddevicetogateway/AsyncBindDeviceToGateway.java @@ -0,0 +1,49 @@ +/* + * Copyright 2022 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 + * + * https://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. + */ + +package com.google.cloud.iot.v1.samples; + +// [START iot_v1_generated_devicemanagerclient_binddevicetogateway_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.iot.v1.BindDeviceToGatewayRequest; +import com.google.cloud.iot.v1.BindDeviceToGatewayResponse; +import com.google.cloud.iot.v1.DeviceManagerClient; +import com.google.cloud.iot.v1.RegistryName; + +public class AsyncBindDeviceToGateway { + + public static void main(String[] args) throws Exception { + asyncBindDeviceToGateway(); + } + + public static void asyncBindDeviceToGateway() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (DeviceManagerClient deviceManagerClient = DeviceManagerClient.create()) { + BindDeviceToGatewayRequest request = + BindDeviceToGatewayRequest.newBuilder() + .setParent(RegistryName.of("[PROJECT]", "[LOCATION]", "[REGISTRY]").toString()) + .setGatewayId("gatewayId-1354641793") + .setDeviceId("deviceId1109191185") + .build(); + ApiFuture future = + deviceManagerClient.bindDeviceToGatewayCallable().futureCall(request); + // Do something. + BindDeviceToGatewayResponse response = future.get(); + } + } +} +// [END iot_v1_generated_devicemanagerclient_binddevicetogateway_async] diff --git a/java-iot/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/binddevicetogateway/SyncBindDeviceToGateway.java b/java-iot/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/binddevicetogateway/SyncBindDeviceToGateway.java new file mode 100644 index 000000000000..179618e0c393 --- /dev/null +++ b/java-iot/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/binddevicetogateway/SyncBindDeviceToGateway.java @@ -0,0 +1,45 @@ +/* + * Copyright 2022 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 + * + * https://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. + */ + +package com.google.cloud.iot.v1.samples; + +// [START iot_v1_generated_devicemanagerclient_binddevicetogateway_sync] +import com.google.cloud.iot.v1.BindDeviceToGatewayRequest; +import com.google.cloud.iot.v1.BindDeviceToGatewayResponse; +import com.google.cloud.iot.v1.DeviceManagerClient; +import com.google.cloud.iot.v1.RegistryName; + +public class SyncBindDeviceToGateway { + + public static void main(String[] args) throws Exception { + syncBindDeviceToGateway(); + } + + public static void syncBindDeviceToGateway() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (DeviceManagerClient deviceManagerClient = DeviceManagerClient.create()) { + BindDeviceToGatewayRequest request = + BindDeviceToGatewayRequest.newBuilder() + .setParent(RegistryName.of("[PROJECT]", "[LOCATION]", "[REGISTRY]").toString()) + .setGatewayId("gatewayId-1354641793") + .setDeviceId("deviceId1109191185") + .build(); + BindDeviceToGatewayResponse response = deviceManagerClient.bindDeviceToGateway(request); + } + } +} +// [END iot_v1_generated_devicemanagerclient_binddevicetogateway_sync] diff --git a/java-iot/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/binddevicetogateway/SyncBindDeviceToGatewayRegistrynameStringString.java b/java-iot/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/binddevicetogateway/SyncBindDeviceToGatewayRegistrynameStringString.java new file mode 100644 index 000000000000..394a07be5119 --- /dev/null +++ b/java-iot/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/binddevicetogateway/SyncBindDeviceToGatewayRegistrynameStringString.java @@ -0,0 +1,42 @@ +/* + * Copyright 2022 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 + * + * https://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. + */ + +package com.google.cloud.iot.v1.samples; + +// [START iot_v1_generated_devicemanagerclient_binddevicetogateway_registrynamestringstring_sync] +import com.google.cloud.iot.v1.BindDeviceToGatewayResponse; +import com.google.cloud.iot.v1.DeviceManagerClient; +import com.google.cloud.iot.v1.RegistryName; + +public class SyncBindDeviceToGatewayRegistrynameStringString { + + public static void main(String[] args) throws Exception { + syncBindDeviceToGatewayRegistrynameStringString(); + } + + public static void syncBindDeviceToGatewayRegistrynameStringString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (DeviceManagerClient deviceManagerClient = DeviceManagerClient.create()) { + RegistryName parent = RegistryName.of("[PROJECT]", "[LOCATION]", "[REGISTRY]"); + String gatewayId = "gatewayId-1354641793"; + String deviceId = "deviceId1109191185"; + BindDeviceToGatewayResponse response = + deviceManagerClient.bindDeviceToGateway(parent, gatewayId, deviceId); + } + } +} +// [END iot_v1_generated_devicemanagerclient_binddevicetogateway_registrynamestringstring_sync] diff --git a/java-iot/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/binddevicetogateway/SyncBindDeviceToGatewayStringStringString.java b/java-iot/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/binddevicetogateway/SyncBindDeviceToGatewayStringStringString.java new file mode 100644 index 000000000000..c6d96eb9c25e --- /dev/null +++ b/java-iot/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/binddevicetogateway/SyncBindDeviceToGatewayStringStringString.java @@ -0,0 +1,42 @@ +/* + * Copyright 2022 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 + * + * https://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. + */ + +package com.google.cloud.iot.v1.samples; + +// [START iot_v1_generated_devicemanagerclient_binddevicetogateway_stringstringstring_sync] +import com.google.cloud.iot.v1.BindDeviceToGatewayResponse; +import com.google.cloud.iot.v1.DeviceManagerClient; +import com.google.cloud.iot.v1.RegistryName; + +public class SyncBindDeviceToGatewayStringStringString { + + public static void main(String[] args) throws Exception { + syncBindDeviceToGatewayStringStringString(); + } + + public static void syncBindDeviceToGatewayStringStringString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (DeviceManagerClient deviceManagerClient = DeviceManagerClient.create()) { + String parent = RegistryName.of("[PROJECT]", "[LOCATION]", "[REGISTRY]").toString(); + String gatewayId = "gatewayId-1354641793"; + String deviceId = "deviceId1109191185"; + BindDeviceToGatewayResponse response = + deviceManagerClient.bindDeviceToGateway(parent, gatewayId, deviceId); + } + } +} +// [END iot_v1_generated_devicemanagerclient_binddevicetogateway_stringstringstring_sync] diff --git a/java-iot/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/create/SyncCreateSetCredentialsProvider.java b/java-iot/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/create/SyncCreateSetCredentialsProvider.java new file mode 100644 index 000000000000..21f3684186df --- /dev/null +++ b/java-iot/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/create/SyncCreateSetCredentialsProvider.java @@ -0,0 +1,41 @@ +/* + * Copyright 2022 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 + * + * https://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. + */ + +package com.google.cloud.iot.v1.samples; + +// [START iot_v1_generated_devicemanagerclient_create_setcredentialsprovider_sync] +import com.google.api.gax.core.FixedCredentialsProvider; +import com.google.cloud.iot.v1.DeviceManagerClient; +import com.google.cloud.iot.v1.DeviceManagerSettings; +import com.google.cloud.iot.v1.myCredentials; + +public class SyncCreateSetCredentialsProvider { + + public static void main(String[] args) throws Exception { + syncCreateSetCredentialsProvider(); + } + + public static void syncCreateSetCredentialsProvider() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + DeviceManagerSettings deviceManagerSettings = + DeviceManagerSettings.newBuilder() + .setCredentialsProvider(FixedCredentialsProvider.create(myCredentials)) + .build(); + DeviceManagerClient deviceManagerClient = DeviceManagerClient.create(deviceManagerSettings); + } +} +// [END iot_v1_generated_devicemanagerclient_create_setcredentialsprovider_sync] diff --git a/java-iot/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/create/SyncCreateSetCredentialsProvider1.java b/java-iot/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/create/SyncCreateSetCredentialsProvider1.java new file mode 100644 index 000000000000..7da39d5a1cbe --- /dev/null +++ b/java-iot/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/create/SyncCreateSetCredentialsProvider1.java @@ -0,0 +1,40 @@ +/* + * Copyright 2022 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 + * + * https://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. + */ + +package com.google.cloud.iot.v1.samples; + +// [START iot_v1_generated_devicemanagerclient_create_setcredentialsprovider1_sync] +import com.google.cloud.iot.v1.DeviceManagerClient; +import com.google.cloud.iot.v1.DeviceManagerSettings; + +public class SyncCreateSetCredentialsProvider1 { + + public static void main(String[] args) throws Exception { + syncCreateSetCredentialsProvider1(); + } + + public static void syncCreateSetCredentialsProvider1() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + DeviceManagerSettings deviceManagerSettings = + DeviceManagerSettings.newBuilder() + .setTransportChannelProvider( + DeviceManagerSettings.defaultHttpJsonTransportProviderBuilder().build()) + .build(); + DeviceManagerClient deviceManagerClient = DeviceManagerClient.create(deviceManagerSettings); + } +} +// [END iot_v1_generated_devicemanagerclient_create_setcredentialsprovider1_sync] diff --git a/java-iot/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/create/SyncCreateSetEndpoint.java b/java-iot/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/create/SyncCreateSetEndpoint.java new file mode 100644 index 000000000000..0901ca65ed55 --- /dev/null +++ b/java-iot/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/create/SyncCreateSetEndpoint.java @@ -0,0 +1,38 @@ +/* + * Copyright 2022 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 + * + * https://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. + */ + +package com.google.cloud.iot.v1.samples; + +// [START iot_v1_generated_devicemanagerclient_create_setendpoint_sync] +import com.google.cloud.iot.v1.DeviceManagerClient; +import com.google.cloud.iot.v1.DeviceManagerSettings; +import com.google.cloud.iot.v1.myEndpoint; + +public class SyncCreateSetEndpoint { + + public static void main(String[] args) throws Exception { + syncCreateSetEndpoint(); + } + + public static void syncCreateSetEndpoint() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + DeviceManagerSettings deviceManagerSettings = + DeviceManagerSettings.newBuilder().setEndpoint(myEndpoint).build(); + DeviceManagerClient deviceManagerClient = DeviceManagerClient.create(deviceManagerSettings); + } +} +// [END iot_v1_generated_devicemanagerclient_create_setendpoint_sync] diff --git a/java-iot/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/createdevice/AsyncCreateDevice.java b/java-iot/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/createdevice/AsyncCreateDevice.java new file mode 100644 index 000000000000..352b065f3702 --- /dev/null +++ b/java-iot/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/createdevice/AsyncCreateDevice.java @@ -0,0 +1,47 @@ +/* + * Copyright 2022 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 + * + * https://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. + */ + +package com.google.cloud.iot.v1.samples; + +// [START iot_v1_generated_devicemanagerclient_createdevice_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.iot.v1.CreateDeviceRequest; +import com.google.cloud.iot.v1.Device; +import com.google.cloud.iot.v1.DeviceManagerClient; +import com.google.cloud.iot.v1.RegistryName; + +public class AsyncCreateDevice { + + public static void main(String[] args) throws Exception { + asyncCreateDevice(); + } + + public static void asyncCreateDevice() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (DeviceManagerClient deviceManagerClient = DeviceManagerClient.create()) { + CreateDeviceRequest request = + CreateDeviceRequest.newBuilder() + .setParent(RegistryName.of("[PROJECT]", "[LOCATION]", "[REGISTRY]").toString()) + .setDevice(Device.newBuilder().build()) + .build(); + ApiFuture future = deviceManagerClient.createDeviceCallable().futureCall(request); + // Do something. + Device response = future.get(); + } + } +} +// [END iot_v1_generated_devicemanagerclient_createdevice_async] diff --git a/java-iot/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/createdevice/SyncCreateDevice.java b/java-iot/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/createdevice/SyncCreateDevice.java new file mode 100644 index 000000000000..a9b26d8689d6 --- /dev/null +++ b/java-iot/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/createdevice/SyncCreateDevice.java @@ -0,0 +1,44 @@ +/* + * Copyright 2022 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 + * + * https://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. + */ + +package com.google.cloud.iot.v1.samples; + +// [START iot_v1_generated_devicemanagerclient_createdevice_sync] +import com.google.cloud.iot.v1.CreateDeviceRequest; +import com.google.cloud.iot.v1.Device; +import com.google.cloud.iot.v1.DeviceManagerClient; +import com.google.cloud.iot.v1.RegistryName; + +public class SyncCreateDevice { + + public static void main(String[] args) throws Exception { + syncCreateDevice(); + } + + public static void syncCreateDevice() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (DeviceManagerClient deviceManagerClient = DeviceManagerClient.create()) { + CreateDeviceRequest request = + CreateDeviceRequest.newBuilder() + .setParent(RegistryName.of("[PROJECT]", "[LOCATION]", "[REGISTRY]").toString()) + .setDevice(Device.newBuilder().build()) + .build(); + Device response = deviceManagerClient.createDevice(request); + } + } +} +// [END iot_v1_generated_devicemanagerclient_createdevice_sync] diff --git a/java-iot/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/createdevice/SyncCreateDeviceRegistrynameDevice.java b/java-iot/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/createdevice/SyncCreateDeviceRegistrynameDevice.java new file mode 100644 index 000000000000..9b7485325246 --- /dev/null +++ b/java-iot/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/createdevice/SyncCreateDeviceRegistrynameDevice.java @@ -0,0 +1,40 @@ +/* + * Copyright 2022 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 + * + * https://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. + */ + +package com.google.cloud.iot.v1.samples; + +// [START iot_v1_generated_devicemanagerclient_createdevice_registrynamedevice_sync] +import com.google.cloud.iot.v1.Device; +import com.google.cloud.iot.v1.DeviceManagerClient; +import com.google.cloud.iot.v1.RegistryName; + +public class SyncCreateDeviceRegistrynameDevice { + + public static void main(String[] args) throws Exception { + syncCreateDeviceRegistrynameDevice(); + } + + public static void syncCreateDeviceRegistrynameDevice() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (DeviceManagerClient deviceManagerClient = DeviceManagerClient.create()) { + RegistryName parent = RegistryName.of("[PROJECT]", "[LOCATION]", "[REGISTRY]"); + Device device = Device.newBuilder().build(); + Device response = deviceManagerClient.createDevice(parent, device); + } + } +} +// [END iot_v1_generated_devicemanagerclient_createdevice_registrynamedevice_sync] diff --git a/java-iot/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/createdevice/SyncCreateDeviceStringDevice.java b/java-iot/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/createdevice/SyncCreateDeviceStringDevice.java new file mode 100644 index 000000000000..faa03a58810c --- /dev/null +++ b/java-iot/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/createdevice/SyncCreateDeviceStringDevice.java @@ -0,0 +1,40 @@ +/* + * Copyright 2022 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 + * + * https://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. + */ + +package com.google.cloud.iot.v1.samples; + +// [START iot_v1_generated_devicemanagerclient_createdevice_stringdevice_sync] +import com.google.cloud.iot.v1.Device; +import com.google.cloud.iot.v1.DeviceManagerClient; +import com.google.cloud.iot.v1.RegistryName; + +public class SyncCreateDeviceStringDevice { + + public static void main(String[] args) throws Exception { + syncCreateDeviceStringDevice(); + } + + public static void syncCreateDeviceStringDevice() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (DeviceManagerClient deviceManagerClient = DeviceManagerClient.create()) { + String parent = RegistryName.of("[PROJECT]", "[LOCATION]", "[REGISTRY]").toString(); + Device device = Device.newBuilder().build(); + Device response = deviceManagerClient.createDevice(parent, device); + } + } +} +// [END iot_v1_generated_devicemanagerclient_createdevice_stringdevice_sync] diff --git a/java-iot/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/createdeviceregistry/AsyncCreateDeviceRegistry.java b/java-iot/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/createdeviceregistry/AsyncCreateDeviceRegistry.java new file mode 100644 index 000000000000..89f18d9f68fd --- /dev/null +++ b/java-iot/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/createdeviceregistry/AsyncCreateDeviceRegistry.java @@ -0,0 +1,48 @@ +/* + * Copyright 2022 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 + * + * https://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. + */ + +package com.google.cloud.iot.v1.samples; + +// [START iot_v1_generated_devicemanagerclient_createdeviceregistry_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.iot.v1.CreateDeviceRegistryRequest; +import com.google.cloud.iot.v1.DeviceManagerClient; +import com.google.cloud.iot.v1.DeviceRegistry; +import com.google.cloud.iot.v1.LocationName; + +public class AsyncCreateDeviceRegistry { + + public static void main(String[] args) throws Exception { + asyncCreateDeviceRegistry(); + } + + public static void asyncCreateDeviceRegistry() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (DeviceManagerClient deviceManagerClient = DeviceManagerClient.create()) { + CreateDeviceRegistryRequest request = + CreateDeviceRegistryRequest.newBuilder() + .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString()) + .setDeviceRegistry(DeviceRegistry.newBuilder().build()) + .build(); + ApiFuture future = + deviceManagerClient.createDeviceRegistryCallable().futureCall(request); + // Do something. + DeviceRegistry response = future.get(); + } + } +} +// [END iot_v1_generated_devicemanagerclient_createdeviceregistry_async] diff --git a/java-iot/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/createdeviceregistry/SyncCreateDeviceRegistry.java b/java-iot/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/createdeviceregistry/SyncCreateDeviceRegistry.java new file mode 100644 index 000000000000..b519382d96b4 --- /dev/null +++ b/java-iot/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/createdeviceregistry/SyncCreateDeviceRegistry.java @@ -0,0 +1,44 @@ +/* + * Copyright 2022 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 + * + * https://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. + */ + +package com.google.cloud.iot.v1.samples; + +// [START iot_v1_generated_devicemanagerclient_createdeviceregistry_sync] +import com.google.cloud.iot.v1.CreateDeviceRegistryRequest; +import com.google.cloud.iot.v1.DeviceManagerClient; +import com.google.cloud.iot.v1.DeviceRegistry; +import com.google.cloud.iot.v1.LocationName; + +public class SyncCreateDeviceRegistry { + + public static void main(String[] args) throws Exception { + syncCreateDeviceRegistry(); + } + + public static void syncCreateDeviceRegistry() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (DeviceManagerClient deviceManagerClient = DeviceManagerClient.create()) { + CreateDeviceRegistryRequest request = + CreateDeviceRegistryRequest.newBuilder() + .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString()) + .setDeviceRegistry(DeviceRegistry.newBuilder().build()) + .build(); + DeviceRegistry response = deviceManagerClient.createDeviceRegistry(request); + } + } +} +// [END iot_v1_generated_devicemanagerclient_createdeviceregistry_sync] diff --git a/java-iot/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/createdeviceregistry/SyncCreateDeviceRegistryLocationnameDeviceregistry.java b/java-iot/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/createdeviceregistry/SyncCreateDeviceRegistryLocationnameDeviceregistry.java new file mode 100644 index 000000000000..57280b3d8e02 --- /dev/null +++ b/java-iot/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/createdeviceregistry/SyncCreateDeviceRegistryLocationnameDeviceregistry.java @@ -0,0 +1,40 @@ +/* + * Copyright 2022 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 + * + * https://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. + */ + +package com.google.cloud.iot.v1.samples; + +// [START iot_v1_generated_devicemanagerclient_createdeviceregistry_locationnamedeviceregistry_sync] +import com.google.cloud.iot.v1.DeviceManagerClient; +import com.google.cloud.iot.v1.DeviceRegistry; +import com.google.cloud.iot.v1.LocationName; + +public class SyncCreateDeviceRegistryLocationnameDeviceregistry { + + public static void main(String[] args) throws Exception { + syncCreateDeviceRegistryLocationnameDeviceregistry(); + } + + public static void syncCreateDeviceRegistryLocationnameDeviceregistry() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (DeviceManagerClient deviceManagerClient = DeviceManagerClient.create()) { + LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]"); + DeviceRegistry deviceRegistry = DeviceRegistry.newBuilder().build(); + DeviceRegistry response = deviceManagerClient.createDeviceRegistry(parent, deviceRegistry); + } + } +} +// [END iot_v1_generated_devicemanagerclient_createdeviceregistry_locationnamedeviceregistry_sync] diff --git a/java-iot/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/createdeviceregistry/SyncCreateDeviceRegistryStringDeviceregistry.java b/java-iot/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/createdeviceregistry/SyncCreateDeviceRegistryStringDeviceregistry.java new file mode 100644 index 000000000000..7e654e509131 --- /dev/null +++ b/java-iot/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/createdeviceregistry/SyncCreateDeviceRegistryStringDeviceregistry.java @@ -0,0 +1,40 @@ +/* + * Copyright 2022 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 + * + * https://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. + */ + +package com.google.cloud.iot.v1.samples; + +// [START iot_v1_generated_devicemanagerclient_createdeviceregistry_stringdeviceregistry_sync] +import com.google.cloud.iot.v1.DeviceManagerClient; +import com.google.cloud.iot.v1.DeviceRegistry; +import com.google.cloud.iot.v1.LocationName; + +public class SyncCreateDeviceRegistryStringDeviceregistry { + + public static void main(String[] args) throws Exception { + syncCreateDeviceRegistryStringDeviceregistry(); + } + + public static void syncCreateDeviceRegistryStringDeviceregistry() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (DeviceManagerClient deviceManagerClient = DeviceManagerClient.create()) { + String parent = LocationName.of("[PROJECT]", "[LOCATION]").toString(); + DeviceRegistry deviceRegistry = DeviceRegistry.newBuilder().build(); + DeviceRegistry response = deviceManagerClient.createDeviceRegistry(parent, deviceRegistry); + } + } +} +// [END iot_v1_generated_devicemanagerclient_createdeviceregistry_stringdeviceregistry_sync] diff --git a/java-iot/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/deletedevice/AsyncDeleteDevice.java b/java-iot/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/deletedevice/AsyncDeleteDevice.java new file mode 100644 index 000000000000..4a0dc80b4322 --- /dev/null +++ b/java-iot/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/deletedevice/AsyncDeleteDevice.java @@ -0,0 +1,47 @@ +/* + * Copyright 2022 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 + * + * https://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. + */ + +package com.google.cloud.iot.v1.samples; + +// [START iot_v1_generated_devicemanagerclient_deletedevice_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.iot.v1.DeleteDeviceRequest; +import com.google.cloud.iot.v1.DeviceManagerClient; +import com.google.cloud.iot.v1.DeviceName; +import com.google.protobuf.Empty; + +public class AsyncDeleteDevice { + + public static void main(String[] args) throws Exception { + asyncDeleteDevice(); + } + + public static void asyncDeleteDevice() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (DeviceManagerClient deviceManagerClient = DeviceManagerClient.create()) { + DeleteDeviceRequest request = + DeleteDeviceRequest.newBuilder() + .setName( + DeviceName.of("[PROJECT]", "[LOCATION]", "[REGISTRY]", "[DEVICE]").toString()) + .build(); + ApiFuture future = deviceManagerClient.deleteDeviceCallable().futureCall(request); + // Do something. + future.get(); + } + } +} +// [END iot_v1_generated_devicemanagerclient_deletedevice_async] diff --git a/java-iot/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/deletedevice/SyncDeleteDevice.java b/java-iot/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/deletedevice/SyncDeleteDevice.java new file mode 100644 index 000000000000..365a35779492 --- /dev/null +++ b/java-iot/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/deletedevice/SyncDeleteDevice.java @@ -0,0 +1,43 @@ +/* + * Copyright 2022 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 + * + * https://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. + */ + +package com.google.cloud.iot.v1.samples; + +// [START iot_v1_generated_devicemanagerclient_deletedevice_sync] +import com.google.cloud.iot.v1.DeleteDeviceRequest; +import com.google.cloud.iot.v1.DeviceManagerClient; +import com.google.cloud.iot.v1.DeviceName; + +public class SyncDeleteDevice { + + public static void main(String[] args) throws Exception { + syncDeleteDevice(); + } + + public static void syncDeleteDevice() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (DeviceManagerClient deviceManagerClient = DeviceManagerClient.create()) { + DeleteDeviceRequest request = + DeleteDeviceRequest.newBuilder() + .setName( + DeviceName.of("[PROJECT]", "[LOCATION]", "[REGISTRY]", "[DEVICE]").toString()) + .build(); + deviceManagerClient.deleteDevice(request); + } + } +} +// [END iot_v1_generated_devicemanagerclient_deletedevice_sync] diff --git a/java-iot/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/deletedevice/SyncDeleteDeviceDevicename.java b/java-iot/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/deletedevice/SyncDeleteDeviceDevicename.java new file mode 100644 index 000000000000..d7ba8d5ea1dc --- /dev/null +++ b/java-iot/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/deletedevice/SyncDeleteDeviceDevicename.java @@ -0,0 +1,38 @@ +/* + * Copyright 2022 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 + * + * https://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. + */ + +package com.google.cloud.iot.v1.samples; + +// [START iot_v1_generated_devicemanagerclient_deletedevice_devicename_sync] +import com.google.cloud.iot.v1.DeviceManagerClient; +import com.google.cloud.iot.v1.DeviceName; + +public class SyncDeleteDeviceDevicename { + + public static void main(String[] args) throws Exception { + syncDeleteDeviceDevicename(); + } + + public static void syncDeleteDeviceDevicename() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (DeviceManagerClient deviceManagerClient = DeviceManagerClient.create()) { + DeviceName name = DeviceName.of("[PROJECT]", "[LOCATION]", "[REGISTRY]", "[DEVICE]"); + deviceManagerClient.deleteDevice(name); + } + } +} +// [END iot_v1_generated_devicemanagerclient_deletedevice_devicename_sync] diff --git a/java-iot/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/deletedevice/SyncDeleteDeviceString.java b/java-iot/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/deletedevice/SyncDeleteDeviceString.java new file mode 100644 index 000000000000..72ffc7136af1 --- /dev/null +++ b/java-iot/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/deletedevice/SyncDeleteDeviceString.java @@ -0,0 +1,38 @@ +/* + * Copyright 2022 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 + * + * https://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. + */ + +package com.google.cloud.iot.v1.samples; + +// [START iot_v1_generated_devicemanagerclient_deletedevice_string_sync] +import com.google.cloud.iot.v1.DeviceManagerClient; +import com.google.cloud.iot.v1.DeviceName; + +public class SyncDeleteDeviceString { + + public static void main(String[] args) throws Exception { + syncDeleteDeviceString(); + } + + public static void syncDeleteDeviceString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (DeviceManagerClient deviceManagerClient = DeviceManagerClient.create()) { + String name = DeviceName.of("[PROJECT]", "[LOCATION]", "[REGISTRY]", "[DEVICE]").toString(); + deviceManagerClient.deleteDevice(name); + } + } +} +// [END iot_v1_generated_devicemanagerclient_deletedevice_string_sync] diff --git a/java-iot/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/deletedeviceregistry/AsyncDeleteDeviceRegistry.java b/java-iot/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/deletedeviceregistry/AsyncDeleteDeviceRegistry.java new file mode 100644 index 000000000000..5fb47ba4d98f --- /dev/null +++ b/java-iot/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/deletedeviceregistry/AsyncDeleteDeviceRegistry.java @@ -0,0 +1,47 @@ +/* + * Copyright 2022 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 + * + * https://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. + */ + +package com.google.cloud.iot.v1.samples; + +// [START iot_v1_generated_devicemanagerclient_deletedeviceregistry_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.iot.v1.DeleteDeviceRegistryRequest; +import com.google.cloud.iot.v1.DeviceManagerClient; +import com.google.cloud.iot.v1.RegistryName; +import com.google.protobuf.Empty; + +public class AsyncDeleteDeviceRegistry { + + public static void main(String[] args) throws Exception { + asyncDeleteDeviceRegistry(); + } + + public static void asyncDeleteDeviceRegistry() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (DeviceManagerClient deviceManagerClient = DeviceManagerClient.create()) { + DeleteDeviceRegistryRequest request = + DeleteDeviceRegistryRequest.newBuilder() + .setName(RegistryName.of("[PROJECT]", "[LOCATION]", "[REGISTRY]").toString()) + .build(); + ApiFuture future = + deviceManagerClient.deleteDeviceRegistryCallable().futureCall(request); + // Do something. + future.get(); + } + } +} +// [END iot_v1_generated_devicemanagerclient_deletedeviceregistry_async] diff --git a/java-iot/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/deletedeviceregistry/SyncDeleteDeviceRegistry.java b/java-iot/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/deletedeviceregistry/SyncDeleteDeviceRegistry.java new file mode 100644 index 000000000000..ea71070f032a --- /dev/null +++ b/java-iot/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/deletedeviceregistry/SyncDeleteDeviceRegistry.java @@ -0,0 +1,42 @@ +/* + * Copyright 2022 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 + * + * https://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. + */ + +package com.google.cloud.iot.v1.samples; + +// [START iot_v1_generated_devicemanagerclient_deletedeviceregistry_sync] +import com.google.cloud.iot.v1.DeleteDeviceRegistryRequest; +import com.google.cloud.iot.v1.DeviceManagerClient; +import com.google.cloud.iot.v1.RegistryName; + +public class SyncDeleteDeviceRegistry { + + public static void main(String[] args) throws Exception { + syncDeleteDeviceRegistry(); + } + + public static void syncDeleteDeviceRegistry() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (DeviceManagerClient deviceManagerClient = DeviceManagerClient.create()) { + DeleteDeviceRegistryRequest request = + DeleteDeviceRegistryRequest.newBuilder() + .setName(RegistryName.of("[PROJECT]", "[LOCATION]", "[REGISTRY]").toString()) + .build(); + deviceManagerClient.deleteDeviceRegistry(request); + } + } +} +// [END iot_v1_generated_devicemanagerclient_deletedeviceregistry_sync] diff --git a/java-iot/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/deletedeviceregistry/SyncDeleteDeviceRegistryRegistryname.java b/java-iot/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/deletedeviceregistry/SyncDeleteDeviceRegistryRegistryname.java new file mode 100644 index 000000000000..fc75e1da814b --- /dev/null +++ b/java-iot/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/deletedeviceregistry/SyncDeleteDeviceRegistryRegistryname.java @@ -0,0 +1,38 @@ +/* + * Copyright 2022 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 + * + * https://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. + */ + +package com.google.cloud.iot.v1.samples; + +// [START iot_v1_generated_devicemanagerclient_deletedeviceregistry_registryname_sync] +import com.google.cloud.iot.v1.DeviceManagerClient; +import com.google.cloud.iot.v1.RegistryName; + +public class SyncDeleteDeviceRegistryRegistryname { + + public static void main(String[] args) throws Exception { + syncDeleteDeviceRegistryRegistryname(); + } + + public static void syncDeleteDeviceRegistryRegistryname() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (DeviceManagerClient deviceManagerClient = DeviceManagerClient.create()) { + RegistryName name = RegistryName.of("[PROJECT]", "[LOCATION]", "[REGISTRY]"); + deviceManagerClient.deleteDeviceRegistry(name); + } + } +} +// [END iot_v1_generated_devicemanagerclient_deletedeviceregistry_registryname_sync] diff --git a/java-iot/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/deletedeviceregistry/SyncDeleteDeviceRegistryString.java b/java-iot/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/deletedeviceregistry/SyncDeleteDeviceRegistryString.java new file mode 100644 index 000000000000..a11b4c2a3e48 --- /dev/null +++ b/java-iot/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/deletedeviceregistry/SyncDeleteDeviceRegistryString.java @@ -0,0 +1,38 @@ +/* + * Copyright 2022 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 + * + * https://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. + */ + +package com.google.cloud.iot.v1.samples; + +// [START iot_v1_generated_devicemanagerclient_deletedeviceregistry_string_sync] +import com.google.cloud.iot.v1.DeviceManagerClient; +import com.google.cloud.iot.v1.RegistryName; + +public class SyncDeleteDeviceRegistryString { + + public static void main(String[] args) throws Exception { + syncDeleteDeviceRegistryString(); + } + + public static void syncDeleteDeviceRegistryString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (DeviceManagerClient deviceManagerClient = DeviceManagerClient.create()) { + String name = RegistryName.of("[PROJECT]", "[LOCATION]", "[REGISTRY]").toString(); + deviceManagerClient.deleteDeviceRegistry(name); + } + } +} +// [END iot_v1_generated_devicemanagerclient_deletedeviceregistry_string_sync] diff --git a/java-iot/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/getdevice/AsyncGetDevice.java b/java-iot/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/getdevice/AsyncGetDevice.java new file mode 100644 index 000000000000..a7bde5c04ba8 --- /dev/null +++ b/java-iot/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/getdevice/AsyncGetDevice.java @@ -0,0 +1,49 @@ +/* + * Copyright 2022 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 + * + * https://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. + */ + +package com.google.cloud.iot.v1.samples; + +// [START iot_v1_generated_devicemanagerclient_getdevice_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.iot.v1.Device; +import com.google.cloud.iot.v1.DeviceManagerClient; +import com.google.cloud.iot.v1.DeviceName; +import com.google.cloud.iot.v1.GetDeviceRequest; +import com.google.protobuf.FieldMask; + +public class AsyncGetDevice { + + public static void main(String[] args) throws Exception { + asyncGetDevice(); + } + + public static void asyncGetDevice() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (DeviceManagerClient deviceManagerClient = DeviceManagerClient.create()) { + GetDeviceRequest request = + GetDeviceRequest.newBuilder() + .setName( + DeviceName.of("[PROJECT]", "[LOCATION]", "[REGISTRY]", "[DEVICE]").toString()) + .setFieldMask(FieldMask.newBuilder().build()) + .build(); + ApiFuture future = deviceManagerClient.getDeviceCallable().futureCall(request); + // Do something. + Device response = future.get(); + } + } +} +// [END iot_v1_generated_devicemanagerclient_getdevice_async] diff --git a/java-iot/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/getdevice/SyncGetDevice.java b/java-iot/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/getdevice/SyncGetDevice.java new file mode 100644 index 000000000000..a8a0c391d747 --- /dev/null +++ b/java-iot/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/getdevice/SyncGetDevice.java @@ -0,0 +1,46 @@ +/* + * Copyright 2022 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 + * + * https://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. + */ + +package com.google.cloud.iot.v1.samples; + +// [START iot_v1_generated_devicemanagerclient_getdevice_sync] +import com.google.cloud.iot.v1.Device; +import com.google.cloud.iot.v1.DeviceManagerClient; +import com.google.cloud.iot.v1.DeviceName; +import com.google.cloud.iot.v1.GetDeviceRequest; +import com.google.protobuf.FieldMask; + +public class SyncGetDevice { + + public static void main(String[] args) throws Exception { + syncGetDevice(); + } + + public static void syncGetDevice() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (DeviceManagerClient deviceManagerClient = DeviceManagerClient.create()) { + GetDeviceRequest request = + GetDeviceRequest.newBuilder() + .setName( + DeviceName.of("[PROJECT]", "[LOCATION]", "[REGISTRY]", "[DEVICE]").toString()) + .setFieldMask(FieldMask.newBuilder().build()) + .build(); + Device response = deviceManagerClient.getDevice(request); + } + } +} +// [END iot_v1_generated_devicemanagerclient_getdevice_sync] diff --git a/java-iot/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/getdevice/SyncGetDeviceDevicename.java b/java-iot/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/getdevice/SyncGetDeviceDevicename.java new file mode 100644 index 000000000000..b914e7c86c4c --- /dev/null +++ b/java-iot/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/getdevice/SyncGetDeviceDevicename.java @@ -0,0 +1,39 @@ +/* + * Copyright 2022 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 + * + * https://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. + */ + +package com.google.cloud.iot.v1.samples; + +// [START iot_v1_generated_devicemanagerclient_getdevice_devicename_sync] +import com.google.cloud.iot.v1.Device; +import com.google.cloud.iot.v1.DeviceManagerClient; +import com.google.cloud.iot.v1.DeviceName; + +public class SyncGetDeviceDevicename { + + public static void main(String[] args) throws Exception { + syncGetDeviceDevicename(); + } + + public static void syncGetDeviceDevicename() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (DeviceManagerClient deviceManagerClient = DeviceManagerClient.create()) { + DeviceName name = DeviceName.of("[PROJECT]", "[LOCATION]", "[REGISTRY]", "[DEVICE]"); + Device response = deviceManagerClient.getDevice(name); + } + } +} +// [END iot_v1_generated_devicemanagerclient_getdevice_devicename_sync] diff --git a/java-iot/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/getdevice/SyncGetDeviceString.java b/java-iot/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/getdevice/SyncGetDeviceString.java new file mode 100644 index 000000000000..158a4682834f --- /dev/null +++ b/java-iot/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/getdevice/SyncGetDeviceString.java @@ -0,0 +1,39 @@ +/* + * Copyright 2022 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 + * + * https://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. + */ + +package com.google.cloud.iot.v1.samples; + +// [START iot_v1_generated_devicemanagerclient_getdevice_string_sync] +import com.google.cloud.iot.v1.Device; +import com.google.cloud.iot.v1.DeviceManagerClient; +import com.google.cloud.iot.v1.DeviceName; + +public class SyncGetDeviceString { + + public static void main(String[] args) throws Exception { + syncGetDeviceString(); + } + + public static void syncGetDeviceString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (DeviceManagerClient deviceManagerClient = DeviceManagerClient.create()) { + String name = DeviceName.of("[PROJECT]", "[LOCATION]", "[REGISTRY]", "[DEVICE]").toString(); + Device response = deviceManagerClient.getDevice(name); + } + } +} +// [END iot_v1_generated_devicemanagerclient_getdevice_string_sync] diff --git a/java-iot/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/getdeviceregistry/AsyncGetDeviceRegistry.java b/java-iot/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/getdeviceregistry/AsyncGetDeviceRegistry.java new file mode 100644 index 000000000000..25b5322c326c --- /dev/null +++ b/java-iot/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/getdeviceregistry/AsyncGetDeviceRegistry.java @@ -0,0 +1,47 @@ +/* + * Copyright 2022 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 + * + * https://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. + */ + +package com.google.cloud.iot.v1.samples; + +// [START iot_v1_generated_devicemanagerclient_getdeviceregistry_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.iot.v1.DeviceManagerClient; +import com.google.cloud.iot.v1.DeviceRegistry; +import com.google.cloud.iot.v1.GetDeviceRegistryRequest; +import com.google.cloud.iot.v1.RegistryName; + +public class AsyncGetDeviceRegistry { + + public static void main(String[] args) throws Exception { + asyncGetDeviceRegistry(); + } + + public static void asyncGetDeviceRegistry() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (DeviceManagerClient deviceManagerClient = DeviceManagerClient.create()) { + GetDeviceRegistryRequest request = + GetDeviceRegistryRequest.newBuilder() + .setName(RegistryName.of("[PROJECT]", "[LOCATION]", "[REGISTRY]").toString()) + .build(); + ApiFuture future = + deviceManagerClient.getDeviceRegistryCallable().futureCall(request); + // Do something. + DeviceRegistry response = future.get(); + } + } +} +// [END iot_v1_generated_devicemanagerclient_getdeviceregistry_async] diff --git a/java-iot/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/getdeviceregistry/SyncGetDeviceRegistry.java b/java-iot/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/getdeviceregistry/SyncGetDeviceRegistry.java new file mode 100644 index 000000000000..07bd505fe27a --- /dev/null +++ b/java-iot/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/getdeviceregistry/SyncGetDeviceRegistry.java @@ -0,0 +1,43 @@ +/* + * Copyright 2022 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 + * + * https://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. + */ + +package com.google.cloud.iot.v1.samples; + +// [START iot_v1_generated_devicemanagerclient_getdeviceregistry_sync] +import com.google.cloud.iot.v1.DeviceManagerClient; +import com.google.cloud.iot.v1.DeviceRegistry; +import com.google.cloud.iot.v1.GetDeviceRegistryRequest; +import com.google.cloud.iot.v1.RegistryName; + +public class SyncGetDeviceRegistry { + + public static void main(String[] args) throws Exception { + syncGetDeviceRegistry(); + } + + public static void syncGetDeviceRegistry() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (DeviceManagerClient deviceManagerClient = DeviceManagerClient.create()) { + GetDeviceRegistryRequest request = + GetDeviceRegistryRequest.newBuilder() + .setName(RegistryName.of("[PROJECT]", "[LOCATION]", "[REGISTRY]").toString()) + .build(); + DeviceRegistry response = deviceManagerClient.getDeviceRegistry(request); + } + } +} +// [END iot_v1_generated_devicemanagerclient_getdeviceregistry_sync] diff --git a/java-iot/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/getdeviceregistry/SyncGetDeviceRegistryRegistryname.java b/java-iot/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/getdeviceregistry/SyncGetDeviceRegistryRegistryname.java new file mode 100644 index 000000000000..236fb79b06b5 --- /dev/null +++ b/java-iot/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/getdeviceregistry/SyncGetDeviceRegistryRegistryname.java @@ -0,0 +1,39 @@ +/* + * Copyright 2022 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 + * + * https://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. + */ + +package com.google.cloud.iot.v1.samples; + +// [START iot_v1_generated_devicemanagerclient_getdeviceregistry_registryname_sync] +import com.google.cloud.iot.v1.DeviceManagerClient; +import com.google.cloud.iot.v1.DeviceRegistry; +import com.google.cloud.iot.v1.RegistryName; + +public class SyncGetDeviceRegistryRegistryname { + + public static void main(String[] args) throws Exception { + syncGetDeviceRegistryRegistryname(); + } + + public static void syncGetDeviceRegistryRegistryname() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (DeviceManagerClient deviceManagerClient = DeviceManagerClient.create()) { + RegistryName name = RegistryName.of("[PROJECT]", "[LOCATION]", "[REGISTRY]"); + DeviceRegistry response = deviceManagerClient.getDeviceRegistry(name); + } + } +} +// [END iot_v1_generated_devicemanagerclient_getdeviceregistry_registryname_sync] diff --git a/java-iot/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/getdeviceregistry/SyncGetDeviceRegistryString.java b/java-iot/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/getdeviceregistry/SyncGetDeviceRegistryString.java new file mode 100644 index 000000000000..c657e4386a4e --- /dev/null +++ b/java-iot/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/getdeviceregistry/SyncGetDeviceRegistryString.java @@ -0,0 +1,39 @@ +/* + * Copyright 2022 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 + * + * https://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. + */ + +package com.google.cloud.iot.v1.samples; + +// [START iot_v1_generated_devicemanagerclient_getdeviceregistry_string_sync] +import com.google.cloud.iot.v1.DeviceManagerClient; +import com.google.cloud.iot.v1.DeviceRegistry; +import com.google.cloud.iot.v1.RegistryName; + +public class SyncGetDeviceRegistryString { + + public static void main(String[] args) throws Exception { + syncGetDeviceRegistryString(); + } + + public static void syncGetDeviceRegistryString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (DeviceManagerClient deviceManagerClient = DeviceManagerClient.create()) { + String name = RegistryName.of("[PROJECT]", "[LOCATION]", "[REGISTRY]").toString(); + DeviceRegistry response = deviceManagerClient.getDeviceRegistry(name); + } + } +} +// [END iot_v1_generated_devicemanagerclient_getdeviceregistry_string_sync] diff --git a/java-iot/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/getiampolicy/AsyncGetIamPolicy.java b/java-iot/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/getiampolicy/AsyncGetIamPolicy.java new file mode 100644 index 000000000000..32eb3622b355 --- /dev/null +++ b/java-iot/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/getiampolicy/AsyncGetIamPolicy.java @@ -0,0 +1,48 @@ +/* + * Copyright 2022 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 + * + * https://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. + */ + +package com.google.cloud.iot.v1.samples; + +// [START iot_v1_generated_devicemanagerclient_getiampolicy_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.iot.v1.DeviceManagerClient; +import com.google.cloud.iot.v1.RegistryName; +import com.google.iam.v1.GetIamPolicyRequest; +import com.google.iam.v1.GetPolicyOptions; +import com.google.iam.v1.Policy; + +public class AsyncGetIamPolicy { + + public static void main(String[] args) throws Exception { + asyncGetIamPolicy(); + } + + public static void asyncGetIamPolicy() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (DeviceManagerClient deviceManagerClient = DeviceManagerClient.create()) { + GetIamPolicyRequest request = + GetIamPolicyRequest.newBuilder() + .setResource(RegistryName.of("[PROJECT]", "[LOCATION]", "[REGISTRY]").toString()) + .setOptions(GetPolicyOptions.newBuilder().build()) + .build(); + ApiFuture future = deviceManagerClient.getIamPolicyCallable().futureCall(request); + // Do something. + Policy response = future.get(); + } + } +} +// [END iot_v1_generated_devicemanagerclient_getiampolicy_async] diff --git a/java-iot/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/getiampolicy/SyncGetIamPolicy.java b/java-iot/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/getiampolicy/SyncGetIamPolicy.java new file mode 100644 index 000000000000..54e1d4593898 --- /dev/null +++ b/java-iot/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/getiampolicy/SyncGetIamPolicy.java @@ -0,0 +1,45 @@ +/* + * Copyright 2022 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 + * + * https://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. + */ + +package com.google.cloud.iot.v1.samples; + +// [START iot_v1_generated_devicemanagerclient_getiampolicy_sync] +import com.google.cloud.iot.v1.DeviceManagerClient; +import com.google.cloud.iot.v1.RegistryName; +import com.google.iam.v1.GetIamPolicyRequest; +import com.google.iam.v1.GetPolicyOptions; +import com.google.iam.v1.Policy; + +public class SyncGetIamPolicy { + + public static void main(String[] args) throws Exception { + syncGetIamPolicy(); + } + + public static void syncGetIamPolicy() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (DeviceManagerClient deviceManagerClient = DeviceManagerClient.create()) { + GetIamPolicyRequest request = + GetIamPolicyRequest.newBuilder() + .setResource(RegistryName.of("[PROJECT]", "[LOCATION]", "[REGISTRY]").toString()) + .setOptions(GetPolicyOptions.newBuilder().build()) + .build(); + Policy response = deviceManagerClient.getIamPolicy(request); + } + } +} +// [END iot_v1_generated_devicemanagerclient_getiampolicy_sync] diff --git a/java-iot/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/getiampolicy/SyncGetIamPolicyResourcename.java b/java-iot/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/getiampolicy/SyncGetIamPolicyResourcename.java new file mode 100644 index 000000000000..c3c92d471b27 --- /dev/null +++ b/java-iot/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/getiampolicy/SyncGetIamPolicyResourcename.java @@ -0,0 +1,40 @@ +/* + * Copyright 2022 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 + * + * https://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. + */ + +package com.google.cloud.iot.v1.samples; + +// [START iot_v1_generated_devicemanagerclient_getiampolicy_resourcename_sync] +import com.google.api.resourcenames.ResourceName; +import com.google.cloud.iot.v1.DeviceManagerClient; +import com.google.cloud.iot.v1.RegistryName; +import com.google.iam.v1.Policy; + +public class SyncGetIamPolicyResourcename { + + public static void main(String[] args) throws Exception { + syncGetIamPolicyResourcename(); + } + + public static void syncGetIamPolicyResourcename() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (DeviceManagerClient deviceManagerClient = DeviceManagerClient.create()) { + ResourceName resource = RegistryName.of("[PROJECT]", "[LOCATION]", "[REGISTRY]"); + Policy response = deviceManagerClient.getIamPolicy(resource); + } + } +} +// [END iot_v1_generated_devicemanagerclient_getiampolicy_resourcename_sync] diff --git a/java-iot/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/getiampolicy/SyncGetIamPolicyString.java b/java-iot/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/getiampolicy/SyncGetIamPolicyString.java new file mode 100644 index 000000000000..795e8bd83063 --- /dev/null +++ b/java-iot/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/getiampolicy/SyncGetIamPolicyString.java @@ -0,0 +1,40 @@ +/* + * Copyright 2022 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 + * + * https://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. + */ + +package com.google.cloud.iot.v1.samples; + +// [START iot_v1_generated_devicemanagerclient_getiampolicy_string_sync] +import com.google.cloud.iot.v1.DeviceManagerClient; +import com.google.cloud.iot.v1.DeviceName; +import com.google.iam.v1.Policy; + +public class SyncGetIamPolicyString { + + public static void main(String[] args) throws Exception { + syncGetIamPolicyString(); + } + + public static void syncGetIamPolicyString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (DeviceManagerClient deviceManagerClient = DeviceManagerClient.create()) { + String resource = + DeviceName.of("[PROJECT]", "[LOCATION]", "[REGISTRY]", "[DEVICE]").toString(); + Policy response = deviceManagerClient.getIamPolicy(resource); + } + } +} +// [END iot_v1_generated_devicemanagerclient_getiampolicy_string_sync] diff --git a/java-iot/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/listdeviceconfigversions/AsyncListDeviceConfigVersions.java b/java-iot/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/listdeviceconfigversions/AsyncListDeviceConfigVersions.java new file mode 100644 index 000000000000..0d75d876ce81 --- /dev/null +++ b/java-iot/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/listdeviceconfigversions/AsyncListDeviceConfigVersions.java @@ -0,0 +1,49 @@ +/* + * Copyright 2022 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 + * + * https://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. + */ + +package com.google.cloud.iot.v1.samples; + +// [START iot_v1_generated_devicemanagerclient_listdeviceconfigversions_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.iot.v1.DeviceManagerClient; +import com.google.cloud.iot.v1.DeviceName; +import com.google.cloud.iot.v1.ListDeviceConfigVersionsRequest; +import com.google.cloud.iot.v1.ListDeviceConfigVersionsResponse; + +public class AsyncListDeviceConfigVersions { + + public static void main(String[] args) throws Exception { + asyncListDeviceConfigVersions(); + } + + public static void asyncListDeviceConfigVersions() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (DeviceManagerClient deviceManagerClient = DeviceManagerClient.create()) { + ListDeviceConfigVersionsRequest request = + ListDeviceConfigVersionsRequest.newBuilder() + .setName( + DeviceName.of("[PROJECT]", "[LOCATION]", "[REGISTRY]", "[DEVICE]").toString()) + .setNumVersions(-315385036) + .build(); + ApiFuture future = + deviceManagerClient.listDeviceConfigVersionsCallable().futureCall(request); + // Do something. + ListDeviceConfigVersionsResponse response = future.get(); + } + } +} +// [END iot_v1_generated_devicemanagerclient_listdeviceconfigversions_async] diff --git a/java-iot/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/listdeviceconfigversions/SyncListDeviceConfigVersions.java b/java-iot/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/listdeviceconfigversions/SyncListDeviceConfigVersions.java new file mode 100644 index 000000000000..558b23a474bc --- /dev/null +++ b/java-iot/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/listdeviceconfigversions/SyncListDeviceConfigVersions.java @@ -0,0 +1,46 @@ +/* + * Copyright 2022 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 + * + * https://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. + */ + +package com.google.cloud.iot.v1.samples; + +// [START iot_v1_generated_devicemanagerclient_listdeviceconfigversions_sync] +import com.google.cloud.iot.v1.DeviceManagerClient; +import com.google.cloud.iot.v1.DeviceName; +import com.google.cloud.iot.v1.ListDeviceConfigVersionsRequest; +import com.google.cloud.iot.v1.ListDeviceConfigVersionsResponse; + +public class SyncListDeviceConfigVersions { + + public static void main(String[] args) throws Exception { + syncListDeviceConfigVersions(); + } + + public static void syncListDeviceConfigVersions() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (DeviceManagerClient deviceManagerClient = DeviceManagerClient.create()) { + ListDeviceConfigVersionsRequest request = + ListDeviceConfigVersionsRequest.newBuilder() + .setName( + DeviceName.of("[PROJECT]", "[LOCATION]", "[REGISTRY]", "[DEVICE]").toString()) + .setNumVersions(-315385036) + .build(); + ListDeviceConfigVersionsResponse response = + deviceManagerClient.listDeviceConfigVersions(request); + } + } +} +// [END iot_v1_generated_devicemanagerclient_listdeviceconfigversions_sync] diff --git a/java-iot/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/listdeviceconfigversions/SyncListDeviceConfigVersionsDevicename.java b/java-iot/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/listdeviceconfigversions/SyncListDeviceConfigVersionsDevicename.java new file mode 100644 index 000000000000..260dd90300d2 --- /dev/null +++ b/java-iot/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/listdeviceconfigversions/SyncListDeviceConfigVersionsDevicename.java @@ -0,0 +1,40 @@ +/* + * Copyright 2022 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 + * + * https://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. + */ + +package com.google.cloud.iot.v1.samples; + +// [START iot_v1_generated_devicemanagerclient_listdeviceconfigversions_devicename_sync] +import com.google.cloud.iot.v1.DeviceManagerClient; +import com.google.cloud.iot.v1.DeviceName; +import com.google.cloud.iot.v1.ListDeviceConfigVersionsResponse; + +public class SyncListDeviceConfigVersionsDevicename { + + public static void main(String[] args) throws Exception { + syncListDeviceConfigVersionsDevicename(); + } + + public static void syncListDeviceConfigVersionsDevicename() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (DeviceManagerClient deviceManagerClient = DeviceManagerClient.create()) { + DeviceName name = DeviceName.of("[PROJECT]", "[LOCATION]", "[REGISTRY]", "[DEVICE]"); + ListDeviceConfigVersionsResponse response = + deviceManagerClient.listDeviceConfigVersions(name); + } + } +} +// [END iot_v1_generated_devicemanagerclient_listdeviceconfigversions_devicename_sync] diff --git a/java-iot/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/listdeviceconfigversions/SyncListDeviceConfigVersionsString.java b/java-iot/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/listdeviceconfigversions/SyncListDeviceConfigVersionsString.java new file mode 100644 index 000000000000..f4e9bec3081d --- /dev/null +++ b/java-iot/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/listdeviceconfigversions/SyncListDeviceConfigVersionsString.java @@ -0,0 +1,40 @@ +/* + * Copyright 2022 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 + * + * https://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. + */ + +package com.google.cloud.iot.v1.samples; + +// [START iot_v1_generated_devicemanagerclient_listdeviceconfigversions_string_sync] +import com.google.cloud.iot.v1.DeviceManagerClient; +import com.google.cloud.iot.v1.DeviceName; +import com.google.cloud.iot.v1.ListDeviceConfigVersionsResponse; + +public class SyncListDeviceConfigVersionsString { + + public static void main(String[] args) throws Exception { + syncListDeviceConfigVersionsString(); + } + + public static void syncListDeviceConfigVersionsString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (DeviceManagerClient deviceManagerClient = DeviceManagerClient.create()) { + String name = DeviceName.of("[PROJECT]", "[LOCATION]", "[REGISTRY]", "[DEVICE]").toString(); + ListDeviceConfigVersionsResponse response = + deviceManagerClient.listDeviceConfigVersions(name); + } + } +} +// [END iot_v1_generated_devicemanagerclient_listdeviceconfigversions_string_sync] diff --git a/java-iot/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/listdeviceregistries/AsyncListDeviceRegistries.java b/java-iot/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/listdeviceregistries/AsyncListDeviceRegistries.java new file mode 100644 index 000000000000..d24edbe819ff --- /dev/null +++ b/java-iot/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/listdeviceregistries/AsyncListDeviceRegistries.java @@ -0,0 +1,51 @@ +/* + * Copyright 2022 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 + * + * https://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. + */ + +package com.google.cloud.iot.v1.samples; + +// [START iot_v1_generated_devicemanagerclient_listdeviceregistries_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.iot.v1.DeviceManagerClient; +import com.google.cloud.iot.v1.DeviceRegistry; +import com.google.cloud.iot.v1.ListDeviceRegistriesRequest; +import com.google.cloud.iot.v1.LocationName; + +public class AsyncListDeviceRegistries { + + public static void main(String[] args) throws Exception { + asyncListDeviceRegistries(); + } + + public static void asyncListDeviceRegistries() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (DeviceManagerClient deviceManagerClient = DeviceManagerClient.create()) { + ListDeviceRegistriesRequest request = + ListDeviceRegistriesRequest.newBuilder() + .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString()) + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .build(); + ApiFuture future = + deviceManagerClient.listDeviceRegistriesPagedCallable().futureCall(request); + // Do something. + for (DeviceRegistry element : future.get().iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END iot_v1_generated_devicemanagerclient_listdeviceregistries_async] diff --git a/java-iot/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/listdeviceregistries/AsyncListDeviceRegistriesPaged.java b/java-iot/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/listdeviceregistries/AsyncListDeviceRegistriesPaged.java new file mode 100644 index 000000000000..67fb8cf9c3cd --- /dev/null +++ b/java-iot/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/listdeviceregistries/AsyncListDeviceRegistriesPaged.java @@ -0,0 +1,59 @@ +/* + * Copyright 2022 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 + * + * https://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. + */ + +package com.google.cloud.iot.v1.samples; + +// [START iot_v1_generated_devicemanagerclient_listdeviceregistries_paged_async] +import com.google.cloud.iot.v1.DeviceManagerClient; +import com.google.cloud.iot.v1.DeviceRegistry; +import com.google.cloud.iot.v1.ListDeviceRegistriesRequest; +import com.google.cloud.iot.v1.ListDeviceRegistriesResponse; +import com.google.cloud.iot.v1.LocationName; +import com.google.common.base.Strings; + +public class AsyncListDeviceRegistriesPaged { + + public static void main(String[] args) throws Exception { + asyncListDeviceRegistriesPaged(); + } + + public static void asyncListDeviceRegistriesPaged() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (DeviceManagerClient deviceManagerClient = DeviceManagerClient.create()) { + ListDeviceRegistriesRequest request = + ListDeviceRegistriesRequest.newBuilder() + .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString()) + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .build(); + while (true) { + ListDeviceRegistriesResponse response = + deviceManagerClient.listDeviceRegistriesCallable().call(request); + for (DeviceRegistry element : response.getDeviceRegistriesList()) { + // doThingsWith(element); + } + String nextPageToken = response.getNextPageToken(); + if (!Strings.isNullOrEmpty(nextPageToken)) { + request = request.toBuilder().setPageToken(nextPageToken).build(); + } else { + break; + } + } + } + } +} +// [END iot_v1_generated_devicemanagerclient_listdeviceregistries_paged_async] diff --git a/java-iot/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/listdeviceregistries/SyncListDeviceRegistries.java b/java-iot/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/listdeviceregistries/SyncListDeviceRegistries.java new file mode 100644 index 000000000000..bd896f4c0dca --- /dev/null +++ b/java-iot/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/listdeviceregistries/SyncListDeviceRegistries.java @@ -0,0 +1,48 @@ +/* + * Copyright 2022 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 + * + * https://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. + */ + +package com.google.cloud.iot.v1.samples; + +// [START iot_v1_generated_devicemanagerclient_listdeviceregistries_sync] +import com.google.cloud.iot.v1.DeviceManagerClient; +import com.google.cloud.iot.v1.DeviceRegistry; +import com.google.cloud.iot.v1.ListDeviceRegistriesRequest; +import com.google.cloud.iot.v1.LocationName; + +public class SyncListDeviceRegistries { + + public static void main(String[] args) throws Exception { + syncListDeviceRegistries(); + } + + public static void syncListDeviceRegistries() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (DeviceManagerClient deviceManagerClient = DeviceManagerClient.create()) { + ListDeviceRegistriesRequest request = + ListDeviceRegistriesRequest.newBuilder() + .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString()) + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .build(); + for (DeviceRegistry element : + deviceManagerClient.listDeviceRegistries(request).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END iot_v1_generated_devicemanagerclient_listdeviceregistries_sync] diff --git a/java-iot/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/listdeviceregistries/SyncListDeviceRegistriesLocationname.java b/java-iot/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/listdeviceregistries/SyncListDeviceRegistriesLocationname.java new file mode 100644 index 000000000000..d022d994a92e --- /dev/null +++ b/java-iot/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/listdeviceregistries/SyncListDeviceRegistriesLocationname.java @@ -0,0 +1,41 @@ +/* + * Copyright 2022 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 + * + * https://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. + */ + +package com.google.cloud.iot.v1.samples; + +// [START iot_v1_generated_devicemanagerclient_listdeviceregistries_locationname_sync] +import com.google.cloud.iot.v1.DeviceManagerClient; +import com.google.cloud.iot.v1.DeviceRegistry; +import com.google.cloud.iot.v1.LocationName; + +public class SyncListDeviceRegistriesLocationname { + + public static void main(String[] args) throws Exception { + syncListDeviceRegistriesLocationname(); + } + + public static void syncListDeviceRegistriesLocationname() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (DeviceManagerClient deviceManagerClient = DeviceManagerClient.create()) { + LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]"); + for (DeviceRegistry element : deviceManagerClient.listDeviceRegistries(parent).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END iot_v1_generated_devicemanagerclient_listdeviceregistries_locationname_sync] diff --git a/java-iot/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/listdeviceregistries/SyncListDeviceRegistriesString.java b/java-iot/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/listdeviceregistries/SyncListDeviceRegistriesString.java new file mode 100644 index 000000000000..3ea5d4b0024c --- /dev/null +++ b/java-iot/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/listdeviceregistries/SyncListDeviceRegistriesString.java @@ -0,0 +1,41 @@ +/* + * Copyright 2022 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 + * + * https://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. + */ + +package com.google.cloud.iot.v1.samples; + +// [START iot_v1_generated_devicemanagerclient_listdeviceregistries_string_sync] +import com.google.cloud.iot.v1.DeviceManagerClient; +import com.google.cloud.iot.v1.DeviceRegistry; +import com.google.cloud.iot.v1.LocationName; + +public class SyncListDeviceRegistriesString { + + public static void main(String[] args) throws Exception { + syncListDeviceRegistriesString(); + } + + public static void syncListDeviceRegistriesString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (DeviceManagerClient deviceManagerClient = DeviceManagerClient.create()) { + String parent = LocationName.of("[PROJECT]", "[LOCATION]").toString(); + for (DeviceRegistry element : deviceManagerClient.listDeviceRegistries(parent).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END iot_v1_generated_devicemanagerclient_listdeviceregistries_string_sync] diff --git a/java-iot/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/listdevices/AsyncListDevices.java b/java-iot/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/listdevices/AsyncListDevices.java new file mode 100644 index 000000000000..33eb2f6d19e0 --- /dev/null +++ b/java-iot/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/listdevices/AsyncListDevices.java @@ -0,0 +1,57 @@ +/* + * Copyright 2022 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 + * + * https://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. + */ + +package com.google.cloud.iot.v1.samples; + +// [START iot_v1_generated_devicemanagerclient_listdevices_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.iot.v1.Device; +import com.google.cloud.iot.v1.DeviceManagerClient; +import com.google.cloud.iot.v1.GatewayListOptions; +import com.google.cloud.iot.v1.ListDevicesRequest; +import com.google.cloud.iot.v1.RegistryName; +import com.google.protobuf.FieldMask; +import java.util.ArrayList; + +public class AsyncListDevices { + + public static void main(String[] args) throws Exception { + asyncListDevices(); + } + + public static void asyncListDevices() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (DeviceManagerClient deviceManagerClient = DeviceManagerClient.create()) { + ListDevicesRequest request = + ListDevicesRequest.newBuilder() + .setParent(RegistryName.of("[PROJECT]", "[LOCATION]", "[REGISTRY]").toString()) + .addAllDeviceNumIds(new ArrayList()) + .addAllDeviceIds(new ArrayList()) + .setFieldMask(FieldMask.newBuilder().build()) + .setGatewayListOptions(GatewayListOptions.newBuilder().build()) + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .build(); + ApiFuture future = deviceManagerClient.listDevicesPagedCallable().futureCall(request); + // Do something. + for (Device element : future.get().iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END iot_v1_generated_devicemanagerclient_listdevices_async] diff --git a/java-iot/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/listdevices/AsyncListDevicesPaged.java b/java-iot/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/listdevices/AsyncListDevicesPaged.java new file mode 100644 index 000000000000..86f8f01b9c8b --- /dev/null +++ b/java-iot/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/listdevices/AsyncListDevicesPaged.java @@ -0,0 +1,65 @@ +/* + * Copyright 2022 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 + * + * https://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. + */ + +package com.google.cloud.iot.v1.samples; + +// [START iot_v1_generated_devicemanagerclient_listdevices_paged_async] +import com.google.cloud.iot.v1.Device; +import com.google.cloud.iot.v1.DeviceManagerClient; +import com.google.cloud.iot.v1.GatewayListOptions; +import com.google.cloud.iot.v1.ListDevicesRequest; +import com.google.cloud.iot.v1.ListDevicesResponse; +import com.google.cloud.iot.v1.RegistryName; +import com.google.common.base.Strings; +import com.google.protobuf.FieldMask; +import java.util.ArrayList; + +public class AsyncListDevicesPaged { + + public static void main(String[] args) throws Exception { + asyncListDevicesPaged(); + } + + public static void asyncListDevicesPaged() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (DeviceManagerClient deviceManagerClient = DeviceManagerClient.create()) { + ListDevicesRequest request = + ListDevicesRequest.newBuilder() + .setParent(RegistryName.of("[PROJECT]", "[LOCATION]", "[REGISTRY]").toString()) + .addAllDeviceNumIds(new ArrayList()) + .addAllDeviceIds(new ArrayList()) + .setFieldMask(FieldMask.newBuilder().build()) + .setGatewayListOptions(GatewayListOptions.newBuilder().build()) + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .build(); + while (true) { + ListDevicesResponse response = deviceManagerClient.listDevicesCallable().call(request); + for (Device element : response.getDevicesList()) { + // doThingsWith(element); + } + String nextPageToken = response.getNextPageToken(); + if (!Strings.isNullOrEmpty(nextPageToken)) { + request = request.toBuilder().setPageToken(nextPageToken).build(); + } else { + break; + } + } + } + } +} +// [END iot_v1_generated_devicemanagerclient_listdevices_paged_async] diff --git a/java-iot/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/listdevices/SyncListDevices.java b/java-iot/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/listdevices/SyncListDevices.java new file mode 100644 index 000000000000..61f60c4930d0 --- /dev/null +++ b/java-iot/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/listdevices/SyncListDevices.java @@ -0,0 +1,54 @@ +/* + * Copyright 2022 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 + * + * https://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. + */ + +package com.google.cloud.iot.v1.samples; + +// [START iot_v1_generated_devicemanagerclient_listdevices_sync] +import com.google.cloud.iot.v1.Device; +import com.google.cloud.iot.v1.DeviceManagerClient; +import com.google.cloud.iot.v1.GatewayListOptions; +import com.google.cloud.iot.v1.ListDevicesRequest; +import com.google.cloud.iot.v1.RegistryName; +import com.google.protobuf.FieldMask; +import java.util.ArrayList; + +public class SyncListDevices { + + public static void main(String[] args) throws Exception { + syncListDevices(); + } + + public static void syncListDevices() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (DeviceManagerClient deviceManagerClient = DeviceManagerClient.create()) { + ListDevicesRequest request = + ListDevicesRequest.newBuilder() + .setParent(RegistryName.of("[PROJECT]", "[LOCATION]", "[REGISTRY]").toString()) + .addAllDeviceNumIds(new ArrayList()) + .addAllDeviceIds(new ArrayList()) + .setFieldMask(FieldMask.newBuilder().build()) + .setGatewayListOptions(GatewayListOptions.newBuilder().build()) + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .build(); + for (Device element : deviceManagerClient.listDevices(request).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END iot_v1_generated_devicemanagerclient_listdevices_sync] diff --git a/java-iot/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/listdevices/SyncListDevicesRegistryname.java b/java-iot/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/listdevices/SyncListDevicesRegistryname.java new file mode 100644 index 000000000000..8ccb15b16412 --- /dev/null +++ b/java-iot/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/listdevices/SyncListDevicesRegistryname.java @@ -0,0 +1,41 @@ +/* + * Copyright 2022 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 + * + * https://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. + */ + +package com.google.cloud.iot.v1.samples; + +// [START iot_v1_generated_devicemanagerclient_listdevices_registryname_sync] +import com.google.cloud.iot.v1.Device; +import com.google.cloud.iot.v1.DeviceManagerClient; +import com.google.cloud.iot.v1.RegistryName; + +public class SyncListDevicesRegistryname { + + public static void main(String[] args) throws Exception { + syncListDevicesRegistryname(); + } + + public static void syncListDevicesRegistryname() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (DeviceManagerClient deviceManagerClient = DeviceManagerClient.create()) { + RegistryName parent = RegistryName.of("[PROJECT]", "[LOCATION]", "[REGISTRY]"); + for (Device element : deviceManagerClient.listDevices(parent).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END iot_v1_generated_devicemanagerclient_listdevices_registryname_sync] diff --git a/java-iot/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/listdevices/SyncListDevicesString.java b/java-iot/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/listdevices/SyncListDevicesString.java new file mode 100644 index 000000000000..e666e198317a --- /dev/null +++ b/java-iot/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/listdevices/SyncListDevicesString.java @@ -0,0 +1,41 @@ +/* + * Copyright 2022 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 + * + * https://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. + */ + +package com.google.cloud.iot.v1.samples; + +// [START iot_v1_generated_devicemanagerclient_listdevices_string_sync] +import com.google.cloud.iot.v1.Device; +import com.google.cloud.iot.v1.DeviceManagerClient; +import com.google.cloud.iot.v1.RegistryName; + +public class SyncListDevicesString { + + public static void main(String[] args) throws Exception { + syncListDevicesString(); + } + + public static void syncListDevicesString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (DeviceManagerClient deviceManagerClient = DeviceManagerClient.create()) { + String parent = RegistryName.of("[PROJECT]", "[LOCATION]", "[REGISTRY]").toString(); + for (Device element : deviceManagerClient.listDevices(parent).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END iot_v1_generated_devicemanagerclient_listdevices_string_sync] diff --git a/java-iot/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/listdevicestates/AsyncListDeviceStates.java b/java-iot/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/listdevicestates/AsyncListDeviceStates.java new file mode 100644 index 000000000000..0a761d6508c5 --- /dev/null +++ b/java-iot/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/listdevicestates/AsyncListDeviceStates.java @@ -0,0 +1,49 @@ +/* + * Copyright 2022 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 + * + * https://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. + */ + +package com.google.cloud.iot.v1.samples; + +// [START iot_v1_generated_devicemanagerclient_listdevicestates_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.iot.v1.DeviceManagerClient; +import com.google.cloud.iot.v1.DeviceName; +import com.google.cloud.iot.v1.ListDeviceStatesRequest; +import com.google.cloud.iot.v1.ListDeviceStatesResponse; + +public class AsyncListDeviceStates { + + public static void main(String[] args) throws Exception { + asyncListDeviceStates(); + } + + public static void asyncListDeviceStates() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (DeviceManagerClient deviceManagerClient = DeviceManagerClient.create()) { + ListDeviceStatesRequest request = + ListDeviceStatesRequest.newBuilder() + .setName( + DeviceName.of("[PROJECT]", "[LOCATION]", "[REGISTRY]", "[DEVICE]").toString()) + .setNumStates(1643330779) + .build(); + ApiFuture future = + deviceManagerClient.listDeviceStatesCallable().futureCall(request); + // Do something. + ListDeviceStatesResponse response = future.get(); + } + } +} +// [END iot_v1_generated_devicemanagerclient_listdevicestates_async] diff --git a/java-iot/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/listdevicestates/SyncListDeviceStates.java b/java-iot/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/listdevicestates/SyncListDeviceStates.java new file mode 100644 index 000000000000..879a4cc4361b --- /dev/null +++ b/java-iot/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/listdevicestates/SyncListDeviceStates.java @@ -0,0 +1,45 @@ +/* + * Copyright 2022 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 + * + * https://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. + */ + +package com.google.cloud.iot.v1.samples; + +// [START iot_v1_generated_devicemanagerclient_listdevicestates_sync] +import com.google.cloud.iot.v1.DeviceManagerClient; +import com.google.cloud.iot.v1.DeviceName; +import com.google.cloud.iot.v1.ListDeviceStatesRequest; +import com.google.cloud.iot.v1.ListDeviceStatesResponse; + +public class SyncListDeviceStates { + + public static void main(String[] args) throws Exception { + syncListDeviceStates(); + } + + public static void syncListDeviceStates() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (DeviceManagerClient deviceManagerClient = DeviceManagerClient.create()) { + ListDeviceStatesRequest request = + ListDeviceStatesRequest.newBuilder() + .setName( + DeviceName.of("[PROJECT]", "[LOCATION]", "[REGISTRY]", "[DEVICE]").toString()) + .setNumStates(1643330779) + .build(); + ListDeviceStatesResponse response = deviceManagerClient.listDeviceStates(request); + } + } +} +// [END iot_v1_generated_devicemanagerclient_listdevicestates_sync] diff --git a/java-iot/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/listdevicestates/SyncListDeviceStatesDevicename.java b/java-iot/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/listdevicestates/SyncListDeviceStatesDevicename.java new file mode 100644 index 000000000000..47eb9a14b026 --- /dev/null +++ b/java-iot/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/listdevicestates/SyncListDeviceStatesDevicename.java @@ -0,0 +1,39 @@ +/* + * Copyright 2022 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 + * + * https://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. + */ + +package com.google.cloud.iot.v1.samples; + +// [START iot_v1_generated_devicemanagerclient_listdevicestates_devicename_sync] +import com.google.cloud.iot.v1.DeviceManagerClient; +import com.google.cloud.iot.v1.DeviceName; +import com.google.cloud.iot.v1.ListDeviceStatesResponse; + +public class SyncListDeviceStatesDevicename { + + public static void main(String[] args) throws Exception { + syncListDeviceStatesDevicename(); + } + + public static void syncListDeviceStatesDevicename() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (DeviceManagerClient deviceManagerClient = DeviceManagerClient.create()) { + DeviceName name = DeviceName.of("[PROJECT]", "[LOCATION]", "[REGISTRY]", "[DEVICE]"); + ListDeviceStatesResponse response = deviceManagerClient.listDeviceStates(name); + } + } +} +// [END iot_v1_generated_devicemanagerclient_listdevicestates_devicename_sync] diff --git a/java-iot/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/listdevicestates/SyncListDeviceStatesString.java b/java-iot/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/listdevicestates/SyncListDeviceStatesString.java new file mode 100644 index 000000000000..ee9b22ecf8ef --- /dev/null +++ b/java-iot/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/listdevicestates/SyncListDeviceStatesString.java @@ -0,0 +1,39 @@ +/* + * Copyright 2022 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 + * + * https://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. + */ + +package com.google.cloud.iot.v1.samples; + +// [START iot_v1_generated_devicemanagerclient_listdevicestates_string_sync] +import com.google.cloud.iot.v1.DeviceManagerClient; +import com.google.cloud.iot.v1.DeviceName; +import com.google.cloud.iot.v1.ListDeviceStatesResponse; + +public class SyncListDeviceStatesString { + + public static void main(String[] args) throws Exception { + syncListDeviceStatesString(); + } + + public static void syncListDeviceStatesString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (DeviceManagerClient deviceManagerClient = DeviceManagerClient.create()) { + String name = DeviceName.of("[PROJECT]", "[LOCATION]", "[REGISTRY]", "[DEVICE]").toString(); + ListDeviceStatesResponse response = deviceManagerClient.listDeviceStates(name); + } + } +} +// [END iot_v1_generated_devicemanagerclient_listdevicestates_string_sync] diff --git a/java-iot/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/modifycloudtodeviceconfig/AsyncModifyCloudToDeviceConfig.java b/java-iot/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/modifycloudtodeviceconfig/AsyncModifyCloudToDeviceConfig.java new file mode 100644 index 000000000000..39171621405b --- /dev/null +++ b/java-iot/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/modifycloudtodeviceconfig/AsyncModifyCloudToDeviceConfig.java @@ -0,0 +1,51 @@ +/* + * Copyright 2022 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 + * + * https://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. + */ + +package com.google.cloud.iot.v1.samples; + +// [START iot_v1_generated_devicemanagerclient_modifycloudtodeviceconfig_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.iot.v1.DeviceConfig; +import com.google.cloud.iot.v1.DeviceManagerClient; +import com.google.cloud.iot.v1.DeviceName; +import com.google.cloud.iot.v1.ModifyCloudToDeviceConfigRequest; +import com.google.protobuf.ByteString; + +public class AsyncModifyCloudToDeviceConfig { + + public static void main(String[] args) throws Exception { + asyncModifyCloudToDeviceConfig(); + } + + public static void asyncModifyCloudToDeviceConfig() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (DeviceManagerClient deviceManagerClient = DeviceManagerClient.create()) { + ModifyCloudToDeviceConfigRequest request = + ModifyCloudToDeviceConfigRequest.newBuilder() + .setName( + DeviceName.of("[PROJECT]", "[LOCATION]", "[REGISTRY]", "[DEVICE]").toString()) + .setVersionToUpdate(462348390) + .setBinaryData(ByteString.EMPTY) + .build(); + ApiFuture future = + deviceManagerClient.modifyCloudToDeviceConfigCallable().futureCall(request); + // Do something. + DeviceConfig response = future.get(); + } + } +} +// [END iot_v1_generated_devicemanagerclient_modifycloudtodeviceconfig_async] diff --git a/java-iot/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/modifycloudtodeviceconfig/SyncModifyCloudToDeviceConfig.java b/java-iot/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/modifycloudtodeviceconfig/SyncModifyCloudToDeviceConfig.java new file mode 100644 index 000000000000..8de4fbc4bcf1 --- /dev/null +++ b/java-iot/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/modifycloudtodeviceconfig/SyncModifyCloudToDeviceConfig.java @@ -0,0 +1,47 @@ +/* + * Copyright 2022 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 + * + * https://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. + */ + +package com.google.cloud.iot.v1.samples; + +// [START iot_v1_generated_devicemanagerclient_modifycloudtodeviceconfig_sync] +import com.google.cloud.iot.v1.DeviceConfig; +import com.google.cloud.iot.v1.DeviceManagerClient; +import com.google.cloud.iot.v1.DeviceName; +import com.google.cloud.iot.v1.ModifyCloudToDeviceConfigRequest; +import com.google.protobuf.ByteString; + +public class SyncModifyCloudToDeviceConfig { + + public static void main(String[] args) throws Exception { + syncModifyCloudToDeviceConfig(); + } + + public static void syncModifyCloudToDeviceConfig() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (DeviceManagerClient deviceManagerClient = DeviceManagerClient.create()) { + ModifyCloudToDeviceConfigRequest request = + ModifyCloudToDeviceConfigRequest.newBuilder() + .setName( + DeviceName.of("[PROJECT]", "[LOCATION]", "[REGISTRY]", "[DEVICE]").toString()) + .setVersionToUpdate(462348390) + .setBinaryData(ByteString.EMPTY) + .build(); + DeviceConfig response = deviceManagerClient.modifyCloudToDeviceConfig(request); + } + } +} +// [END iot_v1_generated_devicemanagerclient_modifycloudtodeviceconfig_sync] diff --git a/java-iot/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/modifycloudtodeviceconfig/SyncModifyCloudToDeviceConfigDevicenameBytestring.java b/java-iot/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/modifycloudtodeviceconfig/SyncModifyCloudToDeviceConfigDevicenameBytestring.java new file mode 100644 index 000000000000..b23744c0d5d5 --- /dev/null +++ b/java-iot/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/modifycloudtodeviceconfig/SyncModifyCloudToDeviceConfigDevicenameBytestring.java @@ -0,0 +1,41 @@ +/* + * Copyright 2022 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 + * + * https://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. + */ + +package com.google.cloud.iot.v1.samples; + +// [START iot_v1_generated_devicemanagerclient_modifycloudtodeviceconfig_devicenamebytestring_sync] +import com.google.cloud.iot.v1.DeviceConfig; +import com.google.cloud.iot.v1.DeviceManagerClient; +import com.google.cloud.iot.v1.DeviceName; +import com.google.protobuf.ByteString; + +public class SyncModifyCloudToDeviceConfigDevicenameBytestring { + + public static void main(String[] args) throws Exception { + syncModifyCloudToDeviceConfigDevicenameBytestring(); + } + + public static void syncModifyCloudToDeviceConfigDevicenameBytestring() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (DeviceManagerClient deviceManagerClient = DeviceManagerClient.create()) { + DeviceName name = DeviceName.of("[PROJECT]", "[LOCATION]", "[REGISTRY]", "[DEVICE]"); + ByteString binaryData = ByteString.EMPTY; + DeviceConfig response = deviceManagerClient.modifyCloudToDeviceConfig(name, binaryData); + } + } +} +// [END iot_v1_generated_devicemanagerclient_modifycloudtodeviceconfig_devicenamebytestring_sync] diff --git a/java-iot/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/modifycloudtodeviceconfig/SyncModifyCloudToDeviceConfigStringBytestring.java b/java-iot/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/modifycloudtodeviceconfig/SyncModifyCloudToDeviceConfigStringBytestring.java new file mode 100644 index 000000000000..03290984cebb --- /dev/null +++ b/java-iot/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/modifycloudtodeviceconfig/SyncModifyCloudToDeviceConfigStringBytestring.java @@ -0,0 +1,41 @@ +/* + * Copyright 2022 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 + * + * https://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. + */ + +package com.google.cloud.iot.v1.samples; + +// [START iot_v1_generated_devicemanagerclient_modifycloudtodeviceconfig_stringbytestring_sync] +import com.google.cloud.iot.v1.DeviceConfig; +import com.google.cloud.iot.v1.DeviceManagerClient; +import com.google.cloud.iot.v1.DeviceName; +import com.google.protobuf.ByteString; + +public class SyncModifyCloudToDeviceConfigStringBytestring { + + public static void main(String[] args) throws Exception { + syncModifyCloudToDeviceConfigStringBytestring(); + } + + public static void syncModifyCloudToDeviceConfigStringBytestring() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (DeviceManagerClient deviceManagerClient = DeviceManagerClient.create()) { + String name = DeviceName.of("[PROJECT]", "[LOCATION]", "[REGISTRY]", "[DEVICE]").toString(); + ByteString binaryData = ByteString.EMPTY; + DeviceConfig response = deviceManagerClient.modifyCloudToDeviceConfig(name, binaryData); + } + } +} +// [END iot_v1_generated_devicemanagerclient_modifycloudtodeviceconfig_stringbytestring_sync] diff --git a/java-iot/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/sendcommandtodevice/AsyncSendCommandToDevice.java b/java-iot/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/sendcommandtodevice/AsyncSendCommandToDevice.java new file mode 100644 index 000000000000..971c5e5723f9 --- /dev/null +++ b/java-iot/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/sendcommandtodevice/AsyncSendCommandToDevice.java @@ -0,0 +1,51 @@ +/* + * Copyright 2022 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 + * + * https://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. + */ + +package com.google.cloud.iot.v1.samples; + +// [START iot_v1_generated_devicemanagerclient_sendcommandtodevice_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.iot.v1.DeviceManagerClient; +import com.google.cloud.iot.v1.DeviceName; +import com.google.cloud.iot.v1.SendCommandToDeviceRequest; +import com.google.cloud.iot.v1.SendCommandToDeviceResponse; +import com.google.protobuf.ByteString; + +public class AsyncSendCommandToDevice { + + public static void main(String[] args) throws Exception { + asyncSendCommandToDevice(); + } + + public static void asyncSendCommandToDevice() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (DeviceManagerClient deviceManagerClient = DeviceManagerClient.create()) { + SendCommandToDeviceRequest request = + SendCommandToDeviceRequest.newBuilder() + .setName( + DeviceName.of("[PROJECT]", "[LOCATION]", "[REGISTRY]", "[DEVICE]").toString()) + .setBinaryData(ByteString.EMPTY) + .setSubfolder("subfolder153561774") + .build(); + ApiFuture future = + deviceManagerClient.sendCommandToDeviceCallable().futureCall(request); + // Do something. + SendCommandToDeviceResponse response = future.get(); + } + } +} +// [END iot_v1_generated_devicemanagerclient_sendcommandtodevice_async] diff --git a/java-iot/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/sendcommandtodevice/SyncSendCommandToDevice.java b/java-iot/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/sendcommandtodevice/SyncSendCommandToDevice.java new file mode 100644 index 000000000000..a45dacdc4050 --- /dev/null +++ b/java-iot/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/sendcommandtodevice/SyncSendCommandToDevice.java @@ -0,0 +1,47 @@ +/* + * Copyright 2022 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 + * + * https://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. + */ + +package com.google.cloud.iot.v1.samples; + +// [START iot_v1_generated_devicemanagerclient_sendcommandtodevice_sync] +import com.google.cloud.iot.v1.DeviceManagerClient; +import com.google.cloud.iot.v1.DeviceName; +import com.google.cloud.iot.v1.SendCommandToDeviceRequest; +import com.google.cloud.iot.v1.SendCommandToDeviceResponse; +import com.google.protobuf.ByteString; + +public class SyncSendCommandToDevice { + + public static void main(String[] args) throws Exception { + syncSendCommandToDevice(); + } + + public static void syncSendCommandToDevice() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (DeviceManagerClient deviceManagerClient = DeviceManagerClient.create()) { + SendCommandToDeviceRequest request = + SendCommandToDeviceRequest.newBuilder() + .setName( + DeviceName.of("[PROJECT]", "[LOCATION]", "[REGISTRY]", "[DEVICE]").toString()) + .setBinaryData(ByteString.EMPTY) + .setSubfolder("subfolder153561774") + .build(); + SendCommandToDeviceResponse response = deviceManagerClient.sendCommandToDevice(request); + } + } +} +// [END iot_v1_generated_devicemanagerclient_sendcommandtodevice_sync] diff --git a/java-iot/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/sendcommandtodevice/SyncSendCommandToDeviceDevicenameBytestring.java b/java-iot/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/sendcommandtodevice/SyncSendCommandToDeviceDevicenameBytestring.java new file mode 100644 index 000000000000..ebcb096f23ff --- /dev/null +++ b/java-iot/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/sendcommandtodevice/SyncSendCommandToDeviceDevicenameBytestring.java @@ -0,0 +1,42 @@ +/* + * Copyright 2022 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 + * + * https://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. + */ + +package com.google.cloud.iot.v1.samples; + +// [START iot_v1_generated_devicemanagerclient_sendcommandtodevice_devicenamebytestring_sync] +import com.google.cloud.iot.v1.DeviceManagerClient; +import com.google.cloud.iot.v1.DeviceName; +import com.google.cloud.iot.v1.SendCommandToDeviceResponse; +import com.google.protobuf.ByteString; + +public class SyncSendCommandToDeviceDevicenameBytestring { + + public static void main(String[] args) throws Exception { + syncSendCommandToDeviceDevicenameBytestring(); + } + + public static void syncSendCommandToDeviceDevicenameBytestring() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (DeviceManagerClient deviceManagerClient = DeviceManagerClient.create()) { + DeviceName name = DeviceName.of("[PROJECT]", "[LOCATION]", "[REGISTRY]", "[DEVICE]"); + ByteString binaryData = ByteString.EMPTY; + SendCommandToDeviceResponse response = + deviceManagerClient.sendCommandToDevice(name, binaryData); + } + } +} +// [END iot_v1_generated_devicemanagerclient_sendcommandtodevice_devicenamebytestring_sync] diff --git a/java-iot/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/sendcommandtodevice/SyncSendCommandToDeviceDevicenameBytestringString.java b/java-iot/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/sendcommandtodevice/SyncSendCommandToDeviceDevicenameBytestringString.java new file mode 100644 index 000000000000..3a71ea241dbc --- /dev/null +++ b/java-iot/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/sendcommandtodevice/SyncSendCommandToDeviceDevicenameBytestringString.java @@ -0,0 +1,43 @@ +/* + * Copyright 2022 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 + * + * https://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. + */ + +package com.google.cloud.iot.v1.samples; + +// [START iot_v1_generated_devicemanagerclient_sendcommandtodevice_devicenamebytestringstring_sync] +import com.google.cloud.iot.v1.DeviceManagerClient; +import com.google.cloud.iot.v1.DeviceName; +import com.google.cloud.iot.v1.SendCommandToDeviceResponse; +import com.google.protobuf.ByteString; + +public class SyncSendCommandToDeviceDevicenameBytestringString { + + public static void main(String[] args) throws Exception { + syncSendCommandToDeviceDevicenameBytestringString(); + } + + public static void syncSendCommandToDeviceDevicenameBytestringString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (DeviceManagerClient deviceManagerClient = DeviceManagerClient.create()) { + DeviceName name = DeviceName.of("[PROJECT]", "[LOCATION]", "[REGISTRY]", "[DEVICE]"); + ByteString binaryData = ByteString.EMPTY; + String subfolder = "subfolder153561774"; + SendCommandToDeviceResponse response = + deviceManagerClient.sendCommandToDevice(name, binaryData, subfolder); + } + } +} +// [END iot_v1_generated_devicemanagerclient_sendcommandtodevice_devicenamebytestringstring_sync] diff --git a/java-iot/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/sendcommandtodevice/SyncSendCommandToDeviceStringBytestring.java b/java-iot/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/sendcommandtodevice/SyncSendCommandToDeviceStringBytestring.java new file mode 100644 index 000000000000..7d91a2b68a0f --- /dev/null +++ b/java-iot/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/sendcommandtodevice/SyncSendCommandToDeviceStringBytestring.java @@ -0,0 +1,42 @@ +/* + * Copyright 2022 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 + * + * https://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. + */ + +package com.google.cloud.iot.v1.samples; + +// [START iot_v1_generated_devicemanagerclient_sendcommandtodevice_stringbytestring_sync] +import com.google.cloud.iot.v1.DeviceManagerClient; +import com.google.cloud.iot.v1.DeviceName; +import com.google.cloud.iot.v1.SendCommandToDeviceResponse; +import com.google.protobuf.ByteString; + +public class SyncSendCommandToDeviceStringBytestring { + + public static void main(String[] args) throws Exception { + syncSendCommandToDeviceStringBytestring(); + } + + public static void syncSendCommandToDeviceStringBytestring() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (DeviceManagerClient deviceManagerClient = DeviceManagerClient.create()) { + String name = DeviceName.of("[PROJECT]", "[LOCATION]", "[REGISTRY]", "[DEVICE]").toString(); + ByteString binaryData = ByteString.EMPTY; + SendCommandToDeviceResponse response = + deviceManagerClient.sendCommandToDevice(name, binaryData); + } + } +} +// [END iot_v1_generated_devicemanagerclient_sendcommandtodevice_stringbytestring_sync] diff --git a/java-iot/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/sendcommandtodevice/SyncSendCommandToDeviceStringBytestringString.java b/java-iot/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/sendcommandtodevice/SyncSendCommandToDeviceStringBytestringString.java new file mode 100644 index 000000000000..d21bbd803d51 --- /dev/null +++ b/java-iot/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/sendcommandtodevice/SyncSendCommandToDeviceStringBytestringString.java @@ -0,0 +1,43 @@ +/* + * Copyright 2022 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 + * + * https://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. + */ + +package com.google.cloud.iot.v1.samples; + +// [START iot_v1_generated_devicemanagerclient_sendcommandtodevice_stringbytestringstring_sync] +import com.google.cloud.iot.v1.DeviceManagerClient; +import com.google.cloud.iot.v1.DeviceName; +import com.google.cloud.iot.v1.SendCommandToDeviceResponse; +import com.google.protobuf.ByteString; + +public class SyncSendCommandToDeviceStringBytestringString { + + public static void main(String[] args) throws Exception { + syncSendCommandToDeviceStringBytestringString(); + } + + public static void syncSendCommandToDeviceStringBytestringString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (DeviceManagerClient deviceManagerClient = DeviceManagerClient.create()) { + String name = DeviceName.of("[PROJECT]", "[LOCATION]", "[REGISTRY]", "[DEVICE]").toString(); + ByteString binaryData = ByteString.EMPTY; + String subfolder = "subfolder153561774"; + SendCommandToDeviceResponse response = + deviceManagerClient.sendCommandToDevice(name, binaryData, subfolder); + } + } +} +// [END iot_v1_generated_devicemanagerclient_sendcommandtodevice_stringbytestringstring_sync] diff --git a/java-iot/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/setiampolicy/AsyncSetIamPolicy.java b/java-iot/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/setiampolicy/AsyncSetIamPolicy.java new file mode 100644 index 000000000000..9a5e65f33f94 --- /dev/null +++ b/java-iot/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/setiampolicy/AsyncSetIamPolicy.java @@ -0,0 +1,49 @@ +/* + * Copyright 2022 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 + * + * https://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. + */ + +package com.google.cloud.iot.v1.samples; + +// [START iot_v1_generated_devicemanagerclient_setiampolicy_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.iot.v1.DeviceManagerClient; +import com.google.cloud.iot.v1.RegistryName; +import com.google.iam.v1.Policy; +import com.google.iam.v1.SetIamPolicyRequest; +import com.google.protobuf.FieldMask; + +public class AsyncSetIamPolicy { + + public static void main(String[] args) throws Exception { + asyncSetIamPolicy(); + } + + public static void asyncSetIamPolicy() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (DeviceManagerClient deviceManagerClient = DeviceManagerClient.create()) { + SetIamPolicyRequest request = + SetIamPolicyRequest.newBuilder() + .setResource(RegistryName.of("[PROJECT]", "[LOCATION]", "[REGISTRY]").toString()) + .setPolicy(Policy.newBuilder().build()) + .setUpdateMask(FieldMask.newBuilder().build()) + .build(); + ApiFuture future = deviceManagerClient.setIamPolicyCallable().futureCall(request); + // Do something. + Policy response = future.get(); + } + } +} +// [END iot_v1_generated_devicemanagerclient_setiampolicy_async] diff --git a/java-iot/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/setiampolicy/SyncSetIamPolicy.java b/java-iot/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/setiampolicy/SyncSetIamPolicy.java new file mode 100644 index 000000000000..8921ca9035ce --- /dev/null +++ b/java-iot/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/setiampolicy/SyncSetIamPolicy.java @@ -0,0 +1,46 @@ +/* + * Copyright 2022 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 + * + * https://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. + */ + +package com.google.cloud.iot.v1.samples; + +// [START iot_v1_generated_devicemanagerclient_setiampolicy_sync] +import com.google.cloud.iot.v1.DeviceManagerClient; +import com.google.cloud.iot.v1.RegistryName; +import com.google.iam.v1.Policy; +import com.google.iam.v1.SetIamPolicyRequest; +import com.google.protobuf.FieldMask; + +public class SyncSetIamPolicy { + + public static void main(String[] args) throws Exception { + syncSetIamPolicy(); + } + + public static void syncSetIamPolicy() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (DeviceManagerClient deviceManagerClient = DeviceManagerClient.create()) { + SetIamPolicyRequest request = + SetIamPolicyRequest.newBuilder() + .setResource(RegistryName.of("[PROJECT]", "[LOCATION]", "[REGISTRY]").toString()) + .setPolicy(Policy.newBuilder().build()) + .setUpdateMask(FieldMask.newBuilder().build()) + .build(); + Policy response = deviceManagerClient.setIamPolicy(request); + } + } +} +// [END iot_v1_generated_devicemanagerclient_setiampolicy_sync] diff --git a/java-iot/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/setiampolicy/SyncSetIamPolicyResourcenamePolicy.java b/java-iot/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/setiampolicy/SyncSetIamPolicyResourcenamePolicy.java new file mode 100644 index 000000000000..66f6682bead8 --- /dev/null +++ b/java-iot/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/setiampolicy/SyncSetIamPolicyResourcenamePolicy.java @@ -0,0 +1,41 @@ +/* + * Copyright 2022 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 + * + * https://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. + */ + +package com.google.cloud.iot.v1.samples; + +// [START iot_v1_generated_devicemanagerclient_setiampolicy_resourcenamepolicy_sync] +import com.google.api.resourcenames.ResourceName; +import com.google.cloud.iot.v1.DeviceManagerClient; +import com.google.cloud.iot.v1.RegistryName; +import com.google.iam.v1.Policy; + +public class SyncSetIamPolicyResourcenamePolicy { + + public static void main(String[] args) throws Exception { + syncSetIamPolicyResourcenamePolicy(); + } + + public static void syncSetIamPolicyResourcenamePolicy() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (DeviceManagerClient deviceManagerClient = DeviceManagerClient.create()) { + ResourceName resource = RegistryName.of("[PROJECT]", "[LOCATION]", "[REGISTRY]"); + Policy policy = Policy.newBuilder().build(); + Policy response = deviceManagerClient.setIamPolicy(resource, policy); + } + } +} +// [END iot_v1_generated_devicemanagerclient_setiampolicy_resourcenamepolicy_sync] diff --git a/java-iot/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/setiampolicy/SyncSetIamPolicyStringPolicy.java b/java-iot/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/setiampolicy/SyncSetIamPolicyStringPolicy.java new file mode 100644 index 000000000000..70a20b65e15d --- /dev/null +++ b/java-iot/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/setiampolicy/SyncSetIamPolicyStringPolicy.java @@ -0,0 +1,41 @@ +/* + * Copyright 2022 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 + * + * https://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. + */ + +package com.google.cloud.iot.v1.samples; + +// [START iot_v1_generated_devicemanagerclient_setiampolicy_stringpolicy_sync] +import com.google.cloud.iot.v1.DeviceManagerClient; +import com.google.cloud.iot.v1.DeviceName; +import com.google.iam.v1.Policy; + +public class SyncSetIamPolicyStringPolicy { + + public static void main(String[] args) throws Exception { + syncSetIamPolicyStringPolicy(); + } + + public static void syncSetIamPolicyStringPolicy() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (DeviceManagerClient deviceManagerClient = DeviceManagerClient.create()) { + String resource = + DeviceName.of("[PROJECT]", "[LOCATION]", "[REGISTRY]", "[DEVICE]").toString(); + Policy policy = Policy.newBuilder().build(); + Policy response = deviceManagerClient.setIamPolicy(resource, policy); + } + } +} +// [END iot_v1_generated_devicemanagerclient_setiampolicy_stringpolicy_sync] diff --git a/java-iot/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/testiampermissions/AsyncTestIamPermissions.java b/java-iot/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/testiampermissions/AsyncTestIamPermissions.java new file mode 100644 index 000000000000..30fc679ef5ff --- /dev/null +++ b/java-iot/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/testiampermissions/AsyncTestIamPermissions.java @@ -0,0 +1,49 @@ +/* + * Copyright 2022 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 + * + * https://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. + */ + +package com.google.cloud.iot.v1.samples; + +// [START iot_v1_generated_devicemanagerclient_testiampermissions_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.iot.v1.DeviceManagerClient; +import com.google.cloud.iot.v1.RegistryName; +import com.google.iam.v1.TestIamPermissionsRequest; +import com.google.iam.v1.TestIamPermissionsResponse; +import java.util.ArrayList; + +public class AsyncTestIamPermissions { + + public static void main(String[] args) throws Exception { + asyncTestIamPermissions(); + } + + public static void asyncTestIamPermissions() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (DeviceManagerClient deviceManagerClient = DeviceManagerClient.create()) { + TestIamPermissionsRequest request = + TestIamPermissionsRequest.newBuilder() + .setResource(RegistryName.of("[PROJECT]", "[LOCATION]", "[REGISTRY]").toString()) + .addAllPermissions(new ArrayList()) + .build(); + ApiFuture future = + deviceManagerClient.testIamPermissionsCallable().futureCall(request); + // Do something. + TestIamPermissionsResponse response = future.get(); + } + } +} +// [END iot_v1_generated_devicemanagerclient_testiampermissions_async] diff --git a/java-iot/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/testiampermissions/SyncTestIamPermissions.java b/java-iot/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/testiampermissions/SyncTestIamPermissions.java new file mode 100644 index 000000000000..5267cf4b9963 --- /dev/null +++ b/java-iot/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/testiampermissions/SyncTestIamPermissions.java @@ -0,0 +1,45 @@ +/* + * Copyright 2022 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 + * + * https://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. + */ + +package com.google.cloud.iot.v1.samples; + +// [START iot_v1_generated_devicemanagerclient_testiampermissions_sync] +import com.google.cloud.iot.v1.DeviceManagerClient; +import com.google.cloud.iot.v1.RegistryName; +import com.google.iam.v1.TestIamPermissionsRequest; +import com.google.iam.v1.TestIamPermissionsResponse; +import java.util.ArrayList; + +public class SyncTestIamPermissions { + + public static void main(String[] args) throws Exception { + syncTestIamPermissions(); + } + + public static void syncTestIamPermissions() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (DeviceManagerClient deviceManagerClient = DeviceManagerClient.create()) { + TestIamPermissionsRequest request = + TestIamPermissionsRequest.newBuilder() + .setResource(RegistryName.of("[PROJECT]", "[LOCATION]", "[REGISTRY]").toString()) + .addAllPermissions(new ArrayList()) + .build(); + TestIamPermissionsResponse response = deviceManagerClient.testIamPermissions(request); + } + } +} +// [END iot_v1_generated_devicemanagerclient_testiampermissions_sync] diff --git a/java-iot/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/testiampermissions/SyncTestIamPermissionsResourcenameListstring.java b/java-iot/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/testiampermissions/SyncTestIamPermissionsResourcenameListstring.java new file mode 100644 index 000000000000..1a0e8fbe2a9b --- /dev/null +++ b/java-iot/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/testiampermissions/SyncTestIamPermissionsResourcenameListstring.java @@ -0,0 +1,44 @@ +/* + * Copyright 2022 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 + * + * https://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. + */ + +package com.google.cloud.iot.v1.samples; + +// [START iot_v1_generated_devicemanagerclient_testiampermissions_resourcenameliststring_sync] +import com.google.api.resourcenames.ResourceName; +import com.google.cloud.iot.v1.DeviceManagerClient; +import com.google.cloud.iot.v1.RegistryName; +import com.google.iam.v1.TestIamPermissionsResponse; +import java.util.ArrayList; +import java.util.List; + +public class SyncTestIamPermissionsResourcenameListstring { + + public static void main(String[] args) throws Exception { + syncTestIamPermissionsResourcenameListstring(); + } + + public static void syncTestIamPermissionsResourcenameListstring() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (DeviceManagerClient deviceManagerClient = DeviceManagerClient.create()) { + ResourceName resource = RegistryName.of("[PROJECT]", "[LOCATION]", "[REGISTRY]"); + List permissions = new ArrayList<>(); + TestIamPermissionsResponse response = + deviceManagerClient.testIamPermissions(resource, permissions); + } + } +} +// [END iot_v1_generated_devicemanagerclient_testiampermissions_resourcenameliststring_sync] diff --git a/java-iot/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/testiampermissions/SyncTestIamPermissionsStringListstring.java b/java-iot/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/testiampermissions/SyncTestIamPermissionsStringListstring.java new file mode 100644 index 000000000000..d0807fe69967 --- /dev/null +++ b/java-iot/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/testiampermissions/SyncTestIamPermissionsStringListstring.java @@ -0,0 +1,44 @@ +/* + * Copyright 2022 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 + * + * https://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. + */ + +package com.google.cloud.iot.v1.samples; + +// [START iot_v1_generated_devicemanagerclient_testiampermissions_stringliststring_sync] +import com.google.cloud.iot.v1.DeviceManagerClient; +import com.google.cloud.iot.v1.DeviceName; +import com.google.iam.v1.TestIamPermissionsResponse; +import java.util.ArrayList; +import java.util.List; + +public class SyncTestIamPermissionsStringListstring { + + public static void main(String[] args) throws Exception { + syncTestIamPermissionsStringListstring(); + } + + public static void syncTestIamPermissionsStringListstring() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (DeviceManagerClient deviceManagerClient = DeviceManagerClient.create()) { + String resource = + DeviceName.of("[PROJECT]", "[LOCATION]", "[REGISTRY]", "[DEVICE]").toString(); + List permissions = new ArrayList<>(); + TestIamPermissionsResponse response = + deviceManagerClient.testIamPermissions(resource, permissions); + } + } +} +// [END iot_v1_generated_devicemanagerclient_testiampermissions_stringliststring_sync] diff --git a/java-iot/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/unbinddevicefromgateway/AsyncUnbindDeviceFromGateway.java b/java-iot/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/unbinddevicefromgateway/AsyncUnbindDeviceFromGateway.java new file mode 100644 index 000000000000..ef98fd8c17ae --- /dev/null +++ b/java-iot/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/unbinddevicefromgateway/AsyncUnbindDeviceFromGateway.java @@ -0,0 +1,49 @@ +/* + * Copyright 2022 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 + * + * https://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. + */ + +package com.google.cloud.iot.v1.samples; + +// [START iot_v1_generated_devicemanagerclient_unbinddevicefromgateway_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.iot.v1.DeviceManagerClient; +import com.google.cloud.iot.v1.RegistryName; +import com.google.cloud.iot.v1.UnbindDeviceFromGatewayRequest; +import com.google.cloud.iot.v1.UnbindDeviceFromGatewayResponse; + +public class AsyncUnbindDeviceFromGateway { + + public static void main(String[] args) throws Exception { + asyncUnbindDeviceFromGateway(); + } + + public static void asyncUnbindDeviceFromGateway() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (DeviceManagerClient deviceManagerClient = DeviceManagerClient.create()) { + UnbindDeviceFromGatewayRequest request = + UnbindDeviceFromGatewayRequest.newBuilder() + .setParent(RegistryName.of("[PROJECT]", "[LOCATION]", "[REGISTRY]").toString()) + .setGatewayId("gatewayId-1354641793") + .setDeviceId("deviceId1109191185") + .build(); + ApiFuture future = + deviceManagerClient.unbindDeviceFromGatewayCallable().futureCall(request); + // Do something. + UnbindDeviceFromGatewayResponse response = future.get(); + } + } +} +// [END iot_v1_generated_devicemanagerclient_unbinddevicefromgateway_async] diff --git a/java-iot/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/unbinddevicefromgateway/SyncUnbindDeviceFromGateway.java b/java-iot/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/unbinddevicefromgateway/SyncUnbindDeviceFromGateway.java new file mode 100644 index 000000000000..d58e14fec39c --- /dev/null +++ b/java-iot/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/unbinddevicefromgateway/SyncUnbindDeviceFromGateway.java @@ -0,0 +1,46 @@ +/* + * Copyright 2022 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 + * + * https://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. + */ + +package com.google.cloud.iot.v1.samples; + +// [START iot_v1_generated_devicemanagerclient_unbinddevicefromgateway_sync] +import com.google.cloud.iot.v1.DeviceManagerClient; +import com.google.cloud.iot.v1.RegistryName; +import com.google.cloud.iot.v1.UnbindDeviceFromGatewayRequest; +import com.google.cloud.iot.v1.UnbindDeviceFromGatewayResponse; + +public class SyncUnbindDeviceFromGateway { + + public static void main(String[] args) throws Exception { + syncUnbindDeviceFromGateway(); + } + + public static void syncUnbindDeviceFromGateway() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (DeviceManagerClient deviceManagerClient = DeviceManagerClient.create()) { + UnbindDeviceFromGatewayRequest request = + UnbindDeviceFromGatewayRequest.newBuilder() + .setParent(RegistryName.of("[PROJECT]", "[LOCATION]", "[REGISTRY]").toString()) + .setGatewayId("gatewayId-1354641793") + .setDeviceId("deviceId1109191185") + .build(); + UnbindDeviceFromGatewayResponse response = + deviceManagerClient.unbindDeviceFromGateway(request); + } + } +} +// [END iot_v1_generated_devicemanagerclient_unbinddevicefromgateway_sync] diff --git a/java-iot/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/unbinddevicefromgateway/SyncUnbindDeviceFromGatewayRegistrynameStringString.java b/java-iot/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/unbinddevicefromgateway/SyncUnbindDeviceFromGatewayRegistrynameStringString.java new file mode 100644 index 000000000000..d604ee5d8333 --- /dev/null +++ b/java-iot/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/unbinddevicefromgateway/SyncUnbindDeviceFromGatewayRegistrynameStringString.java @@ -0,0 +1,43 @@ +/* + * Copyright 2022 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 + * + * https://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. + */ + +package com.google.cloud.iot.v1.samples; + +// [START +// iot_v1_generated_devicemanagerclient_unbinddevicefromgateway_registrynamestringstring_sync] +import com.google.cloud.iot.v1.DeviceManagerClient; +import com.google.cloud.iot.v1.RegistryName; +import com.google.cloud.iot.v1.UnbindDeviceFromGatewayResponse; + +public class SyncUnbindDeviceFromGatewayRegistrynameStringString { + + public static void main(String[] args) throws Exception { + syncUnbindDeviceFromGatewayRegistrynameStringString(); + } + + public static void syncUnbindDeviceFromGatewayRegistrynameStringString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (DeviceManagerClient deviceManagerClient = DeviceManagerClient.create()) { + RegistryName parent = RegistryName.of("[PROJECT]", "[LOCATION]", "[REGISTRY]"); + String gatewayId = "gatewayId-1354641793"; + String deviceId = "deviceId1109191185"; + UnbindDeviceFromGatewayResponse response = + deviceManagerClient.unbindDeviceFromGateway(parent, gatewayId, deviceId); + } + } +} +// [END iot_v1_generated_devicemanagerclient_unbinddevicefromgateway_registrynamestringstring_sync] diff --git a/java-iot/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/unbinddevicefromgateway/SyncUnbindDeviceFromGatewayStringStringString.java b/java-iot/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/unbinddevicefromgateway/SyncUnbindDeviceFromGatewayStringStringString.java new file mode 100644 index 000000000000..62f593e3c5df --- /dev/null +++ b/java-iot/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/unbinddevicefromgateway/SyncUnbindDeviceFromGatewayStringStringString.java @@ -0,0 +1,42 @@ +/* + * Copyright 2022 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 + * + * https://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. + */ + +package com.google.cloud.iot.v1.samples; + +// [START iot_v1_generated_devicemanagerclient_unbinddevicefromgateway_stringstringstring_sync] +import com.google.cloud.iot.v1.DeviceManagerClient; +import com.google.cloud.iot.v1.RegistryName; +import com.google.cloud.iot.v1.UnbindDeviceFromGatewayResponse; + +public class SyncUnbindDeviceFromGatewayStringStringString { + + public static void main(String[] args) throws Exception { + syncUnbindDeviceFromGatewayStringStringString(); + } + + public static void syncUnbindDeviceFromGatewayStringStringString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (DeviceManagerClient deviceManagerClient = DeviceManagerClient.create()) { + String parent = RegistryName.of("[PROJECT]", "[LOCATION]", "[REGISTRY]").toString(); + String gatewayId = "gatewayId-1354641793"; + String deviceId = "deviceId1109191185"; + UnbindDeviceFromGatewayResponse response = + deviceManagerClient.unbindDeviceFromGateway(parent, gatewayId, deviceId); + } + } +} +// [END iot_v1_generated_devicemanagerclient_unbinddevicefromgateway_stringstringstring_sync] diff --git a/java-iot/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/updatedevice/AsyncUpdateDevice.java b/java-iot/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/updatedevice/AsyncUpdateDevice.java new file mode 100644 index 000000000000..f97b79d2054e --- /dev/null +++ b/java-iot/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/updatedevice/AsyncUpdateDevice.java @@ -0,0 +1,47 @@ +/* + * Copyright 2022 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 + * + * https://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. + */ + +package com.google.cloud.iot.v1.samples; + +// [START iot_v1_generated_devicemanagerclient_updatedevice_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.iot.v1.Device; +import com.google.cloud.iot.v1.DeviceManagerClient; +import com.google.cloud.iot.v1.UpdateDeviceRequest; +import com.google.protobuf.FieldMask; + +public class AsyncUpdateDevice { + + public static void main(String[] args) throws Exception { + asyncUpdateDevice(); + } + + public static void asyncUpdateDevice() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (DeviceManagerClient deviceManagerClient = DeviceManagerClient.create()) { + UpdateDeviceRequest request = + UpdateDeviceRequest.newBuilder() + .setDevice(Device.newBuilder().build()) + .setUpdateMask(FieldMask.newBuilder().build()) + .build(); + ApiFuture future = deviceManagerClient.updateDeviceCallable().futureCall(request); + // Do something. + Device response = future.get(); + } + } +} +// [END iot_v1_generated_devicemanagerclient_updatedevice_async] diff --git a/java-iot/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/updatedevice/SyncUpdateDevice.java b/java-iot/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/updatedevice/SyncUpdateDevice.java new file mode 100644 index 000000000000..f492fe05f1bc --- /dev/null +++ b/java-iot/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/updatedevice/SyncUpdateDevice.java @@ -0,0 +1,44 @@ +/* + * Copyright 2022 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 + * + * https://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. + */ + +package com.google.cloud.iot.v1.samples; + +// [START iot_v1_generated_devicemanagerclient_updatedevice_sync] +import com.google.cloud.iot.v1.Device; +import com.google.cloud.iot.v1.DeviceManagerClient; +import com.google.cloud.iot.v1.UpdateDeviceRequest; +import com.google.protobuf.FieldMask; + +public class SyncUpdateDevice { + + public static void main(String[] args) throws Exception { + syncUpdateDevice(); + } + + public static void syncUpdateDevice() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (DeviceManagerClient deviceManagerClient = DeviceManagerClient.create()) { + UpdateDeviceRequest request = + UpdateDeviceRequest.newBuilder() + .setDevice(Device.newBuilder().build()) + .setUpdateMask(FieldMask.newBuilder().build()) + .build(); + Device response = deviceManagerClient.updateDevice(request); + } + } +} +// [END iot_v1_generated_devicemanagerclient_updatedevice_sync] diff --git a/java-iot/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/updatedevice/SyncUpdateDeviceDeviceFieldmask.java b/java-iot/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/updatedevice/SyncUpdateDeviceDeviceFieldmask.java new file mode 100644 index 000000000000..b6ff04ccd634 --- /dev/null +++ b/java-iot/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/updatedevice/SyncUpdateDeviceDeviceFieldmask.java @@ -0,0 +1,40 @@ +/* + * Copyright 2022 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 + * + * https://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. + */ + +package com.google.cloud.iot.v1.samples; + +// [START iot_v1_generated_devicemanagerclient_updatedevice_devicefieldmask_sync] +import com.google.cloud.iot.v1.Device; +import com.google.cloud.iot.v1.DeviceManagerClient; +import com.google.protobuf.FieldMask; + +public class SyncUpdateDeviceDeviceFieldmask { + + public static void main(String[] args) throws Exception { + syncUpdateDeviceDeviceFieldmask(); + } + + public static void syncUpdateDeviceDeviceFieldmask() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (DeviceManagerClient deviceManagerClient = DeviceManagerClient.create()) { + Device device = Device.newBuilder().build(); + FieldMask updateMask = FieldMask.newBuilder().build(); + Device response = deviceManagerClient.updateDevice(device, updateMask); + } + } +} +// [END iot_v1_generated_devicemanagerclient_updatedevice_devicefieldmask_sync] diff --git a/java-iot/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/updatedeviceregistry/AsyncUpdateDeviceRegistry.java b/java-iot/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/updatedeviceregistry/AsyncUpdateDeviceRegistry.java new file mode 100644 index 000000000000..f5662c33cb0d --- /dev/null +++ b/java-iot/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/updatedeviceregistry/AsyncUpdateDeviceRegistry.java @@ -0,0 +1,48 @@ +/* + * Copyright 2022 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 + * + * https://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. + */ + +package com.google.cloud.iot.v1.samples; + +// [START iot_v1_generated_devicemanagerclient_updatedeviceregistry_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.iot.v1.DeviceManagerClient; +import com.google.cloud.iot.v1.DeviceRegistry; +import com.google.cloud.iot.v1.UpdateDeviceRegistryRequest; +import com.google.protobuf.FieldMask; + +public class AsyncUpdateDeviceRegistry { + + public static void main(String[] args) throws Exception { + asyncUpdateDeviceRegistry(); + } + + public static void asyncUpdateDeviceRegistry() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (DeviceManagerClient deviceManagerClient = DeviceManagerClient.create()) { + UpdateDeviceRegistryRequest request = + UpdateDeviceRegistryRequest.newBuilder() + .setDeviceRegistry(DeviceRegistry.newBuilder().build()) + .setUpdateMask(FieldMask.newBuilder().build()) + .build(); + ApiFuture future = + deviceManagerClient.updateDeviceRegistryCallable().futureCall(request); + // Do something. + DeviceRegistry response = future.get(); + } + } +} +// [END iot_v1_generated_devicemanagerclient_updatedeviceregistry_async] diff --git a/java-iot/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/updatedeviceregistry/SyncUpdateDeviceRegistry.java b/java-iot/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/updatedeviceregistry/SyncUpdateDeviceRegistry.java new file mode 100644 index 000000000000..3625e1a9afb2 --- /dev/null +++ b/java-iot/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/updatedeviceregistry/SyncUpdateDeviceRegistry.java @@ -0,0 +1,44 @@ +/* + * Copyright 2022 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 + * + * https://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. + */ + +package com.google.cloud.iot.v1.samples; + +// [START iot_v1_generated_devicemanagerclient_updatedeviceregistry_sync] +import com.google.cloud.iot.v1.DeviceManagerClient; +import com.google.cloud.iot.v1.DeviceRegistry; +import com.google.cloud.iot.v1.UpdateDeviceRegistryRequest; +import com.google.protobuf.FieldMask; + +public class SyncUpdateDeviceRegistry { + + public static void main(String[] args) throws Exception { + syncUpdateDeviceRegistry(); + } + + public static void syncUpdateDeviceRegistry() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (DeviceManagerClient deviceManagerClient = DeviceManagerClient.create()) { + UpdateDeviceRegistryRequest request = + UpdateDeviceRegistryRequest.newBuilder() + .setDeviceRegistry(DeviceRegistry.newBuilder().build()) + .setUpdateMask(FieldMask.newBuilder().build()) + .build(); + DeviceRegistry response = deviceManagerClient.updateDeviceRegistry(request); + } + } +} +// [END iot_v1_generated_devicemanagerclient_updatedeviceregistry_sync] diff --git a/java-iot/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/updatedeviceregistry/SyncUpdateDeviceRegistryDeviceregistryFieldmask.java b/java-iot/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/updatedeviceregistry/SyncUpdateDeviceRegistryDeviceregistryFieldmask.java new file mode 100644 index 000000000000..8ba608c95268 --- /dev/null +++ b/java-iot/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/updatedeviceregistry/SyncUpdateDeviceRegistryDeviceregistryFieldmask.java @@ -0,0 +1,41 @@ +/* + * Copyright 2022 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 + * + * https://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. + */ + +package com.google.cloud.iot.v1.samples; + +// [START iot_v1_generated_devicemanagerclient_updatedeviceregistry_deviceregistryfieldmask_sync] +import com.google.cloud.iot.v1.DeviceManagerClient; +import com.google.cloud.iot.v1.DeviceRegistry; +import com.google.protobuf.FieldMask; + +public class SyncUpdateDeviceRegistryDeviceregistryFieldmask { + + public static void main(String[] args) throws Exception { + syncUpdateDeviceRegistryDeviceregistryFieldmask(); + } + + public static void syncUpdateDeviceRegistryDeviceregistryFieldmask() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (DeviceManagerClient deviceManagerClient = DeviceManagerClient.create()) { + DeviceRegistry deviceRegistry = DeviceRegistry.newBuilder().build(); + FieldMask updateMask = FieldMask.newBuilder().build(); + DeviceRegistry response = + deviceManagerClient.updateDeviceRegistry(deviceRegistry, updateMask); + } + } +} +// [END iot_v1_generated_devicemanagerclient_updatedeviceregistry_deviceregistryfieldmask_sync] diff --git a/java-iot/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagersettings/createdeviceregistry/SyncCreateDeviceRegistry.java b/java-iot/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagersettings/createdeviceregistry/SyncCreateDeviceRegistry.java new file mode 100644 index 000000000000..3090bcb1b769 --- /dev/null +++ b/java-iot/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagersettings/createdeviceregistry/SyncCreateDeviceRegistry.java @@ -0,0 +1,45 @@ +/* + * Copyright 2022 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 + * + * https://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. + */ + +package com.google.cloud.iot.v1.samples; + +// [START iot_v1_generated_devicemanagersettings_createdeviceregistry_sync] +import com.google.cloud.iot.v1.DeviceManagerSettings; +import java.time.Duration; + +public class SyncCreateDeviceRegistry { + + public static void main(String[] args) throws Exception { + syncCreateDeviceRegistry(); + } + + public static void syncCreateDeviceRegistry() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + DeviceManagerSettings.Builder deviceManagerSettingsBuilder = DeviceManagerSettings.newBuilder(); + deviceManagerSettingsBuilder + .createDeviceRegistrySettings() + .setRetrySettings( + deviceManagerSettingsBuilder + .createDeviceRegistrySettings() + .getRetrySettings() + .toBuilder() + .setTotalTimeout(Duration.ofSeconds(30)) + .build()); + DeviceManagerSettings deviceManagerSettings = deviceManagerSettingsBuilder.build(); + } +} +// [END iot_v1_generated_devicemanagersettings_createdeviceregistry_sync] diff --git a/java-iot/samples/snippets/generated/com/google/cloud/iot/v1/stub/devicemanagerstubsettings/createdeviceregistry/SyncCreateDeviceRegistry.java b/java-iot/samples/snippets/generated/com/google/cloud/iot/v1/stub/devicemanagerstubsettings/createdeviceregistry/SyncCreateDeviceRegistry.java new file mode 100644 index 000000000000..acfb964956c4 --- /dev/null +++ b/java-iot/samples/snippets/generated/com/google/cloud/iot/v1/stub/devicemanagerstubsettings/createdeviceregistry/SyncCreateDeviceRegistry.java @@ -0,0 +1,46 @@ +/* + * Copyright 2022 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 + * + * https://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. + */ + +package com.google.cloud.iot.v1.stub.samples; + +// [START iot_v1_generated_devicemanagerstubsettings_createdeviceregistry_sync] +import com.google.cloud.iot.v1.stub.DeviceManagerStubSettings; +import java.time.Duration; + +public class SyncCreateDeviceRegistry { + + public static void main(String[] args) throws Exception { + syncCreateDeviceRegistry(); + } + + public static void syncCreateDeviceRegistry() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + DeviceManagerStubSettings.Builder deviceManagerSettingsBuilder = + DeviceManagerStubSettings.newBuilder(); + deviceManagerSettingsBuilder + .createDeviceRegistrySettings() + .setRetrySettings( + deviceManagerSettingsBuilder + .createDeviceRegistrySettings() + .getRetrySettings() + .toBuilder() + .setTotalTimeout(Duration.ofSeconds(30)) + .build()); + DeviceManagerStubSettings deviceManagerSettings = deviceManagerSettingsBuilder.build(); + } +} +// [END iot_v1_generated_devicemanagerstubsettings_createdeviceregistry_sync]