From 070cb11bc2ddce8c90bf120e39fcadd521b7b4da Mon Sep 17 00:00:00 2001 From: RashmiK14 Date: Fri, 21 Oct 2022 21:13:01 +0530 Subject: [PATCH 001/151] Initial Commit --- .kokoro/build.bat | 18 - .kokoro/build.sh | 134 - .kokoro/coerce_logs.sh | 37 - .kokoro/common.cfg | 13 - .kokoro/common.sh | 60 - .kokoro/continuous/common.cfg | 25 - .kokoro/continuous/java8.cfg | 12 - .kokoro/continuous/propose_release.sh | 29 - .kokoro/dependencies.sh | 110 - .kokoro/nightly/common.cfg | 25 - .kokoro/nightly/integration.cfg | 37 - .kokoro/nightly/java11-integration.cfg | 37 - .kokoro/nightly/java11.cfg | 7 - .kokoro/nightly/java7.cfg | 7 - .kokoro/nightly/java8-osx.cfg | 3 - .kokoro/nightly/java8-win.cfg | 3 - .kokoro/nightly/java8.cfg | 12 - .kokoro/nightly/samples.cfg | 38 - .kokoro/populate-secrets.sh | 43 - .kokoro/presubmit/clirr.cfg | 13 - .kokoro/presubmit/common.cfg | 34 - .kokoro/presubmit/dependencies.cfg | 12 - .kokoro/presubmit/graalvm-native-17.cfg | 33 - .kokoro/presubmit/graalvm-native.cfg | 33 - .kokoro/presubmit/integration.cfg | 33 - .kokoro/presubmit/java11.cfg | 7 - .kokoro/presubmit/java7.cfg | 7 - .kokoro/presubmit/java8-osx.cfg | 3 - .kokoro/presubmit/java8-win.cfg | 3 - .kokoro/presubmit/java8.cfg | 12 - .kokoro/presubmit/linkage-monitor.cfg | 12 - .kokoro/presubmit/lint.cfg | 13 - .kokoro/presubmit/samples.cfg | 33 - .kokoro/readme.sh | 45 - .kokoro/release/bump_snapshot.cfg | 53 - .kokoro/release/bump_snapshot.sh | 30 - .kokoro/release/common.cfg | 49 - .kokoro/release/common.sh | 50 - .kokoro/release/drop.cfg | 6 - .kokoro/release/drop.sh | 32 - .kokoro/release/promote.cfg | 6 - .kokoro/release/promote.sh | 34 - .kokoro/release/publish_javadoc.cfg | 23 - .kokoro/release/publish_javadoc.sh | 53 - .kokoro/release/publish_javadoc11.cfg | 30 - .kokoro/release/publish_javadoc11.sh | 63 - .kokoro/release/snapshot.cfg | 6 - .kokoro/release/snapshot.sh | 33 - .kokoro/release/stage.cfg | 19 - .kokoro/release/stage.sh | 47 - .kokoro/requirements.in | 31 - .kokoro/requirements.txt | 452 -- .kokoro/trampoline.sh | 26 - .repo-metadata.json | 17 - CHANGELOG.md | 494 -- CODE_OF_CONDUCT.md | 94 - CONTRIBUTING.md | 92 - LICENSE | 201 - README.md | 225 - SECURITY.md | 7 - .../cloud/iot/v1/DeviceManagerClient.class | Bin 0 -> 2324 bytes .../SendCommandToDeviceRequest$Builder.class | Bin 0 -> 1358 bytes .../iot/v1/SendCommandToDeviceRequest.class | Bin 0 -> 1184 bytes .../SendCommandToDeviceResponse$Builder.class | Bin 0 -> 1179 bytes .../iot/v1/SendCommandToDeviceResponse.class | Bin 0 -> 4812 bytes .../iot/v1/SyncSendCommandToDevice.class | Bin 0 -> 2914 bytes .../cloud/iot/v1/utils/Constants.class | Bin 0 -> 2696 bytes .../iot/v1/utils/DeviceName$Builder.class | Bin 0 -> 1792 bytes .../cloud/iot/v1/utils/DeviceName.class | Bin 0 -> 2275 bytes .../cloud/iot/v1/SyncSendCommandToDevice.java | 27 + .../cloud/iot/v1/DeviceManagerClient.java | 44 + .../iot/v1/SendCommandToDeviceRequest.java | 55 + .../iot/v1/SendCommandToDeviceResponse.java | 129 + .../cloud/iot/v1/utils/Constants.java | 73 + .../cloud/iot/v1/utils/DeviceName.java | 123 + codecov.yaml | 4 - google-cloud-iot-bom/pom.xml | 81 - google-cloud-iot/pom.xml | 135 - .../cloud/iot/v1/DeviceManagerClient.java | 2934 ---------- .../cloud/iot/v1/DeviceManagerSettings.java | 427 -- .../google/cloud/iot/v1/gapic_metadata.json | 75 - .../com/google/cloud/iot/v1/package-info.java | 43 - .../cloud/iot/v1/stub/DeviceManagerStub.java | 162 - .../v1/stub/DeviceManagerStubSettings.java | 980 ---- .../GrpcDeviceManagerCallableFactory.java | 113 - .../iot/v1/stub/GrpcDeviceManagerStub.java | 791 --- .../HttpJsonDeviceManagerCallableFactory.java | 105 - .../v1/stub/HttpJsonDeviceManagerStub.java | 1250 ---- .../v1/DeviceManagerClientHttpJsonTest.java | 2008 ------- .../cloud/iot/v1/DeviceManagerClientTest.java | 1752 ------ .../cloud/iot/v1/MockDeviceManager.java | 59 - .../cloud/iot/v1/MockDeviceManagerImpl.java | 465 -- .../google/cloud/iot/v1/it/ITSystemTest.java | 178 - grpc-google-cloud-iot-v1/pom.xml | 69 - .../cloud/iot/v1/DeviceManagerGrpc.java | 2533 -------- java.header | 15 - license-checks.xml | 10 - owlbot.py | 24 - pom.xml | 187 - .../clirr-ignored-differences.xml | 19 - proto-google-cloud-iot-v1/pom.xml | 46 - .../iot/v1/BindDeviceToGatewayRequest.java | 1013 ---- .../BindDeviceToGatewayRequestOrBuilder.java | 112 - .../iot/v1/BindDeviceToGatewayResponse.java | 436 -- .../BindDeviceToGatewayResponseOrBuilder.java | 24 - .../iot/v1/CreateDeviceRegistryRequest.java | 952 --- .../CreateDeviceRegistryRequestOrBuilder.java | 103 - .../cloud/iot/v1/CreateDeviceRequest.java | 934 --- .../iot/v1/CreateDeviceRequestOrBuilder.java | 99 - .../iot/v1/DeleteDeviceRegistryRequest.java | 636 -- .../DeleteDeviceRegistryRequestOrBuilder.java | 56 - .../cloud/iot/v1/DeleteDeviceRequest.java | 642 --- .../iot/v1/DeleteDeviceRequestOrBuilder.java | 58 - .../java/com/google/cloud/iot/v1/Device.java | 5113 ----------------- .../com/google/cloud/iot/v1/DeviceConfig.java | 1273 ---- .../cloud/iot/v1/DeviceConfigOrBuilder.java | 151 - .../google/cloud/iot/v1/DeviceCredential.java | 1218 ---- .../iot/v1/DeviceCredentialOrBuilder.java | 133 - .../cloud/iot/v1/DeviceManagerProto.java | 568 -- .../com/google/cloud/iot/v1/DeviceName.java | 257 - .../google/cloud/iot/v1/DeviceOrBuilder.java | 735 --- .../google/cloud/iot/v1/DeviceRegistry.java | 3240 ----------- .../cloud/iot/v1/DeviceRegistryOrBuilder.java | 421 -- .../com/google/cloud/iot/v1/DeviceState.java | 803 --- .../cloud/iot/v1/DeviceStateOrBuilder.java | 76 - .../cloud/iot/v1/EventNotificationConfig.java | 821 --- .../v1/EventNotificationConfigOrBuilder.java | 83 - .../cloud/iot/v1/GatewayAuthMethod.java | 211 - .../google/cloud/iot/v1/GatewayConfig.java | 1201 ---- .../cloud/iot/v1/GatewayConfigOrBuilder.java | 140 - .../cloud/iot/v1/GatewayListOptions.java | 1252 ---- .../iot/v1/GatewayListOptionsOrBuilder.java | 162 - .../com/google/cloud/iot/v1/GatewayType.java | 176 - .../iot/v1/GetDeviceRegistryRequest.java | 636 -- .../v1/GetDeviceRegistryRequestOrBuilder.java | 56 - .../google/cloud/iot/v1/GetDeviceRequest.java | 924 --- .../iot/v1/GetDeviceRequestOrBuilder.java | 99 - .../com/google/cloud/iot/v1/HttpConfig.java | 589 -- .../cloud/iot/v1/HttpConfigOrBuilder.java | 52 - .../com/google/cloud/iot/v1/HttpState.java | 179 - .../v1/ListDeviceConfigVersionsRequest.java | 744 --- ...tDeviceConfigVersionsRequestOrBuilder.java | 73 - .../v1/ListDeviceConfigVersionsResponse.java | 955 --- ...DeviceConfigVersionsResponseOrBuilder.java | 82 - .../iot/v1/ListDeviceRegistriesRequest.java | 931 --- .../ListDeviceRegistriesRequestOrBuilder.java | 101 - .../iot/v1/ListDeviceRegistriesResponse.java | 1123 ---- ...ListDeviceRegistriesResponseOrBuilder.java | 106 - .../cloud/iot/v1/ListDeviceStatesRequest.java | 742 --- .../v1/ListDeviceStatesRequestOrBuilder.java | 73 - .../iot/v1/ListDeviceStatesResponse.java | 949 --- .../v1/ListDeviceStatesResponseOrBuilder.java | 82 - .../cloud/iot/v1/ListDevicesRequest.java | 2027 ------- .../iot/v1/ListDevicesRequestOrBuilder.java | 276 - .../cloud/iot/v1/ListDevicesResponse.java | 1106 ---- .../iot/v1/ListDevicesResponseOrBuilder.java | 103 - .../com/google/cloud/iot/v1/LocationName.java | 192 - .../com/google/cloud/iot/v1/LogLevel.java | 226 - .../v1/ModifyCloudToDeviceConfigRequest.java | 847 --- ...fyCloudToDeviceConfigRequestOrBuilder.java | 88 - .../com/google/cloud/iot/v1/MqttConfig.java | 589 -- .../cloud/iot/v1/MqttConfigOrBuilder.java | 52 - .../com/google/cloud/iot/v1/MqttState.java | 177 - .../cloud/iot/v1/PublicKeyCertificate.java | 1041 ---- .../iot/v1/PublicKeyCertificateFormat.java | 163 - .../iot/v1/PublicKeyCertificateOrBuilder.java | 110 - .../cloud/iot/v1/PublicKeyCredential.java | 765 --- .../iot/v1/PublicKeyCredentialOrBuilder.java | 75 - .../google/cloud/iot/v1/PublicKeyFormat.java | 244 - .../cloud/iot/v1/RegistryCredential.java | 810 --- .../iot/v1/RegistryCredentialOrBuilder.java | 62 - .../com/google/cloud/iot/v1/RegistryName.java | 223 - .../google/cloud/iot/v1/ResourcesProto.java | 364 -- .../iot/v1/SendCommandToDeviceRequest.java | 944 --- .../SendCommandToDeviceRequestOrBuilder.java | 104 - .../iot/v1/SendCommandToDeviceResponse.java | 436 -- .../SendCommandToDeviceResponseOrBuilder.java | 24 - .../cloud/iot/v1/StateNotificationConfig.java | 622 -- .../v1/StateNotificationConfigOrBuilder.java | 52 - .../v1/UnbindDeviceFromGatewayRequest.java | 1015 ---- ...bindDeviceFromGatewayRequestOrBuilder.java | 112 - .../v1/UnbindDeviceFromGatewayResponse.java | 438 -- ...indDeviceFromGatewayResponseOrBuilder.java | 24 - .../iot/v1/UpdateDeviceRegistryRequest.java | 1075 ---- .../UpdateDeviceRegistryRequestOrBuilder.java | 122 - .../cloud/iot/v1/UpdateDeviceRequest.java | 1050 ---- .../iot/v1/UpdateDeviceRequestOrBuilder.java | 116 - .../cloud/iot/v1/X509CertificateDetails.java | 1670 ------ .../v1/X509CertificateDetailsOrBuilder.java | 195 - .../google/cloud/iot/v1/device_manager.proto | 651 --- .../proto/google/cloud/iot/v1/resources.proto | 483 -- renovate.json | 75 - samples/install-without-bom/pom.xml | 84 - samples/pom.xml | 56 - samples/snapshot/pom.xml | 83 - .../AsyncBindDeviceToGateway.java | 52 - .../SyncBindDeviceToGateway.java | 48 - ...viceToGatewayRegistrynameStringString.java | 45 - ...BindDeviceToGatewayStringStringString.java | 45 - .../SyncCreateSetCredentialsProvider.java | 44 - .../SyncCreateSetCredentialsProvider1.java | 43 - .../create/SyncCreateSetEndpoint.java | 41 - .../createdevice/AsyncCreateDevice.java | 50 - .../createdevice/SyncCreateDevice.java | 47 - .../SyncCreateDeviceRegistrynameDevice.java | 43 - .../SyncCreateDeviceStringDevice.java | 43 - .../AsyncCreateDeviceRegistry.java | 51 - .../SyncCreateDeviceRegistry.java | 47 - ...iceRegistryLocationnameDeviceregistry.java | 43 - ...ateDeviceRegistryStringDeviceregistry.java | 43 - .../deletedevice/AsyncDeleteDevice.java | 50 - .../deletedevice/SyncDeleteDevice.java | 47 - .../SyncDeleteDeviceDevicename.java | 42 - .../deletedevice/SyncDeleteDeviceString.java | 42 - .../AsyncDeleteDeviceRegistry.java | 50 - .../SyncDeleteDeviceRegistry.java | 46 - .../SyncDeleteDeviceRegistryRegistryname.java | 42 - .../SyncDeleteDeviceRegistryString.java | 42 - .../getdevice/AsyncGetDevice.java | 52 - .../getdevice/SyncGetDevice.java | 49 - .../getdevice/SyncGetDeviceDevicename.java | 42 - .../getdevice/SyncGetDeviceString.java | 42 - .../AsyncGetDeviceRegistry.java | 50 - .../SyncGetDeviceRegistry.java | 46 - .../SyncGetDeviceRegistryRegistryname.java | 42 - .../SyncGetDeviceRegistryString.java | 42 - .../getiampolicy/AsyncGetIamPolicy.java | 51 - .../getiampolicy/SyncGetIamPolicy.java | 48 - .../SyncGetIamPolicyResourcename.java | 43 - .../getiampolicy/SyncGetIamPolicyString.java | 43 - .../AsyncListDeviceConfigVersions.java | 52 - .../SyncListDeviceConfigVersions.java | 49 - ...yncListDeviceConfigVersionsDevicename.java | 43 - .../SyncListDeviceConfigVersionsString.java | 43 - .../AsyncListDeviceRegistries.java | 54 - .../AsyncListDeviceRegistriesPaged.java | 62 - .../SyncListDeviceRegistries.java | 51 - .../SyncListDeviceRegistriesLocationname.java | 44 - .../SyncListDeviceRegistriesString.java | 44 - .../listdevices/AsyncListDevices.java | 60 - .../listdevices/AsyncListDevicesPaged.java | 68 - .../listdevices/SyncListDevices.java | 57 - .../SyncListDevicesRegistryname.java | 44 - .../listdevices/SyncListDevicesString.java | 44 - .../AsyncListDeviceStates.java | 52 - .../SyncListDeviceStates.java | 48 - .../SyncListDeviceStatesDevicename.java | 42 - .../SyncListDeviceStatesString.java | 42 - .../AsyncModifyCloudToDeviceConfig.java | 54 - .../SyncModifyCloudToDeviceConfig.java | 50 - ...oudToDeviceConfigDevicenameBytestring.java | 44 - ...fyCloudToDeviceConfigStringBytestring.java | 44 - .../AsyncSendCommandToDevice.java | 54 - .../SyncSendCommandToDevice.java | 50 - ...ndCommandToDeviceDevicenameBytestring.java | 45 - ...andToDeviceDevicenameBytestringString.java | 46 - ...ncSendCommandToDeviceStringBytestring.java | 45 - ...CommandToDeviceStringBytestringString.java | 46 - .../setiampolicy/AsyncSetIamPolicy.java | 52 - .../setiampolicy/SyncSetIamPolicy.java | 49 - .../SyncSetIamPolicyResourcenamePolicy.java | 44 - .../SyncSetIamPolicyStringPolicy.java | 44 - .../AsyncTestIamPermissions.java | 52 - .../SyncTestIamPermissions.java | 48 - ...tIamPermissionsResourcenameListstring.java | 47 - ...yncTestIamPermissionsStringListstring.java | 47 - .../AsyncUnbindDeviceFromGateway.java | 52 - .../SyncUnbindDeviceFromGateway.java | 49 - ...ceFromGatewayRegistrynameStringString.java | 45 - ...ndDeviceFromGatewayStringStringString.java | 45 - .../updatedevice/AsyncUpdateDevice.java | 50 - .../updatedevice/SyncUpdateDevice.java | 47 - .../SyncUpdateDeviceDeviceFieldmask.java | 43 - .../AsyncUpdateDeviceRegistry.java | 51 - .../SyncUpdateDeviceRegistry.java | 47 - ...DeviceRegistryDeviceregistryFieldmask.java | 44 - .../SyncCreateDeviceRegistry.java | 48 - .../SyncCreateDeviceRegistry.java | 49 - samples/snippets/pom.xml | 60 - synth.metadata | 214 - versions.txt | 6 - 281 files changed, 451 insertions(+), 72353 deletions(-) delete mode 100644 .kokoro/build.bat delete mode 100755 .kokoro/build.sh delete mode 100755 .kokoro/coerce_logs.sh delete mode 100644 .kokoro/common.cfg delete mode 100644 .kokoro/common.sh delete mode 100644 .kokoro/continuous/common.cfg delete mode 100644 .kokoro/continuous/java8.cfg delete mode 100755 .kokoro/continuous/propose_release.sh delete mode 100755 .kokoro/dependencies.sh delete mode 100644 .kokoro/nightly/common.cfg delete mode 100644 .kokoro/nightly/integration.cfg delete mode 100644 .kokoro/nightly/java11-integration.cfg delete mode 100644 .kokoro/nightly/java11.cfg delete mode 100644 .kokoro/nightly/java7.cfg delete mode 100644 .kokoro/nightly/java8-osx.cfg delete mode 100644 .kokoro/nightly/java8-win.cfg delete mode 100644 .kokoro/nightly/java8.cfg delete mode 100644 .kokoro/nightly/samples.cfg delete mode 100755 .kokoro/populate-secrets.sh delete mode 100644 .kokoro/presubmit/clirr.cfg delete mode 100644 .kokoro/presubmit/common.cfg delete mode 100644 .kokoro/presubmit/dependencies.cfg delete mode 100644 .kokoro/presubmit/graalvm-native-17.cfg delete mode 100644 .kokoro/presubmit/graalvm-native.cfg delete mode 100644 .kokoro/presubmit/integration.cfg delete mode 100644 .kokoro/presubmit/java11.cfg delete mode 100644 .kokoro/presubmit/java7.cfg delete mode 100644 .kokoro/presubmit/java8-osx.cfg delete mode 100644 .kokoro/presubmit/java8-win.cfg delete mode 100644 .kokoro/presubmit/java8.cfg delete mode 100644 .kokoro/presubmit/linkage-monitor.cfg delete mode 100644 .kokoro/presubmit/lint.cfg delete mode 100644 .kokoro/presubmit/samples.cfg delete mode 100755 .kokoro/readme.sh delete mode 100644 .kokoro/release/bump_snapshot.cfg delete mode 100755 .kokoro/release/bump_snapshot.sh delete mode 100644 .kokoro/release/common.cfg delete mode 100755 .kokoro/release/common.sh delete mode 100644 .kokoro/release/drop.cfg delete mode 100755 .kokoro/release/drop.sh delete mode 100644 .kokoro/release/promote.cfg delete mode 100755 .kokoro/release/promote.sh delete mode 100644 .kokoro/release/publish_javadoc.cfg delete mode 100755 .kokoro/release/publish_javadoc.sh delete mode 100644 .kokoro/release/publish_javadoc11.cfg delete mode 100755 .kokoro/release/publish_javadoc11.sh delete mode 100644 .kokoro/release/snapshot.cfg delete mode 100755 .kokoro/release/snapshot.sh delete mode 100644 .kokoro/release/stage.cfg delete mode 100755 .kokoro/release/stage.sh delete mode 100644 .kokoro/requirements.in delete mode 100644 .kokoro/requirements.txt delete mode 100644 .kokoro/trampoline.sh delete mode 100644 .repo-metadata.json delete mode 100644 CHANGELOG.md delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 LICENSE delete mode 100644 README.md delete mode 100644 SECURITY.md create mode 100644 clearblade-cloud-iot/bin/com/clearblade/cloud/iot/v1/DeviceManagerClient.class create mode 100644 clearblade-cloud-iot/bin/com/clearblade/cloud/iot/v1/SendCommandToDeviceRequest$Builder.class create mode 100644 clearblade-cloud-iot/bin/com/clearblade/cloud/iot/v1/SendCommandToDeviceRequest.class create mode 100644 clearblade-cloud-iot/bin/com/clearblade/cloud/iot/v1/SendCommandToDeviceResponse$Builder.class create mode 100644 clearblade-cloud-iot/bin/com/clearblade/cloud/iot/v1/SendCommandToDeviceResponse.class create mode 100644 clearblade-cloud-iot/bin/com/clearblade/cloud/iot/v1/SyncSendCommandToDevice.class create mode 100644 clearblade-cloud-iot/bin/com/clearblade/cloud/iot/v1/utils/Constants.class create mode 100644 clearblade-cloud-iot/bin/com/clearblade/cloud/iot/v1/utils/DeviceName$Builder.class create mode 100644 clearblade-cloud-iot/bin/com/clearblade/cloud/iot/v1/utils/DeviceName.class create mode 100644 clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/SyncSendCommandToDevice.java create mode 100644 clearblade-cloud-iot/src/main/java/com/clearblade/cloud/iot/v1/DeviceManagerClient.java create mode 100644 clearblade-cloud-iot/src/main/java/com/clearblade/cloud/iot/v1/SendCommandToDeviceRequest.java create mode 100644 clearblade-cloud-iot/src/main/java/com/clearblade/cloud/iot/v1/SendCommandToDeviceResponse.java create mode 100644 clearblade-cloud-iot/src/main/java/com/clearblade/cloud/iot/v1/utils/Constants.java create mode 100644 clearblade-cloud-iot/src/main/java/com/clearblade/cloud/iot/v1/utils/DeviceName.java delete mode 100644 codecov.yaml delete mode 100644 google-cloud-iot-bom/pom.xml delete mode 100644 google-cloud-iot/pom.xml delete mode 100644 google-cloud-iot/src/main/java/com/google/cloud/iot/v1/DeviceManagerClient.java delete mode 100644 google-cloud-iot/src/main/java/com/google/cloud/iot/v1/DeviceManagerSettings.java delete mode 100644 google-cloud-iot/src/main/java/com/google/cloud/iot/v1/gapic_metadata.json delete mode 100644 google-cloud-iot/src/main/java/com/google/cloud/iot/v1/package-info.java delete mode 100644 google-cloud-iot/src/main/java/com/google/cloud/iot/v1/stub/DeviceManagerStub.java delete mode 100644 google-cloud-iot/src/main/java/com/google/cloud/iot/v1/stub/DeviceManagerStubSettings.java delete mode 100644 google-cloud-iot/src/main/java/com/google/cloud/iot/v1/stub/GrpcDeviceManagerCallableFactory.java delete mode 100644 google-cloud-iot/src/main/java/com/google/cloud/iot/v1/stub/GrpcDeviceManagerStub.java delete mode 100644 google-cloud-iot/src/main/java/com/google/cloud/iot/v1/stub/HttpJsonDeviceManagerCallableFactory.java delete mode 100644 google-cloud-iot/src/main/java/com/google/cloud/iot/v1/stub/HttpJsonDeviceManagerStub.java delete mode 100644 google-cloud-iot/src/test/java/com/google/cloud/iot/v1/DeviceManagerClientHttpJsonTest.java delete mode 100644 google-cloud-iot/src/test/java/com/google/cloud/iot/v1/DeviceManagerClientTest.java delete mode 100644 google-cloud-iot/src/test/java/com/google/cloud/iot/v1/MockDeviceManager.java delete mode 100644 google-cloud-iot/src/test/java/com/google/cloud/iot/v1/MockDeviceManagerImpl.java delete mode 100644 google-cloud-iot/src/test/java/com/google/cloud/iot/v1/it/ITSystemTest.java delete mode 100644 grpc-google-cloud-iot-v1/pom.xml delete mode 100644 grpc-google-cloud-iot-v1/src/main/java/com/google/cloud/iot/v1/DeviceManagerGrpc.java delete mode 100644 java.header delete mode 100644 license-checks.xml delete mode 100644 owlbot.py delete mode 100644 pom.xml delete mode 100644 proto-google-cloud-iot-v1/clirr-ignored-differences.xml delete mode 100644 proto-google-cloud-iot-v1/pom.xml delete mode 100644 proto-google-cloud-iot-v1/src/main/java/com/google/cloud/iot/v1/BindDeviceToGatewayRequest.java delete mode 100644 proto-google-cloud-iot-v1/src/main/java/com/google/cloud/iot/v1/BindDeviceToGatewayRequestOrBuilder.java delete mode 100644 proto-google-cloud-iot-v1/src/main/java/com/google/cloud/iot/v1/BindDeviceToGatewayResponse.java delete mode 100644 proto-google-cloud-iot-v1/src/main/java/com/google/cloud/iot/v1/BindDeviceToGatewayResponseOrBuilder.java delete mode 100644 proto-google-cloud-iot-v1/src/main/java/com/google/cloud/iot/v1/CreateDeviceRegistryRequest.java delete mode 100644 proto-google-cloud-iot-v1/src/main/java/com/google/cloud/iot/v1/CreateDeviceRegistryRequestOrBuilder.java delete mode 100644 proto-google-cloud-iot-v1/src/main/java/com/google/cloud/iot/v1/CreateDeviceRequest.java delete mode 100644 proto-google-cloud-iot-v1/src/main/java/com/google/cloud/iot/v1/CreateDeviceRequestOrBuilder.java delete mode 100644 proto-google-cloud-iot-v1/src/main/java/com/google/cloud/iot/v1/DeleteDeviceRegistryRequest.java delete mode 100644 proto-google-cloud-iot-v1/src/main/java/com/google/cloud/iot/v1/DeleteDeviceRegistryRequestOrBuilder.java delete mode 100644 proto-google-cloud-iot-v1/src/main/java/com/google/cloud/iot/v1/DeleteDeviceRequest.java delete mode 100644 proto-google-cloud-iot-v1/src/main/java/com/google/cloud/iot/v1/DeleteDeviceRequestOrBuilder.java delete mode 100644 proto-google-cloud-iot-v1/src/main/java/com/google/cloud/iot/v1/Device.java delete mode 100644 proto-google-cloud-iot-v1/src/main/java/com/google/cloud/iot/v1/DeviceConfig.java delete mode 100644 proto-google-cloud-iot-v1/src/main/java/com/google/cloud/iot/v1/DeviceConfigOrBuilder.java delete mode 100644 proto-google-cloud-iot-v1/src/main/java/com/google/cloud/iot/v1/DeviceCredential.java delete mode 100644 proto-google-cloud-iot-v1/src/main/java/com/google/cloud/iot/v1/DeviceCredentialOrBuilder.java delete mode 100644 proto-google-cloud-iot-v1/src/main/java/com/google/cloud/iot/v1/DeviceManagerProto.java delete mode 100644 proto-google-cloud-iot-v1/src/main/java/com/google/cloud/iot/v1/DeviceName.java delete mode 100644 proto-google-cloud-iot-v1/src/main/java/com/google/cloud/iot/v1/DeviceOrBuilder.java delete mode 100644 proto-google-cloud-iot-v1/src/main/java/com/google/cloud/iot/v1/DeviceRegistry.java delete mode 100644 proto-google-cloud-iot-v1/src/main/java/com/google/cloud/iot/v1/DeviceRegistryOrBuilder.java delete mode 100644 proto-google-cloud-iot-v1/src/main/java/com/google/cloud/iot/v1/DeviceState.java delete mode 100644 proto-google-cloud-iot-v1/src/main/java/com/google/cloud/iot/v1/DeviceStateOrBuilder.java delete mode 100644 proto-google-cloud-iot-v1/src/main/java/com/google/cloud/iot/v1/EventNotificationConfig.java delete mode 100644 proto-google-cloud-iot-v1/src/main/java/com/google/cloud/iot/v1/EventNotificationConfigOrBuilder.java delete mode 100644 proto-google-cloud-iot-v1/src/main/java/com/google/cloud/iot/v1/GatewayAuthMethod.java delete mode 100644 proto-google-cloud-iot-v1/src/main/java/com/google/cloud/iot/v1/GatewayConfig.java delete mode 100644 proto-google-cloud-iot-v1/src/main/java/com/google/cloud/iot/v1/GatewayConfigOrBuilder.java delete mode 100644 proto-google-cloud-iot-v1/src/main/java/com/google/cloud/iot/v1/GatewayListOptions.java delete mode 100644 proto-google-cloud-iot-v1/src/main/java/com/google/cloud/iot/v1/GatewayListOptionsOrBuilder.java delete mode 100644 proto-google-cloud-iot-v1/src/main/java/com/google/cloud/iot/v1/GatewayType.java delete mode 100644 proto-google-cloud-iot-v1/src/main/java/com/google/cloud/iot/v1/GetDeviceRegistryRequest.java delete mode 100644 proto-google-cloud-iot-v1/src/main/java/com/google/cloud/iot/v1/GetDeviceRegistryRequestOrBuilder.java delete mode 100644 proto-google-cloud-iot-v1/src/main/java/com/google/cloud/iot/v1/GetDeviceRequest.java delete mode 100644 proto-google-cloud-iot-v1/src/main/java/com/google/cloud/iot/v1/GetDeviceRequestOrBuilder.java delete mode 100644 proto-google-cloud-iot-v1/src/main/java/com/google/cloud/iot/v1/HttpConfig.java delete mode 100644 proto-google-cloud-iot-v1/src/main/java/com/google/cloud/iot/v1/HttpConfigOrBuilder.java delete mode 100644 proto-google-cloud-iot-v1/src/main/java/com/google/cloud/iot/v1/HttpState.java delete mode 100644 proto-google-cloud-iot-v1/src/main/java/com/google/cloud/iot/v1/ListDeviceConfigVersionsRequest.java delete mode 100644 proto-google-cloud-iot-v1/src/main/java/com/google/cloud/iot/v1/ListDeviceConfigVersionsRequestOrBuilder.java delete mode 100644 proto-google-cloud-iot-v1/src/main/java/com/google/cloud/iot/v1/ListDeviceConfigVersionsResponse.java delete mode 100644 proto-google-cloud-iot-v1/src/main/java/com/google/cloud/iot/v1/ListDeviceConfigVersionsResponseOrBuilder.java delete mode 100644 proto-google-cloud-iot-v1/src/main/java/com/google/cloud/iot/v1/ListDeviceRegistriesRequest.java delete mode 100644 proto-google-cloud-iot-v1/src/main/java/com/google/cloud/iot/v1/ListDeviceRegistriesRequestOrBuilder.java delete mode 100644 proto-google-cloud-iot-v1/src/main/java/com/google/cloud/iot/v1/ListDeviceRegistriesResponse.java delete mode 100644 proto-google-cloud-iot-v1/src/main/java/com/google/cloud/iot/v1/ListDeviceRegistriesResponseOrBuilder.java delete mode 100644 proto-google-cloud-iot-v1/src/main/java/com/google/cloud/iot/v1/ListDeviceStatesRequest.java delete mode 100644 proto-google-cloud-iot-v1/src/main/java/com/google/cloud/iot/v1/ListDeviceStatesRequestOrBuilder.java delete mode 100644 proto-google-cloud-iot-v1/src/main/java/com/google/cloud/iot/v1/ListDeviceStatesResponse.java delete mode 100644 proto-google-cloud-iot-v1/src/main/java/com/google/cloud/iot/v1/ListDeviceStatesResponseOrBuilder.java delete mode 100644 proto-google-cloud-iot-v1/src/main/java/com/google/cloud/iot/v1/ListDevicesRequest.java delete mode 100644 proto-google-cloud-iot-v1/src/main/java/com/google/cloud/iot/v1/ListDevicesRequestOrBuilder.java delete mode 100644 proto-google-cloud-iot-v1/src/main/java/com/google/cloud/iot/v1/ListDevicesResponse.java delete mode 100644 proto-google-cloud-iot-v1/src/main/java/com/google/cloud/iot/v1/ListDevicesResponseOrBuilder.java delete mode 100644 proto-google-cloud-iot-v1/src/main/java/com/google/cloud/iot/v1/LocationName.java delete mode 100644 proto-google-cloud-iot-v1/src/main/java/com/google/cloud/iot/v1/LogLevel.java delete mode 100644 proto-google-cloud-iot-v1/src/main/java/com/google/cloud/iot/v1/ModifyCloudToDeviceConfigRequest.java delete mode 100644 proto-google-cloud-iot-v1/src/main/java/com/google/cloud/iot/v1/ModifyCloudToDeviceConfigRequestOrBuilder.java delete mode 100644 proto-google-cloud-iot-v1/src/main/java/com/google/cloud/iot/v1/MqttConfig.java delete mode 100644 proto-google-cloud-iot-v1/src/main/java/com/google/cloud/iot/v1/MqttConfigOrBuilder.java delete mode 100644 proto-google-cloud-iot-v1/src/main/java/com/google/cloud/iot/v1/MqttState.java delete mode 100644 proto-google-cloud-iot-v1/src/main/java/com/google/cloud/iot/v1/PublicKeyCertificate.java delete mode 100644 proto-google-cloud-iot-v1/src/main/java/com/google/cloud/iot/v1/PublicKeyCertificateFormat.java delete mode 100644 proto-google-cloud-iot-v1/src/main/java/com/google/cloud/iot/v1/PublicKeyCertificateOrBuilder.java delete mode 100644 proto-google-cloud-iot-v1/src/main/java/com/google/cloud/iot/v1/PublicKeyCredential.java delete mode 100644 proto-google-cloud-iot-v1/src/main/java/com/google/cloud/iot/v1/PublicKeyCredentialOrBuilder.java delete mode 100644 proto-google-cloud-iot-v1/src/main/java/com/google/cloud/iot/v1/PublicKeyFormat.java delete mode 100644 proto-google-cloud-iot-v1/src/main/java/com/google/cloud/iot/v1/RegistryCredential.java delete mode 100644 proto-google-cloud-iot-v1/src/main/java/com/google/cloud/iot/v1/RegistryCredentialOrBuilder.java delete mode 100644 proto-google-cloud-iot-v1/src/main/java/com/google/cloud/iot/v1/RegistryName.java delete mode 100644 proto-google-cloud-iot-v1/src/main/java/com/google/cloud/iot/v1/ResourcesProto.java delete mode 100644 proto-google-cloud-iot-v1/src/main/java/com/google/cloud/iot/v1/SendCommandToDeviceRequest.java delete mode 100644 proto-google-cloud-iot-v1/src/main/java/com/google/cloud/iot/v1/SendCommandToDeviceRequestOrBuilder.java delete mode 100644 proto-google-cloud-iot-v1/src/main/java/com/google/cloud/iot/v1/SendCommandToDeviceResponse.java delete mode 100644 proto-google-cloud-iot-v1/src/main/java/com/google/cloud/iot/v1/SendCommandToDeviceResponseOrBuilder.java delete mode 100644 proto-google-cloud-iot-v1/src/main/java/com/google/cloud/iot/v1/StateNotificationConfig.java delete mode 100644 proto-google-cloud-iot-v1/src/main/java/com/google/cloud/iot/v1/StateNotificationConfigOrBuilder.java delete mode 100644 proto-google-cloud-iot-v1/src/main/java/com/google/cloud/iot/v1/UnbindDeviceFromGatewayRequest.java delete mode 100644 proto-google-cloud-iot-v1/src/main/java/com/google/cloud/iot/v1/UnbindDeviceFromGatewayRequestOrBuilder.java delete mode 100644 proto-google-cloud-iot-v1/src/main/java/com/google/cloud/iot/v1/UnbindDeviceFromGatewayResponse.java delete mode 100644 proto-google-cloud-iot-v1/src/main/java/com/google/cloud/iot/v1/UnbindDeviceFromGatewayResponseOrBuilder.java delete mode 100644 proto-google-cloud-iot-v1/src/main/java/com/google/cloud/iot/v1/UpdateDeviceRegistryRequest.java delete mode 100644 proto-google-cloud-iot-v1/src/main/java/com/google/cloud/iot/v1/UpdateDeviceRegistryRequestOrBuilder.java delete mode 100644 proto-google-cloud-iot-v1/src/main/java/com/google/cloud/iot/v1/UpdateDeviceRequest.java delete mode 100644 proto-google-cloud-iot-v1/src/main/java/com/google/cloud/iot/v1/UpdateDeviceRequestOrBuilder.java delete mode 100644 proto-google-cloud-iot-v1/src/main/java/com/google/cloud/iot/v1/X509CertificateDetails.java delete mode 100644 proto-google-cloud-iot-v1/src/main/java/com/google/cloud/iot/v1/X509CertificateDetailsOrBuilder.java delete mode 100644 proto-google-cloud-iot-v1/src/main/proto/google/cloud/iot/v1/device_manager.proto delete mode 100644 proto-google-cloud-iot-v1/src/main/proto/google/cloud/iot/v1/resources.proto delete mode 100644 renovate.json delete mode 100644 samples/install-without-bom/pom.xml delete mode 100644 samples/pom.xml delete mode 100644 samples/snapshot/pom.xml delete mode 100644 samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/binddevicetogateway/AsyncBindDeviceToGateway.java delete mode 100644 samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/binddevicetogateway/SyncBindDeviceToGateway.java delete mode 100644 samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/binddevicetogateway/SyncBindDeviceToGatewayRegistrynameStringString.java delete mode 100644 samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/binddevicetogateway/SyncBindDeviceToGatewayStringStringString.java delete mode 100644 samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/create/SyncCreateSetCredentialsProvider.java delete mode 100644 samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/create/SyncCreateSetCredentialsProvider1.java delete mode 100644 samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/create/SyncCreateSetEndpoint.java delete mode 100644 samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/createdevice/AsyncCreateDevice.java delete mode 100644 samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/createdevice/SyncCreateDevice.java delete mode 100644 samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/createdevice/SyncCreateDeviceRegistrynameDevice.java delete mode 100644 samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/createdevice/SyncCreateDeviceStringDevice.java delete mode 100644 samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/createdeviceregistry/AsyncCreateDeviceRegistry.java delete mode 100644 samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/createdeviceregistry/SyncCreateDeviceRegistry.java delete mode 100644 samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/createdeviceregistry/SyncCreateDeviceRegistryLocationnameDeviceregistry.java delete mode 100644 samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/createdeviceregistry/SyncCreateDeviceRegistryStringDeviceregistry.java delete mode 100644 samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/deletedevice/AsyncDeleteDevice.java delete mode 100644 samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/deletedevice/SyncDeleteDevice.java delete mode 100644 samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/deletedevice/SyncDeleteDeviceDevicename.java delete mode 100644 samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/deletedevice/SyncDeleteDeviceString.java delete mode 100644 samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/deletedeviceregistry/AsyncDeleteDeviceRegistry.java delete mode 100644 samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/deletedeviceregistry/SyncDeleteDeviceRegistry.java delete mode 100644 samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/deletedeviceregistry/SyncDeleteDeviceRegistryRegistryname.java delete mode 100644 samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/deletedeviceregistry/SyncDeleteDeviceRegistryString.java delete mode 100644 samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/getdevice/AsyncGetDevice.java delete mode 100644 samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/getdevice/SyncGetDevice.java delete mode 100644 samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/getdevice/SyncGetDeviceDevicename.java delete mode 100644 samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/getdevice/SyncGetDeviceString.java delete mode 100644 samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/getdeviceregistry/AsyncGetDeviceRegistry.java delete mode 100644 samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/getdeviceregistry/SyncGetDeviceRegistry.java delete mode 100644 samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/getdeviceregistry/SyncGetDeviceRegistryRegistryname.java delete mode 100644 samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/getdeviceregistry/SyncGetDeviceRegistryString.java delete mode 100644 samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/getiampolicy/AsyncGetIamPolicy.java delete mode 100644 samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/getiampolicy/SyncGetIamPolicy.java delete mode 100644 samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/getiampolicy/SyncGetIamPolicyResourcename.java delete mode 100644 samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/getiampolicy/SyncGetIamPolicyString.java delete mode 100644 samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/listdeviceconfigversions/AsyncListDeviceConfigVersions.java delete mode 100644 samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/listdeviceconfigversions/SyncListDeviceConfigVersions.java delete mode 100644 samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/listdeviceconfigversions/SyncListDeviceConfigVersionsDevicename.java delete mode 100644 samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/listdeviceconfigversions/SyncListDeviceConfigVersionsString.java delete mode 100644 samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/listdeviceregistries/AsyncListDeviceRegistries.java delete mode 100644 samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/listdeviceregistries/AsyncListDeviceRegistriesPaged.java delete mode 100644 samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/listdeviceregistries/SyncListDeviceRegistries.java delete mode 100644 samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/listdeviceregistries/SyncListDeviceRegistriesLocationname.java delete mode 100644 samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/listdeviceregistries/SyncListDeviceRegistriesString.java delete mode 100644 samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/listdevices/AsyncListDevices.java delete mode 100644 samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/listdevices/AsyncListDevicesPaged.java delete mode 100644 samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/listdevices/SyncListDevices.java delete mode 100644 samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/listdevices/SyncListDevicesRegistryname.java delete mode 100644 samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/listdevices/SyncListDevicesString.java delete mode 100644 samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/listdevicestates/AsyncListDeviceStates.java delete mode 100644 samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/listdevicestates/SyncListDeviceStates.java delete mode 100644 samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/listdevicestates/SyncListDeviceStatesDevicename.java delete mode 100644 samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/listdevicestates/SyncListDeviceStatesString.java delete mode 100644 samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/modifycloudtodeviceconfig/AsyncModifyCloudToDeviceConfig.java delete mode 100644 samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/modifycloudtodeviceconfig/SyncModifyCloudToDeviceConfig.java delete mode 100644 samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/modifycloudtodeviceconfig/SyncModifyCloudToDeviceConfigDevicenameBytestring.java delete mode 100644 samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/modifycloudtodeviceconfig/SyncModifyCloudToDeviceConfigStringBytestring.java delete mode 100644 samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/sendcommandtodevice/AsyncSendCommandToDevice.java delete mode 100644 samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/sendcommandtodevice/SyncSendCommandToDevice.java delete mode 100644 samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/sendcommandtodevice/SyncSendCommandToDeviceDevicenameBytestring.java delete mode 100644 samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/sendcommandtodevice/SyncSendCommandToDeviceDevicenameBytestringString.java delete mode 100644 samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/sendcommandtodevice/SyncSendCommandToDeviceStringBytestring.java delete mode 100644 samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/sendcommandtodevice/SyncSendCommandToDeviceStringBytestringString.java delete mode 100644 samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/setiampolicy/AsyncSetIamPolicy.java delete mode 100644 samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/setiampolicy/SyncSetIamPolicy.java delete mode 100644 samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/setiampolicy/SyncSetIamPolicyResourcenamePolicy.java delete mode 100644 samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/setiampolicy/SyncSetIamPolicyStringPolicy.java delete mode 100644 samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/testiampermissions/AsyncTestIamPermissions.java delete mode 100644 samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/testiampermissions/SyncTestIamPermissions.java delete mode 100644 samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/testiampermissions/SyncTestIamPermissionsResourcenameListstring.java delete mode 100644 samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/testiampermissions/SyncTestIamPermissionsStringListstring.java delete mode 100644 samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/unbinddevicefromgateway/AsyncUnbindDeviceFromGateway.java delete mode 100644 samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/unbinddevicefromgateway/SyncUnbindDeviceFromGateway.java delete mode 100644 samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/unbinddevicefromgateway/SyncUnbindDeviceFromGatewayRegistrynameStringString.java delete mode 100644 samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/unbinddevicefromgateway/SyncUnbindDeviceFromGatewayStringStringString.java delete mode 100644 samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/updatedevice/AsyncUpdateDevice.java delete mode 100644 samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/updatedevice/SyncUpdateDevice.java delete mode 100644 samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/updatedevice/SyncUpdateDeviceDeviceFieldmask.java delete mode 100644 samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/updatedeviceregistry/AsyncUpdateDeviceRegistry.java delete mode 100644 samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/updatedeviceregistry/SyncUpdateDeviceRegistry.java delete mode 100644 samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/updatedeviceregistry/SyncUpdateDeviceRegistryDeviceregistryFieldmask.java delete mode 100644 samples/snippets/generated/com/google/cloud/iot/v1/devicemanagersettings/createdeviceregistry/SyncCreateDeviceRegistry.java delete mode 100644 samples/snippets/generated/com/google/cloud/iot/v1/stub/devicemanagerstubsettings/createdeviceregistry/SyncCreateDeviceRegistry.java delete mode 100644 samples/snippets/pom.xml delete mode 100644 synth.metadata delete mode 100644 versions.txt diff --git a/.kokoro/build.bat b/.kokoro/build.bat deleted file mode 100644 index 067cf4a4..00000000 --- a/.kokoro/build.bat +++ /dev/null @@ -1,18 +0,0 @@ -:: 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 -:: -:: http://www.apache.org/licenses/LICENSE-2.0 -:: -:: Unless required by applicable law or agreed to in writing, software -:: distributed under the License is distributed on an "AS IS" BASIS, -:: WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -:: See the License for the specific language governing permissions and -:: limitations under the License. -:: Github action job to test core java library features on -:: downstream client libraries before they are released. -:: See documentation in type-shell-output.bat - -"C:\Program Files\Git\bin\bash.exe" %~dp0build.sh diff --git a/.kokoro/build.sh b/.kokoro/build.sh deleted file mode 100755 index 1927fe78..00000000 --- a/.kokoro/build.sh +++ /dev/null @@ -1,134 +0,0 @@ -#!/bin/bash -# Copyright 2019 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -set -eo pipefail - -## Get the directory of the build script -scriptDir=$(realpath $(dirname "${BASH_SOURCE[0]}")) -## cd to the parent directory, i.e. the root of the git repo -cd ${scriptDir}/.. - -# include common functions -source ${scriptDir}/common.sh - -# Print out Maven & Java version -mvn -version -echo ${JOB_TYPE} - -# attempt to install 3 times with exponential backoff (starting with 10 seconds) -retry_with_backoff 3 10 \ - mvn install -B -V -ntp \ - -DskipTests=true \ - -Dclirr.skip=true \ - -Denforcer.skip=true \ - -Dmaven.javadoc.skip=true \ - -Dgcloud.download.skip=true \ - -T 1C - -# if GOOGLE_APPLICATION_CREDENTIALS is specified as a relative path, prepend Kokoro root directory onto it -if [[ ! -z "${GOOGLE_APPLICATION_CREDENTIALS}" && "${GOOGLE_APPLICATION_CREDENTIALS}" != /* ]]; then - export GOOGLE_APPLICATION_CREDENTIALS=$(realpath ${KOKORO_GFILE_DIR}/${GOOGLE_APPLICATION_CREDENTIALS}) -fi - -RETURN_CODE=0 -set +e - -case ${JOB_TYPE} in -test) - mvn test -B -ntp -Dclirr.skip=true -Denforcer.skip=true - RETURN_CODE=$? - ;; -lint) - mvn com.coveo:fmt-maven-plugin:check -B -ntp - RETURN_CODE=$? - ;; -javadoc) - mvn javadoc:javadoc javadoc:test-javadoc -B -ntp - RETURN_CODE=$? - ;; -integration) - mvn -B ${INTEGRATION_TEST_ARGS} \ - -ntp \ - -Penable-integration-tests \ - -DtrimStackTrace=false \ - -Dclirr.skip=true \ - -Denforcer.skip=true \ - -fae \ - verify - RETURN_CODE=$? - ;; -graalvm) - # Run Unit and Integration Tests with Native Image - mvn -B ${INTEGRATION_TEST_ARGS} -ntp -Pnative -Penable-integration-tests test - RETURN_CODE=$? - ;; -graalvm17) - # Run Unit and Integration Tests with Native Image - mvn -B ${INTEGRATION_TEST_ARGS} -ntp -Pnative -Penable-integration-tests test - RETURN_CODE=$? - ;; -samples) - SAMPLES_DIR=samples - # only run ITs in snapshot/ on presubmit PRs. run ITs in all 3 samples/ subdirectories otherwise. - if [[ ! -z ${KOKORO_GITHUB_PULL_REQUEST_NUMBER} ]] - then - SAMPLES_DIR=samples/snapshot - fi - - if [[ -f ${SAMPLES_DIR}/pom.xml ]] - then - for FILE in ${KOKORO_GFILE_DIR}/secret_manager/*-samples-secrets; do - [[ -f "$FILE" ]] || continue - source "$FILE" - done - - pushd ${SAMPLES_DIR} - mvn -B \ - -ntp \ - -DtrimStackTrace=false \ - -Dclirr.skip=true \ - -Denforcer.skip=true \ - -fae \ - verify - RETURN_CODE=$? - popd - else - echo "no sample pom.xml found - skipping sample tests" - fi - ;; -clirr) - mvn -B -ntp -Denforcer.skip=true clirr:check - RETURN_CODE=$? - ;; -*) - ;; -esac - -if [ "${REPORT_COVERAGE}" == "true" ] -then - bash ${KOKORO_GFILE_DIR}/codecov.sh -fi - -# fix output location of logs -bash .kokoro/coerce_logs.sh - -if [[ "${ENABLE_FLAKYBOT}" == "true" ]] -then - chmod +x ${KOKORO_GFILE_DIR}/linux_amd64/flakybot - ${KOKORO_GFILE_DIR}/linux_amd64/flakybot -repo=googleapis/java-iot -fi - -echo "exiting with ${RETURN_CODE}" -exit ${RETURN_CODE} diff --git a/.kokoro/coerce_logs.sh b/.kokoro/coerce_logs.sh deleted file mode 100755 index 46edbf7f..00000000 --- a/.kokoro/coerce_logs.sh +++ /dev/null @@ -1,37 +0,0 @@ -#!/bin/bash -# Copyright 2019 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -# This script finds and moves sponge logs so that they can be found by placer -# and are not flagged as flaky by sponge. - -set -eo pipefail - -## Get the directory of the build script -scriptDir=$(realpath $(dirname "${BASH_SOURCE[0]}")) -## cd to the parent directory, i.e. the root of the git repo -cd ${scriptDir}/.. - -job=$(basename ${KOKORO_JOB_NAME}) - -echo "coercing sponge logs..." -for xml in `find . -name *-sponge_log.xml` -do - class=$(basename ${xml} | cut -d- -f2) - dir=$(dirname ${xml})/${job}/${class} - text=$(dirname ${xml})/${class}-sponge_log.txt - mkdir -p ${dir} - mv ${xml} ${dir}/sponge_log.xml - mv ${text} ${dir}/sponge_log.txt -done diff --git a/.kokoro/common.cfg b/.kokoro/common.cfg deleted file mode 100644 index f1c507d5..00000000 --- a/.kokoro/common.cfg +++ /dev/null @@ -1,13 +0,0 @@ -# Format: //devtools/kokoro/config/proto/build.proto - -# Download trampoline resources. These will be in ${KOKORO_GFILE_DIR} -gfile_resources: "/bigstore/cloud-devrel-kokoro-resources/trampoline" - -# All builds use the trampoline script to run in docker. -build_file: "java-iot/.kokoro/trampoline.sh" - -# Tell the trampoline which build file to use. -env_vars: { - key: "TRAMPOLINE_BUILD_FILE" - value: "github/java-iot/.kokoro/build.sh" -} diff --git a/.kokoro/common.sh b/.kokoro/common.sh deleted file mode 100644 index f8f957af..00000000 --- a/.kokoro/common.sh +++ /dev/null @@ -1,60 +0,0 @@ -#!/bin/bash -# Copyright 2020 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -function retry_with_backoff { - attempts_left=$1 - sleep_seconds=$2 - shift 2 - command=$@ - - - # store current flag state - flags=$- - - # allow a failures to continue - set +e - ${command} - exit_code=$? - - # restore "e" flag - if [[ ${flags} =~ e ]] - then set -e - else set +e - fi - - if [[ $exit_code == 0 ]] - then - return 0 - fi - - # failure - if [[ ${attempts_left} > 0 ]] - then - echo "failure (${exit_code}), sleeping ${sleep_seconds}..." - sleep ${sleep_seconds} - new_attempts=$((${attempts_left} - 1)) - new_sleep=$((${sleep_seconds} * 2)) - retry_with_backoff ${new_attempts} ${new_sleep} ${command} - fi - - return $exit_code -} - -## Helper functionss -function now() { date +"%Y-%m-%d %H:%M:%S" | tr -d '\n'; } -function msg() { println "$*" >&2; } -function println() { printf '%s\n' "$(now) $*"; } - -## Helper comment to trigger updated repo dependency release \ No newline at end of file diff --git a/.kokoro/continuous/common.cfg b/.kokoro/continuous/common.cfg deleted file mode 100644 index be619526..00000000 --- a/.kokoro/continuous/common.cfg +++ /dev/null @@ -1,25 +0,0 @@ -# Format: //devtools/kokoro/config/proto/build.proto - -# Build logs will be here -action { - define_artifacts { - regex: "**/*sponge_log.xml" - regex: "**/*sponge_log.txt" - } -} - -# Download trampoline resources. -gfile_resources: "/bigstore/cloud-devrel-kokoro-resources/trampoline" - -# Use the trampoline script to run in docker. -build_file: "java-iot/.kokoro/trampoline.sh" - -env_vars: { - key: "TRAMPOLINE_BUILD_FILE" - value: "github/java-iot/.kokoro/build.sh" -} - -env_vars: { - key: "JOB_TYPE" - value: "test" -} diff --git a/.kokoro/continuous/java8.cfg b/.kokoro/continuous/java8.cfg deleted file mode 100644 index 495cc7ba..00000000 --- a/.kokoro/continuous/java8.cfg +++ /dev/null @@ -1,12 +0,0 @@ -# Format: //devtools/kokoro/config/proto/build.proto - -# Configure the docker image for kokoro-trampoline. -env_vars: { - key: "TRAMPOLINE_IMAGE" - value: "gcr.io/cloud-devrel-kokoro-resources/java8" -} - -env_vars: { - key: "REPORT_COVERAGE" - value: "true" -} diff --git a/.kokoro/continuous/propose_release.sh b/.kokoro/continuous/propose_release.sh deleted file mode 100755 index 9594a60d..00000000 --- a/.kokoro/continuous/propose_release.sh +++ /dev/null @@ -1,29 +0,0 @@ -#!/bin/bash - -# Copyright 2019 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. - -set -eo pipefail - -export NPM_CONFIG_PREFIX=/home/node/.npm-global - -if [ -f ${KOKORO_KEYSTORE_DIR}/73713_github-magic-proxy-url-release-please ]; then - # Groom the release PR as new commits are merged. - npx release-please release-pr --token=${KOKORO_KEYSTORE_DIR}/73713_github-magic-proxy-token-release-please \ - --repo-url=googleapis/java-iot \ - --package-name="cloudiot" \ - --api-url=${KOKORO_KEYSTORE_DIR}/73713_github-magic-proxy-url-release-please \ - --proxy-key=${KOKORO_KEYSTORE_DIR}/73713_github-magic-proxy-key-release-please \ - --release-type=java-yoshi -fi diff --git a/.kokoro/dependencies.sh b/.kokoro/dependencies.sh deleted file mode 100755 index d7476cfe..00000000 --- a/.kokoro/dependencies.sh +++ /dev/null @@ -1,110 +0,0 @@ -#!/bin/bash -# Copyright 2019 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -set -eo pipefail -shopt -s nullglob - -## Get the directory of the build script -scriptDir=$(realpath $(dirname "${BASH_SOURCE[0]}")) -## cd to the parent directory, i.e. the root of the git repo -cd ${scriptDir}/.. - -# include common functions -source ${scriptDir}/common.sh - -# Print out Java -java -version -echo $JOB_TYPE - -function determineMavenOpts() { - local javaVersion=$( - # filter down to the version line, then pull out the version between quotes, - # then trim the version number down to its minimal number (removing any - # update or suffix number). - java -version 2>&1 | grep "version" \ - | sed -E 's/^.*"(.*?)".*$/\1/g' \ - | sed -E 's/^(1\.[0-9]\.0).*$/\1/g' - ) - - if [[ $javaVersion == 17* ]] - then - # MaxPermSize is no longer supported as of jdk 17 - echo -n "-Xmx1024m" - else - echo -n "-Xmx1024m -XX:MaxPermSize=128m" - fi -} - -export MAVEN_OPTS=$(determineMavenOpts) - -# this should run maven enforcer -retry_with_backoff 3 10 \ - mvn install -B -V -ntp \ - -DskipTests=true \ - -Dmaven.javadoc.skip=true \ - -Dclirr.skip=true - -mvn -B dependency:analyze -DfailOnWarning=true - -echo "****************** DEPENDENCY LIST COMPLETENESS CHECK *******************" -## Run dependency list completeness check -function completenessCheck() { - # Output dep list with compile scope generated using the original pom - # Running mvn dependency:list on Java versions that support modules will also include the module of the dependency. - # This is stripped from the output as it is not present in the flattened pom. - # Only dependencies with 'compile' or 'runtime' scope are included from original dependency list. - msg "Generating dependency list using original pom..." - mvn dependency:list -f pom.xml -DincludeScope=runtime -Dsort=true | grep '\[INFO] .*:.*:.*:.*:.*' | sed -e 's/ --.*//' >.org-list.txt - - # Output dep list generated using the flattened pom (only 'compile' and 'runtime' scopes) - msg "Generating dependency list using flattened pom..." - mvn dependency:list -f .flattened-pom.xml -DincludeScope=runtime -Dsort=true | grep '\[INFO] .*:.*:.*:.*:.*' >.new-list.txt - - # Compare two dependency lists - msg "Comparing dependency lists..." - diff .org-list.txt .new-list.txt >.diff.txt - if [[ $? == 0 ]] - then - msg "Success. No diff!" - else - msg "Diff found. See below: " - msg "You can also check .diff.txt file located in $1." - cat .diff.txt - return 1 - fi -} - -# Allow failures to continue running the script -set +e - -error_count=0 -for path in **/.flattened-pom.xml -do - # Check flattened pom in each dir that contains it for completeness - dir=$(dirname "$path") - pushd "$dir" - completenessCheck "$dir" - error_count=$(($error_count + $?)) - popd -done - -if [[ $error_count == 0 ]] -then - msg "All checks passed." - exit 0 -else - msg "Errors found. See log statements above." - exit 1 -fi diff --git a/.kokoro/nightly/common.cfg b/.kokoro/nightly/common.cfg deleted file mode 100644 index be619526..00000000 --- a/.kokoro/nightly/common.cfg +++ /dev/null @@ -1,25 +0,0 @@ -# Format: //devtools/kokoro/config/proto/build.proto - -# Build logs will be here -action { - define_artifacts { - regex: "**/*sponge_log.xml" - regex: "**/*sponge_log.txt" - } -} - -# Download trampoline resources. -gfile_resources: "/bigstore/cloud-devrel-kokoro-resources/trampoline" - -# Use the trampoline script to run in docker. -build_file: "java-iot/.kokoro/trampoline.sh" - -env_vars: { - key: "TRAMPOLINE_BUILD_FILE" - value: "github/java-iot/.kokoro/build.sh" -} - -env_vars: { - key: "JOB_TYPE" - value: "test" -} diff --git a/.kokoro/nightly/integration.cfg b/.kokoro/nightly/integration.cfg deleted file mode 100644 index a2907a25..00000000 --- a/.kokoro/nightly/integration.cfg +++ /dev/null @@ -1,37 +0,0 @@ -# Format: //devtools/kokoro/config/proto/build.proto - -# Configure the docker image for kokoro-trampoline. -env_vars: { - key: "TRAMPOLINE_IMAGE" - value: "gcr.io/cloud-devrel-kokoro-resources/java8" -} - -env_vars: { - key: "JOB_TYPE" - value: "integration" -} -# TODO: remove this after we've migrated all tests and scripts -env_vars: { - key: "GCLOUD_PROJECT" - value: "java-docs-samples-testing" -} - -env_vars: { - key: "GOOGLE_CLOUD_PROJECT" - value: "java-docs-samples-testing" -} - -env_vars: { - key: "ENABLE_FLAKYBOT" - value: "true" -} - -env_vars: { - key: "GOOGLE_APPLICATION_CREDENTIALS" - value: "secret_manager/java-it-service-account" -} - -env_vars: { - key: "SECRET_MANAGER_KEYS" - value: "java-it-service-account" -} diff --git a/.kokoro/nightly/java11-integration.cfg b/.kokoro/nightly/java11-integration.cfg deleted file mode 100644 index 58049cc3..00000000 --- a/.kokoro/nightly/java11-integration.cfg +++ /dev/null @@ -1,37 +0,0 @@ -# Format: //devtools/kokoro/config/proto/build.proto - -# Configure the docker image for kokoro-trampoline. -env_vars: { - key: "TRAMPOLINE_IMAGE" - value: "gcr.io/cloud-devrel-public-resources/java11014" -} - -env_vars: { - key: "JOB_TYPE" - value: "integration" -} -# TODO: remove this after we've migrated all tests and scripts -env_vars: { - key: "GCLOUD_PROJECT" - value: "gcloud-devel" -} - -env_vars: { - key: "GOOGLE_CLOUD_PROJECT" - value: "gcloud-devel" -} - -env_vars: { - key: "ENABLE_FLAKYBOT" - value: "true" -} - -env_vars: { - key: "GOOGLE_APPLICATION_CREDENTIALS" - value: "secret_manager/java-it-service-account" -} - -env_vars: { - key: "SECRET_MANAGER_KEYS" - value: "java-it-service-account" -} diff --git a/.kokoro/nightly/java11.cfg b/.kokoro/nightly/java11.cfg deleted file mode 100644 index 709f2b4c..00000000 --- a/.kokoro/nightly/java11.cfg +++ /dev/null @@ -1,7 +0,0 @@ -# Format: //devtools/kokoro/config/proto/build.proto - -# Configure the docker image for kokoro-trampoline. -env_vars: { - key: "TRAMPOLINE_IMAGE" - value: "gcr.io/cloud-devrel-kokoro-resources/java11" -} diff --git a/.kokoro/nightly/java7.cfg b/.kokoro/nightly/java7.cfg deleted file mode 100644 index cb24f44e..00000000 --- a/.kokoro/nightly/java7.cfg +++ /dev/null @@ -1,7 +0,0 @@ -# Format: //devtools/kokoro/config/proto/build.proto - -# Configure the docker image for kokoro-trampoline. -env_vars: { - key: "TRAMPOLINE_IMAGE" - value: "gcr.io/cloud-devrel-kokoro-resources/java7" -} diff --git a/.kokoro/nightly/java8-osx.cfg b/.kokoro/nightly/java8-osx.cfg deleted file mode 100644 index cbcbfae7..00000000 --- a/.kokoro/nightly/java8-osx.cfg +++ /dev/null @@ -1,3 +0,0 @@ -# Format: //devtools/kokoro/config/proto/build.proto - -build_file: "java-iot/.kokoro/build.sh" diff --git a/.kokoro/nightly/java8-win.cfg b/.kokoro/nightly/java8-win.cfg deleted file mode 100644 index 45de109f..00000000 --- a/.kokoro/nightly/java8-win.cfg +++ /dev/null @@ -1,3 +0,0 @@ -# Format: //devtools/kokoro/config/proto/build.proto - -build_file: "java-iot/.kokoro/build.bat" diff --git a/.kokoro/nightly/java8.cfg b/.kokoro/nightly/java8.cfg deleted file mode 100644 index 495cc7ba..00000000 --- a/.kokoro/nightly/java8.cfg +++ /dev/null @@ -1,12 +0,0 @@ -# Format: //devtools/kokoro/config/proto/build.proto - -# Configure the docker image for kokoro-trampoline. -env_vars: { - key: "TRAMPOLINE_IMAGE" - value: "gcr.io/cloud-devrel-kokoro-resources/java8" -} - -env_vars: { - key: "REPORT_COVERAGE" - value: "true" -} diff --git a/.kokoro/nightly/samples.cfg b/.kokoro/nightly/samples.cfg deleted file mode 100644 index 9761fd86..00000000 --- a/.kokoro/nightly/samples.cfg +++ /dev/null @@ -1,38 +0,0 @@ -# Format: //devtools/kokoro/config/proto/build.proto - -# Configure the docker image for kokoro-trampoline. -env_vars: { - key: "TRAMPOLINE_IMAGE" - value: "gcr.io/cloud-devrel-kokoro-resources/java8" -} - -env_vars: { - key: "JOB_TYPE" - value: "samples" -} - -# TODO: remove this after we've migrated all tests and scripts -env_vars: { - key: "GCLOUD_PROJECT" - value: "java-docs-samples-testing" -} - -env_vars: { - key: "GOOGLE_CLOUD_PROJECT" - value: "java-docs-samples-testing" -} - -env_vars: { - key: "GOOGLE_APPLICATION_CREDENTIALS" - value: "secret_manager/java-docs-samples-service-account" -} - -env_vars: { - key: "SECRET_MANAGER_KEYS" - value: "java-docs-samples-service-account" -} - -env_vars: { - key: "ENABLE_FLAKYBOT" - value: "true" -} diff --git a/.kokoro/populate-secrets.sh b/.kokoro/populate-secrets.sh deleted file mode 100755 index f5251425..00000000 --- a/.kokoro/populate-secrets.sh +++ /dev/null @@ -1,43 +0,0 @@ -#!/bin/bash -# Copyright 2020 Google LLC. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -set -eo pipefail - -function now { date +"%Y-%m-%d %H:%M:%S" | tr -d '\n' ;} -function msg { println "$*" >&2 ;} -function println { printf '%s\n' "$(now) $*" ;} - - -# Populates requested secrets set in SECRET_MANAGER_KEYS from service account: -# kokoro-trampoline@cloud-devrel-kokoro-resources.iam.gserviceaccount.com -SECRET_LOCATION="${KOKORO_GFILE_DIR}/secret_manager" -msg "Creating folder on disk for secrets: ${SECRET_LOCATION}" -mkdir -p ${SECRET_LOCATION} -for key in $(echo ${SECRET_MANAGER_KEYS} | sed "s/,/ /g") -do - msg "Retrieving secret ${key}" - docker run --entrypoint=gcloud \ - --volume=${KOKORO_GFILE_DIR}:${KOKORO_GFILE_DIR} \ - gcr.io/google.com/cloudsdktool/cloud-sdk \ - secrets versions access latest \ - --project cloud-devrel-kokoro-resources \ - --secret ${key} > \ - "${SECRET_LOCATION}/${key}" - if [[ $? == 0 ]]; then - msg "Secret written to ${SECRET_LOCATION}/${key}" - else - msg "Error retrieving secret ${key}" - fi -done diff --git a/.kokoro/presubmit/clirr.cfg b/.kokoro/presubmit/clirr.cfg deleted file mode 100644 index ec572442..00000000 --- a/.kokoro/presubmit/clirr.cfg +++ /dev/null @@ -1,13 +0,0 @@ -# Format: //devtools/kokoro/config/proto/build.proto - -# Configure the docker image for kokoro-trampoline. - -env_vars: { - key: "TRAMPOLINE_IMAGE" - value: "gcr.io/cloud-devrel-kokoro-resources/java8" -} - -env_vars: { - key: "JOB_TYPE" - value: "clirr" -} \ No newline at end of file diff --git a/.kokoro/presubmit/common.cfg b/.kokoro/presubmit/common.cfg deleted file mode 100644 index 5fbf7c21..00000000 --- a/.kokoro/presubmit/common.cfg +++ /dev/null @@ -1,34 +0,0 @@ -# Format: //devtools/kokoro/config/proto/build.proto - -# Build logs will be here -action { - define_artifacts { - regex: "**/*sponge_log.xml" - regex: "**/*sponge_log.txt" - } -} - -# Download trampoline resources. -gfile_resources: "/bigstore/cloud-devrel-kokoro-resources/trampoline" - -# Use the trampoline script to run in docker. -build_file: "java-iot/.kokoro/trampoline.sh" - -env_vars: { - key: "TRAMPOLINE_BUILD_FILE" - value: "github/java-iot/.kokoro/build.sh" -} - -env_vars: { - key: "JOB_TYPE" - value: "test" -} - -before_action { - fetch_keystore { - keystore_resource { - keystore_config_id: 73713 - keyname: "dpebot_codecov_token" - } - } -} diff --git a/.kokoro/presubmit/dependencies.cfg b/.kokoro/presubmit/dependencies.cfg deleted file mode 100644 index 626509b1..00000000 --- a/.kokoro/presubmit/dependencies.cfg +++ /dev/null @@ -1,12 +0,0 @@ -# Format: //devtools/kokoro/config/proto/build.proto - -# Configure the docker image for kokoro-trampoline. -env_vars: { - key: "TRAMPOLINE_IMAGE" - value: "gcr.io/cloud-devrel-kokoro-resources/java8" -} - -env_vars: { - key: "TRAMPOLINE_BUILD_FILE" - value: "github/java-iot/.kokoro/dependencies.sh" -} diff --git a/.kokoro/presubmit/graalvm-native-17.cfg b/.kokoro/presubmit/graalvm-native-17.cfg deleted file mode 100644 index a3f7fb9d..00000000 --- a/.kokoro/presubmit/graalvm-native-17.cfg +++ /dev/null @@ -1,33 +0,0 @@ -# Format: //devtools/kokoro/config/proto/build.proto - -# Configure the docker image for kokoro-trampoline. -env_vars: { - key: "TRAMPOLINE_IMAGE" - value: "gcr.io/cloud-devrel-kokoro-resources/graalvm17" -} - -env_vars: { - key: "JOB_TYPE" - value: "graalvm17" -} - -# TODO: remove this after we've migrated all tests and scripts -env_vars: { - key: "GCLOUD_PROJECT" - value: "gcloud-devel" -} - -env_vars: { - key: "GOOGLE_CLOUD_PROJECT" - value: "gcloud-devel" -} - -env_vars: { - key: "GOOGLE_APPLICATION_CREDENTIALS" - value: "secret_manager/java-it-service-account" -} - -env_vars: { - key: "SECRET_MANAGER_KEYS" - value: "java-it-service-account" -} \ No newline at end of file diff --git a/.kokoro/presubmit/graalvm-native.cfg b/.kokoro/presubmit/graalvm-native.cfg deleted file mode 100644 index 4c7225ec..00000000 --- a/.kokoro/presubmit/graalvm-native.cfg +++ /dev/null @@ -1,33 +0,0 @@ -# Format: //devtools/kokoro/config/proto/build.proto - -# Configure the docker image for kokoro-trampoline. -env_vars: { - key: "TRAMPOLINE_IMAGE" - value: "gcr.io/cloud-devrel-kokoro-resources/graalvm" -} - -env_vars: { - key: "JOB_TYPE" - value: "graalvm" -} - -# TODO: remove this after we've migrated all tests and scripts -env_vars: { - key: "GCLOUD_PROJECT" - value: "gcloud-devel" -} - -env_vars: { - key: "GOOGLE_CLOUD_PROJECT" - value: "gcloud-devel" -} - -env_vars: { - key: "GOOGLE_APPLICATION_CREDENTIALS" - value: "secret_manager/java-it-service-account" -} - -env_vars: { - key: "SECRET_MANAGER_KEYS" - value: "java-it-service-account" -} diff --git a/.kokoro/presubmit/integration.cfg b/.kokoro/presubmit/integration.cfg deleted file mode 100644 index dded67a9..00000000 --- a/.kokoro/presubmit/integration.cfg +++ /dev/null @@ -1,33 +0,0 @@ -# Format: //devtools/kokoro/config/proto/build.proto - -# Configure the docker image for kokoro-trampoline. -env_vars: { - key: "TRAMPOLINE_IMAGE" - value: "gcr.io/cloud-devrel-kokoro-resources/java8" -} - -env_vars: { - key: "JOB_TYPE" - value: "integration" -} - -# TODO: remove this after we've migrated all tests and scripts -env_vars: { - key: "GCLOUD_PROJECT" - value: "gcloud-devel" -} - -env_vars: { - key: "GOOGLE_CLOUD_PROJECT" - value: "gcloud-devel" -} - -env_vars: { - key: "GOOGLE_APPLICATION_CREDENTIALS" - value: "secret_manager/java-it-service-account" -} - -env_vars: { - key: "SECRET_MANAGER_KEYS" - value: "java-it-service-account" -} diff --git a/.kokoro/presubmit/java11.cfg b/.kokoro/presubmit/java11.cfg deleted file mode 100644 index 709f2b4c..00000000 --- a/.kokoro/presubmit/java11.cfg +++ /dev/null @@ -1,7 +0,0 @@ -# Format: //devtools/kokoro/config/proto/build.proto - -# Configure the docker image for kokoro-trampoline. -env_vars: { - key: "TRAMPOLINE_IMAGE" - value: "gcr.io/cloud-devrel-kokoro-resources/java11" -} diff --git a/.kokoro/presubmit/java7.cfg b/.kokoro/presubmit/java7.cfg deleted file mode 100644 index cb24f44e..00000000 --- a/.kokoro/presubmit/java7.cfg +++ /dev/null @@ -1,7 +0,0 @@ -# Format: //devtools/kokoro/config/proto/build.proto - -# Configure the docker image for kokoro-trampoline. -env_vars: { - key: "TRAMPOLINE_IMAGE" - value: "gcr.io/cloud-devrel-kokoro-resources/java7" -} diff --git a/.kokoro/presubmit/java8-osx.cfg b/.kokoro/presubmit/java8-osx.cfg deleted file mode 100644 index cbcbfae7..00000000 --- a/.kokoro/presubmit/java8-osx.cfg +++ /dev/null @@ -1,3 +0,0 @@ -# Format: //devtools/kokoro/config/proto/build.proto - -build_file: "java-iot/.kokoro/build.sh" diff --git a/.kokoro/presubmit/java8-win.cfg b/.kokoro/presubmit/java8-win.cfg deleted file mode 100644 index 45de109f..00000000 --- a/.kokoro/presubmit/java8-win.cfg +++ /dev/null @@ -1,3 +0,0 @@ -# Format: //devtools/kokoro/config/proto/build.proto - -build_file: "java-iot/.kokoro/build.bat" diff --git a/.kokoro/presubmit/java8.cfg b/.kokoro/presubmit/java8.cfg deleted file mode 100644 index 495cc7ba..00000000 --- a/.kokoro/presubmit/java8.cfg +++ /dev/null @@ -1,12 +0,0 @@ -# Format: //devtools/kokoro/config/proto/build.proto - -# Configure the docker image for kokoro-trampoline. -env_vars: { - key: "TRAMPOLINE_IMAGE" - value: "gcr.io/cloud-devrel-kokoro-resources/java8" -} - -env_vars: { - key: "REPORT_COVERAGE" - value: "true" -} diff --git a/.kokoro/presubmit/linkage-monitor.cfg b/.kokoro/presubmit/linkage-monitor.cfg deleted file mode 100644 index 7b6ba010..00000000 --- a/.kokoro/presubmit/linkage-monitor.cfg +++ /dev/null @@ -1,12 +0,0 @@ -# Format: //devtools/kokoro/config/proto/build.proto - -# Configure the docker image for kokoro-trampoline. -env_vars: { - key: "TRAMPOLINE_IMAGE" - value: "gcr.io/cloud-devrel-kokoro-resources/java8" -} - -env_vars: { - key: "TRAMPOLINE_BUILD_FILE" - value: "github/java-iot/.kokoro/linkage-monitor.sh" -} \ No newline at end of file diff --git a/.kokoro/presubmit/lint.cfg b/.kokoro/presubmit/lint.cfg deleted file mode 100644 index 6d323c8a..00000000 --- a/.kokoro/presubmit/lint.cfg +++ /dev/null @@ -1,13 +0,0 @@ -# Format: //devtools/kokoro/config/proto/build.proto - -# Configure the docker image for kokoro-trampoline. - -env_vars: { - key: "TRAMPOLINE_IMAGE" - value: "gcr.io/cloud-devrel-kokoro-resources/java8" -} - -env_vars: { - key: "JOB_TYPE" - value: "lint" -} \ No newline at end of file diff --git a/.kokoro/presubmit/samples.cfg b/.kokoro/presubmit/samples.cfg deleted file mode 100644 index 01e09600..00000000 --- a/.kokoro/presubmit/samples.cfg +++ /dev/null @@ -1,33 +0,0 @@ -# Format: //devtools/kokoro/config/proto/build.proto - -# Configure the docker image for kokoro-trampoline. -env_vars: { - key: "TRAMPOLINE_IMAGE" - value: "gcr.io/cloud-devrel-kokoro-resources/java8" -} - -env_vars: { - key: "JOB_TYPE" - value: "samples" -} - -# TODO: remove this after we've migrated all tests and scripts -env_vars: { - key: "GCLOUD_PROJECT" - value: "java-docs-samples-testing" -} - -env_vars: { - key: "GOOGLE_CLOUD_PROJECT" - value: "java-docs-samples-testing" -} - -env_vars: { - key: "GOOGLE_APPLICATION_CREDENTIALS" - value: "secret_manager/java-docs-samples-service-account" -} - -env_vars: { - key: "SECRET_MANAGER_KEYS" - value: "java-docs-samples-service-account" -} \ No newline at end of file diff --git a/.kokoro/readme.sh b/.kokoro/readme.sh deleted file mode 100755 index 5f671a9d..00000000 --- a/.kokoro/readme.sh +++ /dev/null @@ -1,45 +0,0 @@ -#!/bin/bash -# Copyright 2020 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -set -eo pipefail - -cd ${KOKORO_ARTIFACTS_DIR}/github/java-iot - -# Disable buffering, so that the logs stream through. -export PYTHONUNBUFFERED=1 - -# Kokoro exposes this as a file, but the scripts expect just a plain variable. -export GITHUB_TOKEN=$(cat ${KOKORO_KEYSTORE_DIR}/73713_yoshi-automation-github-key) - -# Setup git credentials -echo "https://${GITHUB_TOKEN}:@github.com" >> ~/.git-credentials -git config --global credential.helper 'store --file ~/.git-credentials' - -python3.6 -m pip install git+https://github.com/googleapis/synthtool.git#egg=gcp-synthtool - -set +e -python3.6 -m autosynth.synth \ - --repository=googleapis/java-iot \ - --synth-file-name=.github/readme/synth.py \ - --metadata-path=.github/readme/synth.metadata \ - --pr-title="chore: regenerate README" \ - --branch-suffix="readme" - -# autosynth returns 28 to signal there are no changes -RETURN_CODE=$? -if [[ ${RETURN_CODE} -ne 0 && ${RETURN_CODE} -ne 28 ]] -then - exit ${RETURN_CODE} -fi diff --git a/.kokoro/release/bump_snapshot.cfg b/.kokoro/release/bump_snapshot.cfg deleted file mode 100644 index 620df343..00000000 --- a/.kokoro/release/bump_snapshot.cfg +++ /dev/null @@ -1,53 +0,0 @@ -# Format: //devtools/kokoro/config/proto/build.proto - -# Build logs will be here -action { - define_artifacts { - regex: "**/*sponge_log.xml" - } -} - -# Download trampoline resources. -gfile_resources: "/bigstore/cloud-devrel-kokoro-resources/trampoline" - -# Use the trampoline script to run in docker. -build_file: "java-iot/.kokoro/trampoline.sh" - -# Configure the docker image for kokoro-trampoline. -env_vars: { - key: "TRAMPOLINE_IMAGE" - value: "gcr.io/cloud-devrel-kokoro-resources/node:10-user" -} - -env_vars: { - key: "TRAMPOLINE_BUILD_FILE" - value: "github/java-iot/.kokoro/release/bump_snapshot.sh" -} - -# tokens used by release-please to keep an up-to-date release PR. -before_action { - fetch_keystore { - keystore_resource { - keystore_config_id: 73713 - keyname: "github-magic-proxy-key-release-please" - } - } -} - -before_action { - fetch_keystore { - keystore_resource { - keystore_config_id: 73713 - keyname: "github-magic-proxy-token-release-please" - } - } -} - -before_action { - fetch_keystore { - keystore_resource { - keystore_config_id: 73713 - keyname: "github-magic-proxy-url-release-please" - } - } -} diff --git a/.kokoro/release/bump_snapshot.sh b/.kokoro/release/bump_snapshot.sh deleted file mode 100755 index a14bfa08..00000000 --- a/.kokoro/release/bump_snapshot.sh +++ /dev/null @@ -1,30 +0,0 @@ -#!/bin/bash - -# Copyright 2019 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. - -set -eo pipefail - -export NPM_CONFIG_PREFIX=/home/node/.npm-global - -if [ -f ${KOKORO_KEYSTORE_DIR}/73713_github-magic-proxy-url-release-please ]; then - # Groom the snapshot release PR immediately after publishing a release - npx release-please release-pr --token=${KOKORO_KEYSTORE_DIR}/73713_github-magic-proxy-token-release-please \ - --repo-url=googleapis/java-iot \ - --package-name="cloudiot" \ - --api-url=${KOKORO_KEYSTORE_DIR}/73713_github-magic-proxy-url-release-please \ - --proxy-key=${KOKORO_KEYSTORE_DIR}/73713_github-magic-proxy-key-release-please \ - --snapshot \ - --release-type=java-auth-yoshi -fi diff --git a/.kokoro/release/common.cfg b/.kokoro/release/common.cfg deleted file mode 100644 index b40b7754..00000000 --- a/.kokoro/release/common.cfg +++ /dev/null @@ -1,49 +0,0 @@ -# Format: //devtools/kokoro/config/proto/build.proto - -# Download trampoline resources. -gfile_resources: "/bigstore/cloud-devrel-kokoro-resources/trampoline" - -# Use the trampoline script to run in docker. -build_file: "java-iot/.kokoro/trampoline.sh" - -# Configure the docker image for kokoro-trampoline. -env_vars: { - key: "TRAMPOLINE_IMAGE" - value: "gcr.io/cloud-devrel-kokoro-resources/java8" -} - -before_action { - fetch_keystore { - keystore_resource { - keystore_config_id: 70247 - keyname: "maven-gpg-keyring" - } - } -} - -before_action { - fetch_keystore { - keystore_resource { - keystore_config_id: 70247 - keyname: "maven-gpg-passphrase" - } - } -} - -before_action { - fetch_keystore { - keystore_resource { - keystore_config_id: 70247 - keyname: "maven-gpg-pubkeyring" - } - } -} - -before_action { - fetch_keystore { - keystore_resource { - keystore_config_id: 70247 - keyname: "sonatype-credentials" - } - } -} diff --git a/.kokoro/release/common.sh b/.kokoro/release/common.sh deleted file mode 100755 index 7f78ee41..00000000 --- a/.kokoro/release/common.sh +++ /dev/null @@ -1,50 +0,0 @@ -#!/bin/bash -# Copyright 2018 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -set -eo pipefail - -# Get secrets from keystore and set and environment variables -setup_environment_secrets() { - export GPG_PASSPHRASE=$(cat ${KOKORO_KEYSTORE_DIR}/70247_maven-gpg-passphrase) - export GPG_TTY=$(tty) - export GPG_HOMEDIR=/gpg - mkdir $GPG_HOMEDIR - mv ${KOKORO_KEYSTORE_DIR}/70247_maven-gpg-pubkeyring $GPG_HOMEDIR/pubring.gpg - mv ${KOKORO_KEYSTORE_DIR}/70247_maven-gpg-keyring $GPG_HOMEDIR/secring.gpg - export SONATYPE_USERNAME=$(cat ${KOKORO_KEYSTORE_DIR}/70247_sonatype-credentials | cut -f1 -d'|') - export SONATYPE_PASSWORD=$(cat ${KOKORO_KEYSTORE_DIR}/70247_sonatype-credentials | cut -f2 -d'|') -} - -create_settings_xml_file() { - echo " - - - ossrh - ${SONATYPE_USERNAME} - ${SONATYPE_PASSWORD} - - - sonatype-nexus-staging - ${SONATYPE_USERNAME} - ${SONATYPE_PASSWORD} - - - sonatype-nexus-snapshots - ${SONATYPE_USERNAME} - ${SONATYPE_PASSWORD} - - -" > $1 -} \ No newline at end of file diff --git a/.kokoro/release/drop.cfg b/.kokoro/release/drop.cfg deleted file mode 100644 index 01755c30..00000000 --- a/.kokoro/release/drop.cfg +++ /dev/null @@ -1,6 +0,0 @@ -# Format: //devtools/kokoro/config/proto/build.proto - -env_vars: { - key: "TRAMPOLINE_BUILD_FILE" - value: "github/java-iot/.kokoro/release/drop.sh" -} diff --git a/.kokoro/release/drop.sh b/.kokoro/release/drop.sh deleted file mode 100755 index 742ec1a8..00000000 --- a/.kokoro/release/drop.sh +++ /dev/null @@ -1,32 +0,0 @@ -#!/bin/bash -# Copyright 2018 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -set -eo pipefail - -# STAGING_REPOSITORY_ID must be set -if [ -z "${STAGING_REPOSITORY_ID}" ]; then - echo "Missing STAGING_REPOSITORY_ID environment variable" - exit 1 -fi - -source $(dirname "$0")/common.sh -pushd $(dirname "$0")/../../ - -setup_environment_secrets -create_settings_xml_file "settings.xml" - -mvn nexus-staging:drop -B \ - --settings=settings.xml \ - -DstagingRepositoryId=${STAGING_REPOSITORY_ID} diff --git a/.kokoro/release/promote.cfg b/.kokoro/release/promote.cfg deleted file mode 100644 index 8c79f5ae..00000000 --- a/.kokoro/release/promote.cfg +++ /dev/null @@ -1,6 +0,0 @@ -# Format: //devtools/kokoro/config/proto/build.proto - -env_vars: { - key: "TRAMPOLINE_BUILD_FILE" - value: "github/java-iot/.kokoro/release/promote.sh" -} diff --git a/.kokoro/release/promote.sh b/.kokoro/release/promote.sh deleted file mode 100755 index 3cac3d8a..00000000 --- a/.kokoro/release/promote.sh +++ /dev/null @@ -1,34 +0,0 @@ -#!/bin/bash -# Copyright 2018 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -set -eo pipefail - -# STAGING_REPOSITORY_ID must be set -if [ -z "${STAGING_REPOSITORY_ID}" ]; then - echo "Missing STAGING_REPOSITORY_ID environment variable" - exit 1 -fi - -source $(dirname "$0")/common.sh - -pushd $(dirname "$0")/../../ - -setup_environment_secrets -create_settings_xml_file "settings.xml" - -mvn nexus-staging:release -B \ - -DperformRelease=true \ - --settings=settings.xml \ - -DstagingRepositoryId=${STAGING_REPOSITORY_ID} diff --git a/.kokoro/release/publish_javadoc.cfg b/.kokoro/release/publish_javadoc.cfg deleted file mode 100644 index 6e9cb998..00000000 --- a/.kokoro/release/publish_javadoc.cfg +++ /dev/null @@ -1,23 +0,0 @@ -# Format: //devtools/kokoro/config/proto/build.proto - -gfile_resources: "/bigstore/cloud-devrel-kokoro-resources/doc-templates/" - -env_vars: { - key: "STAGING_BUCKET" - value: "docs-staging" -} - -env_vars: { - key: "TRAMPOLINE_BUILD_FILE" - value: "github/java-iot/.kokoro/release/publish_javadoc.sh" -} - - -before_action { - fetch_keystore { - keystore_resource { - keystore_config_id: 73713 - keyname: "docuploader_service_account" - } - } -} diff --git a/.kokoro/release/publish_javadoc.sh b/.kokoro/release/publish_javadoc.sh deleted file mode 100755 index 27035cc0..00000000 --- a/.kokoro/release/publish_javadoc.sh +++ /dev/null @@ -1,53 +0,0 @@ -#!/bin/bash -# Copyright 2019 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -set -eo pipefail - -if [[ -z "${CREDENTIALS}" ]]; then - CREDENTIALS=${KOKORO_KEYSTORE_DIR}/73713_docuploader_service_account -fi - -if [[ -z "${STAGING_BUCKET}" ]]; then - echo "Need to set STAGING_BUCKET environment variable" - exit 1 -fi - -# work from the git root directory -pushd $(dirname "$0")/../../ - -# install docuploader package -python3 -m pip install --require-hashes -r .kokoro/requirements.txt - -# compile all packages -mvn clean install -B -q -DskipTests=true - -export NAME=google-cloud-iot -export VERSION=$(grep ${NAME}: versions.txt | cut -d: -f3) - -# build the docs -mvn site -B -q - -pushd target/site/apidocs - -# create metadata -python3 -m docuploader create-metadata \ - --name ${NAME} \ - --version ${VERSION} \ - --language java - -# upload docs -python3 -m docuploader upload . \ - --credentials ${CREDENTIALS} \ - --staging-bucket ${STAGING_BUCKET} diff --git a/.kokoro/release/publish_javadoc11.cfg b/.kokoro/release/publish_javadoc11.cfg deleted file mode 100644 index c21091d1..00000000 --- a/.kokoro/release/publish_javadoc11.cfg +++ /dev/null @@ -1,30 +0,0 @@ -# Format: //devtools/kokoro/config/proto/build.proto - -# cloud-rad production -env_vars: { - key: "STAGING_BUCKET_V2" - value: "docs-staging-v2" -} - -# Configure the docker image for kokoro-trampoline -env_vars: { - key: "TRAMPOLINE_IMAGE" - value: "gcr.io/cloud-devrel-kokoro-resources/java11" -} - -env_vars: { - key: "TRAMPOLINE_BUILD_FILE" - value: "github/java-iot/.kokoro/release/publish_javadoc11.sh" -} - -before_action { - fetch_keystore { - keystore_resource { - keystore_config_id: 73713 - keyname: "docuploader_service_account" - } - } -} - -# Downloads docfx doclet resource. This will be in ${KOKORO_GFILE_DIR}/ -gfile_resources: "/bigstore/cloud-devrel-kokoro-resources/docfx" diff --git a/.kokoro/release/publish_javadoc11.sh b/.kokoro/release/publish_javadoc11.sh deleted file mode 100755 index 027a432c..00000000 --- a/.kokoro/release/publish_javadoc11.sh +++ /dev/null @@ -1,63 +0,0 @@ -#!/bin/bash -# Copyright 2021 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -set -eo pipefail - -if [[ -z "${CREDENTIALS}" ]]; then - CREDENTIALS=${KOKORO_KEYSTORE_DIR}/73713_docuploader_service_account -fi - -if [[ -z "${STAGING_BUCKET_V2}" ]]; then - echo "Need to set STAGING_BUCKET_V2 environment variable" - exit 1 -fi - -# work from the git root directory -pushd $(dirname "$0")/../../ - -# install docuploader package -python3 -m pip install --require-hashes -r .kokoro/requirements.txt - -# compile all packages -mvn clean install -B -q -DskipTests=true - -export NAME=google-cloud-iot -export VERSION=$(grep ${NAME}: versions.txt | cut -d: -f3) - -# cloud RAD generation -mvn clean javadoc:aggregate -B -q -P docFX -# include CHANGELOG -cp CHANGELOG.md target/docfx-yml/history.md - -pushd target/docfx-yml - -# create metadata -python3 -m docuploader create-metadata \ - --name ${NAME} \ - --version ${VERSION} \ - --xrefs devsite://java/gax \ - --xrefs devsite://java/google-cloud-core \ - --xrefs devsite://java/api-common \ - --xrefs devsite://java/proto-google-common-protos \ - --xrefs devsite://java/google-api-client \ - --xrefs devsite://java/google-http-client \ - --xrefs devsite://java/protobuf \ - --language java - -# upload yml to production bucket -python3 -m docuploader upload . \ - --credentials ${CREDENTIALS} \ - --staging-bucket ${STAGING_BUCKET_V2} \ - --destination-prefix docfx diff --git a/.kokoro/release/snapshot.cfg b/.kokoro/release/snapshot.cfg deleted file mode 100644 index 26f61b15..00000000 --- a/.kokoro/release/snapshot.cfg +++ /dev/null @@ -1,6 +0,0 @@ -# Format: //devtools/kokoro/config/proto/build.proto - -env_vars: { - key: "TRAMPOLINE_BUILD_FILE" - value: "github/java-iot/.kokoro/release/snapshot.sh" -} \ No newline at end of file diff --git a/.kokoro/release/snapshot.sh b/.kokoro/release/snapshot.sh deleted file mode 100755 index 1f55b770..00000000 --- a/.kokoro/release/snapshot.sh +++ /dev/null @@ -1,33 +0,0 @@ -#!/bin/bash -# Copyright 2019 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -set -eo pipefail - -source $(dirname "$0")/common.sh -MAVEN_SETTINGS_FILE=$(realpath $(dirname "$0")/../../)/settings.xml -pushd $(dirname "$0")/../../ - -# ensure we're trying to push a snapshot (no-result returns non-zero exit code) -grep SNAPSHOT versions.txt - -setup_environment_secrets -create_settings_xml_file "settings.xml" - -mvn clean deploy -B \ - --settings ${MAVEN_SETTINGS_FILE} \ - -DperformRelease=true \ - -Dgpg.executable=gpg \ - -Dgpg.passphrase=${GPG_PASSPHRASE} \ - -Dgpg.homedir=${GPG_HOMEDIR} diff --git a/.kokoro/release/stage.cfg b/.kokoro/release/stage.cfg deleted file mode 100644 index f1db1542..00000000 --- a/.kokoro/release/stage.cfg +++ /dev/null @@ -1,19 +0,0 @@ -# Format: //devtools/kokoro/config/proto/build.proto - -env_vars: { - key: "TRAMPOLINE_BUILD_FILE" - value: "github/java-iot/.kokoro/release/stage.sh" -} - -# Need to save the properties file -action { - define_artifacts { - regex: "github/java-iot/target/nexus-staging/staging/*.properties" - strip_prefix: "github/java-iot" - } -} - -env_vars: { - key: "SECRET_MANAGER_KEYS" - value: "releasetool-publish-reporter-app,releasetool-publish-reporter-googleapis-installation,releasetool-publish-reporter-pem" -} diff --git a/.kokoro/release/stage.sh b/.kokoro/release/stage.sh deleted file mode 100755 index 61e714d6..00000000 --- a/.kokoro/release/stage.sh +++ /dev/null @@ -1,47 +0,0 @@ -#!/bin/bash -# Copyright 2018 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -set -eo pipefail - -# Start the releasetool reporter -requirementsFile=$(realpath $(dirname "${BASH_SOURCE[0]}")/../requirements.txt) -python3 -m pip install --require-hashes -r $requirementsFile -python3 -m releasetool publish-reporter-script > /tmp/publisher-script; source /tmp/publisher-script - -source $(dirname "$0")/common.sh -source $(dirname "$0")/../common.sh -MAVEN_SETTINGS_FILE=$(realpath $(dirname "$0")/../../)/settings.xml -pushd $(dirname "$0")/../../ - -setup_environment_secrets -create_settings_xml_file "settings.xml" - -# attempt to stage 3 times with exponential backoff (starting with 10 seconds) -retry_with_backoff 3 10 \ - mvn clean deploy -B \ - --settings ${MAVEN_SETTINGS_FILE} \ - -DskipTests=true \ - -Dclirr.skip=true \ - -DperformRelease=true \ - -Dgpg.executable=gpg \ - -Dgpg.passphrase=${GPG_PASSPHRASE} \ - -Dgpg.homedir=${GPG_HOMEDIR} - -if [[ -n "${AUTORELEASE_PR}" ]] -then - mvn nexus-staging:release -B \ - -DperformRelease=true \ - --settings=settings.xml -fi diff --git a/.kokoro/requirements.in b/.kokoro/requirements.in deleted file mode 100644 index cfdc2e7e..00000000 --- a/.kokoro/requirements.in +++ /dev/null @@ -1,31 +0,0 @@ -gcp-docuploader==0.6.3 -google-crc32c==1.3.0 -googleapis-common-protos==1.56.3 -gcp-releasetool==1.8.7 -cachetools==4.2.4 -cffi==1.15.1 -jeepney==0.7.1 -jinja2==3.0.3 -markupsafe==2.0.1 -keyring==23.4.1 -packaging==21.3 -protobuf==3.19.5 -pyjwt==2.4.0 -pyparsing==3.0.9 -pycparser==2.21 -pyperclip==1.8.2 -python-dateutil==2.8.2 -requests==2.27.1 -importlib-metadata==4.8.3 -zipp==3.6.0 -google_api_core==2.8.2 -google-cloud-storage==2.0.0 -google-cloud-core==2.3.1 -typing-extensions==4.1.1 -urllib3==1.26.12 -zipp==3.6.0 -rsa==4.9 -six==1.16.0 -attrs==22.1.0 -google-auth==2.11.0 -idna==3.4 \ No newline at end of file diff --git a/.kokoro/requirements.txt b/.kokoro/requirements.txt deleted file mode 100644 index 170f1c63..00000000 --- a/.kokoro/requirements.txt +++ /dev/null @@ -1,452 +0,0 @@ -# -# This file is autogenerated by pip-compile with python 3.10 -# To update, run: -# -# pip-compile --allow-unsafe --generate-hashes requirements.in -# -attrs==22.1.0 \ - --hash=sha256:29adc2665447e5191d0e7c568fde78b21f9672d344281d0c6e1ab085429b22b6 \ - --hash=sha256:86efa402f67bf2df34f51a335487cf46b1ec130d02b8d39fd248abfd30da551c - # via - # -r requirements.in - # gcp-releasetool -cachetools==4.2.4 \ - --hash=sha256:89ea6f1b638d5a73a4f9226be57ac5e4f399d22770b92355f92dcb0f7f001693 \ - --hash=sha256:92971d3cb7d2a97efff7c7bb1657f21a8f5fb309a37530537c71b1774189f2d1 - # via - # -r requirements.in - # google-auth -certifi==2022.9.14 \ - --hash=sha256:36973885b9542e6bd01dea287b2b4b3b21236307c56324fcc3f1160f2d655ed5 \ - --hash=sha256:e232343de1ab72c2aa521b625c80f699e356830fd0e2c620b465b304b17b0516 - # via requests -cffi==1.15.1 \ - --hash=sha256:00a9ed42e88df81ffae7a8ab6d9356b371399b91dbdf0c3cb1e84c03a13aceb5 \ - --hash=sha256:03425bdae262c76aad70202debd780501fabeaca237cdfddc008987c0e0f59ef \ - --hash=sha256:04ed324bda3cda42b9b695d51bb7d54b680b9719cfab04227cdd1e04e5de3104 \ - --hash=sha256:0e2642fe3142e4cc4af0799748233ad6da94c62a8bec3a6648bf8ee68b1c7426 \ - --hash=sha256:173379135477dc8cac4bc58f45db08ab45d228b3363adb7af79436135d028405 \ - --hash=sha256:198caafb44239b60e252492445da556afafc7d1e3ab7a1fb3f0584ef6d742375 \ - --hash=sha256:1e74c6b51a9ed6589199c787bf5f9875612ca4a8a0785fb2d4a84429badaf22a \ - --hash=sha256:2012c72d854c2d03e45d06ae57f40d78e5770d252f195b93f581acf3ba44496e \ - --hash=sha256:21157295583fe8943475029ed5abdcf71eb3911894724e360acff1d61c1d54bc \ - --hash=sha256:2470043b93ff09bf8fb1d46d1cb756ce6132c54826661a32d4e4d132e1977adf \ - --hash=sha256:285d29981935eb726a4399badae8f0ffdff4f5050eaa6d0cfc3f64b857b77185 \ - --hash=sha256:30d78fbc8ebf9c92c9b7823ee18eb92f2e6ef79b45ac84db507f52fbe3ec4497 \ - --hash=sha256:320dab6e7cb2eacdf0e658569d2575c4dad258c0fcc794f46215e1e39f90f2c3 \ - --hash=sha256:33ab79603146aace82c2427da5ca6e58f2b3f2fb5da893ceac0c42218a40be35 \ - --hash=sha256:3548db281cd7d2561c9ad9984681c95f7b0e38881201e157833a2342c30d5e8c \ - --hash=sha256:3799aecf2e17cf585d977b780ce79ff0dc9b78d799fc694221ce814c2c19db83 \ - --hash=sha256:39d39875251ca8f612b6f33e6b1195af86d1b3e60086068be9cc053aa4376e21 \ - --hash=sha256:3b926aa83d1edb5aa5b427b4053dc420ec295a08e40911296b9eb1b6170f6cca \ - --hash=sha256:3bcde07039e586f91b45c88f8583ea7cf7a0770df3a1649627bf598332cb6984 \ - --hash=sha256:3d08afd128ddaa624a48cf2b859afef385b720bb4b43df214f85616922e6a5ac \ - --hash=sha256:3eb6971dcff08619f8d91607cfc726518b6fa2a9eba42856be181c6d0d9515fd \ - --hash=sha256:40f4774f5a9d4f5e344f31a32b5096977b5d48560c5592e2f3d2c4374bd543ee \ - --hash=sha256:4289fc34b2f5316fbb762d75362931e351941fa95fa18789191b33fc4cf9504a \ - --hash=sha256:470c103ae716238bbe698d67ad020e1db9d9dba34fa5a899b5e21577e6d52ed2 \ - --hash=sha256:4f2c9f67e9821cad2e5f480bc8d83b8742896f1242dba247911072d4fa94c192 \ - --hash=sha256:50a74364d85fd319352182ef59c5c790484a336f6db772c1a9231f1c3ed0cbd7 \ - --hash=sha256:54a2db7b78338edd780e7ef7f9f6c442500fb0d41a5a4ea24fff1c929d5af585 \ - --hash=sha256:5635bd9cb9731e6d4a1132a498dd34f764034a8ce60cef4f5319c0541159392f \ - --hash=sha256:59c0b02d0a6c384d453fece7566d1c7e6b7bae4fc5874ef2ef46d56776d61c9e \ - --hash=sha256:5d598b938678ebf3c67377cdd45e09d431369c3b1a5b331058c338e201f12b27 \ - --hash=sha256:5df2768244d19ab7f60546d0c7c63ce1581f7af8b5de3eb3004b9b6fc8a9f84b \ - --hash=sha256:5ef34d190326c3b1f822a5b7a45f6c4535e2f47ed06fec77d3d799c450b2651e \ - --hash=sha256:6975a3fac6bc83c4a65c9f9fcab9e47019a11d3d2cf7f3c0d03431bf145a941e \ - --hash=sha256:6c9a799e985904922a4d207a94eae35c78ebae90e128f0c4e521ce339396be9d \ - --hash=sha256:70df4e3b545a17496c9b3f41f5115e69a4f2e77e94e1d2a8e1070bc0c38c8a3c \ - --hash=sha256:7473e861101c9e72452f9bf8acb984947aa1661a7704553a9f6e4baa5ba64415 \ - --hash=sha256:8102eaf27e1e448db915d08afa8b41d6c7ca7a04b7d73af6514df10a3e74bd82 \ - --hash=sha256:87c450779d0914f2861b8526e035c5e6da0a3199d8f1add1a665e1cbc6fc6d02 \ - --hash=sha256:8b7ee99e510d7b66cdb6c593f21c043c248537a32e0bedf02e01e9553a172314 \ - --hash=sha256:91fc98adde3d7881af9b59ed0294046f3806221863722ba7d8d120c575314325 \ - --hash=sha256:94411f22c3985acaec6f83c6df553f2dbe17b698cc7f8ae751ff2237d96b9e3c \ - --hash=sha256:98d85c6a2bef81588d9227dde12db8a7f47f639f4a17c9ae08e773aa9c697bf3 \ - --hash=sha256:9ad5db27f9cabae298d151c85cf2bad1d359a1b9c686a275df03385758e2f914 \ - --hash=sha256:a0b71b1b8fbf2b96e41c4d990244165e2c9be83d54962a9a1d118fd8657d2045 \ - --hash=sha256:a0f100c8912c114ff53e1202d0078b425bee3649ae34d7b070e9697f93c5d52d \ - --hash=sha256:a591fe9e525846e4d154205572a029f653ada1a78b93697f3b5a8f1f2bc055b9 \ - --hash=sha256:a5c84c68147988265e60416b57fc83425a78058853509c1b0629c180094904a5 \ - --hash=sha256:a66d3508133af6e8548451b25058d5812812ec3798c886bf38ed24a98216fab2 \ - --hash=sha256:a8c4917bd7ad33e8eb21e9a5bbba979b49d9a97acb3a803092cbc1133e20343c \ - --hash=sha256:b3bbeb01c2b273cca1e1e0c5df57f12dce9a4dd331b4fa1635b8bec26350bde3 \ - --hash=sha256:cba9d6b9a7d64d4bd46167096fc9d2f835e25d7e4c121fb2ddfc6528fb0413b2 \ - --hash=sha256:cc4d65aeeaa04136a12677d3dd0b1c0c94dc43abac5860ab33cceb42b801c1e8 \ - --hash=sha256:ce4bcc037df4fc5e3d184794f27bdaab018943698f4ca31630bc7f84a7b69c6d \ - --hash=sha256:cec7d9412a9102bdc577382c3929b337320c4c4c4849f2c5cdd14d7368c5562d \ - --hash=sha256:d400bfb9a37b1351253cb402671cea7e89bdecc294e8016a707f6d1d8ac934f9 \ - --hash=sha256:d61f4695e6c866a23a21acab0509af1cdfd2c013cf256bbf5b6b5e2695827162 \ - --hash=sha256:db0fbb9c62743ce59a9ff687eb5f4afbe77e5e8403d6697f7446e5f609976f76 \ - --hash=sha256:dd86c085fae2efd48ac91dd7ccffcfc0571387fe1193d33b6394db7ef31fe2a4 \ - --hash=sha256:e00b098126fd45523dd056d2efba6c5a63b71ffe9f2bbe1a4fe1716e1d0c331e \ - --hash=sha256:e229a521186c75c8ad9490854fd8bbdd9a0c9aa3a524326b55be83b54d4e0ad9 \ - --hash=sha256:e263d77ee3dd201c3a142934a086a4450861778baaeeb45db4591ef65550b0a6 \ - --hash=sha256:ed9cb427ba5504c1dc15ede7d516b84757c3e3d7868ccc85121d9310d27eed0b \ - --hash=sha256:fa6693661a4c91757f4412306191b6dc88c1703f780c8234035eac011922bc01 \ - --hash=sha256:fcd131dd944808b5bdb38e6f5b53013c5aa4f334c5cad0c72742f6eba4b73db0 - # via - # -r requirements.in - # cryptography -charset-normalizer==2.0.12 \ - --hash=sha256:2857e29ff0d34db842cd7ca3230549d1a697f96ee6d3fb071cfa6c7393832597 \ - --hash=sha256:6881edbebdb17b39b4eaaa821b438bf6eddffb4468cf344f09f89def34a8b1df - # via requests -click==8.0.4 \ - --hash=sha256:6a7a62563bbfabfda3a38f3023a1db4a35978c0abd76f6c9605ecd6554d6d9b1 \ - --hash=sha256:8458d7b1287c5fb128c90e23381cf99dcde74beaf6c7ff6384ce84d6fe090adb - # via - # gcp-docuploader - # gcp-releasetool -colorlog==6.7.0 \ - --hash=sha256:0d33ca236784a1ba3ff9c532d4964126d8a2c44f1f0cb1d2b0728196f512f662 \ - --hash=sha256:bd94bd21c1e13fac7bd3153f4bc3a7dc0eb0974b8bc2fdf1a989e474f6e582e5 - # via gcp-docuploader -cryptography==38.0.1 \ - --hash=sha256:0297ffc478bdd237f5ca3a7dc96fc0d315670bfa099c04dc3a4a2172008a405a \ - --hash=sha256:10d1f29d6292fc95acb597bacefd5b9e812099d75a6469004fd38ba5471a977f \ - --hash=sha256:16fa61e7481f4b77ef53991075de29fc5bacb582a1244046d2e8b4bb72ef66d0 \ - --hash=sha256:194044c6b89a2f9f169df475cc167f6157eb9151cc69af8a2a163481d45cc407 \ - --hash=sha256:1db3d807a14931fa317f96435695d9ec386be7b84b618cc61cfa5d08b0ae33d7 \ - --hash=sha256:3261725c0ef84e7592597606f6583385fed2a5ec3909f43bc475ade9729a41d6 \ - --hash=sha256:3b72c360427889b40f36dc214630e688c2fe03e16c162ef0aa41da7ab1455153 \ - --hash=sha256:3e3a2599e640927089f932295a9a247fc40a5bdf69b0484532f530471a382750 \ - --hash=sha256:3fc26e22840b77326a764ceb5f02ca2d342305fba08f002a8c1f139540cdfaad \ - --hash=sha256:5067ee7f2bce36b11d0e334abcd1ccf8c541fc0bbdaf57cdd511fdee53e879b6 \ - --hash=sha256:52e7bee800ec869b4031093875279f1ff2ed12c1e2f74923e8f49c916afd1d3b \ - --hash=sha256:64760ba5331e3f1794d0bcaabc0d0c39e8c60bf67d09c93dc0e54189dfd7cfe5 \ - --hash=sha256:765fa194a0f3372d83005ab83ab35d7c5526c4e22951e46059b8ac678b44fa5a \ - --hash=sha256:79473cf8a5cbc471979bd9378c9f425384980fcf2ab6534b18ed7d0d9843987d \ - --hash=sha256:896dd3a66959d3a5ddcfc140a53391f69ff1e8f25d93f0e2e7830c6de90ceb9d \ - --hash=sha256:89ed49784ba88c221756ff4d4755dbc03b3c8d2c5103f6d6b4f83a0fb1e85294 \ - --hash=sha256:ac7e48f7e7261207d750fa7e55eac2d45f720027d5703cd9007e9b37bbb59ac0 \ - --hash=sha256:ad7353f6ddf285aeadfaf79e5a6829110106ff8189391704c1d8801aa0bae45a \ - --hash=sha256:b0163a849b6f315bf52815e238bc2b2346604413fa7c1601eea84bcddb5fb9ac \ - --hash=sha256:b6c9b706316d7b5a137c35e14f4103e2115b088c412140fdbd5f87c73284df61 \ - --hash=sha256:c2e5856248a416767322c8668ef1845ad46ee62629266f84a8f007a317141013 \ - --hash=sha256:ca9f6784ea96b55ff41708b92c3f6aeaebde4c560308e5fbbd3173fbc466e94e \ - --hash=sha256:d1a5bd52d684e49a36582193e0b89ff267704cd4025abefb9e26803adeb3e5fb \ - --hash=sha256:d3971e2749a723e9084dd507584e2a2761f78ad2c638aa31e80bc7a15c9db4f9 \ - --hash=sha256:d4ef6cc305394ed669d4d9eebf10d3a101059bdcf2669c366ec1d14e4fb227bd \ - --hash=sha256:d9e69ae01f99abe6ad646947bba8941e896cb3aa805be2597a0400e0764b5818 - # via - # gcp-releasetool - # secretstorage -gcp-docuploader==0.6.3 \ - --hash=sha256:ba8c9d76b3bbac54b0311c503a373b00edc2dc02d6d54ea9507045adb8e870f7 \ - --hash=sha256:c0f5aaa82ce1854a386197e4e359b120ad6d4e57ae2c812fce42219a3288026b - # via -r requirements.in -gcp-releasetool==1.8.7 \ - --hash=sha256:3d2a67c9db39322194afb3b427e9cb0476ce8f2a04033695f0aeb63979fc2b37 \ - --hash=sha256:5e4d28f66e90780d77f3ecf1e9155852b0c3b13cbccb08ab07e66b2357c8da8d - # via -r requirements.in -google-api-core==2.8.2 \ - --hash=sha256:06f7244c640322b508b125903bb5701bebabce8832f85aba9335ec00b3d02edc \ - --hash=sha256:93c6a91ccac79079ac6bbf8b74ee75db970cc899278b97d53bc012f35908cf50 - # via - # -r requirements.in - # google-cloud-core - # google-cloud-storage -google-auth==2.11.0 \ - --hash=sha256:be62acaae38d0049c21ca90f27a23847245c9f161ff54ede13af2cb6afecbac9 \ - --hash=sha256:ed65ecf9f681832298e29328e1ef0a3676e3732b2e56f41532d45f70a22de0fb - # via - # -r requirements.in - # gcp-releasetool - # google-api-core - # google-cloud-core - # google-cloud-storage -google-cloud-core==2.3.1 \ - --hash=sha256:113ba4f492467d5bd442c8d724c1a25ad7384045c3178369038840ecdd19346c \ - --hash=sha256:34334359cb04187bdc80ddcf613e462dfd7a3aabbc3fe4d118517ab4b9303d53 - # via - # -r requirements.in - # google-cloud-storage -google-cloud-storage==2.0.0 \ - --hash=sha256:a57a15aead0f9dfbd4381f1bfdbe8bf89818a4bd75bab846cafcefb2db846c47 \ - --hash=sha256:ec4be60bb223a3a960f0d01697d849b86d91cad815a84915a32ed3635e93a5e7 - # via - # -r requirements.in - # gcp-docuploader -google-crc32c==1.3.0 \ - --hash=sha256:04e7c220798a72fd0f08242bc8d7a05986b2a08a0573396187fd32c1dcdd58b3 \ - --hash=sha256:05340b60bf05b574159e9bd940152a47d38af3fb43803ffe71f11d704b7696a6 \ - --hash=sha256:12674a4c3b56b706153a358eaa1018c4137a5a04635b92b4652440d3d7386206 \ - --hash=sha256:127f9cc3ac41b6a859bd9dc4321097b1a4f6aa7fdf71b4f9227b9e3ebffb4422 \ - --hash=sha256:13af315c3a0eec8bb8b8d80b8b128cb3fcd17d7e4edafc39647846345a3f003a \ - --hash=sha256:1926fd8de0acb9d15ee757175ce7242e235482a783cd4ec711cc999fc103c24e \ - --hash=sha256:226f2f9b8e128a6ca6a9af9b9e8384f7b53a801907425c9a292553a3a7218ce0 \ - --hash=sha256:276de6273eb074a35bc598f8efbc00c7869c5cf2e29c90748fccc8c898c244df \ - --hash=sha256:318f73f5484b5671f0c7f5f63741ab020a599504ed81d209b5c7129ee4667407 \ - --hash=sha256:3bbce1be3687bbfebe29abdb7631b83e6b25da3f4e1856a1611eb21854b689ea \ - --hash=sha256:42ae4781333e331a1743445931b08ebdad73e188fd554259e772556fc4937c48 \ - --hash=sha256:58be56ae0529c664cc04a9c76e68bb92b091e0194d6e3c50bea7e0f266f73713 \ - --hash=sha256:5da2c81575cc3ccf05d9830f9e8d3c70954819ca9a63828210498c0774fda1a3 \ - --hash=sha256:6311853aa2bba4064d0c28ca54e7b50c4d48e3de04f6770f6c60ebda1e975267 \ - --hash=sha256:650e2917660e696041ab3dcd7abac160b4121cd9a484c08406f24c5964099829 \ - --hash=sha256:6a4db36f9721fdf391646685ecffa404eb986cbe007a3289499020daf72e88a2 \ - --hash=sha256:779cbf1ce375b96111db98fca913c1f5ec11b1d870e529b1dc7354b2681a8c3a \ - --hash=sha256:7f6fe42536d9dcd3e2ffb9d3053f5d05221ae3bbcefbe472bdf2c71c793e3183 \ - --hash=sha256:891f712ce54e0d631370e1f4997b3f182f3368179198efc30d477c75d1f44942 \ - --hash=sha256:95c68a4b9b7828ba0428f8f7e3109c5d476ca44996ed9a5f8aac6269296e2d59 \ - --hash=sha256:96a8918a78d5d64e07c8ea4ed2bc44354e3f93f46a4866a40e8db934e4c0d74b \ - --hash=sha256:9c3cf890c3c0ecfe1510a452a165431b5831e24160c5fcf2071f0f85ca5a47cd \ - --hash=sha256:9f58099ad7affc0754ae42e6d87443299f15d739b0ce03c76f515153a5cda06c \ - --hash=sha256:a0b9e622c3b2b8d0ce32f77eba617ab0d6768b82836391e4f8f9e2074582bf02 \ - --hash=sha256:a7f9cbea4245ee36190f85fe1814e2d7b1e5f2186381b082f5d59f99b7f11328 \ - --hash=sha256:bab4aebd525218bab4ee615786c4581952eadc16b1ff031813a2fd51f0cc7b08 \ - --hash=sha256:c124b8c8779bf2d35d9b721e52d4adb41c9bfbde45e6a3f25f0820caa9aba73f \ - --hash=sha256:c9da0a39b53d2fab3e5467329ed50e951eb91386e9d0d5b12daf593973c3b168 \ - --hash=sha256:ca60076c388728d3b6ac3846842474f4250c91efbfe5afa872d3ffd69dd4b318 \ - --hash=sha256:cb6994fff247987c66a8a4e550ef374671c2b82e3c0d2115e689d21e511a652d \ - --hash=sha256:d1c1d6236feab51200272d79b3d3e0f12cf2cbb12b208c835b175a21efdb0a73 \ - --hash=sha256:dd7760a88a8d3d705ff562aa93f8445ead54f58fd482e4f9e2bafb7e177375d4 \ - --hash=sha256:dda4d8a3bb0b50f540f6ff4b6033f3a74e8bf0bd5320b70fab2c03e512a62812 \ - --hash=sha256:e0f1ff55dde0ebcfbef027edc21f71c205845585fffe30d4ec4979416613e9b3 \ - --hash=sha256:e7a539b9be7b9c00f11ef16b55486141bc2cdb0c54762f84e3c6fc091917436d \ - --hash=sha256:eb0b14523758e37802f27b7f8cd973f5f3d33be7613952c0df904b68c4842f0e \ - --hash=sha256:ed447680ff21c14aaceb6a9f99a5f639f583ccfe4ce1a5e1d48eb41c3d6b3217 \ - --hash=sha256:f52a4ad2568314ee713715b1e2d79ab55fab11e8b304fd1462ff5cccf4264b3e \ - --hash=sha256:fbd60c6aaa07c31d7754edbc2334aef50601b7f1ada67a96eb1eb57c7c72378f \ - --hash=sha256:fc28e0db232c62ca0c3600884933178f0825c99be4474cdd645e378a10588125 \ - --hash=sha256:fe31de3002e7b08eb20823b3735b97c86c5926dd0581c7710a680b418a8709d4 \ - --hash=sha256:fec221a051150eeddfdfcff162e6db92c65ecf46cb0f7bb1bf812a1520ec026b \ - --hash=sha256:ff71073ebf0e42258a42a0b34f2c09ec384977e7f6808999102eedd5b49920e3 - # via - # -r requirements.in - # google-resumable-media -google-resumable-media==2.3.3 \ - --hash=sha256:27c52620bd364d1c8116eaac4ea2afcbfb81ae9139fb3199652fcac1724bfb6c \ - --hash=sha256:5b52774ea7a829a8cdaa8bd2d4c3d4bc660c91b30857ab2668d0eb830f4ea8c5 - # via google-cloud-storage -googleapis-common-protos==1.56.3 \ - --hash=sha256:6f1369b58ed6cf3a4b7054a44ebe8d03b29c309257583a2bbdc064cd1e4a1442 \ - --hash=sha256:87955d7b3a73e6e803f2572a33179de23989ebba725e05ea42f24838b792e461 - # via - # -r requirements.in - # google-api-core -idna==3.4 \ - --hash=sha256:814f528e8dead7d329833b91c5faa87d60bf71824cd12a7530b5526063d02cb4 \ - --hash=sha256:90b77e79eaa3eba6de819a0c442c0b4ceefc341a7a2ab77d7562bf49f425c5c2 - # via - # -r requirements.in - # requests -importlib-metadata==4.8.3 \ - --hash=sha256:65a9576a5b2d58ca44d133c42a241905cc45e34d2c06fd5ba2bafa221e5d7b5e \ - --hash=sha256:766abffff765960fcc18003801f7044eb6755ffae4521c8e8ce8e83b9c9b0668 - # via - # -r requirements.in - # keyring -jeepney==0.7.1 \ - --hash=sha256:1b5a0ea5c0e7b166b2f5895b91a08c14de8915afda4407fb5022a195224958ac \ - --hash=sha256:fa9e232dfa0c498bd0b8a3a73b8d8a31978304dcef0515adc859d4e096f96f4f - # via - # -r requirements.in - # keyring - # secretstorage -jinja2==3.0.3 \ - --hash=sha256:077ce6014f7b40d03b47d1f1ca4b0fc8328a692bd284016f806ed0eaca390ad8 \ - --hash=sha256:611bb273cd68f3b993fabdc4064fc858c5b47a973cb5aa7999ec1ba405c87cd7 - # via - # -r requirements.in - # gcp-releasetool -keyring==23.4.1 \ - --hash=sha256:17e49fb0d6883c2b4445359434dba95aad84aabb29bbff044ad0ed7100232eca \ - --hash=sha256:89cbd74d4683ed164c8082fb38619341097741323b3786905c6dac04d6915a55 - # via - # -r requirements.in - # gcp-releasetool -markupsafe==2.0.1 \ - --hash=sha256:01a9b8ea66f1658938f65b93a85ebe8bc016e6769611be228d797c9d998dd298 \ - --hash=sha256:023cb26ec21ece8dc3907c0e8320058b2e0cb3c55cf9564da612bc325bed5e64 \ - --hash=sha256:0446679737af14f45767963a1a9ef7620189912317d095f2d9ffa183a4d25d2b \ - --hash=sha256:04635854b943835a6ea959e948d19dcd311762c5c0c6e1f0e16ee57022669194 \ - --hash=sha256:0717a7390a68be14b8c793ba258e075c6f4ca819f15edfc2a3a027c823718567 \ - --hash=sha256:0955295dd5eec6cb6cc2fe1698f4c6d84af2e92de33fbcac4111913cd100a6ff \ - --hash=sha256:0d4b31cc67ab36e3392bbf3862cfbadac3db12bdd8b02a2731f509ed5b829724 \ - --hash=sha256:10f82115e21dc0dfec9ab5c0223652f7197feb168c940f3ef61563fc2d6beb74 \ - --hash=sha256:168cd0a3642de83558a5153c8bd34f175a9a6e7f6dc6384b9655d2697312a646 \ - --hash=sha256:1d609f577dc6e1aa17d746f8bd3c31aa4d258f4070d61b2aa5c4166c1539de35 \ - --hash=sha256:1f2ade76b9903f39aa442b4aadd2177decb66525062db244b35d71d0ee8599b6 \ - --hash=sha256:20dca64a3ef2d6e4d5d615a3fd418ad3bde77a47ec8a23d984a12b5b4c74491a \ - --hash=sha256:2a7d351cbd8cfeb19ca00de495e224dea7e7d919659c2841bbb7f420ad03e2d6 \ - --hash=sha256:2d7d807855b419fc2ed3e631034685db6079889a1f01d5d9dac950f764da3dad \ - --hash=sha256:2ef54abee730b502252bcdf31b10dacb0a416229b72c18b19e24a4509f273d26 \ - --hash=sha256:36bc903cbb393720fad60fc28c10de6acf10dc6cc883f3e24ee4012371399a38 \ - --hash=sha256:37205cac2a79194e3750b0af2a5720d95f786a55ce7df90c3af697bfa100eaac \ - --hash=sha256:3c112550557578c26af18a1ccc9e090bfe03832ae994343cfdacd287db6a6ae7 \ - --hash=sha256:3dd007d54ee88b46be476e293f48c85048603f5f516008bee124ddd891398ed6 \ - --hash=sha256:4296f2b1ce8c86a6aea78613c34bb1a672ea0e3de9c6ba08a960efe0b0a09047 \ - --hash=sha256:47ab1e7b91c098ab893b828deafa1203de86d0bc6ab587b160f78fe6c4011f75 \ - --hash=sha256:49e3ceeabbfb9d66c3aef5af3a60cc43b85c33df25ce03d0031a608b0a8b2e3f \ - --hash=sha256:4dc8f9fb58f7364b63fd9f85013b780ef83c11857ae79f2feda41e270468dd9b \ - --hash=sha256:4efca8f86c54b22348a5467704e3fec767b2db12fc39c6d963168ab1d3fc9135 \ - --hash=sha256:53edb4da6925ad13c07b6d26c2a852bd81e364f95301c66e930ab2aef5b5ddd8 \ - --hash=sha256:5855f8438a7d1d458206a2466bf82b0f104a3724bf96a1c781ab731e4201731a \ - --hash=sha256:594c67807fb16238b30c44bdf74f36c02cdf22d1c8cda91ef8a0ed8dabf5620a \ - --hash=sha256:5b6d930f030f8ed98e3e6c98ffa0652bdb82601e7a016ec2ab5d7ff23baa78d1 \ - --hash=sha256:5bb28c636d87e840583ee3adeb78172efc47c8b26127267f54a9c0ec251d41a9 \ - --hash=sha256:60bf42e36abfaf9aff1f50f52644b336d4f0a3fd6d8a60ca0d054ac9f713a864 \ - --hash=sha256:611d1ad9a4288cf3e3c16014564df047fe08410e628f89805e475368bd304914 \ - --hash=sha256:6300b8454aa6930a24b9618fbb54b5a68135092bc666f7b06901f897fa5c2fee \ - --hash=sha256:63f3268ba69ace99cab4e3e3b5840b03340efed0948ab8f78d2fd87ee5442a4f \ - --hash=sha256:6557b31b5e2c9ddf0de32a691f2312a32f77cd7681d8af66c2692efdbef84c18 \ - --hash=sha256:693ce3f9e70a6cf7d2fb9e6c9d8b204b6b39897a2c4a1aa65728d5ac97dcc1d8 \ - --hash=sha256:6a7fae0dd14cf60ad5ff42baa2e95727c3d81ded453457771d02b7d2b3f9c0c2 \ - --hash=sha256:6c4ca60fa24e85fe25b912b01e62cb969d69a23a5d5867682dd3e80b5b02581d \ - --hash=sha256:6fcf051089389abe060c9cd7caa212c707e58153afa2c649f00346ce6d260f1b \ - --hash=sha256:7d91275b0245b1da4d4cfa07e0faedd5b0812efc15b702576d103293e252af1b \ - --hash=sha256:89c687013cb1cd489a0f0ac24febe8c7a666e6e221b783e53ac50ebf68e45d86 \ - --hash=sha256:8d206346619592c6200148b01a2142798c989edcb9c896f9ac9722a99d4e77e6 \ - --hash=sha256:905fec760bd2fa1388bb5b489ee8ee5f7291d692638ea5f67982d968366bef9f \ - --hash=sha256:97383d78eb34da7e1fa37dd273c20ad4320929af65d156e35a5e2d89566d9dfb \ - --hash=sha256:984d76483eb32f1bcb536dc27e4ad56bba4baa70be32fa87152832cdd9db0833 \ - --hash=sha256:99df47edb6bda1249d3e80fdabb1dab8c08ef3975f69aed437cb69d0a5de1e28 \ - --hash=sha256:9f02365d4e99430a12647f09b6cc8bab61a6564363f313126f775eb4f6ef798e \ - --hash=sha256:a30e67a65b53ea0a5e62fe23682cfe22712e01f453b95233b25502f7c61cb415 \ - --hash=sha256:ab3ef638ace319fa26553db0624c4699e31a28bb2a835c5faca8f8acf6a5a902 \ - --hash=sha256:aca6377c0cb8a8253e493c6b451565ac77e98c2951c45f913e0b52facdcff83f \ - --hash=sha256:add36cb2dbb8b736611303cd3bfcee00afd96471b09cda130da3581cbdc56a6d \ - --hash=sha256:b2f4bf27480f5e5e8ce285a8c8fd176c0b03e93dcc6646477d4630e83440c6a9 \ - --hash=sha256:b7f2d075102dc8c794cbde1947378051c4e5180d52d276987b8d28a3bd58c17d \ - --hash=sha256:baa1a4e8f868845af802979fcdbf0bb11f94f1cb7ced4c4b8a351bb60d108145 \ - --hash=sha256:be98f628055368795d818ebf93da628541e10b75b41c559fdf36d104c5787066 \ - --hash=sha256:bf5d821ffabf0ef3533c39c518f3357b171a1651c1ff6827325e4489b0e46c3c \ - --hash=sha256:c47adbc92fc1bb2b3274c4b3a43ae0e4573d9fbff4f54cd484555edbf030baf1 \ - --hash=sha256:cdfba22ea2f0029c9261a4bd07e830a8da012291fbe44dc794e488b6c9bb353a \ - --hash=sha256:d6c7ebd4e944c85e2c3421e612a7057a2f48d478d79e61800d81468a8d842207 \ - --hash=sha256:d7f9850398e85aba693bb640262d3611788b1f29a79f0c93c565694658f4071f \ - --hash=sha256:d8446c54dc28c01e5a2dbac5a25f071f6653e6e40f3a8818e8b45d790fe6ef53 \ - --hash=sha256:deb993cacb280823246a026e3b2d81c493c53de6acfd5e6bfe31ab3402bb37dd \ - --hash=sha256:e0f138900af21926a02425cf736db95be9f4af72ba1bb21453432a07f6082134 \ - --hash=sha256:e9936f0b261d4df76ad22f8fee3ae83b60d7c3e871292cd42f40b81b70afae85 \ - --hash=sha256:f0567c4dc99f264f49fe27da5f735f414c4e7e7dd850cfd8e69f0862d7c74ea9 \ - --hash=sha256:f5653a225f31e113b152e56f154ccbe59eeb1c7487b39b9d9f9cdb58e6c79dc5 \ - --hash=sha256:f826e31d18b516f653fe296d967d700fddad5901ae07c622bb3705955e1faa94 \ - --hash=sha256:f8ba0e8349a38d3001fae7eadded3f6606f0da5d748ee53cc1dab1d6527b9509 \ - --hash=sha256:f9081981fe268bd86831e5c75f7de206ef275defcb82bc70740ae6dc507aee51 \ - --hash=sha256:fa130dd50c57d53368c9d59395cb5526eda596d3ffe36666cd81a44d56e48872 - # via - # -r requirements.in - # jinja2 -packaging==21.3 \ - --hash=sha256:dd47c42927d89ab911e606518907cc2d3a1f38bbd026385970643f9c5b8ecfeb \ - --hash=sha256:ef103e05f519cdc783ae24ea4e2e0f508a9c99b2d4969652eed6a2e1ea5bd522 - # via - # -r requirements.in - # gcp-releasetool -protobuf==3.19.5 \ - --hash=sha256:1867f93b06a183f87696871bb8d1e99ee71dbb69d468ce1f0cc8bf3d30f982f3 \ - --hash=sha256:3c4160b601220627f7e91154e572baf5e161a9c3f445a8242d536ee3d0b7b17c \ - --hash=sha256:4ee2af7051d3b10c8a4fe6fd1a2c69f201fea36aeee7086cf202a692e1b99ee1 \ - --hash=sha256:5266c36cc0af3bb3dbf44f199d225b33da66a9a5c3bdc2b14865ad10eddf0e37 \ - --hash=sha256:5470f892961af464ae6eaf0f3099e2c1190ae8c7f36f174b89491281341f79ca \ - --hash=sha256:66d14b5b90090353efe75c9fb1bf65ef7267383034688d255b500822e37d5c2f \ - --hash=sha256:67efb5d20618020aa9596e17bfc37ca068c28ec0c1507d9507f73c93d46c9855 \ - --hash=sha256:696e6cfab94cc15a14946f2bf72719dced087d437adbd994fff34f38986628bc \ - --hash=sha256:6a02172b9650f819d01fb8e224fc69b0706458fc1ab4f1c669281243c71c1a5e \ - --hash=sha256:6eca9ae238ba615d702387a2ddea635d535d769994a9968c09a4ca920c487ab9 \ - --hash=sha256:950abd6c00e7b51f87ae8b18a0ce4d69fea217f62f171426e77de5061f6d9850 \ - --hash=sha256:9e1d74032f56ff25f417cfe84c8147047732e5059137ca42efad20cbbd25f5e0 \ - --hash=sha256:9e42b1cf2ecd8a1bd161239e693f22035ba99905ae6d7efeac8a0546c7ec1a27 \ - --hash=sha256:9f957ef53e872d58a0afd3bf6d80d48535d28c99b40e75e6634cbc33ea42fd54 \ - --hash=sha256:a89aa0c042e61e11ade320b802d6db4ee5391d8d973e46d3a48172c1597789f8 \ - --hash=sha256:c0f80876a8ff0ae7064084ed094eb86497bd5a3812e6fc96a05318b92301674e \ - --hash=sha256:c44e3282cff74ad18c7e8a0375f407f69ee50c2116364b44492a196293e08b21 \ - --hash=sha256:d249519ba5ecf5dd6b18150c9b6bcde510b273714b696f3923ff8308fc11ae49 \ - --hash=sha256:d3973a2d58aefc7d1230725c2447ce7f86a71cbc094b86a77c6ee1505ac7cdb1 \ - --hash=sha256:dca2284378a5f2a86ffed35c6ac147d14c48b525eefcd1083e5a9ce28dfa8657 \ - --hash=sha256:e63b0b3c42e51c94add62b010366cd4979cb6d5f06158bcae8faac4c294f91e1 \ - --hash=sha256:f2b599a21c9a32e171ec29a2ac54e03297736c578698e11b099d031f79da114b \ - --hash=sha256:f2bde37667b18c2b5280df83bc799204394a5d2d774e4deaf9de0eb741df6833 \ - --hash=sha256:f4f909f4dde413dec435a44b0894956d55bb928ded7d6e3c726556ca4c796e84 \ - --hash=sha256:f976234e20ab2785f54224bcdafa027674e23663b132fa3ca0caa291a6cfbde7 \ - --hash=sha256:f9cebda093c2f6bfed88f1c17cdade09d4d96096421b344026feee236532d4de - # via - # -r requirements.in - # gcp-docuploader - # gcp-releasetool - # google-api-core - # google-cloud-storage - # googleapis-common-protos -pyasn1==0.4.8 \ - --hash=sha256:39c7e2ec30515947ff4e87fb6f456dfc6e84857d34be479c9d4a4ba4bf46aa5d \ - --hash=sha256:aef77c9fb94a3ac588e87841208bdec464471d9871bd5050a287cc9a475cd0ba - # via - # pyasn1-modules - # rsa -pyasn1-modules==0.2.8 \ - --hash=sha256:905f84c712230b2c592c19470d3ca8d552de726050d1d1716282a1f6146be65e \ - --hash=sha256:a50b808ffeb97cb3601dd25981f6b016cbb3d31fbf57a8b8a87428e6158d0c74 - # via google-auth -pycparser==2.21 \ - --hash=sha256:8ee45429555515e1f6b185e78100aea234072576aa43ab53aefcae078162fca9 \ - --hash=sha256:e644fdec12f7872f86c58ff790da456218b10f863970249516d60a5eaca77206 - # via - # -r requirements.in - # cffi -pyjwt==2.4.0 \ - --hash=sha256:72d1d253f32dbd4f5c88eaf1fdc62f3a19f676ccbadb9dbc5d07e951b2b26daf \ - --hash=sha256:d42908208c699b3b973cbeb01a969ba6a96c821eefb1c5bfe4c390c01d67abba - # via - # -r requirements.in - # gcp-releasetool -pyparsing==3.0.9 \ - --hash=sha256:2b020ecf7d21b687f219b71ecad3631f644a47f01403fa1d1036b0c6416d70fb \ - --hash=sha256:5026bae9a10eeaefb61dab2f09052b9f4307d44aee4eda64b309723d8d206bbc - # via - # -r requirements.in - # packaging -pyperclip==1.8.2 \ - --hash=sha256:105254a8b04934f0bc84e9c24eb360a591aaf6535c9def5f29d92af107a9bf57 - # via - # -r requirements.in - # gcp-releasetool -python-dateutil==2.8.2 \ - --hash=sha256:0123cacc1627ae19ddf3c27a5de5bd67ee4586fbdd6440d9748f8abb483d3e86 \ - --hash=sha256:961d03dc3453ebbc59dbdea9e4e11c5651520a876d0f4db161e8674aae935da9 - # via - # -r requirements.in - # gcp-releasetool -requests==2.27.1 \ - --hash=sha256:68d7c56fd5a8999887728ef304a6d12edc7be74f1cfa47714fc8b414525c9a61 \ - --hash=sha256:f22fa1e554c9ddfd16e6e41ac79759e17be9e492b3587efa038054674760e72d - # via - # -r requirements.in - # gcp-releasetool - # google-api-core - # google-cloud-storage -rsa==4.9 \ - --hash=sha256:90260d9058e514786967344d0ef75fa8727eed8a7d2e43ce9f4bcf1b536174f7 \ - --hash=sha256:e38464a49c6c85d7f1351b0126661487a7e0a14a50f1675ec50eb34d4f20ef21 - # via - # -r requirements.in - # google-auth -secretstorage==3.3.3 \ - --hash=sha256:2403533ef369eca6d2ba81718576c5e0f564d5cca1b58f73a8b23e7d4eeebd77 \ - --hash=sha256:f356e6628222568e3af06f2eba8df495efa13b3b63081dafd4f7d9a7b7bc9f99 - # via keyring -six==1.16.0 \ - --hash=sha256:1e61c37477a1626458e36f7b1d82aa5c9b094fa4802892072e49de9c60c4c926 \ - --hash=sha256:8abb2f1d86890a2dfb989f9a77cfcfd3e47c2a354b01111771326f8aa26e0254 - # via - # -r requirements.in - # gcp-docuploader - # google-auth - # python-dateutil -typing-extensions==4.1.1 \ - --hash=sha256:1a9462dcc3347a79b1f1c0271fbe79e844580bb598bafa1ed208b94da3cdcd42 \ - --hash=sha256:21c85e0fe4b9a155d0799430b0ad741cdce7e359660ccbd8b530613e8df88ce2 - # via -r requirements.in -urllib3==1.26.12 \ - --hash=sha256:3fa96cf423e6987997fc326ae8df396db2a8b7c667747d47ddd8ecba91f4a74e \ - --hash=sha256:b930dd878d5a8afb066a637fbb35144fe7901e3b209d1cd4f524bd0e9deee997 - # via - # -r requirements.in - # requests -zipp==3.6.0 \ - --hash=sha256:71c644c5369f4a6e07636f0aa966270449561fcea2e3d6747b8d23efaa9d7832 \ - --hash=sha256:9fe5ea21568a0a70e50f273397638d39b03353731e6cbbb3fd8502a33fec40bc - # via - # -r requirements.in - # importlib-metadata diff --git a/.kokoro/trampoline.sh b/.kokoro/trampoline.sh deleted file mode 100644 index 8b69b793..00000000 --- a/.kokoro/trampoline.sh +++ /dev/null @@ -1,26 +0,0 @@ -#!/bin/bash -# Copyright 2018 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -set -eo pipefail -# Always run the cleanup script, regardless of the success of bouncing into -# the container. -function cleanup() { - chmod +x ${KOKORO_GFILE_DIR}/trampoline_cleanup.sh - ${KOKORO_GFILE_DIR}/trampoline_cleanup.sh - echo "cleanup"; -} -trap cleanup EXIT - -$(dirname $0)/populate-secrets.sh # Secret Manager secrets. -python3 "${KOKORO_GFILE_DIR}/trampoline_v1.py" diff --git a/.repo-metadata.json b/.repo-metadata.json deleted file mode 100644 index 9241b6fb..00000000 --- a/.repo-metadata.json +++ /dev/null @@ -1,17 +0,0 @@ -{ - "api_shortname": "cloudiot", - "name_pretty": "Cloud Internet of Things (IoT) Core", - "product_documentation": "https://cloud.google.com/iot", - "client_documentation": "https://cloud.google.com/java/docs/reference/google-cloud-iot/latest/history", - "issue_tracker": "https://issuetracker.google.com/issues?q=status:open%20componentid:310170", - "release_level": "stable", - "language": "java", - "repo": "googleapis/java-iot", - "repo_short": "java-iot", - "distribution_name": "com.google.cloud:google-cloud-iot", - "api_id": "cloudiot.googleapis.com", - "transport": "grpc", - "requires_billing": true, - "api_description": "is a complete set of tools to connect, process, store, and analyze data both at the edge and in the cloud. The platform consists of scalable, fully-managed cloud services; an integrated software stack for edge/on-premises computing with machine learning capabilities for all your IoT needs.", - "library_type": "GAPIC_AUTO" -} diff --git a/CHANGELOG.md b/CHANGELOG.md deleted file mode 100644 index 0400f3b8..00000000 --- a/CHANGELOG.md +++ /dev/null @@ -1,494 +0,0 @@ -# Changelog - -## [2.3.5](https://github.com/googleapis/java-iot/compare/v2.3.4...v2.3.5) (2022-10-03) - - -### Dependencies - -* Update dependency cachetools to v5 ([#796](https://github.com/googleapis/java-iot/issues/796)) ([13c40c0](https://github.com/googleapis/java-iot/commit/13c40c00900bf6ef7d0ec85ba12990399f2f0acb)) -* Update dependency certifi to v2022.9.24 ([#776](https://github.com/googleapis/java-iot/issues/776)) ([27d967b](https://github.com/googleapis/java-iot/commit/27d967bfc4c8d18ff5868f594ca9ce5f9ab819c9)) -* Update dependency charset-normalizer to v2.1.1 ([#780](https://github.com/googleapis/java-iot/issues/780)) ([31175a8](https://github.com/googleapis/java-iot/commit/31175a8ef23d32ca3e7466aefd5ca127513be3b2)) -* Update dependency click to v8.1.3 ([#782](https://github.com/googleapis/java-iot/issues/782)) ([b29aac4](https://github.com/googleapis/java-iot/commit/b29aac47bf782afa730201a2ee38e52269a57773)) -* Update dependency com.google.cloud:google-cloud-shared-dependencies to v3.0.4 ([#801](https://github.com/googleapis/java-iot/issues/801)) ([5aaca23](https://github.com/googleapis/java-iot/commit/5aaca23ead7950d90997a663ad19cfbe43e34b4a)) -* Update dependency gcp-releasetool to v1.8.8 ([#777](https://github.com/googleapis/java-iot/issues/777)) ([efd99d2](https://github.com/googleapis/java-iot/commit/efd99d2bbdaba94dd1153f9f542bf4f64b722909)) -* Update dependency google-api-core to v2.10.1 ([#783](https://github.com/googleapis/java-iot/issues/783)) ([6cf9827](https://github.com/googleapis/java-iot/commit/6cf982706d553957bc4a4b8e7310dd08bd6f14ed)) -* Update dependency google-auth to v2.12.0 ([#784](https://github.com/googleapis/java-iot/issues/784)) ([af599e9](https://github.com/googleapis/java-iot/commit/af599e98b6aa14246fffb77d424e600d054dee05)) -* Update dependency google-cloud-core to v2.3.2 ([#778](https://github.com/googleapis/java-iot/issues/778)) ([13fe93a](https://github.com/googleapis/java-iot/commit/13fe93a833d709663df7beede1a0c7d7134bf220)) -* Update dependency google-cloud-storage to v2.5.0 ([#785](https://github.com/googleapis/java-iot/issues/785)) ([6250d45](https://github.com/googleapis/java-iot/commit/6250d45704d6a1b5fe7c6cd5bc31918f2a55349e)) -* Update dependency google-crc32c to v1.5.0 ([#786](https://github.com/googleapis/java-iot/issues/786)) ([35a4c8b](https://github.com/googleapis/java-iot/commit/35a4c8ba0dea3234b6a7e29f41191ebbd0eede7f)) -* Update dependency googleapis-common-protos to v1.56.4 ([#779](https://github.com/googleapis/java-iot/issues/779)) ([9ebbbd9](https://github.com/googleapis/java-iot/commit/9ebbbd9f206205cb1b6cdf0b5fdafdc931e6a5ac)) -* Update dependency importlib-metadata to v4.12.0 ([#787](https://github.com/googleapis/java-iot/issues/787)) ([64f2a73](https://github.com/googleapis/java-iot/commit/64f2a73aaf15ff127d9bc20178e69db54f074bfa)) -* Update dependency jeepney to v0.8.0 ([#788](https://github.com/googleapis/java-iot/issues/788)) ([9e99be7](https://github.com/googleapis/java-iot/commit/9e99be7bb50c6591dbb077279e793655fa74548e)) -* Update dependency jinja2 to v3.1.2 ([#789](https://github.com/googleapis/java-iot/issues/789)) ([4638fff](https://github.com/googleapis/java-iot/commit/4638fffbf442b7d8fd73e12c8733d216a25b8b40)) -* Update dependency keyring to v23.9.3 ([#790](https://github.com/googleapis/java-iot/issues/790)) ([2c197aa](https://github.com/googleapis/java-iot/commit/2c197aa52a57afb49d82d4730b8627966558844a)) -* Update dependency markupsafe to v2.1.1 ([#781](https://github.com/googleapis/java-iot/issues/781)) ([664d31e](https://github.com/googleapis/java-iot/commit/664d31e93916f720716fe0a5ab34be245294f723)) -* Update dependency protobuf to v3.20.2 ([#791](https://github.com/googleapis/java-iot/issues/791)) ([3e9c38c](https://github.com/googleapis/java-iot/commit/3e9c38c2b039660e68d3fb43b1186665c479fac3)) -* Update dependency protobuf to v4 ([#797](https://github.com/googleapis/java-iot/issues/797)) ([acd00dd](https://github.com/googleapis/java-iot/commit/acd00dd0fd3f46b0f3cbbda26409ac0c8f4809c4)) -* Update dependency typing-extensions to v4.3.0 ([#794](https://github.com/googleapis/java-iot/issues/794)) ([5a80492](https://github.com/googleapis/java-iot/commit/5a8049249f7e8ad5dec08d00d8ecceda3bb17efc)) -* Update dependency zipp to v3.8.1 ([#795](https://github.com/googleapis/java-iot/issues/795)) ([e5ae448](https://github.com/googleapis/java-iot/commit/e5ae448ad2f5fb22ff6ac7047b642959a40f1795)) - -## [2.3.4](https://github.com/googleapis/java-iot/compare/v2.3.3...v2.3.4) (2022-09-15) - - -### Dependencies - -* Update dependency com.google.cloud:google-cloud-shared-dependencies to v3.0.3 ([#769](https://github.com/googleapis/java-iot/issues/769)) ([e6531c4](https://github.com/googleapis/java-iot/commit/e6531c424e06c0c867907011c5a312568f3d4c0f)) - -## [2.3.3](https://github.com/googleapis/java-iot/compare/v2.3.2...v2.3.3) (2022-09-09) - - -### Dependencies - -* Update dependency com.google.cloud:google-cloud-shared-dependencies to v3.0.2 ([#764](https://github.com/googleapis/java-iot/issues/764)) ([45f17bf](https://github.com/googleapis/java-iot/commit/45f17bf034c3b097ec641838e24f79da0da49b0a)) - -## [2.3.2](https://github.com/googleapis/java-iot/compare/v2.3.1...v2.3.2) (2022-08-09) - - -### Dependencies - -* update dependency com.google.cloud:google-cloud-shared-dependencies to v3 ([#753](https://github.com/googleapis/java-iot/issues/753)) ([336679d](https://github.com/googleapis/java-iot/commit/336679dc3bd02a1658b4a6dbf27523bb55e33ce4)) - -## [2.3.1](https://github.com/googleapis/java-iot/compare/v2.3.0...v2.3.1) (2022-07-13) - - -### Bug Fixes - -* enable longpaths support for windows test ([#1485](https://github.com/googleapis/java-iot/issues/1485)) ([#747](https://github.com/googleapis/java-iot/issues/747)) ([93a62e2](https://github.com/googleapis/java-iot/commit/93a62e289e62e9a94c018cf925b4884181380dab)) - -## [2.3.0](https://github.com/googleapis/java-iot/compare/v2.2.1...v2.3.0) (2022-07-01) - - -### Features - -* Enable REST transport for most of Java and Go clients ([#734](https://github.com/googleapis/java-iot/issues/734)) ([21fa6cc](https://github.com/googleapis/java-iot/commit/21fa6ccea1a7c7489f374c90fd7354c54b15e925)) - -## [2.2.1](https://github.com/googleapis/java-iot/compare/v2.2.0...v2.2.1) (2022-06-23) - - -### Dependencies - -* update dependency com.google.cloud:google-cloud-shared-dependencies to v2.13.0 ([#733](https://github.com/googleapis/java-iot/issues/733)) ([8e216cb](https://github.com/googleapis/java-iot/commit/8e216cbf0b23315793db24e0f7a42d38c1c81fc8)) - -## [2.2.0](https://github.com/googleapis/java-iot/compare/v2.1.10...v2.2.0) (2022-05-24) - - -### Features - -* add build scripts for native image testing in Java 17 ([#1440](https://github.com/googleapis/java-iot/issues/1440)) ([#724](https://github.com/googleapis/java-iot/issues/724)) ([fd58590](https://github.com/googleapis/java-iot/commit/fd585903e6ea00080ac335843b3ce82837009470)) -* AuditConfig for IAM v1 ([ed54ce1](https://github.com/googleapis/java-iot/commit/ed54ce113925c0ccf55e7758d8b1fd97c712ed45)) - - -### Dependencies - -* update dependency com.google.cloud:google-cloud-shared-dependencies to v2.12.0 ([#723](https://github.com/googleapis/java-iot/issues/723)) ([40b82e2](https://github.com/googleapis/java-iot/commit/40b82e243a8b684e07a39bda35a7b7b16f072ab4)) - -### [2.1.10](https://github.com/googleapis/java-iot/compare/v2.1.9...v2.1.10) (2022-04-15) - - -### Dependencies - -* update dependency com.google.cloud:google-cloud-shared-dependencies to v2.10.0 ([#711](https://github.com/googleapis/java-iot/issues/711)) ([7911cc0](https://github.com/googleapis/java-iot/commit/7911cc03ffc7f81c488655d981a71ee752feb6bf)) - -### [2.1.9](https://github.com/googleapis/java-iot/compare/v2.1.8...v2.1.9) (2022-03-29) - - -### Dependencies - -* update dependency com.google.cloud:google-cloud-shared-dependencies to v2.9.0 ([#704](https://github.com/googleapis/java-iot/issues/704)) ([87daba1](https://github.com/googleapis/java-iot/commit/87daba169750a091368123f97fe84e41ca07c562)) - -### [2.1.8](https://github.com/googleapis/java-iot/compare/v2.1.7...v2.1.8) (2022-03-02) - - -### Dependencies - -* update dependency com.google.cloud:google-cloud-shared-dependencies to v2.8.0 ([#694](https://github.com/googleapis/java-iot/issues/694)) ([ddd037c](https://github.com/googleapis/java-iot/commit/ddd037c56843b5a52919833819064d835de75b3f)) - -### [2.1.7](https://github.com/googleapis/java-iot/compare/v2.1.6...v2.1.7) (2022-02-28) - - -### Dependencies - -* update actions/setup-java action to v3 ([#686](https://github.com/googleapis/java-iot/issues/686)) ([d4c341f](https://github.com/googleapis/java-iot/commit/d4c341fd778fe77d1c6e22807beb5772796460b9)) - -### [2.1.6](https://github.com/googleapis/java-iot/compare/v2.1.5...v2.1.6) (2022-02-03) - - -### Dependencies - -* **java:** update actions/github-script action to v5 ([#1339](https://github.com/googleapis/java-iot/issues/1339)) ([#669](https://github.com/googleapis/java-iot/issues/669)) ([1cbfb0c](https://github.com/googleapis/java-iot/commit/1cbfb0c56c4197e141871b627cad95b5b73814b2)) -* update actions/github-script action to v5 ([#668](https://github.com/googleapis/java-iot/issues/668)) ([c4d4901](https://github.com/googleapis/java-iot/commit/c4d4901d9b07be8004f3bd6b04df9fcc44a99de0)) -* update dependency com.google.cloud:google-cloud-shared-dependencies to v2.7.0 ([#671](https://github.com/googleapis/java-iot/issues/671)) ([8b15b63](https://github.com/googleapis/java-iot/commit/8b15b6332a75643cd8c63369b6602b295b90ebab)) - -### [2.1.5](https://www.github.com/googleapis/java-iot/compare/v2.1.4...v2.1.5) (2022-01-07) - - -### Bug Fixes - -* **java:** add -ntp flag to native image testing command ([#1299](https://www.github.com/googleapis/java-iot/issues/1299)) ([#646](https://www.github.com/googleapis/java-iot/issues/646)) ([dcb46c9](https://www.github.com/googleapis/java-iot/commit/dcb46c97122c06afe2862b9ac0a942cb0c60f795)) -* **java:** run Maven in plain console-friendly mode ([#1301](https://www.github.com/googleapis/java-iot/issues/1301)) ([#652](https://www.github.com/googleapis/java-iot/issues/652)) ([7aeb5f5](https://www.github.com/googleapis/java-iot/commit/7aeb5f5bd1174766864aa723adc1863446dc10c7)) - - -### Dependencies - -* update dependency com.google.cloud:google-cloud-shared-dependencies to v2.6.0 ([#655](https://www.github.com/googleapis/java-iot/issues/655)) ([4dec841](https://www.github.com/googleapis/java-iot/commit/4dec8416347514fc93d05d6daf25e1f8c27899d5)) - -### [2.1.4](https://www.github.com/googleapis/java-iot/compare/v2.1.3...v2.1.4) (2021-12-03) - - -### Bug Fixes - -* **java:** java 17 dependency arguments ([#1266](https://www.github.com/googleapis/java-iot/issues/1266)) ([#628](https://www.github.com/googleapis/java-iot/issues/628)) ([eefb123](https://www.github.com/googleapis/java-iot/commit/eefb123a2faf601062af07ae8119643d64f5f424)) - - -### Dependencies - -* update dependency com.google.cloud:google-cloud-shared-dependencies to v2.5.0 ([#638](https://www.github.com/googleapis/java-iot/issues/638)) ([4d080af](https://www.github.com/googleapis/java-iot/commit/4d080af650c3c8ad96a607fbe7a036048ff4b86e)) -* update dependency com.google.cloud:google-cloud-shared-dependencies to v2.5.1 ([#643](https://www.github.com/googleapis/java-iot/issues/643)) ([1c46464](https://www.github.com/googleapis/java-iot/commit/1c46464b7bf1d0eb51280e84f3f31975ba0e4848)) - -### [2.1.3](https://www.github.com/googleapis/java-iot/compare/v2.1.2...v2.1.3) (2021-10-20) - - -### Dependencies - -* update dependency com.google.cloud:google-cloud-shared-dependencies to v2.4.0 ([#623](https://www.github.com/googleapis/java-iot/issues/623)) ([dd1fb94](https://www.github.com/googleapis/java-iot/commit/dd1fb9401e8e53c80834cde56a779cb1ab402e49)) - -### [2.1.2](https://www.github.com/googleapis/java-iot/compare/v2.1.1...v2.1.2) (2021-09-22) - - -### Dependencies - -* update dependency com.google.cloud:google-cloud-shared-dependencies to v2.3.0 ([#609](https://www.github.com/googleapis/java-iot/issues/609)) ([5164f18](https://www.github.com/googleapis/java-iot/commit/5164f188229d07d7ad86aa9bcf74353f70667acf)) - -### [2.1.1](https://www.github.com/googleapis/java-iot/compare/v2.1.0...v2.1.1) (2021-09-14) - - -### Dependencies - -* update dependency com.google.cloud:google-cloud-shared-dependencies to v2.2.1 ([#602](https://www.github.com/googleapis/java-iot/issues/602)) ([1adda1f](https://www.github.com/googleapis/java-iot/commit/1adda1fbf953a6deb8045b454b1e3540bbe72983)) - -## [2.1.0](https://www.github.com/googleapis/java-iot/compare/v2.0.2...v2.1.0) (2021-09-01) - - -### Features - -* Remove use of deprecated gradle command in java README ([#1196](https://www.github.com/googleapis/java-iot/issues/1196)) ([#587](https://www.github.com/googleapis/java-iot/issues/587)) ([944c08a](https://www.github.com/googleapis/java-iot/commit/944c08a98c04511734fc4bed2524d84330e6634f)) - - -### Dependencies - -* update dependency com.google.cloud:google-cloud-shared-dependencies to v2.2.0 ([#590](https://www.github.com/googleapis/java-iot/issues/590)) ([dd89994](https://www.github.com/googleapis/java-iot/commit/dd899945a0036a474ffe6087e16a09e31cf20276)) - -### [2.0.2](https://www.github.com/googleapis/java-iot/compare/v2.0.1...v2.0.2) (2021-08-23) - - -### Dependencies - -* update dependency com.google.cloud:google-cloud-shared-dependencies to v2.1.0 ([#579](https://www.github.com/googleapis/java-iot/issues/579)) ([eb46418](https://www.github.com/googleapis/java-iot/commit/eb46418919ab783d2f2e8aaf5a8bc7baaeacb524)) - -### [2.0.1](https://www.github.com/googleapis/java-iot/compare/v2.0.0...v2.0.1) (2021-08-12) - - -### Dependencies - -* update dependency com.google.cloud:google-cloud-shared-dependencies to v2.0.1 ([#571](https://www.github.com/googleapis/java-iot/issues/571)) ([04a3172](https://www.github.com/googleapis/java-iot/commit/04a3172a25fb2d17b533ee52fcd43144f2e03105)) - -## [2.0.0](https://www.github.com/googleapis/java-iot/compare/v1.3.2...v2.0.0) (2021-08-10) - - -### ⚠ BREAKING CHANGES - -* release gapic-generator-java v2.0.0 (#562) - -### Features - -* release gapic-generator-java v2.0.0 ([#562](https://www.github.com/googleapis/java-iot/issues/562)) ([413e8f1](https://www.github.com/googleapis/java-iot/commit/413e8f110c371d2ed919e4c31685fac8a3aa58f3)) - - -### Dependencies - -* update dependency com.google.cloud:google-cloud-shared-dependencies to v2 ([#563](https://www.github.com/googleapis/java-iot/issues/563)) ([cc1b78d](https://www.github.com/googleapis/java-iot/commit/cc1b78dd0e9f440404da838c7c405d3231429aa2)) - -### [1.3.2](https://www.github.com/googleapis/java-iot/compare/v1.3.1...v1.3.2) (2021-07-01) - - -### Dependencies - -* update dependency com.google.cloud:google-cloud-shared-dependencies to v1.4.0 ([#495](https://www.github.com/googleapis/java-iot/issues/495)) ([f491778](https://www.github.com/googleapis/java-iot/commit/f4917783f293cf9194b2b232fe0f1bf55451f707)) - -### [1.3.1](https://www.github.com/googleapis/java-iot/compare/v1.3.0...v1.3.1) (2021-06-04) - - -### Dependencies - -* update dependency com.google.cloud:google-cloud-shared-dependencies to v1.3.0 ([#476](https://www.github.com/googleapis/java-iot/issues/476)) ([80e67b4](https://www.github.com/googleapis/java-iot/commit/80e67b4a3e114bcaaf5c0be781abacfa77ee79f6)) - -## [1.3.0](https://www.github.com/googleapis/java-iot/compare/v1.2.3...v1.3.0) (2021-05-26) - - -### Features - -* add `gcf-owl-bot[bot]` to `ignoreAuthors` ([#461](https://www.github.com/googleapis/java-iot/issues/461)) ([0660812](https://www.github.com/googleapis/java-iot/commit/06608126cd1ce2d980c87518c79e3f825380a8dd)) -* add blunderbuss config to cloud iot label ([#422](https://www.github.com/googleapis/java-iot/issues/422)) ([6eb088e](https://www.github.com/googleapis/java-iot/commit/6eb088efb53bb285bb6ca99f54b04b6403305fdd)) - - -### Dependencies - -* update dependency com.google.cloud:google-cloud-shared-dependencies to v1.2.0 ([#460](https://www.github.com/googleapis/java-iot/issues/460)) ([8b9624a](https://www.github.com/googleapis/java-iot/commit/8b9624ad6732e1f9a6c958eb36ba0ef15d171df7)) - -### [1.2.3](https://www.github.com/googleapis/java-iot/compare/v1.2.2...v1.2.3) (2021-05-14) - - -### Dependencies - -* update dependency com.google.cloud:google-cloud-shared-dependencies to v1.1.0 ([#451](https://www.github.com/googleapis/java-iot/issues/451)) ([ec33a85](https://www.github.com/googleapis/java-iot/commit/ec33a85715c24b26dcc180047d6f81e378c9dd88)) - -### [1.2.2](https://www.github.com/googleapis/java-iot/compare/v1.2.1...v1.2.2) (2021-04-23) - - -### Bug Fixes - -* release scripts from issuing overlapping phases ([#430](https://www.github.com/googleapis/java-iot/issues/430)) ([f210f43](https://www.github.com/googleapis/java-iot/commit/f210f43821fc883503b9f453c35b9b101e7784eb)) -* typo ([#427](https://www.github.com/googleapis/java-iot/issues/427)) ([e7a6dfb](https://www.github.com/googleapis/java-iot/commit/e7a6dfb3c5cecb18dce4cfb3c74c0f7c126da4b9)) - - -### Dependencies - -* update dependency com.google.cloud:google-cloud-shared-dependencies to v0.21.1 ([#433](https://www.github.com/googleapis/java-iot/issues/433)) ([88a624c](https://www.github.com/googleapis/java-iot/commit/88a624c019fe00e3f8c5d9c1200370d78b8bc3d9)) -* update dependency com.google.cloud:google-cloud-shared-dependencies to v1 ([#436](https://www.github.com/googleapis/java-iot/issues/436)) ([9df5b96](https://www.github.com/googleapis/java-iot/commit/9df5b962e152c03dbc2bec65c786b5ddff3ee401)) - -### [1.2.1](https://www.github.com/googleapis/java-iot/compare/v1.2.0...v1.2.1) (2021-04-09) - - -### Dependencies - -* update dependency com.google.cloud:google-cloud-shared-dependencies to v0.21.0 ([#415](https://www.github.com/googleapis/java-iot/issues/415)) ([33c4371](https://www.github.com/googleapis/java-iot/commit/33c437140f24740500f4c51c9fd532fff4e75cb5)) - -## [1.2.0](https://www.github.com/googleapis/java-iot/compare/v1.1.14...v1.2.0) (2021-03-11) - - -### Features - -* **generator:** update protoc to v3.15.3 ([#389](https://www.github.com/googleapis/java-iot/issues/389)) ([7c7af19](https://www.github.com/googleapis/java-iot/commit/7c7af19f806ae6a13461b38af811d0e56f627089)) - - -### Dependencies - -* update dependency com.google.cloud:google-cloud-shared-dependencies to v0.20.1 ([#400](https://www.github.com/googleapis/java-iot/issues/400)) ([6981d80](https://www.github.com/googleapis/java-iot/commit/6981d802f101912c1ae7e8f671e9179ab4561c7c)) - -### [1.1.14](https://www.github.com/googleapis/java-iot/compare/v1.1.13...v1.1.14) (2021-02-25) - - -### Dependencies - -* update dependency com.google.cloud:google-cloud-shared-dependencies to v0.20.0 ([#384](https://www.github.com/googleapis/java-iot/issues/384)) ([a160727](https://www.github.com/googleapis/java-iot/commit/a16072783ce70c269bf69efff11cf74e5a8ee200)) - -### [1.1.13](https://www.github.com/googleapis/java-iot/compare/v1.1.12...v1.1.13) (2021-02-22) - - -### Dependencies - -* update dependency com.google.cloud:google-cloud-shared-dependencies to v0.19.0 ([#373](https://www.github.com/googleapis/java-iot/issues/373)) ([fc78b63](https://www.github.com/googleapis/java-iot/commit/fc78b63d49c72b33b154840c445cb7d545504d07)) - -### [1.1.12](https://www.github.com/googleapis/java-iot/compare/v1.1.11...v1.1.12) (2021-02-09) - - -### Bug Fixes - -* update repo name ([#355](https://www.github.com/googleapis/java-iot/issues/355)) ([f62acec](https://www.github.com/googleapis/java-iot/commit/f62acec74a9b5ac0455aaaf6b56aadfd8407f40e)) - -### [1.1.11](https://www.github.com/googleapis/java-iot/compare/v1.1.10...v1.1.11) (2021-01-14) - - -### Dependencies - -* update dependency com.google.cloud:google-cloud-shared-dependencies to v0.18.0 ([#336](https://www.github.com/googleapis/java-iot/issues/336)) ([752b95a](https://www.github.com/googleapis/java-iot/commit/752b95a91bec6882f9ed868e300990e1862ca5a8)) - -### [1.1.10](https://www.github.com/googleapis/java-iot/compare/v1.1.9...v1.1.10) (2020-12-15) - - -### Dependencies - -* update dependency com.google.cloud:google-cloud-shared-dependencies to v0.17.0 ([#324](https://www.github.com/googleapis/java-iot/issues/324)) ([29c5962](https://www.github.com/googleapis/java-iot/commit/29c5962ab4e4e9fbf6286269a72c963792f68669)) - -### [1.1.9](https://www.github.com/googleapis/java-iot/compare/v1.1.8...v1.1.9) (2020-12-14) - - -### Dependencies - -* update dependency com.google.cloud:google-cloud-shared-dependencies to v0.16.1 ([#319](https://www.github.com/googleapis/java-iot/issues/319)) ([4e4b532](https://www.github.com/googleapis/java-iot/commit/4e4b532484eff8a83797cdc83af51fa0fbcb6053)) - -### [1.1.8](https://www.github.com/googleapis/java-iot/compare/v1.1.7...v1.1.8) (2020-12-02) - - -### Dependencies - -* update dependency com.google.cloud:google-cloud-shared-dependencies to v0.16.0 ([#310](https://www.github.com/googleapis/java-iot/issues/310)) ([83a6954](https://www.github.com/googleapis/java-iot/commit/83a6954f2899ed902bb6d68209739ee1aa6e23f5)) - -### [1.1.7](https://www.github.com/googleapis/java-iot/compare/v1.1.6...v1.1.7) (2020-11-11) - - -### Dependencies - -* update dependency com.google.cloud:google-cloud-shared-dependencies to v0.15.0 ([#292](https://www.github.com/googleapis/java-iot/issues/292)) ([65828cf](https://www.github.com/googleapis/java-iot/commit/65828cf27c9044b607f88135c70d8691e2ce485f)) - -### [1.1.6](https://www.github.com/googleapis/java-iot/compare/v1.1.5...v1.1.6) (2020-11-02) - - -### Dependencies - -* update dependency com.google.cloud:google-cloud-shared-dependencies to v0.14.1 ([#280](https://www.github.com/googleapis/java-iot/issues/280)) ([689d2ff](https://www.github.com/googleapis/java-iot/commit/689d2ffdf7ae2e9eb5dd62a55fd078761f58c337)) - -### [1.1.5](https://www.github.com/googleapis/java-iot/compare/v1.1.4...v1.1.5) (2020-10-21) - - -### Dependencies - -* update dependency com.google.cloud:google-cloud-shared-dependencies to v0.13.0 ([#265](https://www.github.com/googleapis/java-iot/issues/265)) ([d6e1444](https://www.github.com/googleapis/java-iot/commit/d6e1444a49e28df36d956450dd13419ddff99d5d)) - -### [1.1.4](https://www.github.com/googleapis/java-iot/compare/v1.1.3...v1.1.4) (2020-10-19) - - -### Dependencies - -* update dependency com.google.cloud:google-cloud-shared-dependencies to v0.12.1 ([#258](https://www.github.com/googleapis/java-iot/issues/258)) ([7015034](https://www.github.com/googleapis/java-iot/commit/701503477e4d55680217dcb7529cf72303186863)) - -### [1.1.3](https://www.github.com/googleapis/java-iot/compare/v1.1.2...v1.1.3) (2020-10-08) - - -### Dependencies - -* update dependency com.google.cloud:google-cloud-shared-dependencies to v0.10.2 ([#241](https://www.github.com/googleapis/java-iot/issues/241)) ([0532228](https://www.github.com/googleapis/java-iot/commit/05322283b98c6da9b13058b5d913c97849d57ddc)) - -### [1.1.2](https://www.github.com/googleapis/java-iot/compare/v1.1.1...v1.1.2) (2020-09-23) - - -### Dependencies - -* update dependency com.google.cloud:google-cloud-shared-dependencies to v0.10.0 ([#228](https://www.github.com/googleapis/java-iot/issues/228)) ([c12ccc0](https://www.github.com/googleapis/java-iot/commit/c12ccc0be9921a27d5ee18b76c50eefe55e2f6fa)) - -### [1.1.1](https://www.github.com/googleapis/java-iot/compare/v1.1.0...v1.1.1) (2020-09-21) - - -### Dependencies - -* update dependency com.google.cloud:google-cloud-shared-dependencies to v0.9.0 ([#213](https://www.github.com/googleapis/java-iot/issues/213)) ([70a8da1](https://www.github.com/googleapis/java-iot/commit/70a8da1b178557b863cf2d846171aba3d0ee9ae8)) - -## [1.1.0](https://www.github.com/googleapis/java-iot/compare/v1.0.2...v1.1.0) (2020-08-10) - - -### Features - -* **deps:** adopt flatten plugin and google-cloud-shared-dependencies ([#174](https://www.github.com/googleapis/java-iot/issues/174)) ([272cb69](https://www.github.com/googleapis/java-iot/commit/272cb690cd954dcbe24f91a76107ea8afd379d51)) - - -### Bug Fixes - -* restore GAPIC v2 retry configs ([#144](https://www.github.com/googleapis/java-iot/issues/144)) ([f8ae7ba](https://www.github.com/googleapis/java-iot/commit/f8ae7bab29c0c7d0dde44cd142ac5081d18954c5)) -* **v1:** migrate to grpc_service_config ([#193](https://www.github.com/googleapis/java-iot/issues/193)) ([5dd9dcf](https://www.github.com/googleapis/java-iot/commit/5dd9dcfdf03cafce29d11518dca61f247627dc2b)) - - -### Dependencies - -* update core dependencies ([#165](https://www.github.com/googleapis/java-iot/issues/165)) ([5c3b059](https://www.github.com/googleapis/java-iot/commit/5c3b05901f87428ace2a6532b93764e095aea150)) -* update dependency com.google.api:api-common to v1.9.1 ([#149](https://www.github.com/googleapis/java-iot/issues/149)) ([9031980](https://www.github.com/googleapis/java-iot/commit/903198019ea5477dd32536a0c778db93c4cd2498)) -* update dependency com.google.api:api-common to v1.9.2 ([#156](https://www.github.com/googleapis/java-iot/issues/156)) ([975d1f5](https://www.github.com/googleapis/java-iot/commit/975d1f5f33a7a372dec507d2b81c9dde98068288)) -* update dependency com.google.api.grpc:proto-google-common-protos to v1.18.0 ([#138](https://www.github.com/googleapis/java-iot/issues/138)) ([bba4e4b](https://www.github.com/googleapis/java-iot/commit/bba4e4b1f3f61a0bef0384b285694d14c0ea3417)) -* update dependency com.google.cloud:google-cloud-core to v1.93.5 ([#150](https://www.github.com/googleapis/java-iot/issues/150)) ([aaf25dd](https://www.github.com/googleapis/java-iot/commit/aaf25dd0d66dbcd245563347e473534a5e6246c5)) -* update dependency com.google.cloud:google-cloud-shared-dependencies to v0.8.2 ([#186](https://www.github.com/googleapis/java-iot/issues/186)) ([00a0cb8](https://www.github.com/googleapis/java-iot/commit/00a0cb8d98360b57666b39de45ab6186448d8324)) -* update dependency com.google.cloud:google-cloud-shared-dependencies to v0.8.3 ([#188](https://www.github.com/googleapis/java-iot/issues/188)) ([5f50037](https://www.github.com/googleapis/java-iot/commit/5f5003797131085392d53f2ba6d69924de1774d1)) -* update dependency com.google.cloud:google-cloud-shared-dependencies to v0.8.6 ([b1c5afd](https://www.github.com/googleapis/java-iot/commit/b1c5afd9af67df7f8509540fcb366ccdbd9ec28f)) -* update dependency com.google.protobuf:protobuf-java to v3.12.0 ([#142](https://www.github.com/googleapis/java-iot/issues/142)) ([6fa8924](https://www.github.com/googleapis/java-iot/commit/6fa892490fb8b82aabe1c5d977bfd70cf179aa53)) -* update dependency com.google.protobuf:protobuf-java to v3.12.2 ([#147](https://www.github.com/googleapis/java-iot/issues/147)) ([ad04bfa](https://www.github.com/googleapis/java-iot/commit/ad04bfa78c1ad29c04ad15dca7c7b4c9938b885d)) -* update dependency io.grpc:grpc-bom to v1.29.0 ([#128](https://www.github.com/googleapis/java-iot/issues/128)) ([cafb37a](https://www.github.com/googleapis/java-iot/commit/cafb37a2a58d5b792e1896a1c08c1477eb1eda1f)) -* update dependency io.grpc:grpc-bom to v1.30.0 ([#160](https://www.github.com/googleapis/java-iot/issues/160)) ([718abd7](https://www.github.com/googleapis/java-iot/commit/718abd7c91b1a780aef4e95c04e92b1dd5bfe602)) -* update dependency org.threeten:threetenbp to v1.4.4 ([#134](https://www.github.com/googleapis/java-iot/issues/134)) ([daf9439](https://www.github.com/googleapis/java-iot/commit/daf94390aaad11c2c4160488b94d4e5ce20069b7)) - -### [1.0.2](https://www.github.com/googleapis/java-iot/compare/v1.0.1...v1.0.2) (2020-04-17) - - -### Dependencies - -* update dependency com.google.guava:guava-bom to v29 ([#111](https://www.github.com/googleapis/java-iot/issues/111)) ([dbf82b1](https://www.github.com/googleapis/java-iot/commit/dbf82b14cccab8bf59555fe8b5dca9ccf66a0860)) - -### [1.0.1](https://www.github.com/googleapis/java-iot/compare/v1.0.0...v1.0.1) (2020-04-07) - - -### Dependencies - -* update core dependencies ([#85](https://www.github.com/googleapis/java-iot/issues/85)) ([c9ab329](https://www.github.com/googleapis/java-iot/commit/c9ab3290f357f136f9aa4f50b9c31dad8492c7a2)) -* update dependency com.google.api:api-common to v1.9.0 ([#95](https://www.github.com/googleapis/java-iot/issues/95)) ([bcbce5c](https://www.github.com/googleapis/java-iot/commit/bcbce5c4c0ae318dc0723f2a6e72284ba62c1055)) -* update dependency com.google.cloud:google-cloud-core to v1.93.4 ([#104](https://www.github.com/googleapis/java-iot/issues/104)) ([2769135](https://www.github.com/googleapis/java-iot/commit/2769135a7ac9d57d702dd332d14babd7a75d15f5)) -* update dependency com.google.cloud.samples:shared-configuration to v1.0.13 ([#94](https://www.github.com/googleapis/java-iot/issues/94)) ([9a8d54d](https://www.github.com/googleapis/java-iot/commit/9a8d54dd36319642a36f6a50d3739b1335d8a939)) -* update dependency org.threeten:threetenbp to v1.4.3 ([#91](https://www.github.com/googleapis/java-iot/issues/91)) ([d41fc82](https://www.github.com/googleapis/java-iot/commit/d41fc8267dd59020b3de34d47f1eaeae928b9209)) - -## [1.0.0](https://www.github.com/googleapis/java-iot/compare/v0.117.1...v1.0.0) (2020-03-03) - - -### Features - -* promote to GA ([#78](https://www.github.com/googleapis/java-iot/issues/78)) ([5573219](https://www.github.com/googleapis/java-iot/commit/55732197b5aba712be602fb962edab8fe1a2894d)) - - -### Dependencies - -* update core dependencies to v1.54.0 ([#79](https://www.github.com/googleapis/java-iot/issues/79)) ([5f41e9f](https://www.github.com/googleapis/java-iot/commit/5f41e9f499eabb9d271b0773ae5a10f3c2413a39)) -* update dependency com.google.cloud:google-cloud-core to v1.92.5 ([c326f85](https://www.github.com/googleapis/java-iot/commit/c326f8535da3aeed6d6b55d7dca5f734ec28ce84)) -* update dependency com.google.cloud:google-cloud-core to v1.93.0 ([#81](https://www.github.com/googleapis/java-iot/issues/81)) ([fc699d3](https://www.github.com/googleapis/java-iot/commit/fc699d3bf454937c8a551cf2be79ad879169a1f4)) -* update dependency com.google.cloud:google-cloud-core to v1.93.1 ([#83](https://www.github.com/googleapis/java-iot/issues/83)) ([397933a](https://www.github.com/googleapis/java-iot/commit/397933ab7fa9cb8bd61e1718fa2e07f5ae706170)) -* update dependency com.google.protobuf:protobuf-java to v3.11.4 ([e85d455](https://www.github.com/googleapis/java-iot/commit/e85d455b308c9ddb7dfdaafbdc99899ba4862d57)) -* update dependency io.grpc:grpc-bom to v1.27.1 ([ae3471e](https://www.github.com/googleapis/java-iot/commit/ae3471eb7ccbbe9a6b83a084ca9987c038c42314)) -* update dependency io.grpc:grpc-bom to v1.27.2 ([ff82b00](https://www.github.com/googleapis/java-iot/commit/ff82b0011b061e432f76e56de34ac29798719bf6)) - - -### Documentation - -* **regen:** update sample code to set total timeout, add API client header test ([bbbc09f](https://www.github.com/googleapis/java-iot/commit/bbbc09f9472a308a84f16dd6317fe39eae8797c8)) - -### [0.117.1](https://www.github.com/googleapis/java-iot/compare/v0.117.0...v0.117.1) (2020-02-04) - - -### Dependencies - -* update core dependencies ([#41](https://www.github.com/googleapis/java-iot/issues/41)) ([8f9ffa9](https://www.github.com/googleapis/java-iot/commit/8f9ffa90245a86a947b5969cfab4c64506a8c195)) -* update core dependencies ([#56](https://www.github.com/googleapis/java-iot/issues/56)) ([7727de7](https://www.github.com/googleapis/java-iot/commit/7727de7968c141218bf167287d779e7615687578)) -* update dependency com.google.guava:guava-bom to v28.2-android ([#39](https://www.github.com/googleapis/java-iot/issues/39)) ([fe1bddc](https://www.github.com/googleapis/java-iot/commit/fe1bddc373ca7ba4754c7a9c1182ef8b9026d41a)) -* update dependency com.google.protobuf:protobuf-java to v3.11.3 ([#58](https://www.github.com/googleapis/java-iot/issues/58)) ([81a6775](https://www.github.com/googleapis/java-iot/commit/81a6775a88f0b88c2a6fc66a031c90e3d73174ae)) -* update dependency org.threeten:threetenbp to v1.4.1 ([b337cae](https://www.github.com/googleapis/java-iot/commit/b337cae09704b0451c23e01da69ce4080478c317)) - -## [0.117.0](https://www.github.com/googleapis/java-iot/compare/v0.116.0...v0.117.0) (2020-01-07) - - -### ⚠ BREAKING CHANGES - -* setIamPolicy now accepts ResourceName instead of ResourceName subtypes (#21) - -### Features - -* setIamPolicy now accepts ResourceName instead of ResourceName subtypes ([#21](https://www.github.com/googleapis/java-iot/issues/21)) ([d90614c](https://www.github.com/googleapis/java-iot/commit/d90614c9a88ac9d4e509c6905dd001f59b8d66d9)) - - -### Dependencies - -* update core dependencies ([aec8e5b](https://www.github.com/googleapis/java-iot/commit/aec8e5b855afb96d69ec875494f4be355dd4cdba)) -* update dependency com.google.protobuf:protobuf-java to v3.11.0 ([#24](https://www.github.com/googleapis/java-iot/issues/24)) ([5981edb](https://www.github.com/googleapis/java-iot/commit/5981edbb973592e90721f6fe9eb46476ad6157f4)) -* update dependency com.google.protobuf:protobuf-java to v3.11.1 ([a998d6a](https://www.github.com/googleapis/java-iot/commit/a998d6a0b23d6885a6b844947771ff79a7c9b1bc)) -* update dependency io.grpc:grpc-bom to v1.26.0 ([#32](https://www.github.com/googleapis/java-iot/issues/32)) ([fff06a9](https://www.github.com/googleapis/java-iot/commit/fff06a913811cccef1fe9555b2fea3adfe3b89f0)) - - -### Documentation - -* reference libraries-bom in docs ([#16](https://www.github.com/googleapis/java-iot/issues/16)) ([6c21666](https://www.github.com/googleapis/java-iot/commit/6c2166694a51fd4b9d0590740a852b86a97e557c)) -* **regen:** update javadocs from protoc update ([#35](https://www.github.com/googleapis/java-iot/issues/35)) ([634572b](https://www.github.com/googleapis/java-iot/commit/634572baef98d9e2d9bc5f496d015e54ab48deb5)) - -## [0.116.0](https://www.github.com/googleapis/java-iot/compare/0.115.0...v0.116.0) (2019-10-28) - - -### Features - -* make repo releasable, add parent/bom ([#1](https://www.github.com/googleapis/java-iot/issues/1)) ([6c0ce94](https://www.github.com/googleapis/java-iot/commit/6c0ce94db78bc9d7f310f677eedbcb0a5af6c576)) - - -### Dependencies - -* update dependency io.grpc:grpc-bom to v1.24.1 ([764b21a](https://www.github.com/googleapis/java-iot/commit/764b21a4d4645d515ecb724aa3a126bcbae2b6e2)) -* update gax.version to v1.49.1 ([f36d626](https://www.github.com/googleapis/java-iot/commit/f36d62623797faac6688454360a2344ebc53207d)) diff --git a/CODE_OF_CONDUCT.md b/CODE_OF_CONDUCT.md deleted file mode 100644 index 2add2547..00000000 --- a/CODE_OF_CONDUCT.md +++ /dev/null @@ -1,94 +0,0 @@ - -# Code of Conduct - -## Our Pledge - -In the interest of fostering an open and welcoming environment, we as -contributors and maintainers pledge to making participation in our project and -our community a harassment-free experience for everyone, regardless of age, body -size, disability, ethnicity, gender identity and expression, level of -experience, education, socio-economic status, nationality, personal appearance, -race, religion, or sexual identity and orientation. - -## Our Standards - -Examples of behavior that contributes to creating a positive environment -include: - -* Using welcoming and inclusive language -* Being respectful of differing viewpoints and experiences -* Gracefully accepting constructive criticism -* Focusing on what is best for the community -* Showing empathy towards other community members - -Examples of unacceptable behavior by participants include: - -* The use of sexualized language or imagery and unwelcome sexual attention or - advances -* Trolling, insulting/derogatory comments, and personal or political attacks -* Public or private harassment -* Publishing others' private information, such as a physical or electronic - address, without explicit permission -* Other conduct which could reasonably be considered inappropriate in a - professional setting - -## Our Responsibilities - -Project maintainers are responsible for clarifying the standards of acceptable -behavior and are expected to take appropriate and fair corrective action in -response to any instances of unacceptable behavior. - -Project maintainers have the right and responsibility to remove, edit, or reject -comments, commits, code, wiki edits, issues, and other contributions that are -not aligned to this Code of Conduct, or to ban temporarily or permanently any -contributor for other behaviors that they deem inappropriate, threatening, -offensive, or harmful. - -## Scope - -This Code of Conduct applies both within project spaces and in public spaces -when an individual is representing the project or its community. Examples of -representing a project or community include using an official project e-mail -address, posting via an official social media account, or acting as an appointed -representative at an online or offline event. Representation of a project may be -further defined and clarified by project maintainers. - -This Code of Conduct also applies outside the project spaces when the Project -Steward has a reasonable belief that an individual's behavior may have a -negative impact on the project or its community. - -## Conflict Resolution - -We do not believe that all conflict is bad; healthy debate and disagreement -often yield positive results. However, it is never okay to be disrespectful or -to engage in behavior that violates the project’s code of conduct. - -If you see someone violating the code of conduct, you are encouraged to address -the behavior directly with those involved. Many issues can be resolved quickly -and easily, and this gives people more control over the outcome of their -dispute. If you are unable to resolve the matter for any reason, or if the -behavior is threatening or harassing, report it. We are dedicated to providing -an environment where participants feel welcome and safe. - -Reports should be directed to *googleapis-stewards@google.com*, the -Project Steward(s) for *Google Cloud Client Libraries*. It is the Project Steward’s duty to -receive and address reported violations of the code of conduct. They will then -work with a committee consisting of representatives from the Open Source -Programs Office and the Google Open Source Strategy team. If for any reason you -are uncomfortable reaching out to the Project Steward, please email -opensource@google.com. - -We will investigate every complaint, but you may not receive a direct response. -We will use our discretion in determining when and how to follow up on reported -incidents, which may range from not taking action to permanent expulsion from -the project and project-sponsored spaces. We will notify the accused of the -report and provide them an opportunity to discuss it before any action is taken. -The identity of the reporter will be omitted from the details of the report -supplied to the accused. In potentially harmful situations, such as ongoing -harassment or threats to anyone's safety, we may take action without notice. - -## Attribution - -This Code of Conduct is adapted from the Contributor Covenant, version 1.4, -available at -https://www.contributor-covenant.org/version/1/4/code-of-conduct.html \ No newline at end of file diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md deleted file mode 100644 index b65dd279..00000000 --- a/CONTRIBUTING.md +++ /dev/null @@ -1,92 +0,0 @@ -# How to Contribute - -We'd love to accept your patches and contributions to this project. There are -just a few small guidelines you need to follow. - -## Contributor License Agreement - -Contributions to this project must be accompanied by a Contributor License -Agreement. You (or your employer) retain the copyright to your contribution; -this simply gives us permission to use and redistribute your contributions as -part of the project. Head over to to see -your current agreements on file or to sign a new one. - -You generally only need to submit a CLA once, so if you've already submitted one -(even if it was for a different project), you probably don't need to do it -again. - -## Code reviews - -All submissions, including submissions by project members, require review. We -use GitHub pull requests for this purpose. Consult -[GitHub Help](https://help.github.com/articles/about-pull-requests/) for more -information on using pull requests. - -## Community Guidelines - -This project follows -[Google's Open Source Community Guidelines](https://opensource.google.com/conduct/). - -## Building the project - -To build, package, and run all unit tests run the command - -``` -mvn clean verify -``` - -### Running Integration tests - -To include integration tests when building the project, you need access to -a GCP Project with a valid service account. - -For instructions on how to generate a service account and corresponding -credentials JSON see: [Creating a Service Account][1]. - -Then run the following to build, package, run all unit tests and run all -integration tests. - -```bash -export GOOGLE_APPLICATION_CREDENTIALS=/path/to/service/account.json -mvn -Penable-integration-tests clean verify -``` - -## Code Samples - -All code samples must be in compliance with the [java sample formatting guide][3]. -Code Samples must be bundled in separate Maven modules. - -The samples must be separate from the primary project for a few reasons: -1. Primary projects have a minimum Java version of Java 8 whereas samples can have - Java version of Java 11. Due to this we need the ability to - selectively exclude samples from a build run. -2. Many code samples depend on external GCP services and need - credentials to access the service. -3. Code samples are not released as Maven artifacts and must be excluded from - release builds. - -### Building - -```bash -mvn clean verify -``` - -Some samples require access to GCP services and require a service account: - -```bash -export GOOGLE_APPLICATION_CREDENTIALS=/path/to/service/account.json -mvn clean verify -``` - -### Code Formatting - -Code in this repo is formatted with -[google-java-format](https://github.com/google/google-java-format). -To run formatting on your project, you can run: -``` -mvn com.coveo:fmt-maven-plugin:format -``` - -[1]: https://cloud.google.com/docs/authentication/getting-started#creating_a_service_account -[2]: https://maven.apache.org/settings.html#Active_Profiles -[3]: https://github.com/GoogleCloudPlatform/java-docs-samples/blob/main/SAMPLE_FORMAT.md \ No newline at end of file diff --git a/LICENSE b/LICENSE deleted file mode 100644 index 261eeb9e..00000000 --- a/LICENSE +++ /dev/null @@ -1,201 +0,0 @@ - Apache License - Version 2.0, January 2004 - http://www.apache.org/licenses/ - - TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - - 1. Definitions. - - "License" shall mean the terms and conditions for use, reproduction, - and distribution as defined by Sections 1 through 9 of this document. - - "Licensor" shall mean the copyright owner or entity authorized by - the copyright owner that is granting the License. - - "Legal Entity" shall mean the union of the acting entity and all - other entities that control, are controlled by, or are under common - control with that entity. For the purposes of this definition, - "control" means (i) the power, direct or indirect, to cause the - direction or management of such entity, whether by contract or - otherwise, or (ii) ownership of fifty percent (50%) or more of the - outstanding shares, or (iii) beneficial ownership of such entity. - - "You" (or "Your") shall mean an individual or Legal Entity - exercising permissions granted by this License. - - "Source" form shall mean the preferred form for making modifications, - including but not limited to software source code, documentation - source, and configuration files. - - "Object" form shall mean any form resulting from mechanical - transformation or translation of a Source form, including but - not limited to compiled object code, generated documentation, - and conversions to other media types. - - "Work" shall mean the work of authorship, whether in Source or - Object form, made available under the License, as indicated by a - copyright notice that is included in or attached to the work - (an example is provided in the Appendix below). - - "Derivative Works" shall mean any work, whether in Source or Object - form, that is based on (or derived from) the Work and for which the - editorial revisions, annotations, elaborations, or other modifications - represent, as a whole, an original work of authorship. For the purposes - of this License, Derivative Works shall not include works that remain - separable from, or merely link (or bind by name) to the interfaces of, - the Work and Derivative Works thereof. - - "Contribution" shall mean any work of authorship, including - the original version of the Work and any modifications or additions - to that Work or Derivative Works thereof, that is intentionally - submitted to Licensor for inclusion in the Work by the copyright owner - or by an individual or Legal Entity authorized to submit on behalf of - the copyright owner. For the purposes of this definition, "submitted" - means any form of electronic, verbal, or written communication sent - to the Licensor or its representatives, including but not limited to - communication on electronic mailing lists, source code control systems, - and issue tracking systems that are managed by, or on behalf of, the - Licensor for the purpose of discussing and improving the Work, but - excluding communication that is conspicuously marked or otherwise - designated in writing by the copyright owner as "Not a Contribution." - - "Contributor" shall mean Licensor and any individual or Legal Entity - on behalf of whom a Contribution has been received by Licensor and - subsequently incorporated within the Work. - - 2. Grant of Copyright License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - copyright license to reproduce, prepare Derivative Works of, - publicly display, publicly perform, sublicense, and distribute the - Work and such Derivative Works in Source or Object form. - - 3. Grant of Patent License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - (except as stated in this section) patent license to make, have made, - use, offer to sell, sell, import, and otherwise transfer the Work, - where such license applies only to those patent claims licensable - by such Contributor that are necessarily infringed by their - Contribution(s) alone or by combination of their Contribution(s) - with the Work to which such Contribution(s) was submitted. If You - institute patent litigation against any entity (including a - cross-claim or counterclaim in a lawsuit) alleging that the Work - or a Contribution incorporated within the Work constitutes direct - or contributory patent infringement, then any patent licenses - granted to You under this License for that Work shall terminate - as of the date such litigation is filed. - - 4. Redistribution. You may reproduce and distribute copies of the - Work or Derivative Works thereof in any medium, with or without - modifications, and in Source or Object form, provided that You - meet the following conditions: - - (a) You must give any other recipients of the Work or - Derivative Works a copy of this License; and - - (b) You must cause any modified files to carry prominent notices - stating that You changed the files; and - - (c) You must retain, in the Source form of any Derivative Works - that You distribute, all copyright, patent, trademark, and - attribution notices from the Source form of the Work, - excluding those notices that do not pertain to any part of - the Derivative Works; and - - (d) If the Work includes a "NOTICE" text file as part of its - distribution, then any Derivative Works that You distribute must - include a readable copy of the attribution notices contained - within such NOTICE file, excluding those notices that do not - pertain to any part of the Derivative Works, in at least one - of the following places: within a NOTICE text file distributed - as part of the Derivative Works; within the Source form or - documentation, if provided along with the Derivative Works; or, - within a display generated by the Derivative Works, if and - wherever such third-party notices normally appear. The contents - of the NOTICE file are for informational purposes only and - do not modify the License. You may add Your own attribution - notices within Derivative Works that You distribute, alongside - or as an addendum to the NOTICE text from the Work, provided - that such additional attribution notices cannot be construed - as modifying the License. - - You may add Your own copyright statement to Your modifications and - may provide additional or different license terms and conditions - for use, reproduction, or distribution of Your modifications, or - for any such Derivative Works as a whole, provided Your use, - reproduction, and distribution of the Work otherwise complies with - the conditions stated in this License. - - 5. Submission of Contributions. Unless You explicitly state otherwise, - any Contribution intentionally submitted for inclusion in the Work - by You to the Licensor shall be under the terms and conditions of - this License, without any additional terms or conditions. - Notwithstanding the above, nothing herein shall supersede or modify - the terms of any separate license agreement you may have executed - with Licensor regarding such Contributions. - - 6. Trademarks. This License does not grant permission to use the trade - names, trademarks, service marks, or product names of the Licensor, - except as required for reasonable and customary use in describing the - origin of the Work and reproducing the content of the NOTICE file. - - 7. Disclaimer of Warranty. Unless required by applicable law or - agreed to in writing, Licensor provides the Work (and each - Contributor provides its Contributions) on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - implied, including, without limitation, any warranties or conditions - of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A - PARTICULAR PURPOSE. You are solely responsible for determining the - appropriateness of using or redistributing the Work and assume any - risks associated with Your exercise of permissions under this License. - - 8. Limitation of Liability. In no event and under no legal theory, - whether in tort (including negligence), contract, or otherwise, - unless required by applicable law (such as deliberate and grossly - negligent acts) or agreed to in writing, shall any Contributor be - liable to You for damages, including any direct, indirect, special, - incidental, or consequential damages of any character arising as a - result of this License or out of the use or inability to use the - Work (including but not limited to damages for loss of goodwill, - work stoppage, computer failure or malfunction, or any and all - other commercial damages or losses), even if such Contributor - has been advised of the possibility of such damages. - - 9. Accepting Warranty or Additional Liability. While redistributing - the Work or Derivative Works thereof, You may choose to offer, - and charge a fee for, acceptance of support, warranty, indemnity, - or other liability obligations and/or rights consistent with this - License. However, in accepting such obligations, You may act only - on Your own behalf and on Your sole responsibility, not on behalf - of any other Contributor, and only if You agree to indemnify, - defend, and hold each Contributor harmless for any liability - incurred by, or claims asserted against, such Contributor by reason - of your accepting any such warranty or additional liability. - - END OF TERMS AND CONDITIONS - - APPENDIX: How to apply the Apache License to your work. - - To apply the Apache License to your work, attach the following - boilerplate notice, with the fields enclosed by brackets "[]" - replaced with your own identifying information. (Don't include - the brackets!) The text should be enclosed in the appropriate - comment syntax for the file format. We also recommend that a - file or class name and description of purpose be included on the - same "printed page" as the copyright notice for easier - identification within third-party archives. - - Copyright [yyyy] [name of copyright owner] - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. diff --git a/README.md b/README.md deleted file mode 100644 index 8a4817f8..00000000 --- a/README.md +++ /dev/null @@ -1,225 +0,0 @@ -# Google Cloud Internet of Things (IoT) Core Client for Java - -Java idiomatic client for [Cloud Internet of Things (IoT) Core][product-docs]. - -[![Maven][maven-version-image]][maven-version-link] -![Stability][stability-image] - -- [Product Documentation][product-docs] -- [Client Library Documentation][javadocs] - - -## Quickstart - -If you are using Maven with [BOM][libraries-bom], add this to your pom.xml file: - -```xml - - - - com.google.cloud - libraries-bom - 26.1.2 - pom - import - - - - - - - com.google.cloud - google-cloud-iot - - -``` - -If you are using Maven without BOM, add this to your dependencies: - - -```xml - - com.google.cloud - google-cloud-iot - 2.3.4 - - -``` - -If you are using Gradle 5.x or later, add this to your dependencies: - -```Groovy -implementation platform('com.google.cloud:libraries-bom:26.1.2') - -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.3.4' -``` - -If you are using SBT, add this to your dependencies: - -```Scala -libraryDependencies += "com.google.cloud" % "google-cloud-iot" % "2.3.4" -``` - -## Authentication - -See the [Authentication][authentication] section in the base directory's README. - -## Authorization - -The client application making API calls must be granted [authorization scopes][auth-scopes] required for the desired Cloud Internet of Things (IoT) Core APIs, and the authenticated principal must have the [IAM role(s)][predefined-iam-roles] required to access GCP resources using the Cloud Internet of Things (IoT) Core API calls. - -## Getting Started - -### Prerequisites - -You will need a [Google Cloud Platform Console][developer-console] project with the Cloud Internet of Things (IoT) Core [API enabled][enable-api]. -You will need to [enable billing][enable-billing] to use Google Cloud Internet of Things (IoT) Core. -[Follow these instructions][create-project] to get your project set up. You will also need to set up the local development environment by -[installing the Google Cloud SDK][cloud-sdk] and running the following commands in command line: -`gcloud auth login` and `gcloud config set project [YOUR PROJECT ID]`. - -### Installation and setup - -You'll need to obtain the `google-cloud-iot` library. See the [Quickstart](#quickstart) section -to add `google-cloud-iot` as a dependency in your code. - -## About Cloud Internet of Things (IoT) Core - - -[Cloud Internet of Things (IoT) Core][product-docs] is a complete set of tools to connect, process, store, and analyze data both at the edge and in the cloud. The platform consists of scalable, fully-managed cloud services; an integrated software stack for edge/on-premises computing with machine learning capabilities for all your IoT needs. - -See the [Cloud Internet of Things (IoT) Core client library docs][javadocs] to learn how to -use this Cloud Internet of Things (IoT) Core Client Library. - - - - - - -## Troubleshooting - -To get help, follow the instructions in the [shared Troubleshooting document][troubleshooting]. - -## Transport - -Cloud Internet of Things (IoT) Core uses gRPC for the transport layer. - -## Supported Java Versions - -Java 8 or above is required for using this client. - -Google's Java client libraries, -[Google Cloud Client Libraries][cloudlibs] -and -[Google Cloud API Libraries][apilibs], -follow the -[Oracle Java SE support roadmap][oracle] -(see the Oracle Java SE Product Releases section). - -### For new development - -In general, new feature development occurs with support for the lowest Java -LTS version covered by Oracle's Premier Support (which typically lasts 5 years -from initial General Availability). If the minimum required JVM for a given -library is changed, it is accompanied by a [semver][semver] major release. - -Java 11 and (in September 2021) Java 17 are the best choices for new -development. - -### Keeping production systems current - -Google tests its client libraries with all current LTS versions covered by -Oracle's Extended Support (which typically lasts 8 years from initial -General Availability). - -#### Legacy support - -Google's client libraries support legacy versions of Java runtimes with long -term stable libraries that don't receive feature updates on a best efforts basis -as it may not be possible to backport all patches. - -Google provides updates on a best efforts basis to apps that continue to use -Java 7, though apps might need to upgrade to current versions of the library -that supports their JVM. - -#### Where to find specific information - -The latest versions and the supported Java versions are identified on -the individual GitHub repository `github.com/GoogleAPIs/java-SERVICENAME` -and on [google-cloud-java][g-c-j]. - -## Versioning - - -This library follows [Semantic Versioning](http://semver.org/). - - - -## Contributing - - -Contributions to this library are always welcome and highly encouraged. - -See [CONTRIBUTING][contributing] for more information how to get started. - -Please note that this project is released with a Contributor Code of Conduct. By participating in -this project you agree to abide by its terms. See [Code of Conduct][code-of-conduct] for more -information. - - -## License - -Apache 2.0 - See [LICENSE][license] for more information. - -## CI Status - -Java Version | Status ------------- | ------ -Java 8 | [![Kokoro CI][kokoro-badge-image-2]][kokoro-badge-link-2] -Java 8 OSX | [![Kokoro CI][kokoro-badge-image-3]][kokoro-badge-link-3] -Java 8 Windows | [![Kokoro CI][kokoro-badge-image-4]][kokoro-badge-link-4] -Java 11 | [![Kokoro CI][kokoro-badge-image-5]][kokoro-badge-link-5] - -Java is a registered trademark of Oracle and/or its affiliates. - -[product-docs]: https://cloud.google.com/iot -[javadocs]: https://cloud.google.com/java/docs/reference/google-cloud-iot/latest/history -[kokoro-badge-image-1]: http://storage.googleapis.com/cloud-devrel-public/java/badges/java-iot/java7.svg -[kokoro-badge-link-1]: http://storage.googleapis.com/cloud-devrel-public/java/badges/java-iot/java7.html -[kokoro-badge-image-2]: http://storage.googleapis.com/cloud-devrel-public/java/badges/java-iot/java8.svg -[kokoro-badge-link-2]: http://storage.googleapis.com/cloud-devrel-public/java/badges/java-iot/java8.html -[kokoro-badge-image-3]: http://storage.googleapis.com/cloud-devrel-public/java/badges/java-iot/java8-osx.svg -[kokoro-badge-link-3]: http://storage.googleapis.com/cloud-devrel-public/java/badges/java-iot/java8-osx.html -[kokoro-badge-image-4]: http://storage.googleapis.com/cloud-devrel-public/java/badges/java-iot/java8-win.svg -[kokoro-badge-link-4]: http://storage.googleapis.com/cloud-devrel-public/java/badges/java-iot/java8-win.html -[kokoro-badge-image-5]: http://storage.googleapis.com/cloud-devrel-public/java/badges/java-iot/java11.svg -[kokoro-badge-link-5]: http://storage.googleapis.com/cloud-devrel-public/java/badges/java-iot/java11.html -[stability-image]: https://img.shields.io/badge/stability-stable-green -[maven-version-image]: https://img.shields.io/maven-central/v/com.google.cloud/google-cloud-iot.svg -[maven-version-link]: https://search.maven.org/search?q=g:com.google.cloud%20AND%20a:google-cloud-iot&core=gav -[authentication]: https://github.com/googleapis/google-cloud-java#authentication -[auth-scopes]: https://developers.google.com/identity/protocols/oauth2/scopes -[predefined-iam-roles]: https://cloud.google.com/iam/docs/understanding-roles#predefined_roles -[iam-policy]: https://cloud.google.com/iam/docs/overview#cloud-iam-policy -[developer-console]: https://console.developers.google.com/ -[create-project]: https://cloud.google.com/resource-manager/docs/creating-managing-projects -[cloud-sdk]: https://cloud.google.com/sdk/ -[troubleshooting]: https://github.com/googleapis/google-cloud-common/blob/main/troubleshooting/readme.md#troubleshooting -[contributing]: https://github.com/googleapis/java-iot/blob/main/CONTRIBUTING.md -[code-of-conduct]: https://github.com/googleapis/java-iot/blob/main/CODE_OF_CONDUCT.md#contributor-code-of-conduct -[license]: https://github.com/googleapis/java-iot/blob/main/LICENSE -[enable-billing]: https://cloud.google.com/apis/docs/getting-started#enabling_billing -[enable-api]: https://console.cloud.google.com/flows/enableapi?apiid=cloudiot.googleapis.com -[libraries-bom]: https://github.com/GoogleCloudPlatform/cloud-opensource-java/wiki/The-Google-Cloud-Platform-Libraries-BOM -[shell_img]: https://gstatic.com/cloudssh/images/open-btn.png - -[semver]: https://semver.org/ -[cloudlibs]: https://cloud.google.com/apis/docs/client-libraries-explained -[apilibs]: https://cloud.google.com/apis/docs/client-libraries-explained#google_api_client_libraries -[oracle]: https://www.oracle.com/java/technologies/java-se-support-roadmap.html -[g-c-j]: http://github.com/googleapis/google-cloud-java diff --git a/SECURITY.md b/SECURITY.md deleted file mode 100644 index 8b58ae9c..00000000 --- a/SECURITY.md +++ /dev/null @@ -1,7 +0,0 @@ -# Security Policy - -To report a security issue, please use [g.co/vulnz](https://g.co/vulnz). - -The Google Security Team will respond within 5 working days of your report on g.co/vulnz. - -We use g.co/vulnz for our intake, and do coordination and disclosure here using GitHub Security Advisory to privately discuss and fix the issue. diff --git a/clearblade-cloud-iot/bin/com/clearblade/cloud/iot/v1/DeviceManagerClient.class b/clearblade-cloud-iot/bin/com/clearblade/cloud/iot/v1/DeviceManagerClient.class new file mode 100644 index 0000000000000000000000000000000000000000..0bf879c7a49ba19110c094cc20fedbb6ba6b2554 GIT binary patch literal 2324 zcmcgtZBNrs6n@Sa6iRtjT zN_pL|Tz!9BUzYnuPOb}6>_|IPFr?`!h!R?N#lFxB!rakcXLn`JB{bwL({Y9AI)u@+ zFwl}~6dXNsWS%C}%^9ZQE)Z%G$!$V3W96la8Z>H9P~QMTlZIN<5n9#^Q*M-sS!r*H zY(WxYYgSGawuNnY^U7k>eQz+2@lYNY1jk&W9u);Q3By$cp`s0qgf>T-`HWR83NycD z1r7+AL@19ykHC0C6lHqtMBPo-Hq4!La$98)IyJ;luOf~f1>J;&FoK)snY@u7O44x$ zmP$q;FKrEXaF?K(@?&L%u#`xKa{V`I+T+)!p&$1MiX&YwB*I>m8e9vF`x*u@#M#3% zmJCzapO%Fy2wRB@B)*QglNwSOCe&s zxIytd%HQ0y_}##>IYj(_YU%)LioQep#;XxD^SjyK$^DeA8+cC(uW5lbT5*GC+})0m zX4%^FqNRSK?d<_>oxxHW(?e`zloK577^fY#dAG;t3tQIm7*Cbaafq(rGI~eK7$_sL zks2*yWHx$2v7g<8w?@&y1UnhNi{ax;tAiU}H_z_)?j{1riaQ2}jt4&7IL7giUA8gO zBTR4*UA+DnlfF<~-72)+v5hBW(;=pq(p(u&)-e*f|H8-QnM7|1c~dg0LV0>L9U;J%=3nEH+k z6KC|$=?mp|!r_oBe-Q48k@Un{@jexCveiyy;ETvWfnnvCkGKjVw%u5m;qMI)VxbfI z!UV&Tg^O5bC_R-*Cc6xIyRpx(+?7i7(xEG&0e1sxtJ)1c9_;f->i^7WB9A4)N{(dA z@Z$Vc8L>z-DGcxIg=jM@o|}>iaj|Zph!Sx^Wwg)CWMIz@<-a7nVZlI|q3CL5F+BO_ z(Y6e1GCW?Sy!pB?QNwMmgF6hJ#l+7C`E@&5T0Uk!Oe0Uclv+8p`9V8c>PV>pr9nR59L&|o<9j!%F=+#=jKz}x!>!*AQc5njg6YXK&ifOV{97HuWrPof-J^=Ywrg6ikYVH&cLg;-+;T*75KXSjkj`s$R=2}&n5n)kop zYIB;=%*>lqVLgLb8@o*)C?M-ZXTFB(e*)W>0o$gKyK}%a9UAN=ZcV@*5oNlq$|-6G k)LMO7+n9|9XIiUF>dIq_LUP!qM96rh5#kmT!m_ov1?o3ws{*BLtF<<%ZHzQcOeiK&N&Gp$1gBYc>#~seR+_Xl z(ZmPvp^SIf)h5Ma(rk8S?#!KY?#G#*zrOtdu!AiP5r)l<+qXKl;9lG2T|rBC*tMkV zTcdTWDV%Q2?f1FUJ#_cPNOr_K@o6XqzJ?e>`iPIXWpk%zy=@$6~o zzO)BcfY%`ZZ3ew99qxVJ<349F>*v5t-;+*{JmN2a(Y2_OxeEyf$%Ma literal 0 HcmV?d00001 diff --git a/clearblade-cloud-iot/bin/com/clearblade/cloud/iot/v1/SendCommandToDeviceResponse$Builder.class b/clearblade-cloud-iot/bin/com/clearblade/cloud/iot/v1/SendCommandToDeviceResponse$Builder.class new file mode 100644 index 0000000000000000000000000000000000000000..88f283bfdf8039df77236343e51552d65e511a23 GIT binary patch literal 1179 zcmb_bO>fgc5Pg#`$F8BJKp{Y(1rBMDun-a-3N(UL6-ZH$XjQ4lwLJn?ju&hv9Qadk zK$WP(58y{3W^IcA>Lmpq*0ZxSZ)V?{{r=(>>+KOjsW2K*jqijm*AqI;dkou=2N2MtJrg+FH#xKauT<#E;$iiJ88DC zwc?_Q7NO}I*$MsAi_y1mh466hp(v$v(7`n$-6~=06r}t$5JqxmS5MM_w*IFAdmnvw&7 zGDWT4oiDi9n^klQ_onnYC?HnKunIyFiW`{9mvFfPyDzsho!H0d97s1;XK>{Owtwr! buAu6;E-5wKz?%Hc8zd2PUAntj_&YxVA^JJz{WbrX#_qX$6Ot1-p%Sq}d!C)Z>vJbDc31 z4I5oXDq+S`hJrGInfvu2Js8vD`+^;P`;D+Apd^h0X(Pqiiq_{X+U9H&nBH$$iEc}` z(y3-MVhD&90dHY32ZD>O1qj_%G8*4Uc6XQvEj@0f1Oii{NL$fZD%hMOC$H*JA5Ga9$#das6Ua$Vtir*8GjwH+FE$~BE^-NPx%7~EnEtJuvDb!sO|=bngNDpMY` zV}*R|(Qqqty56MztTu6$%BUF^xH=c3S!{*9Mg?I3zXX0LD0fq-SWsq3iYgSyR2Zx= zogLjh9`s?KhJMttE;F*T;pLb|BHyoJz%~t$_m~4lT*aWktY%sJn`G?|Y)!Fp$Q>!m z)R4dd){ug%&Lr_Ctzo9nWgIxkf2@BhSZOrEwT!qG=owBJD$>NqK!`=dx->#?f6643 zgA9+g;jodgRPca?+p7DbaXmS_PPg>xkiR6b!Q!1p6|WK~Pg{Ef^yD45Q^9M--Fr@yX?QJO$Ec#*reVvV(z7pPq1s(d9^8dD zDtH48Z^z_><21Ypck{f1$*4ugDmA;BT3F;H*F75EBJYoK-q0z=`Z2s+!P^9`Din;K z{-k+OR(cKZz&n{9dL+`FP9&17HU`sfZZW1jG2J9>^DYhdVZLLVTrG6&E`j%GsK!DS z?<1s5Jw2U!I=0BN^?nUCs8#R*s+-fMDZO{Eku)M*1|uq|;6VXjZm%UycQ_Vzw&l4a z8a{{*F*j(tA_7*zB9|0xG;FSIh2i)?-qxd@Q!0l!zb-jV{k>}tt=PsapMdgRq*NY z@nhEz4QKHfdjnI3Yn78pgxkr6CTlPT;%8_Rnd$y)i{+1-mj9rc955mtd=6hw@cCRg zjOW$xxU33FLW+wqyD#7g1z!}n*7l67E^T^jubCV)BCIa!56LuSYHIkBjJO##AKS6; zKu=N+Q<*0v|5u6*Yw5@{dGM6n{aS9QtfJDjbe`2eXY}P zmP9FVZk}^|Q1eu`%_}|2q|dSDIVMFEIRq*F1wAioZ;};!Uu4q4`gmhbTVvgh{~qZKSgW2R0bTa-NGv{*&NeZm*^rTd($iUHmMU z?flqiGi1}7!UAep%8#2ecx7MAS&3{P?U5~?J+cSmsFJ1v(@8&rZ!M%N;aE{OhM9Hs zr*YLN=A5$0=kht-7CM_ObI3dwKCaDn7;rVN;Tu^o4=m&SG-aT{8-Q0gT5!cmegRE&}4p1990JOCWSjR#q{P z#V02KS$tU_EbNnj)Q@8EL?CqpQvV!4q{$@^_O@ABAzD%@uhpGF{f;pNMzM6F#4T)- zTZ=GhdE>k|C#Uo%Po+D>fw~NqoxycGyvxUMBh9=tgOwSq%Am=+fe&Y86K5H0X+4AX z9X4@ip13Pdv^785&Y5=?ANBl^ZwxPOTav*o=g`+4@J2G&>xhkp$^zb)uPlRjz?<}1 z_BdpZ-b11C05=YckV}M=Kn5=lslIaW(F|T4a{E-DyVU1Co5AaS>f>1HQ!{w;2$qFh z@>R88eXhqsiqCZ(9-k6&jiA!!@+lAUjY9@+h#-ScY?G2QJ3{LDOBdzzQzKaTFdp%q z%iyyktbSDg{0L^s@yjDn<@nW8H2evi;|%~jgdg&c*(SD&UA$A|80L-~2Y3sV+R=U# ze$sR>d2U7kU2IUhF@&u+f?nLo{`zigXScEo_p-0P54TYI9?HKJ|3RM+?19~gh#Bm1 ztFTYhA}Sg%AeJL0R&m^fxM+hZI*}0DkrcbxZiZor2%F3S42c-q$^;JE!E_umWx!;E zDIn_cbvr!!aS`9ZH+5dORony~pS`&wgif2%A2`k~5%s{f^HY-#963fDKkZ{K) z@Itwa49Utg=8k+^*r?!1{+=r1JHNE}lm&EiHn075dOa=ED}&!<@CWaoWm;wM7ble_ q)}A9pdG61;rWAjp#1i}+|KRB5Y!*-XC%@TO<6rjp4Aly5&aph9ijsQ%eXlvtZ?N+{`4cMX{%ALV=H=b%*cqh{4TlWIeqjG?$@yMmKeL zmZ34+lVb2KSQ!ySBLXU#(9Ccxrki4|kV^|Y$t=RZ!U`_!Ya;LJmgy*HV`#7Jdiy5`h7J|iCF+|_^(fFu z+|Clv_9_P{=wgV}a=;7aDmQsn*b9a(OgD&51Qgt6=&Pk!aCO6pED(N|o30Z?Hv)3_ zNJR*D$-%5}=L@=#5jMkQxTj_uJ!2l2HJ%gq%bL?c+`|I}_Zdbn26J9t#V7dG!?Iyp zUVU^BmP)Y8DUs*&sOXiuuMl!s5i&V)y$ z!q8t2S`}j$XK1iqFzkoVgS*^HeG#WfPhv{JLx$N}*sEN`xOi0%j(d_b71NlZn49AD z+x*X8kpGLVmhjE0_zZIliX&WECJgy-U3E2GJ1Fk~!;g7}kQPl9wwJbt)48#+^Sa6HgGKIghGdlt|8H3Gz%Nuh#+M9DX?g7! zrY;?H3U()ADps*Z#NwRiUIwRj;NKm|%cQ``6U_)hwSl;TrwkKym#Ak#MM9G4)x2$K z!g0!#8^BlCR6wl!pLUWsa9oj7@in%nl~@JpEZ4n@s9TW@;&GR#L-5?Rf@eg}XBnkj z`hI*v9KNxhNQUCV!w}M)(9~2Yh;4i)ThjMrxLQf1q`PSqn&cS2Yk5p1)r5){$Wo`{ z`8?%@VW67+Io7Cf>Ne6r?7&d4d(wGMJEbBgaVdG}r$K$JJyYtrry2#raLvo-apEZz zYK#Hxq-7B9n)+utjBKiA>Cz9rhgzi*5xba_B-B5gR(Rk)W@bNTRe9hLC*!HTn)HO zkBmloih)Mr4m8uK&@4idk!HGD^CuUHAvKB>`2HY=8VxPhCcb$argwZv4i+C+biV{~pE;?|R6bd$Uj>nq~J zB0ly+*b{x87(Bx8>JcXTi+I%bc@YamtgQ786!B!r*X1i>z03C}?)--2F}Anbo*&{{ zxyp;k6!EeMT_Tnkf$@@$E%1|otr`8R?#OrRYz=%BvTiaC0!t&k5f^5Q8m=q_%R zyc;Fleq><6B1^4!jyzsbRE9{?hC`mtp&u>^bk+(UU=Od!*L~XC3HA?}X;RRspj$yy f!GS`wAhYp9Y5WmCk!+*+Bo6R1#q=IMLP-7#^YT2Z literal 0 HcmV?d00001 diff --git a/clearblade-cloud-iot/bin/com/clearblade/cloud/iot/v1/utils/Constants.class b/clearblade-cloud-iot/bin/com/clearblade/cloud/iot/v1/utils/Constants.class new file mode 100644 index 0000000000000000000000000000000000000000..3c1dcd50fd2fabf5ce856790fb42752314b80d47 GIT binary patch literal 2696 zcmbW3Yg-dn5Xb+EKtf!+M6_zFR_g_VWD|@aYOy6;+?b1yB@t>%_i{)!>;{{z66s7Ej$U{ZH&Nw=8V z)GXCt^ysz>$#i{bFDv+EE_+A8q0?swmJyo()rzVxO2Ge~3QRWygUDKh* zc>YLT_M4_tdm>Qe0PUA0wP+=v<%i1Fq8jp ztVOnG>WrUod!b`Tu7;nQj_J<}I5j>|AQ$Bn+ID8^L%cR z6d@g294ezoQ#p1mIO-ot2v0BdNEFYgKDU{n>2q2pr5kK6rLk?znA4_> zZF)0Olpz6Mi&)@xBH5J>n<|P$0T(>##jI=FRNsnw6x*_h6>c#~7KL8xMIj6Liyh?Z z+KO(L%$&UbPEHq1*^`~Mhk90?k#}}qRkFFcByCEo)m7RgXNvY(W8ax9Q7xqilwR*uW?i3c6%zQTYu49w4Hx*;2Sd|Y72kClgv6jgztJB4mb-%Q- zlqqCW>CI{(T~s#qOUgoHQ<1rC+8}^}xo;ZJ$!}xHlkG}|L**6zY}Et3vN2s$^i-j- z{;>Eem2|zPXX|fTPIg8vY}fMJo2Hjqx3U>;wwkeN_{=`A-)xo3xksx!lP^T%d0wKF z7o{_W&gM;r65ix{estnrBD}&3bA|hNSlB{>@T(K!4$`zxeIJ#V}`BuaT*F;GZgvW*7i->Vy zjD+1f=VD#NX^12)yRD|qmQ5b|nI3zRbCPq}aac2Jsh-Cu{7ClzYC@X1^j#Uo04JxX z0ZtpN1Q)D?60GDsSjio&qhv|5nSRgG+YfY#Ky*A5!3mc-ySgXv(|KaKwL0*M|Z1jU9LP2PRg@J7JgCq$=Ist^276g*Zm+f1TuR92(N7p@?9v%RzJw&P!JkLVIW)mAoB$B>;w?rTpUED^6p&o@nY5b pK^8(m=sOq&qV+&i6f=5f#T_n#lX06fG!4GDo&+pC+lD=oj`T2)C$uUR!6 zFEkHV%x37gf%#M(I=0-h>T>=`({ZcP*N_qz*|!cY)3q8k^HpVE+M$4U;Cs<&wA}f1 zJM^7KZCzl<^=vD2yapY8S#yHW{~|D0Rs3{#;53}@kwCIg+!07^cvYz*iSq_@WCVuG zPD5@r>lNw0vns9>7%dZ_yJPtd-&@X9xaR}{Yvr?aMpf!H8NP1!F;*z{c9Mp`gn?^FSTLSm{Yree(Gz2Pt+iUu^eCDtqhof+C*L;4%86$Fx0skJtU zHegEz;d3ttag~ISq?Jq|!J48|f;FTpX+~L63E2$A&?->8K{u1EAUja{j&t8s*f4zu zm2(p#bT*;@T)-&Z1TJEXzW;-dF#fd*{4y4NDHc504So{~o{k02bc5f=f-lE{v)$m` zSnw4!VD9-b4K_hmD=i#jywri~%Kd?+|4~s)L}9J55kS2QPy1Rt*<=q{g&_7RWc;{H zc0HbKriZLXWP7KOu|k+^KAtSwL*^1${S-2mnV{x%U86oF!TL`B oM1GgjFLxd+()edZ6=^)(qDm5s7iblC$m)tRk2U(6y{r8Bzq&+4lK=n! literal 0 HcmV?d00001 diff --git a/clearblade-cloud-iot/bin/com/clearblade/cloud/iot/v1/utils/DeviceName.class b/clearblade-cloud-iot/bin/com/clearblade/cloud/iot/v1/utils/DeviceName.class new file mode 100644 index 0000000000000000000000000000000000000000..9898c6967fd4cfb0cc5c9e1a287a81141be9abf4 GIT binary patch literal 2275 zcmbVNYi}Ay6g>kN3`|V@ZfKm=Nt^<)O^F>hi62ShG|huJXL;(mc?nm z^f$FqOR84t59p7odhYIm5#BFYh@F|cbMHC#!QtQk{`v>NE)G+ODXi9=R=M6ZmRoCD z4a2R|ZIo@tE1y)#UC(ZI$`8$nT{j0-%cPJ{_~@N=VwIa#`?&m~_RiEjh18F(6YOTH zr*98E*KQwgD@-<>y5-qUn_Jf$+a1sSSs~f*<8rfOw{34vAzmmRDJ1rthRGm~DUA%W zX%JFl0!i7;XrzMOoW^9ZThK@&sgSGMZFA6V)r|X{RcjjFt`fL;WVyDSLu11G!R{!m zSI5bmS==d%<#Fvn*KRh9yInlWUIz%uOPOTb=6zTIh1(>1p2W9> z;1s!eP8drJH)Sj~6e{EOgMCnlId2tyDx59d`7Gn5#dH+D)L6s1U zMsOPsr9U-(@pd)#1S3m~;c2+9@m1eGJPrFA55=D5{a_k|=_8GA@K|BOp9_UA#_T5p zCf_=4%c4}giAeCg#Xlo8q8e3==Q7Zfo)ZWVD}3m5-MV>Xizehw3fr@aR9(7)dbf$_$IM0qcFGo64>LQ%yN1az9oYV5V z4V?>qU4Y5IvGn=_%A@{8-(MQSAIrdNgYzRrNsAX7RT*_#8-h)T)kCa0+*$46-dYb2dieS@++|KCP$Aw;?lw4!n;fBA?C=&lTk&B^L8x$+8PuO< z;kPJ%tbT@z^2f?3X*|Kxki;(`iF`DP9-f`@xWY)F%EhtG=sV=GOCEdVagRLiGsU|@ mT=D}h`2m;wfJ;8)62}2!#_$3!xr(GN@%t^`zT!C{=l=m(9?bUu literal 0 HcmV?d00001 diff --git a/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/SyncSendCommandToDevice.java b/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/SyncSendCommandToDevice.java new file mode 100644 index 00000000..23a6b078 --- /dev/null +++ b/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/SyncSendCommandToDevice.java @@ -0,0 +1,27 @@ +package com.clearblade.cloud.iot.v1; + +import com.clearblade.cloud.iot.v1.utils.Constants; +import com.clearblade.cloud.iot.v1.utils.DeviceName; + +public class SyncSendCommandToDevice { + + public static void main(String[] args) throws Exception { + syncSendCommandToDevice(); + } + + public static void syncSendCommandToDevice() throws Exception { + DeviceManagerClient deviceManagerClient = new DeviceManagerClient(); + Constants constants = new Constants(); + DeviceName name = DeviceName.of(constants.getBuilder().getProject(), constants.getBuilder().getLocation(), constants.getBuilder().getRegistry(), constants.getBuilder().getDevice()); + SendCommandToDeviceRequest request = SendCommandToDeviceRequest.Builder + .newBuilder() + .setName(name) + .setBinaryData("c2VuZEZ1bm55TWVzc2FnZVRvRGV2aWNl") + .build(); + SendCommandToDeviceResponse response = deviceManagerClient.sendCommandToDevice(request); + response.processRequest(); + if(response != null) { + System.out.println("POST Response is :: " + response.toString()); + } + } + } diff --git a/clearblade-cloud-iot/src/main/java/com/clearblade/cloud/iot/v1/DeviceManagerClient.java b/clearblade-cloud-iot/src/main/java/com/clearblade/cloud/iot/v1/DeviceManagerClient.java new file mode 100644 index 00000000..c33f6596 --- /dev/null +++ b/clearblade-cloud-iot/src/main/java/com/clearblade/cloud/iot/v1/DeviceManagerClient.java @@ -0,0 +1,44 @@ +package com.clearblade.cloud.iot.v1; + +import com.clearblade.cloud.iot.v1.utils.Constants; + +import com.clearblade.cloud.iot.v1.utils.DeviceName; + +public class DeviceManagerClient { + Constants constants = null; + /** + * Initialise the Constants object + * This method will set details like project, location, registry, device + */ + public void init() { + constants = new Constants(); + } + + /** + * SendCommandToDevice method + * @param name + * @param binaryData + */ + public void sendCommandToDevice(DeviceName name, String binaryData) { + init(); + SendCommandToDeviceRequest request = SendCommandToDeviceRequest.Builder.newBuilder() + .setName(name) + .setBinaryData(binaryData) + .build(); + SendCommandToDeviceResponse response = this.sendCommandToDevice(request); + //response.processRequest(); + } + + /** + * Print the response for sendCommandToDevice + * @param request + * @return + */ + public SendCommandToDeviceResponse sendCommandToDevice(SendCommandToDeviceRequest request) { + SendCommandToDeviceResponse response = SendCommandToDeviceResponse.Builder.newBuilder() + .setSendCommandToDeviceRequest(request) + .build(); + return response; + } + +} diff --git a/clearblade-cloud-iot/src/main/java/com/clearblade/cloud/iot/v1/SendCommandToDeviceRequest.java b/clearblade-cloud-iot/src/main/java/com/clearblade/cloud/iot/v1/SendCommandToDeviceRequest.java new file mode 100644 index 00000000..9f373978 --- /dev/null +++ b/clearblade-cloud-iot/src/main/java/com/clearblade/cloud/iot/v1/SendCommandToDeviceRequest.java @@ -0,0 +1,55 @@ +package com.clearblade.cloud.iot.v1; + +import com.clearblade.cloud.iot.v1.utils.DeviceName; + +final class SendCommandToDeviceRequest { + + private final DeviceName name; + private final String binaryData; + + private SendCommandToDeviceRequest(Builder builder){ + this.name = builder.name; + this.binaryData = builder.binaryData; + } + + // Static class Builder + public static class Builder { + + /// instance fields + private DeviceName name; + private String binaryData; + + public static Builder newBuilder() + { + return new Builder(); + } + + private Builder() {} + + // Setter methods + public Builder setName(DeviceName name) + { + this.name = name; + return this; + } + public Builder setBinaryData(String binaryData) + { + this.binaryData = binaryData; + return this; + } + + // build method to deal with outer class + // to return outer instance + public SendCommandToDeviceRequest build() + { + return new SendCommandToDeviceRequest(this); + } + } + + @Override + public String toString() + { + return "name = " + this.name.getDevice() + ", binaryData = " + this.binaryData; + } + } + diff --git a/clearblade-cloud-iot/src/main/java/com/clearblade/cloud/iot/v1/SendCommandToDeviceResponse.java b/clearblade-cloud-iot/src/main/java/com/clearblade/cloud/iot/v1/SendCommandToDeviceResponse.java new file mode 100644 index 00000000..fffcaf94 --- /dev/null +++ b/clearblade-cloud-iot/src/main/java/com/clearblade/cloud/iot/v1/SendCommandToDeviceResponse.java @@ -0,0 +1,129 @@ +package com.clearblade.cloud.iot.v1; + +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStreamReader; +import java.io.OutputStream; +import java.net.HttpURLConnection; +import java.net.MalformedURLException; +import java.net.URL; + +import javax.net.ssl.HttpsURLConnection; + +import com.clearblade.cloud.iot.v1.utils.Constants; + +public class SendCommandToDeviceResponse { + + private final SendCommandToDeviceRequest request; + private int httpStatusCode; + private String httpStatusResponse; + private Constants constants; + + protected SendCommandToDeviceResponse(Builder builder){ + this.request = builder.request; + } + + + public int getHttpStatusCode() { + return httpStatusCode; + } + + + public void setHttpStatusCode(int httpStatusCode) { + this.httpStatusCode = httpStatusCode; + } + + + public String getHttpStatusResponse() { + return httpStatusResponse; + } + + public void setHttpStatusResponse(String httpStatusResponse) { + this.httpStatusResponse = httpStatusResponse; + } + + + // Static class Builder + public static class Builder { + + /// instance fields + private SendCommandToDeviceRequest request; + + public static Builder newBuilder() + { + return new Builder(); + } + + private Builder() {} + + // Setter methods + public Builder setSendCommandToDeviceRequest(SendCommandToDeviceRequest request) + { + this.request = request; + return this; + } + + // build method to deal with outer class + // to return outer instance + public SendCommandToDeviceResponse build() + { + return new SendCommandToDeviceResponse(this); + } + } + + public void init() { + constants = new Constants(); + } + + public void processRequest() { + init(); + try { + String post_param ="?name="+constants.getBuilder().getDevice()+"&method="+constants.getMethodName(); + URL obj = new URL("https://"+constants.getEndPoint()+constants.getPath()+constants.getSystemKey()+"/cloudiot_devices"+post_param); + HttpsURLConnection con = (HttpsURLConnection) obj.openConnection(); con.setRequestMethod("POST"); + + String cBTOken = constants.getToken(); + con.setRequestProperty("ClearBlade-UserToken", cBTOken); + con.setRequestProperty("Content-Type", "application/json"); + con.setRequestProperty("Accept", "application/json"); + + String jsonInputString = + "{\"binaryData\": \"c2VuZEZ1bm55TWVzc2FnZVRvRGV2aWNl\"}"; + + + con.setDoOutput(true); try(OutputStream os = con.getOutputStream()) { byte[] + input = jsonInputString.getBytes("utf-8"); os.write(input, 0, input.length); + } + + int responseCode = con.getResponseCode(); + if (responseCode == HttpURLConnection.HTTP_OK) { + this.setHttpStatusCode(responseCode); + this.setHttpStatusResponse("HTTP_OK"); + //success + BufferedReader in = new BufferedReader(new InputStreamReader( con.getInputStream())); + String inputLine; + StringBuffer response = new StringBuffer(); + + while ((inputLine = in.readLine()) != null) { + response.append(inputLine); + } + in.close(); + } else { + System.out.println("POST request not worked"); + } + } catch(MalformedURLException e) { + e.printStackTrace(); + }catch (IOException e) { + e.printStackTrace(); + }catch(Exception e) { + e.printStackTrace(); + } + + } + + @Override + public String toString() + { + return "Http Status Code :: " + this.getHttpStatusCode() +" Http Status Response :: " + this.getHttpStatusResponse(); + } +} diff --git a/clearblade-cloud-iot/src/main/java/com/clearblade/cloud/iot/v1/utils/Constants.java b/clearblade-cloud-iot/src/main/java/com/clearblade/cloud/iot/v1/utils/Constants.java new file mode 100644 index 00000000..74e978a7 --- /dev/null +++ b/clearblade-cloud-iot/src/main/java/com/clearblade/cloud/iot/v1/utils/Constants.java @@ -0,0 +1,73 @@ +package com.clearblade.cloud.iot.v1.utils; + +public class Constants { + + private String endPoint; + private String path; + private String systemKey; + private String methodName; + private String token; + private DeviceName.Builder builder; + + public Constants() { + this.setEndPoint("iot-sandbox.clearblade.com:443"); + this.setBuilder(DeviceName.newBuilder() + .setProject("ingressdevelopmentenv") + .setLocation("us-central1") + .setRegistry("Rashmi_Registry_Test") + .setDevice("Rashmi_Device_Test")); + this.setPath("/api/v/4/webhook/execute/"); + this.setSystemKey("fedbc9b40cde90befbd9b2dfde9d01"); //Rashmi System Key + this.setMethodName("sendCommandToDevice"); + this.setToken("eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1aWQiOiI4NmRjYzliNDBjOWVkMmI4YWFmZmMwOWRhMmNkMDEiLCJzaWQiOiJmZTdkNWIyMy1hODg4LTQ2NGUtOGE4MC01ZWM1NTYwOTBjZTIiLCJ1dCI6MiwidHQiOjEsImV4cCI6LTEsImlhdCI6MTY2NTc0MjU5NX0.osrsmcqunC6IMfgLfZis0UlC4s7W4mmKe73mq_SSJ8Q"); + } + + public String getEndPoint() { + return endPoint; + } + + public void setEndPoint(String endPoint) { + this.endPoint = endPoint; + } + + public String getPath() { + return path; + } + + public void setPath(String path) { + this.path = path; + } + + public String getSystemKey() { + return systemKey; + } + + public void setSystemKey(String systemKey) { + this.systemKey = systemKey; + } + + public String getMethodName() { + return methodName; + } + + public void setMethodName(String methodName) { + this.methodName = methodName; + } + + public String getToken() { + return token; + } + + public void setToken(String token) { + this.token = token; + } + + public DeviceName.Builder getBuilder() { + return builder; + } + + public void setBuilder(DeviceName.Builder builder) { + this.builder = builder; + } + +} diff --git a/clearblade-cloud-iot/src/main/java/com/clearblade/cloud/iot/v1/utils/DeviceName.java b/clearblade-cloud-iot/src/main/java/com/clearblade/cloud/iot/v1/utils/DeviceName.java new file mode 100644 index 00000000..91a6c4c2 --- /dev/null +++ b/clearblade-cloud-iot/src/main/java/com/clearblade/cloud/iot/v1/utils/DeviceName.java @@ -0,0 +1,123 @@ +package com.clearblade.cloud.iot.v1.utils; + +public class DeviceName { + + private final String project; + private final String location; + private final String registry; + private final String device; + + protected DeviceName() { + project = null; + location = null; + registry = null; + device = null; + } + + private DeviceName(Builder builder) { + project = builder.getProject(); + location = builder.getLocation(); + registry = builder.getRegistry(); + device = builder.getDevice(); + } + + public String getProject() { + return project; + } + + public String getLocation() { + return location; + } + + public String getRegistry() { + return registry; + } + + public String getDevice() { + return device; + } + + public static Builder newBuilder() { + return new Builder(); + } + + public Builder toBuilder() { + return new Builder(this); + } + + public static DeviceName of(String project, String location, String registry, String device) { + return newBuilder() + .setProject(project) + .setLocation(location) + .setRegistry(registry) + .setDevice(device) + .build(); + } + + public static String format(String project, String location, String registry, String device) { + return newBuilder() + .setProject(project) + .setLocation(location) + .setRegistry(registry) + .setDevice(device) + .build() + .toString(); + } + + /** Builder for projects/{project}/locations/{location}/registries/{registry}/devices/{device}. */ + public static class Builder { + private String project; + private String location; + private String registry; + private String device; + + protected Builder() {} + + public String getProject() { + return project; + } + + public String getLocation() { + return location; + } + + public String getRegistry() { + return registry; + } + + public String getDevice() { + return device; + } + + public Builder setProject(String project) { + this.project = project; + return this; + } + + public Builder setLocation(String location) { + this.location = location; + return this; + } + + public Builder setRegistry(String registry) { + this.registry = registry; + return this; + } + + public Builder setDevice(String device) { + this.device = device; + return this; + } + + private Builder(DeviceName deviceName) { + this.project = deviceName.project; + this.location = deviceName.location; + this.registry = deviceName.registry; + this.device = deviceName.device; + } + + public DeviceName build() { + return new DeviceName(this); + } + } +} diff --git a/codecov.yaml b/codecov.yaml deleted file mode 100644 index 5724ea94..00000000 --- a/codecov.yaml +++ /dev/null @@ -1,4 +0,0 @@ ---- -codecov: - ci: - - source.cloud.google.com diff --git a/google-cloud-iot-bom/pom.xml b/google-cloud-iot-bom/pom.xml deleted file mode 100644 index 4f03ef43..00000000 --- a/google-cloud-iot-bom/pom.xml +++ /dev/null @@ -1,81 +0,0 @@ - - - 4.0.0 - com.google.cloud - google-cloud-iot-bom - 2.3.5 - pom - - com.google.cloud - google-cloud-shared-config - 1.5.3 - - - Google Cloud iot BOM - https://github.com/googleapis/java-iot - - BOM for Google Cloud IoT Core - - - - Google LLC - - - - - chingor13 - Jeff Ching - chingor@google.com - Google LLC - - Developer - - - - - - scm:git:https://github.com/googleapis/java-iot.git - scm:git:git@github.com:googleapis/java-iot.git - https://github.com/googleapis/java-iot - - - - - The Apache Software License, Version 2.0 - http://www.apache.org/licenses/LICENSE-2.0.txt - repo - - - - - - - com.google.cloud - google-cloud-iot - 2.3.5 - - - com.google.api.grpc - grpc-google-cloud-iot-v1 - 2.3.5 - - - com.google.api.grpc - proto-google-cloud-iot-v1 - 2.3.5 - - - - - - - - org.apache.maven.plugins - maven-checkstyle-plugin - - true - - - - - diff --git a/google-cloud-iot/pom.xml b/google-cloud-iot/pom.xml deleted file mode 100644 index 8b3d128c..00000000 --- a/google-cloud-iot/pom.xml +++ /dev/null @@ -1,135 +0,0 @@ - - - 4.0.0 - com.google.cloud - google-cloud-iot - 2.3.5 - jar - Google Cloud IoT Core - https://github.com/googleapis/java-iot - Java idiomatic client for Google Cloud IoT Core - - com.google.cloud - google-cloud-iot-parent - 2.3.5 - - - google-cloud-iot - - - - io.grpc - grpc-api - - - io.grpc - grpc-stub - - - io.grpc - grpc-protobuf - - - com.google.api - api-common - - - com.google.protobuf - protobuf-java - - - com.google.api.grpc - proto-google-common-protos - - - com.google.api.grpc - proto-google-iam-v1 - - - - com.google.api.grpc - proto-google-cloud-iot-v1 - - - com.google.guava - guava - - - com.google.api - gax - - - com.google.api - gax-grpc - - - com.google.api - gax-httpjson - - - org.threeten - threetenbp - - - - - junit - junit - test - - - com.google.cloud - google-cloud-core - test - - - - com.google.api.grpc - grpc-google-cloud-iot-v1 - test - - - - com.google.api - gax - testlib - test - - - com.google.api - gax-grpc - testlib - test - - - com.google.api - gax-httpjson - testlib - test - - - - - - java9 - - [9,) - - - - javax.annotation - javax.annotation-api - - - - - - - - - org.codehaus.mojo - flatten-maven-plugin - - - - diff --git a/google-cloud-iot/src/main/java/com/google/cloud/iot/v1/DeviceManagerClient.java b/google-cloud-iot/src/main/java/com/google/cloud/iot/v1/DeviceManagerClient.java deleted file mode 100644 index 839d3392..00000000 --- a/google-cloud-iot/src/main/java/com/google/cloud/iot/v1/DeviceManagerClient.java +++ /dev/null @@ -1,2934 +0,0 @@ -/* - * 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 com.google.api.core.ApiFuture; -import com.google.api.core.ApiFutures; -import com.google.api.gax.core.BackgroundResource; -import com.google.api.gax.paging.AbstractFixedSizeCollection; -import com.google.api.gax.paging.AbstractPage; -import com.google.api.gax.paging.AbstractPagedListResponse; -import com.google.api.gax.rpc.PageContext; -import com.google.api.gax.rpc.UnaryCallable; -import com.google.api.resourcenames.ResourceName; -import com.google.cloud.iot.v1.stub.DeviceManagerStub; -import com.google.cloud.iot.v1.stub.DeviceManagerStubSettings; -import com.google.common.util.concurrent.MoreExecutors; -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.ByteString; -import com.google.protobuf.Empty; -import com.google.protobuf.FieldMask; -import java.io.IOException; -import java.util.List; -import java.util.concurrent.TimeUnit; -import javax.annotation.Generated; - -// AUTO-GENERATED DOCUMENTATION AND CLASS. -/** - * Service Description: Internet of Things (IoT) service. Securely connect and manage IoT devices. - * - *

This class provides the ability to make remote calls to the backing service through method - * calls that map to API methods. Sample code to get started: - * - *

{@code
- * // This snippet has been automatically generated and should be regarded as a code template only.
- * // It will require modifications to work:
- * // - It may require correct/in-range values for request initialization.
- * // - It may require specifying regional endpoints when creating the service client as shown in
- * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
- * try (DeviceManagerClient deviceManagerClient = DeviceManagerClient.create()) {
- *   LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]");
- *   DeviceRegistry deviceRegistry = DeviceRegistry.newBuilder().build();
- *   DeviceRegistry response = deviceManagerClient.createDeviceRegistry(parent, deviceRegistry);
- * }
- * }
- * - *

Note: close() needs to be called on the DeviceManagerClient object to clean up resources such - * as threads. In the example above, try-with-resources is used, which automatically calls close(). - * - *

The surface of this class includes several types of Java methods for each of the API's - * methods: - * - *

    - *
  1. A "flattened" method. With this type of method, the fields of the request type have been - * converted into function parameters. It may be the case that not all fields are available as - * parameters, and not every API method will have a flattened method entry point. - *
  2. A "request object" method. This type of method only takes one parameter, a request object, - * which must be constructed before the call. Not every API method will have a request object - * method. - *
  3. A "callable" method. This type of method takes no parameters and returns an immutable API - * callable object, which can be used to initiate calls to the service. - *
- * - *

See the individual methods for example code. - * - *

Many parameters require resource names to be formatted in a particular way. To assist with - * these names, this class includes a format method for each type of name, and additionally a parse - * method to extract the individual identifiers contained within names that are returned. - * - *

This class can be customized by passing in a custom instance of DeviceManagerSettings to - * create(). For example: - * - *

To customize credentials: - * - *

{@code
- * // This snippet has been automatically generated and should be regarded as a code template only.
- * // It will require modifications to work:
- * // - It may require correct/in-range values for request initialization.
- * // - It may require specifying regional endpoints when creating the service client as shown in
- * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
- * DeviceManagerSettings deviceManagerSettings =
- *     DeviceManagerSettings.newBuilder()
- *         .setCredentialsProvider(FixedCredentialsProvider.create(myCredentials))
- *         .build();
- * DeviceManagerClient deviceManagerClient = DeviceManagerClient.create(deviceManagerSettings);
- * }
- * - *

To customize the endpoint: - * - *

{@code
- * // This snippet has been automatically generated and should be regarded as a code template only.
- * // It will require modifications to work:
- * // - It may require correct/in-range values for request initialization.
- * // - It may require specifying regional endpoints when creating the service client as shown in
- * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
- * DeviceManagerSettings deviceManagerSettings =
- *     DeviceManagerSettings.newBuilder().setEndpoint(myEndpoint).build();
- * 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 and should be regarded as a code template only.
- * // It will require modifications to work:
- * // - It may require correct/in-range values for request initialization.
- * // - It may require specifying regional endpoints when creating the service client as shown in
- * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
- * 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") -public class DeviceManagerClient implements BackgroundResource { - private final DeviceManagerSettings settings; - private final DeviceManagerStub stub; - - /** Constructs an instance of DeviceManagerClient with default settings. */ - public static final DeviceManagerClient create() throws IOException { - return create(DeviceManagerSettings.newBuilder().build()); - } - - /** - * Constructs an instance of DeviceManagerClient, using the given settings. The channels are - * created based on the settings passed in, or defaults for any settings that are not set. - */ - public static final DeviceManagerClient create(DeviceManagerSettings settings) - throws IOException { - return new DeviceManagerClient(settings); - } - - /** - * Constructs an instance of DeviceManagerClient, using the given stub for making calls. This is - * for advanced usage - prefer using create(DeviceManagerSettings). - */ - public static final DeviceManagerClient create(DeviceManagerStub stub) { - return new DeviceManagerClient(stub); - } - - /** - * Constructs an instance of DeviceManagerClient, 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 DeviceManagerClient(DeviceManagerSettings settings) throws IOException { - this.settings = settings; - this.stub = ((DeviceManagerStubSettings) settings.getStubSettings()).createStub(); - } - - protected DeviceManagerClient(DeviceManagerStub stub) { - this.settings = null; - this.stub = stub; - } - - public final DeviceManagerSettings getSettings() { - return settings; - } - - public DeviceManagerStub getStub() { - return stub; - } - - // AUTO-GENERATED DOCUMENTATION AND METHOD. - /** - * Creates a device registry that contains devices. - * - *

Sample code: - * - *

{@code
-   * // This snippet has been automatically generated and should be regarded as a code template only.
-   * // It will require modifications to work:
-   * // - It may require correct/in-range values for request initialization.
-   * // - It may require specifying regional endpoints when creating the service client as shown in
-   * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
-   * try (DeviceManagerClient deviceManagerClient = DeviceManagerClient.create()) {
-   *   LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]");
-   *   DeviceRegistry deviceRegistry = DeviceRegistry.newBuilder().build();
-   *   DeviceRegistry response = deviceManagerClient.createDeviceRegistry(parent, deviceRegistry);
-   * }
-   * }
- * - * @param parent Required. The project and cloud region where this device registry must be - * created. For example, `projects/example-project/locations/us-central1`. - * @param deviceRegistry Required. The device registry. The field `name` must be empty. The server - * will generate that field from the device registry `id` provided and the `parent` field. - * @throws com.google.api.gax.rpc.ApiException if the remote call fails - */ - public final DeviceRegistry createDeviceRegistry( - LocationName parent, DeviceRegistry deviceRegistry) { - CreateDeviceRegistryRequest request = - CreateDeviceRegistryRequest.newBuilder() - .setParent(parent == null ? null : parent.toString()) - .setDeviceRegistry(deviceRegistry) - .build(); - return createDeviceRegistry(request); - } - - // AUTO-GENERATED DOCUMENTATION AND METHOD. - /** - * Creates a device registry that contains devices. - * - *

Sample code: - * - *

{@code
-   * // This snippet has been automatically generated and should be regarded as a code template only.
-   * // It will require modifications to work:
-   * // - It may require correct/in-range values for request initialization.
-   * // - It may require specifying regional endpoints when creating the service client as shown in
-   * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
-   * try (DeviceManagerClient deviceManagerClient = DeviceManagerClient.create()) {
-   *   String parent = LocationName.of("[PROJECT]", "[LOCATION]").toString();
-   *   DeviceRegistry deviceRegistry = DeviceRegistry.newBuilder().build();
-   *   DeviceRegistry response = deviceManagerClient.createDeviceRegistry(parent, deviceRegistry);
-   * }
-   * }
- * - * @param parent Required. The project and cloud region where this device registry must be - * created. For example, `projects/example-project/locations/us-central1`. - * @param deviceRegistry Required. The device registry. The field `name` must be empty. The server - * will generate that field from the device registry `id` provided and the `parent` field. - * @throws com.google.api.gax.rpc.ApiException if the remote call fails - */ - public final DeviceRegistry createDeviceRegistry(String parent, DeviceRegistry deviceRegistry) { - CreateDeviceRegistryRequest request = - CreateDeviceRegistryRequest.newBuilder() - .setParent(parent) - .setDeviceRegistry(deviceRegistry) - .build(); - return createDeviceRegistry(request); - } - - // AUTO-GENERATED DOCUMENTATION AND METHOD. - /** - * Creates a device registry that contains devices. - * - *

Sample code: - * - *

{@code
-   * // This snippet has been automatically generated and should be regarded as a code template only.
-   * // It will require modifications to work:
-   * // - It may require correct/in-range values for request initialization.
-   * // - It may require specifying regional endpoints when creating the service client as shown in
-   * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
-   * 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);
-   * }
-   * }
- * - * @param request The request object containing all of the parameters for the API call. - * @throws com.google.api.gax.rpc.ApiException if the remote call fails - */ - public final DeviceRegistry createDeviceRegistry(CreateDeviceRegistryRequest request) { - return createDeviceRegistryCallable().call(request); - } - - // AUTO-GENERATED DOCUMENTATION AND METHOD. - /** - * Creates a device registry that contains devices. - * - *

Sample code: - * - *

{@code
-   * // This snippet has been automatically generated and should be regarded as a code template only.
-   * // It will require modifications to work:
-   * // - It may require correct/in-range values for request initialization.
-   * // - It may require specifying regional endpoints when creating the service client as shown in
-   * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
-   * 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();
-   * }
-   * }
- */ - public final UnaryCallable - createDeviceRegistryCallable() { - return stub.createDeviceRegistryCallable(); - } - - // AUTO-GENERATED DOCUMENTATION AND METHOD. - /** - * Gets a device registry configuration. - * - *

Sample code: - * - *

{@code
-   * // This snippet has been automatically generated and should be regarded as a code template only.
-   * // It will require modifications to work:
-   * // - It may require correct/in-range values for request initialization.
-   * // - It may require specifying regional endpoints when creating the service client as shown in
-   * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
-   * try (DeviceManagerClient deviceManagerClient = DeviceManagerClient.create()) {
-   *   RegistryName name = RegistryName.of("[PROJECT]", "[LOCATION]", "[REGISTRY]");
-   *   DeviceRegistry response = deviceManagerClient.getDeviceRegistry(name);
-   * }
-   * }
- * - * @param name Required. The name of the device registry. For example, - * `projects/example-project/locations/us-central1/registries/my-registry`. - * @throws com.google.api.gax.rpc.ApiException if the remote call fails - */ - public final DeviceRegistry getDeviceRegistry(RegistryName name) { - GetDeviceRegistryRequest request = - GetDeviceRegistryRequest.newBuilder() - .setName(name == null ? null : name.toString()) - .build(); - return getDeviceRegistry(request); - } - - // AUTO-GENERATED DOCUMENTATION AND METHOD. - /** - * Gets a device registry configuration. - * - *

Sample code: - * - *

{@code
-   * // This snippet has been automatically generated and should be regarded as a code template only.
-   * // It will require modifications to work:
-   * // - It may require correct/in-range values for request initialization.
-   * // - It may require specifying regional endpoints when creating the service client as shown in
-   * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
-   * try (DeviceManagerClient deviceManagerClient = DeviceManagerClient.create()) {
-   *   String name = RegistryName.of("[PROJECT]", "[LOCATION]", "[REGISTRY]").toString();
-   *   DeviceRegistry response = deviceManagerClient.getDeviceRegistry(name);
-   * }
-   * }
- * - * @param name Required. The name of the device registry. For example, - * `projects/example-project/locations/us-central1/registries/my-registry`. - * @throws com.google.api.gax.rpc.ApiException if the remote call fails - */ - public final DeviceRegistry getDeviceRegistry(String name) { - GetDeviceRegistryRequest request = GetDeviceRegistryRequest.newBuilder().setName(name).build(); - return getDeviceRegistry(request); - } - - // AUTO-GENERATED DOCUMENTATION AND METHOD. - /** - * Gets a device registry configuration. - * - *

Sample code: - * - *

{@code
-   * // This snippet has been automatically generated and should be regarded as a code template only.
-   * // It will require modifications to work:
-   * // - It may require correct/in-range values for request initialization.
-   * // - It may require specifying regional endpoints when creating the service client as shown in
-   * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
-   * try (DeviceManagerClient deviceManagerClient = DeviceManagerClient.create()) {
-   *   GetDeviceRegistryRequest request =
-   *       GetDeviceRegistryRequest.newBuilder()
-   *           .setName(RegistryName.of("[PROJECT]", "[LOCATION]", "[REGISTRY]").toString())
-   *           .build();
-   *   DeviceRegistry response = deviceManagerClient.getDeviceRegistry(request);
-   * }
-   * }
- * - * @param request The request object containing all of the parameters for the API call. - * @throws com.google.api.gax.rpc.ApiException if the remote call fails - */ - public final DeviceRegistry getDeviceRegistry(GetDeviceRegistryRequest request) { - return getDeviceRegistryCallable().call(request); - } - - // AUTO-GENERATED DOCUMENTATION AND METHOD. - /** - * Gets a device registry configuration. - * - *

Sample code: - * - *

{@code
-   * // This snippet has been automatically generated and should be regarded as a code template only.
-   * // It will require modifications to work:
-   * // - It may require correct/in-range values for request initialization.
-   * // - It may require specifying regional endpoints when creating the service client as shown in
-   * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
-   * 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();
-   * }
-   * }
- */ - public final UnaryCallable getDeviceRegistryCallable() { - return stub.getDeviceRegistryCallable(); - } - - // AUTO-GENERATED DOCUMENTATION AND METHOD. - /** - * Updates a device registry configuration. - * - *

Sample code: - * - *

{@code
-   * // This snippet has been automatically generated and should be regarded as a code template only.
-   * // It will require modifications to work:
-   * // - It may require correct/in-range values for request initialization.
-   * // - It may require specifying regional endpoints when creating the service client as shown in
-   * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
-   * try (DeviceManagerClient deviceManagerClient = DeviceManagerClient.create()) {
-   *   DeviceRegistry deviceRegistry = DeviceRegistry.newBuilder().build();
-   *   FieldMask updateMask = FieldMask.newBuilder().build();
-   *   DeviceRegistry response =
-   *       deviceManagerClient.updateDeviceRegistry(deviceRegistry, updateMask);
-   * }
-   * }
- * - * @param deviceRegistry Required. The new values for the device registry. The `id` field must be - * empty, and the `name` field must indicate the path of the resource. For example, - * `projects/example-project/locations/us-central1/registries/my-registry`. - * @param updateMask Required. Only updates the `device_registry` fields indicated by this mask. - * The field mask must not be empty, and it must not contain fields that are immutable or only - * set by the server. Mutable top-level fields: `event_notification_config`, `http_config`, - * `mqtt_config`, and `state_notification_config`. - * @throws com.google.api.gax.rpc.ApiException if the remote call fails - */ - public final DeviceRegistry updateDeviceRegistry( - DeviceRegistry deviceRegistry, FieldMask updateMask) { - UpdateDeviceRegistryRequest request = - UpdateDeviceRegistryRequest.newBuilder() - .setDeviceRegistry(deviceRegistry) - .setUpdateMask(updateMask) - .build(); - return updateDeviceRegistry(request); - } - - // AUTO-GENERATED DOCUMENTATION AND METHOD. - /** - * Updates a device registry configuration. - * - *

Sample code: - * - *

{@code
-   * // This snippet has been automatically generated and should be regarded as a code template only.
-   * // It will require modifications to work:
-   * // - It may require correct/in-range values for request initialization.
-   * // - It may require specifying regional endpoints when creating the service client as shown in
-   * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
-   * try (DeviceManagerClient deviceManagerClient = DeviceManagerClient.create()) {
-   *   UpdateDeviceRegistryRequest request =
-   *       UpdateDeviceRegistryRequest.newBuilder()
-   *           .setDeviceRegistry(DeviceRegistry.newBuilder().build())
-   *           .setUpdateMask(FieldMask.newBuilder().build())
-   *           .build();
-   *   DeviceRegistry response = deviceManagerClient.updateDeviceRegistry(request);
-   * }
-   * }
- * - * @param request The request object containing all of the parameters for the API call. - * @throws com.google.api.gax.rpc.ApiException if the remote call fails - */ - public final DeviceRegistry updateDeviceRegistry(UpdateDeviceRegistryRequest request) { - return updateDeviceRegistryCallable().call(request); - } - - // AUTO-GENERATED DOCUMENTATION AND METHOD. - /** - * Updates a device registry configuration. - * - *

Sample code: - * - *

{@code
-   * // This snippet has been automatically generated and should be regarded as a code template only.
-   * // It will require modifications to work:
-   * // - It may require correct/in-range values for request initialization.
-   * // - It may require specifying regional endpoints when creating the service client as shown in
-   * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
-   * 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();
-   * }
-   * }
- */ - public final UnaryCallable - updateDeviceRegistryCallable() { - return stub.updateDeviceRegistryCallable(); - } - - // AUTO-GENERATED DOCUMENTATION AND METHOD. - /** - * Deletes a device registry configuration. - * - *

Sample code: - * - *

{@code
-   * // This snippet has been automatically generated and should be regarded as a code template only.
-   * // It will require modifications to work:
-   * // - It may require correct/in-range values for request initialization.
-   * // - It may require specifying regional endpoints when creating the service client as shown in
-   * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
-   * try (DeviceManagerClient deviceManagerClient = DeviceManagerClient.create()) {
-   *   RegistryName name = RegistryName.of("[PROJECT]", "[LOCATION]", "[REGISTRY]");
-   *   deviceManagerClient.deleteDeviceRegistry(name);
-   * }
-   * }
- * - * @param name Required. The name of the device registry. For example, - * `projects/example-project/locations/us-central1/registries/my-registry`. - * @throws com.google.api.gax.rpc.ApiException if the remote call fails - */ - public final void deleteDeviceRegistry(RegistryName name) { - DeleteDeviceRegistryRequest request = - DeleteDeviceRegistryRequest.newBuilder() - .setName(name == null ? null : name.toString()) - .build(); - deleteDeviceRegistry(request); - } - - // AUTO-GENERATED DOCUMENTATION AND METHOD. - /** - * Deletes a device registry configuration. - * - *

Sample code: - * - *

{@code
-   * // This snippet has been automatically generated and should be regarded as a code template only.
-   * // It will require modifications to work:
-   * // - It may require correct/in-range values for request initialization.
-   * // - It may require specifying regional endpoints when creating the service client as shown in
-   * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
-   * try (DeviceManagerClient deviceManagerClient = DeviceManagerClient.create()) {
-   *   String name = RegistryName.of("[PROJECT]", "[LOCATION]", "[REGISTRY]").toString();
-   *   deviceManagerClient.deleteDeviceRegistry(name);
-   * }
-   * }
- * - * @param name Required. The name of the device registry. For example, - * `projects/example-project/locations/us-central1/registries/my-registry`. - * @throws com.google.api.gax.rpc.ApiException if the remote call fails - */ - public final void deleteDeviceRegistry(String name) { - DeleteDeviceRegistryRequest request = - DeleteDeviceRegistryRequest.newBuilder().setName(name).build(); - deleteDeviceRegistry(request); - } - - // AUTO-GENERATED DOCUMENTATION AND METHOD. - /** - * Deletes a device registry configuration. - * - *

Sample code: - * - *

{@code
-   * // This snippet has been automatically generated and should be regarded as a code template only.
-   * // It will require modifications to work:
-   * // - It may require correct/in-range values for request initialization.
-   * // - It may require specifying regional endpoints when creating the service client as shown in
-   * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
-   * try (DeviceManagerClient deviceManagerClient = DeviceManagerClient.create()) {
-   *   DeleteDeviceRegistryRequest request =
-   *       DeleteDeviceRegistryRequest.newBuilder()
-   *           .setName(RegistryName.of("[PROJECT]", "[LOCATION]", "[REGISTRY]").toString())
-   *           .build();
-   *   deviceManagerClient.deleteDeviceRegistry(request);
-   * }
-   * }
- * - * @param request The request object containing all of the parameters for the API call. - * @throws com.google.api.gax.rpc.ApiException if the remote call fails - */ - public final void deleteDeviceRegistry(DeleteDeviceRegistryRequest request) { - deleteDeviceRegistryCallable().call(request); - } - - // AUTO-GENERATED DOCUMENTATION AND METHOD. - /** - * Deletes a device registry configuration. - * - *

Sample code: - * - *

{@code
-   * // This snippet has been automatically generated and should be regarded as a code template only.
-   * // It will require modifications to work:
-   * // - It may require correct/in-range values for request initialization.
-   * // - It may require specifying regional endpoints when creating the service client as shown in
-   * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
-   * 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();
-   * }
-   * }
- */ - public final UnaryCallable deleteDeviceRegistryCallable() { - return stub.deleteDeviceRegistryCallable(); - } - - // AUTO-GENERATED DOCUMENTATION AND METHOD. - /** - * Lists device registries. - * - *

Sample code: - * - *

{@code
-   * // This snippet has been automatically generated and should be regarded as a code template only.
-   * // It will require modifications to work:
-   * // - It may require correct/in-range values for request initialization.
-   * // - It may require specifying regional endpoints when creating the service client as shown in
-   * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
-   * try (DeviceManagerClient deviceManagerClient = DeviceManagerClient.create()) {
-   *   LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]");
-   *   for (DeviceRegistry element : deviceManagerClient.listDeviceRegistries(parent).iterateAll()) {
-   *     // doThingsWith(element);
-   *   }
-   * }
-   * }
- * - * @param parent Required. The project and cloud region path. For example, - * `projects/example-project/locations/us-central1`. - * @throws com.google.api.gax.rpc.ApiException if the remote call fails - */ - public final ListDeviceRegistriesPagedResponse listDeviceRegistries(LocationName parent) { - ListDeviceRegistriesRequest request = - ListDeviceRegistriesRequest.newBuilder() - .setParent(parent == null ? null : parent.toString()) - .build(); - return listDeviceRegistries(request); - } - - // AUTO-GENERATED DOCUMENTATION AND METHOD. - /** - * Lists device registries. - * - *

Sample code: - * - *

{@code
-   * // This snippet has been automatically generated and should be regarded as a code template only.
-   * // It will require modifications to work:
-   * // - It may require correct/in-range values for request initialization.
-   * // - It may require specifying regional endpoints when creating the service client as shown in
-   * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
-   * try (DeviceManagerClient deviceManagerClient = DeviceManagerClient.create()) {
-   *   String parent = LocationName.of("[PROJECT]", "[LOCATION]").toString();
-   *   for (DeviceRegistry element : deviceManagerClient.listDeviceRegistries(parent).iterateAll()) {
-   *     // doThingsWith(element);
-   *   }
-   * }
-   * }
- * - * @param parent Required. The project and cloud region path. For example, - * `projects/example-project/locations/us-central1`. - * @throws com.google.api.gax.rpc.ApiException if the remote call fails - */ - public final ListDeviceRegistriesPagedResponse listDeviceRegistries(String parent) { - ListDeviceRegistriesRequest request = - ListDeviceRegistriesRequest.newBuilder().setParent(parent).build(); - return listDeviceRegistries(request); - } - - // AUTO-GENERATED DOCUMENTATION AND METHOD. - /** - * Lists device registries. - * - *

Sample code: - * - *

{@code
-   * // This snippet has been automatically generated and should be regarded as a code template only.
-   * // It will require modifications to work:
-   * // - It may require correct/in-range values for request initialization.
-   * // - It may require specifying regional endpoints when creating the service client as shown in
-   * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
-   * 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);
-   *   }
-   * }
-   * }
- * - * @param request The request object containing all of the parameters for the API call. - * @throws com.google.api.gax.rpc.ApiException if the remote call fails - */ - public final ListDeviceRegistriesPagedResponse listDeviceRegistries( - ListDeviceRegistriesRequest request) { - return listDeviceRegistriesPagedCallable().call(request); - } - - // AUTO-GENERATED DOCUMENTATION AND METHOD. - /** - * Lists device registries. - * - *

Sample code: - * - *

{@code
-   * // This snippet has been automatically generated and should be regarded as a code template only.
-   * // It will require modifications to work:
-   * // - It may require correct/in-range values for request initialization.
-   * // - It may require specifying regional endpoints when creating the service client as shown in
-   * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
-   * 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);
-   *   }
-   * }
-   * }
- */ - public final UnaryCallable - listDeviceRegistriesPagedCallable() { - return stub.listDeviceRegistriesPagedCallable(); - } - - // AUTO-GENERATED DOCUMENTATION AND METHOD. - /** - * Lists device registries. - * - *

Sample code: - * - *

{@code
-   * // This snippet has been automatically generated and should be regarded as a code template only.
-   * // It will require modifications to work:
-   * // - It may require correct/in-range values for request initialization.
-   * // - It may require specifying regional endpoints when creating the service client as shown in
-   * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
-   * 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;
-   *     }
-   *   }
-   * }
-   * }
- */ - public final UnaryCallable - listDeviceRegistriesCallable() { - return stub.listDeviceRegistriesCallable(); - } - - // AUTO-GENERATED DOCUMENTATION AND METHOD. - /** - * Creates a device in a device registry. - * - *

Sample code: - * - *

{@code
-   * // This snippet has been automatically generated and should be regarded as a code template only.
-   * // It will require modifications to work:
-   * // - It may require correct/in-range values for request initialization.
-   * // - It may require specifying regional endpoints when creating the service client as shown in
-   * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
-   * try (DeviceManagerClient deviceManagerClient = DeviceManagerClient.create()) {
-   *   RegistryName parent = RegistryName.of("[PROJECT]", "[LOCATION]", "[REGISTRY]");
-   *   Device device = Device.newBuilder().build();
-   *   Device response = deviceManagerClient.createDevice(parent, device);
-   * }
-   * }
- * - * @param parent Required. The name of the device registry where this device should be created. - * For example, `projects/example-project/locations/us-central1/registries/my-registry`. - * @param device Required. The device registration details. The field `name` must be empty. The - * server generates `name` from the device registry `id` and the `parent` field. - * @throws com.google.api.gax.rpc.ApiException if the remote call fails - */ - public final Device createDevice(RegistryName parent, Device device) { - CreateDeviceRequest request = - CreateDeviceRequest.newBuilder() - .setParent(parent == null ? null : parent.toString()) - .setDevice(device) - .build(); - return createDevice(request); - } - - // AUTO-GENERATED DOCUMENTATION AND METHOD. - /** - * Creates a device in a device registry. - * - *

Sample code: - * - *

{@code
-   * // This snippet has been automatically generated and should be regarded as a code template only.
-   * // It will require modifications to work:
-   * // - It may require correct/in-range values for request initialization.
-   * // - It may require specifying regional endpoints when creating the service client as shown in
-   * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
-   * try (DeviceManagerClient deviceManagerClient = DeviceManagerClient.create()) {
-   *   String parent = RegistryName.of("[PROJECT]", "[LOCATION]", "[REGISTRY]").toString();
-   *   Device device = Device.newBuilder().build();
-   *   Device response = deviceManagerClient.createDevice(parent, device);
-   * }
-   * }
- * - * @param parent Required. The name of the device registry where this device should be created. - * For example, `projects/example-project/locations/us-central1/registries/my-registry`. - * @param device Required. The device registration details. The field `name` must be empty. The - * server generates `name` from the device registry `id` and the `parent` field. - * @throws com.google.api.gax.rpc.ApiException if the remote call fails - */ - public final Device createDevice(String parent, Device device) { - CreateDeviceRequest request = - CreateDeviceRequest.newBuilder().setParent(parent).setDevice(device).build(); - return createDevice(request); - } - - // AUTO-GENERATED DOCUMENTATION AND METHOD. - /** - * Creates a device in a device registry. - * - *

Sample code: - * - *

{@code
-   * // This snippet has been automatically generated and should be regarded as a code template only.
-   * // It will require modifications to work:
-   * // - It may require correct/in-range values for request initialization.
-   * // - It may require specifying regional endpoints when creating the service client as shown in
-   * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
-   * 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);
-   * }
-   * }
- * - * @param request The request object containing all of the parameters for the API call. - * @throws com.google.api.gax.rpc.ApiException if the remote call fails - */ - public final Device createDevice(CreateDeviceRequest request) { - return createDeviceCallable().call(request); - } - - // AUTO-GENERATED DOCUMENTATION AND METHOD. - /** - * Creates a device in a device registry. - * - *

Sample code: - * - *

{@code
-   * // This snippet has been automatically generated and should be regarded as a code template only.
-   * // It will require modifications to work:
-   * // - It may require correct/in-range values for request initialization.
-   * // - It may require specifying regional endpoints when creating the service client as shown in
-   * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
-   * 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();
-   * }
-   * }
- */ - public final UnaryCallable createDeviceCallable() { - return stub.createDeviceCallable(); - } - - // AUTO-GENERATED DOCUMENTATION AND METHOD. - /** - * Gets details about a device. - * - *

Sample code: - * - *

{@code
-   * // This snippet has been automatically generated and should be regarded as a code template only.
-   * // It will require modifications to work:
-   * // - It may require correct/in-range values for request initialization.
-   * // - It may require specifying regional endpoints when creating the service client as shown in
-   * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
-   * try (DeviceManagerClient deviceManagerClient = DeviceManagerClient.create()) {
-   *   DeviceName name = DeviceName.of("[PROJECT]", "[LOCATION]", "[REGISTRY]", "[DEVICE]");
-   *   Device response = deviceManagerClient.getDevice(name);
-   * }
-   * }
- * - * @param name Required. The name of the device. For example, - * `projects/p0/locations/us-central1/registries/registry0/devices/device0` or - * `projects/p0/locations/us-central1/registries/registry0/devices/{num_id}`. - * @throws com.google.api.gax.rpc.ApiException if the remote call fails - */ - public final Device getDevice(DeviceName name) { - GetDeviceRequest request = - GetDeviceRequest.newBuilder().setName(name == null ? null : name.toString()).build(); - return getDevice(request); - } - - // AUTO-GENERATED DOCUMENTATION AND METHOD. - /** - * Gets details about a device. - * - *

Sample code: - * - *

{@code
-   * // This snippet has been automatically generated and should be regarded as a code template only.
-   * // It will require modifications to work:
-   * // - It may require correct/in-range values for request initialization.
-   * // - It may require specifying regional endpoints when creating the service client as shown in
-   * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
-   * try (DeviceManagerClient deviceManagerClient = DeviceManagerClient.create()) {
-   *   String name = DeviceName.of("[PROJECT]", "[LOCATION]", "[REGISTRY]", "[DEVICE]").toString();
-   *   Device response = deviceManagerClient.getDevice(name);
-   * }
-   * }
- * - * @param name Required. The name of the device. For example, - * `projects/p0/locations/us-central1/registries/registry0/devices/device0` or - * `projects/p0/locations/us-central1/registries/registry0/devices/{num_id}`. - * @throws com.google.api.gax.rpc.ApiException if the remote call fails - */ - public final Device getDevice(String name) { - GetDeviceRequest request = GetDeviceRequest.newBuilder().setName(name).build(); - return getDevice(request); - } - - // AUTO-GENERATED DOCUMENTATION AND METHOD. - /** - * Gets details about a device. - * - *

Sample code: - * - *

{@code
-   * // This snippet has been automatically generated and should be regarded as a code template only.
-   * // It will require modifications to work:
-   * // - It may require correct/in-range values for request initialization.
-   * // - It may require specifying regional endpoints when creating the service client as shown in
-   * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
-   * 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);
-   * }
-   * }
- * - * @param request The request object containing all of the parameters for the API call. - * @throws com.google.api.gax.rpc.ApiException if the remote call fails - */ - public final Device getDevice(GetDeviceRequest request) { - return getDeviceCallable().call(request); - } - - // AUTO-GENERATED DOCUMENTATION AND METHOD. - /** - * Gets details about a device. - * - *

Sample code: - * - *

{@code
-   * // This snippet has been automatically generated and should be regarded as a code template only.
-   * // It will require modifications to work:
-   * // - It may require correct/in-range values for request initialization.
-   * // - It may require specifying regional endpoints when creating the service client as shown in
-   * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
-   * 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();
-   * }
-   * }
- */ - public final UnaryCallable getDeviceCallable() { - return stub.getDeviceCallable(); - } - - // AUTO-GENERATED DOCUMENTATION AND METHOD. - /** - * Updates a device. - * - *

Sample code: - * - *

{@code
-   * // This snippet has been automatically generated and should be regarded as a code template only.
-   * // It will require modifications to work:
-   * // - It may require correct/in-range values for request initialization.
-   * // - It may require specifying regional endpoints when creating the service client as shown in
-   * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
-   * try (DeviceManagerClient deviceManagerClient = DeviceManagerClient.create()) {
-   *   Device device = Device.newBuilder().build();
-   *   FieldMask updateMask = FieldMask.newBuilder().build();
-   *   Device response = deviceManagerClient.updateDevice(device, updateMask);
-   * }
-   * }
- * - * @param device Required. The new values for the device. The `id` and `num_id` fields must be - * empty, and the field `name` must specify the name path. For example, - * `projects/p0/locations/us-central1/registries/registry0/devices/device0`or - * `projects/p0/locations/us-central1/registries/registry0/devices/{num_id}`. - * @param updateMask Required. Only updates the `device` fields indicated by this mask. The field - * mask must not be empty, and it must not contain fields that are immutable or only set by - * the server. Mutable top-level fields: `credentials`, `blocked`, and `metadata` - * @throws com.google.api.gax.rpc.ApiException if the remote call fails - */ - public final Device updateDevice(Device device, FieldMask updateMask) { - UpdateDeviceRequest request = - UpdateDeviceRequest.newBuilder().setDevice(device).setUpdateMask(updateMask).build(); - return updateDevice(request); - } - - // AUTO-GENERATED DOCUMENTATION AND METHOD. - /** - * Updates a device. - * - *

Sample code: - * - *

{@code
-   * // This snippet has been automatically generated and should be regarded as a code template only.
-   * // It will require modifications to work:
-   * // - It may require correct/in-range values for request initialization.
-   * // - It may require specifying regional endpoints when creating the service client as shown in
-   * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
-   * try (DeviceManagerClient deviceManagerClient = DeviceManagerClient.create()) {
-   *   UpdateDeviceRequest request =
-   *       UpdateDeviceRequest.newBuilder()
-   *           .setDevice(Device.newBuilder().build())
-   *           .setUpdateMask(FieldMask.newBuilder().build())
-   *           .build();
-   *   Device response = deviceManagerClient.updateDevice(request);
-   * }
-   * }
- * - * @param request The request object containing all of the parameters for the API call. - * @throws com.google.api.gax.rpc.ApiException if the remote call fails - */ - public final Device updateDevice(UpdateDeviceRequest request) { - return updateDeviceCallable().call(request); - } - - // AUTO-GENERATED DOCUMENTATION AND METHOD. - /** - * Updates a device. - * - *

Sample code: - * - *

{@code
-   * // This snippet has been automatically generated and should be regarded as a code template only.
-   * // It will require modifications to work:
-   * // - It may require correct/in-range values for request initialization.
-   * // - It may require specifying regional endpoints when creating the service client as shown in
-   * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
-   * 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();
-   * }
-   * }
- */ - public final UnaryCallable updateDeviceCallable() { - return stub.updateDeviceCallable(); - } - - // AUTO-GENERATED DOCUMENTATION AND METHOD. - /** - * Deletes a device. - * - *

Sample code: - * - *

{@code
-   * // This snippet has been automatically generated and should be regarded as a code template only.
-   * // It will require modifications to work:
-   * // - It may require correct/in-range values for request initialization.
-   * // - It may require specifying regional endpoints when creating the service client as shown in
-   * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
-   * try (DeviceManagerClient deviceManagerClient = DeviceManagerClient.create()) {
-   *   DeviceName name = DeviceName.of("[PROJECT]", "[LOCATION]", "[REGISTRY]", "[DEVICE]");
-   *   deviceManagerClient.deleteDevice(name);
-   * }
-   * }
- * - * @param name Required. The name of the device. For example, - * `projects/p0/locations/us-central1/registries/registry0/devices/device0` or - * `projects/p0/locations/us-central1/registries/registry0/devices/{num_id}`. - * @throws com.google.api.gax.rpc.ApiException if the remote call fails - */ - public final void deleteDevice(DeviceName name) { - DeleteDeviceRequest request = - DeleteDeviceRequest.newBuilder().setName(name == null ? null : name.toString()).build(); - deleteDevice(request); - } - - // AUTO-GENERATED DOCUMENTATION AND METHOD. - /** - * Deletes a device. - * - *

Sample code: - * - *

{@code
-   * // This snippet has been automatically generated and should be regarded as a code template only.
-   * // It will require modifications to work:
-   * // - It may require correct/in-range values for request initialization.
-   * // - It may require specifying regional endpoints when creating the service client as shown in
-   * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
-   * try (DeviceManagerClient deviceManagerClient = DeviceManagerClient.create()) {
-   *   String name = DeviceName.of("[PROJECT]", "[LOCATION]", "[REGISTRY]", "[DEVICE]").toString();
-   *   deviceManagerClient.deleteDevice(name);
-   * }
-   * }
- * - * @param name Required. The name of the device. For example, - * `projects/p0/locations/us-central1/registries/registry0/devices/device0` or - * `projects/p0/locations/us-central1/registries/registry0/devices/{num_id}`. - * @throws com.google.api.gax.rpc.ApiException if the remote call fails - */ - public final void deleteDevice(String name) { - DeleteDeviceRequest request = DeleteDeviceRequest.newBuilder().setName(name).build(); - deleteDevice(request); - } - - // AUTO-GENERATED DOCUMENTATION AND METHOD. - /** - * Deletes a device. - * - *

Sample code: - * - *

{@code
-   * // This snippet has been automatically generated and should be regarded as a code template only.
-   * // It will require modifications to work:
-   * // - It may require correct/in-range values for request initialization.
-   * // - It may require specifying regional endpoints when creating the service client as shown in
-   * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
-   * try (DeviceManagerClient deviceManagerClient = DeviceManagerClient.create()) {
-   *   DeleteDeviceRequest request =
-   *       DeleteDeviceRequest.newBuilder()
-   *           .setName(
-   *               DeviceName.of("[PROJECT]", "[LOCATION]", "[REGISTRY]", "[DEVICE]").toString())
-   *           .build();
-   *   deviceManagerClient.deleteDevice(request);
-   * }
-   * }
- * - * @param request The request object containing all of the parameters for the API call. - * @throws com.google.api.gax.rpc.ApiException if the remote call fails - */ - public final void deleteDevice(DeleteDeviceRequest request) { - deleteDeviceCallable().call(request); - } - - // AUTO-GENERATED DOCUMENTATION AND METHOD. - /** - * Deletes a device. - * - *

Sample code: - * - *

{@code
-   * // This snippet has been automatically generated and should be regarded as a code template only.
-   * // It will require modifications to work:
-   * // - It may require correct/in-range values for request initialization.
-   * // - It may require specifying regional endpoints when creating the service client as shown in
-   * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
-   * 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();
-   * }
-   * }
- */ - public final UnaryCallable deleteDeviceCallable() { - return stub.deleteDeviceCallable(); - } - - // AUTO-GENERATED DOCUMENTATION AND METHOD. - /** - * List devices in a device registry. - * - *

Sample code: - * - *

{@code
-   * // This snippet has been automatically generated and should be regarded as a code template only.
-   * // It will require modifications to work:
-   * // - It may require correct/in-range values for request initialization.
-   * // - It may require specifying regional endpoints when creating the service client as shown in
-   * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
-   * try (DeviceManagerClient deviceManagerClient = DeviceManagerClient.create()) {
-   *   RegistryName parent = RegistryName.of("[PROJECT]", "[LOCATION]", "[REGISTRY]");
-   *   for (Device element : deviceManagerClient.listDevices(parent).iterateAll()) {
-   *     // doThingsWith(element);
-   *   }
-   * }
-   * }
- * - * @param parent Required. The device registry path. Required. For example, - * `projects/my-project/locations/us-central1/registries/my-registry`. - * @throws com.google.api.gax.rpc.ApiException if the remote call fails - */ - public final ListDevicesPagedResponse listDevices(RegistryName parent) { - ListDevicesRequest request = - ListDevicesRequest.newBuilder() - .setParent(parent == null ? null : parent.toString()) - .build(); - return listDevices(request); - } - - // AUTO-GENERATED DOCUMENTATION AND METHOD. - /** - * List devices in a device registry. - * - *

Sample code: - * - *

{@code
-   * // This snippet has been automatically generated and should be regarded as a code template only.
-   * // It will require modifications to work:
-   * // - It may require correct/in-range values for request initialization.
-   * // - It may require specifying regional endpoints when creating the service client as shown in
-   * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
-   * try (DeviceManagerClient deviceManagerClient = DeviceManagerClient.create()) {
-   *   String parent = RegistryName.of("[PROJECT]", "[LOCATION]", "[REGISTRY]").toString();
-   *   for (Device element : deviceManagerClient.listDevices(parent).iterateAll()) {
-   *     // doThingsWith(element);
-   *   }
-   * }
-   * }
- * - * @param parent Required. The device registry path. Required. For example, - * `projects/my-project/locations/us-central1/registries/my-registry`. - * @throws com.google.api.gax.rpc.ApiException if the remote call fails - */ - public final ListDevicesPagedResponse listDevices(String parent) { - ListDevicesRequest request = ListDevicesRequest.newBuilder().setParent(parent).build(); - return listDevices(request); - } - - // AUTO-GENERATED DOCUMENTATION AND METHOD. - /** - * List devices in a device registry. - * - *

Sample code: - * - *

{@code
-   * // This snippet has been automatically generated and should be regarded as a code template only.
-   * // It will require modifications to work:
-   * // - It may require correct/in-range values for request initialization.
-   * // - It may require specifying regional endpoints when creating the service client as shown in
-   * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
-   * 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);
-   *   }
-   * }
-   * }
- * - * @param request The request object containing all of the parameters for the API call. - * @throws com.google.api.gax.rpc.ApiException if the remote call fails - */ - public final ListDevicesPagedResponse listDevices(ListDevicesRequest request) { - return listDevicesPagedCallable().call(request); - } - - // AUTO-GENERATED DOCUMENTATION AND METHOD. - /** - * List devices in a device registry. - * - *

Sample code: - * - *

{@code
-   * // This snippet has been automatically generated and should be regarded as a code template only.
-   * // It will require modifications to work:
-   * // - It may require correct/in-range values for request initialization.
-   * // - It may require specifying regional endpoints when creating the service client as shown in
-   * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
-   * 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);
-   *   }
-   * }
-   * }
- */ - public final UnaryCallable - listDevicesPagedCallable() { - return stub.listDevicesPagedCallable(); - } - - // AUTO-GENERATED DOCUMENTATION AND METHOD. - /** - * List devices in a device registry. - * - *

Sample code: - * - *

{@code
-   * // This snippet has been automatically generated and should be regarded as a code template only.
-   * // It will require modifications to work:
-   * // - It may require correct/in-range values for request initialization.
-   * // - It may require specifying regional endpoints when creating the service client as shown in
-   * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
-   * 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;
-   *     }
-   *   }
-   * }
-   * }
- */ - public final UnaryCallable listDevicesCallable() { - return stub.listDevicesCallable(); - } - - // AUTO-GENERATED DOCUMENTATION AND METHOD. - /** - * Modifies the configuration for the device, which is eventually sent from the Cloud IoT Core - * servers. Returns the modified configuration version and its metadata. - * - *

Sample code: - * - *

{@code
-   * // This snippet has been automatically generated and should be regarded as a code template only.
-   * // It will require modifications to work:
-   * // - It may require correct/in-range values for request initialization.
-   * // - It may require specifying regional endpoints when creating the service client as shown in
-   * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
-   * try (DeviceManagerClient deviceManagerClient = DeviceManagerClient.create()) {
-   *   DeviceName name = DeviceName.of("[PROJECT]", "[LOCATION]", "[REGISTRY]", "[DEVICE]");
-   *   ByteString binaryData = ByteString.EMPTY;
-   *   DeviceConfig response = deviceManagerClient.modifyCloudToDeviceConfig(name, binaryData);
-   * }
-   * }
- * - * @param name Required. The name of the device. For example, - * `projects/p0/locations/us-central1/registries/registry0/devices/device0` or - * `projects/p0/locations/us-central1/registries/registry0/devices/{num_id}`. - * @param binaryData Required. The configuration data for the device. - * @throws com.google.api.gax.rpc.ApiException if the remote call fails - */ - public final DeviceConfig modifyCloudToDeviceConfig(DeviceName name, ByteString binaryData) { - ModifyCloudToDeviceConfigRequest request = - ModifyCloudToDeviceConfigRequest.newBuilder() - .setName(name == null ? null : name.toString()) - .setBinaryData(binaryData) - .build(); - return modifyCloudToDeviceConfig(request); - } - - // AUTO-GENERATED DOCUMENTATION AND METHOD. - /** - * Modifies the configuration for the device, which is eventually sent from the Cloud IoT Core - * servers. Returns the modified configuration version and its metadata. - * - *

Sample code: - * - *

{@code
-   * // This snippet has been automatically generated and should be regarded as a code template only.
-   * // It will require modifications to work:
-   * // - It may require correct/in-range values for request initialization.
-   * // - It may require specifying regional endpoints when creating the service client as shown in
-   * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
-   * try (DeviceManagerClient deviceManagerClient = DeviceManagerClient.create()) {
-   *   String name = DeviceName.of("[PROJECT]", "[LOCATION]", "[REGISTRY]", "[DEVICE]").toString();
-   *   ByteString binaryData = ByteString.EMPTY;
-   *   DeviceConfig response = deviceManagerClient.modifyCloudToDeviceConfig(name, binaryData);
-   * }
-   * }
- * - * @param name Required. The name of the device. For example, - * `projects/p0/locations/us-central1/registries/registry0/devices/device0` or - * `projects/p0/locations/us-central1/registries/registry0/devices/{num_id}`. - * @param binaryData Required. The configuration data for the device. - * @throws com.google.api.gax.rpc.ApiException if the remote call fails - */ - public final DeviceConfig modifyCloudToDeviceConfig(String name, ByteString binaryData) { - ModifyCloudToDeviceConfigRequest request = - ModifyCloudToDeviceConfigRequest.newBuilder() - .setName(name) - .setBinaryData(binaryData) - .build(); - return modifyCloudToDeviceConfig(request); - } - - // AUTO-GENERATED DOCUMENTATION AND METHOD. - /** - * Modifies the configuration for the device, which is eventually sent from the Cloud IoT Core - * servers. Returns the modified configuration version and its metadata. - * - *

Sample code: - * - *

{@code
-   * // This snippet has been automatically generated and should be regarded as a code template only.
-   * // It will require modifications to work:
-   * // - It may require correct/in-range values for request initialization.
-   * // - It may require specifying regional endpoints when creating the service client as shown in
-   * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
-   * 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);
-   * }
-   * }
- * - * @param request The request object containing all of the parameters for the API call. - * @throws com.google.api.gax.rpc.ApiException if the remote call fails - */ - public final DeviceConfig modifyCloudToDeviceConfig(ModifyCloudToDeviceConfigRequest request) { - return modifyCloudToDeviceConfigCallable().call(request); - } - - // AUTO-GENERATED DOCUMENTATION AND METHOD. - /** - * Modifies the configuration for the device, which is eventually sent from the Cloud IoT Core - * servers. Returns the modified configuration version and its metadata. - * - *

Sample code: - * - *

{@code
-   * // This snippet has been automatically generated and should be regarded as a code template only.
-   * // It will require modifications to work:
-   * // - It may require correct/in-range values for request initialization.
-   * // - It may require specifying regional endpoints when creating the service client as shown in
-   * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
-   * 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();
-   * }
-   * }
- */ - public final UnaryCallable - modifyCloudToDeviceConfigCallable() { - return stub.modifyCloudToDeviceConfigCallable(); - } - - // AUTO-GENERATED DOCUMENTATION AND METHOD. - /** - * Lists the last few versions of the device configuration in descending order (i.e.: newest - * first). - * - *

Sample code: - * - *

{@code
-   * // This snippet has been automatically generated and should be regarded as a code template only.
-   * // It will require modifications to work:
-   * // - It may require correct/in-range values for request initialization.
-   * // - It may require specifying regional endpoints when creating the service client as shown in
-   * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
-   * try (DeviceManagerClient deviceManagerClient = DeviceManagerClient.create()) {
-   *   DeviceName name = DeviceName.of("[PROJECT]", "[LOCATION]", "[REGISTRY]", "[DEVICE]");
-   *   ListDeviceConfigVersionsResponse response =
-   *       deviceManagerClient.listDeviceConfigVersions(name);
-   * }
-   * }
- * - * @param name Required. The name of the device. For example, - * `projects/p0/locations/us-central1/registries/registry0/devices/device0` or - * `projects/p0/locations/us-central1/registries/registry0/devices/{num_id}`. - * @throws com.google.api.gax.rpc.ApiException if the remote call fails - */ - public final ListDeviceConfigVersionsResponse listDeviceConfigVersions(DeviceName name) { - ListDeviceConfigVersionsRequest request = - ListDeviceConfigVersionsRequest.newBuilder() - .setName(name == null ? null : name.toString()) - .build(); - return listDeviceConfigVersions(request); - } - - // AUTO-GENERATED DOCUMENTATION AND METHOD. - /** - * Lists the last few versions of the device configuration in descending order (i.e.: newest - * first). - * - *

Sample code: - * - *

{@code
-   * // This snippet has been automatically generated and should be regarded as a code template only.
-   * // It will require modifications to work:
-   * // - It may require correct/in-range values for request initialization.
-   * // - It may require specifying regional endpoints when creating the service client as shown in
-   * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
-   * try (DeviceManagerClient deviceManagerClient = DeviceManagerClient.create()) {
-   *   String name = DeviceName.of("[PROJECT]", "[LOCATION]", "[REGISTRY]", "[DEVICE]").toString();
-   *   ListDeviceConfigVersionsResponse response =
-   *       deviceManagerClient.listDeviceConfigVersions(name);
-   * }
-   * }
- * - * @param name Required. The name of the device. For example, - * `projects/p0/locations/us-central1/registries/registry0/devices/device0` or - * `projects/p0/locations/us-central1/registries/registry0/devices/{num_id}`. - * @throws com.google.api.gax.rpc.ApiException if the remote call fails - */ - public final ListDeviceConfigVersionsResponse listDeviceConfigVersions(String name) { - ListDeviceConfigVersionsRequest request = - ListDeviceConfigVersionsRequest.newBuilder().setName(name).build(); - return listDeviceConfigVersions(request); - } - - // AUTO-GENERATED DOCUMENTATION AND METHOD. - /** - * Lists the last few versions of the device configuration in descending order (i.e.: newest - * first). - * - *

Sample code: - * - *

{@code
-   * // This snippet has been automatically generated and should be regarded as a code template only.
-   * // It will require modifications to work:
-   * // - It may require correct/in-range values for request initialization.
-   * // - It may require specifying regional endpoints when creating the service client as shown in
-   * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
-   * 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);
-   * }
-   * }
- * - * @param request The request object containing all of the parameters for the API call. - * @throws com.google.api.gax.rpc.ApiException if the remote call fails - */ - public final ListDeviceConfigVersionsResponse listDeviceConfigVersions( - ListDeviceConfigVersionsRequest request) { - return listDeviceConfigVersionsCallable().call(request); - } - - // AUTO-GENERATED DOCUMENTATION AND METHOD. - /** - * Lists the last few versions of the device configuration in descending order (i.e.: newest - * first). - * - *

Sample code: - * - *

{@code
-   * // This snippet has been automatically generated and should be regarded as a code template only.
-   * // It will require modifications to work:
-   * // - It may require correct/in-range values for request initialization.
-   * // - It may require specifying regional endpoints when creating the service client as shown in
-   * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
-   * 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();
-   * }
-   * }
- */ - public final UnaryCallable - listDeviceConfigVersionsCallable() { - return stub.listDeviceConfigVersionsCallable(); - } - - // AUTO-GENERATED DOCUMENTATION AND METHOD. - /** - * Lists the last few versions of the device state in descending order (i.e.: newest first). - * - *

Sample code: - * - *

{@code
-   * // This snippet has been automatically generated and should be regarded as a code template only.
-   * // It will require modifications to work:
-   * // - It may require correct/in-range values for request initialization.
-   * // - It may require specifying regional endpoints when creating the service client as shown in
-   * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
-   * try (DeviceManagerClient deviceManagerClient = DeviceManagerClient.create()) {
-   *   DeviceName name = DeviceName.of("[PROJECT]", "[LOCATION]", "[REGISTRY]", "[DEVICE]");
-   *   ListDeviceStatesResponse response = deviceManagerClient.listDeviceStates(name);
-   * }
-   * }
- * - * @param name Required. The name of the device. For example, - * `projects/p0/locations/us-central1/registries/registry0/devices/device0` or - * `projects/p0/locations/us-central1/registries/registry0/devices/{num_id}`. - * @throws com.google.api.gax.rpc.ApiException if the remote call fails - */ - public final ListDeviceStatesResponse listDeviceStates(DeviceName name) { - ListDeviceStatesRequest request = - ListDeviceStatesRequest.newBuilder().setName(name == null ? null : name.toString()).build(); - return listDeviceStates(request); - } - - // AUTO-GENERATED DOCUMENTATION AND METHOD. - /** - * Lists the last few versions of the device state in descending order (i.e.: newest first). - * - *

Sample code: - * - *

{@code
-   * // This snippet has been automatically generated and should be regarded as a code template only.
-   * // It will require modifications to work:
-   * // - It may require correct/in-range values for request initialization.
-   * // - It may require specifying regional endpoints when creating the service client as shown in
-   * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
-   * try (DeviceManagerClient deviceManagerClient = DeviceManagerClient.create()) {
-   *   String name = DeviceName.of("[PROJECT]", "[LOCATION]", "[REGISTRY]", "[DEVICE]").toString();
-   *   ListDeviceStatesResponse response = deviceManagerClient.listDeviceStates(name);
-   * }
-   * }
- * - * @param name Required. The name of the device. For example, - * `projects/p0/locations/us-central1/registries/registry0/devices/device0` or - * `projects/p0/locations/us-central1/registries/registry0/devices/{num_id}`. - * @throws com.google.api.gax.rpc.ApiException if the remote call fails - */ - public final ListDeviceStatesResponse listDeviceStates(String name) { - ListDeviceStatesRequest request = ListDeviceStatesRequest.newBuilder().setName(name).build(); - return listDeviceStates(request); - } - - // AUTO-GENERATED DOCUMENTATION AND METHOD. - /** - * Lists the last few versions of the device state in descending order (i.e.: newest first). - * - *

Sample code: - * - *

{@code
-   * // This snippet has been automatically generated and should be regarded as a code template only.
-   * // It will require modifications to work:
-   * // - It may require correct/in-range values for request initialization.
-   * // - It may require specifying regional endpoints when creating the service client as shown in
-   * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
-   * 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);
-   * }
-   * }
- * - * @param request The request object containing all of the parameters for the API call. - * @throws com.google.api.gax.rpc.ApiException if the remote call fails - */ - public final ListDeviceStatesResponse listDeviceStates(ListDeviceStatesRequest request) { - return listDeviceStatesCallable().call(request); - } - - // AUTO-GENERATED DOCUMENTATION AND METHOD. - /** - * Lists the last few versions of the device state in descending order (i.e.: newest first). - * - *

Sample code: - * - *

{@code
-   * // This snippet has been automatically generated and should be regarded as a code template only.
-   * // It will require modifications to work:
-   * // - It may require correct/in-range values for request initialization.
-   * // - It may require specifying regional endpoints when creating the service client as shown in
-   * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
-   * 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();
-   * }
-   * }
- */ - public final UnaryCallable - listDeviceStatesCallable() { - return stub.listDeviceStatesCallable(); - } - - // AUTO-GENERATED DOCUMENTATION AND METHOD. - /** - * Sets the access control policy on the specified resource. Replaces any existing policy. - * - *

Sample code: - * - *

{@code
-   * // This snippet has been automatically generated and should be regarded as a code template only.
-   * // It will require modifications to work:
-   * // - It may require correct/in-range values for request initialization.
-   * // - It may require specifying regional endpoints when creating the service client as shown in
-   * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
-   * try (DeviceManagerClient deviceManagerClient = DeviceManagerClient.create()) {
-   *   ResourceName resource = RegistryName.of("[PROJECT]", "[LOCATION]", "[REGISTRY]");
-   *   Policy policy = Policy.newBuilder().build();
-   *   Policy response = deviceManagerClient.setIamPolicy(resource, policy);
-   * }
-   * }
- * - * @param resource REQUIRED: The resource for which the policy is being specified. See the - * operation documentation for the appropriate value for this field. - * @param policy REQUIRED: The complete policy to be applied to the `resource`. The size of the - * policy is limited to a few 10s of KB. An empty policy is a valid policy but certain Cloud - * Platform services (such as Projects) might reject them. - * @throws com.google.api.gax.rpc.ApiException if the remote call fails - */ - public final Policy setIamPolicy(ResourceName resource, Policy policy) { - SetIamPolicyRequest request = - SetIamPolicyRequest.newBuilder() - .setResource(resource == null ? null : resource.toString()) - .setPolicy(policy) - .build(); - return setIamPolicy(request); - } - - // AUTO-GENERATED DOCUMENTATION AND METHOD. - /** - * Sets the access control policy on the specified resource. Replaces any existing policy. - * - *

Sample code: - * - *

{@code
-   * // This snippet has been automatically generated and should be regarded as a code template only.
-   * // It will require modifications to work:
-   * // - It may require correct/in-range values for request initialization.
-   * // - It may require specifying regional endpoints when creating the service client as shown in
-   * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
-   * 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);
-   * }
-   * }
- * - * @param resource REQUIRED: The resource for which the policy is being specified. See the - * operation documentation for the appropriate value for this field. - * @param policy REQUIRED: The complete policy to be applied to the `resource`. The size of the - * policy is limited to a few 10s of KB. An empty policy is a valid policy but certain Cloud - * Platform services (such as Projects) might reject them. - * @throws com.google.api.gax.rpc.ApiException if the remote call fails - */ - public final Policy setIamPolicy(String resource, Policy policy) { - SetIamPolicyRequest request = - SetIamPolicyRequest.newBuilder().setResource(resource).setPolicy(policy).build(); - return setIamPolicy(request); - } - - // AUTO-GENERATED DOCUMENTATION AND METHOD. - /** - * Sets the access control policy on the specified resource. Replaces any existing policy. - * - *

Sample code: - * - *

{@code
-   * // This snippet has been automatically generated and should be regarded as a code template only.
-   * // It will require modifications to work:
-   * // - It may require correct/in-range values for request initialization.
-   * // - It may require specifying regional endpoints when creating the service client as shown in
-   * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
-   * 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);
-   * }
-   * }
- * - * @param request The request object containing all of the parameters for the API call. - * @throws com.google.api.gax.rpc.ApiException if the remote call fails - */ - public final Policy setIamPolicy(SetIamPolicyRequest request) { - return setIamPolicyCallable().call(request); - } - - // AUTO-GENERATED DOCUMENTATION AND METHOD. - /** - * Sets the access control policy on the specified resource. Replaces any existing policy. - * - *

Sample code: - * - *

{@code
-   * // This snippet has been automatically generated and should be regarded as a code template only.
-   * // It will require modifications to work:
-   * // - It may require correct/in-range values for request initialization.
-   * // - It may require specifying regional endpoints when creating the service client as shown in
-   * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
-   * 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();
-   * }
-   * }
- */ - public final UnaryCallable setIamPolicyCallable() { - return stub.setIamPolicyCallable(); - } - - // AUTO-GENERATED DOCUMENTATION AND METHOD. - /** - * Gets the access control policy for a resource. Returns an empty policy if the resource exists - * and does not have a policy set. - * - *

Sample code: - * - *

{@code
-   * // This snippet has been automatically generated and should be regarded as a code template only.
-   * // It will require modifications to work:
-   * // - It may require correct/in-range values for request initialization.
-   * // - It may require specifying regional endpoints when creating the service client as shown in
-   * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
-   * try (DeviceManagerClient deviceManagerClient = DeviceManagerClient.create()) {
-   *   ResourceName resource = RegistryName.of("[PROJECT]", "[LOCATION]", "[REGISTRY]");
-   *   Policy response = deviceManagerClient.getIamPolicy(resource);
-   * }
-   * }
- * - * @param resource REQUIRED: The resource for which the policy is being requested. See the - * operation documentation for the appropriate value for this field. - * @throws com.google.api.gax.rpc.ApiException if the remote call fails - */ - public final Policy getIamPolicy(ResourceName resource) { - GetIamPolicyRequest request = - GetIamPolicyRequest.newBuilder() - .setResource(resource == null ? null : resource.toString()) - .build(); - return getIamPolicy(request); - } - - // AUTO-GENERATED DOCUMENTATION AND METHOD. - /** - * Gets the access control policy for a resource. Returns an empty policy if the resource exists - * and does not have a policy set. - * - *

Sample code: - * - *

{@code
-   * // This snippet has been automatically generated and should be regarded as a code template only.
-   * // It will require modifications to work:
-   * // - It may require correct/in-range values for request initialization.
-   * // - It may require specifying regional endpoints when creating the service client as shown in
-   * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
-   * try (DeviceManagerClient deviceManagerClient = DeviceManagerClient.create()) {
-   *   String resource =
-   *       DeviceName.of("[PROJECT]", "[LOCATION]", "[REGISTRY]", "[DEVICE]").toString();
-   *   Policy response = deviceManagerClient.getIamPolicy(resource);
-   * }
-   * }
- * - * @param resource REQUIRED: The resource for which the policy is being requested. See the - * operation documentation for the appropriate value for this field. - * @throws com.google.api.gax.rpc.ApiException if the remote call fails - */ - public final Policy getIamPolicy(String resource) { - GetIamPolicyRequest request = GetIamPolicyRequest.newBuilder().setResource(resource).build(); - return getIamPolicy(request); - } - - // AUTO-GENERATED DOCUMENTATION AND METHOD. - /** - * Gets the access control policy for a resource. Returns an empty policy if the resource exists - * and does not have a policy set. - * - *

Sample code: - * - *

{@code
-   * // This snippet has been automatically generated and should be regarded as a code template only.
-   * // It will require modifications to work:
-   * // - It may require correct/in-range values for request initialization.
-   * // - It may require specifying regional endpoints when creating the service client as shown in
-   * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
-   * 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);
-   * }
-   * }
- * - * @param request The request object containing all of the parameters for the API call. - * @throws com.google.api.gax.rpc.ApiException if the remote call fails - */ - public final Policy getIamPolicy(GetIamPolicyRequest request) { - return getIamPolicyCallable().call(request); - } - - // AUTO-GENERATED DOCUMENTATION AND METHOD. - /** - * Gets the access control policy for a resource. Returns an empty policy if the resource exists - * and does not have a policy set. - * - *

Sample code: - * - *

{@code
-   * // This snippet has been automatically generated and should be regarded as a code template only.
-   * // It will require modifications to work:
-   * // - It may require correct/in-range values for request initialization.
-   * // - It may require specifying regional endpoints when creating the service client as shown in
-   * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
-   * 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();
-   * }
-   * }
- */ - public final UnaryCallable getIamPolicyCallable() { - return stub.getIamPolicyCallable(); - } - - // AUTO-GENERATED DOCUMENTATION AND METHOD. - /** - * Returns permissions that a caller has on the specified resource. If the resource does not - * exist, this will return an empty set of permissions, not a NOT_FOUND error. - * - *

Sample code: - * - *

{@code
-   * // This snippet has been automatically generated and should be regarded as a code template only.
-   * // It will require modifications to work:
-   * // - It may require correct/in-range values for request initialization.
-   * // - It may require specifying regional endpoints when creating the service client as shown in
-   * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
-   * try (DeviceManagerClient deviceManagerClient = DeviceManagerClient.create()) {
-   *   ResourceName resource = RegistryName.of("[PROJECT]", "[LOCATION]", "[REGISTRY]");
-   *   List permissions = new ArrayList<>();
-   *   TestIamPermissionsResponse response =
-   *       deviceManagerClient.testIamPermissions(resource, permissions);
-   * }
-   * }
- * - * @param resource REQUIRED: The resource for which the policy detail is being requested. See the - * operation documentation for the appropriate value for this field. - * @param permissions The set of permissions to check for the `resource`. Permissions with - * wildcards (such as '*' or 'storage.*') are not allowed. For more information see - * [IAM Overview](https://cloud.google.com/iam/docs/overview#permissions). - * @throws com.google.api.gax.rpc.ApiException if the remote call fails - */ - public final TestIamPermissionsResponse testIamPermissions( - ResourceName resource, List permissions) { - TestIamPermissionsRequest request = - TestIamPermissionsRequest.newBuilder() - .setResource(resource == null ? null : resource.toString()) - .addAllPermissions(permissions) - .build(); - return testIamPermissions(request); - } - - // AUTO-GENERATED DOCUMENTATION AND METHOD. - /** - * Returns permissions that a caller has on the specified resource. If the resource does not - * exist, this will return an empty set of permissions, not a NOT_FOUND error. - * - *

Sample code: - * - *

{@code
-   * // This snippet has been automatically generated and should be regarded as a code template only.
-   * // It will require modifications to work:
-   * // - It may require correct/in-range values for request initialization.
-   * // - It may require specifying regional endpoints when creating the service client as shown in
-   * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
-   * try (DeviceManagerClient deviceManagerClient = DeviceManagerClient.create()) {
-   *   String resource =
-   *       DeviceName.of("[PROJECT]", "[LOCATION]", "[REGISTRY]", "[DEVICE]").toString();
-   *   List permissions = new ArrayList<>();
-   *   TestIamPermissionsResponse response =
-   *       deviceManagerClient.testIamPermissions(resource, permissions);
-   * }
-   * }
- * - * @param resource REQUIRED: The resource for which the policy detail is being requested. See the - * operation documentation for the appropriate value for this field. - * @param permissions The set of permissions to check for the `resource`. Permissions with - * wildcards (such as '*' or 'storage.*') are not allowed. For more information see - * [IAM Overview](https://cloud.google.com/iam/docs/overview#permissions). - * @throws com.google.api.gax.rpc.ApiException if the remote call fails - */ - public final TestIamPermissionsResponse testIamPermissions( - String resource, List permissions) { - TestIamPermissionsRequest request = - TestIamPermissionsRequest.newBuilder() - .setResource(resource) - .addAllPermissions(permissions) - .build(); - return testIamPermissions(request); - } - - // AUTO-GENERATED DOCUMENTATION AND METHOD. - /** - * Returns permissions that a caller has on the specified resource. If the resource does not - * exist, this will return an empty set of permissions, not a NOT_FOUND error. - * - *

Sample code: - * - *

{@code
-   * // This snippet has been automatically generated and should be regarded as a code template only.
-   * // It will require modifications to work:
-   * // - It may require correct/in-range values for request initialization.
-   * // - It may require specifying regional endpoints when creating the service client as shown in
-   * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
-   * 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);
-   * }
-   * }
- * - * @param request The request object containing all of the parameters for the API call. - * @throws com.google.api.gax.rpc.ApiException if the remote call fails - */ - public final TestIamPermissionsResponse testIamPermissions(TestIamPermissionsRequest request) { - return testIamPermissionsCallable().call(request); - } - - // AUTO-GENERATED DOCUMENTATION AND METHOD. - /** - * Returns permissions that a caller has on the specified resource. If the resource does not - * exist, this will return an empty set of permissions, not a NOT_FOUND error. - * - *

Sample code: - * - *

{@code
-   * // This snippet has been automatically generated and should be regarded as a code template only.
-   * // It will require modifications to work:
-   * // - It may require correct/in-range values for request initialization.
-   * // - It may require specifying regional endpoints when creating the service client as shown in
-   * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
-   * 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();
-   * }
-   * }
- */ - public final UnaryCallable - testIamPermissionsCallable() { - return stub.testIamPermissionsCallable(); - } - - // AUTO-GENERATED DOCUMENTATION AND METHOD. - /** - * Sends a command to the specified device. In order for a device to be able to receive commands, - * it must: 1) be connected to Cloud IoT Core using the MQTT protocol, and 2) be subscribed to the - * group of MQTT topics specified by /devices/{device-id}/commands/#. This subscription will - * receive commands at the top-level topic /devices/{device-id}/commands as well as commands for - * subfolders, like /devices/{device-id}/commands/subfolder. Note that subscribing to specific - * subfolders is not supported. If the command could not be delivered to the device, this method - * will return an error; in particular, if the device is not subscribed, this method will return - * FAILED_PRECONDITION. Otherwise, this method will return OK. If the subscription is QoS 1, at - * least once delivery will be guaranteed; for QoS 0, no acknowledgment will be expected from the - * device. - * - *

Sample code: - * - *

{@code
-   * // This snippet has been automatically generated and should be regarded as a code template only.
-   * // It will require modifications to work:
-   * // - It may require correct/in-range values for request initialization.
-   * // - It may require specifying regional endpoints when creating the service client as shown in
-   * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
-   * try (DeviceManagerClient deviceManagerClient = DeviceManagerClient.create()) {
-   *   DeviceName name = DeviceName.of("[PROJECT]", "[LOCATION]", "[REGISTRY]", "[DEVICE]");
-   *   ByteString binaryData = ByteString.EMPTY;
-   *   SendCommandToDeviceResponse response =
-   *       deviceManagerClient.sendCommandToDevice(name, binaryData);
-   * }
-   * }
- * - * @param name Required. The name of the device. For example, - * `projects/p0/locations/us-central1/registries/registry0/devices/device0` or - * `projects/p0/locations/us-central1/registries/registry0/devices/{num_id}`. - * @param binaryData Required. The command data to send to the device. - * @throws com.google.api.gax.rpc.ApiException if the remote call fails - */ - public final SendCommandToDeviceResponse sendCommandToDevice( - DeviceName name, ByteString binaryData) { - SendCommandToDeviceRequest request = - SendCommandToDeviceRequest.newBuilder() - .setName(name == null ? null : name.toString()) - .setBinaryData(binaryData) - .build(); - return sendCommandToDevice(request); - } - - // AUTO-GENERATED DOCUMENTATION AND METHOD. - /** - * Sends a command to the specified device. In order for a device to be able to receive commands, - * it must: 1) be connected to Cloud IoT Core using the MQTT protocol, and 2) be subscribed to the - * group of MQTT topics specified by /devices/{device-id}/commands/#. This subscription will - * receive commands at the top-level topic /devices/{device-id}/commands as well as commands for - * subfolders, like /devices/{device-id}/commands/subfolder. Note that subscribing to specific - * subfolders is not supported. If the command could not be delivered to the device, this method - * will return an error; in particular, if the device is not subscribed, this method will return - * FAILED_PRECONDITION. Otherwise, this method will return OK. If the subscription is QoS 1, at - * least once delivery will be guaranteed; for QoS 0, no acknowledgment will be expected from the - * device. - * - *

Sample code: - * - *

{@code
-   * // This snippet has been automatically generated and should be regarded as a code template only.
-   * // It will require modifications to work:
-   * // - It may require correct/in-range values for request initialization.
-   * // - It may require specifying regional endpoints when creating the service client as shown in
-   * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
-   * try (DeviceManagerClient deviceManagerClient = DeviceManagerClient.create()) {
-   *   String name = DeviceName.of("[PROJECT]", "[LOCATION]", "[REGISTRY]", "[DEVICE]").toString();
-   *   ByteString binaryData = ByteString.EMPTY;
-   *   SendCommandToDeviceResponse response =
-   *       deviceManagerClient.sendCommandToDevice(name, binaryData);
-   * }
-   * }
- * - * @param name Required. The name of the device. For example, - * `projects/p0/locations/us-central1/registries/registry0/devices/device0` or - * `projects/p0/locations/us-central1/registries/registry0/devices/{num_id}`. - * @param binaryData Required. The command data to send to the device. - * @throws com.google.api.gax.rpc.ApiException if the remote call fails - */ - public final SendCommandToDeviceResponse sendCommandToDevice(String name, ByteString binaryData) { - SendCommandToDeviceRequest request = - SendCommandToDeviceRequest.newBuilder().setName(name).setBinaryData(binaryData).build(); - return sendCommandToDevice(request); - } - - // AUTO-GENERATED DOCUMENTATION AND METHOD. - /** - * Sends a command to the specified device. In order for a device to be able to receive commands, - * it must: 1) be connected to Cloud IoT Core using the MQTT protocol, and 2) be subscribed to the - * group of MQTT topics specified by /devices/{device-id}/commands/#. This subscription will - * receive commands at the top-level topic /devices/{device-id}/commands as well as commands for - * subfolders, like /devices/{device-id}/commands/subfolder. Note that subscribing to specific - * subfolders is not supported. If the command could not be delivered to the device, this method - * will return an error; in particular, if the device is not subscribed, this method will return - * FAILED_PRECONDITION. Otherwise, this method will return OK. If the subscription is QoS 1, at - * least once delivery will be guaranteed; for QoS 0, no acknowledgment will be expected from the - * device. - * - *

Sample code: - * - *

{@code
-   * // This snippet has been automatically generated and should be regarded as a code template only.
-   * // It will require modifications to work:
-   * // - It may require correct/in-range values for request initialization.
-   * // - It may require specifying regional endpoints when creating the service client as shown in
-   * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
-   * 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);
-   * }
-   * }
- * - * @param name Required. The name of the device. For example, - * `projects/p0/locations/us-central1/registries/registry0/devices/device0` or - * `projects/p0/locations/us-central1/registries/registry0/devices/{num_id}`. - * @param binaryData Required. The command data to send to the device. - * @param subfolder Optional subfolder for the command. If empty, the command will be delivered to - * the /devices/{device-id}/commands topic, otherwise it will be delivered to the - * /devices/{device-id}/commands/{subfolder} topic. Multi-level subfolders are allowed. This - * field must not have more than 256 characters, and must not contain any MQTT wildcards ("+" - * or "#") or null characters. - * @throws com.google.api.gax.rpc.ApiException if the remote call fails - */ - public final SendCommandToDeviceResponse sendCommandToDevice( - DeviceName name, ByteString binaryData, String subfolder) { - SendCommandToDeviceRequest request = - SendCommandToDeviceRequest.newBuilder() - .setName(name == null ? null : name.toString()) - .setBinaryData(binaryData) - .setSubfolder(subfolder) - .build(); - return sendCommandToDevice(request); - } - - // AUTO-GENERATED DOCUMENTATION AND METHOD. - /** - * Sends a command to the specified device. In order for a device to be able to receive commands, - * it must: 1) be connected to Cloud IoT Core using the MQTT protocol, and 2) be subscribed to the - * group of MQTT topics specified by /devices/{device-id}/commands/#. This subscription will - * receive commands at the top-level topic /devices/{device-id}/commands as well as commands for - * subfolders, like /devices/{device-id}/commands/subfolder. Note that subscribing to specific - * subfolders is not supported. If the command could not be delivered to the device, this method - * will return an error; in particular, if the device is not subscribed, this method will return - * FAILED_PRECONDITION. Otherwise, this method will return OK. If the subscription is QoS 1, at - * least once delivery will be guaranteed; for QoS 0, no acknowledgment will be expected from the - * device. - * - *

Sample code: - * - *

{@code
-   * // This snippet has been automatically generated and should be regarded as a code template only.
-   * // It will require modifications to work:
-   * // - It may require correct/in-range values for request initialization.
-   * // - It may require specifying regional endpoints when creating the service client as shown in
-   * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
-   * 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);
-   * }
-   * }
- * - * @param name Required. The name of the device. For example, - * `projects/p0/locations/us-central1/registries/registry0/devices/device0` or - * `projects/p0/locations/us-central1/registries/registry0/devices/{num_id}`. - * @param binaryData Required. The command data to send to the device. - * @param subfolder Optional subfolder for the command. If empty, the command will be delivered to - * the /devices/{device-id}/commands topic, otherwise it will be delivered to the - * /devices/{device-id}/commands/{subfolder} topic. Multi-level subfolders are allowed. This - * field must not have more than 256 characters, and must not contain any MQTT wildcards ("+" - * or "#") or null characters. - * @throws com.google.api.gax.rpc.ApiException if the remote call fails - */ - public final SendCommandToDeviceResponse sendCommandToDevice( - String name, ByteString binaryData, String subfolder) { - SendCommandToDeviceRequest request = - SendCommandToDeviceRequest.newBuilder() - .setName(name) - .setBinaryData(binaryData) - .setSubfolder(subfolder) - .build(); - return sendCommandToDevice(request); - } - - // AUTO-GENERATED DOCUMENTATION AND METHOD. - /** - * Sends a command to the specified device. In order for a device to be able to receive commands, - * it must: 1) be connected to Cloud IoT Core using the MQTT protocol, and 2) be subscribed to the - * group of MQTT topics specified by /devices/{device-id}/commands/#. This subscription will - * receive commands at the top-level topic /devices/{device-id}/commands as well as commands for - * subfolders, like /devices/{device-id}/commands/subfolder. Note that subscribing to specific - * subfolders is not supported. If the command could not be delivered to the device, this method - * will return an error; in particular, if the device is not subscribed, this method will return - * FAILED_PRECONDITION. Otherwise, this method will return OK. If the subscription is QoS 1, at - * least once delivery will be guaranteed; for QoS 0, no acknowledgment will be expected from the - * device. - * - *

Sample code: - * - *

{@code
-   * // This snippet has been automatically generated and should be regarded as a code template only.
-   * // It will require modifications to work:
-   * // - It may require correct/in-range values for request initialization.
-   * // - It may require specifying regional endpoints when creating the service client as shown in
-   * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
-   * 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);
-   * }
-   * }
- * - * @param request The request object containing all of the parameters for the API call. - * @throws com.google.api.gax.rpc.ApiException if the remote call fails - */ - public final SendCommandToDeviceResponse sendCommandToDevice(SendCommandToDeviceRequest request) { - return sendCommandToDeviceCallable().call(request); - } - - // AUTO-GENERATED DOCUMENTATION AND METHOD. - /** - * Sends a command to the specified device. In order for a device to be able to receive commands, - * it must: 1) be connected to Cloud IoT Core using the MQTT protocol, and 2) be subscribed to the - * group of MQTT topics specified by /devices/{device-id}/commands/#. This subscription will - * receive commands at the top-level topic /devices/{device-id}/commands as well as commands for - * subfolders, like /devices/{device-id}/commands/subfolder. Note that subscribing to specific - * subfolders is not supported. If the command could not be delivered to the device, this method - * will return an error; in particular, if the device is not subscribed, this method will return - * FAILED_PRECONDITION. Otherwise, this method will return OK. If the subscription is QoS 1, at - * least once delivery will be guaranteed; for QoS 0, no acknowledgment will be expected from the - * device. - * - *

Sample code: - * - *

{@code
-   * // This snippet has been automatically generated and should be regarded as a code template only.
-   * // It will require modifications to work:
-   * // - It may require correct/in-range values for request initialization.
-   * // - It may require specifying regional endpoints when creating the service client as shown in
-   * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
-   * 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();
-   * }
-   * }
- */ - public final UnaryCallable - sendCommandToDeviceCallable() { - return stub.sendCommandToDeviceCallable(); - } - - // AUTO-GENERATED DOCUMENTATION AND METHOD. - /** - * Associates the device with the gateway. - * - *

Sample code: - * - *

{@code
-   * // This snippet has been automatically generated and should be regarded as a code template only.
-   * // It will require modifications to work:
-   * // - It may require correct/in-range values for request initialization.
-   * // - It may require specifying regional endpoints when creating the service client as shown in
-   * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
-   * 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);
-   * }
-   * }
- * - * @param parent Required. The name of the registry. For example, - * `projects/example-project/locations/us-central1/registries/my-registry`. - * @param gatewayId Required. The value of `gateway_id` can be either the device numeric ID or the - * user-defined device identifier. - * @param deviceId Required. The device to associate with the specified gateway. The value of - * `device_id` can be either the device numeric ID or the user-defined device identifier. - * @throws com.google.api.gax.rpc.ApiException if the remote call fails - */ - public final BindDeviceToGatewayResponse bindDeviceToGateway( - RegistryName parent, String gatewayId, String deviceId) { - BindDeviceToGatewayRequest request = - BindDeviceToGatewayRequest.newBuilder() - .setParent(parent == null ? null : parent.toString()) - .setGatewayId(gatewayId) - .setDeviceId(deviceId) - .build(); - return bindDeviceToGateway(request); - } - - // AUTO-GENERATED DOCUMENTATION AND METHOD. - /** - * Associates the device with the gateway. - * - *

Sample code: - * - *

{@code
-   * // This snippet has been automatically generated and should be regarded as a code template only.
-   * // It will require modifications to work:
-   * // - It may require correct/in-range values for request initialization.
-   * // - It may require specifying regional endpoints when creating the service client as shown in
-   * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
-   * 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);
-   * }
-   * }
- * - * @param parent Required. The name of the registry. For example, - * `projects/example-project/locations/us-central1/registries/my-registry`. - * @param gatewayId Required. The value of `gateway_id` can be either the device numeric ID or the - * user-defined device identifier. - * @param deviceId Required. The device to associate with the specified gateway. The value of - * `device_id` can be either the device numeric ID or the user-defined device identifier. - * @throws com.google.api.gax.rpc.ApiException if the remote call fails - */ - public final BindDeviceToGatewayResponse bindDeviceToGateway( - String parent, String gatewayId, String deviceId) { - BindDeviceToGatewayRequest request = - BindDeviceToGatewayRequest.newBuilder() - .setParent(parent) - .setGatewayId(gatewayId) - .setDeviceId(deviceId) - .build(); - return bindDeviceToGateway(request); - } - - // AUTO-GENERATED DOCUMENTATION AND METHOD. - /** - * Associates the device with the gateway. - * - *

Sample code: - * - *

{@code
-   * // This snippet has been automatically generated and should be regarded as a code template only.
-   * // It will require modifications to work:
-   * // - It may require correct/in-range values for request initialization.
-   * // - It may require specifying regional endpoints when creating the service client as shown in
-   * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
-   * 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);
-   * }
-   * }
- * - * @param request The request object containing all of the parameters for the API call. - * @throws com.google.api.gax.rpc.ApiException if the remote call fails - */ - public final BindDeviceToGatewayResponse bindDeviceToGateway(BindDeviceToGatewayRequest request) { - return bindDeviceToGatewayCallable().call(request); - } - - // AUTO-GENERATED DOCUMENTATION AND METHOD. - /** - * Associates the device with the gateway. - * - *

Sample code: - * - *

{@code
-   * // This snippet has been automatically generated and should be regarded as a code template only.
-   * // It will require modifications to work:
-   * // - It may require correct/in-range values for request initialization.
-   * // - It may require specifying regional endpoints when creating the service client as shown in
-   * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
-   * 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();
-   * }
-   * }
- */ - public final UnaryCallable - bindDeviceToGatewayCallable() { - return stub.bindDeviceToGatewayCallable(); - } - - // AUTO-GENERATED DOCUMENTATION AND METHOD. - /** - * Deletes the association between the device and the gateway. - * - *

Sample code: - * - *

{@code
-   * // This snippet has been automatically generated and should be regarded as a code template only.
-   * // It will require modifications to work:
-   * // - It may require correct/in-range values for request initialization.
-   * // - It may require specifying regional endpoints when creating the service client as shown in
-   * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
-   * 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);
-   * }
-   * }
- * - * @param parent Required. The name of the registry. For example, - * `projects/example-project/locations/us-central1/registries/my-registry`. - * @param gatewayId Required. The value of `gateway_id` can be either the device numeric ID or the - * user-defined device identifier. - * @param deviceId Required. The device to disassociate from the specified gateway. The value of - * `device_id` can be either the device numeric ID or the user-defined device identifier. - * @throws com.google.api.gax.rpc.ApiException if the remote call fails - */ - public final UnbindDeviceFromGatewayResponse unbindDeviceFromGateway( - RegistryName parent, String gatewayId, String deviceId) { - UnbindDeviceFromGatewayRequest request = - UnbindDeviceFromGatewayRequest.newBuilder() - .setParent(parent == null ? null : parent.toString()) - .setGatewayId(gatewayId) - .setDeviceId(deviceId) - .build(); - return unbindDeviceFromGateway(request); - } - - // AUTO-GENERATED DOCUMENTATION AND METHOD. - /** - * Deletes the association between the device and the gateway. - * - *

Sample code: - * - *

{@code
-   * // This snippet has been automatically generated and should be regarded as a code template only.
-   * // It will require modifications to work:
-   * // - It may require correct/in-range values for request initialization.
-   * // - It may require specifying regional endpoints when creating the service client as shown in
-   * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
-   * 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);
-   * }
-   * }
- * - * @param parent Required. The name of the registry. For example, - * `projects/example-project/locations/us-central1/registries/my-registry`. - * @param gatewayId Required. The value of `gateway_id` can be either the device numeric ID or the - * user-defined device identifier. - * @param deviceId Required. The device to disassociate from the specified gateway. The value of - * `device_id` can be either the device numeric ID or the user-defined device identifier. - * @throws com.google.api.gax.rpc.ApiException if the remote call fails - */ - public final UnbindDeviceFromGatewayResponse unbindDeviceFromGateway( - String parent, String gatewayId, String deviceId) { - UnbindDeviceFromGatewayRequest request = - UnbindDeviceFromGatewayRequest.newBuilder() - .setParent(parent) - .setGatewayId(gatewayId) - .setDeviceId(deviceId) - .build(); - return unbindDeviceFromGateway(request); - } - - // AUTO-GENERATED DOCUMENTATION AND METHOD. - /** - * Deletes the association between the device and the gateway. - * - *

Sample code: - * - *

{@code
-   * // This snippet has been automatically generated and should be regarded as a code template only.
-   * // It will require modifications to work:
-   * // - It may require correct/in-range values for request initialization.
-   * // - It may require specifying regional endpoints when creating the service client as shown in
-   * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
-   * 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);
-   * }
-   * }
- * - * @param request The request object containing all of the parameters for the API call. - * @throws com.google.api.gax.rpc.ApiException if the remote call fails - */ - public final UnbindDeviceFromGatewayResponse unbindDeviceFromGateway( - UnbindDeviceFromGatewayRequest request) { - return unbindDeviceFromGatewayCallable().call(request); - } - - // AUTO-GENERATED DOCUMENTATION AND METHOD. - /** - * Deletes the association between the device and the gateway. - * - *

Sample code: - * - *

{@code
-   * // This snippet has been automatically generated and should be regarded as a code template only.
-   * // It will require modifications to work:
-   * // - It may require correct/in-range values for request initialization.
-   * // - It may require specifying regional endpoints when creating the service client as shown in
-   * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
-   * 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();
-   * }
-   * }
- */ - public final UnaryCallable - unbindDeviceFromGatewayCallable() { - return stub.unbindDeviceFromGatewayCallable(); - } - - @Override - public final void close() { - stub.close(); - } - - @Override - public void shutdown() { - stub.shutdown(); - } - - @Override - public boolean isShutdown() { - return stub.isShutdown(); - } - - @Override - public boolean isTerminated() { - return stub.isTerminated(); - } - - @Override - public void shutdownNow() { - stub.shutdownNow(); - } - - @Override - public boolean awaitTermination(long duration, TimeUnit unit) throws InterruptedException { - return stub.awaitTermination(duration, unit); - } - - public static class ListDeviceRegistriesPagedResponse - extends AbstractPagedListResponse< - ListDeviceRegistriesRequest, - ListDeviceRegistriesResponse, - DeviceRegistry, - ListDeviceRegistriesPage, - ListDeviceRegistriesFixedSizeCollection> { - - public static ApiFuture createAsync( - PageContext - context, - ApiFuture futureResponse) { - ApiFuture futurePage = - ListDeviceRegistriesPage.createEmptyPage().createPageAsync(context, futureResponse); - return ApiFutures.transform( - futurePage, - input -> new ListDeviceRegistriesPagedResponse(input), - MoreExecutors.directExecutor()); - } - - private ListDeviceRegistriesPagedResponse(ListDeviceRegistriesPage page) { - super(page, ListDeviceRegistriesFixedSizeCollection.createEmptyCollection()); - } - } - - public static class ListDeviceRegistriesPage - extends AbstractPage< - ListDeviceRegistriesRequest, - ListDeviceRegistriesResponse, - DeviceRegistry, - ListDeviceRegistriesPage> { - - private ListDeviceRegistriesPage( - PageContext - context, - ListDeviceRegistriesResponse response) { - super(context, response); - } - - private static ListDeviceRegistriesPage createEmptyPage() { - return new ListDeviceRegistriesPage(null, null); - } - - @Override - protected ListDeviceRegistriesPage createPage( - PageContext - context, - ListDeviceRegistriesResponse response) { - return new ListDeviceRegistriesPage(context, response); - } - - @Override - public ApiFuture createPageAsync( - PageContext - context, - ApiFuture futureResponse) { - return super.createPageAsync(context, futureResponse); - } - } - - public static class ListDeviceRegistriesFixedSizeCollection - extends AbstractFixedSizeCollection< - ListDeviceRegistriesRequest, - ListDeviceRegistriesResponse, - DeviceRegistry, - ListDeviceRegistriesPage, - ListDeviceRegistriesFixedSizeCollection> { - - private ListDeviceRegistriesFixedSizeCollection( - List pages, int collectionSize) { - super(pages, collectionSize); - } - - private static ListDeviceRegistriesFixedSizeCollection createEmptyCollection() { - return new ListDeviceRegistriesFixedSizeCollection(null, 0); - } - - @Override - protected ListDeviceRegistriesFixedSizeCollection createCollection( - List pages, int collectionSize) { - return new ListDeviceRegistriesFixedSizeCollection(pages, collectionSize); - } - } - - public static class ListDevicesPagedResponse - extends AbstractPagedListResponse< - ListDevicesRequest, - ListDevicesResponse, - Device, - ListDevicesPage, - ListDevicesFixedSizeCollection> { - - public static ApiFuture createAsync( - PageContext context, - ApiFuture futureResponse) { - ApiFuture futurePage = - ListDevicesPage.createEmptyPage().createPageAsync(context, futureResponse); - return ApiFutures.transform( - futurePage, input -> new ListDevicesPagedResponse(input), MoreExecutors.directExecutor()); - } - - private ListDevicesPagedResponse(ListDevicesPage page) { - super(page, ListDevicesFixedSizeCollection.createEmptyCollection()); - } - } - - public static class ListDevicesPage - extends AbstractPage { - - private ListDevicesPage( - PageContext context, - ListDevicesResponse response) { - super(context, response); - } - - private static ListDevicesPage createEmptyPage() { - return new ListDevicesPage(null, null); - } - - @Override - protected ListDevicesPage createPage( - PageContext context, - ListDevicesResponse response) { - return new ListDevicesPage(context, response); - } - - @Override - public ApiFuture createPageAsync( - PageContext context, - ApiFuture futureResponse) { - return super.createPageAsync(context, futureResponse); - } - } - - public static class ListDevicesFixedSizeCollection - extends AbstractFixedSizeCollection< - ListDevicesRequest, - ListDevicesResponse, - Device, - ListDevicesPage, - ListDevicesFixedSizeCollection> { - - private ListDevicesFixedSizeCollection(List pages, int collectionSize) { - super(pages, collectionSize); - } - - private static ListDevicesFixedSizeCollection createEmptyCollection() { - return new ListDevicesFixedSizeCollection(null, 0); - } - - @Override - protected ListDevicesFixedSizeCollection createCollection( - List pages, int collectionSize) { - return new ListDevicesFixedSizeCollection(pages, collectionSize); - } - } -} diff --git a/google-cloud-iot/src/main/java/com/google/cloud/iot/v1/DeviceManagerSettings.java b/google-cloud-iot/src/main/java/com/google/cloud/iot/v1/DeviceManagerSettings.java deleted file mode 100644 index 3c64e9cd..00000000 --- a/google-cloud-iot/src/main/java/com/google/cloud/iot/v1/DeviceManagerSettings.java +++ /dev/null @@ -1,427 +0,0 @@ -/* - * 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.core.ApiFunction; -import com.google.api.core.BetaApi; -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; -import com.google.api.gax.rpc.PagedCallSettings; -import com.google.api.gax.rpc.TransportChannelProvider; -import com.google.api.gax.rpc.UnaryCallSettings; -import com.google.cloud.iot.v1.stub.DeviceManagerStubSettings; -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 java.io.IOException; -import java.util.List; -import javax.annotation.Generated; - -// AUTO-GENERATED DOCUMENTATION AND CLASS. -/** - * Settings class to configure an instance of {@link DeviceManagerClient}. - * - *

The default instance has everything set to sensible defaults: - * - *

    - *
  • The default service address (cloudiot.googleapis.com) and default port (443) are used. - *
  • Credentials are acquired automatically through Application Default Credentials. - *
  • Retries are configured for idempotent methods but not for non-idempotent methods. - *
- * - *

The builder of this class is recursive, so contained classes are themselves builders. When - * build() is called, the tree of builders is called to create the complete settings object. - * - *

For example, to set the total timeout of createDeviceRegistry to 30 seconds: - * - *

{@code
- * // This snippet has been automatically generated and should be regarded as a code template only.
- * // It will require modifications to work:
- * // - It may require correct/in-range values for request initialization.
- * // - It may require specifying regional endpoints when creating the service client as shown in
- * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
- * DeviceManagerSettings.Builder deviceManagerSettingsBuilder = DeviceManagerSettings.newBuilder();
- * deviceManagerSettingsBuilder
- *     .createDeviceRegistrySettings()
- *     .setRetrySettings(
- *         deviceManagerSettingsBuilder
- *             .createDeviceRegistrySettings()
- *             .getRetrySettings()
- *             .toBuilder()
- *             .setTotalTimeout(Duration.ofSeconds(30))
- *             .build());
- * DeviceManagerSettings deviceManagerSettings = deviceManagerSettingsBuilder.build();
- * }
- */ -@Generated("by gapic-generator-java") -public class DeviceManagerSettings extends ClientSettings { - - /** Returns the object with the settings used for calls to createDeviceRegistry. */ - public UnaryCallSettings - createDeviceRegistrySettings() { - return ((DeviceManagerStubSettings) getStubSettings()).createDeviceRegistrySettings(); - } - - /** Returns the object with the settings used for calls to getDeviceRegistry. */ - public UnaryCallSettings getDeviceRegistrySettings() { - return ((DeviceManagerStubSettings) getStubSettings()).getDeviceRegistrySettings(); - } - - /** Returns the object with the settings used for calls to updateDeviceRegistry. */ - public UnaryCallSettings - updateDeviceRegistrySettings() { - return ((DeviceManagerStubSettings) getStubSettings()).updateDeviceRegistrySettings(); - } - - /** Returns the object with the settings used for calls to deleteDeviceRegistry. */ - public UnaryCallSettings deleteDeviceRegistrySettings() { - return ((DeviceManagerStubSettings) getStubSettings()).deleteDeviceRegistrySettings(); - } - - /** Returns the object with the settings used for calls to listDeviceRegistries. */ - public PagedCallSettings< - ListDeviceRegistriesRequest, - ListDeviceRegistriesResponse, - ListDeviceRegistriesPagedResponse> - listDeviceRegistriesSettings() { - return ((DeviceManagerStubSettings) getStubSettings()).listDeviceRegistriesSettings(); - } - - /** Returns the object with the settings used for calls to createDevice. */ - public UnaryCallSettings createDeviceSettings() { - return ((DeviceManagerStubSettings) getStubSettings()).createDeviceSettings(); - } - - /** Returns the object with the settings used for calls to getDevice. */ - public UnaryCallSettings getDeviceSettings() { - return ((DeviceManagerStubSettings) getStubSettings()).getDeviceSettings(); - } - - /** Returns the object with the settings used for calls to updateDevice. */ - public UnaryCallSettings updateDeviceSettings() { - return ((DeviceManagerStubSettings) getStubSettings()).updateDeviceSettings(); - } - - /** Returns the object with the settings used for calls to deleteDevice. */ - public UnaryCallSettings deleteDeviceSettings() { - return ((DeviceManagerStubSettings) getStubSettings()).deleteDeviceSettings(); - } - - /** Returns the object with the settings used for calls to listDevices. */ - public PagedCallSettings - listDevicesSettings() { - return ((DeviceManagerStubSettings) getStubSettings()).listDevicesSettings(); - } - - /** Returns the object with the settings used for calls to modifyCloudToDeviceConfig. */ - public UnaryCallSettings - modifyCloudToDeviceConfigSettings() { - return ((DeviceManagerStubSettings) getStubSettings()).modifyCloudToDeviceConfigSettings(); - } - - /** Returns the object with the settings used for calls to listDeviceConfigVersions. */ - public UnaryCallSettings - listDeviceConfigVersionsSettings() { - return ((DeviceManagerStubSettings) getStubSettings()).listDeviceConfigVersionsSettings(); - } - - /** Returns the object with the settings used for calls to listDeviceStates. */ - public UnaryCallSettings - listDeviceStatesSettings() { - return ((DeviceManagerStubSettings) getStubSettings()).listDeviceStatesSettings(); - } - - /** Returns the object with the settings used for calls to setIamPolicy. */ - public UnaryCallSettings setIamPolicySettings() { - return ((DeviceManagerStubSettings) getStubSettings()).setIamPolicySettings(); - } - - /** Returns the object with the settings used for calls to getIamPolicy. */ - public UnaryCallSettings getIamPolicySettings() { - return ((DeviceManagerStubSettings) getStubSettings()).getIamPolicySettings(); - } - - /** Returns the object with the settings used for calls to testIamPermissions. */ - public UnaryCallSettings - testIamPermissionsSettings() { - return ((DeviceManagerStubSettings) getStubSettings()).testIamPermissionsSettings(); - } - - /** Returns the object with the settings used for calls to sendCommandToDevice. */ - public UnaryCallSettings - sendCommandToDeviceSettings() { - return ((DeviceManagerStubSettings) getStubSettings()).sendCommandToDeviceSettings(); - } - - /** Returns the object with the settings used for calls to bindDeviceToGateway. */ - public UnaryCallSettings - bindDeviceToGatewaySettings() { - return ((DeviceManagerStubSettings) getStubSettings()).bindDeviceToGatewaySettings(); - } - - /** Returns the object with the settings used for calls to unbindDeviceFromGateway. */ - public UnaryCallSettings - unbindDeviceFromGatewaySettings() { - return ((DeviceManagerStubSettings) getStubSettings()).unbindDeviceFromGatewaySettings(); - } - - public static final DeviceManagerSettings create(DeviceManagerStubSettings stub) - throws IOException { - return new DeviceManagerSettings.Builder(stub.toBuilder()).build(); - } - - /** Returns a builder for the default ExecutorProvider for this service. */ - public static InstantiatingExecutorProvider.Builder defaultExecutorProviderBuilder() { - return DeviceManagerStubSettings.defaultExecutorProviderBuilder(); - } - - /** Returns the default service endpoint. */ - public static String getDefaultEndpoint() { - return DeviceManagerStubSettings.getDefaultEndpoint(); - } - - /** Returns the default service scopes. */ - public static List getDefaultServiceScopes() { - return DeviceManagerStubSettings.getDefaultServiceScopes(); - } - - /** Returns a builder for the default credentials for this service. */ - public static GoogleCredentialsProvider.Builder defaultCredentialsProviderBuilder() { - return DeviceManagerStubSettings.defaultCredentialsProviderBuilder(); - } - - /** 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(); - } - - @BetaApi("The surface for customizing headers is not stable yet and may change in the future.") - public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuilder() { - return DeviceManagerStubSettings.defaultApiClientHeaderProviderBuilder(); - } - - /** 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); - } - - /** Returns a builder containing all the values of this settings class. */ - public Builder toBuilder() { - return new Builder(this); - } - - protected DeviceManagerSettings(Builder settingsBuilder) throws IOException { - super(settingsBuilder); - } - - /** Builder for DeviceManagerSettings. */ - public static class Builder extends ClientSettings.Builder { - - protected Builder() throws IOException { - this(((ClientContext) null)); - } - - protected Builder(ClientContext clientContext) { - super(DeviceManagerStubSettings.newBuilder(clientContext)); - } - - protected Builder(DeviceManagerSettings settings) { - super(settings.getStubSettings().toBuilder()); - } - - protected Builder(DeviceManagerStubSettings.Builder stubSettings) { - super(stubSettings); - } - - 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()); - } - - /** - * Applies the given settings updater function to all of the unary API methods in this service. - * - *

Note: This method does not support applying settings to streaming methods. - */ - public Builder applyToAllUnaryMethods( - ApiFunction, Void> settingsUpdater) { - super.applyToAllUnaryMethods( - getStubSettingsBuilder().unaryMethodSettingsBuilders(), settingsUpdater); - return this; - } - - /** Returns the builder for the settings used for calls to createDeviceRegistry. */ - public UnaryCallSettings.Builder - createDeviceRegistrySettings() { - return getStubSettingsBuilder().createDeviceRegistrySettings(); - } - - /** Returns the builder for the settings used for calls to getDeviceRegistry. */ - public UnaryCallSettings.Builder - getDeviceRegistrySettings() { - return getStubSettingsBuilder().getDeviceRegistrySettings(); - } - - /** Returns the builder for the settings used for calls to updateDeviceRegistry. */ - public UnaryCallSettings.Builder - updateDeviceRegistrySettings() { - return getStubSettingsBuilder().updateDeviceRegistrySettings(); - } - - /** Returns the builder for the settings used for calls to deleteDeviceRegistry. */ - public UnaryCallSettings.Builder - deleteDeviceRegistrySettings() { - return getStubSettingsBuilder().deleteDeviceRegistrySettings(); - } - - /** Returns the builder for the settings used for calls to listDeviceRegistries. */ - public PagedCallSettings.Builder< - ListDeviceRegistriesRequest, - ListDeviceRegistriesResponse, - ListDeviceRegistriesPagedResponse> - listDeviceRegistriesSettings() { - return getStubSettingsBuilder().listDeviceRegistriesSettings(); - } - - /** Returns the builder for the settings used for calls to createDevice. */ - public UnaryCallSettings.Builder createDeviceSettings() { - return getStubSettingsBuilder().createDeviceSettings(); - } - - /** Returns the builder for the settings used for calls to getDevice. */ - public UnaryCallSettings.Builder getDeviceSettings() { - return getStubSettingsBuilder().getDeviceSettings(); - } - - /** Returns the builder for the settings used for calls to updateDevice. */ - public UnaryCallSettings.Builder updateDeviceSettings() { - return getStubSettingsBuilder().updateDeviceSettings(); - } - - /** Returns the builder for the settings used for calls to deleteDevice. */ - public UnaryCallSettings.Builder deleteDeviceSettings() { - return getStubSettingsBuilder().deleteDeviceSettings(); - } - - /** Returns the builder for the settings used for calls to listDevices. */ - public PagedCallSettings.Builder< - ListDevicesRequest, ListDevicesResponse, ListDevicesPagedResponse> - listDevicesSettings() { - return getStubSettingsBuilder().listDevicesSettings(); - } - - /** Returns the builder for the settings used for calls to modifyCloudToDeviceConfig. */ - public UnaryCallSettings.Builder - modifyCloudToDeviceConfigSettings() { - return getStubSettingsBuilder().modifyCloudToDeviceConfigSettings(); - } - - /** Returns the builder for the settings used for calls to listDeviceConfigVersions. */ - public UnaryCallSettings.Builder< - ListDeviceConfigVersionsRequest, ListDeviceConfigVersionsResponse> - listDeviceConfigVersionsSettings() { - return getStubSettingsBuilder().listDeviceConfigVersionsSettings(); - } - - /** Returns the builder for the settings used for calls to listDeviceStates. */ - public UnaryCallSettings.Builder - listDeviceStatesSettings() { - return getStubSettingsBuilder().listDeviceStatesSettings(); - } - - /** Returns the builder for the settings used for calls to setIamPolicy. */ - public UnaryCallSettings.Builder setIamPolicySettings() { - return getStubSettingsBuilder().setIamPolicySettings(); - } - - /** Returns the builder for the settings used for calls to getIamPolicy. */ - public UnaryCallSettings.Builder getIamPolicySettings() { - return getStubSettingsBuilder().getIamPolicySettings(); - } - - /** Returns the builder for the settings used for calls to testIamPermissions. */ - public UnaryCallSettings.Builder - testIamPermissionsSettings() { - return getStubSettingsBuilder().testIamPermissionsSettings(); - } - - /** Returns the builder for the settings used for calls to sendCommandToDevice. */ - public UnaryCallSettings.Builder - sendCommandToDeviceSettings() { - return getStubSettingsBuilder().sendCommandToDeviceSettings(); - } - - /** Returns the builder for the settings used for calls to bindDeviceToGateway. */ - public UnaryCallSettings.Builder - bindDeviceToGatewaySettings() { - return getStubSettingsBuilder().bindDeviceToGatewaySettings(); - } - - /** Returns the builder for the settings used for calls to unbindDeviceFromGateway. */ - public UnaryCallSettings.Builder< - UnbindDeviceFromGatewayRequest, UnbindDeviceFromGatewayResponse> - unbindDeviceFromGatewaySettings() { - return getStubSettingsBuilder().unbindDeviceFromGatewaySettings(); - } - - @Override - public DeviceManagerSettings build() throws IOException { - return new DeviceManagerSettings(this); - } - } -} diff --git a/google-cloud-iot/src/main/java/com/google/cloud/iot/v1/gapic_metadata.json b/google-cloud-iot/src/main/java/com/google/cloud/iot/v1/gapic_metadata.json deleted file mode 100644 index 6b042a32..00000000 --- a/google-cloud-iot/src/main/java/com/google/cloud/iot/v1/gapic_metadata.json +++ /dev/null @@ -1,75 +0,0 @@ -{ - "schema": "1.0", - "comment": "This file maps proto services/RPCs to the corresponding library clients/methods", - "language": "java", - "protoPackage": "google.cloud.iot.v1", - "libraryPackage": "com.google.cloud.iot.v1", - "services": { - "DeviceManager": { - "clients": { - "grpc": { - "libraryClient": "DeviceManagerClient", - "rpcs": { - "BindDeviceToGateway": { - "methods": ["bindDeviceToGateway", "bindDeviceToGateway", "bindDeviceToGateway", "bindDeviceToGatewayCallable"] - }, - "CreateDevice": { - "methods": ["createDevice", "createDevice", "createDevice", "createDeviceCallable"] - }, - "CreateDeviceRegistry": { - "methods": ["createDeviceRegistry", "createDeviceRegistry", "createDeviceRegistry", "createDeviceRegistryCallable"] - }, - "DeleteDevice": { - "methods": ["deleteDevice", "deleteDevice", "deleteDevice", "deleteDeviceCallable"] - }, - "DeleteDeviceRegistry": { - "methods": ["deleteDeviceRegistry", "deleteDeviceRegistry", "deleteDeviceRegistry", "deleteDeviceRegistryCallable"] - }, - "GetDevice": { - "methods": ["getDevice", "getDevice", "getDevice", "getDeviceCallable"] - }, - "GetDeviceRegistry": { - "methods": ["getDeviceRegistry", "getDeviceRegistry", "getDeviceRegistry", "getDeviceRegistryCallable"] - }, - "GetIamPolicy": { - "methods": ["getIamPolicy", "getIamPolicy", "getIamPolicy", "getIamPolicyCallable"] - }, - "ListDeviceConfigVersions": { - "methods": ["listDeviceConfigVersions", "listDeviceConfigVersions", "listDeviceConfigVersions", "listDeviceConfigVersionsCallable"] - }, - "ListDeviceRegistries": { - "methods": ["listDeviceRegistries", "listDeviceRegistries", "listDeviceRegistries", "listDeviceRegistriesPagedCallable", "listDeviceRegistriesCallable"] - }, - "ListDeviceStates": { - "methods": ["listDeviceStates", "listDeviceStates", "listDeviceStates", "listDeviceStatesCallable"] - }, - "ListDevices": { - "methods": ["listDevices", "listDevices", "listDevices", "listDevicesPagedCallable", "listDevicesCallable"] - }, - "ModifyCloudToDeviceConfig": { - "methods": ["modifyCloudToDeviceConfig", "modifyCloudToDeviceConfig", "modifyCloudToDeviceConfig", "modifyCloudToDeviceConfigCallable"] - }, - "SendCommandToDevice": { - "methods": ["sendCommandToDevice", "sendCommandToDevice", "sendCommandToDevice", "sendCommandToDevice", "sendCommandToDevice", "sendCommandToDeviceCallable"] - }, - "SetIamPolicy": { - "methods": ["setIamPolicy", "setIamPolicy", "setIamPolicy", "setIamPolicyCallable"] - }, - "TestIamPermissions": { - "methods": ["testIamPermissions", "testIamPermissions", "testIamPermissions", "testIamPermissionsCallable"] - }, - "UnbindDeviceFromGateway": { - "methods": ["unbindDeviceFromGateway", "unbindDeviceFromGateway", "unbindDeviceFromGateway", "unbindDeviceFromGatewayCallable"] - }, - "UpdateDevice": { - "methods": ["updateDevice", "updateDevice", "updateDeviceCallable"] - }, - "UpdateDeviceRegistry": { - "methods": ["updateDeviceRegistry", "updateDeviceRegistry", "updateDeviceRegistryCallable"] - } - } - } - } - } - } -} \ No newline at end of file diff --git a/google-cloud-iot/src/main/java/com/google/cloud/iot/v1/package-info.java b/google-cloud-iot/src/main/java/com/google/cloud/iot/v1/package-info.java deleted file mode 100644 index 0e447431..00000000 --- a/google-cloud-iot/src/main/java/com/google/cloud/iot/v1/package-info.java +++ /dev/null @@ -1,43 +0,0 @@ -/* - * 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. - */ - -/** - * The interfaces provided are listed below, along with usage samples. - * - *

======================= DeviceManagerClient ======================= - * - *

Service Description: Internet of Things (IoT) service. Securely connect and manage IoT - * devices. - * - *

Sample for DeviceManagerClient: - * - *

{@code
- * // This snippet has been automatically generated and should be regarded as a code template only.
- * // It will require modifications to work:
- * // - It may require correct/in-range values for request initialization.
- * // - It may require specifying regional endpoints when creating the service client as shown in
- * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
- * try (DeviceManagerClient deviceManagerClient = DeviceManagerClient.create()) {
- *   LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]");
- *   DeviceRegistry deviceRegistry = DeviceRegistry.newBuilder().build();
- *   DeviceRegistry response = deviceManagerClient.createDeviceRegistry(parent, deviceRegistry);
- * }
- * }
- */ -@Generated("by gapic-generator-java") -package com.google.cloud.iot.v1; - -import javax.annotation.Generated; diff --git a/google-cloud-iot/src/main/java/com/google/cloud/iot/v1/stub/DeviceManagerStub.java b/google-cloud-iot/src/main/java/com/google/cloud/iot/v1/stub/DeviceManagerStub.java deleted file mode 100644 index 3417a46d..00000000 --- a/google-cloud-iot/src/main/java/com/google/cloud/iot/v1/stub/DeviceManagerStub.java +++ /dev/null @@ -1,162 +0,0 @@ -/* - * 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.gax.core.BackgroundResource; -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 javax.annotation.Generated; - -// AUTO-GENERATED DOCUMENTATION AND CLASS. -/** - * Base stub class for the DeviceManager service API. - * - *

This class is for advanced usage and reflects the underlying API directly. - */ -@Generated("by gapic-generator-java") -public abstract class DeviceManagerStub implements BackgroundResource { - - public UnaryCallable createDeviceRegistryCallable() { - throw new UnsupportedOperationException("Not implemented: createDeviceRegistryCallable()"); - } - - public UnaryCallable getDeviceRegistryCallable() { - throw new UnsupportedOperationException("Not implemented: getDeviceRegistryCallable()"); - } - - public UnaryCallable updateDeviceRegistryCallable() { - throw new UnsupportedOperationException("Not implemented: updateDeviceRegistryCallable()"); - } - - public UnaryCallable deleteDeviceRegistryCallable() { - throw new UnsupportedOperationException("Not implemented: deleteDeviceRegistryCallable()"); - } - - public UnaryCallable - listDeviceRegistriesPagedCallable() { - throw new UnsupportedOperationException("Not implemented: listDeviceRegistriesPagedCallable()"); - } - - public UnaryCallable - listDeviceRegistriesCallable() { - throw new UnsupportedOperationException("Not implemented: listDeviceRegistriesCallable()"); - } - - public UnaryCallable createDeviceCallable() { - throw new UnsupportedOperationException("Not implemented: createDeviceCallable()"); - } - - public UnaryCallable getDeviceCallable() { - throw new UnsupportedOperationException("Not implemented: getDeviceCallable()"); - } - - public UnaryCallable updateDeviceCallable() { - throw new UnsupportedOperationException("Not implemented: updateDeviceCallable()"); - } - - public UnaryCallable deleteDeviceCallable() { - throw new UnsupportedOperationException("Not implemented: deleteDeviceCallable()"); - } - - public UnaryCallable listDevicesPagedCallable() { - throw new UnsupportedOperationException("Not implemented: listDevicesPagedCallable()"); - } - - public UnaryCallable listDevicesCallable() { - throw new UnsupportedOperationException("Not implemented: listDevicesCallable()"); - } - - public UnaryCallable - modifyCloudToDeviceConfigCallable() { - throw new UnsupportedOperationException("Not implemented: modifyCloudToDeviceConfigCallable()"); - } - - public UnaryCallable - listDeviceConfigVersionsCallable() { - throw new UnsupportedOperationException("Not implemented: listDeviceConfigVersionsCallable()"); - } - - public UnaryCallable - listDeviceStatesCallable() { - throw new UnsupportedOperationException("Not implemented: listDeviceStatesCallable()"); - } - - public UnaryCallable setIamPolicyCallable() { - throw new UnsupportedOperationException("Not implemented: setIamPolicyCallable()"); - } - - public UnaryCallable getIamPolicyCallable() { - throw new UnsupportedOperationException("Not implemented: getIamPolicyCallable()"); - } - - public UnaryCallable - testIamPermissionsCallable() { - throw new UnsupportedOperationException("Not implemented: testIamPermissionsCallable()"); - } - - public UnaryCallable - sendCommandToDeviceCallable() { - throw new UnsupportedOperationException("Not implemented: sendCommandToDeviceCallable()"); - } - - public UnaryCallable - bindDeviceToGatewayCallable() { - throw new UnsupportedOperationException("Not implemented: bindDeviceToGatewayCallable()"); - } - - public UnaryCallable - unbindDeviceFromGatewayCallable() { - throw new UnsupportedOperationException("Not implemented: unbindDeviceFromGatewayCallable()"); - } - - @Override - public abstract void close(); -} diff --git a/google-cloud-iot/src/main/java/com/google/cloud/iot/v1/stub/DeviceManagerStubSettings.java b/google-cloud-iot/src/main/java/com/google/cloud/iot/v1/stub/DeviceManagerStubSettings.java deleted file mode 100644 index 2eb0c0b5..00000000 --- a/google-cloud-iot/src/main/java/com/google/cloud/iot/v1/stub/DeviceManagerStubSettings.java +++ /dev/null @@ -1,980 +0,0 @@ -/* - * 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.ApiFunction; -import com.google.api.core.ApiFuture; -import com.google.api.core.BetaApi; -import com.google.api.gax.core.GaxProperties; -import com.google.api.gax.core.GoogleCredentialsProvider; -import com.google.api.gax.core.InstantiatingExecutorProvider; -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; -import com.google.api.gax.rpc.ClientContext; -import com.google.api.gax.rpc.PageContext; -import com.google.api.gax.rpc.PagedCallSettings; -import com.google.api.gax.rpc.PagedListDescriptor; -import com.google.api.gax.rpc.PagedListResponseFactory; -import com.google.api.gax.rpc.StatusCode; -import com.google.api.gax.rpc.StubSettings; -import com.google.api.gax.rpc.TransportChannelProvider; -import com.google.api.gax.rpc.UnaryCallSettings; -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.common.collect.ImmutableList; -import com.google.common.collect.ImmutableMap; -import com.google.common.collect.ImmutableSet; -import com.google.common.collect.Lists; -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 java.io.IOException; -import java.util.List; -import javax.annotation.Generated; -import org.threeten.bp.Duration; - -// AUTO-GENERATED DOCUMENTATION AND CLASS. -/** - * Settings class to configure an instance of {@link DeviceManagerStub}. - * - *

The default instance has everything set to sensible defaults: - * - *

    - *
  • The default service address (cloudiot.googleapis.com) and default port (443) are used. - *
  • Credentials are acquired automatically through Application Default Credentials. - *
  • Retries are configured for idempotent methods but not for non-idempotent methods. - *
- * - *

The builder of this class is recursive, so contained classes are themselves builders. When - * build() is called, the tree of builders is called to create the complete settings object. - * - *

For example, to set the total timeout of createDeviceRegistry to 30 seconds: - * - *

{@code
- * // This snippet has been automatically generated and should be regarded as a code template only.
- * // It will require modifications to work:
- * // - It may require correct/in-range values for request initialization.
- * // - It may require specifying regional endpoints when creating the service client as shown in
- * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
- * DeviceManagerStubSettings.Builder deviceManagerSettingsBuilder =
- *     DeviceManagerStubSettings.newBuilder();
- * deviceManagerSettingsBuilder
- *     .createDeviceRegistrySettings()
- *     .setRetrySettings(
- *         deviceManagerSettingsBuilder
- *             .createDeviceRegistrySettings()
- *             .getRetrySettings()
- *             .toBuilder()
- *             .setTotalTimeout(Duration.ofSeconds(30))
- *             .build());
- * DeviceManagerStubSettings deviceManagerSettings = deviceManagerSettingsBuilder.build();
- * }
- */ -@Generated("by gapic-generator-java") -public class DeviceManagerStubSettings extends StubSettings { - /** The default scopes of the service. */ - private static final ImmutableList DEFAULT_SERVICE_SCOPES = - ImmutableList.builder() - .add("https://www.googleapis.com/auth/cloud-platform") - .add("https://www.googleapis.com/auth/cloudiot") - .build(); - - private final UnaryCallSettings - createDeviceRegistrySettings; - private final UnaryCallSettings - getDeviceRegistrySettings; - private final UnaryCallSettings - updateDeviceRegistrySettings; - private final UnaryCallSettings deleteDeviceRegistrySettings; - private final PagedCallSettings< - ListDeviceRegistriesRequest, - ListDeviceRegistriesResponse, - ListDeviceRegistriesPagedResponse> - listDeviceRegistriesSettings; - private final UnaryCallSettings createDeviceSettings; - private final UnaryCallSettings getDeviceSettings; - private final UnaryCallSettings updateDeviceSettings; - private final UnaryCallSettings deleteDeviceSettings; - private final PagedCallSettings - listDevicesSettings; - private final UnaryCallSettings - modifyCloudToDeviceConfigSettings; - private final UnaryCallSettings - listDeviceConfigVersionsSettings; - private final UnaryCallSettings - listDeviceStatesSettings; - private final UnaryCallSettings setIamPolicySettings; - private final UnaryCallSettings getIamPolicySettings; - private final UnaryCallSettings - testIamPermissionsSettings; - private final UnaryCallSettings - sendCommandToDeviceSettings; - private final UnaryCallSettings - bindDeviceToGatewaySettings; - private final UnaryCallSettings - unbindDeviceFromGatewaySettings; - - private static final PagedListDescriptor< - ListDeviceRegistriesRequest, ListDeviceRegistriesResponse, DeviceRegistry> - LIST_DEVICE_REGISTRIES_PAGE_STR_DESC = - new PagedListDescriptor< - ListDeviceRegistriesRequest, ListDeviceRegistriesResponse, DeviceRegistry>() { - @Override - public String emptyToken() { - return ""; - } - - @Override - public ListDeviceRegistriesRequest injectToken( - ListDeviceRegistriesRequest payload, String token) { - return ListDeviceRegistriesRequest.newBuilder(payload).setPageToken(token).build(); - } - - @Override - public ListDeviceRegistriesRequest injectPageSize( - ListDeviceRegistriesRequest payload, int pageSize) { - return ListDeviceRegistriesRequest.newBuilder(payload).setPageSize(pageSize).build(); - } - - @Override - public Integer extractPageSize(ListDeviceRegistriesRequest payload) { - return payload.getPageSize(); - } - - @Override - public String extractNextToken(ListDeviceRegistriesResponse payload) { - return payload.getNextPageToken(); - } - - @Override - public Iterable extractResources(ListDeviceRegistriesResponse payload) { - return payload.getDeviceRegistriesList() == null - ? ImmutableList.of() - : payload.getDeviceRegistriesList(); - } - }; - - private static final PagedListDescriptor - LIST_DEVICES_PAGE_STR_DESC = - new PagedListDescriptor() { - @Override - public String emptyToken() { - return ""; - } - - @Override - public ListDevicesRequest injectToken(ListDevicesRequest payload, String token) { - return ListDevicesRequest.newBuilder(payload).setPageToken(token).build(); - } - - @Override - public ListDevicesRequest injectPageSize(ListDevicesRequest payload, int pageSize) { - return ListDevicesRequest.newBuilder(payload).setPageSize(pageSize).build(); - } - - @Override - public Integer extractPageSize(ListDevicesRequest payload) { - return payload.getPageSize(); - } - - @Override - public String extractNextToken(ListDevicesResponse payload) { - return payload.getNextPageToken(); - } - - @Override - public Iterable extractResources(ListDevicesResponse payload) { - return payload.getDevicesList() == null - ? ImmutableList.of() - : payload.getDevicesList(); - } - }; - - private static final PagedListResponseFactory< - ListDeviceRegistriesRequest, - ListDeviceRegistriesResponse, - ListDeviceRegistriesPagedResponse> - LIST_DEVICE_REGISTRIES_PAGE_STR_FACT = - new PagedListResponseFactory< - ListDeviceRegistriesRequest, - ListDeviceRegistriesResponse, - ListDeviceRegistriesPagedResponse>() { - @Override - public ApiFuture getFuturePagedResponse( - UnaryCallable callable, - ListDeviceRegistriesRequest request, - ApiCallContext context, - ApiFuture futureResponse) { - PageContext - pageContext = - PageContext.create( - callable, LIST_DEVICE_REGISTRIES_PAGE_STR_DESC, request, context); - return ListDeviceRegistriesPagedResponse.createAsync(pageContext, futureResponse); - } - }; - - private static final PagedListResponseFactory< - ListDevicesRequest, ListDevicesResponse, ListDevicesPagedResponse> - LIST_DEVICES_PAGE_STR_FACT = - new PagedListResponseFactory< - ListDevicesRequest, ListDevicesResponse, ListDevicesPagedResponse>() { - @Override - public ApiFuture getFuturePagedResponse( - UnaryCallable callable, - ListDevicesRequest request, - ApiCallContext context, - ApiFuture futureResponse) { - PageContext pageContext = - PageContext.create(callable, LIST_DEVICES_PAGE_STR_DESC, request, context); - return ListDevicesPagedResponse.createAsync(pageContext, futureResponse); - } - }; - - /** Returns the object with the settings used for calls to createDeviceRegistry. */ - public UnaryCallSettings - createDeviceRegistrySettings() { - return createDeviceRegistrySettings; - } - - /** Returns the object with the settings used for calls to getDeviceRegistry. */ - public UnaryCallSettings getDeviceRegistrySettings() { - return getDeviceRegistrySettings; - } - - /** Returns the object with the settings used for calls to updateDeviceRegistry. */ - public UnaryCallSettings - updateDeviceRegistrySettings() { - return updateDeviceRegistrySettings; - } - - /** Returns the object with the settings used for calls to deleteDeviceRegistry. */ - public UnaryCallSettings deleteDeviceRegistrySettings() { - return deleteDeviceRegistrySettings; - } - - /** Returns the object with the settings used for calls to listDeviceRegistries. */ - public PagedCallSettings< - ListDeviceRegistriesRequest, - ListDeviceRegistriesResponse, - ListDeviceRegistriesPagedResponse> - listDeviceRegistriesSettings() { - return listDeviceRegistriesSettings; - } - - /** Returns the object with the settings used for calls to createDevice. */ - public UnaryCallSettings createDeviceSettings() { - return createDeviceSettings; - } - - /** Returns the object with the settings used for calls to getDevice. */ - public UnaryCallSettings getDeviceSettings() { - return getDeviceSettings; - } - - /** Returns the object with the settings used for calls to updateDevice. */ - public UnaryCallSettings updateDeviceSettings() { - return updateDeviceSettings; - } - - /** Returns the object with the settings used for calls to deleteDevice. */ - public UnaryCallSettings deleteDeviceSettings() { - return deleteDeviceSettings; - } - - /** Returns the object with the settings used for calls to listDevices. */ - public PagedCallSettings - listDevicesSettings() { - return listDevicesSettings; - } - - /** Returns the object with the settings used for calls to modifyCloudToDeviceConfig. */ - public UnaryCallSettings - modifyCloudToDeviceConfigSettings() { - return modifyCloudToDeviceConfigSettings; - } - - /** Returns the object with the settings used for calls to listDeviceConfigVersions. */ - public UnaryCallSettings - listDeviceConfigVersionsSettings() { - return listDeviceConfigVersionsSettings; - } - - /** Returns the object with the settings used for calls to listDeviceStates. */ - public UnaryCallSettings - listDeviceStatesSettings() { - return listDeviceStatesSettings; - } - - /** Returns the object with the settings used for calls to setIamPolicy. */ - public UnaryCallSettings setIamPolicySettings() { - return setIamPolicySettings; - } - - /** Returns the object with the settings used for calls to getIamPolicy. */ - public UnaryCallSettings getIamPolicySettings() { - return getIamPolicySettings; - } - - /** Returns the object with the settings used for calls to testIamPermissions. */ - public UnaryCallSettings - testIamPermissionsSettings() { - return testIamPermissionsSettings; - } - - /** Returns the object with the settings used for calls to sendCommandToDevice. */ - public UnaryCallSettings - sendCommandToDeviceSettings() { - return sendCommandToDeviceSettings; - } - - /** Returns the object with the settings used for calls to bindDeviceToGateway. */ - public UnaryCallSettings - bindDeviceToGatewaySettings() { - return bindDeviceToGatewaySettings; - } - - /** Returns the object with the settings used for calls to unbindDeviceFromGateway. */ - public UnaryCallSettings - unbindDeviceFromGatewaySettings() { - return unbindDeviceFromGatewaySettings; - } - - public DeviceManagerStub createStub() throws IOException { - if (getTransportChannelProvider() - .getTransportName() - .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())); - } - - /** Returns a builder for the default ExecutorProvider for this service. */ - public static InstantiatingExecutorProvider.Builder defaultExecutorProviderBuilder() { - return InstantiatingExecutorProvider.newBuilder(); - } - - /** Returns the default service endpoint. */ - public static String getDefaultEndpoint() { - return "cloudiot.googleapis.com:443"; - } - - /** Returns the default mTLS service endpoint. */ - public static String getDefaultMtlsEndpoint() { - return "cloudiot.mtls.googleapis.com:443"; - } - - /** Returns the default service scopes. */ - public static List getDefaultServiceScopes() { - return DEFAULT_SERVICE_SCOPES; - } - - /** Returns a builder for the default credentials for this service. */ - public static GoogleCredentialsProvider.Builder defaultCredentialsProviderBuilder() { - return GoogleCredentialsProvider.newBuilder() - .setScopesToApply(DEFAULT_SERVICE_SCOPES) - .setUseJwtAccessWithScope(true); - } - - /** 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 defaultGrpcApiClientHeaderProviderBuilder() { - return ApiClientHeaderProvider.newBuilder() - .setGeneratedLibToken( - "gapic", GaxProperties.getLibraryVersion(DeviceManagerStubSettings.class)) - .setTransportToken( - GaxGrpcProperties.getGrpcTokenName(), GaxGrpcProperties.getGrpcVersion()); - } - - @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); - } - - /** Returns a builder containing all the values of this settings class. */ - public Builder toBuilder() { - return new Builder(this); - } - - protected DeviceManagerStubSettings(Builder settingsBuilder) throws IOException { - super(settingsBuilder); - - createDeviceRegistrySettings = settingsBuilder.createDeviceRegistrySettings().build(); - getDeviceRegistrySettings = settingsBuilder.getDeviceRegistrySettings().build(); - updateDeviceRegistrySettings = settingsBuilder.updateDeviceRegistrySettings().build(); - deleteDeviceRegistrySettings = settingsBuilder.deleteDeviceRegistrySettings().build(); - listDeviceRegistriesSettings = settingsBuilder.listDeviceRegistriesSettings().build(); - createDeviceSettings = settingsBuilder.createDeviceSettings().build(); - getDeviceSettings = settingsBuilder.getDeviceSettings().build(); - updateDeviceSettings = settingsBuilder.updateDeviceSettings().build(); - deleteDeviceSettings = settingsBuilder.deleteDeviceSettings().build(); - listDevicesSettings = settingsBuilder.listDevicesSettings().build(); - modifyCloudToDeviceConfigSettings = settingsBuilder.modifyCloudToDeviceConfigSettings().build(); - listDeviceConfigVersionsSettings = settingsBuilder.listDeviceConfigVersionsSettings().build(); - listDeviceStatesSettings = settingsBuilder.listDeviceStatesSettings().build(); - setIamPolicySettings = settingsBuilder.setIamPolicySettings().build(); - getIamPolicySettings = settingsBuilder.getIamPolicySettings().build(); - testIamPermissionsSettings = settingsBuilder.testIamPermissionsSettings().build(); - sendCommandToDeviceSettings = settingsBuilder.sendCommandToDeviceSettings().build(); - bindDeviceToGatewaySettings = settingsBuilder.bindDeviceToGatewaySettings().build(); - unbindDeviceFromGatewaySettings = settingsBuilder.unbindDeviceFromGatewaySettings().build(); - } - - /** Builder for DeviceManagerStubSettings. */ - public static class Builder extends StubSettings.Builder { - private final ImmutableList> unaryMethodSettingsBuilders; - private final UnaryCallSettings.Builder - createDeviceRegistrySettings; - private final UnaryCallSettings.Builder - getDeviceRegistrySettings; - private final UnaryCallSettings.Builder - updateDeviceRegistrySettings; - private final UnaryCallSettings.Builder - deleteDeviceRegistrySettings; - private final PagedCallSettings.Builder< - ListDeviceRegistriesRequest, - ListDeviceRegistriesResponse, - ListDeviceRegistriesPagedResponse> - listDeviceRegistriesSettings; - private final UnaryCallSettings.Builder createDeviceSettings; - private final UnaryCallSettings.Builder getDeviceSettings; - private final UnaryCallSettings.Builder updateDeviceSettings; - private final UnaryCallSettings.Builder deleteDeviceSettings; - private final PagedCallSettings.Builder< - ListDevicesRequest, ListDevicesResponse, ListDevicesPagedResponse> - listDevicesSettings; - private final UnaryCallSettings.Builder - modifyCloudToDeviceConfigSettings; - private final UnaryCallSettings.Builder< - ListDeviceConfigVersionsRequest, ListDeviceConfigVersionsResponse> - listDeviceConfigVersionsSettings; - private final UnaryCallSettings.Builder - listDeviceStatesSettings; - private final UnaryCallSettings.Builder setIamPolicySettings; - private final UnaryCallSettings.Builder getIamPolicySettings; - private final UnaryCallSettings.Builder - testIamPermissionsSettings; - private final UnaryCallSettings.Builder - sendCommandToDeviceSettings; - private final UnaryCallSettings.Builder - bindDeviceToGatewaySettings; - private final UnaryCallSettings.Builder< - UnbindDeviceFromGatewayRequest, UnbindDeviceFromGatewayResponse> - unbindDeviceFromGatewaySettings; - private static final ImmutableMap> - RETRYABLE_CODE_DEFINITIONS; - - static { - ImmutableMap.Builder> definitions = - ImmutableMap.builder(); - definitions.put( - "no_retry_0_codes", ImmutableSet.copyOf(Lists.newArrayList())); - definitions.put( - "retry_policy_1_codes", - ImmutableSet.copyOf( - Lists.newArrayList( - StatusCode.Code.UNAVAILABLE, StatusCode.Code.DEADLINE_EXCEEDED))); - definitions.put( - "retry_policy_2_codes", - ImmutableSet.copyOf( - Lists.newArrayList( - StatusCode.Code.UNAVAILABLE, - StatusCode.Code.DEADLINE_EXCEEDED, - StatusCode.Code.RESOURCE_EXHAUSTED))); - RETRYABLE_CODE_DEFINITIONS = definitions.build(); - } - - private static final ImmutableMap RETRY_PARAM_DEFINITIONS; - - static { - ImmutableMap.Builder definitions = ImmutableMap.builder(); - RetrySettings settings = null; - settings = - RetrySettings.newBuilder() - .setInitialRpcTimeout(Duration.ofMillis(120000L)) - .setRpcTimeoutMultiplier(1.0) - .setMaxRpcTimeout(Duration.ofMillis(120000L)) - .setTotalTimeout(Duration.ofMillis(120000L)) - .build(); - definitions.put("no_retry_0_params", settings); - settings = - RetrySettings.newBuilder() - .setInitialRetryDelay(Duration.ofMillis(100L)) - .setRetryDelayMultiplier(1.3) - .setMaxRetryDelay(Duration.ofMillis(60000L)) - .setInitialRpcTimeout(Duration.ofMillis(120000L)) - .setRpcTimeoutMultiplier(1.0) - .setMaxRpcTimeout(Duration.ofMillis(120000L)) - .setTotalTimeout(Duration.ofMillis(120000L)) - .build(); - definitions.put("retry_policy_1_params", settings); - settings = - RetrySettings.newBuilder() - .setInitialRetryDelay(Duration.ofMillis(1000L)) - .setRetryDelayMultiplier(1.3) - .setMaxRetryDelay(Duration.ofMillis(60000L)) - .setInitialRpcTimeout(Duration.ofMillis(120000L)) - .setRpcTimeoutMultiplier(1.0) - .setMaxRpcTimeout(Duration.ofMillis(120000L)) - .setTotalTimeout(Duration.ofMillis(120000L)) - .build(); - definitions.put("retry_policy_2_params", settings); - RETRY_PARAM_DEFINITIONS = definitions.build(); - } - - protected Builder() { - this(((ClientContext) null)); - } - - protected Builder(ClientContext clientContext) { - super(clientContext); - - createDeviceRegistrySettings = UnaryCallSettings.newUnaryCallSettingsBuilder(); - getDeviceRegistrySettings = UnaryCallSettings.newUnaryCallSettingsBuilder(); - updateDeviceRegistrySettings = UnaryCallSettings.newUnaryCallSettingsBuilder(); - deleteDeviceRegistrySettings = UnaryCallSettings.newUnaryCallSettingsBuilder(); - listDeviceRegistriesSettings = - PagedCallSettings.newBuilder(LIST_DEVICE_REGISTRIES_PAGE_STR_FACT); - createDeviceSettings = UnaryCallSettings.newUnaryCallSettingsBuilder(); - getDeviceSettings = UnaryCallSettings.newUnaryCallSettingsBuilder(); - updateDeviceSettings = UnaryCallSettings.newUnaryCallSettingsBuilder(); - deleteDeviceSettings = UnaryCallSettings.newUnaryCallSettingsBuilder(); - listDevicesSettings = PagedCallSettings.newBuilder(LIST_DEVICES_PAGE_STR_FACT); - modifyCloudToDeviceConfigSettings = UnaryCallSettings.newUnaryCallSettingsBuilder(); - listDeviceConfigVersionsSettings = UnaryCallSettings.newUnaryCallSettingsBuilder(); - listDeviceStatesSettings = UnaryCallSettings.newUnaryCallSettingsBuilder(); - setIamPolicySettings = UnaryCallSettings.newUnaryCallSettingsBuilder(); - getIamPolicySettings = UnaryCallSettings.newUnaryCallSettingsBuilder(); - testIamPermissionsSettings = UnaryCallSettings.newUnaryCallSettingsBuilder(); - sendCommandToDeviceSettings = UnaryCallSettings.newUnaryCallSettingsBuilder(); - bindDeviceToGatewaySettings = UnaryCallSettings.newUnaryCallSettingsBuilder(); - unbindDeviceFromGatewaySettings = UnaryCallSettings.newUnaryCallSettingsBuilder(); - - unaryMethodSettingsBuilders = - ImmutableList.>of( - createDeviceRegistrySettings, - getDeviceRegistrySettings, - updateDeviceRegistrySettings, - deleteDeviceRegistrySettings, - listDeviceRegistriesSettings, - createDeviceSettings, - getDeviceSettings, - updateDeviceSettings, - deleteDeviceSettings, - listDevicesSettings, - modifyCloudToDeviceConfigSettings, - listDeviceConfigVersionsSettings, - listDeviceStatesSettings, - setIamPolicySettings, - getIamPolicySettings, - testIamPermissionsSettings, - sendCommandToDeviceSettings, - bindDeviceToGatewaySettings, - unbindDeviceFromGatewaySettings); - initDefaults(this); - } - - protected Builder(DeviceManagerStubSettings settings) { - super(settings); - - createDeviceRegistrySettings = settings.createDeviceRegistrySettings.toBuilder(); - getDeviceRegistrySettings = settings.getDeviceRegistrySettings.toBuilder(); - updateDeviceRegistrySettings = settings.updateDeviceRegistrySettings.toBuilder(); - deleteDeviceRegistrySettings = settings.deleteDeviceRegistrySettings.toBuilder(); - listDeviceRegistriesSettings = settings.listDeviceRegistriesSettings.toBuilder(); - createDeviceSettings = settings.createDeviceSettings.toBuilder(); - getDeviceSettings = settings.getDeviceSettings.toBuilder(); - updateDeviceSettings = settings.updateDeviceSettings.toBuilder(); - deleteDeviceSettings = settings.deleteDeviceSettings.toBuilder(); - listDevicesSettings = settings.listDevicesSettings.toBuilder(); - modifyCloudToDeviceConfigSettings = settings.modifyCloudToDeviceConfigSettings.toBuilder(); - listDeviceConfigVersionsSettings = settings.listDeviceConfigVersionsSettings.toBuilder(); - listDeviceStatesSettings = settings.listDeviceStatesSettings.toBuilder(); - setIamPolicySettings = settings.setIamPolicySettings.toBuilder(); - getIamPolicySettings = settings.getIamPolicySettings.toBuilder(); - testIamPermissionsSettings = settings.testIamPermissionsSettings.toBuilder(); - sendCommandToDeviceSettings = settings.sendCommandToDeviceSettings.toBuilder(); - bindDeviceToGatewaySettings = settings.bindDeviceToGatewaySettings.toBuilder(); - unbindDeviceFromGatewaySettings = settings.unbindDeviceFromGatewaySettings.toBuilder(); - - unaryMethodSettingsBuilders = - ImmutableList.>of( - createDeviceRegistrySettings, - getDeviceRegistrySettings, - updateDeviceRegistrySettings, - deleteDeviceRegistrySettings, - listDeviceRegistriesSettings, - createDeviceSettings, - getDeviceSettings, - updateDeviceSettings, - deleteDeviceSettings, - listDevicesSettings, - modifyCloudToDeviceConfigSettings, - listDeviceConfigVersionsSettings, - listDeviceStatesSettings, - setIamPolicySettings, - getIamPolicySettings, - testIamPermissionsSettings, - sendCommandToDeviceSettings, - bindDeviceToGatewaySettings, - unbindDeviceFromGatewaySettings); - } - - private static Builder createDefault() { - Builder builder = new Builder(((ClientContext) null)); - - builder.setTransportChannelProvider(defaultTransportChannelProvider()); - builder.setCredentialsProvider(defaultCredentialsProviderBuilder().build()); - builder.setInternalHeaderProvider(defaultApiClientHeaderProviderBuilder().build()); - builder.setEndpoint(getDefaultEndpoint()); - builder.setMtlsEndpoint(getDefaultMtlsEndpoint()); - builder.setSwitchToMtlsEndpointAllowed(true); - - 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() - .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("no_retry_0_codes")) - .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("no_retry_0_params")); - - builder - .getDeviceRegistrySettings() - .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("retry_policy_1_codes")) - .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("retry_policy_1_params")); - - builder - .updateDeviceRegistrySettings() - .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("no_retry_0_codes")) - .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("no_retry_0_params")); - - builder - .deleteDeviceRegistrySettings() - .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("retry_policy_1_codes")) - .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("retry_policy_1_params")); - - builder - .listDeviceRegistriesSettings() - .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("retry_policy_1_codes")) - .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("retry_policy_1_params")); - - builder - .createDeviceSettings() - .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("no_retry_0_codes")) - .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("no_retry_0_params")); - - builder - .getDeviceSettings() - .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("retry_policy_1_codes")) - .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("retry_policy_1_params")); - - builder - .updateDeviceSettings() - .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("no_retry_0_codes")) - .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("no_retry_0_params")); - - builder - .deleteDeviceSettings() - .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("retry_policy_1_codes")) - .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("retry_policy_1_params")); - - builder - .listDevicesSettings() - .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("retry_policy_1_codes")) - .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("retry_policy_1_params")); - - builder - .modifyCloudToDeviceConfigSettings() - .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("retry_policy_2_codes")) - .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("retry_policy_2_params")); - - builder - .listDeviceConfigVersionsSettings() - .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("retry_policy_1_codes")) - .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("retry_policy_1_params")); - - builder - .listDeviceStatesSettings() - .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("retry_policy_1_codes")) - .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("retry_policy_1_params")); - - builder - .setIamPolicySettings() - .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("no_retry_0_codes")) - .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("no_retry_0_params")); - - builder - .getIamPolicySettings() - .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("no_retry_0_codes")) - .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("no_retry_0_params")); - - builder - .testIamPermissionsSettings() - .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("no_retry_0_codes")) - .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("no_retry_0_params")); - - builder - .sendCommandToDeviceSettings() - .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("retry_policy_2_codes")) - .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("retry_policy_2_params")); - - builder - .bindDeviceToGatewaySettings() - .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("no_retry_0_codes")) - .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("no_retry_0_params")); - - builder - .unbindDeviceFromGatewaySettings() - .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("no_retry_0_codes")) - .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("no_retry_0_params")); - - return builder; - } - - /** - * Applies the given settings updater function to all of the unary API methods in this service. - * - *

Note: This method does not support applying settings to streaming methods. - */ - public Builder applyToAllUnaryMethods( - ApiFunction, Void> settingsUpdater) { - super.applyToAllUnaryMethods(unaryMethodSettingsBuilders, settingsUpdater); - return this; - } - - public ImmutableList> unaryMethodSettingsBuilders() { - return unaryMethodSettingsBuilders; - } - - /** Returns the builder for the settings used for calls to createDeviceRegistry. */ - public UnaryCallSettings.Builder - createDeviceRegistrySettings() { - return createDeviceRegistrySettings; - } - - /** Returns the builder for the settings used for calls to getDeviceRegistry. */ - public UnaryCallSettings.Builder - getDeviceRegistrySettings() { - return getDeviceRegistrySettings; - } - - /** Returns the builder for the settings used for calls to updateDeviceRegistry. */ - public UnaryCallSettings.Builder - updateDeviceRegistrySettings() { - return updateDeviceRegistrySettings; - } - - /** Returns the builder for the settings used for calls to deleteDeviceRegistry. */ - public UnaryCallSettings.Builder - deleteDeviceRegistrySettings() { - return deleteDeviceRegistrySettings; - } - - /** Returns the builder for the settings used for calls to listDeviceRegistries. */ - public PagedCallSettings.Builder< - ListDeviceRegistriesRequest, - ListDeviceRegistriesResponse, - ListDeviceRegistriesPagedResponse> - listDeviceRegistriesSettings() { - return listDeviceRegistriesSettings; - } - - /** Returns the builder for the settings used for calls to createDevice. */ - public UnaryCallSettings.Builder createDeviceSettings() { - return createDeviceSettings; - } - - /** Returns the builder for the settings used for calls to getDevice. */ - public UnaryCallSettings.Builder getDeviceSettings() { - return getDeviceSettings; - } - - /** Returns the builder for the settings used for calls to updateDevice. */ - public UnaryCallSettings.Builder updateDeviceSettings() { - return updateDeviceSettings; - } - - /** Returns the builder for the settings used for calls to deleteDevice. */ - public UnaryCallSettings.Builder deleteDeviceSettings() { - return deleteDeviceSettings; - } - - /** Returns the builder for the settings used for calls to listDevices. */ - public PagedCallSettings.Builder< - ListDevicesRequest, ListDevicesResponse, ListDevicesPagedResponse> - listDevicesSettings() { - return listDevicesSettings; - } - - /** Returns the builder for the settings used for calls to modifyCloudToDeviceConfig. */ - public UnaryCallSettings.Builder - modifyCloudToDeviceConfigSettings() { - return modifyCloudToDeviceConfigSettings; - } - - /** Returns the builder for the settings used for calls to listDeviceConfigVersions. */ - public UnaryCallSettings.Builder< - ListDeviceConfigVersionsRequest, ListDeviceConfigVersionsResponse> - listDeviceConfigVersionsSettings() { - return listDeviceConfigVersionsSettings; - } - - /** Returns the builder for the settings used for calls to listDeviceStates. */ - public UnaryCallSettings.Builder - listDeviceStatesSettings() { - return listDeviceStatesSettings; - } - - /** Returns the builder for the settings used for calls to setIamPolicy. */ - public UnaryCallSettings.Builder setIamPolicySettings() { - return setIamPolicySettings; - } - - /** Returns the builder for the settings used for calls to getIamPolicy. */ - public UnaryCallSettings.Builder getIamPolicySettings() { - return getIamPolicySettings; - } - - /** Returns the builder for the settings used for calls to testIamPermissions. */ - public UnaryCallSettings.Builder - testIamPermissionsSettings() { - return testIamPermissionsSettings; - } - - /** Returns the builder for the settings used for calls to sendCommandToDevice. */ - public UnaryCallSettings.Builder - sendCommandToDeviceSettings() { - return sendCommandToDeviceSettings; - } - - /** Returns the builder for the settings used for calls to bindDeviceToGateway. */ - public UnaryCallSettings.Builder - bindDeviceToGatewaySettings() { - return bindDeviceToGatewaySettings; - } - - /** Returns the builder for the settings used for calls to unbindDeviceFromGateway. */ - public UnaryCallSettings.Builder< - UnbindDeviceFromGatewayRequest, UnbindDeviceFromGatewayResponse> - unbindDeviceFromGatewaySettings() { - return unbindDeviceFromGatewaySettings; - } - - @Override - public DeviceManagerStubSettings build() throws IOException { - return new DeviceManagerStubSettings(this); - } - } -} diff --git a/google-cloud-iot/src/main/java/com/google/cloud/iot/v1/stub/GrpcDeviceManagerCallableFactory.java b/google-cloud-iot/src/main/java/com/google/cloud/iot/v1/stub/GrpcDeviceManagerCallableFactory.java deleted file mode 100644 index ea87b08a..00000000 --- a/google-cloud-iot/src/main/java/com/google/cloud/iot/v1/stub/GrpcDeviceManagerCallableFactory.java +++ /dev/null @@ -1,113 +0,0 @@ -/* - * 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.gax.grpc.GrpcCallSettings; -import com.google.api.gax.grpc.GrpcCallableFactory; -import com.google.api.gax.grpc.GrpcStubCallableFactory; -import com.google.api.gax.rpc.BatchingCallSettings; -import com.google.api.gax.rpc.BidiStreamingCallable; -import com.google.api.gax.rpc.ClientContext; -import com.google.api.gax.rpc.ClientStreamingCallable; -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.StreamingCallSettings; -import com.google.api.gax.rpc.UnaryCallSettings; -import com.google.api.gax.rpc.UnaryCallable; -import com.google.longrunning.Operation; -import com.google.longrunning.stub.OperationsStub; -import javax.annotation.Generated; - -// AUTO-GENERATED DOCUMENTATION AND CLASS. -/** - * gRPC callable factory implementation for the DeviceManager service API. - * - *

This class is for advanced usage. - */ -@Generated("by gapic-generator-java") -public class GrpcDeviceManagerCallableFactory implements GrpcStubCallableFactory { - - @Override - public UnaryCallable createUnaryCallable( - GrpcCallSettings grpcCallSettings, - UnaryCallSettings callSettings, - ClientContext clientContext) { - return GrpcCallableFactory.createUnaryCallable(grpcCallSettings, callSettings, clientContext); - } - - @Override - public - UnaryCallable createPagedCallable( - GrpcCallSettings grpcCallSettings, - PagedCallSettings callSettings, - ClientContext clientContext) { - return GrpcCallableFactory.createPagedCallable(grpcCallSettings, callSettings, clientContext); - } - - @Override - public UnaryCallable createBatchingCallable( - GrpcCallSettings grpcCallSettings, - BatchingCallSettings callSettings, - ClientContext clientContext) { - return GrpcCallableFactory.createBatchingCallable( - grpcCallSettings, callSettings, clientContext); - } - - @Override - public - OperationCallable createOperationCallable( - GrpcCallSettings grpcCallSettings, - OperationCallSettings callSettings, - ClientContext clientContext, - OperationsStub operationsStub) { - return GrpcCallableFactory.createOperationCallable( - grpcCallSettings, callSettings, clientContext, operationsStub); - } - - @Override - public - BidiStreamingCallable createBidiStreamingCallable( - GrpcCallSettings grpcCallSettings, - StreamingCallSettings callSettings, - ClientContext clientContext) { - return GrpcCallableFactory.createBidiStreamingCallable( - grpcCallSettings, callSettings, clientContext); - } - - @Override - public - ServerStreamingCallable createServerStreamingCallable( - GrpcCallSettings grpcCallSettings, - ServerStreamingCallSettings callSettings, - ClientContext clientContext) { - return GrpcCallableFactory.createServerStreamingCallable( - grpcCallSettings, callSettings, clientContext); - } - - @Override - public - ClientStreamingCallable createClientStreamingCallable( - GrpcCallSettings grpcCallSettings, - StreamingCallSettings callSettings, - ClientContext clientContext) { - return GrpcCallableFactory.createClientStreamingCallable( - grpcCallSettings, callSettings, clientContext); - } -} diff --git a/google-cloud-iot/src/main/java/com/google/cloud/iot/v1/stub/GrpcDeviceManagerStub.java b/google-cloud-iot/src/main/java/com/google/cloud/iot/v1/stub/GrpcDeviceManagerStub.java deleted file mode 100644 index 2641a62f..00000000 --- a/google-cloud-iot/src/main/java/com/google/cloud/iot/v1/stub/GrpcDeviceManagerStub.java +++ /dev/null @@ -1,791 +0,0 @@ -/* - * 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.gax.core.BackgroundResource; -import com.google.api.gax.core.BackgroundResourceAggregation; -import com.google.api.gax.grpc.GrpcCallSettings; -import com.google.api.gax.grpc.GrpcStubCallableFactory; -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.common.collect.ImmutableMap; -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.longrunning.stub.GrpcOperationsStub; -import com.google.protobuf.Empty; -import io.grpc.MethodDescriptor; -import io.grpc.protobuf.ProtoUtils; -import java.io.IOException; -import java.util.concurrent.TimeUnit; -import javax.annotation.Generated; - -// AUTO-GENERATED DOCUMENTATION AND CLASS. -/** - * gRPC stub implementation for the DeviceManager service API. - * - *

This class is for advanced usage and reflects the underlying API directly. - */ -@Generated("by gapic-generator-java") -public class GrpcDeviceManagerStub extends DeviceManagerStub { - private static final MethodDescriptor - createDeviceRegistryMethodDescriptor = - MethodDescriptor.newBuilder() - .setType(MethodDescriptor.MethodType.UNARY) - .setFullMethodName("google.cloud.iot.v1.DeviceManager/CreateDeviceRegistry") - .setRequestMarshaller( - ProtoUtils.marshaller(CreateDeviceRegistryRequest.getDefaultInstance())) - .setResponseMarshaller(ProtoUtils.marshaller(DeviceRegistry.getDefaultInstance())) - .build(); - - private static final MethodDescriptor - getDeviceRegistryMethodDescriptor = - MethodDescriptor.newBuilder() - .setType(MethodDescriptor.MethodType.UNARY) - .setFullMethodName("google.cloud.iot.v1.DeviceManager/GetDeviceRegistry") - .setRequestMarshaller( - ProtoUtils.marshaller(GetDeviceRegistryRequest.getDefaultInstance())) - .setResponseMarshaller(ProtoUtils.marshaller(DeviceRegistry.getDefaultInstance())) - .build(); - - private static final MethodDescriptor - updateDeviceRegistryMethodDescriptor = - MethodDescriptor.newBuilder() - .setType(MethodDescriptor.MethodType.UNARY) - .setFullMethodName("google.cloud.iot.v1.DeviceManager/UpdateDeviceRegistry") - .setRequestMarshaller( - ProtoUtils.marshaller(UpdateDeviceRegistryRequest.getDefaultInstance())) - .setResponseMarshaller(ProtoUtils.marshaller(DeviceRegistry.getDefaultInstance())) - .build(); - - private static final MethodDescriptor - deleteDeviceRegistryMethodDescriptor = - MethodDescriptor.newBuilder() - .setType(MethodDescriptor.MethodType.UNARY) - .setFullMethodName("google.cloud.iot.v1.DeviceManager/DeleteDeviceRegistry") - .setRequestMarshaller( - ProtoUtils.marshaller(DeleteDeviceRegistryRequest.getDefaultInstance())) - .setResponseMarshaller(ProtoUtils.marshaller(Empty.getDefaultInstance())) - .build(); - - private static final MethodDescriptor - listDeviceRegistriesMethodDescriptor = - MethodDescriptor.newBuilder() - .setType(MethodDescriptor.MethodType.UNARY) - .setFullMethodName("google.cloud.iot.v1.DeviceManager/ListDeviceRegistries") - .setRequestMarshaller( - ProtoUtils.marshaller(ListDeviceRegistriesRequest.getDefaultInstance())) - .setResponseMarshaller( - ProtoUtils.marshaller(ListDeviceRegistriesResponse.getDefaultInstance())) - .build(); - - private static final MethodDescriptor createDeviceMethodDescriptor = - MethodDescriptor.newBuilder() - .setType(MethodDescriptor.MethodType.UNARY) - .setFullMethodName("google.cloud.iot.v1.DeviceManager/CreateDevice") - .setRequestMarshaller(ProtoUtils.marshaller(CreateDeviceRequest.getDefaultInstance())) - .setResponseMarshaller(ProtoUtils.marshaller(Device.getDefaultInstance())) - .build(); - - private static final MethodDescriptor getDeviceMethodDescriptor = - MethodDescriptor.newBuilder() - .setType(MethodDescriptor.MethodType.UNARY) - .setFullMethodName("google.cloud.iot.v1.DeviceManager/GetDevice") - .setRequestMarshaller(ProtoUtils.marshaller(GetDeviceRequest.getDefaultInstance())) - .setResponseMarshaller(ProtoUtils.marshaller(Device.getDefaultInstance())) - .build(); - - private static final MethodDescriptor updateDeviceMethodDescriptor = - MethodDescriptor.newBuilder() - .setType(MethodDescriptor.MethodType.UNARY) - .setFullMethodName("google.cloud.iot.v1.DeviceManager/UpdateDevice") - .setRequestMarshaller(ProtoUtils.marshaller(UpdateDeviceRequest.getDefaultInstance())) - .setResponseMarshaller(ProtoUtils.marshaller(Device.getDefaultInstance())) - .build(); - - private static final MethodDescriptor deleteDeviceMethodDescriptor = - MethodDescriptor.newBuilder() - .setType(MethodDescriptor.MethodType.UNARY) - .setFullMethodName("google.cloud.iot.v1.DeviceManager/DeleteDevice") - .setRequestMarshaller(ProtoUtils.marshaller(DeleteDeviceRequest.getDefaultInstance())) - .setResponseMarshaller(ProtoUtils.marshaller(Empty.getDefaultInstance())) - .build(); - - private static final MethodDescriptor - listDevicesMethodDescriptor = - MethodDescriptor.newBuilder() - .setType(MethodDescriptor.MethodType.UNARY) - .setFullMethodName("google.cloud.iot.v1.DeviceManager/ListDevices") - .setRequestMarshaller(ProtoUtils.marshaller(ListDevicesRequest.getDefaultInstance())) - .setResponseMarshaller( - ProtoUtils.marshaller(ListDevicesResponse.getDefaultInstance())) - .build(); - - private static final MethodDescriptor - modifyCloudToDeviceConfigMethodDescriptor = - MethodDescriptor.newBuilder() - .setType(MethodDescriptor.MethodType.UNARY) - .setFullMethodName("google.cloud.iot.v1.DeviceManager/ModifyCloudToDeviceConfig") - .setRequestMarshaller( - ProtoUtils.marshaller(ModifyCloudToDeviceConfigRequest.getDefaultInstance())) - .setResponseMarshaller(ProtoUtils.marshaller(DeviceConfig.getDefaultInstance())) - .build(); - - private static final MethodDescriptor< - ListDeviceConfigVersionsRequest, ListDeviceConfigVersionsResponse> - listDeviceConfigVersionsMethodDescriptor = - MethodDescriptor - .newBuilder() - .setType(MethodDescriptor.MethodType.UNARY) - .setFullMethodName("google.cloud.iot.v1.DeviceManager/ListDeviceConfigVersions") - .setRequestMarshaller( - ProtoUtils.marshaller(ListDeviceConfigVersionsRequest.getDefaultInstance())) - .setResponseMarshaller( - ProtoUtils.marshaller(ListDeviceConfigVersionsResponse.getDefaultInstance())) - .build(); - - private static final MethodDescriptor - listDeviceStatesMethodDescriptor = - MethodDescriptor.newBuilder() - .setType(MethodDescriptor.MethodType.UNARY) - .setFullMethodName("google.cloud.iot.v1.DeviceManager/ListDeviceStates") - .setRequestMarshaller( - ProtoUtils.marshaller(ListDeviceStatesRequest.getDefaultInstance())) - .setResponseMarshaller( - ProtoUtils.marshaller(ListDeviceStatesResponse.getDefaultInstance())) - .build(); - - private static final MethodDescriptor setIamPolicyMethodDescriptor = - MethodDescriptor.newBuilder() - .setType(MethodDescriptor.MethodType.UNARY) - .setFullMethodName("google.cloud.iot.v1.DeviceManager/SetIamPolicy") - .setRequestMarshaller(ProtoUtils.marshaller(SetIamPolicyRequest.getDefaultInstance())) - .setResponseMarshaller(ProtoUtils.marshaller(Policy.getDefaultInstance())) - .build(); - - private static final MethodDescriptor getIamPolicyMethodDescriptor = - MethodDescriptor.newBuilder() - .setType(MethodDescriptor.MethodType.UNARY) - .setFullMethodName("google.cloud.iot.v1.DeviceManager/GetIamPolicy") - .setRequestMarshaller(ProtoUtils.marshaller(GetIamPolicyRequest.getDefaultInstance())) - .setResponseMarshaller(ProtoUtils.marshaller(Policy.getDefaultInstance())) - .build(); - - private static final MethodDescriptor - testIamPermissionsMethodDescriptor = - MethodDescriptor.newBuilder() - .setType(MethodDescriptor.MethodType.UNARY) - .setFullMethodName("google.cloud.iot.v1.DeviceManager/TestIamPermissions") - .setRequestMarshaller( - ProtoUtils.marshaller(TestIamPermissionsRequest.getDefaultInstance())) - .setResponseMarshaller( - ProtoUtils.marshaller(TestIamPermissionsResponse.getDefaultInstance())) - .build(); - - private static final MethodDescriptor - sendCommandToDeviceMethodDescriptor = - MethodDescriptor.newBuilder() - .setType(MethodDescriptor.MethodType.UNARY) - .setFullMethodName("google.cloud.iot.v1.DeviceManager/SendCommandToDevice") - .setRequestMarshaller( - ProtoUtils.marshaller(SendCommandToDeviceRequest.getDefaultInstance())) - .setResponseMarshaller( - ProtoUtils.marshaller(SendCommandToDeviceResponse.getDefaultInstance())) - .build(); - - private static final MethodDescriptor - bindDeviceToGatewayMethodDescriptor = - MethodDescriptor.newBuilder() - .setType(MethodDescriptor.MethodType.UNARY) - .setFullMethodName("google.cloud.iot.v1.DeviceManager/BindDeviceToGateway") - .setRequestMarshaller( - ProtoUtils.marshaller(BindDeviceToGatewayRequest.getDefaultInstance())) - .setResponseMarshaller( - ProtoUtils.marshaller(BindDeviceToGatewayResponse.getDefaultInstance())) - .build(); - - private static final MethodDescriptor< - UnbindDeviceFromGatewayRequest, UnbindDeviceFromGatewayResponse> - unbindDeviceFromGatewayMethodDescriptor = - MethodDescriptor - .newBuilder() - .setType(MethodDescriptor.MethodType.UNARY) - .setFullMethodName("google.cloud.iot.v1.DeviceManager/UnbindDeviceFromGateway") - .setRequestMarshaller( - ProtoUtils.marshaller(UnbindDeviceFromGatewayRequest.getDefaultInstance())) - .setResponseMarshaller( - ProtoUtils.marshaller(UnbindDeviceFromGatewayResponse.getDefaultInstance())) - .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 GrpcOperationsStub operationsStub; - private final GrpcStubCallableFactory callableFactory; - - public static final GrpcDeviceManagerStub create(DeviceManagerStubSettings settings) - throws IOException { - return new GrpcDeviceManagerStub(settings, ClientContext.create(settings)); - } - - public static final GrpcDeviceManagerStub create(ClientContext clientContext) throws IOException { - return new GrpcDeviceManagerStub(DeviceManagerStubSettings.newBuilder().build(), clientContext); - } - - public static final GrpcDeviceManagerStub create( - ClientContext clientContext, GrpcStubCallableFactory callableFactory) throws IOException { - return new GrpcDeviceManagerStub( - DeviceManagerStubSettings.newBuilder().build(), clientContext, callableFactory); - } - - /** - * Constructs an instance of GrpcDeviceManagerStub, 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 GrpcDeviceManagerStub(DeviceManagerStubSettings settings, ClientContext clientContext) - throws IOException { - this(settings, clientContext, new GrpcDeviceManagerCallableFactory()); - } - - /** - * Constructs an instance of GrpcDeviceManagerStub, 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 GrpcDeviceManagerStub( - DeviceManagerStubSettings settings, - ClientContext clientContext, - GrpcStubCallableFactory callableFactory) - throws IOException { - this.callableFactory = callableFactory; - this.operationsStub = GrpcOperationsStub.create(clientContext, callableFactory); - - GrpcCallSettings - createDeviceRegistryTransportSettings = - GrpcCallSettings.newBuilder() - .setMethodDescriptor(createDeviceRegistryMethodDescriptor) - .setParamsExtractor( - request -> { - ImmutableMap.Builder params = ImmutableMap.builder(); - params.put("parent", String.valueOf(request.getParent())); - return params.build(); - }) - .build(); - GrpcCallSettings getDeviceRegistryTransportSettings = - GrpcCallSettings.newBuilder() - .setMethodDescriptor(getDeviceRegistryMethodDescriptor) - .setParamsExtractor( - request -> { - ImmutableMap.Builder params = ImmutableMap.builder(); - params.put("name", String.valueOf(request.getName())); - return params.build(); - }) - .build(); - GrpcCallSettings - updateDeviceRegistryTransportSettings = - GrpcCallSettings.newBuilder() - .setMethodDescriptor(updateDeviceRegistryMethodDescriptor) - .setParamsExtractor( - request -> { - ImmutableMap.Builder params = ImmutableMap.builder(); - params.put( - "device_registry.name", - String.valueOf(request.getDeviceRegistry().getName())); - return params.build(); - }) - .build(); - GrpcCallSettings deleteDeviceRegistryTransportSettings = - GrpcCallSettings.newBuilder() - .setMethodDescriptor(deleteDeviceRegistryMethodDescriptor) - .setParamsExtractor( - request -> { - ImmutableMap.Builder params = ImmutableMap.builder(); - params.put("name", String.valueOf(request.getName())); - return params.build(); - }) - .build(); - GrpcCallSettings - listDeviceRegistriesTransportSettings = - GrpcCallSettings.newBuilder() - .setMethodDescriptor(listDeviceRegistriesMethodDescriptor) - .setParamsExtractor( - request -> { - ImmutableMap.Builder params = ImmutableMap.builder(); - params.put("parent", String.valueOf(request.getParent())); - return params.build(); - }) - .build(); - GrpcCallSettings createDeviceTransportSettings = - GrpcCallSettings.newBuilder() - .setMethodDescriptor(createDeviceMethodDescriptor) - .setParamsExtractor( - request -> { - ImmutableMap.Builder params = ImmutableMap.builder(); - params.put("parent", String.valueOf(request.getParent())); - return params.build(); - }) - .build(); - GrpcCallSettings getDeviceTransportSettings = - GrpcCallSettings.newBuilder() - .setMethodDescriptor(getDeviceMethodDescriptor) - .setParamsExtractor( - request -> { - ImmutableMap.Builder params = ImmutableMap.builder(); - params.put("name", String.valueOf(request.getName())); - return params.build(); - }) - .build(); - GrpcCallSettings updateDeviceTransportSettings = - GrpcCallSettings.newBuilder() - .setMethodDescriptor(updateDeviceMethodDescriptor) - .setParamsExtractor( - request -> { - ImmutableMap.Builder params = ImmutableMap.builder(); - params.put("device.name", String.valueOf(request.getDevice().getName())); - return params.build(); - }) - .build(); - GrpcCallSettings deleteDeviceTransportSettings = - GrpcCallSettings.newBuilder() - .setMethodDescriptor(deleteDeviceMethodDescriptor) - .setParamsExtractor( - request -> { - ImmutableMap.Builder params = ImmutableMap.builder(); - params.put("name", String.valueOf(request.getName())); - return params.build(); - }) - .build(); - GrpcCallSettings listDevicesTransportSettings = - GrpcCallSettings.newBuilder() - .setMethodDescriptor(listDevicesMethodDescriptor) - .setParamsExtractor( - request -> { - ImmutableMap.Builder params = ImmutableMap.builder(); - params.put("parent", String.valueOf(request.getParent())); - return params.build(); - }) - .build(); - GrpcCallSettings - modifyCloudToDeviceConfigTransportSettings = - GrpcCallSettings.newBuilder() - .setMethodDescriptor(modifyCloudToDeviceConfigMethodDescriptor) - .setParamsExtractor( - request -> { - ImmutableMap.Builder params = ImmutableMap.builder(); - params.put("name", String.valueOf(request.getName())); - return params.build(); - }) - .build(); - GrpcCallSettings - listDeviceConfigVersionsTransportSettings = - GrpcCallSettings - .newBuilder() - .setMethodDescriptor(listDeviceConfigVersionsMethodDescriptor) - .setParamsExtractor( - request -> { - ImmutableMap.Builder params = ImmutableMap.builder(); - params.put("name", String.valueOf(request.getName())); - return params.build(); - }) - .build(); - GrpcCallSettings - listDeviceStatesTransportSettings = - GrpcCallSettings.newBuilder() - .setMethodDescriptor(listDeviceStatesMethodDescriptor) - .setParamsExtractor( - request -> { - ImmutableMap.Builder params = ImmutableMap.builder(); - params.put("name", String.valueOf(request.getName())); - return params.build(); - }) - .build(); - GrpcCallSettings setIamPolicyTransportSettings = - GrpcCallSettings.newBuilder() - .setMethodDescriptor(setIamPolicyMethodDescriptor) - .setParamsExtractor( - request -> { - ImmutableMap.Builder params = ImmutableMap.builder(); - params.put("resource", String.valueOf(request.getResource())); - return params.build(); - }) - .build(); - GrpcCallSettings getIamPolicyTransportSettings = - GrpcCallSettings.newBuilder() - .setMethodDescriptor(getIamPolicyMethodDescriptor) - .setParamsExtractor( - request -> { - ImmutableMap.Builder params = ImmutableMap.builder(); - params.put("resource", String.valueOf(request.getResource())); - return params.build(); - }) - .build(); - GrpcCallSettings - testIamPermissionsTransportSettings = - GrpcCallSettings.newBuilder() - .setMethodDescriptor(testIamPermissionsMethodDescriptor) - .setParamsExtractor( - request -> { - ImmutableMap.Builder params = ImmutableMap.builder(); - params.put("resource", String.valueOf(request.getResource())); - return params.build(); - }) - .build(); - GrpcCallSettings - sendCommandToDeviceTransportSettings = - GrpcCallSettings.newBuilder() - .setMethodDescriptor(sendCommandToDeviceMethodDescriptor) - .setParamsExtractor( - request -> { - ImmutableMap.Builder params = ImmutableMap.builder(); - params.put("name", String.valueOf(request.getName())); - return params.build(); - }) - .build(); - GrpcCallSettings - bindDeviceToGatewayTransportSettings = - GrpcCallSettings.newBuilder() - .setMethodDescriptor(bindDeviceToGatewayMethodDescriptor) - .setParamsExtractor( - request -> { - ImmutableMap.Builder params = ImmutableMap.builder(); - params.put("parent", String.valueOf(request.getParent())); - return params.build(); - }) - .build(); - GrpcCallSettings - unbindDeviceFromGatewayTransportSettings = - GrpcCallSettings - .newBuilder() - .setMethodDescriptor(unbindDeviceFromGatewayMethodDescriptor) - .setParamsExtractor( - request -> { - ImmutableMap.Builder params = ImmutableMap.builder(); - params.put("parent", String.valueOf(request.getParent())); - return params.build(); - }) - .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()); - } - - public GrpcOperationsStub getOperationsStub() { - return operationsStub; - } - - @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/google-cloud-iot/src/main/java/com/google/cloud/iot/v1/stub/HttpJsonDeviceManagerCallableFactory.java b/google-cloud-iot/src/main/java/com/google/cloud/iot/v1/stub/HttpJsonDeviceManagerCallableFactory.java deleted file mode 100644 index 58d6577e..00000000 --- a/google-cloud-iot/src/main/java/com/google/cloud/iot/v1/stub/HttpJsonDeviceManagerCallableFactory.java +++ /dev/null @@ -1,105 +0,0 @@ -/* - * 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/google-cloud-iot/src/main/java/com/google/cloud/iot/v1/stub/HttpJsonDeviceManagerStub.java b/google-cloud-iot/src/main/java/com/google/cloud/iot/v1/stub/HttpJsonDeviceManagerStub.java deleted file mode 100644 index fd445c9f..00000000 --- a/google-cloud-iot/src/main/java/com/google/cloud/iot/v1/stub/HttpJsonDeviceManagerStub.java +++ /dev/null @@ -1,1250 +0,0 @@ -/* - * 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(), false)) - .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(), false)) - .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(), false)) - .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(), false)) - .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(), false)) - .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(), false)) - .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(), false)) - .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(), false)) - .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(), false)) - .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(), false)) - .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(), false)) - .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/google-cloud-iot/src/test/java/com/google/cloud/iot/v1/DeviceManagerClientHttpJsonTest.java b/google-cloud-iot/src/test/java/com/google/cloud/iot/v1/DeviceManagerClientHttpJsonTest.java deleted file mode 100644 index 5878f0fb..00000000 --- a/google-cloud-iot/src/test/java/com/google/cloud/iot/v1/DeviceManagerClientHttpJsonTest.java +++ /dev/null @@ -1,2008 +0,0 @@ -/* - * 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/google-cloud-iot/src/test/java/com/google/cloud/iot/v1/DeviceManagerClientTest.java b/google-cloud-iot/src/test/java/com/google/cloud/iot/v1/DeviceManagerClientTest.java deleted file mode 100644 index 7dc640a7..00000000 --- a/google-cloud-iot/src/test/java/com/google/cloud/iot/v1/DeviceManagerClientTest.java +++ /dev/null @@ -1,1752 +0,0 @@ -/* - * 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.grpc.GaxGrpcProperties; -import com.google.api.gax.grpc.testing.LocalChannelProvider; -import com.google.api.gax.grpc.testing.MockGrpcService; -import com.google.api.gax.grpc.testing.MockServiceHelper; -import com.google.api.gax.rpc.ApiClientHeaderProvider; -import com.google.api.gax.rpc.InvalidArgumentException; -import com.google.api.resourcenames.ResourceName; -import com.google.common.collect.Lists; -import com.google.iam.v1.AuditConfig; -import com.google.iam.v1.Binding; -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.AbstractMessage; -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 io.grpc.StatusRuntimeException; -import java.io.IOException; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.HashMap; -import java.util.List; -import java.util.UUID; -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 DeviceManagerClientTest { - private static MockDeviceManager mockDeviceManager; - private static MockServiceHelper mockServiceHelper; - private LocalChannelProvider channelProvider; - private DeviceManagerClient client; - - @BeforeClass - public static void startStaticServer() { - mockDeviceManager = new MockDeviceManager(); - mockServiceHelper = - new MockServiceHelper( - UUID.randomUUID().toString(), Arrays.asList(mockDeviceManager)); - mockServiceHelper.start(); - } - - @AfterClass - public static void stopServer() { - mockServiceHelper.stop(); - } - - @Before - public void setUp() throws IOException { - mockServiceHelper.reset(); - channelProvider = mockServiceHelper.createChannelProvider(); - DeviceManagerSettings settings = - DeviceManagerSettings.newBuilder() - .setTransportChannelProvider(channelProvider) - .setCredentialsProvider(NoCredentialsProvider.create()) - .build(); - client = DeviceManagerClient.create(settings); - } - - @After - public void tearDown() throws Exception { - client.close(); - } - - @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(); - mockDeviceManager.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 = mockDeviceManager.getRequests(); - Assert.assertEquals(1, actualRequests.size()); - CreateDeviceRegistryRequest actualRequest = - ((CreateDeviceRegistryRequest) actualRequests.get(0)); - - Assert.assertEquals(parent.toString(), actualRequest.getParent()); - Assert.assertEquals(deviceRegistry, actualRequest.getDeviceRegistry()); - Assert.assertTrue( - channelProvider.isHeaderSent( - ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), - GaxGrpcProperties.getDefaultApiClientHeaderPattern())); - } - - @Test - public void createDeviceRegistryExceptionTest() throws Exception { - StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT); - mockDeviceManager.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(); - mockDeviceManager.addResponse(expectedResponse); - - String parent = "parent-995424086"; - DeviceRegistry deviceRegistry = DeviceRegistry.newBuilder().build(); - - DeviceRegistry actualResponse = client.createDeviceRegistry(parent, deviceRegistry); - Assert.assertEquals(expectedResponse, actualResponse); - - List actualRequests = mockDeviceManager.getRequests(); - Assert.assertEquals(1, actualRequests.size()); - CreateDeviceRegistryRequest actualRequest = - ((CreateDeviceRegistryRequest) actualRequests.get(0)); - - Assert.assertEquals(parent, actualRequest.getParent()); - Assert.assertEquals(deviceRegistry, actualRequest.getDeviceRegistry()); - Assert.assertTrue( - channelProvider.isHeaderSent( - ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), - GaxGrpcProperties.getDefaultApiClientHeaderPattern())); - } - - @Test - public void createDeviceRegistryExceptionTest2() throws Exception { - StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT); - mockDeviceManager.addException(exception); - - try { - String parent = "parent-995424086"; - 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(); - mockDeviceManager.addResponse(expectedResponse); - - RegistryName name = RegistryName.of("[PROJECT]", "[LOCATION]", "[REGISTRY]"); - - DeviceRegistry actualResponse = client.getDeviceRegistry(name); - Assert.assertEquals(expectedResponse, actualResponse); - - List actualRequests = mockDeviceManager.getRequests(); - Assert.assertEquals(1, actualRequests.size()); - GetDeviceRegistryRequest actualRequest = ((GetDeviceRegistryRequest) actualRequests.get(0)); - - Assert.assertEquals(name.toString(), actualRequest.getName()); - Assert.assertTrue( - channelProvider.isHeaderSent( - ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), - GaxGrpcProperties.getDefaultApiClientHeaderPattern())); - } - - @Test - public void getDeviceRegistryExceptionTest() throws Exception { - StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT); - mockDeviceManager.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(); - mockDeviceManager.addResponse(expectedResponse); - - String name = "name3373707"; - - DeviceRegistry actualResponse = client.getDeviceRegistry(name); - Assert.assertEquals(expectedResponse, actualResponse); - - List actualRequests = mockDeviceManager.getRequests(); - Assert.assertEquals(1, actualRequests.size()); - GetDeviceRegistryRequest actualRequest = ((GetDeviceRegistryRequest) actualRequests.get(0)); - - Assert.assertEquals(name, actualRequest.getName()); - Assert.assertTrue( - channelProvider.isHeaderSent( - ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), - GaxGrpcProperties.getDefaultApiClientHeaderPattern())); - } - - @Test - public void getDeviceRegistryExceptionTest2() throws Exception { - StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT); - mockDeviceManager.addException(exception); - - try { - String name = "name3373707"; - 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(); - mockDeviceManager.addResponse(expectedResponse); - - DeviceRegistry deviceRegistry = DeviceRegistry.newBuilder().build(); - FieldMask updateMask = FieldMask.newBuilder().build(); - - DeviceRegistry actualResponse = client.updateDeviceRegistry(deviceRegistry, updateMask); - Assert.assertEquals(expectedResponse, actualResponse); - - List actualRequests = mockDeviceManager.getRequests(); - Assert.assertEquals(1, actualRequests.size()); - UpdateDeviceRegistryRequest actualRequest = - ((UpdateDeviceRegistryRequest) actualRequests.get(0)); - - Assert.assertEquals(deviceRegistry, actualRequest.getDeviceRegistry()); - Assert.assertEquals(updateMask, actualRequest.getUpdateMask()); - Assert.assertTrue( - channelProvider.isHeaderSent( - ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), - GaxGrpcProperties.getDefaultApiClientHeaderPattern())); - } - - @Test - public void updateDeviceRegistryExceptionTest() throws Exception { - StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT); - mockDeviceManager.addException(exception); - - try { - DeviceRegistry deviceRegistry = DeviceRegistry.newBuilder().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(); - mockDeviceManager.addResponse(expectedResponse); - - RegistryName name = RegistryName.of("[PROJECT]", "[LOCATION]", "[REGISTRY]"); - - client.deleteDeviceRegistry(name); - - List actualRequests = mockDeviceManager.getRequests(); - Assert.assertEquals(1, actualRequests.size()); - DeleteDeviceRegistryRequest actualRequest = - ((DeleteDeviceRegistryRequest) actualRequests.get(0)); - - Assert.assertEquals(name.toString(), actualRequest.getName()); - Assert.assertTrue( - channelProvider.isHeaderSent( - ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), - GaxGrpcProperties.getDefaultApiClientHeaderPattern())); - } - - @Test - public void deleteDeviceRegistryExceptionTest() throws Exception { - StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT); - mockDeviceManager.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(); - mockDeviceManager.addResponse(expectedResponse); - - String name = "name3373707"; - - client.deleteDeviceRegistry(name); - - List actualRequests = mockDeviceManager.getRequests(); - Assert.assertEquals(1, actualRequests.size()); - DeleteDeviceRegistryRequest actualRequest = - ((DeleteDeviceRegistryRequest) actualRequests.get(0)); - - Assert.assertEquals(name, actualRequest.getName()); - Assert.assertTrue( - channelProvider.isHeaderSent( - ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), - GaxGrpcProperties.getDefaultApiClientHeaderPattern())); - } - - @Test - public void deleteDeviceRegistryExceptionTest2() throws Exception { - StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT); - mockDeviceManager.addException(exception); - - try { - String name = "name3373707"; - 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(); - mockDeviceManager.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 = mockDeviceManager.getRequests(); - Assert.assertEquals(1, actualRequests.size()); - ListDeviceRegistriesRequest actualRequest = - ((ListDeviceRegistriesRequest) actualRequests.get(0)); - - Assert.assertEquals(parent.toString(), actualRequest.getParent()); - Assert.assertTrue( - channelProvider.isHeaderSent( - ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), - GaxGrpcProperties.getDefaultApiClientHeaderPattern())); - } - - @Test - public void listDeviceRegistriesExceptionTest() throws Exception { - StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT); - mockDeviceManager.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(); - mockDeviceManager.addResponse(expectedResponse); - - String parent = "parent-995424086"; - - 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 = mockDeviceManager.getRequests(); - Assert.assertEquals(1, actualRequests.size()); - ListDeviceRegistriesRequest actualRequest = - ((ListDeviceRegistriesRequest) actualRequests.get(0)); - - Assert.assertEquals(parent, actualRequest.getParent()); - Assert.assertTrue( - channelProvider.isHeaderSent( - ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), - GaxGrpcProperties.getDefaultApiClientHeaderPattern())); - } - - @Test - public void listDeviceRegistriesExceptionTest2() throws Exception { - StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT); - mockDeviceManager.addException(exception); - - try { - String parent = "parent-995424086"; - 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(); - mockDeviceManager.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 = mockDeviceManager.getRequests(); - Assert.assertEquals(1, actualRequests.size()); - CreateDeviceRequest actualRequest = ((CreateDeviceRequest) actualRequests.get(0)); - - Assert.assertEquals(parent.toString(), actualRequest.getParent()); - Assert.assertEquals(device, actualRequest.getDevice()); - Assert.assertTrue( - channelProvider.isHeaderSent( - ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), - GaxGrpcProperties.getDefaultApiClientHeaderPattern())); - } - - @Test - public void createDeviceExceptionTest() throws Exception { - StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT); - mockDeviceManager.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(); - mockDeviceManager.addResponse(expectedResponse); - - String parent = "parent-995424086"; - Device device = Device.newBuilder().build(); - - Device actualResponse = client.createDevice(parent, device); - Assert.assertEquals(expectedResponse, actualResponse); - - List actualRequests = mockDeviceManager.getRequests(); - Assert.assertEquals(1, actualRequests.size()); - CreateDeviceRequest actualRequest = ((CreateDeviceRequest) actualRequests.get(0)); - - Assert.assertEquals(parent, actualRequest.getParent()); - Assert.assertEquals(device, actualRequest.getDevice()); - Assert.assertTrue( - channelProvider.isHeaderSent( - ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), - GaxGrpcProperties.getDefaultApiClientHeaderPattern())); - } - - @Test - public void createDeviceExceptionTest2() throws Exception { - StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT); - mockDeviceManager.addException(exception); - - try { - String parent = "parent-995424086"; - 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(); - mockDeviceManager.addResponse(expectedResponse); - - DeviceName name = DeviceName.of("[PROJECT]", "[LOCATION]", "[REGISTRY]", "[DEVICE]"); - - Device actualResponse = client.getDevice(name); - Assert.assertEquals(expectedResponse, actualResponse); - - List actualRequests = mockDeviceManager.getRequests(); - Assert.assertEquals(1, actualRequests.size()); - GetDeviceRequest actualRequest = ((GetDeviceRequest) actualRequests.get(0)); - - Assert.assertEquals(name.toString(), actualRequest.getName()); - Assert.assertTrue( - channelProvider.isHeaderSent( - ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), - GaxGrpcProperties.getDefaultApiClientHeaderPattern())); - } - - @Test - public void getDeviceExceptionTest() throws Exception { - StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT); - mockDeviceManager.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(); - mockDeviceManager.addResponse(expectedResponse); - - String name = "name3373707"; - - Device actualResponse = client.getDevice(name); - Assert.assertEquals(expectedResponse, actualResponse); - - List actualRequests = mockDeviceManager.getRequests(); - Assert.assertEquals(1, actualRequests.size()); - GetDeviceRequest actualRequest = ((GetDeviceRequest) actualRequests.get(0)); - - Assert.assertEquals(name, actualRequest.getName()); - Assert.assertTrue( - channelProvider.isHeaderSent( - ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), - GaxGrpcProperties.getDefaultApiClientHeaderPattern())); - } - - @Test - public void getDeviceExceptionTest2() throws Exception { - StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT); - mockDeviceManager.addException(exception); - - try { - String name = "name3373707"; - 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(); - mockDeviceManager.addResponse(expectedResponse); - - Device device = Device.newBuilder().build(); - FieldMask updateMask = FieldMask.newBuilder().build(); - - Device actualResponse = client.updateDevice(device, updateMask); - Assert.assertEquals(expectedResponse, actualResponse); - - List actualRequests = mockDeviceManager.getRequests(); - Assert.assertEquals(1, actualRequests.size()); - UpdateDeviceRequest actualRequest = ((UpdateDeviceRequest) actualRequests.get(0)); - - Assert.assertEquals(device, actualRequest.getDevice()); - Assert.assertEquals(updateMask, actualRequest.getUpdateMask()); - Assert.assertTrue( - channelProvider.isHeaderSent( - ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), - GaxGrpcProperties.getDefaultApiClientHeaderPattern())); - } - - @Test - public void updateDeviceExceptionTest() throws Exception { - StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT); - mockDeviceManager.addException(exception); - - try { - Device device = Device.newBuilder().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(); - mockDeviceManager.addResponse(expectedResponse); - - DeviceName name = DeviceName.of("[PROJECT]", "[LOCATION]", "[REGISTRY]", "[DEVICE]"); - - client.deleteDevice(name); - - List actualRequests = mockDeviceManager.getRequests(); - Assert.assertEquals(1, actualRequests.size()); - DeleteDeviceRequest actualRequest = ((DeleteDeviceRequest) actualRequests.get(0)); - - Assert.assertEquals(name.toString(), actualRequest.getName()); - Assert.assertTrue( - channelProvider.isHeaderSent( - ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), - GaxGrpcProperties.getDefaultApiClientHeaderPattern())); - } - - @Test - public void deleteDeviceExceptionTest() throws Exception { - StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT); - mockDeviceManager.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(); - mockDeviceManager.addResponse(expectedResponse); - - String name = "name3373707"; - - client.deleteDevice(name); - - List actualRequests = mockDeviceManager.getRequests(); - Assert.assertEquals(1, actualRequests.size()); - DeleteDeviceRequest actualRequest = ((DeleteDeviceRequest) actualRequests.get(0)); - - Assert.assertEquals(name, actualRequest.getName()); - Assert.assertTrue( - channelProvider.isHeaderSent( - ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), - GaxGrpcProperties.getDefaultApiClientHeaderPattern())); - } - - @Test - public void deleteDeviceExceptionTest2() throws Exception { - StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT); - mockDeviceManager.addException(exception); - - try { - String name = "name3373707"; - 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(); - mockDeviceManager.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 = mockDeviceManager.getRequests(); - Assert.assertEquals(1, actualRequests.size()); - ListDevicesRequest actualRequest = ((ListDevicesRequest) actualRequests.get(0)); - - Assert.assertEquals(parent.toString(), actualRequest.getParent()); - Assert.assertTrue( - channelProvider.isHeaderSent( - ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), - GaxGrpcProperties.getDefaultApiClientHeaderPattern())); - } - - @Test - public void listDevicesExceptionTest() throws Exception { - StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT); - mockDeviceManager.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(); - mockDeviceManager.addResponse(expectedResponse); - - String parent = "parent-995424086"; - - 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 = mockDeviceManager.getRequests(); - Assert.assertEquals(1, actualRequests.size()); - ListDevicesRequest actualRequest = ((ListDevicesRequest) actualRequests.get(0)); - - Assert.assertEquals(parent, actualRequest.getParent()); - Assert.assertTrue( - channelProvider.isHeaderSent( - ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), - GaxGrpcProperties.getDefaultApiClientHeaderPattern())); - } - - @Test - public void listDevicesExceptionTest2() throws Exception { - StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT); - mockDeviceManager.addException(exception); - - try { - String parent = "parent-995424086"; - 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(); - mockDeviceManager.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 = mockDeviceManager.getRequests(); - Assert.assertEquals(1, actualRequests.size()); - ModifyCloudToDeviceConfigRequest actualRequest = - ((ModifyCloudToDeviceConfigRequest) actualRequests.get(0)); - - Assert.assertEquals(name.toString(), actualRequest.getName()); - Assert.assertEquals(binaryData, actualRequest.getBinaryData()); - Assert.assertTrue( - channelProvider.isHeaderSent( - ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), - GaxGrpcProperties.getDefaultApiClientHeaderPattern())); - } - - @Test - public void modifyCloudToDeviceConfigExceptionTest() throws Exception { - StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT); - mockDeviceManager.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(); - mockDeviceManager.addResponse(expectedResponse); - - String name = "name3373707"; - ByteString binaryData = ByteString.EMPTY; - - DeviceConfig actualResponse = client.modifyCloudToDeviceConfig(name, binaryData); - Assert.assertEquals(expectedResponse, actualResponse); - - List actualRequests = mockDeviceManager.getRequests(); - Assert.assertEquals(1, actualRequests.size()); - ModifyCloudToDeviceConfigRequest actualRequest = - ((ModifyCloudToDeviceConfigRequest) actualRequests.get(0)); - - Assert.assertEquals(name, actualRequest.getName()); - Assert.assertEquals(binaryData, actualRequest.getBinaryData()); - Assert.assertTrue( - channelProvider.isHeaderSent( - ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), - GaxGrpcProperties.getDefaultApiClientHeaderPattern())); - } - - @Test - public void modifyCloudToDeviceConfigExceptionTest2() throws Exception { - StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT); - mockDeviceManager.addException(exception); - - try { - String name = "name3373707"; - 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(); - mockDeviceManager.addResponse(expectedResponse); - - DeviceName name = DeviceName.of("[PROJECT]", "[LOCATION]", "[REGISTRY]", "[DEVICE]"); - - ListDeviceConfigVersionsResponse actualResponse = client.listDeviceConfigVersions(name); - Assert.assertEquals(expectedResponse, actualResponse); - - List actualRequests = mockDeviceManager.getRequests(); - Assert.assertEquals(1, actualRequests.size()); - ListDeviceConfigVersionsRequest actualRequest = - ((ListDeviceConfigVersionsRequest) actualRequests.get(0)); - - Assert.assertEquals(name.toString(), actualRequest.getName()); - Assert.assertTrue( - channelProvider.isHeaderSent( - ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), - GaxGrpcProperties.getDefaultApiClientHeaderPattern())); - } - - @Test - public void listDeviceConfigVersionsExceptionTest() throws Exception { - StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT); - mockDeviceManager.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(); - mockDeviceManager.addResponse(expectedResponse); - - String name = "name3373707"; - - ListDeviceConfigVersionsResponse actualResponse = client.listDeviceConfigVersions(name); - Assert.assertEquals(expectedResponse, actualResponse); - - List actualRequests = mockDeviceManager.getRequests(); - Assert.assertEquals(1, actualRequests.size()); - ListDeviceConfigVersionsRequest actualRequest = - ((ListDeviceConfigVersionsRequest) actualRequests.get(0)); - - Assert.assertEquals(name, actualRequest.getName()); - Assert.assertTrue( - channelProvider.isHeaderSent( - ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), - GaxGrpcProperties.getDefaultApiClientHeaderPattern())); - } - - @Test - public void listDeviceConfigVersionsExceptionTest2() throws Exception { - StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT); - mockDeviceManager.addException(exception); - - try { - String name = "name3373707"; - 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(); - mockDeviceManager.addResponse(expectedResponse); - - DeviceName name = DeviceName.of("[PROJECT]", "[LOCATION]", "[REGISTRY]", "[DEVICE]"); - - ListDeviceStatesResponse actualResponse = client.listDeviceStates(name); - Assert.assertEquals(expectedResponse, actualResponse); - - List actualRequests = mockDeviceManager.getRequests(); - Assert.assertEquals(1, actualRequests.size()); - ListDeviceStatesRequest actualRequest = ((ListDeviceStatesRequest) actualRequests.get(0)); - - Assert.assertEquals(name.toString(), actualRequest.getName()); - Assert.assertTrue( - channelProvider.isHeaderSent( - ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), - GaxGrpcProperties.getDefaultApiClientHeaderPattern())); - } - - @Test - public void listDeviceStatesExceptionTest() throws Exception { - StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT); - mockDeviceManager.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(); - mockDeviceManager.addResponse(expectedResponse); - - String name = "name3373707"; - - ListDeviceStatesResponse actualResponse = client.listDeviceStates(name); - Assert.assertEquals(expectedResponse, actualResponse); - - List actualRequests = mockDeviceManager.getRequests(); - Assert.assertEquals(1, actualRequests.size()); - ListDeviceStatesRequest actualRequest = ((ListDeviceStatesRequest) actualRequests.get(0)); - - Assert.assertEquals(name, actualRequest.getName()); - Assert.assertTrue( - channelProvider.isHeaderSent( - ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), - GaxGrpcProperties.getDefaultApiClientHeaderPattern())); - } - - @Test - public void listDeviceStatesExceptionTest2() throws Exception { - StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT); - mockDeviceManager.addException(exception); - - try { - String name = "name3373707"; - 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(); - mockDeviceManager.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 = mockDeviceManager.getRequests(); - Assert.assertEquals(1, actualRequests.size()); - SetIamPolicyRequest actualRequest = ((SetIamPolicyRequest) actualRequests.get(0)); - - Assert.assertEquals(resource.toString(), actualRequest.getResource()); - Assert.assertEquals(policy, actualRequest.getPolicy()); - Assert.assertTrue( - channelProvider.isHeaderSent( - ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), - GaxGrpcProperties.getDefaultApiClientHeaderPattern())); - } - - @Test - public void setIamPolicyExceptionTest() throws Exception { - StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT); - mockDeviceManager.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(); - mockDeviceManager.addResponse(expectedResponse); - - String resource = "resource-341064690"; - Policy policy = Policy.newBuilder().build(); - - Policy actualResponse = client.setIamPolicy(resource, policy); - Assert.assertEquals(expectedResponse, actualResponse); - - List actualRequests = mockDeviceManager.getRequests(); - Assert.assertEquals(1, actualRequests.size()); - SetIamPolicyRequest actualRequest = ((SetIamPolicyRequest) actualRequests.get(0)); - - Assert.assertEquals(resource, actualRequest.getResource()); - Assert.assertEquals(policy, actualRequest.getPolicy()); - Assert.assertTrue( - channelProvider.isHeaderSent( - ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), - GaxGrpcProperties.getDefaultApiClientHeaderPattern())); - } - - @Test - public void setIamPolicyExceptionTest2() throws Exception { - StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT); - mockDeviceManager.addException(exception); - - try { - String resource = "resource-341064690"; - 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(); - mockDeviceManager.addResponse(expectedResponse); - - ResourceName resource = RegistryName.of("[PROJECT]", "[LOCATION]", "[REGISTRY]"); - - Policy actualResponse = client.getIamPolicy(resource); - Assert.assertEquals(expectedResponse, actualResponse); - - List actualRequests = mockDeviceManager.getRequests(); - Assert.assertEquals(1, actualRequests.size()); - GetIamPolicyRequest actualRequest = ((GetIamPolicyRequest) actualRequests.get(0)); - - Assert.assertEquals(resource.toString(), actualRequest.getResource()); - Assert.assertTrue( - channelProvider.isHeaderSent( - ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), - GaxGrpcProperties.getDefaultApiClientHeaderPattern())); - } - - @Test - public void getIamPolicyExceptionTest() throws Exception { - StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT); - mockDeviceManager.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(); - mockDeviceManager.addResponse(expectedResponse); - - String resource = "resource-341064690"; - - Policy actualResponse = client.getIamPolicy(resource); - Assert.assertEquals(expectedResponse, actualResponse); - - List actualRequests = mockDeviceManager.getRequests(); - Assert.assertEquals(1, actualRequests.size()); - GetIamPolicyRequest actualRequest = ((GetIamPolicyRequest) actualRequests.get(0)); - - Assert.assertEquals(resource, actualRequest.getResource()); - Assert.assertTrue( - channelProvider.isHeaderSent( - ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), - GaxGrpcProperties.getDefaultApiClientHeaderPattern())); - } - - @Test - public void getIamPolicyExceptionTest2() throws Exception { - StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT); - mockDeviceManager.addException(exception); - - try { - String resource = "resource-341064690"; - 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(); - mockDeviceManager.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 = mockDeviceManager.getRequests(); - Assert.assertEquals(1, actualRequests.size()); - TestIamPermissionsRequest actualRequest = ((TestIamPermissionsRequest) actualRequests.get(0)); - - Assert.assertEquals(resource.toString(), actualRequest.getResource()); - Assert.assertEquals(permissions, actualRequest.getPermissionsList()); - Assert.assertTrue( - channelProvider.isHeaderSent( - ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), - GaxGrpcProperties.getDefaultApiClientHeaderPattern())); - } - - @Test - public void testIamPermissionsExceptionTest() throws Exception { - StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT); - mockDeviceManager.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(); - mockDeviceManager.addResponse(expectedResponse); - - String resource = "resource-341064690"; - List permissions = new ArrayList<>(); - - TestIamPermissionsResponse actualResponse = client.testIamPermissions(resource, permissions); - Assert.assertEquals(expectedResponse, actualResponse); - - List actualRequests = mockDeviceManager.getRequests(); - Assert.assertEquals(1, actualRequests.size()); - TestIamPermissionsRequest actualRequest = ((TestIamPermissionsRequest) actualRequests.get(0)); - - Assert.assertEquals(resource, actualRequest.getResource()); - Assert.assertEquals(permissions, actualRequest.getPermissionsList()); - Assert.assertTrue( - channelProvider.isHeaderSent( - ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), - GaxGrpcProperties.getDefaultApiClientHeaderPattern())); - } - - @Test - public void testIamPermissionsExceptionTest2() throws Exception { - StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT); - mockDeviceManager.addException(exception); - - try { - String resource = "resource-341064690"; - 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(); - mockDeviceManager.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 = mockDeviceManager.getRequests(); - Assert.assertEquals(1, actualRequests.size()); - SendCommandToDeviceRequest actualRequest = ((SendCommandToDeviceRequest) actualRequests.get(0)); - - Assert.assertEquals(name.toString(), actualRequest.getName()); - Assert.assertEquals(binaryData, actualRequest.getBinaryData()); - Assert.assertTrue( - channelProvider.isHeaderSent( - ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), - GaxGrpcProperties.getDefaultApiClientHeaderPattern())); - } - - @Test - public void sendCommandToDeviceExceptionTest() throws Exception { - StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT); - mockDeviceManager.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(); - mockDeviceManager.addResponse(expectedResponse); - - String name = "name3373707"; - ByteString binaryData = ByteString.EMPTY; - - SendCommandToDeviceResponse actualResponse = client.sendCommandToDevice(name, binaryData); - Assert.assertEquals(expectedResponse, actualResponse); - - List actualRequests = mockDeviceManager.getRequests(); - Assert.assertEquals(1, actualRequests.size()); - SendCommandToDeviceRequest actualRequest = ((SendCommandToDeviceRequest) actualRequests.get(0)); - - Assert.assertEquals(name, actualRequest.getName()); - Assert.assertEquals(binaryData, actualRequest.getBinaryData()); - Assert.assertTrue( - channelProvider.isHeaderSent( - ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), - GaxGrpcProperties.getDefaultApiClientHeaderPattern())); - } - - @Test - public void sendCommandToDeviceExceptionTest2() throws Exception { - StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT); - mockDeviceManager.addException(exception); - - try { - String name = "name3373707"; - 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(); - mockDeviceManager.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 = mockDeviceManager.getRequests(); - Assert.assertEquals(1, actualRequests.size()); - SendCommandToDeviceRequest actualRequest = ((SendCommandToDeviceRequest) actualRequests.get(0)); - - Assert.assertEquals(name.toString(), actualRequest.getName()); - Assert.assertEquals(binaryData, actualRequest.getBinaryData()); - Assert.assertEquals(subfolder, actualRequest.getSubfolder()); - Assert.assertTrue( - channelProvider.isHeaderSent( - ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), - GaxGrpcProperties.getDefaultApiClientHeaderPattern())); - } - - @Test - public void sendCommandToDeviceExceptionTest3() throws Exception { - StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT); - mockDeviceManager.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(); - mockDeviceManager.addResponse(expectedResponse); - - String name = "name3373707"; - ByteString binaryData = ByteString.EMPTY; - String subfolder = "subfolder153561774"; - - SendCommandToDeviceResponse actualResponse = - client.sendCommandToDevice(name, binaryData, subfolder); - Assert.assertEquals(expectedResponse, actualResponse); - - List actualRequests = mockDeviceManager.getRequests(); - Assert.assertEquals(1, actualRequests.size()); - SendCommandToDeviceRequest actualRequest = ((SendCommandToDeviceRequest) actualRequests.get(0)); - - Assert.assertEquals(name, actualRequest.getName()); - Assert.assertEquals(binaryData, actualRequest.getBinaryData()); - Assert.assertEquals(subfolder, actualRequest.getSubfolder()); - Assert.assertTrue( - channelProvider.isHeaderSent( - ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), - GaxGrpcProperties.getDefaultApiClientHeaderPattern())); - } - - @Test - public void sendCommandToDeviceExceptionTest4() throws Exception { - StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT); - mockDeviceManager.addException(exception); - - try { - String name = "name3373707"; - 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(); - mockDeviceManager.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 = mockDeviceManager.getRequests(); - Assert.assertEquals(1, actualRequests.size()); - BindDeviceToGatewayRequest actualRequest = ((BindDeviceToGatewayRequest) actualRequests.get(0)); - - Assert.assertEquals(parent.toString(), actualRequest.getParent()); - Assert.assertEquals(gatewayId, actualRequest.getGatewayId()); - Assert.assertEquals(deviceId, actualRequest.getDeviceId()); - Assert.assertTrue( - channelProvider.isHeaderSent( - ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), - GaxGrpcProperties.getDefaultApiClientHeaderPattern())); - } - - @Test - public void bindDeviceToGatewayExceptionTest() throws Exception { - StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT); - mockDeviceManager.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(); - mockDeviceManager.addResponse(expectedResponse); - - String parent = "parent-995424086"; - String gatewayId = "gatewayId-1354641793"; - String deviceId = "deviceId1109191185"; - - BindDeviceToGatewayResponse actualResponse = - client.bindDeviceToGateway(parent, gatewayId, deviceId); - Assert.assertEquals(expectedResponse, actualResponse); - - List actualRequests = mockDeviceManager.getRequests(); - Assert.assertEquals(1, actualRequests.size()); - BindDeviceToGatewayRequest actualRequest = ((BindDeviceToGatewayRequest) actualRequests.get(0)); - - Assert.assertEquals(parent, actualRequest.getParent()); - Assert.assertEquals(gatewayId, actualRequest.getGatewayId()); - Assert.assertEquals(deviceId, actualRequest.getDeviceId()); - Assert.assertTrue( - channelProvider.isHeaderSent( - ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), - GaxGrpcProperties.getDefaultApiClientHeaderPattern())); - } - - @Test - public void bindDeviceToGatewayExceptionTest2() throws Exception { - StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT); - mockDeviceManager.addException(exception); - - try { - String parent = "parent-995424086"; - 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(); - mockDeviceManager.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 = mockDeviceManager.getRequests(); - Assert.assertEquals(1, actualRequests.size()); - UnbindDeviceFromGatewayRequest actualRequest = - ((UnbindDeviceFromGatewayRequest) actualRequests.get(0)); - - Assert.assertEquals(parent.toString(), actualRequest.getParent()); - Assert.assertEquals(gatewayId, actualRequest.getGatewayId()); - Assert.assertEquals(deviceId, actualRequest.getDeviceId()); - Assert.assertTrue( - channelProvider.isHeaderSent( - ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), - GaxGrpcProperties.getDefaultApiClientHeaderPattern())); - } - - @Test - public void unbindDeviceFromGatewayExceptionTest() throws Exception { - StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT); - mockDeviceManager.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(); - mockDeviceManager.addResponse(expectedResponse); - - String parent = "parent-995424086"; - String gatewayId = "gatewayId-1354641793"; - String deviceId = "deviceId1109191185"; - - UnbindDeviceFromGatewayResponse actualResponse = - client.unbindDeviceFromGateway(parent, gatewayId, deviceId); - Assert.assertEquals(expectedResponse, actualResponse); - - List actualRequests = mockDeviceManager.getRequests(); - Assert.assertEquals(1, actualRequests.size()); - UnbindDeviceFromGatewayRequest actualRequest = - ((UnbindDeviceFromGatewayRequest) actualRequests.get(0)); - - Assert.assertEquals(parent, actualRequest.getParent()); - Assert.assertEquals(gatewayId, actualRequest.getGatewayId()); - Assert.assertEquals(deviceId, actualRequest.getDeviceId()); - Assert.assertTrue( - channelProvider.isHeaderSent( - ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), - GaxGrpcProperties.getDefaultApiClientHeaderPattern())); - } - - @Test - public void unbindDeviceFromGatewayExceptionTest2() throws Exception { - StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT); - mockDeviceManager.addException(exception); - - try { - String parent = "parent-995424086"; - 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/google-cloud-iot/src/test/java/com/google/cloud/iot/v1/MockDeviceManager.java b/google-cloud-iot/src/test/java/com/google/cloud/iot/v1/MockDeviceManager.java deleted file mode 100644 index 5da71a7a..00000000 --- a/google-cloud-iot/src/test/java/com/google/cloud/iot/v1/MockDeviceManager.java +++ /dev/null @@ -1,59 +0,0 @@ -/* - * 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 com.google.api.core.BetaApi; -import com.google.api.gax.grpc.testing.MockGrpcService; -import com.google.protobuf.AbstractMessage; -import io.grpc.ServerServiceDefinition; -import java.util.List; -import javax.annotation.Generated; - -@BetaApi -@Generated("by gapic-generator-java") -public class MockDeviceManager implements MockGrpcService { - private final MockDeviceManagerImpl serviceImpl; - - public MockDeviceManager() { - serviceImpl = new MockDeviceManagerImpl(); - } - - @Override - public List getRequests() { - return serviceImpl.getRequests(); - } - - @Override - public void addResponse(AbstractMessage response) { - serviceImpl.addResponse(response); - } - - @Override - public void addException(Exception exception) { - serviceImpl.addException(exception); - } - - @Override - public ServerServiceDefinition getServiceDefinition() { - return serviceImpl.bindService(); - } - - @Override - public void reset() { - serviceImpl.reset(); - } -} diff --git a/google-cloud-iot/src/test/java/com/google/cloud/iot/v1/MockDeviceManagerImpl.java b/google-cloud-iot/src/test/java/com/google/cloud/iot/v1/MockDeviceManagerImpl.java deleted file mode 100644 index f137ef47..00000000 --- a/google-cloud-iot/src/test/java/com/google/cloud/iot/v1/MockDeviceManagerImpl.java +++ /dev/null @@ -1,465 +0,0 @@ -/* - * 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 com.google.api.core.BetaApi; -import com.google.cloud.iot.v1.DeviceManagerGrpc.DeviceManagerImplBase; -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.AbstractMessage; -import com.google.protobuf.Empty; -import io.grpc.stub.StreamObserver; -import java.util.ArrayList; -import java.util.LinkedList; -import java.util.List; -import java.util.Queue; -import javax.annotation.Generated; - -@BetaApi -@Generated("by gapic-generator-java") -public class MockDeviceManagerImpl extends DeviceManagerImplBase { - private List requests; - private Queue responses; - - public MockDeviceManagerImpl() { - requests = new ArrayList<>(); - responses = new LinkedList<>(); - } - - public List getRequests() { - return requests; - } - - public void addResponse(AbstractMessage response) { - responses.add(response); - } - - public void setResponses(List responses) { - this.responses = new LinkedList(responses); - } - - public void addException(Exception exception) { - responses.add(exception); - } - - public void reset() { - requests = new ArrayList<>(); - responses = new LinkedList<>(); - } - - @Override - public void createDeviceRegistry( - CreateDeviceRegistryRequest request, StreamObserver responseObserver) { - Object response = responses.poll(); - if (response instanceof DeviceRegistry) { - requests.add(request); - responseObserver.onNext(((DeviceRegistry) response)); - responseObserver.onCompleted(); - } else if (response instanceof Exception) { - responseObserver.onError(((Exception) response)); - } else { - responseObserver.onError( - new IllegalArgumentException( - String.format( - "Unrecognized response type %s for method CreateDeviceRegistry, expected %s or %s", - response == null ? "null" : response.getClass().getName(), - DeviceRegistry.class.getName(), - Exception.class.getName()))); - } - } - - @Override - public void getDeviceRegistry( - GetDeviceRegistryRequest request, StreamObserver responseObserver) { - Object response = responses.poll(); - if (response instanceof DeviceRegistry) { - requests.add(request); - responseObserver.onNext(((DeviceRegistry) response)); - responseObserver.onCompleted(); - } else if (response instanceof Exception) { - responseObserver.onError(((Exception) response)); - } else { - responseObserver.onError( - new IllegalArgumentException( - String.format( - "Unrecognized response type %s for method GetDeviceRegistry, expected %s or %s", - response == null ? "null" : response.getClass().getName(), - DeviceRegistry.class.getName(), - Exception.class.getName()))); - } - } - - @Override - public void updateDeviceRegistry( - UpdateDeviceRegistryRequest request, StreamObserver responseObserver) { - Object response = responses.poll(); - if (response instanceof DeviceRegistry) { - requests.add(request); - responseObserver.onNext(((DeviceRegistry) response)); - responseObserver.onCompleted(); - } else if (response instanceof Exception) { - responseObserver.onError(((Exception) response)); - } else { - responseObserver.onError( - new IllegalArgumentException( - String.format( - "Unrecognized response type %s for method UpdateDeviceRegistry, expected %s or %s", - response == null ? "null" : response.getClass().getName(), - DeviceRegistry.class.getName(), - Exception.class.getName()))); - } - } - - @Override - public void deleteDeviceRegistry( - DeleteDeviceRegistryRequest request, StreamObserver responseObserver) { - Object response = responses.poll(); - if (response instanceof Empty) { - requests.add(request); - responseObserver.onNext(((Empty) response)); - responseObserver.onCompleted(); - } else if (response instanceof Exception) { - responseObserver.onError(((Exception) response)); - } else { - responseObserver.onError( - new IllegalArgumentException( - String.format( - "Unrecognized response type %s for method DeleteDeviceRegistry, expected %s or %s", - response == null ? "null" : response.getClass().getName(), - Empty.class.getName(), - Exception.class.getName()))); - } - } - - @Override - public void listDeviceRegistries( - ListDeviceRegistriesRequest request, - StreamObserver responseObserver) { - Object response = responses.poll(); - if (response instanceof ListDeviceRegistriesResponse) { - requests.add(request); - responseObserver.onNext(((ListDeviceRegistriesResponse) response)); - responseObserver.onCompleted(); - } else if (response instanceof Exception) { - responseObserver.onError(((Exception) response)); - } else { - responseObserver.onError( - new IllegalArgumentException( - String.format( - "Unrecognized response type %s for method ListDeviceRegistries, expected %s or %s", - response == null ? "null" : response.getClass().getName(), - ListDeviceRegistriesResponse.class.getName(), - Exception.class.getName()))); - } - } - - @Override - public void createDevice(CreateDeviceRequest request, StreamObserver responseObserver) { - Object response = responses.poll(); - if (response instanceof Device) { - requests.add(request); - responseObserver.onNext(((Device) response)); - responseObserver.onCompleted(); - } else if (response instanceof Exception) { - responseObserver.onError(((Exception) response)); - } else { - responseObserver.onError( - new IllegalArgumentException( - String.format( - "Unrecognized response type %s for method CreateDevice, expected %s or %s", - response == null ? "null" : response.getClass().getName(), - Device.class.getName(), - Exception.class.getName()))); - } - } - - @Override - public void getDevice(GetDeviceRequest request, StreamObserver responseObserver) { - Object response = responses.poll(); - if (response instanceof Device) { - requests.add(request); - responseObserver.onNext(((Device) response)); - responseObserver.onCompleted(); - } else if (response instanceof Exception) { - responseObserver.onError(((Exception) response)); - } else { - responseObserver.onError( - new IllegalArgumentException( - String.format( - "Unrecognized response type %s for method GetDevice, expected %s or %s", - response == null ? "null" : response.getClass().getName(), - Device.class.getName(), - Exception.class.getName()))); - } - } - - @Override - public void updateDevice(UpdateDeviceRequest request, StreamObserver responseObserver) { - Object response = responses.poll(); - if (response instanceof Device) { - requests.add(request); - responseObserver.onNext(((Device) response)); - responseObserver.onCompleted(); - } else if (response instanceof Exception) { - responseObserver.onError(((Exception) response)); - } else { - responseObserver.onError( - new IllegalArgumentException( - String.format( - "Unrecognized response type %s for method UpdateDevice, expected %s or %s", - response == null ? "null" : response.getClass().getName(), - Device.class.getName(), - Exception.class.getName()))); - } - } - - @Override - public void deleteDevice(DeleteDeviceRequest request, StreamObserver responseObserver) { - Object response = responses.poll(); - if (response instanceof Empty) { - requests.add(request); - responseObserver.onNext(((Empty) response)); - responseObserver.onCompleted(); - } else if (response instanceof Exception) { - responseObserver.onError(((Exception) response)); - } else { - responseObserver.onError( - new IllegalArgumentException( - String.format( - "Unrecognized response type %s for method DeleteDevice, expected %s or %s", - response == null ? "null" : response.getClass().getName(), - Empty.class.getName(), - Exception.class.getName()))); - } - } - - @Override - public void listDevices( - ListDevicesRequest request, StreamObserver responseObserver) { - Object response = responses.poll(); - if (response instanceof ListDevicesResponse) { - requests.add(request); - responseObserver.onNext(((ListDevicesResponse) response)); - responseObserver.onCompleted(); - } else if (response instanceof Exception) { - responseObserver.onError(((Exception) response)); - } else { - responseObserver.onError( - new IllegalArgumentException( - String.format( - "Unrecognized response type %s for method ListDevices, expected %s or %s", - response == null ? "null" : response.getClass().getName(), - ListDevicesResponse.class.getName(), - Exception.class.getName()))); - } - } - - @Override - public void modifyCloudToDeviceConfig( - ModifyCloudToDeviceConfigRequest request, StreamObserver responseObserver) { - Object response = responses.poll(); - if (response instanceof DeviceConfig) { - requests.add(request); - responseObserver.onNext(((DeviceConfig) response)); - responseObserver.onCompleted(); - } else if (response instanceof Exception) { - responseObserver.onError(((Exception) response)); - } else { - responseObserver.onError( - new IllegalArgumentException( - String.format( - "Unrecognized response type %s for method ModifyCloudToDeviceConfig, expected %s or %s", - response == null ? "null" : response.getClass().getName(), - DeviceConfig.class.getName(), - Exception.class.getName()))); - } - } - - @Override - public void listDeviceConfigVersions( - ListDeviceConfigVersionsRequest request, - StreamObserver responseObserver) { - Object response = responses.poll(); - if (response instanceof ListDeviceConfigVersionsResponse) { - requests.add(request); - responseObserver.onNext(((ListDeviceConfigVersionsResponse) response)); - responseObserver.onCompleted(); - } else if (response instanceof Exception) { - responseObserver.onError(((Exception) response)); - } else { - responseObserver.onError( - new IllegalArgumentException( - String.format( - "Unrecognized response type %s for method ListDeviceConfigVersions, expected %s or %s", - response == null ? "null" : response.getClass().getName(), - ListDeviceConfigVersionsResponse.class.getName(), - Exception.class.getName()))); - } - } - - @Override - public void listDeviceStates( - ListDeviceStatesRequest request, StreamObserver responseObserver) { - Object response = responses.poll(); - if (response instanceof ListDeviceStatesResponse) { - requests.add(request); - responseObserver.onNext(((ListDeviceStatesResponse) response)); - responseObserver.onCompleted(); - } else if (response instanceof Exception) { - responseObserver.onError(((Exception) response)); - } else { - responseObserver.onError( - new IllegalArgumentException( - String.format( - "Unrecognized response type %s for method ListDeviceStates, expected %s or %s", - response == null ? "null" : response.getClass().getName(), - ListDeviceStatesResponse.class.getName(), - Exception.class.getName()))); - } - } - - @Override - public void setIamPolicy(SetIamPolicyRequest request, StreamObserver responseObserver) { - Object response = responses.poll(); - if (response instanceof Policy) { - requests.add(request); - responseObserver.onNext(((Policy) response)); - responseObserver.onCompleted(); - } else if (response instanceof Exception) { - responseObserver.onError(((Exception) response)); - } else { - responseObserver.onError( - new IllegalArgumentException( - String.format( - "Unrecognized response type %s for method SetIamPolicy, expected %s or %s", - response == null ? "null" : response.getClass().getName(), - Policy.class.getName(), - Exception.class.getName()))); - } - } - - @Override - public void getIamPolicy(GetIamPolicyRequest request, StreamObserver responseObserver) { - Object response = responses.poll(); - if (response instanceof Policy) { - requests.add(request); - responseObserver.onNext(((Policy) response)); - responseObserver.onCompleted(); - } else if (response instanceof Exception) { - responseObserver.onError(((Exception) response)); - } else { - responseObserver.onError( - new IllegalArgumentException( - String.format( - "Unrecognized response type %s for method GetIamPolicy, expected %s or %s", - response == null ? "null" : response.getClass().getName(), - Policy.class.getName(), - Exception.class.getName()))); - } - } - - @Override - public void testIamPermissions( - TestIamPermissionsRequest request, - StreamObserver responseObserver) { - Object response = responses.poll(); - if (response instanceof TestIamPermissionsResponse) { - requests.add(request); - responseObserver.onNext(((TestIamPermissionsResponse) response)); - responseObserver.onCompleted(); - } else if (response instanceof Exception) { - responseObserver.onError(((Exception) response)); - } else { - responseObserver.onError( - new IllegalArgumentException( - String.format( - "Unrecognized response type %s for method TestIamPermissions, expected %s or %s", - response == null ? "null" : response.getClass().getName(), - TestIamPermissionsResponse.class.getName(), - Exception.class.getName()))); - } - } - - @Override - public void sendCommandToDevice( - SendCommandToDeviceRequest request, - StreamObserver responseObserver) { - Object response = responses.poll(); - if (response instanceof SendCommandToDeviceResponse) { - requests.add(request); - responseObserver.onNext(((SendCommandToDeviceResponse) response)); - responseObserver.onCompleted(); - } else if (response instanceof Exception) { - responseObserver.onError(((Exception) response)); - } else { - responseObserver.onError( - new IllegalArgumentException( - String.format( - "Unrecognized response type %s for method SendCommandToDevice, expected %s or %s", - response == null ? "null" : response.getClass().getName(), - SendCommandToDeviceResponse.class.getName(), - Exception.class.getName()))); - } - } - - @Override - public void bindDeviceToGateway( - BindDeviceToGatewayRequest request, - StreamObserver responseObserver) { - Object response = responses.poll(); - if (response instanceof BindDeviceToGatewayResponse) { - requests.add(request); - responseObserver.onNext(((BindDeviceToGatewayResponse) response)); - responseObserver.onCompleted(); - } else if (response instanceof Exception) { - responseObserver.onError(((Exception) response)); - } else { - responseObserver.onError( - new IllegalArgumentException( - String.format( - "Unrecognized response type %s for method BindDeviceToGateway, expected %s or %s", - response == null ? "null" : response.getClass().getName(), - BindDeviceToGatewayResponse.class.getName(), - Exception.class.getName()))); - } - } - - @Override - public void unbindDeviceFromGateway( - UnbindDeviceFromGatewayRequest request, - StreamObserver responseObserver) { - Object response = responses.poll(); - if (response instanceof UnbindDeviceFromGatewayResponse) { - requests.add(request); - responseObserver.onNext(((UnbindDeviceFromGatewayResponse) response)); - responseObserver.onCompleted(); - } else if (response instanceof Exception) { - responseObserver.onError(((Exception) response)); - } else { - responseObserver.onError( - new IllegalArgumentException( - String.format( - "Unrecognized response type %s for method UnbindDeviceFromGateway, expected %s or %s", - response == null ? "null" : response.getClass().getName(), - UnbindDeviceFromGatewayResponse.class.getName(), - Exception.class.getName()))); - } - } -} diff --git a/google-cloud-iot/src/test/java/com/google/cloud/iot/v1/it/ITSystemTest.java b/google-cloud-iot/src/test/java/com/google/cloud/iot/v1/it/ITSystemTest.java deleted file mode 100644 index 0c683327..00000000 --- a/google-cloud-iot/src/test/java/com/google/cloud/iot/v1/it/ITSystemTest.java +++ /dev/null @@ -1,178 +0,0 @@ -/* - * Copyright 2019 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.it; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; - -import com.google.cloud.ServiceOptions; -import com.google.cloud.iot.v1.Device; -import com.google.cloud.iot.v1.DeviceConfig; -import com.google.cloud.iot.v1.DeviceManagerClient; -import com.google.cloud.iot.v1.DeviceManagerClient.ListDeviceRegistriesPagedResponse; -import com.google.cloud.iot.v1.DeviceManagerClient.ListDevicesPagedResponse; -import com.google.cloud.iot.v1.DeviceName; -import com.google.cloud.iot.v1.DeviceRegistry; -import com.google.cloud.iot.v1.DeviceState; -import com.google.cloud.iot.v1.GatewayAuthMethod; -import com.google.cloud.iot.v1.GatewayConfig; -import com.google.cloud.iot.v1.HttpConfig; -import com.google.cloud.iot.v1.HttpState; -import com.google.cloud.iot.v1.ListDeviceConfigVersionsResponse; -import com.google.cloud.iot.v1.ListDeviceStatesResponse; -import com.google.cloud.iot.v1.LocationName; -import com.google.cloud.iot.v1.MqttConfig; -import com.google.cloud.iot.v1.MqttState; -import com.google.cloud.iot.v1.RegistryName; -import com.google.common.collect.Lists; -import com.google.iam.v1.Policy; -import com.google.protobuf.ByteString; -import java.util.List; -import java.util.UUID; -import org.junit.AfterClass; -import org.junit.BeforeClass; -import org.junit.Test; - -public class ITSystemTest { - - private static DeviceManagerClient client; - private static DeviceRegistry deviceRegistry; - private static Device device; - - private static final String PROJECT_ID = ServiceOptions.getDefaultProjectId(); - private static final String LOCATION = "us-central1"; - private static final String REGISTRY_ID = "test" + UUID.randomUUID().toString().substring(0, 8); - private static final RegistryName REGISTRY_NAME = - RegistryName.of(PROJECT_ID, LOCATION, REGISTRY_ID); - private static final LocationName PARENT = LocationName.of(PROJECT_ID, LOCATION); - private static final MqttConfig MQTT_CONFIG = - MqttConfig.newBuilder().setMqttEnabledState(MqttState.MQTT_ENABLED).build(); - private static final HttpConfig HTTP_CONFIG = - HttpConfig.newBuilder().setHttpEnabledState(HttpState.HTTP_ENABLED).build(); - private static final DeviceRegistry DEVICE_REGISTRY = - DeviceRegistry.newBuilder() - .setId(REGISTRY_ID) - .setMqttConfig(MQTT_CONFIG) - .setHttpConfig(HTTP_CONFIG) - .build(); - private static final String DEVICE_ID = - "test-device-" + UUID.randomUUID().toString().substring(0, 8); - private static final DeviceName DEVICE_NAME = - DeviceName.of(PROJECT_ID, LOCATION, REGISTRY_ID, DEVICE_ID); - private static final DeviceState DEVICE_STATE = - DeviceState.newBuilder().setBinaryData(ByteString.EMPTY).build(); - private static final boolean BLOCKED = true; - private static final GatewayConfig GATEWAY_CONFIG = - GatewayConfig.newBuilder() - .setGatewayAuthMethod(GatewayAuthMethod.ASSOCIATION_AND_DEVICE_AUTH_TOKEN) - .build(); - private static final Device DEVICE = - Device.newBuilder() - .setId(DEVICE_ID) - .setBlocked(BLOCKED) - .setGatewayConfig(GATEWAY_CONFIG) - .setState(DEVICE_STATE) - .build(); - - @BeforeClass - public static void beforeTest() throws Exception { - client = DeviceManagerClient.create(); - deviceRegistry = client.createDeviceRegistry(PARENT, DEVICE_REGISTRY); - if (deviceRegistry != null) { - RegistryName parent = RegistryName.of(PROJECT_ID, LOCATION, REGISTRY_ID); - device = client.createDevice(parent, DEVICE); - } - } - - @AfterClass - public static void afterTest() { - if (device != null) { - client.deleteDevice(DEVICE_NAME); - } - if (deviceRegistry != null) { - client.deleteDeviceRegistry(REGISTRY_NAME); - } - client.close(); - } - - @Test - public void getDeviceRegistryTest() { - DeviceRegistry registry = client.getDeviceRegistry(REGISTRY_NAME); - assertEquals(REGISTRY_ID, registry.getId()); - assertEquals(MQTT_CONFIG, registry.getMqttConfig()); - assertEquals(HTTP_CONFIG, registry.getHttpConfig()); - } - - @Test - public void listDeviceRegistryTest() { - ListDeviceRegistriesPagedResponse pagedListResponse = client.listDeviceRegistries(PARENT); - List resources = Lists.newArrayList(pagedListResponse.iterateAll()); - for (DeviceRegistry registry : resources) { - if (registry.equals(REGISTRY_ID)) { - assertEquals(REGISTRY_ID, registry.getId()); - assertEquals(MQTT_CONFIG, registry.getMqttConfig()); - assertEquals(HTTP_CONFIG, registry.getHttpConfig()); - } - } - } - - @Test - public void getDeviceTest() { - Device device = client.getDevice(DEVICE_NAME); - assertEquals(DEVICE_ID, device.getId()); - assertEquals(BLOCKED, device.getBlocked()); - assertEquals(GATEWAY_CONFIG, device.getGatewayConfig()); - } - - @Test - public void listDeviceTest() { - ListDevicesPagedResponse listDevices = client.listDevices(REGISTRY_NAME); - List devices = Lists.newArrayList(listDevices.iterateAll()); - assertEquals(1, devices.size()); - for (Device device : devices) { - if (device.equals(DEVICE_ID)) { - assertEquals(DEVICE_ID, device.getId()); - assertEquals(BLOCKED, device.getBlocked()); - assertEquals(GATEWAY_CONFIG, device.getGatewayConfig()); - } - } - } - - @Test - public void listDeviceStatesTest() { - ListDeviceStatesResponse deviceStates = client.listDeviceStates(DEVICE_NAME); - List devices = deviceStates.getDeviceStatesList(); - assertEquals(0, devices.size()); - } - - @Test - public void listDeviceConfigVersionsTest() { - ListDeviceConfigVersionsResponse deviceConfigVersions = - client.listDeviceConfigVersions(DEVICE_NAME); - List devicesConfigs = deviceConfigVersions.getDeviceConfigsList(); - assertEquals(1, devicesConfigs.size()); - for (DeviceConfig devicesConfig : devicesConfigs) { - assertEquals(1, devicesConfig.getVersion()); - } - } - - @Test - public void getIamPolicyTest() { - Policy policy = client.getIamPolicy(REGISTRY_NAME); - assertNotNull(policy); - assertEquals(0, policy.getVersion()); - } -} diff --git a/grpc-google-cloud-iot-v1/pom.xml b/grpc-google-cloud-iot-v1/pom.xml deleted file mode 100644 index 11787888..00000000 --- a/grpc-google-cloud-iot-v1/pom.xml +++ /dev/null @@ -1,69 +0,0 @@ - - 4.0.0 - com.google.api.grpc - grpc-google-cloud-iot-v1 - 2.3.5 - grpc-google-cloud-iot-v1 - GRPC library for grpc-google-cloud-iot-v1 - - com.google.cloud - google-cloud-iot-parent - 2.3.5 - - - - io.grpc - grpc-api - - - io.grpc - grpc-stub - - - io.grpc - grpc-protobuf - - - com.google.protobuf - protobuf-java - - - com.google.api.grpc - proto-google-cloud-iot-v1 - - - com.google.api.grpc - proto-google-iam-v1 - - - com.google.guava - guava - - - - - - java9 - - [9,) - - - - javax.annotation - javax.annotation-api - - - - - - - - - org.codehaus.mojo - flatten-maven-plugin - - - - \ No newline at end of file diff --git a/grpc-google-cloud-iot-v1/src/main/java/com/google/cloud/iot/v1/DeviceManagerGrpc.java b/grpc-google-cloud-iot-v1/src/main/java/com/google/cloud/iot/v1/DeviceManagerGrpc.java deleted file mode 100644 index 81c87170..00000000 --- a/grpc-google-cloud-iot-v1/src/main/java/com/google/cloud/iot/v1/DeviceManagerGrpc.java +++ /dev/null @@ -1,2533 +0,0 @@ -/* - * Copyright 2020 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 io.grpc.MethodDescriptor.generateFullMethodName; - -/** - * - * - *
- * Internet of Things (IoT) service. Securely connect and manage IoT devices.
- * 
- */ -@javax.annotation.Generated( - value = "by gRPC proto compiler", - comments = "Source: google/cloud/iot/v1/device_manager.proto") -@io.grpc.stub.annotations.GrpcGenerated -public final class DeviceManagerGrpc { - - private DeviceManagerGrpc() {} - - public static final String SERVICE_NAME = "google.cloud.iot.v1.DeviceManager"; - - // Static method descriptors that strictly reflect the proto. - private static volatile io.grpc.MethodDescriptor< - com.google.cloud.iot.v1.CreateDeviceRegistryRequest, - com.google.cloud.iot.v1.DeviceRegistry> - getCreateDeviceRegistryMethod; - - @io.grpc.stub.annotations.RpcMethod( - fullMethodName = SERVICE_NAME + '/' + "CreateDeviceRegistry", - requestType = com.google.cloud.iot.v1.CreateDeviceRegistryRequest.class, - responseType = com.google.cloud.iot.v1.DeviceRegistry.class, - methodType = io.grpc.MethodDescriptor.MethodType.UNARY) - public static io.grpc.MethodDescriptor< - com.google.cloud.iot.v1.CreateDeviceRegistryRequest, - com.google.cloud.iot.v1.DeviceRegistry> - getCreateDeviceRegistryMethod() { - io.grpc.MethodDescriptor< - com.google.cloud.iot.v1.CreateDeviceRegistryRequest, - com.google.cloud.iot.v1.DeviceRegistry> - getCreateDeviceRegistryMethod; - if ((getCreateDeviceRegistryMethod = DeviceManagerGrpc.getCreateDeviceRegistryMethod) == null) { - synchronized (DeviceManagerGrpc.class) { - if ((getCreateDeviceRegistryMethod = DeviceManagerGrpc.getCreateDeviceRegistryMethod) - == null) { - DeviceManagerGrpc.getCreateDeviceRegistryMethod = - getCreateDeviceRegistryMethod = - io.grpc.MethodDescriptor - . - newBuilder() - .setType(io.grpc.MethodDescriptor.MethodType.UNARY) - .setFullMethodName( - generateFullMethodName(SERVICE_NAME, "CreateDeviceRegistry")) - .setSampledToLocalTracing(true) - .setRequestMarshaller( - io.grpc.protobuf.ProtoUtils.marshaller( - com.google.cloud.iot.v1.CreateDeviceRegistryRequest - .getDefaultInstance())) - .setResponseMarshaller( - io.grpc.protobuf.ProtoUtils.marshaller( - com.google.cloud.iot.v1.DeviceRegistry.getDefaultInstance())) - .setSchemaDescriptor( - new DeviceManagerMethodDescriptorSupplier("CreateDeviceRegistry")) - .build(); - } - } - } - return getCreateDeviceRegistryMethod; - } - - private static volatile io.grpc.MethodDescriptor< - com.google.cloud.iot.v1.GetDeviceRegistryRequest, com.google.cloud.iot.v1.DeviceRegistry> - getGetDeviceRegistryMethod; - - @io.grpc.stub.annotations.RpcMethod( - fullMethodName = SERVICE_NAME + '/' + "GetDeviceRegistry", - requestType = com.google.cloud.iot.v1.GetDeviceRegistryRequest.class, - responseType = com.google.cloud.iot.v1.DeviceRegistry.class, - methodType = io.grpc.MethodDescriptor.MethodType.UNARY) - public static io.grpc.MethodDescriptor< - com.google.cloud.iot.v1.GetDeviceRegistryRequest, com.google.cloud.iot.v1.DeviceRegistry> - getGetDeviceRegistryMethod() { - io.grpc.MethodDescriptor< - com.google.cloud.iot.v1.GetDeviceRegistryRequest, - com.google.cloud.iot.v1.DeviceRegistry> - getGetDeviceRegistryMethod; - if ((getGetDeviceRegistryMethod = DeviceManagerGrpc.getGetDeviceRegistryMethod) == null) { - synchronized (DeviceManagerGrpc.class) { - if ((getGetDeviceRegistryMethod = DeviceManagerGrpc.getGetDeviceRegistryMethod) == null) { - DeviceManagerGrpc.getGetDeviceRegistryMethod = - getGetDeviceRegistryMethod = - io.grpc.MethodDescriptor - . - newBuilder() - .setType(io.grpc.MethodDescriptor.MethodType.UNARY) - .setFullMethodName(generateFullMethodName(SERVICE_NAME, "GetDeviceRegistry")) - .setSampledToLocalTracing(true) - .setRequestMarshaller( - io.grpc.protobuf.ProtoUtils.marshaller( - com.google.cloud.iot.v1.GetDeviceRegistryRequest - .getDefaultInstance())) - .setResponseMarshaller( - io.grpc.protobuf.ProtoUtils.marshaller( - com.google.cloud.iot.v1.DeviceRegistry.getDefaultInstance())) - .setSchemaDescriptor( - new DeviceManagerMethodDescriptorSupplier("GetDeviceRegistry")) - .build(); - } - } - } - return getGetDeviceRegistryMethod; - } - - private static volatile io.grpc.MethodDescriptor< - com.google.cloud.iot.v1.UpdateDeviceRegistryRequest, - com.google.cloud.iot.v1.DeviceRegistry> - getUpdateDeviceRegistryMethod; - - @io.grpc.stub.annotations.RpcMethod( - fullMethodName = SERVICE_NAME + '/' + "UpdateDeviceRegistry", - requestType = com.google.cloud.iot.v1.UpdateDeviceRegistryRequest.class, - responseType = com.google.cloud.iot.v1.DeviceRegistry.class, - methodType = io.grpc.MethodDescriptor.MethodType.UNARY) - public static io.grpc.MethodDescriptor< - com.google.cloud.iot.v1.UpdateDeviceRegistryRequest, - com.google.cloud.iot.v1.DeviceRegistry> - getUpdateDeviceRegistryMethod() { - io.grpc.MethodDescriptor< - com.google.cloud.iot.v1.UpdateDeviceRegistryRequest, - com.google.cloud.iot.v1.DeviceRegistry> - getUpdateDeviceRegistryMethod; - if ((getUpdateDeviceRegistryMethod = DeviceManagerGrpc.getUpdateDeviceRegistryMethod) == null) { - synchronized (DeviceManagerGrpc.class) { - if ((getUpdateDeviceRegistryMethod = DeviceManagerGrpc.getUpdateDeviceRegistryMethod) - == null) { - DeviceManagerGrpc.getUpdateDeviceRegistryMethod = - getUpdateDeviceRegistryMethod = - io.grpc.MethodDescriptor - . - newBuilder() - .setType(io.grpc.MethodDescriptor.MethodType.UNARY) - .setFullMethodName( - generateFullMethodName(SERVICE_NAME, "UpdateDeviceRegistry")) - .setSampledToLocalTracing(true) - .setRequestMarshaller( - io.grpc.protobuf.ProtoUtils.marshaller( - com.google.cloud.iot.v1.UpdateDeviceRegistryRequest - .getDefaultInstance())) - .setResponseMarshaller( - io.grpc.protobuf.ProtoUtils.marshaller( - com.google.cloud.iot.v1.DeviceRegistry.getDefaultInstance())) - .setSchemaDescriptor( - new DeviceManagerMethodDescriptorSupplier("UpdateDeviceRegistry")) - .build(); - } - } - } - return getUpdateDeviceRegistryMethod; - } - - private static volatile io.grpc.MethodDescriptor< - com.google.cloud.iot.v1.DeleteDeviceRegistryRequest, com.google.protobuf.Empty> - getDeleteDeviceRegistryMethod; - - @io.grpc.stub.annotations.RpcMethod( - fullMethodName = SERVICE_NAME + '/' + "DeleteDeviceRegistry", - requestType = com.google.cloud.iot.v1.DeleteDeviceRegistryRequest.class, - responseType = com.google.protobuf.Empty.class, - methodType = io.grpc.MethodDescriptor.MethodType.UNARY) - public static io.grpc.MethodDescriptor< - com.google.cloud.iot.v1.DeleteDeviceRegistryRequest, com.google.protobuf.Empty> - getDeleteDeviceRegistryMethod() { - io.grpc.MethodDescriptor< - com.google.cloud.iot.v1.DeleteDeviceRegistryRequest, com.google.protobuf.Empty> - getDeleteDeviceRegistryMethod; - if ((getDeleteDeviceRegistryMethod = DeviceManagerGrpc.getDeleteDeviceRegistryMethod) == null) { - synchronized (DeviceManagerGrpc.class) { - if ((getDeleteDeviceRegistryMethod = DeviceManagerGrpc.getDeleteDeviceRegistryMethod) - == null) { - DeviceManagerGrpc.getDeleteDeviceRegistryMethod = - getDeleteDeviceRegistryMethod = - io.grpc.MethodDescriptor - . - newBuilder() - .setType(io.grpc.MethodDescriptor.MethodType.UNARY) - .setFullMethodName( - generateFullMethodName(SERVICE_NAME, "DeleteDeviceRegistry")) - .setSampledToLocalTracing(true) - .setRequestMarshaller( - io.grpc.protobuf.ProtoUtils.marshaller( - com.google.cloud.iot.v1.DeleteDeviceRegistryRequest - .getDefaultInstance())) - .setResponseMarshaller( - io.grpc.protobuf.ProtoUtils.marshaller( - com.google.protobuf.Empty.getDefaultInstance())) - .setSchemaDescriptor( - new DeviceManagerMethodDescriptorSupplier("DeleteDeviceRegistry")) - .build(); - } - } - } - return getDeleteDeviceRegistryMethod; - } - - private static volatile io.grpc.MethodDescriptor< - com.google.cloud.iot.v1.ListDeviceRegistriesRequest, - com.google.cloud.iot.v1.ListDeviceRegistriesResponse> - getListDeviceRegistriesMethod; - - @io.grpc.stub.annotations.RpcMethod( - fullMethodName = SERVICE_NAME + '/' + "ListDeviceRegistries", - requestType = com.google.cloud.iot.v1.ListDeviceRegistriesRequest.class, - responseType = com.google.cloud.iot.v1.ListDeviceRegistriesResponse.class, - methodType = io.grpc.MethodDescriptor.MethodType.UNARY) - public static io.grpc.MethodDescriptor< - com.google.cloud.iot.v1.ListDeviceRegistriesRequest, - com.google.cloud.iot.v1.ListDeviceRegistriesResponse> - getListDeviceRegistriesMethod() { - io.grpc.MethodDescriptor< - com.google.cloud.iot.v1.ListDeviceRegistriesRequest, - com.google.cloud.iot.v1.ListDeviceRegistriesResponse> - getListDeviceRegistriesMethod; - if ((getListDeviceRegistriesMethod = DeviceManagerGrpc.getListDeviceRegistriesMethod) == null) { - synchronized (DeviceManagerGrpc.class) { - if ((getListDeviceRegistriesMethod = DeviceManagerGrpc.getListDeviceRegistriesMethod) - == null) { - DeviceManagerGrpc.getListDeviceRegistriesMethod = - getListDeviceRegistriesMethod = - io.grpc.MethodDescriptor - . - newBuilder() - .setType(io.grpc.MethodDescriptor.MethodType.UNARY) - .setFullMethodName( - generateFullMethodName(SERVICE_NAME, "ListDeviceRegistries")) - .setSampledToLocalTracing(true) - .setRequestMarshaller( - io.grpc.protobuf.ProtoUtils.marshaller( - com.google.cloud.iot.v1.ListDeviceRegistriesRequest - .getDefaultInstance())) - .setResponseMarshaller( - io.grpc.protobuf.ProtoUtils.marshaller( - com.google.cloud.iot.v1.ListDeviceRegistriesResponse - .getDefaultInstance())) - .setSchemaDescriptor( - new DeviceManagerMethodDescriptorSupplier("ListDeviceRegistries")) - .build(); - } - } - } - return getListDeviceRegistriesMethod; - } - - private static volatile io.grpc.MethodDescriptor< - com.google.cloud.iot.v1.CreateDeviceRequest, com.google.cloud.iot.v1.Device> - getCreateDeviceMethod; - - @io.grpc.stub.annotations.RpcMethod( - fullMethodName = SERVICE_NAME + '/' + "CreateDevice", - requestType = com.google.cloud.iot.v1.CreateDeviceRequest.class, - responseType = com.google.cloud.iot.v1.Device.class, - methodType = io.grpc.MethodDescriptor.MethodType.UNARY) - public static io.grpc.MethodDescriptor< - com.google.cloud.iot.v1.CreateDeviceRequest, com.google.cloud.iot.v1.Device> - getCreateDeviceMethod() { - io.grpc.MethodDescriptor< - com.google.cloud.iot.v1.CreateDeviceRequest, com.google.cloud.iot.v1.Device> - getCreateDeviceMethod; - if ((getCreateDeviceMethod = DeviceManagerGrpc.getCreateDeviceMethod) == null) { - synchronized (DeviceManagerGrpc.class) { - if ((getCreateDeviceMethod = DeviceManagerGrpc.getCreateDeviceMethod) == null) { - DeviceManagerGrpc.getCreateDeviceMethod = - getCreateDeviceMethod = - io.grpc.MethodDescriptor - . - newBuilder() - .setType(io.grpc.MethodDescriptor.MethodType.UNARY) - .setFullMethodName(generateFullMethodName(SERVICE_NAME, "CreateDevice")) - .setSampledToLocalTracing(true) - .setRequestMarshaller( - io.grpc.protobuf.ProtoUtils.marshaller( - com.google.cloud.iot.v1.CreateDeviceRequest.getDefaultInstance())) - .setResponseMarshaller( - io.grpc.protobuf.ProtoUtils.marshaller( - com.google.cloud.iot.v1.Device.getDefaultInstance())) - .setSchemaDescriptor( - new DeviceManagerMethodDescriptorSupplier("CreateDevice")) - .build(); - } - } - } - return getCreateDeviceMethod; - } - - private static volatile io.grpc.MethodDescriptor< - com.google.cloud.iot.v1.GetDeviceRequest, com.google.cloud.iot.v1.Device> - getGetDeviceMethod; - - @io.grpc.stub.annotations.RpcMethod( - fullMethodName = SERVICE_NAME + '/' + "GetDevice", - requestType = com.google.cloud.iot.v1.GetDeviceRequest.class, - responseType = com.google.cloud.iot.v1.Device.class, - methodType = io.grpc.MethodDescriptor.MethodType.UNARY) - public static io.grpc.MethodDescriptor< - com.google.cloud.iot.v1.GetDeviceRequest, com.google.cloud.iot.v1.Device> - getGetDeviceMethod() { - io.grpc.MethodDescriptor< - com.google.cloud.iot.v1.GetDeviceRequest, com.google.cloud.iot.v1.Device> - getGetDeviceMethod; - if ((getGetDeviceMethod = DeviceManagerGrpc.getGetDeviceMethod) == null) { - synchronized (DeviceManagerGrpc.class) { - if ((getGetDeviceMethod = DeviceManagerGrpc.getGetDeviceMethod) == null) { - DeviceManagerGrpc.getGetDeviceMethod = - getGetDeviceMethod = - io.grpc.MethodDescriptor - . - newBuilder() - .setType(io.grpc.MethodDescriptor.MethodType.UNARY) - .setFullMethodName(generateFullMethodName(SERVICE_NAME, "GetDevice")) - .setSampledToLocalTracing(true) - .setRequestMarshaller( - io.grpc.protobuf.ProtoUtils.marshaller( - com.google.cloud.iot.v1.GetDeviceRequest.getDefaultInstance())) - .setResponseMarshaller( - io.grpc.protobuf.ProtoUtils.marshaller( - com.google.cloud.iot.v1.Device.getDefaultInstance())) - .setSchemaDescriptor(new DeviceManagerMethodDescriptorSupplier("GetDevice")) - .build(); - } - } - } - return getGetDeviceMethod; - } - - private static volatile io.grpc.MethodDescriptor< - com.google.cloud.iot.v1.UpdateDeviceRequest, com.google.cloud.iot.v1.Device> - getUpdateDeviceMethod; - - @io.grpc.stub.annotations.RpcMethod( - fullMethodName = SERVICE_NAME + '/' + "UpdateDevice", - requestType = com.google.cloud.iot.v1.UpdateDeviceRequest.class, - responseType = com.google.cloud.iot.v1.Device.class, - methodType = io.grpc.MethodDescriptor.MethodType.UNARY) - public static io.grpc.MethodDescriptor< - com.google.cloud.iot.v1.UpdateDeviceRequest, com.google.cloud.iot.v1.Device> - getUpdateDeviceMethod() { - io.grpc.MethodDescriptor< - com.google.cloud.iot.v1.UpdateDeviceRequest, com.google.cloud.iot.v1.Device> - getUpdateDeviceMethod; - if ((getUpdateDeviceMethod = DeviceManagerGrpc.getUpdateDeviceMethod) == null) { - synchronized (DeviceManagerGrpc.class) { - if ((getUpdateDeviceMethod = DeviceManagerGrpc.getUpdateDeviceMethod) == null) { - DeviceManagerGrpc.getUpdateDeviceMethod = - getUpdateDeviceMethod = - io.grpc.MethodDescriptor - . - newBuilder() - .setType(io.grpc.MethodDescriptor.MethodType.UNARY) - .setFullMethodName(generateFullMethodName(SERVICE_NAME, "UpdateDevice")) - .setSampledToLocalTracing(true) - .setRequestMarshaller( - io.grpc.protobuf.ProtoUtils.marshaller( - com.google.cloud.iot.v1.UpdateDeviceRequest.getDefaultInstance())) - .setResponseMarshaller( - io.grpc.protobuf.ProtoUtils.marshaller( - com.google.cloud.iot.v1.Device.getDefaultInstance())) - .setSchemaDescriptor( - new DeviceManagerMethodDescriptorSupplier("UpdateDevice")) - .build(); - } - } - } - return getUpdateDeviceMethod; - } - - private static volatile io.grpc.MethodDescriptor< - com.google.cloud.iot.v1.DeleteDeviceRequest, com.google.protobuf.Empty> - getDeleteDeviceMethod; - - @io.grpc.stub.annotations.RpcMethod( - fullMethodName = SERVICE_NAME + '/' + "DeleteDevice", - requestType = com.google.cloud.iot.v1.DeleteDeviceRequest.class, - responseType = com.google.protobuf.Empty.class, - methodType = io.grpc.MethodDescriptor.MethodType.UNARY) - public static io.grpc.MethodDescriptor< - com.google.cloud.iot.v1.DeleteDeviceRequest, com.google.protobuf.Empty> - getDeleteDeviceMethod() { - io.grpc.MethodDescriptor - getDeleteDeviceMethod; - if ((getDeleteDeviceMethod = DeviceManagerGrpc.getDeleteDeviceMethod) == null) { - synchronized (DeviceManagerGrpc.class) { - if ((getDeleteDeviceMethod = DeviceManagerGrpc.getDeleteDeviceMethod) == null) { - DeviceManagerGrpc.getDeleteDeviceMethod = - getDeleteDeviceMethod = - io.grpc.MethodDescriptor - . - newBuilder() - .setType(io.grpc.MethodDescriptor.MethodType.UNARY) - .setFullMethodName(generateFullMethodName(SERVICE_NAME, "DeleteDevice")) - .setSampledToLocalTracing(true) - .setRequestMarshaller( - io.grpc.protobuf.ProtoUtils.marshaller( - com.google.cloud.iot.v1.DeleteDeviceRequest.getDefaultInstance())) - .setResponseMarshaller( - io.grpc.protobuf.ProtoUtils.marshaller( - com.google.protobuf.Empty.getDefaultInstance())) - .setSchemaDescriptor( - new DeviceManagerMethodDescriptorSupplier("DeleteDevice")) - .build(); - } - } - } - return getDeleteDeviceMethod; - } - - private static volatile io.grpc.MethodDescriptor< - com.google.cloud.iot.v1.ListDevicesRequest, com.google.cloud.iot.v1.ListDevicesResponse> - getListDevicesMethod; - - @io.grpc.stub.annotations.RpcMethod( - fullMethodName = SERVICE_NAME + '/' + "ListDevices", - requestType = com.google.cloud.iot.v1.ListDevicesRequest.class, - responseType = com.google.cloud.iot.v1.ListDevicesResponse.class, - methodType = io.grpc.MethodDescriptor.MethodType.UNARY) - public static io.grpc.MethodDescriptor< - com.google.cloud.iot.v1.ListDevicesRequest, com.google.cloud.iot.v1.ListDevicesResponse> - getListDevicesMethod() { - io.grpc.MethodDescriptor< - com.google.cloud.iot.v1.ListDevicesRequest, com.google.cloud.iot.v1.ListDevicesResponse> - getListDevicesMethod; - if ((getListDevicesMethod = DeviceManagerGrpc.getListDevicesMethod) == null) { - synchronized (DeviceManagerGrpc.class) { - if ((getListDevicesMethod = DeviceManagerGrpc.getListDevicesMethod) == null) { - DeviceManagerGrpc.getListDevicesMethod = - getListDevicesMethod = - io.grpc.MethodDescriptor - . - newBuilder() - .setType(io.grpc.MethodDescriptor.MethodType.UNARY) - .setFullMethodName(generateFullMethodName(SERVICE_NAME, "ListDevices")) - .setSampledToLocalTracing(true) - .setRequestMarshaller( - io.grpc.protobuf.ProtoUtils.marshaller( - com.google.cloud.iot.v1.ListDevicesRequest.getDefaultInstance())) - .setResponseMarshaller( - io.grpc.protobuf.ProtoUtils.marshaller( - com.google.cloud.iot.v1.ListDevicesResponse.getDefaultInstance())) - .setSchemaDescriptor(new DeviceManagerMethodDescriptorSupplier("ListDevices")) - .build(); - } - } - } - return getListDevicesMethod; - } - - private static volatile io.grpc.MethodDescriptor< - com.google.cloud.iot.v1.ModifyCloudToDeviceConfigRequest, - com.google.cloud.iot.v1.DeviceConfig> - getModifyCloudToDeviceConfigMethod; - - @io.grpc.stub.annotations.RpcMethod( - fullMethodName = SERVICE_NAME + '/' + "ModifyCloudToDeviceConfig", - requestType = com.google.cloud.iot.v1.ModifyCloudToDeviceConfigRequest.class, - responseType = com.google.cloud.iot.v1.DeviceConfig.class, - methodType = io.grpc.MethodDescriptor.MethodType.UNARY) - public static io.grpc.MethodDescriptor< - com.google.cloud.iot.v1.ModifyCloudToDeviceConfigRequest, - com.google.cloud.iot.v1.DeviceConfig> - getModifyCloudToDeviceConfigMethod() { - io.grpc.MethodDescriptor< - com.google.cloud.iot.v1.ModifyCloudToDeviceConfigRequest, - com.google.cloud.iot.v1.DeviceConfig> - getModifyCloudToDeviceConfigMethod; - if ((getModifyCloudToDeviceConfigMethod = DeviceManagerGrpc.getModifyCloudToDeviceConfigMethod) - == null) { - synchronized (DeviceManagerGrpc.class) { - if ((getModifyCloudToDeviceConfigMethod = - DeviceManagerGrpc.getModifyCloudToDeviceConfigMethod) - == null) { - DeviceManagerGrpc.getModifyCloudToDeviceConfigMethod = - getModifyCloudToDeviceConfigMethod = - io.grpc.MethodDescriptor - . - newBuilder() - .setType(io.grpc.MethodDescriptor.MethodType.UNARY) - .setFullMethodName( - generateFullMethodName(SERVICE_NAME, "ModifyCloudToDeviceConfig")) - .setSampledToLocalTracing(true) - .setRequestMarshaller( - io.grpc.protobuf.ProtoUtils.marshaller( - com.google.cloud.iot.v1.ModifyCloudToDeviceConfigRequest - .getDefaultInstance())) - .setResponseMarshaller( - io.grpc.protobuf.ProtoUtils.marshaller( - com.google.cloud.iot.v1.DeviceConfig.getDefaultInstance())) - .setSchemaDescriptor( - new DeviceManagerMethodDescriptorSupplier("ModifyCloudToDeviceConfig")) - .build(); - } - } - } - return getModifyCloudToDeviceConfigMethod; - } - - private static volatile io.grpc.MethodDescriptor< - com.google.cloud.iot.v1.ListDeviceConfigVersionsRequest, - com.google.cloud.iot.v1.ListDeviceConfigVersionsResponse> - getListDeviceConfigVersionsMethod; - - @io.grpc.stub.annotations.RpcMethod( - fullMethodName = SERVICE_NAME + '/' + "ListDeviceConfigVersions", - requestType = com.google.cloud.iot.v1.ListDeviceConfigVersionsRequest.class, - responseType = com.google.cloud.iot.v1.ListDeviceConfigVersionsResponse.class, - methodType = io.grpc.MethodDescriptor.MethodType.UNARY) - public static io.grpc.MethodDescriptor< - com.google.cloud.iot.v1.ListDeviceConfigVersionsRequest, - com.google.cloud.iot.v1.ListDeviceConfigVersionsResponse> - getListDeviceConfigVersionsMethod() { - io.grpc.MethodDescriptor< - com.google.cloud.iot.v1.ListDeviceConfigVersionsRequest, - com.google.cloud.iot.v1.ListDeviceConfigVersionsResponse> - getListDeviceConfigVersionsMethod; - if ((getListDeviceConfigVersionsMethod = DeviceManagerGrpc.getListDeviceConfigVersionsMethod) - == null) { - synchronized (DeviceManagerGrpc.class) { - if ((getListDeviceConfigVersionsMethod = - DeviceManagerGrpc.getListDeviceConfigVersionsMethod) - == null) { - DeviceManagerGrpc.getListDeviceConfigVersionsMethod = - getListDeviceConfigVersionsMethod = - io.grpc.MethodDescriptor - . - newBuilder() - .setType(io.grpc.MethodDescriptor.MethodType.UNARY) - .setFullMethodName( - generateFullMethodName(SERVICE_NAME, "ListDeviceConfigVersions")) - .setSampledToLocalTracing(true) - .setRequestMarshaller( - io.grpc.protobuf.ProtoUtils.marshaller( - com.google.cloud.iot.v1.ListDeviceConfigVersionsRequest - .getDefaultInstance())) - .setResponseMarshaller( - io.grpc.protobuf.ProtoUtils.marshaller( - com.google.cloud.iot.v1.ListDeviceConfigVersionsResponse - .getDefaultInstance())) - .setSchemaDescriptor( - new DeviceManagerMethodDescriptorSupplier("ListDeviceConfigVersions")) - .build(); - } - } - } - return getListDeviceConfigVersionsMethod; - } - - private static volatile io.grpc.MethodDescriptor< - com.google.cloud.iot.v1.ListDeviceStatesRequest, - com.google.cloud.iot.v1.ListDeviceStatesResponse> - getListDeviceStatesMethod; - - @io.grpc.stub.annotations.RpcMethod( - fullMethodName = SERVICE_NAME + '/' + "ListDeviceStates", - requestType = com.google.cloud.iot.v1.ListDeviceStatesRequest.class, - responseType = com.google.cloud.iot.v1.ListDeviceStatesResponse.class, - methodType = io.grpc.MethodDescriptor.MethodType.UNARY) - public static io.grpc.MethodDescriptor< - com.google.cloud.iot.v1.ListDeviceStatesRequest, - com.google.cloud.iot.v1.ListDeviceStatesResponse> - getListDeviceStatesMethod() { - io.grpc.MethodDescriptor< - com.google.cloud.iot.v1.ListDeviceStatesRequest, - com.google.cloud.iot.v1.ListDeviceStatesResponse> - getListDeviceStatesMethod; - if ((getListDeviceStatesMethod = DeviceManagerGrpc.getListDeviceStatesMethod) == null) { - synchronized (DeviceManagerGrpc.class) { - if ((getListDeviceStatesMethod = DeviceManagerGrpc.getListDeviceStatesMethod) == null) { - DeviceManagerGrpc.getListDeviceStatesMethod = - getListDeviceStatesMethod = - io.grpc.MethodDescriptor - . - newBuilder() - .setType(io.grpc.MethodDescriptor.MethodType.UNARY) - .setFullMethodName(generateFullMethodName(SERVICE_NAME, "ListDeviceStates")) - .setSampledToLocalTracing(true) - .setRequestMarshaller( - io.grpc.protobuf.ProtoUtils.marshaller( - com.google.cloud.iot.v1.ListDeviceStatesRequest.getDefaultInstance())) - .setResponseMarshaller( - io.grpc.protobuf.ProtoUtils.marshaller( - com.google.cloud.iot.v1.ListDeviceStatesResponse - .getDefaultInstance())) - .setSchemaDescriptor( - new DeviceManagerMethodDescriptorSupplier("ListDeviceStates")) - .build(); - } - } - } - return getListDeviceStatesMethod; - } - - private static volatile io.grpc.MethodDescriptor< - com.google.iam.v1.SetIamPolicyRequest, com.google.iam.v1.Policy> - getSetIamPolicyMethod; - - @io.grpc.stub.annotations.RpcMethod( - fullMethodName = SERVICE_NAME + '/' + "SetIamPolicy", - requestType = com.google.iam.v1.SetIamPolicyRequest.class, - responseType = com.google.iam.v1.Policy.class, - methodType = io.grpc.MethodDescriptor.MethodType.UNARY) - public static io.grpc.MethodDescriptor< - com.google.iam.v1.SetIamPolicyRequest, com.google.iam.v1.Policy> - getSetIamPolicyMethod() { - io.grpc.MethodDescriptor - getSetIamPolicyMethod; - if ((getSetIamPolicyMethod = DeviceManagerGrpc.getSetIamPolicyMethod) == null) { - synchronized (DeviceManagerGrpc.class) { - if ((getSetIamPolicyMethod = DeviceManagerGrpc.getSetIamPolicyMethod) == null) { - DeviceManagerGrpc.getSetIamPolicyMethod = - getSetIamPolicyMethod = - io.grpc.MethodDescriptor - .newBuilder() - .setType(io.grpc.MethodDescriptor.MethodType.UNARY) - .setFullMethodName(generateFullMethodName(SERVICE_NAME, "SetIamPolicy")) - .setSampledToLocalTracing(true) - .setRequestMarshaller( - io.grpc.protobuf.ProtoUtils.marshaller( - com.google.iam.v1.SetIamPolicyRequest.getDefaultInstance())) - .setResponseMarshaller( - io.grpc.protobuf.ProtoUtils.marshaller( - com.google.iam.v1.Policy.getDefaultInstance())) - .setSchemaDescriptor( - new DeviceManagerMethodDescriptorSupplier("SetIamPolicy")) - .build(); - } - } - } - return getSetIamPolicyMethod; - } - - private static volatile io.grpc.MethodDescriptor< - com.google.iam.v1.GetIamPolicyRequest, com.google.iam.v1.Policy> - getGetIamPolicyMethod; - - @io.grpc.stub.annotations.RpcMethod( - fullMethodName = SERVICE_NAME + '/' + "GetIamPolicy", - requestType = com.google.iam.v1.GetIamPolicyRequest.class, - responseType = com.google.iam.v1.Policy.class, - methodType = io.grpc.MethodDescriptor.MethodType.UNARY) - public static io.grpc.MethodDescriptor< - com.google.iam.v1.GetIamPolicyRequest, com.google.iam.v1.Policy> - getGetIamPolicyMethod() { - io.grpc.MethodDescriptor - getGetIamPolicyMethod; - if ((getGetIamPolicyMethod = DeviceManagerGrpc.getGetIamPolicyMethod) == null) { - synchronized (DeviceManagerGrpc.class) { - if ((getGetIamPolicyMethod = DeviceManagerGrpc.getGetIamPolicyMethod) == null) { - DeviceManagerGrpc.getGetIamPolicyMethod = - getGetIamPolicyMethod = - io.grpc.MethodDescriptor - .newBuilder() - .setType(io.grpc.MethodDescriptor.MethodType.UNARY) - .setFullMethodName(generateFullMethodName(SERVICE_NAME, "GetIamPolicy")) - .setSampledToLocalTracing(true) - .setRequestMarshaller( - io.grpc.protobuf.ProtoUtils.marshaller( - com.google.iam.v1.GetIamPolicyRequest.getDefaultInstance())) - .setResponseMarshaller( - io.grpc.protobuf.ProtoUtils.marshaller( - com.google.iam.v1.Policy.getDefaultInstance())) - .setSchemaDescriptor( - new DeviceManagerMethodDescriptorSupplier("GetIamPolicy")) - .build(); - } - } - } - return getGetIamPolicyMethod; - } - - private static volatile io.grpc.MethodDescriptor< - com.google.iam.v1.TestIamPermissionsRequest, com.google.iam.v1.TestIamPermissionsResponse> - getTestIamPermissionsMethod; - - @io.grpc.stub.annotations.RpcMethod( - fullMethodName = SERVICE_NAME + '/' + "TestIamPermissions", - requestType = com.google.iam.v1.TestIamPermissionsRequest.class, - responseType = com.google.iam.v1.TestIamPermissionsResponse.class, - methodType = io.grpc.MethodDescriptor.MethodType.UNARY) - public static io.grpc.MethodDescriptor< - com.google.iam.v1.TestIamPermissionsRequest, com.google.iam.v1.TestIamPermissionsResponse> - getTestIamPermissionsMethod() { - io.grpc.MethodDescriptor< - com.google.iam.v1.TestIamPermissionsRequest, - com.google.iam.v1.TestIamPermissionsResponse> - getTestIamPermissionsMethod; - if ((getTestIamPermissionsMethod = DeviceManagerGrpc.getTestIamPermissionsMethod) == null) { - synchronized (DeviceManagerGrpc.class) { - if ((getTestIamPermissionsMethod = DeviceManagerGrpc.getTestIamPermissionsMethod) == null) { - DeviceManagerGrpc.getTestIamPermissionsMethod = - getTestIamPermissionsMethod = - io.grpc.MethodDescriptor - . - newBuilder() - .setType(io.grpc.MethodDescriptor.MethodType.UNARY) - .setFullMethodName(generateFullMethodName(SERVICE_NAME, "TestIamPermissions")) - .setSampledToLocalTracing(true) - .setRequestMarshaller( - io.grpc.protobuf.ProtoUtils.marshaller( - com.google.iam.v1.TestIamPermissionsRequest.getDefaultInstance())) - .setResponseMarshaller( - io.grpc.protobuf.ProtoUtils.marshaller( - com.google.iam.v1.TestIamPermissionsResponse.getDefaultInstance())) - .setSchemaDescriptor( - new DeviceManagerMethodDescriptorSupplier("TestIamPermissions")) - .build(); - } - } - } - return getTestIamPermissionsMethod; - } - - private static volatile io.grpc.MethodDescriptor< - com.google.cloud.iot.v1.SendCommandToDeviceRequest, - com.google.cloud.iot.v1.SendCommandToDeviceResponse> - getSendCommandToDeviceMethod; - - @io.grpc.stub.annotations.RpcMethod( - fullMethodName = SERVICE_NAME + '/' + "SendCommandToDevice", - requestType = com.google.cloud.iot.v1.SendCommandToDeviceRequest.class, - responseType = com.google.cloud.iot.v1.SendCommandToDeviceResponse.class, - methodType = io.grpc.MethodDescriptor.MethodType.UNARY) - public static io.grpc.MethodDescriptor< - com.google.cloud.iot.v1.SendCommandToDeviceRequest, - com.google.cloud.iot.v1.SendCommandToDeviceResponse> - getSendCommandToDeviceMethod() { - io.grpc.MethodDescriptor< - com.google.cloud.iot.v1.SendCommandToDeviceRequest, - com.google.cloud.iot.v1.SendCommandToDeviceResponse> - getSendCommandToDeviceMethod; - if ((getSendCommandToDeviceMethod = DeviceManagerGrpc.getSendCommandToDeviceMethod) == null) { - synchronized (DeviceManagerGrpc.class) { - if ((getSendCommandToDeviceMethod = DeviceManagerGrpc.getSendCommandToDeviceMethod) - == null) { - DeviceManagerGrpc.getSendCommandToDeviceMethod = - getSendCommandToDeviceMethod = - io.grpc.MethodDescriptor - . - newBuilder() - .setType(io.grpc.MethodDescriptor.MethodType.UNARY) - .setFullMethodName( - generateFullMethodName(SERVICE_NAME, "SendCommandToDevice")) - .setSampledToLocalTracing(true) - .setRequestMarshaller( - io.grpc.protobuf.ProtoUtils.marshaller( - com.google.cloud.iot.v1.SendCommandToDeviceRequest - .getDefaultInstance())) - .setResponseMarshaller( - io.grpc.protobuf.ProtoUtils.marshaller( - com.google.cloud.iot.v1.SendCommandToDeviceResponse - .getDefaultInstance())) - .setSchemaDescriptor( - new DeviceManagerMethodDescriptorSupplier("SendCommandToDevice")) - .build(); - } - } - } - return getSendCommandToDeviceMethod; - } - - private static volatile io.grpc.MethodDescriptor< - com.google.cloud.iot.v1.BindDeviceToGatewayRequest, - com.google.cloud.iot.v1.BindDeviceToGatewayResponse> - getBindDeviceToGatewayMethod; - - @io.grpc.stub.annotations.RpcMethod( - fullMethodName = SERVICE_NAME + '/' + "BindDeviceToGateway", - requestType = com.google.cloud.iot.v1.BindDeviceToGatewayRequest.class, - responseType = com.google.cloud.iot.v1.BindDeviceToGatewayResponse.class, - methodType = io.grpc.MethodDescriptor.MethodType.UNARY) - public static io.grpc.MethodDescriptor< - com.google.cloud.iot.v1.BindDeviceToGatewayRequest, - com.google.cloud.iot.v1.BindDeviceToGatewayResponse> - getBindDeviceToGatewayMethod() { - io.grpc.MethodDescriptor< - com.google.cloud.iot.v1.BindDeviceToGatewayRequest, - com.google.cloud.iot.v1.BindDeviceToGatewayResponse> - getBindDeviceToGatewayMethod; - if ((getBindDeviceToGatewayMethod = DeviceManagerGrpc.getBindDeviceToGatewayMethod) == null) { - synchronized (DeviceManagerGrpc.class) { - if ((getBindDeviceToGatewayMethod = DeviceManagerGrpc.getBindDeviceToGatewayMethod) - == null) { - DeviceManagerGrpc.getBindDeviceToGatewayMethod = - getBindDeviceToGatewayMethod = - io.grpc.MethodDescriptor - . - newBuilder() - .setType(io.grpc.MethodDescriptor.MethodType.UNARY) - .setFullMethodName( - generateFullMethodName(SERVICE_NAME, "BindDeviceToGateway")) - .setSampledToLocalTracing(true) - .setRequestMarshaller( - io.grpc.protobuf.ProtoUtils.marshaller( - com.google.cloud.iot.v1.BindDeviceToGatewayRequest - .getDefaultInstance())) - .setResponseMarshaller( - io.grpc.protobuf.ProtoUtils.marshaller( - com.google.cloud.iot.v1.BindDeviceToGatewayResponse - .getDefaultInstance())) - .setSchemaDescriptor( - new DeviceManagerMethodDescriptorSupplier("BindDeviceToGateway")) - .build(); - } - } - } - return getBindDeviceToGatewayMethod; - } - - private static volatile io.grpc.MethodDescriptor< - com.google.cloud.iot.v1.UnbindDeviceFromGatewayRequest, - com.google.cloud.iot.v1.UnbindDeviceFromGatewayResponse> - getUnbindDeviceFromGatewayMethod; - - @io.grpc.stub.annotations.RpcMethod( - fullMethodName = SERVICE_NAME + '/' + "UnbindDeviceFromGateway", - requestType = com.google.cloud.iot.v1.UnbindDeviceFromGatewayRequest.class, - responseType = com.google.cloud.iot.v1.UnbindDeviceFromGatewayResponse.class, - methodType = io.grpc.MethodDescriptor.MethodType.UNARY) - public static io.grpc.MethodDescriptor< - com.google.cloud.iot.v1.UnbindDeviceFromGatewayRequest, - com.google.cloud.iot.v1.UnbindDeviceFromGatewayResponse> - getUnbindDeviceFromGatewayMethod() { - io.grpc.MethodDescriptor< - com.google.cloud.iot.v1.UnbindDeviceFromGatewayRequest, - com.google.cloud.iot.v1.UnbindDeviceFromGatewayResponse> - getUnbindDeviceFromGatewayMethod; - if ((getUnbindDeviceFromGatewayMethod = DeviceManagerGrpc.getUnbindDeviceFromGatewayMethod) - == null) { - synchronized (DeviceManagerGrpc.class) { - if ((getUnbindDeviceFromGatewayMethod = DeviceManagerGrpc.getUnbindDeviceFromGatewayMethod) - == null) { - DeviceManagerGrpc.getUnbindDeviceFromGatewayMethod = - getUnbindDeviceFromGatewayMethod = - io.grpc.MethodDescriptor - . - newBuilder() - .setType(io.grpc.MethodDescriptor.MethodType.UNARY) - .setFullMethodName( - generateFullMethodName(SERVICE_NAME, "UnbindDeviceFromGateway")) - .setSampledToLocalTracing(true) - .setRequestMarshaller( - io.grpc.protobuf.ProtoUtils.marshaller( - com.google.cloud.iot.v1.UnbindDeviceFromGatewayRequest - .getDefaultInstance())) - .setResponseMarshaller( - io.grpc.protobuf.ProtoUtils.marshaller( - com.google.cloud.iot.v1.UnbindDeviceFromGatewayResponse - .getDefaultInstance())) - .setSchemaDescriptor( - new DeviceManagerMethodDescriptorSupplier("UnbindDeviceFromGateway")) - .build(); - } - } - } - return getUnbindDeviceFromGatewayMethod; - } - - /** Creates a new async stub that supports all call types for the service */ - public static DeviceManagerStub newStub(io.grpc.Channel channel) { - io.grpc.stub.AbstractStub.StubFactory factory = - new io.grpc.stub.AbstractStub.StubFactory() { - @java.lang.Override - public DeviceManagerStub newStub( - io.grpc.Channel channel, io.grpc.CallOptions callOptions) { - return new DeviceManagerStub(channel, callOptions); - } - }; - return DeviceManagerStub.newStub(factory, channel); - } - - /** - * Creates a new blocking-style stub that supports unary and streaming output calls on the service - */ - public static DeviceManagerBlockingStub newBlockingStub(io.grpc.Channel channel) { - io.grpc.stub.AbstractStub.StubFactory factory = - new io.grpc.stub.AbstractStub.StubFactory() { - @java.lang.Override - public DeviceManagerBlockingStub newStub( - io.grpc.Channel channel, io.grpc.CallOptions callOptions) { - return new DeviceManagerBlockingStub(channel, callOptions); - } - }; - return DeviceManagerBlockingStub.newStub(factory, channel); - } - - /** Creates a new ListenableFuture-style stub that supports unary calls on the service */ - public static DeviceManagerFutureStub newFutureStub(io.grpc.Channel channel) { - io.grpc.stub.AbstractStub.StubFactory factory = - new io.grpc.stub.AbstractStub.StubFactory() { - @java.lang.Override - public DeviceManagerFutureStub newStub( - io.grpc.Channel channel, io.grpc.CallOptions callOptions) { - return new DeviceManagerFutureStub(channel, callOptions); - } - }; - return DeviceManagerFutureStub.newStub(factory, channel); - } - - /** - * - * - *
-   * Internet of Things (IoT) service. Securely connect and manage IoT devices.
-   * 
- */ - public abstract static class DeviceManagerImplBase implements io.grpc.BindableService { - - /** - * - * - *
-     * Creates a device registry that contains devices.
-     * 
- */ - public void createDeviceRegistry( - com.google.cloud.iot.v1.CreateDeviceRegistryRequest request, - io.grpc.stub.StreamObserver responseObserver) { - io.grpc.stub.ServerCalls.asyncUnimplementedUnaryCall( - getCreateDeviceRegistryMethod(), responseObserver); - } - - /** - * - * - *
-     * Gets a device registry configuration.
-     * 
- */ - public void getDeviceRegistry( - com.google.cloud.iot.v1.GetDeviceRegistryRequest request, - io.grpc.stub.StreamObserver responseObserver) { - io.grpc.stub.ServerCalls.asyncUnimplementedUnaryCall( - getGetDeviceRegistryMethod(), responseObserver); - } - - /** - * - * - *
-     * Updates a device registry configuration.
-     * 
- */ - public void updateDeviceRegistry( - com.google.cloud.iot.v1.UpdateDeviceRegistryRequest request, - io.grpc.stub.StreamObserver responseObserver) { - io.grpc.stub.ServerCalls.asyncUnimplementedUnaryCall( - getUpdateDeviceRegistryMethod(), responseObserver); - } - - /** - * - * - *
-     * Deletes a device registry configuration.
-     * 
- */ - public void deleteDeviceRegistry( - com.google.cloud.iot.v1.DeleteDeviceRegistryRequest request, - io.grpc.stub.StreamObserver responseObserver) { - io.grpc.stub.ServerCalls.asyncUnimplementedUnaryCall( - getDeleteDeviceRegistryMethod(), responseObserver); - } - - /** - * - * - *
-     * Lists device registries.
-     * 
- */ - public void listDeviceRegistries( - com.google.cloud.iot.v1.ListDeviceRegistriesRequest request, - io.grpc.stub.StreamObserver - responseObserver) { - io.grpc.stub.ServerCalls.asyncUnimplementedUnaryCall( - getListDeviceRegistriesMethod(), responseObserver); - } - - /** - * - * - *
-     * Creates a device in a device registry.
-     * 
- */ - public void createDevice( - com.google.cloud.iot.v1.CreateDeviceRequest request, - io.grpc.stub.StreamObserver responseObserver) { - io.grpc.stub.ServerCalls.asyncUnimplementedUnaryCall( - getCreateDeviceMethod(), responseObserver); - } - - /** - * - * - *
-     * Gets details about a device.
-     * 
- */ - public void getDevice( - com.google.cloud.iot.v1.GetDeviceRequest request, - io.grpc.stub.StreamObserver responseObserver) { - io.grpc.stub.ServerCalls.asyncUnimplementedUnaryCall(getGetDeviceMethod(), responseObserver); - } - - /** - * - * - *
-     * Updates a device.
-     * 
- */ - public void updateDevice( - com.google.cloud.iot.v1.UpdateDeviceRequest request, - io.grpc.stub.StreamObserver responseObserver) { - io.grpc.stub.ServerCalls.asyncUnimplementedUnaryCall( - getUpdateDeviceMethod(), responseObserver); - } - - /** - * - * - *
-     * Deletes a device.
-     * 
- */ - public void deleteDevice( - com.google.cloud.iot.v1.DeleteDeviceRequest request, - io.grpc.stub.StreamObserver responseObserver) { - io.grpc.stub.ServerCalls.asyncUnimplementedUnaryCall( - getDeleteDeviceMethod(), responseObserver); - } - - /** - * - * - *
-     * List devices in a device registry.
-     * 
- */ - public void listDevices( - com.google.cloud.iot.v1.ListDevicesRequest request, - io.grpc.stub.StreamObserver responseObserver) { - io.grpc.stub.ServerCalls.asyncUnimplementedUnaryCall( - getListDevicesMethod(), responseObserver); - } - - /** - * - * - *
-     * Modifies the configuration for the device, which is eventually sent from
-     * the Cloud IoT Core servers. Returns the modified configuration version and
-     * its metadata.
-     * 
- */ - public void modifyCloudToDeviceConfig( - com.google.cloud.iot.v1.ModifyCloudToDeviceConfigRequest request, - io.grpc.stub.StreamObserver responseObserver) { - io.grpc.stub.ServerCalls.asyncUnimplementedUnaryCall( - getModifyCloudToDeviceConfigMethod(), responseObserver); - } - - /** - * - * - *
-     * Lists the last few versions of the device configuration in descending
-     * order (i.e.: newest first).
-     * 
- */ - public void listDeviceConfigVersions( - com.google.cloud.iot.v1.ListDeviceConfigVersionsRequest request, - io.grpc.stub.StreamObserver - responseObserver) { - io.grpc.stub.ServerCalls.asyncUnimplementedUnaryCall( - getListDeviceConfigVersionsMethod(), responseObserver); - } - - /** - * - * - *
-     * Lists the last few versions of the device state in descending order (i.e.:
-     * newest first).
-     * 
- */ - public void listDeviceStates( - com.google.cloud.iot.v1.ListDeviceStatesRequest request, - io.grpc.stub.StreamObserver - responseObserver) { - io.grpc.stub.ServerCalls.asyncUnimplementedUnaryCall( - getListDeviceStatesMethod(), responseObserver); - } - - /** - * - * - *
-     * Sets the access control policy on the specified resource. Replaces any
-     * existing policy.
-     * 
- */ - public void setIamPolicy( - com.google.iam.v1.SetIamPolicyRequest request, - io.grpc.stub.StreamObserver responseObserver) { - io.grpc.stub.ServerCalls.asyncUnimplementedUnaryCall( - getSetIamPolicyMethod(), responseObserver); - } - - /** - * - * - *
-     * Gets the access control policy for a resource.
-     * Returns an empty policy if the resource exists and does not have a policy
-     * set.
-     * 
- */ - public void getIamPolicy( - com.google.iam.v1.GetIamPolicyRequest request, - io.grpc.stub.StreamObserver responseObserver) { - io.grpc.stub.ServerCalls.asyncUnimplementedUnaryCall( - getGetIamPolicyMethod(), responseObserver); - } - - /** - * - * - *
-     * Returns permissions that a caller has on the specified resource.
-     * If the resource does not exist, this will return an empty set of
-     * permissions, not a NOT_FOUND error.
-     * 
- */ - public void testIamPermissions( - com.google.iam.v1.TestIamPermissionsRequest request, - io.grpc.stub.StreamObserver - responseObserver) { - io.grpc.stub.ServerCalls.asyncUnimplementedUnaryCall( - getTestIamPermissionsMethod(), responseObserver); - } - - /** - * - * - *
-     * Sends a command to the specified device. In order for a device to be able
-     * to receive commands, it must:
-     * 1) be connected to Cloud IoT Core using the MQTT protocol, and
-     * 2) be subscribed to the group of MQTT topics specified by
-     *    /devices/{device-id}/commands/#. This subscription will receive commands
-     *    at the top-level topic /devices/{device-id}/commands as well as commands
-     *    for subfolders, like /devices/{device-id}/commands/subfolder.
-     *    Note that subscribing to specific subfolders is not supported.
-     * If the command could not be delivered to the device, this method will
-     * return an error; in particular, if the device is not subscribed, this
-     * method will return FAILED_PRECONDITION. Otherwise, this method will
-     * return OK. If the subscription is QoS 1, at least once delivery will be
-     * guaranteed; for QoS 0, no acknowledgment will be expected from the device.
-     * 
- */ - public void sendCommandToDevice( - com.google.cloud.iot.v1.SendCommandToDeviceRequest request, - io.grpc.stub.StreamObserver - responseObserver) { - io.grpc.stub.ServerCalls.asyncUnimplementedUnaryCall( - getSendCommandToDeviceMethod(), responseObserver); - } - - /** - * - * - *
-     * Associates the device with the gateway.
-     * 
- */ - public void bindDeviceToGateway( - com.google.cloud.iot.v1.BindDeviceToGatewayRequest request, - io.grpc.stub.StreamObserver - responseObserver) { - io.grpc.stub.ServerCalls.asyncUnimplementedUnaryCall( - getBindDeviceToGatewayMethod(), responseObserver); - } - - /** - * - * - *
-     * Deletes the association between the device and the gateway.
-     * 
- */ - public void unbindDeviceFromGateway( - com.google.cloud.iot.v1.UnbindDeviceFromGatewayRequest request, - io.grpc.stub.StreamObserver - responseObserver) { - io.grpc.stub.ServerCalls.asyncUnimplementedUnaryCall( - getUnbindDeviceFromGatewayMethod(), responseObserver); - } - - @java.lang.Override - public final io.grpc.ServerServiceDefinition bindService() { - return io.grpc.ServerServiceDefinition.builder(getServiceDescriptor()) - .addMethod( - getCreateDeviceRegistryMethod(), - io.grpc.stub.ServerCalls.asyncUnaryCall( - new MethodHandlers< - com.google.cloud.iot.v1.CreateDeviceRegistryRequest, - com.google.cloud.iot.v1.DeviceRegistry>( - this, METHODID_CREATE_DEVICE_REGISTRY))) - .addMethod( - getGetDeviceRegistryMethod(), - io.grpc.stub.ServerCalls.asyncUnaryCall( - new MethodHandlers< - com.google.cloud.iot.v1.GetDeviceRegistryRequest, - com.google.cloud.iot.v1.DeviceRegistry>(this, METHODID_GET_DEVICE_REGISTRY))) - .addMethod( - getUpdateDeviceRegistryMethod(), - io.grpc.stub.ServerCalls.asyncUnaryCall( - new MethodHandlers< - com.google.cloud.iot.v1.UpdateDeviceRegistryRequest, - com.google.cloud.iot.v1.DeviceRegistry>( - this, METHODID_UPDATE_DEVICE_REGISTRY))) - .addMethod( - getDeleteDeviceRegistryMethod(), - io.grpc.stub.ServerCalls.asyncUnaryCall( - new MethodHandlers< - com.google.cloud.iot.v1.DeleteDeviceRegistryRequest, - com.google.protobuf.Empty>(this, METHODID_DELETE_DEVICE_REGISTRY))) - .addMethod( - getListDeviceRegistriesMethod(), - io.grpc.stub.ServerCalls.asyncUnaryCall( - new MethodHandlers< - com.google.cloud.iot.v1.ListDeviceRegistriesRequest, - com.google.cloud.iot.v1.ListDeviceRegistriesResponse>( - this, METHODID_LIST_DEVICE_REGISTRIES))) - .addMethod( - getCreateDeviceMethod(), - io.grpc.stub.ServerCalls.asyncUnaryCall( - new MethodHandlers< - com.google.cloud.iot.v1.CreateDeviceRequest, com.google.cloud.iot.v1.Device>( - this, METHODID_CREATE_DEVICE))) - .addMethod( - getGetDeviceMethod(), - io.grpc.stub.ServerCalls.asyncUnaryCall( - new MethodHandlers< - com.google.cloud.iot.v1.GetDeviceRequest, com.google.cloud.iot.v1.Device>( - this, METHODID_GET_DEVICE))) - .addMethod( - getUpdateDeviceMethod(), - io.grpc.stub.ServerCalls.asyncUnaryCall( - new MethodHandlers< - com.google.cloud.iot.v1.UpdateDeviceRequest, com.google.cloud.iot.v1.Device>( - this, METHODID_UPDATE_DEVICE))) - .addMethod( - getDeleteDeviceMethod(), - io.grpc.stub.ServerCalls.asyncUnaryCall( - new MethodHandlers< - com.google.cloud.iot.v1.DeleteDeviceRequest, com.google.protobuf.Empty>( - this, METHODID_DELETE_DEVICE))) - .addMethod( - getListDevicesMethod(), - io.grpc.stub.ServerCalls.asyncUnaryCall( - new MethodHandlers< - com.google.cloud.iot.v1.ListDevicesRequest, - com.google.cloud.iot.v1.ListDevicesResponse>(this, METHODID_LIST_DEVICES))) - .addMethod( - getModifyCloudToDeviceConfigMethod(), - io.grpc.stub.ServerCalls.asyncUnaryCall( - new MethodHandlers< - com.google.cloud.iot.v1.ModifyCloudToDeviceConfigRequest, - com.google.cloud.iot.v1.DeviceConfig>( - this, METHODID_MODIFY_CLOUD_TO_DEVICE_CONFIG))) - .addMethod( - getListDeviceConfigVersionsMethod(), - io.grpc.stub.ServerCalls.asyncUnaryCall( - new MethodHandlers< - com.google.cloud.iot.v1.ListDeviceConfigVersionsRequest, - com.google.cloud.iot.v1.ListDeviceConfigVersionsResponse>( - this, METHODID_LIST_DEVICE_CONFIG_VERSIONS))) - .addMethod( - getListDeviceStatesMethod(), - io.grpc.stub.ServerCalls.asyncUnaryCall( - new MethodHandlers< - com.google.cloud.iot.v1.ListDeviceStatesRequest, - com.google.cloud.iot.v1.ListDeviceStatesResponse>( - this, METHODID_LIST_DEVICE_STATES))) - .addMethod( - getSetIamPolicyMethod(), - io.grpc.stub.ServerCalls.asyncUnaryCall( - new MethodHandlers< - com.google.iam.v1.SetIamPolicyRequest, com.google.iam.v1.Policy>( - this, METHODID_SET_IAM_POLICY))) - .addMethod( - getGetIamPolicyMethod(), - io.grpc.stub.ServerCalls.asyncUnaryCall( - new MethodHandlers< - com.google.iam.v1.GetIamPolicyRequest, com.google.iam.v1.Policy>( - this, METHODID_GET_IAM_POLICY))) - .addMethod( - getTestIamPermissionsMethod(), - io.grpc.stub.ServerCalls.asyncUnaryCall( - new MethodHandlers< - com.google.iam.v1.TestIamPermissionsRequest, - com.google.iam.v1.TestIamPermissionsResponse>( - this, METHODID_TEST_IAM_PERMISSIONS))) - .addMethod( - getSendCommandToDeviceMethod(), - io.grpc.stub.ServerCalls.asyncUnaryCall( - new MethodHandlers< - com.google.cloud.iot.v1.SendCommandToDeviceRequest, - com.google.cloud.iot.v1.SendCommandToDeviceResponse>( - this, METHODID_SEND_COMMAND_TO_DEVICE))) - .addMethod( - getBindDeviceToGatewayMethod(), - io.grpc.stub.ServerCalls.asyncUnaryCall( - new MethodHandlers< - com.google.cloud.iot.v1.BindDeviceToGatewayRequest, - com.google.cloud.iot.v1.BindDeviceToGatewayResponse>( - this, METHODID_BIND_DEVICE_TO_GATEWAY))) - .addMethod( - getUnbindDeviceFromGatewayMethod(), - io.grpc.stub.ServerCalls.asyncUnaryCall( - new MethodHandlers< - com.google.cloud.iot.v1.UnbindDeviceFromGatewayRequest, - com.google.cloud.iot.v1.UnbindDeviceFromGatewayResponse>( - this, METHODID_UNBIND_DEVICE_FROM_GATEWAY))) - .build(); - } - } - - /** - * - * - *
-   * Internet of Things (IoT) service. Securely connect and manage IoT devices.
-   * 
- */ - public static final class DeviceManagerStub - extends io.grpc.stub.AbstractAsyncStub { - private DeviceManagerStub(io.grpc.Channel channel, io.grpc.CallOptions callOptions) { - super(channel, callOptions); - } - - @java.lang.Override - protected DeviceManagerStub build(io.grpc.Channel channel, io.grpc.CallOptions callOptions) { - return new DeviceManagerStub(channel, callOptions); - } - - /** - * - * - *
-     * Creates a device registry that contains devices.
-     * 
- */ - public void createDeviceRegistry( - com.google.cloud.iot.v1.CreateDeviceRegistryRequest request, - io.grpc.stub.StreamObserver responseObserver) { - io.grpc.stub.ClientCalls.asyncUnaryCall( - getChannel().newCall(getCreateDeviceRegistryMethod(), getCallOptions()), - request, - responseObserver); - } - - /** - * - * - *
-     * Gets a device registry configuration.
-     * 
- */ - public void getDeviceRegistry( - com.google.cloud.iot.v1.GetDeviceRegistryRequest request, - io.grpc.stub.StreamObserver responseObserver) { - io.grpc.stub.ClientCalls.asyncUnaryCall( - getChannel().newCall(getGetDeviceRegistryMethod(), getCallOptions()), - request, - responseObserver); - } - - /** - * - * - *
-     * Updates a device registry configuration.
-     * 
- */ - public void updateDeviceRegistry( - com.google.cloud.iot.v1.UpdateDeviceRegistryRequest request, - io.grpc.stub.StreamObserver responseObserver) { - io.grpc.stub.ClientCalls.asyncUnaryCall( - getChannel().newCall(getUpdateDeviceRegistryMethod(), getCallOptions()), - request, - responseObserver); - } - - /** - * - * - *
-     * Deletes a device registry configuration.
-     * 
- */ - public void deleteDeviceRegistry( - com.google.cloud.iot.v1.DeleteDeviceRegistryRequest request, - io.grpc.stub.StreamObserver responseObserver) { - io.grpc.stub.ClientCalls.asyncUnaryCall( - getChannel().newCall(getDeleteDeviceRegistryMethod(), getCallOptions()), - request, - responseObserver); - } - - /** - * - * - *
-     * Lists device registries.
-     * 
- */ - public void listDeviceRegistries( - com.google.cloud.iot.v1.ListDeviceRegistriesRequest request, - io.grpc.stub.StreamObserver - responseObserver) { - io.grpc.stub.ClientCalls.asyncUnaryCall( - getChannel().newCall(getListDeviceRegistriesMethod(), getCallOptions()), - request, - responseObserver); - } - - /** - * - * - *
-     * Creates a device in a device registry.
-     * 
- */ - public void createDevice( - com.google.cloud.iot.v1.CreateDeviceRequest request, - io.grpc.stub.StreamObserver responseObserver) { - io.grpc.stub.ClientCalls.asyncUnaryCall( - getChannel().newCall(getCreateDeviceMethod(), getCallOptions()), - request, - responseObserver); - } - - /** - * - * - *
-     * Gets details about a device.
-     * 
- */ - public void getDevice( - com.google.cloud.iot.v1.GetDeviceRequest request, - io.grpc.stub.StreamObserver responseObserver) { - io.grpc.stub.ClientCalls.asyncUnaryCall( - getChannel().newCall(getGetDeviceMethod(), getCallOptions()), request, responseObserver); - } - - /** - * - * - *
-     * Updates a device.
-     * 
- */ - public void updateDevice( - com.google.cloud.iot.v1.UpdateDeviceRequest request, - io.grpc.stub.StreamObserver responseObserver) { - io.grpc.stub.ClientCalls.asyncUnaryCall( - getChannel().newCall(getUpdateDeviceMethod(), getCallOptions()), - request, - responseObserver); - } - - /** - * - * - *
-     * Deletes a device.
-     * 
- */ - public void deleteDevice( - com.google.cloud.iot.v1.DeleteDeviceRequest request, - io.grpc.stub.StreamObserver responseObserver) { - io.grpc.stub.ClientCalls.asyncUnaryCall( - getChannel().newCall(getDeleteDeviceMethod(), getCallOptions()), - request, - responseObserver); - } - - /** - * - * - *
-     * List devices in a device registry.
-     * 
- */ - public void listDevices( - com.google.cloud.iot.v1.ListDevicesRequest request, - io.grpc.stub.StreamObserver responseObserver) { - io.grpc.stub.ClientCalls.asyncUnaryCall( - getChannel().newCall(getListDevicesMethod(), getCallOptions()), - request, - responseObserver); - } - - /** - * - * - *
-     * Modifies the configuration for the device, which is eventually sent from
-     * the Cloud IoT Core servers. Returns the modified configuration version and
-     * its metadata.
-     * 
- */ - public void modifyCloudToDeviceConfig( - com.google.cloud.iot.v1.ModifyCloudToDeviceConfigRequest request, - io.grpc.stub.StreamObserver responseObserver) { - io.grpc.stub.ClientCalls.asyncUnaryCall( - getChannel().newCall(getModifyCloudToDeviceConfigMethod(), getCallOptions()), - request, - responseObserver); - } - - /** - * - * - *
-     * Lists the last few versions of the device configuration in descending
-     * order (i.e.: newest first).
-     * 
- */ - public void listDeviceConfigVersions( - com.google.cloud.iot.v1.ListDeviceConfigVersionsRequest request, - io.grpc.stub.StreamObserver - responseObserver) { - io.grpc.stub.ClientCalls.asyncUnaryCall( - getChannel().newCall(getListDeviceConfigVersionsMethod(), getCallOptions()), - request, - responseObserver); - } - - /** - * - * - *
-     * Lists the last few versions of the device state in descending order (i.e.:
-     * newest first).
-     * 
- */ - public void listDeviceStates( - com.google.cloud.iot.v1.ListDeviceStatesRequest request, - io.grpc.stub.StreamObserver - responseObserver) { - io.grpc.stub.ClientCalls.asyncUnaryCall( - getChannel().newCall(getListDeviceStatesMethod(), getCallOptions()), - request, - responseObserver); - } - - /** - * - * - *
-     * Sets the access control policy on the specified resource. Replaces any
-     * existing policy.
-     * 
- */ - public void setIamPolicy( - com.google.iam.v1.SetIamPolicyRequest request, - io.grpc.stub.StreamObserver responseObserver) { - io.grpc.stub.ClientCalls.asyncUnaryCall( - getChannel().newCall(getSetIamPolicyMethod(), getCallOptions()), - request, - responseObserver); - } - - /** - * - * - *
-     * Gets the access control policy for a resource.
-     * Returns an empty policy if the resource exists and does not have a policy
-     * set.
-     * 
- */ - public void getIamPolicy( - com.google.iam.v1.GetIamPolicyRequest request, - io.grpc.stub.StreamObserver responseObserver) { - io.grpc.stub.ClientCalls.asyncUnaryCall( - getChannel().newCall(getGetIamPolicyMethod(), getCallOptions()), - request, - responseObserver); - } - - /** - * - * - *
-     * Returns permissions that a caller has on the specified resource.
-     * If the resource does not exist, this will return an empty set of
-     * permissions, not a NOT_FOUND error.
-     * 
- */ - public void testIamPermissions( - com.google.iam.v1.TestIamPermissionsRequest request, - io.grpc.stub.StreamObserver - responseObserver) { - io.grpc.stub.ClientCalls.asyncUnaryCall( - getChannel().newCall(getTestIamPermissionsMethod(), getCallOptions()), - request, - responseObserver); - } - - /** - * - * - *
-     * Sends a command to the specified device. In order for a device to be able
-     * to receive commands, it must:
-     * 1) be connected to Cloud IoT Core using the MQTT protocol, and
-     * 2) be subscribed to the group of MQTT topics specified by
-     *    /devices/{device-id}/commands/#. This subscription will receive commands
-     *    at the top-level topic /devices/{device-id}/commands as well as commands
-     *    for subfolders, like /devices/{device-id}/commands/subfolder.
-     *    Note that subscribing to specific subfolders is not supported.
-     * If the command could not be delivered to the device, this method will
-     * return an error; in particular, if the device is not subscribed, this
-     * method will return FAILED_PRECONDITION. Otherwise, this method will
-     * return OK. If the subscription is QoS 1, at least once delivery will be
-     * guaranteed; for QoS 0, no acknowledgment will be expected from the device.
-     * 
- */ - public void sendCommandToDevice( - com.google.cloud.iot.v1.SendCommandToDeviceRequest request, - io.grpc.stub.StreamObserver - responseObserver) { - io.grpc.stub.ClientCalls.asyncUnaryCall( - getChannel().newCall(getSendCommandToDeviceMethod(), getCallOptions()), - request, - responseObserver); - } - - /** - * - * - *
-     * Associates the device with the gateway.
-     * 
- */ - public void bindDeviceToGateway( - com.google.cloud.iot.v1.BindDeviceToGatewayRequest request, - io.grpc.stub.StreamObserver - responseObserver) { - io.grpc.stub.ClientCalls.asyncUnaryCall( - getChannel().newCall(getBindDeviceToGatewayMethod(), getCallOptions()), - request, - responseObserver); - } - - /** - * - * - *
-     * Deletes the association between the device and the gateway.
-     * 
- */ - public void unbindDeviceFromGateway( - com.google.cloud.iot.v1.UnbindDeviceFromGatewayRequest request, - io.grpc.stub.StreamObserver - responseObserver) { - io.grpc.stub.ClientCalls.asyncUnaryCall( - getChannel().newCall(getUnbindDeviceFromGatewayMethod(), getCallOptions()), - request, - responseObserver); - } - } - - /** - * - * - *
-   * Internet of Things (IoT) service. Securely connect and manage IoT devices.
-   * 
- */ - public static final class DeviceManagerBlockingStub - extends io.grpc.stub.AbstractBlockingStub { - private DeviceManagerBlockingStub(io.grpc.Channel channel, io.grpc.CallOptions callOptions) { - super(channel, callOptions); - } - - @java.lang.Override - protected DeviceManagerBlockingStub build( - io.grpc.Channel channel, io.grpc.CallOptions callOptions) { - return new DeviceManagerBlockingStub(channel, callOptions); - } - - /** - * - * - *
-     * Creates a device registry that contains devices.
-     * 
- */ - public com.google.cloud.iot.v1.DeviceRegistry createDeviceRegistry( - com.google.cloud.iot.v1.CreateDeviceRegistryRequest request) { - return io.grpc.stub.ClientCalls.blockingUnaryCall( - getChannel(), getCreateDeviceRegistryMethod(), getCallOptions(), request); - } - - /** - * - * - *
-     * Gets a device registry configuration.
-     * 
- */ - public com.google.cloud.iot.v1.DeviceRegistry getDeviceRegistry( - com.google.cloud.iot.v1.GetDeviceRegistryRequest request) { - return io.grpc.stub.ClientCalls.blockingUnaryCall( - getChannel(), getGetDeviceRegistryMethod(), getCallOptions(), request); - } - - /** - * - * - *
-     * Updates a device registry configuration.
-     * 
- */ - public com.google.cloud.iot.v1.DeviceRegistry updateDeviceRegistry( - com.google.cloud.iot.v1.UpdateDeviceRegistryRequest request) { - return io.grpc.stub.ClientCalls.blockingUnaryCall( - getChannel(), getUpdateDeviceRegistryMethod(), getCallOptions(), request); - } - - /** - * - * - *
-     * Deletes a device registry configuration.
-     * 
- */ - public com.google.protobuf.Empty deleteDeviceRegistry( - com.google.cloud.iot.v1.DeleteDeviceRegistryRequest request) { - return io.grpc.stub.ClientCalls.blockingUnaryCall( - getChannel(), getDeleteDeviceRegistryMethod(), getCallOptions(), request); - } - - /** - * - * - *
-     * Lists device registries.
-     * 
- */ - public com.google.cloud.iot.v1.ListDeviceRegistriesResponse listDeviceRegistries( - com.google.cloud.iot.v1.ListDeviceRegistriesRequest request) { - return io.grpc.stub.ClientCalls.blockingUnaryCall( - getChannel(), getListDeviceRegistriesMethod(), getCallOptions(), request); - } - - /** - * - * - *
-     * Creates a device in a device registry.
-     * 
- */ - public com.google.cloud.iot.v1.Device createDevice( - com.google.cloud.iot.v1.CreateDeviceRequest request) { - return io.grpc.stub.ClientCalls.blockingUnaryCall( - getChannel(), getCreateDeviceMethod(), getCallOptions(), request); - } - - /** - * - * - *
-     * Gets details about a device.
-     * 
- */ - public com.google.cloud.iot.v1.Device getDevice( - com.google.cloud.iot.v1.GetDeviceRequest request) { - return io.grpc.stub.ClientCalls.blockingUnaryCall( - getChannel(), getGetDeviceMethod(), getCallOptions(), request); - } - - /** - * - * - *
-     * Updates a device.
-     * 
- */ - public com.google.cloud.iot.v1.Device updateDevice( - com.google.cloud.iot.v1.UpdateDeviceRequest request) { - return io.grpc.stub.ClientCalls.blockingUnaryCall( - getChannel(), getUpdateDeviceMethod(), getCallOptions(), request); - } - - /** - * - * - *
-     * Deletes a device.
-     * 
- */ - public com.google.protobuf.Empty deleteDevice( - com.google.cloud.iot.v1.DeleteDeviceRequest request) { - return io.grpc.stub.ClientCalls.blockingUnaryCall( - getChannel(), getDeleteDeviceMethod(), getCallOptions(), request); - } - - /** - * - * - *
-     * List devices in a device registry.
-     * 
- */ - public com.google.cloud.iot.v1.ListDevicesResponse listDevices( - com.google.cloud.iot.v1.ListDevicesRequest request) { - return io.grpc.stub.ClientCalls.blockingUnaryCall( - getChannel(), getListDevicesMethod(), getCallOptions(), request); - } - - /** - * - * - *
-     * Modifies the configuration for the device, which is eventually sent from
-     * the Cloud IoT Core servers. Returns the modified configuration version and
-     * its metadata.
-     * 
- */ - public com.google.cloud.iot.v1.DeviceConfig modifyCloudToDeviceConfig( - com.google.cloud.iot.v1.ModifyCloudToDeviceConfigRequest request) { - return io.grpc.stub.ClientCalls.blockingUnaryCall( - getChannel(), getModifyCloudToDeviceConfigMethod(), getCallOptions(), request); - } - - /** - * - * - *
-     * Lists the last few versions of the device configuration in descending
-     * order (i.e.: newest first).
-     * 
- */ - public com.google.cloud.iot.v1.ListDeviceConfigVersionsResponse listDeviceConfigVersions( - com.google.cloud.iot.v1.ListDeviceConfigVersionsRequest request) { - return io.grpc.stub.ClientCalls.blockingUnaryCall( - getChannel(), getListDeviceConfigVersionsMethod(), getCallOptions(), request); - } - - /** - * - * - *
-     * Lists the last few versions of the device state in descending order (i.e.:
-     * newest first).
-     * 
- */ - public com.google.cloud.iot.v1.ListDeviceStatesResponse listDeviceStates( - com.google.cloud.iot.v1.ListDeviceStatesRequest request) { - return io.grpc.stub.ClientCalls.blockingUnaryCall( - getChannel(), getListDeviceStatesMethod(), getCallOptions(), request); - } - - /** - * - * - *
-     * Sets the access control policy on the specified resource. Replaces any
-     * existing policy.
-     * 
- */ - public com.google.iam.v1.Policy setIamPolicy(com.google.iam.v1.SetIamPolicyRequest request) { - return io.grpc.stub.ClientCalls.blockingUnaryCall( - getChannel(), getSetIamPolicyMethod(), getCallOptions(), request); - } - - /** - * - * - *
-     * Gets the access control policy for a resource.
-     * Returns an empty policy if the resource exists and does not have a policy
-     * set.
-     * 
- */ - public com.google.iam.v1.Policy getIamPolicy(com.google.iam.v1.GetIamPolicyRequest request) { - return io.grpc.stub.ClientCalls.blockingUnaryCall( - getChannel(), getGetIamPolicyMethod(), getCallOptions(), request); - } - - /** - * - * - *
-     * Returns permissions that a caller has on the specified resource.
-     * If the resource does not exist, this will return an empty set of
-     * permissions, not a NOT_FOUND error.
-     * 
- */ - public com.google.iam.v1.TestIamPermissionsResponse testIamPermissions( - com.google.iam.v1.TestIamPermissionsRequest request) { - return io.grpc.stub.ClientCalls.blockingUnaryCall( - getChannel(), getTestIamPermissionsMethod(), getCallOptions(), request); - } - - /** - * - * - *
-     * Sends a command to the specified device. In order for a device to be able
-     * to receive commands, it must:
-     * 1) be connected to Cloud IoT Core using the MQTT protocol, and
-     * 2) be subscribed to the group of MQTT topics specified by
-     *    /devices/{device-id}/commands/#. This subscription will receive commands
-     *    at the top-level topic /devices/{device-id}/commands as well as commands
-     *    for subfolders, like /devices/{device-id}/commands/subfolder.
-     *    Note that subscribing to specific subfolders is not supported.
-     * If the command could not be delivered to the device, this method will
-     * return an error; in particular, if the device is not subscribed, this
-     * method will return FAILED_PRECONDITION. Otherwise, this method will
-     * return OK. If the subscription is QoS 1, at least once delivery will be
-     * guaranteed; for QoS 0, no acknowledgment will be expected from the device.
-     * 
- */ - public com.google.cloud.iot.v1.SendCommandToDeviceResponse sendCommandToDevice( - com.google.cloud.iot.v1.SendCommandToDeviceRequest request) { - return io.grpc.stub.ClientCalls.blockingUnaryCall( - getChannel(), getSendCommandToDeviceMethod(), getCallOptions(), request); - } - - /** - * - * - *
-     * Associates the device with the gateway.
-     * 
- */ - public com.google.cloud.iot.v1.BindDeviceToGatewayResponse bindDeviceToGateway( - com.google.cloud.iot.v1.BindDeviceToGatewayRequest request) { - return io.grpc.stub.ClientCalls.blockingUnaryCall( - getChannel(), getBindDeviceToGatewayMethod(), getCallOptions(), request); - } - - /** - * - * - *
-     * Deletes the association between the device and the gateway.
-     * 
- */ - public com.google.cloud.iot.v1.UnbindDeviceFromGatewayResponse unbindDeviceFromGateway( - com.google.cloud.iot.v1.UnbindDeviceFromGatewayRequest request) { - return io.grpc.stub.ClientCalls.blockingUnaryCall( - getChannel(), getUnbindDeviceFromGatewayMethod(), getCallOptions(), request); - } - } - - /** - * - * - *
-   * Internet of Things (IoT) service. Securely connect and manage IoT devices.
-   * 
- */ - public static final class DeviceManagerFutureStub - extends io.grpc.stub.AbstractFutureStub { - private DeviceManagerFutureStub(io.grpc.Channel channel, io.grpc.CallOptions callOptions) { - super(channel, callOptions); - } - - @java.lang.Override - protected DeviceManagerFutureStub build( - io.grpc.Channel channel, io.grpc.CallOptions callOptions) { - return new DeviceManagerFutureStub(channel, callOptions); - } - - /** - * - * - *
-     * Creates a device registry that contains devices.
-     * 
- */ - public com.google.common.util.concurrent.ListenableFuture< - com.google.cloud.iot.v1.DeviceRegistry> - createDeviceRegistry(com.google.cloud.iot.v1.CreateDeviceRegistryRequest request) { - return io.grpc.stub.ClientCalls.futureUnaryCall( - getChannel().newCall(getCreateDeviceRegistryMethod(), getCallOptions()), request); - } - - /** - * - * - *
-     * Gets a device registry configuration.
-     * 
- */ - public com.google.common.util.concurrent.ListenableFuture< - com.google.cloud.iot.v1.DeviceRegistry> - getDeviceRegistry(com.google.cloud.iot.v1.GetDeviceRegistryRequest request) { - return io.grpc.stub.ClientCalls.futureUnaryCall( - getChannel().newCall(getGetDeviceRegistryMethod(), getCallOptions()), request); - } - - /** - * - * - *
-     * Updates a device registry configuration.
-     * 
- */ - public com.google.common.util.concurrent.ListenableFuture< - com.google.cloud.iot.v1.DeviceRegistry> - updateDeviceRegistry(com.google.cloud.iot.v1.UpdateDeviceRegistryRequest request) { - return io.grpc.stub.ClientCalls.futureUnaryCall( - getChannel().newCall(getUpdateDeviceRegistryMethod(), getCallOptions()), request); - } - - /** - * - * - *
-     * Deletes a device registry configuration.
-     * 
- */ - public com.google.common.util.concurrent.ListenableFuture - deleteDeviceRegistry(com.google.cloud.iot.v1.DeleteDeviceRegistryRequest request) { - return io.grpc.stub.ClientCalls.futureUnaryCall( - getChannel().newCall(getDeleteDeviceRegistryMethod(), getCallOptions()), request); - } - - /** - * - * - *
-     * Lists device registries.
-     * 
- */ - public com.google.common.util.concurrent.ListenableFuture< - com.google.cloud.iot.v1.ListDeviceRegistriesResponse> - listDeviceRegistries(com.google.cloud.iot.v1.ListDeviceRegistriesRequest request) { - return io.grpc.stub.ClientCalls.futureUnaryCall( - getChannel().newCall(getListDeviceRegistriesMethod(), getCallOptions()), request); - } - - /** - * - * - *
-     * Creates a device in a device registry.
-     * 
- */ - public com.google.common.util.concurrent.ListenableFuture - createDevice(com.google.cloud.iot.v1.CreateDeviceRequest request) { - return io.grpc.stub.ClientCalls.futureUnaryCall( - getChannel().newCall(getCreateDeviceMethod(), getCallOptions()), request); - } - - /** - * - * - *
-     * Gets details about a device.
-     * 
- */ - public com.google.common.util.concurrent.ListenableFuture - getDevice(com.google.cloud.iot.v1.GetDeviceRequest request) { - return io.grpc.stub.ClientCalls.futureUnaryCall( - getChannel().newCall(getGetDeviceMethod(), getCallOptions()), request); - } - - /** - * - * - *
-     * Updates a device.
-     * 
- */ - public com.google.common.util.concurrent.ListenableFuture - updateDevice(com.google.cloud.iot.v1.UpdateDeviceRequest request) { - return io.grpc.stub.ClientCalls.futureUnaryCall( - getChannel().newCall(getUpdateDeviceMethod(), getCallOptions()), request); - } - - /** - * - * - *
-     * Deletes a device.
-     * 
- */ - public com.google.common.util.concurrent.ListenableFuture - deleteDevice(com.google.cloud.iot.v1.DeleteDeviceRequest request) { - return io.grpc.stub.ClientCalls.futureUnaryCall( - getChannel().newCall(getDeleteDeviceMethod(), getCallOptions()), request); - } - - /** - * - * - *
-     * List devices in a device registry.
-     * 
- */ - public com.google.common.util.concurrent.ListenableFuture< - com.google.cloud.iot.v1.ListDevicesResponse> - listDevices(com.google.cloud.iot.v1.ListDevicesRequest request) { - return io.grpc.stub.ClientCalls.futureUnaryCall( - getChannel().newCall(getListDevicesMethod(), getCallOptions()), request); - } - - /** - * - * - *
-     * Modifies the configuration for the device, which is eventually sent from
-     * the Cloud IoT Core servers. Returns the modified configuration version and
-     * its metadata.
-     * 
- */ - public com.google.common.util.concurrent.ListenableFuture - modifyCloudToDeviceConfig( - com.google.cloud.iot.v1.ModifyCloudToDeviceConfigRequest request) { - return io.grpc.stub.ClientCalls.futureUnaryCall( - getChannel().newCall(getModifyCloudToDeviceConfigMethod(), getCallOptions()), request); - } - - /** - * - * - *
-     * Lists the last few versions of the device configuration in descending
-     * order (i.e.: newest first).
-     * 
- */ - public com.google.common.util.concurrent.ListenableFuture< - com.google.cloud.iot.v1.ListDeviceConfigVersionsResponse> - listDeviceConfigVersions(com.google.cloud.iot.v1.ListDeviceConfigVersionsRequest request) { - return io.grpc.stub.ClientCalls.futureUnaryCall( - getChannel().newCall(getListDeviceConfigVersionsMethod(), getCallOptions()), request); - } - - /** - * - * - *
-     * Lists the last few versions of the device state in descending order (i.e.:
-     * newest first).
-     * 
- */ - public com.google.common.util.concurrent.ListenableFuture< - com.google.cloud.iot.v1.ListDeviceStatesResponse> - listDeviceStates(com.google.cloud.iot.v1.ListDeviceStatesRequest request) { - return io.grpc.stub.ClientCalls.futureUnaryCall( - getChannel().newCall(getListDeviceStatesMethod(), getCallOptions()), request); - } - - /** - * - * - *
-     * Sets the access control policy on the specified resource. Replaces any
-     * existing policy.
-     * 
- */ - public com.google.common.util.concurrent.ListenableFuture - setIamPolicy(com.google.iam.v1.SetIamPolicyRequest request) { - return io.grpc.stub.ClientCalls.futureUnaryCall( - getChannel().newCall(getSetIamPolicyMethod(), getCallOptions()), request); - } - - /** - * - * - *
-     * Gets the access control policy for a resource.
-     * Returns an empty policy if the resource exists and does not have a policy
-     * set.
-     * 
- */ - public com.google.common.util.concurrent.ListenableFuture - getIamPolicy(com.google.iam.v1.GetIamPolicyRequest request) { - return io.grpc.stub.ClientCalls.futureUnaryCall( - getChannel().newCall(getGetIamPolicyMethod(), getCallOptions()), request); - } - - /** - * - * - *
-     * Returns permissions that a caller has on the specified resource.
-     * If the resource does not exist, this will return an empty set of
-     * permissions, not a NOT_FOUND error.
-     * 
- */ - public com.google.common.util.concurrent.ListenableFuture< - com.google.iam.v1.TestIamPermissionsResponse> - testIamPermissions(com.google.iam.v1.TestIamPermissionsRequest request) { - return io.grpc.stub.ClientCalls.futureUnaryCall( - getChannel().newCall(getTestIamPermissionsMethod(), getCallOptions()), request); - } - - /** - * - * - *
-     * Sends a command to the specified device. In order for a device to be able
-     * to receive commands, it must:
-     * 1) be connected to Cloud IoT Core using the MQTT protocol, and
-     * 2) be subscribed to the group of MQTT topics specified by
-     *    /devices/{device-id}/commands/#. This subscription will receive commands
-     *    at the top-level topic /devices/{device-id}/commands as well as commands
-     *    for subfolders, like /devices/{device-id}/commands/subfolder.
-     *    Note that subscribing to specific subfolders is not supported.
-     * If the command could not be delivered to the device, this method will
-     * return an error; in particular, if the device is not subscribed, this
-     * method will return FAILED_PRECONDITION. Otherwise, this method will
-     * return OK. If the subscription is QoS 1, at least once delivery will be
-     * guaranteed; for QoS 0, no acknowledgment will be expected from the device.
-     * 
- */ - public com.google.common.util.concurrent.ListenableFuture< - com.google.cloud.iot.v1.SendCommandToDeviceResponse> - sendCommandToDevice(com.google.cloud.iot.v1.SendCommandToDeviceRequest request) { - return io.grpc.stub.ClientCalls.futureUnaryCall( - getChannel().newCall(getSendCommandToDeviceMethod(), getCallOptions()), request); - } - - /** - * - * - *
-     * Associates the device with the gateway.
-     * 
- */ - public com.google.common.util.concurrent.ListenableFuture< - com.google.cloud.iot.v1.BindDeviceToGatewayResponse> - bindDeviceToGateway(com.google.cloud.iot.v1.BindDeviceToGatewayRequest request) { - return io.grpc.stub.ClientCalls.futureUnaryCall( - getChannel().newCall(getBindDeviceToGatewayMethod(), getCallOptions()), request); - } - - /** - * - * - *
-     * Deletes the association between the device and the gateway.
-     * 
- */ - public com.google.common.util.concurrent.ListenableFuture< - com.google.cloud.iot.v1.UnbindDeviceFromGatewayResponse> - unbindDeviceFromGateway(com.google.cloud.iot.v1.UnbindDeviceFromGatewayRequest request) { - return io.grpc.stub.ClientCalls.futureUnaryCall( - getChannel().newCall(getUnbindDeviceFromGatewayMethod(), getCallOptions()), request); - } - } - - private static final int METHODID_CREATE_DEVICE_REGISTRY = 0; - private static final int METHODID_GET_DEVICE_REGISTRY = 1; - private static final int METHODID_UPDATE_DEVICE_REGISTRY = 2; - private static final int METHODID_DELETE_DEVICE_REGISTRY = 3; - private static final int METHODID_LIST_DEVICE_REGISTRIES = 4; - private static final int METHODID_CREATE_DEVICE = 5; - private static final int METHODID_GET_DEVICE = 6; - private static final int METHODID_UPDATE_DEVICE = 7; - private static final int METHODID_DELETE_DEVICE = 8; - private static final int METHODID_LIST_DEVICES = 9; - private static final int METHODID_MODIFY_CLOUD_TO_DEVICE_CONFIG = 10; - private static final int METHODID_LIST_DEVICE_CONFIG_VERSIONS = 11; - private static final int METHODID_LIST_DEVICE_STATES = 12; - private static final int METHODID_SET_IAM_POLICY = 13; - private static final int METHODID_GET_IAM_POLICY = 14; - private static final int METHODID_TEST_IAM_PERMISSIONS = 15; - private static final int METHODID_SEND_COMMAND_TO_DEVICE = 16; - private static final int METHODID_BIND_DEVICE_TO_GATEWAY = 17; - private static final int METHODID_UNBIND_DEVICE_FROM_GATEWAY = 18; - - private static final class MethodHandlers - implements io.grpc.stub.ServerCalls.UnaryMethod, - io.grpc.stub.ServerCalls.ServerStreamingMethod, - io.grpc.stub.ServerCalls.ClientStreamingMethod, - io.grpc.stub.ServerCalls.BidiStreamingMethod { - private final DeviceManagerImplBase serviceImpl; - private final int methodId; - - MethodHandlers(DeviceManagerImplBase serviceImpl, int methodId) { - this.serviceImpl = serviceImpl; - this.methodId = methodId; - } - - @java.lang.Override - @java.lang.SuppressWarnings("unchecked") - public void invoke(Req request, io.grpc.stub.StreamObserver responseObserver) { - switch (methodId) { - case METHODID_CREATE_DEVICE_REGISTRY: - serviceImpl.createDeviceRegistry( - (com.google.cloud.iot.v1.CreateDeviceRegistryRequest) request, - (io.grpc.stub.StreamObserver) - responseObserver); - break; - case METHODID_GET_DEVICE_REGISTRY: - serviceImpl.getDeviceRegistry( - (com.google.cloud.iot.v1.GetDeviceRegistryRequest) request, - (io.grpc.stub.StreamObserver) - responseObserver); - break; - case METHODID_UPDATE_DEVICE_REGISTRY: - serviceImpl.updateDeviceRegistry( - (com.google.cloud.iot.v1.UpdateDeviceRegistryRequest) request, - (io.grpc.stub.StreamObserver) - responseObserver); - break; - case METHODID_DELETE_DEVICE_REGISTRY: - serviceImpl.deleteDeviceRegistry( - (com.google.cloud.iot.v1.DeleteDeviceRegistryRequest) request, - (io.grpc.stub.StreamObserver) responseObserver); - break; - case METHODID_LIST_DEVICE_REGISTRIES: - serviceImpl.listDeviceRegistries( - (com.google.cloud.iot.v1.ListDeviceRegistriesRequest) request, - (io.grpc.stub.StreamObserver) - responseObserver); - break; - case METHODID_CREATE_DEVICE: - serviceImpl.createDevice( - (com.google.cloud.iot.v1.CreateDeviceRequest) request, - (io.grpc.stub.StreamObserver) responseObserver); - break; - case METHODID_GET_DEVICE: - serviceImpl.getDevice( - (com.google.cloud.iot.v1.GetDeviceRequest) request, - (io.grpc.stub.StreamObserver) responseObserver); - break; - case METHODID_UPDATE_DEVICE: - serviceImpl.updateDevice( - (com.google.cloud.iot.v1.UpdateDeviceRequest) request, - (io.grpc.stub.StreamObserver) responseObserver); - break; - case METHODID_DELETE_DEVICE: - serviceImpl.deleteDevice( - (com.google.cloud.iot.v1.DeleteDeviceRequest) request, - (io.grpc.stub.StreamObserver) responseObserver); - break; - case METHODID_LIST_DEVICES: - serviceImpl.listDevices( - (com.google.cloud.iot.v1.ListDevicesRequest) request, - (io.grpc.stub.StreamObserver) - responseObserver); - break; - case METHODID_MODIFY_CLOUD_TO_DEVICE_CONFIG: - serviceImpl.modifyCloudToDeviceConfig( - (com.google.cloud.iot.v1.ModifyCloudToDeviceConfigRequest) request, - (io.grpc.stub.StreamObserver) responseObserver); - break; - case METHODID_LIST_DEVICE_CONFIG_VERSIONS: - serviceImpl.listDeviceConfigVersions( - (com.google.cloud.iot.v1.ListDeviceConfigVersionsRequest) request, - (io.grpc.stub.StreamObserver< - com.google.cloud.iot.v1.ListDeviceConfigVersionsResponse>) - responseObserver); - break; - case METHODID_LIST_DEVICE_STATES: - serviceImpl.listDeviceStates( - (com.google.cloud.iot.v1.ListDeviceStatesRequest) request, - (io.grpc.stub.StreamObserver) - responseObserver); - break; - case METHODID_SET_IAM_POLICY: - serviceImpl.setIamPolicy( - (com.google.iam.v1.SetIamPolicyRequest) request, - (io.grpc.stub.StreamObserver) responseObserver); - break; - case METHODID_GET_IAM_POLICY: - serviceImpl.getIamPolicy( - (com.google.iam.v1.GetIamPolicyRequest) request, - (io.grpc.stub.StreamObserver) responseObserver); - break; - case METHODID_TEST_IAM_PERMISSIONS: - serviceImpl.testIamPermissions( - (com.google.iam.v1.TestIamPermissionsRequest) request, - (io.grpc.stub.StreamObserver) - responseObserver); - break; - case METHODID_SEND_COMMAND_TO_DEVICE: - serviceImpl.sendCommandToDevice( - (com.google.cloud.iot.v1.SendCommandToDeviceRequest) request, - (io.grpc.stub.StreamObserver) - responseObserver); - break; - case METHODID_BIND_DEVICE_TO_GATEWAY: - serviceImpl.bindDeviceToGateway( - (com.google.cloud.iot.v1.BindDeviceToGatewayRequest) request, - (io.grpc.stub.StreamObserver) - responseObserver); - break; - case METHODID_UNBIND_DEVICE_FROM_GATEWAY: - serviceImpl.unbindDeviceFromGateway( - (com.google.cloud.iot.v1.UnbindDeviceFromGatewayRequest) request, - (io.grpc.stub.StreamObserver) - responseObserver); - break; - default: - throw new AssertionError(); - } - } - - @java.lang.Override - @java.lang.SuppressWarnings("unchecked") - public io.grpc.stub.StreamObserver invoke( - io.grpc.stub.StreamObserver responseObserver) { - switch (methodId) { - default: - throw new AssertionError(); - } - } - } - - private abstract static class DeviceManagerBaseDescriptorSupplier - implements io.grpc.protobuf.ProtoFileDescriptorSupplier, - io.grpc.protobuf.ProtoServiceDescriptorSupplier { - DeviceManagerBaseDescriptorSupplier() {} - - @java.lang.Override - public com.google.protobuf.Descriptors.FileDescriptor getFileDescriptor() { - return com.google.cloud.iot.v1.DeviceManagerProto.getDescriptor(); - } - - @java.lang.Override - public com.google.protobuf.Descriptors.ServiceDescriptor getServiceDescriptor() { - return getFileDescriptor().findServiceByName("DeviceManager"); - } - } - - private static final class DeviceManagerFileDescriptorSupplier - extends DeviceManagerBaseDescriptorSupplier { - DeviceManagerFileDescriptorSupplier() {} - } - - private static final class DeviceManagerMethodDescriptorSupplier - extends DeviceManagerBaseDescriptorSupplier - implements io.grpc.protobuf.ProtoMethodDescriptorSupplier { - private final String methodName; - - DeviceManagerMethodDescriptorSupplier(String methodName) { - this.methodName = methodName; - } - - @java.lang.Override - public com.google.protobuf.Descriptors.MethodDescriptor getMethodDescriptor() { - return getServiceDescriptor().findMethodByName(methodName); - } - } - - private static volatile io.grpc.ServiceDescriptor serviceDescriptor; - - public static io.grpc.ServiceDescriptor getServiceDescriptor() { - io.grpc.ServiceDescriptor result = serviceDescriptor; - if (result == null) { - synchronized (DeviceManagerGrpc.class) { - result = serviceDescriptor; - if (result == null) { - serviceDescriptor = - result = - io.grpc.ServiceDescriptor.newBuilder(SERVICE_NAME) - .setSchemaDescriptor(new DeviceManagerFileDescriptorSupplier()) - .addMethod(getCreateDeviceRegistryMethod()) - .addMethod(getGetDeviceRegistryMethod()) - .addMethod(getUpdateDeviceRegistryMethod()) - .addMethod(getDeleteDeviceRegistryMethod()) - .addMethod(getListDeviceRegistriesMethod()) - .addMethod(getCreateDeviceMethod()) - .addMethod(getGetDeviceMethod()) - .addMethod(getUpdateDeviceMethod()) - .addMethod(getDeleteDeviceMethod()) - .addMethod(getListDevicesMethod()) - .addMethod(getModifyCloudToDeviceConfigMethod()) - .addMethod(getListDeviceConfigVersionsMethod()) - .addMethod(getListDeviceStatesMethod()) - .addMethod(getSetIamPolicyMethod()) - .addMethod(getGetIamPolicyMethod()) - .addMethod(getTestIamPermissionsMethod()) - .addMethod(getSendCommandToDeviceMethod()) - .addMethod(getBindDeviceToGatewayMethod()) - .addMethod(getUnbindDeviceFromGatewayMethod()) - .build(); - } - } - } - return result; - } -} diff --git a/java.header b/java.header deleted file mode 100644 index d0970ba7..00000000 --- a/java.header +++ /dev/null @@ -1,15 +0,0 @@ -^/\*$ -^ \* Copyright \d\d\d\d,? Google (Inc\.|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\.$ -^ \*/$ diff --git a/license-checks.xml b/license-checks.xml deleted file mode 100644 index 6597fced..00000000 --- a/license-checks.xml +++ /dev/null @@ -1,10 +0,0 @@ - - - - - - - - diff --git a/owlbot.py b/owlbot.py deleted file mode 100644 index dbd07138..00000000 --- a/owlbot.py +++ /dev/null @@ -1,24 +0,0 @@ -# Copyright 2021 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# 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. - -import synthtool as s -from synthtool.languages import java - - -for library in s.get_staging_dirs(): - # put any special-case replacements here - s.move(library) - -s.remove_staging_dirs() -java.common_templates(excludes=[".github/blunderbuss.yml"]) diff --git a/pom.xml b/pom.xml deleted file mode 100644 index 29828aa8..00000000 --- a/pom.xml +++ /dev/null @@ -1,187 +0,0 @@ - - - 4.0.0 - com.google.cloud - google-cloud-iot-parent - pom - 2.3.5 - Google Cloud IoT Core Parent - https://github.com/googleapis/java-iot - - Java idiomatic client for Google Cloud Platform services. - - - - com.google.cloud - google-cloud-shared-config - 1.5.3 - - - - - chingor - Jeff Ching - chingor@google.com - Google - - Developer - - - - - Google LLC - - - scm:git:git@github.com:googleapis/java-iot.git - scm:git:git@github.com:googleapis/java-iot.git - https://github.com/googleapis/java-iot - HEAD - - - https://github.com/googleapis/java-iot/issues - GitHub Issues - - - - - Apache-2.0 - https://www.apache.org/licenses/LICENSE-2.0.txt - - - - - UTF-8 - UTF-8 - github - google-cloud-iot-parent - - - - - - com.google.api.grpc - proto-google-cloud-iot-v1 - 2.3.5 - - - com.google.api.grpc - grpc-google-cloud-iot-v1 - 2.3.5 - - - com.google.cloud - google-cloud-iot - 2.3.5 - - - - com.google.cloud - google-cloud-shared-dependencies - 3.0.4 - pom - import - - - - junit - junit - 4.13.2 - test - - - - - - - - - org.apache.maven.plugins - maven-dependency-plugin - - - org.objenesis:objenesis - javax.annotation:javax.annotation-api - - - - - - - - - google-cloud-iot - grpc-google-cloud-iot-v1 - proto-google-cloud-iot-v1 - google-cloud-iot-bom - - - - - - org.apache.maven.plugins - maven-project-info-reports-plugin - 3.4.1 - - - - index - dependency-info - team - ci-management - issue-management - licenses - scm - dependency-management - distribution-management - summary - modules - - - - - true - ${site.installationModule} - jar - - - - org.apache.maven.plugins - maven-javadoc-plugin - 3.4.1 - - - html - - aggregate - javadoc - - - - - none - protected - true - ${project.build.directory}/javadoc - - - Test helpers packages - com.google.cloud.testing - - - SPI packages - com.google.cloud.spi* - - - - - https://grpc.io/grpc-java/javadoc/ - https://developers.google.com/protocol-buffers/docs/reference/java/ - https://googleapis.dev/java/google-auth-library/latest/ - https://googleapis.dev/java/gax/latest/ - https://googleapis.github.io/api-common-java/ - - - - - - diff --git a/proto-google-cloud-iot-v1/clirr-ignored-differences.xml b/proto-google-cloud-iot-v1/clirr-ignored-differences.xml deleted file mode 100644 index 74f44694..00000000 --- a/proto-google-cloud-iot-v1/clirr-ignored-differences.xml +++ /dev/null @@ -1,19 +0,0 @@ - - - - - 7012 - com/google/cloud/iot/v1/*OrBuilder - * get*(*) - - - 7012 - com/google/cloud/iot/v1/*OrBuilder - boolean contains*(*) - - - 7012 - com/google/cloud/iot/v1/*OrBuilder - boolean has*(*) - - diff --git a/proto-google-cloud-iot-v1/pom.xml b/proto-google-cloud-iot-v1/pom.xml deleted file mode 100644 index b9a41024..00000000 --- a/proto-google-cloud-iot-v1/pom.xml +++ /dev/null @@ -1,46 +0,0 @@ - - 4.0.0 - com.google.api.grpc - proto-google-cloud-iot-v1 - 2.3.5 - proto-google-cloud-iot-v1 - PROTO library for proto-google-cloud-iot-v1 - - com.google.cloud - google-cloud-iot-parent - 2.3.5 - - - - com.google.protobuf - protobuf-java - - - com.google.api.grpc - proto-google-common-protos - - - com.google.api.grpc - proto-google-iam-v1 - - - com.google.api - api-common - - - com.google.guava - guava - - - - - - - org.codehaus.mojo - flatten-maven-plugin - - - - \ No newline at end of file diff --git a/proto-google-cloud-iot-v1/src/main/java/com/google/cloud/iot/v1/BindDeviceToGatewayRequest.java b/proto-google-cloud-iot-v1/src/main/java/com/google/cloud/iot/v1/BindDeviceToGatewayRequest.java deleted file mode 100644 index d1c9eb8a..00000000 --- a/proto-google-cloud-iot-v1/src/main/java/com/google/cloud/iot/v1/BindDeviceToGatewayRequest.java +++ /dev/null @@ -1,1013 +0,0 @@ -/* - * Copyright 2020 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. - */ -// Generated by the protocol buffer compiler. DO NOT EDIT! -// source: google/cloud/iot/v1/device_manager.proto - -package com.google.cloud.iot.v1; - -/** - * - * - *
- * Request for `BindDeviceToGateway`.
- * 
- * - * Protobuf type {@code google.cloud.iot.v1.BindDeviceToGatewayRequest} - */ -public final class BindDeviceToGatewayRequest extends com.google.protobuf.GeneratedMessageV3 - implements - // @@protoc_insertion_point(message_implements:google.cloud.iot.v1.BindDeviceToGatewayRequest) - BindDeviceToGatewayRequestOrBuilder { - private static final long serialVersionUID = 0L; - // Use BindDeviceToGatewayRequest.newBuilder() to construct. - private BindDeviceToGatewayRequest(com.google.protobuf.GeneratedMessageV3.Builder builder) { - super(builder); - } - - private BindDeviceToGatewayRequest() { - parent_ = ""; - gatewayId_ = ""; - deviceId_ = ""; - } - - @java.lang.Override - @SuppressWarnings({"unused"}) - protected java.lang.Object newInstance(UnusedPrivateParameter unused) { - return new BindDeviceToGatewayRequest(); - } - - @java.lang.Override - public final com.google.protobuf.UnknownFieldSet getUnknownFields() { - return this.unknownFields; - } - - public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { - return com.google.cloud.iot.v1.DeviceManagerProto - .internal_static_google_cloud_iot_v1_BindDeviceToGatewayRequest_descriptor; - } - - @java.lang.Override - protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable - internalGetFieldAccessorTable() { - return com.google.cloud.iot.v1.DeviceManagerProto - .internal_static_google_cloud_iot_v1_BindDeviceToGatewayRequest_fieldAccessorTable - .ensureFieldAccessorsInitialized( - com.google.cloud.iot.v1.BindDeviceToGatewayRequest.class, - com.google.cloud.iot.v1.BindDeviceToGatewayRequest.Builder.class); - } - - public static final int PARENT_FIELD_NUMBER = 1; - private volatile java.lang.Object parent_; - /** - * - * - *
-   * Required. The name of the registry. For example,
-   * `projects/example-project/locations/us-central1/registries/my-registry`.
-   * 
- * - * - * string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } - * - * - * @return The parent. - */ - @java.lang.Override - public java.lang.String getParent() { - java.lang.Object ref = parent_; - if (ref instanceof java.lang.String) { - return (java.lang.String) ref; - } else { - com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; - java.lang.String s = bs.toStringUtf8(); - parent_ = s; - return s; - } - } - /** - * - * - *
-   * Required. The name of the registry. For example,
-   * `projects/example-project/locations/us-central1/registries/my-registry`.
-   * 
- * - * - * string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } - * - * - * @return The bytes for parent. - */ - @java.lang.Override - public com.google.protobuf.ByteString getParentBytes() { - java.lang.Object ref = parent_; - if (ref instanceof java.lang.String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); - parent_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - - public static final int GATEWAY_ID_FIELD_NUMBER = 2; - private volatile java.lang.Object gatewayId_; - /** - * - * - *
-   * Required. The value of `gateway_id` can be either the device numeric ID or the
-   * user-defined device identifier.
-   * 
- * - * string gateway_id = 2 [(.google.api.field_behavior) = REQUIRED]; - * - * @return The gatewayId. - */ - @java.lang.Override - public java.lang.String getGatewayId() { - java.lang.Object ref = gatewayId_; - if (ref instanceof java.lang.String) { - return (java.lang.String) ref; - } else { - com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; - java.lang.String s = bs.toStringUtf8(); - gatewayId_ = s; - return s; - } - } - /** - * - * - *
-   * Required. The value of `gateway_id` can be either the device numeric ID or the
-   * user-defined device identifier.
-   * 
- * - * string gateway_id = 2 [(.google.api.field_behavior) = REQUIRED]; - * - * @return The bytes for gatewayId. - */ - @java.lang.Override - public com.google.protobuf.ByteString getGatewayIdBytes() { - java.lang.Object ref = gatewayId_; - if (ref instanceof java.lang.String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); - gatewayId_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - - public static final int DEVICE_ID_FIELD_NUMBER = 3; - private volatile java.lang.Object deviceId_; - /** - * - * - *
-   * Required. The device to associate with the specified gateway. The value of
-   * `device_id` can be either the device numeric ID or the user-defined device
-   * identifier.
-   * 
- * - * string device_id = 3 [(.google.api.field_behavior) = REQUIRED]; - * - * @return The deviceId. - */ - @java.lang.Override - public java.lang.String getDeviceId() { - java.lang.Object ref = deviceId_; - if (ref instanceof java.lang.String) { - return (java.lang.String) ref; - } else { - com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; - java.lang.String s = bs.toStringUtf8(); - deviceId_ = s; - return s; - } - } - /** - * - * - *
-   * Required. The device to associate with the specified gateway. The value of
-   * `device_id` can be either the device numeric ID or the user-defined device
-   * identifier.
-   * 
- * - * string device_id = 3 [(.google.api.field_behavior) = REQUIRED]; - * - * @return The bytes for deviceId. - */ - @java.lang.Override - public com.google.protobuf.ByteString getDeviceIdBytes() { - java.lang.Object ref = deviceId_; - if (ref instanceof java.lang.String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); - deviceId_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - - private byte memoizedIsInitialized = -1; - - @java.lang.Override - public final boolean isInitialized() { - byte isInitialized = memoizedIsInitialized; - if (isInitialized == 1) return true; - if (isInitialized == 0) return false; - - memoizedIsInitialized = 1; - return true; - } - - @java.lang.Override - public void writeTo(com.google.protobuf.CodedOutputStream output) throws java.io.IOException { - if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(parent_)) { - com.google.protobuf.GeneratedMessageV3.writeString(output, 1, parent_); - } - if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(gatewayId_)) { - com.google.protobuf.GeneratedMessageV3.writeString(output, 2, gatewayId_); - } - if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(deviceId_)) { - com.google.protobuf.GeneratedMessageV3.writeString(output, 3, deviceId_); - } - getUnknownFields().writeTo(output); - } - - @java.lang.Override - public int getSerializedSize() { - int size = memoizedSize; - if (size != -1) return size; - - size = 0; - if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(parent_)) { - size += com.google.protobuf.GeneratedMessageV3.computeStringSize(1, parent_); - } - if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(gatewayId_)) { - size += com.google.protobuf.GeneratedMessageV3.computeStringSize(2, gatewayId_); - } - if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(deviceId_)) { - size += com.google.protobuf.GeneratedMessageV3.computeStringSize(3, deviceId_); - } - size += getUnknownFields().getSerializedSize(); - memoizedSize = size; - return size; - } - - @java.lang.Override - public boolean equals(final java.lang.Object obj) { - if (obj == this) { - return true; - } - if (!(obj instanceof com.google.cloud.iot.v1.BindDeviceToGatewayRequest)) { - return super.equals(obj); - } - com.google.cloud.iot.v1.BindDeviceToGatewayRequest other = - (com.google.cloud.iot.v1.BindDeviceToGatewayRequest) obj; - - if (!getParent().equals(other.getParent())) return false; - if (!getGatewayId().equals(other.getGatewayId())) return false; - if (!getDeviceId().equals(other.getDeviceId())) return false; - if (!getUnknownFields().equals(other.getUnknownFields())) return false; - return true; - } - - @java.lang.Override - public int hashCode() { - if (memoizedHashCode != 0) { - return memoizedHashCode; - } - int hash = 41; - hash = (19 * hash) + getDescriptor().hashCode(); - hash = (37 * hash) + PARENT_FIELD_NUMBER; - hash = (53 * hash) + getParent().hashCode(); - hash = (37 * hash) + GATEWAY_ID_FIELD_NUMBER; - hash = (53 * hash) + getGatewayId().hashCode(); - hash = (37 * hash) + DEVICE_ID_FIELD_NUMBER; - hash = (53 * hash) + getDeviceId().hashCode(); - hash = (29 * hash) + getUnknownFields().hashCode(); - memoizedHashCode = hash; - return hash; - } - - public static com.google.cloud.iot.v1.BindDeviceToGatewayRequest parseFrom( - java.nio.ByteBuffer data) throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); - } - - public static com.google.cloud.iot.v1.BindDeviceToGatewayRequest parseFrom( - java.nio.ByteBuffer data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); - } - - public static com.google.cloud.iot.v1.BindDeviceToGatewayRequest parseFrom( - com.google.protobuf.ByteString data) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); - } - - public static com.google.cloud.iot.v1.BindDeviceToGatewayRequest parseFrom( - com.google.protobuf.ByteString data, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); - } - - public static com.google.cloud.iot.v1.BindDeviceToGatewayRequest parseFrom(byte[] data) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); - } - - public static com.google.cloud.iot.v1.BindDeviceToGatewayRequest parseFrom( - byte[] data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); - } - - public static com.google.cloud.iot.v1.BindDeviceToGatewayRequest parseFrom( - java.io.InputStream input) throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input); - } - - public static com.google.cloud.iot.v1.BindDeviceToGatewayRequest parseFrom( - java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3.parseWithIOException( - PARSER, input, extensionRegistry); - } - - public static com.google.cloud.iot.v1.BindDeviceToGatewayRequest parseDelimitedFrom( - java.io.InputStream input) throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3.parseDelimitedWithIOException(PARSER, input); - } - - public static com.google.cloud.iot.v1.BindDeviceToGatewayRequest parseDelimitedFrom( - java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3.parseDelimitedWithIOException( - PARSER, input, extensionRegistry); - } - - public static com.google.cloud.iot.v1.BindDeviceToGatewayRequest parseFrom( - com.google.protobuf.CodedInputStream input) throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input); - } - - public static com.google.cloud.iot.v1.BindDeviceToGatewayRequest parseFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3.parseWithIOException( - PARSER, input, extensionRegistry); - } - - @java.lang.Override - public Builder newBuilderForType() { - return newBuilder(); - } - - public static Builder newBuilder() { - return DEFAULT_INSTANCE.toBuilder(); - } - - public static Builder newBuilder(com.google.cloud.iot.v1.BindDeviceToGatewayRequest prototype) { - return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); - } - - @java.lang.Override - public Builder toBuilder() { - return this == DEFAULT_INSTANCE ? new Builder() : new Builder().mergeFrom(this); - } - - @java.lang.Override - protected Builder newBuilderForType(com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { - Builder builder = new Builder(parent); - return builder; - } - /** - * - * - *
-   * Request for `BindDeviceToGateway`.
-   * 
- * - * Protobuf type {@code google.cloud.iot.v1.BindDeviceToGatewayRequest} - */ - public static final class Builder extends com.google.protobuf.GeneratedMessageV3.Builder - implements - // @@protoc_insertion_point(builder_implements:google.cloud.iot.v1.BindDeviceToGatewayRequest) - com.google.cloud.iot.v1.BindDeviceToGatewayRequestOrBuilder { - public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { - return com.google.cloud.iot.v1.DeviceManagerProto - .internal_static_google_cloud_iot_v1_BindDeviceToGatewayRequest_descriptor; - } - - @java.lang.Override - protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable - internalGetFieldAccessorTable() { - return com.google.cloud.iot.v1.DeviceManagerProto - .internal_static_google_cloud_iot_v1_BindDeviceToGatewayRequest_fieldAccessorTable - .ensureFieldAccessorsInitialized( - com.google.cloud.iot.v1.BindDeviceToGatewayRequest.class, - com.google.cloud.iot.v1.BindDeviceToGatewayRequest.Builder.class); - } - - // Construct using com.google.cloud.iot.v1.BindDeviceToGatewayRequest.newBuilder() - private Builder() {} - - private Builder(com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { - super(parent); - } - - @java.lang.Override - public Builder clear() { - super.clear(); - parent_ = ""; - - gatewayId_ = ""; - - deviceId_ = ""; - - return this; - } - - @java.lang.Override - public com.google.protobuf.Descriptors.Descriptor getDescriptorForType() { - return com.google.cloud.iot.v1.DeviceManagerProto - .internal_static_google_cloud_iot_v1_BindDeviceToGatewayRequest_descriptor; - } - - @java.lang.Override - public com.google.cloud.iot.v1.BindDeviceToGatewayRequest getDefaultInstanceForType() { - return com.google.cloud.iot.v1.BindDeviceToGatewayRequest.getDefaultInstance(); - } - - @java.lang.Override - public com.google.cloud.iot.v1.BindDeviceToGatewayRequest build() { - com.google.cloud.iot.v1.BindDeviceToGatewayRequest result = buildPartial(); - if (!result.isInitialized()) { - throw newUninitializedMessageException(result); - } - return result; - } - - @java.lang.Override - public com.google.cloud.iot.v1.BindDeviceToGatewayRequest buildPartial() { - com.google.cloud.iot.v1.BindDeviceToGatewayRequest result = - new com.google.cloud.iot.v1.BindDeviceToGatewayRequest(this); - result.parent_ = parent_; - result.gatewayId_ = gatewayId_; - result.deviceId_ = deviceId_; - onBuilt(); - return result; - } - - @java.lang.Override - public Builder clone() { - return super.clone(); - } - - @java.lang.Override - public Builder setField( - com.google.protobuf.Descriptors.FieldDescriptor field, java.lang.Object value) { - return super.setField(field, value); - } - - @java.lang.Override - public Builder clearField(com.google.protobuf.Descriptors.FieldDescriptor field) { - return super.clearField(field); - } - - @java.lang.Override - public Builder clearOneof(com.google.protobuf.Descriptors.OneofDescriptor oneof) { - return super.clearOneof(oneof); - } - - @java.lang.Override - public Builder setRepeatedField( - com.google.protobuf.Descriptors.FieldDescriptor field, int index, java.lang.Object value) { - return super.setRepeatedField(field, index, value); - } - - @java.lang.Override - public Builder addRepeatedField( - com.google.protobuf.Descriptors.FieldDescriptor field, java.lang.Object value) { - return super.addRepeatedField(field, value); - } - - @java.lang.Override - public Builder mergeFrom(com.google.protobuf.Message other) { - if (other instanceof com.google.cloud.iot.v1.BindDeviceToGatewayRequest) { - return mergeFrom((com.google.cloud.iot.v1.BindDeviceToGatewayRequest) other); - } else { - super.mergeFrom(other); - return this; - } - } - - public Builder mergeFrom(com.google.cloud.iot.v1.BindDeviceToGatewayRequest other) { - if (other == com.google.cloud.iot.v1.BindDeviceToGatewayRequest.getDefaultInstance()) - return this; - if (!other.getParent().isEmpty()) { - parent_ = other.parent_; - onChanged(); - } - if (!other.getGatewayId().isEmpty()) { - gatewayId_ = other.gatewayId_; - onChanged(); - } - if (!other.getDeviceId().isEmpty()) { - deviceId_ = other.deviceId_; - onChanged(); - } - this.mergeUnknownFields(other.getUnknownFields()); - onChanged(); - return this; - } - - @java.lang.Override - public final boolean isInitialized() { - return true; - } - - @java.lang.Override - public Builder mergeFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - if (extensionRegistry == null) { - throw new java.lang.NullPointerException(); - } - try { - boolean done = false; - while (!done) { - int tag = input.readTag(); - switch (tag) { - case 0: - done = true; - break; - case 10: - { - parent_ = input.readStringRequireUtf8(); - - break; - } // case 10 - case 18: - { - gatewayId_ = input.readStringRequireUtf8(); - - break; - } // case 18 - case 26: - { - deviceId_ = input.readStringRequireUtf8(); - - break; - } // case 26 - default: - { - if (!super.parseUnknownField(input, extensionRegistry, tag)) { - done = true; // was an endgroup tag - } - break; - } // default: - } // switch (tag) - } // while (!done) - } catch (com.google.protobuf.InvalidProtocolBufferException e) { - throw e.unwrapIOException(); - } finally { - onChanged(); - } // finally - return this; - } - - private java.lang.Object parent_ = ""; - /** - * - * - *
-     * Required. The name of the registry. For example,
-     * `projects/example-project/locations/us-central1/registries/my-registry`.
-     * 
- * - * - * string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } - * - * - * @return The parent. - */ - public java.lang.String getParent() { - java.lang.Object ref = parent_; - if (!(ref instanceof java.lang.String)) { - com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; - java.lang.String s = bs.toStringUtf8(); - parent_ = s; - return s; - } else { - return (java.lang.String) ref; - } - } - /** - * - * - *
-     * Required. The name of the registry. For example,
-     * `projects/example-project/locations/us-central1/registries/my-registry`.
-     * 
- * - * - * string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } - * - * - * @return The bytes for parent. - */ - public com.google.protobuf.ByteString getParentBytes() { - java.lang.Object ref = parent_; - if (ref instanceof String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); - parent_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - /** - * - * - *
-     * Required. The name of the registry. For example,
-     * `projects/example-project/locations/us-central1/registries/my-registry`.
-     * 
- * - * - * string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } - * - * - * @param value The parent to set. - * @return This builder for chaining. - */ - public Builder setParent(java.lang.String value) { - if (value == null) { - throw new NullPointerException(); - } - - parent_ = value; - onChanged(); - return this; - } - /** - * - * - *
-     * Required. The name of the registry. For example,
-     * `projects/example-project/locations/us-central1/registries/my-registry`.
-     * 
- * - * - * string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } - * - * - * @return This builder for chaining. - */ - public Builder clearParent() { - - parent_ = getDefaultInstance().getParent(); - onChanged(); - return this; - } - /** - * - * - *
-     * Required. The name of the registry. For example,
-     * `projects/example-project/locations/us-central1/registries/my-registry`.
-     * 
- * - * - * string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } - * - * - * @param value The bytes for parent to set. - * @return This builder for chaining. - */ - public Builder setParentBytes(com.google.protobuf.ByteString value) { - if (value == null) { - throw new NullPointerException(); - } - checkByteStringIsUtf8(value); - - parent_ = value; - onChanged(); - return this; - } - - private java.lang.Object gatewayId_ = ""; - /** - * - * - *
-     * Required. The value of `gateway_id` can be either the device numeric ID or the
-     * user-defined device identifier.
-     * 
- * - * string gateway_id = 2 [(.google.api.field_behavior) = REQUIRED]; - * - * @return The gatewayId. - */ - public java.lang.String getGatewayId() { - java.lang.Object ref = gatewayId_; - if (!(ref instanceof java.lang.String)) { - com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; - java.lang.String s = bs.toStringUtf8(); - gatewayId_ = s; - return s; - } else { - return (java.lang.String) ref; - } - } - /** - * - * - *
-     * Required. The value of `gateway_id` can be either the device numeric ID or the
-     * user-defined device identifier.
-     * 
- * - * string gateway_id = 2 [(.google.api.field_behavior) = REQUIRED]; - * - * @return The bytes for gatewayId. - */ - public com.google.protobuf.ByteString getGatewayIdBytes() { - java.lang.Object ref = gatewayId_; - if (ref instanceof String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); - gatewayId_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - /** - * - * - *
-     * Required. The value of `gateway_id` can be either the device numeric ID or the
-     * user-defined device identifier.
-     * 
- * - * string gateway_id = 2 [(.google.api.field_behavior) = REQUIRED]; - * - * @param value The gatewayId to set. - * @return This builder for chaining. - */ - public Builder setGatewayId(java.lang.String value) { - if (value == null) { - throw new NullPointerException(); - } - - gatewayId_ = value; - onChanged(); - return this; - } - /** - * - * - *
-     * Required. The value of `gateway_id` can be either the device numeric ID or the
-     * user-defined device identifier.
-     * 
- * - * string gateway_id = 2 [(.google.api.field_behavior) = REQUIRED]; - * - * @return This builder for chaining. - */ - public Builder clearGatewayId() { - - gatewayId_ = getDefaultInstance().getGatewayId(); - onChanged(); - return this; - } - /** - * - * - *
-     * Required. The value of `gateway_id` can be either the device numeric ID or the
-     * user-defined device identifier.
-     * 
- * - * string gateway_id = 2 [(.google.api.field_behavior) = REQUIRED]; - * - * @param value The bytes for gatewayId to set. - * @return This builder for chaining. - */ - public Builder setGatewayIdBytes(com.google.protobuf.ByteString value) { - if (value == null) { - throw new NullPointerException(); - } - checkByteStringIsUtf8(value); - - gatewayId_ = value; - onChanged(); - return this; - } - - private java.lang.Object deviceId_ = ""; - /** - * - * - *
-     * Required. The device to associate with the specified gateway. The value of
-     * `device_id` can be either the device numeric ID or the user-defined device
-     * identifier.
-     * 
- * - * string device_id = 3 [(.google.api.field_behavior) = REQUIRED]; - * - * @return The deviceId. - */ - public java.lang.String getDeviceId() { - java.lang.Object ref = deviceId_; - if (!(ref instanceof java.lang.String)) { - com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; - java.lang.String s = bs.toStringUtf8(); - deviceId_ = s; - return s; - } else { - return (java.lang.String) ref; - } - } - /** - * - * - *
-     * Required. The device to associate with the specified gateway. The value of
-     * `device_id` can be either the device numeric ID or the user-defined device
-     * identifier.
-     * 
- * - * string device_id = 3 [(.google.api.field_behavior) = REQUIRED]; - * - * @return The bytes for deviceId. - */ - public com.google.protobuf.ByteString getDeviceIdBytes() { - java.lang.Object ref = deviceId_; - if (ref instanceof String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); - deviceId_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - /** - * - * - *
-     * Required. The device to associate with the specified gateway. The value of
-     * `device_id` can be either the device numeric ID or the user-defined device
-     * identifier.
-     * 
- * - * string device_id = 3 [(.google.api.field_behavior) = REQUIRED]; - * - * @param value The deviceId to set. - * @return This builder for chaining. - */ - public Builder setDeviceId(java.lang.String value) { - if (value == null) { - throw new NullPointerException(); - } - - deviceId_ = value; - onChanged(); - return this; - } - /** - * - * - *
-     * Required. The device to associate with the specified gateway. The value of
-     * `device_id` can be either the device numeric ID or the user-defined device
-     * identifier.
-     * 
- * - * string device_id = 3 [(.google.api.field_behavior) = REQUIRED]; - * - * @return This builder for chaining. - */ - public Builder clearDeviceId() { - - deviceId_ = getDefaultInstance().getDeviceId(); - onChanged(); - return this; - } - /** - * - * - *
-     * Required. The device to associate with the specified gateway. The value of
-     * `device_id` can be either the device numeric ID or the user-defined device
-     * identifier.
-     * 
- * - * string device_id = 3 [(.google.api.field_behavior) = REQUIRED]; - * - * @param value The bytes for deviceId to set. - * @return This builder for chaining. - */ - public Builder setDeviceIdBytes(com.google.protobuf.ByteString value) { - if (value == null) { - throw new NullPointerException(); - } - checkByteStringIsUtf8(value); - - deviceId_ = value; - onChanged(); - return this; - } - - @java.lang.Override - public final Builder setUnknownFields(final com.google.protobuf.UnknownFieldSet unknownFields) { - return super.setUnknownFields(unknownFields); - } - - @java.lang.Override - public final Builder mergeUnknownFields( - final com.google.protobuf.UnknownFieldSet unknownFields) { - return super.mergeUnknownFields(unknownFields); - } - - // @@protoc_insertion_point(builder_scope:google.cloud.iot.v1.BindDeviceToGatewayRequest) - } - - // @@protoc_insertion_point(class_scope:google.cloud.iot.v1.BindDeviceToGatewayRequest) - private static final com.google.cloud.iot.v1.BindDeviceToGatewayRequest DEFAULT_INSTANCE; - - static { - DEFAULT_INSTANCE = new com.google.cloud.iot.v1.BindDeviceToGatewayRequest(); - } - - public static com.google.cloud.iot.v1.BindDeviceToGatewayRequest getDefaultInstance() { - return DEFAULT_INSTANCE; - } - - private static final com.google.protobuf.Parser PARSER = - new com.google.protobuf.AbstractParser() { - @java.lang.Override - public BindDeviceToGatewayRequest parsePartialFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - Builder builder = newBuilder(); - try { - builder.mergeFrom(input, extensionRegistry); - } catch (com.google.protobuf.InvalidProtocolBufferException e) { - throw e.setUnfinishedMessage(builder.buildPartial()); - } catch (com.google.protobuf.UninitializedMessageException e) { - throw e.asInvalidProtocolBufferException().setUnfinishedMessage(builder.buildPartial()); - } catch (java.io.IOException e) { - throw new com.google.protobuf.InvalidProtocolBufferException(e) - .setUnfinishedMessage(builder.buildPartial()); - } - return builder.buildPartial(); - } - }; - - public static com.google.protobuf.Parser parser() { - return PARSER; - } - - @java.lang.Override - public com.google.protobuf.Parser getParserForType() { - return PARSER; - } - - @java.lang.Override - public com.google.cloud.iot.v1.BindDeviceToGatewayRequest getDefaultInstanceForType() { - return DEFAULT_INSTANCE; - } -} diff --git a/proto-google-cloud-iot-v1/src/main/java/com/google/cloud/iot/v1/BindDeviceToGatewayRequestOrBuilder.java b/proto-google-cloud-iot-v1/src/main/java/com/google/cloud/iot/v1/BindDeviceToGatewayRequestOrBuilder.java deleted file mode 100644 index 4476be56..00000000 --- a/proto-google-cloud-iot-v1/src/main/java/com/google/cloud/iot/v1/BindDeviceToGatewayRequestOrBuilder.java +++ /dev/null @@ -1,112 +0,0 @@ -/* - * Copyright 2020 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. - */ -// Generated by the protocol buffer compiler. DO NOT EDIT! -// source: google/cloud/iot/v1/device_manager.proto - -package com.google.cloud.iot.v1; - -public interface BindDeviceToGatewayRequestOrBuilder - extends - // @@protoc_insertion_point(interface_extends:google.cloud.iot.v1.BindDeviceToGatewayRequest) - com.google.protobuf.MessageOrBuilder { - - /** - * - * - *
-   * Required. The name of the registry. For example,
-   * `projects/example-project/locations/us-central1/registries/my-registry`.
-   * 
- * - * - * string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } - * - * - * @return The parent. - */ - java.lang.String getParent(); - /** - * - * - *
-   * Required. The name of the registry. For example,
-   * `projects/example-project/locations/us-central1/registries/my-registry`.
-   * 
- * - * - * string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } - * - * - * @return The bytes for parent. - */ - com.google.protobuf.ByteString getParentBytes(); - - /** - * - * - *
-   * Required. The value of `gateway_id` can be either the device numeric ID or the
-   * user-defined device identifier.
-   * 
- * - * string gateway_id = 2 [(.google.api.field_behavior) = REQUIRED]; - * - * @return The gatewayId. - */ - java.lang.String getGatewayId(); - /** - * - * - *
-   * Required. The value of `gateway_id` can be either the device numeric ID or the
-   * user-defined device identifier.
-   * 
- * - * string gateway_id = 2 [(.google.api.field_behavior) = REQUIRED]; - * - * @return The bytes for gatewayId. - */ - com.google.protobuf.ByteString getGatewayIdBytes(); - - /** - * - * - *
-   * Required. The device to associate with the specified gateway. The value of
-   * `device_id` can be either the device numeric ID or the user-defined device
-   * identifier.
-   * 
- * - * string device_id = 3 [(.google.api.field_behavior) = REQUIRED]; - * - * @return The deviceId. - */ - java.lang.String getDeviceId(); - /** - * - * - *
-   * Required. The device to associate with the specified gateway. The value of
-   * `device_id` can be either the device numeric ID or the user-defined device
-   * identifier.
-   * 
- * - * string device_id = 3 [(.google.api.field_behavior) = REQUIRED]; - * - * @return The bytes for deviceId. - */ - com.google.protobuf.ByteString getDeviceIdBytes(); -} diff --git a/proto-google-cloud-iot-v1/src/main/java/com/google/cloud/iot/v1/BindDeviceToGatewayResponse.java b/proto-google-cloud-iot-v1/src/main/java/com/google/cloud/iot/v1/BindDeviceToGatewayResponse.java deleted file mode 100644 index 1702fecd..00000000 --- a/proto-google-cloud-iot-v1/src/main/java/com/google/cloud/iot/v1/BindDeviceToGatewayResponse.java +++ /dev/null @@ -1,436 +0,0 @@ -/* - * Copyright 2020 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. - */ -// Generated by the protocol buffer compiler. DO NOT EDIT! -// source: google/cloud/iot/v1/device_manager.proto - -package com.google.cloud.iot.v1; - -/** - * - * - *
- * Response for `BindDeviceToGateway`.
- * 
- * - * Protobuf type {@code google.cloud.iot.v1.BindDeviceToGatewayResponse} - */ -public final class BindDeviceToGatewayResponse extends com.google.protobuf.GeneratedMessageV3 - implements - // @@protoc_insertion_point(message_implements:google.cloud.iot.v1.BindDeviceToGatewayResponse) - BindDeviceToGatewayResponseOrBuilder { - private static final long serialVersionUID = 0L; - // Use BindDeviceToGatewayResponse.newBuilder() to construct. - private BindDeviceToGatewayResponse(com.google.protobuf.GeneratedMessageV3.Builder builder) { - super(builder); - } - - private BindDeviceToGatewayResponse() {} - - @java.lang.Override - @SuppressWarnings({"unused"}) - protected java.lang.Object newInstance(UnusedPrivateParameter unused) { - return new BindDeviceToGatewayResponse(); - } - - @java.lang.Override - public final com.google.protobuf.UnknownFieldSet getUnknownFields() { - return this.unknownFields; - } - - public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { - return com.google.cloud.iot.v1.DeviceManagerProto - .internal_static_google_cloud_iot_v1_BindDeviceToGatewayResponse_descriptor; - } - - @java.lang.Override - protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable - internalGetFieldAccessorTable() { - return com.google.cloud.iot.v1.DeviceManagerProto - .internal_static_google_cloud_iot_v1_BindDeviceToGatewayResponse_fieldAccessorTable - .ensureFieldAccessorsInitialized( - com.google.cloud.iot.v1.BindDeviceToGatewayResponse.class, - com.google.cloud.iot.v1.BindDeviceToGatewayResponse.Builder.class); - } - - private byte memoizedIsInitialized = -1; - - @java.lang.Override - public final boolean isInitialized() { - byte isInitialized = memoizedIsInitialized; - if (isInitialized == 1) return true; - if (isInitialized == 0) return false; - - memoizedIsInitialized = 1; - return true; - } - - @java.lang.Override - public void writeTo(com.google.protobuf.CodedOutputStream output) throws java.io.IOException { - getUnknownFields().writeTo(output); - } - - @java.lang.Override - public int getSerializedSize() { - int size = memoizedSize; - if (size != -1) return size; - - size = 0; - size += getUnknownFields().getSerializedSize(); - memoizedSize = size; - return size; - } - - @java.lang.Override - public boolean equals(final java.lang.Object obj) { - if (obj == this) { - return true; - } - if (!(obj instanceof com.google.cloud.iot.v1.BindDeviceToGatewayResponse)) { - return super.equals(obj); - } - com.google.cloud.iot.v1.BindDeviceToGatewayResponse other = - (com.google.cloud.iot.v1.BindDeviceToGatewayResponse) obj; - - if (!getUnknownFields().equals(other.getUnknownFields())) return false; - return true; - } - - @java.lang.Override - public int hashCode() { - if (memoizedHashCode != 0) { - return memoizedHashCode; - } - int hash = 41; - hash = (19 * hash) + getDescriptor().hashCode(); - hash = (29 * hash) + getUnknownFields().hashCode(); - memoizedHashCode = hash; - return hash; - } - - public static com.google.cloud.iot.v1.BindDeviceToGatewayResponse parseFrom( - java.nio.ByteBuffer data) throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); - } - - public static com.google.cloud.iot.v1.BindDeviceToGatewayResponse parseFrom( - java.nio.ByteBuffer data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); - } - - public static com.google.cloud.iot.v1.BindDeviceToGatewayResponse parseFrom( - com.google.protobuf.ByteString data) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); - } - - public static com.google.cloud.iot.v1.BindDeviceToGatewayResponse parseFrom( - com.google.protobuf.ByteString data, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); - } - - public static com.google.cloud.iot.v1.BindDeviceToGatewayResponse parseFrom(byte[] data) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); - } - - public static com.google.cloud.iot.v1.BindDeviceToGatewayResponse parseFrom( - byte[] data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); - } - - public static com.google.cloud.iot.v1.BindDeviceToGatewayResponse parseFrom( - java.io.InputStream input) throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input); - } - - public static com.google.cloud.iot.v1.BindDeviceToGatewayResponse parseFrom( - java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3.parseWithIOException( - PARSER, input, extensionRegistry); - } - - public static com.google.cloud.iot.v1.BindDeviceToGatewayResponse parseDelimitedFrom( - java.io.InputStream input) throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3.parseDelimitedWithIOException(PARSER, input); - } - - public static com.google.cloud.iot.v1.BindDeviceToGatewayResponse parseDelimitedFrom( - java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3.parseDelimitedWithIOException( - PARSER, input, extensionRegistry); - } - - public static com.google.cloud.iot.v1.BindDeviceToGatewayResponse parseFrom( - com.google.protobuf.CodedInputStream input) throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input); - } - - public static com.google.cloud.iot.v1.BindDeviceToGatewayResponse parseFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3.parseWithIOException( - PARSER, input, extensionRegistry); - } - - @java.lang.Override - public Builder newBuilderForType() { - return newBuilder(); - } - - public static Builder newBuilder() { - return DEFAULT_INSTANCE.toBuilder(); - } - - public static Builder newBuilder(com.google.cloud.iot.v1.BindDeviceToGatewayResponse prototype) { - return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); - } - - @java.lang.Override - public Builder toBuilder() { - return this == DEFAULT_INSTANCE ? new Builder() : new Builder().mergeFrom(this); - } - - @java.lang.Override - protected Builder newBuilderForType(com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { - Builder builder = new Builder(parent); - return builder; - } - /** - * - * - *
-   * Response for `BindDeviceToGateway`.
-   * 
- * - * Protobuf type {@code google.cloud.iot.v1.BindDeviceToGatewayResponse} - */ - public static final class Builder extends com.google.protobuf.GeneratedMessageV3.Builder - implements - // @@protoc_insertion_point(builder_implements:google.cloud.iot.v1.BindDeviceToGatewayResponse) - com.google.cloud.iot.v1.BindDeviceToGatewayResponseOrBuilder { - public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { - return com.google.cloud.iot.v1.DeviceManagerProto - .internal_static_google_cloud_iot_v1_BindDeviceToGatewayResponse_descriptor; - } - - @java.lang.Override - protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable - internalGetFieldAccessorTable() { - return com.google.cloud.iot.v1.DeviceManagerProto - .internal_static_google_cloud_iot_v1_BindDeviceToGatewayResponse_fieldAccessorTable - .ensureFieldAccessorsInitialized( - com.google.cloud.iot.v1.BindDeviceToGatewayResponse.class, - com.google.cloud.iot.v1.BindDeviceToGatewayResponse.Builder.class); - } - - // Construct using com.google.cloud.iot.v1.BindDeviceToGatewayResponse.newBuilder() - private Builder() {} - - private Builder(com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { - super(parent); - } - - @java.lang.Override - public Builder clear() { - super.clear(); - return this; - } - - @java.lang.Override - public com.google.protobuf.Descriptors.Descriptor getDescriptorForType() { - return com.google.cloud.iot.v1.DeviceManagerProto - .internal_static_google_cloud_iot_v1_BindDeviceToGatewayResponse_descriptor; - } - - @java.lang.Override - public com.google.cloud.iot.v1.BindDeviceToGatewayResponse getDefaultInstanceForType() { - return com.google.cloud.iot.v1.BindDeviceToGatewayResponse.getDefaultInstance(); - } - - @java.lang.Override - public com.google.cloud.iot.v1.BindDeviceToGatewayResponse build() { - com.google.cloud.iot.v1.BindDeviceToGatewayResponse result = buildPartial(); - if (!result.isInitialized()) { - throw newUninitializedMessageException(result); - } - return result; - } - - @java.lang.Override - public com.google.cloud.iot.v1.BindDeviceToGatewayResponse buildPartial() { - com.google.cloud.iot.v1.BindDeviceToGatewayResponse result = - new com.google.cloud.iot.v1.BindDeviceToGatewayResponse(this); - onBuilt(); - return result; - } - - @java.lang.Override - public Builder clone() { - return super.clone(); - } - - @java.lang.Override - public Builder setField( - com.google.protobuf.Descriptors.FieldDescriptor field, java.lang.Object value) { - return super.setField(field, value); - } - - @java.lang.Override - public Builder clearField(com.google.protobuf.Descriptors.FieldDescriptor field) { - return super.clearField(field); - } - - @java.lang.Override - public Builder clearOneof(com.google.protobuf.Descriptors.OneofDescriptor oneof) { - return super.clearOneof(oneof); - } - - @java.lang.Override - public Builder setRepeatedField( - com.google.protobuf.Descriptors.FieldDescriptor field, int index, java.lang.Object value) { - return super.setRepeatedField(field, index, value); - } - - @java.lang.Override - public Builder addRepeatedField( - com.google.protobuf.Descriptors.FieldDescriptor field, java.lang.Object value) { - return super.addRepeatedField(field, value); - } - - @java.lang.Override - public Builder mergeFrom(com.google.protobuf.Message other) { - if (other instanceof com.google.cloud.iot.v1.BindDeviceToGatewayResponse) { - return mergeFrom((com.google.cloud.iot.v1.BindDeviceToGatewayResponse) other); - } else { - super.mergeFrom(other); - return this; - } - } - - public Builder mergeFrom(com.google.cloud.iot.v1.BindDeviceToGatewayResponse other) { - if (other == com.google.cloud.iot.v1.BindDeviceToGatewayResponse.getDefaultInstance()) - return this; - this.mergeUnknownFields(other.getUnknownFields()); - onChanged(); - return this; - } - - @java.lang.Override - public final boolean isInitialized() { - return true; - } - - @java.lang.Override - public Builder mergeFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - if (extensionRegistry == null) { - throw new java.lang.NullPointerException(); - } - try { - boolean done = false; - while (!done) { - int tag = input.readTag(); - switch (tag) { - case 0: - done = true; - break; - default: - { - if (!super.parseUnknownField(input, extensionRegistry, tag)) { - done = true; // was an endgroup tag - } - break; - } // default: - } // switch (tag) - } // while (!done) - } catch (com.google.protobuf.InvalidProtocolBufferException e) { - throw e.unwrapIOException(); - } finally { - onChanged(); - } // finally - return this; - } - - @java.lang.Override - public final Builder setUnknownFields(final com.google.protobuf.UnknownFieldSet unknownFields) { - return super.setUnknownFields(unknownFields); - } - - @java.lang.Override - public final Builder mergeUnknownFields( - final com.google.protobuf.UnknownFieldSet unknownFields) { - return super.mergeUnknownFields(unknownFields); - } - - // @@protoc_insertion_point(builder_scope:google.cloud.iot.v1.BindDeviceToGatewayResponse) - } - - // @@protoc_insertion_point(class_scope:google.cloud.iot.v1.BindDeviceToGatewayResponse) - private static final com.google.cloud.iot.v1.BindDeviceToGatewayResponse DEFAULT_INSTANCE; - - static { - DEFAULT_INSTANCE = new com.google.cloud.iot.v1.BindDeviceToGatewayResponse(); - } - - public static com.google.cloud.iot.v1.BindDeviceToGatewayResponse getDefaultInstance() { - return DEFAULT_INSTANCE; - } - - private static final com.google.protobuf.Parser PARSER = - new com.google.protobuf.AbstractParser() { - @java.lang.Override - public BindDeviceToGatewayResponse parsePartialFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - Builder builder = newBuilder(); - try { - builder.mergeFrom(input, extensionRegistry); - } catch (com.google.protobuf.InvalidProtocolBufferException e) { - throw e.setUnfinishedMessage(builder.buildPartial()); - } catch (com.google.protobuf.UninitializedMessageException e) { - throw e.asInvalidProtocolBufferException().setUnfinishedMessage(builder.buildPartial()); - } catch (java.io.IOException e) { - throw new com.google.protobuf.InvalidProtocolBufferException(e) - .setUnfinishedMessage(builder.buildPartial()); - } - return builder.buildPartial(); - } - }; - - public static com.google.protobuf.Parser parser() { - return PARSER; - } - - @java.lang.Override - public com.google.protobuf.Parser getParserForType() { - return PARSER; - } - - @java.lang.Override - public com.google.cloud.iot.v1.BindDeviceToGatewayResponse getDefaultInstanceForType() { - return DEFAULT_INSTANCE; - } -} diff --git a/proto-google-cloud-iot-v1/src/main/java/com/google/cloud/iot/v1/BindDeviceToGatewayResponseOrBuilder.java b/proto-google-cloud-iot-v1/src/main/java/com/google/cloud/iot/v1/BindDeviceToGatewayResponseOrBuilder.java deleted file mode 100644 index a5011d31..00000000 --- a/proto-google-cloud-iot-v1/src/main/java/com/google/cloud/iot/v1/BindDeviceToGatewayResponseOrBuilder.java +++ /dev/null @@ -1,24 +0,0 @@ -/* - * Copyright 2020 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. - */ -// Generated by the protocol buffer compiler. DO NOT EDIT! -// source: google/cloud/iot/v1/device_manager.proto - -package com.google.cloud.iot.v1; - -public interface BindDeviceToGatewayResponseOrBuilder - extends - // @@protoc_insertion_point(interface_extends:google.cloud.iot.v1.BindDeviceToGatewayResponse) - com.google.protobuf.MessageOrBuilder {} diff --git a/proto-google-cloud-iot-v1/src/main/java/com/google/cloud/iot/v1/CreateDeviceRegistryRequest.java b/proto-google-cloud-iot-v1/src/main/java/com/google/cloud/iot/v1/CreateDeviceRegistryRequest.java deleted file mode 100644 index 04602b03..00000000 --- a/proto-google-cloud-iot-v1/src/main/java/com/google/cloud/iot/v1/CreateDeviceRegistryRequest.java +++ /dev/null @@ -1,952 +0,0 @@ -/* - * Copyright 2020 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. - */ -// Generated by the protocol buffer compiler. DO NOT EDIT! -// source: google/cloud/iot/v1/device_manager.proto - -package com.google.cloud.iot.v1; - -/** - * - * - *
- * Request for `CreateDeviceRegistry`.
- * 
- * - * Protobuf type {@code google.cloud.iot.v1.CreateDeviceRegistryRequest} - */ -public final class CreateDeviceRegistryRequest extends com.google.protobuf.GeneratedMessageV3 - implements - // @@protoc_insertion_point(message_implements:google.cloud.iot.v1.CreateDeviceRegistryRequest) - CreateDeviceRegistryRequestOrBuilder { - private static final long serialVersionUID = 0L; - // Use CreateDeviceRegistryRequest.newBuilder() to construct. - private CreateDeviceRegistryRequest(com.google.protobuf.GeneratedMessageV3.Builder builder) { - super(builder); - } - - private CreateDeviceRegistryRequest() { - parent_ = ""; - } - - @java.lang.Override - @SuppressWarnings({"unused"}) - protected java.lang.Object newInstance(UnusedPrivateParameter unused) { - return new CreateDeviceRegistryRequest(); - } - - @java.lang.Override - public final com.google.protobuf.UnknownFieldSet getUnknownFields() { - return this.unknownFields; - } - - public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { - return com.google.cloud.iot.v1.DeviceManagerProto - .internal_static_google_cloud_iot_v1_CreateDeviceRegistryRequest_descriptor; - } - - @java.lang.Override - protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable - internalGetFieldAccessorTable() { - return com.google.cloud.iot.v1.DeviceManagerProto - .internal_static_google_cloud_iot_v1_CreateDeviceRegistryRequest_fieldAccessorTable - .ensureFieldAccessorsInitialized( - com.google.cloud.iot.v1.CreateDeviceRegistryRequest.class, - com.google.cloud.iot.v1.CreateDeviceRegistryRequest.Builder.class); - } - - public static final int PARENT_FIELD_NUMBER = 1; - private volatile java.lang.Object parent_; - /** - * - * - *
-   * Required. The project and cloud region where this device registry must be created.
-   * For example, `projects/example-project/locations/us-central1`.
-   * 
- * - * - * string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } - * - * - * @return The parent. - */ - @java.lang.Override - public java.lang.String getParent() { - java.lang.Object ref = parent_; - if (ref instanceof java.lang.String) { - return (java.lang.String) ref; - } else { - com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; - java.lang.String s = bs.toStringUtf8(); - parent_ = s; - return s; - } - } - /** - * - * - *
-   * Required. The project and cloud region where this device registry must be created.
-   * For example, `projects/example-project/locations/us-central1`.
-   * 
- * - * - * string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } - * - * - * @return The bytes for parent. - */ - @java.lang.Override - public com.google.protobuf.ByteString getParentBytes() { - java.lang.Object ref = parent_; - if (ref instanceof java.lang.String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); - parent_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - - public static final int DEVICE_REGISTRY_FIELD_NUMBER = 2; - private com.google.cloud.iot.v1.DeviceRegistry deviceRegistry_; - /** - * - * - *
-   * Required. The device registry. The field `name` must be empty. The server will
-   * generate that field from the device registry `id` provided and the
-   * `parent` field.
-   * 
- * - * - * .google.cloud.iot.v1.DeviceRegistry device_registry = 2 [(.google.api.field_behavior) = REQUIRED]; - * - * - * @return Whether the deviceRegistry field is set. - */ - @java.lang.Override - public boolean hasDeviceRegistry() { - return deviceRegistry_ != null; - } - /** - * - * - *
-   * Required. The device registry. The field `name` must be empty. The server will
-   * generate that field from the device registry `id` provided and the
-   * `parent` field.
-   * 
- * - * - * .google.cloud.iot.v1.DeviceRegistry device_registry = 2 [(.google.api.field_behavior) = REQUIRED]; - * - * - * @return The deviceRegistry. - */ - @java.lang.Override - public com.google.cloud.iot.v1.DeviceRegistry getDeviceRegistry() { - return deviceRegistry_ == null - ? com.google.cloud.iot.v1.DeviceRegistry.getDefaultInstance() - : deviceRegistry_; - } - /** - * - * - *
-   * Required. The device registry. The field `name` must be empty. The server will
-   * generate that field from the device registry `id` provided and the
-   * `parent` field.
-   * 
- * - * - * .google.cloud.iot.v1.DeviceRegistry device_registry = 2 [(.google.api.field_behavior) = REQUIRED]; - * - */ - @java.lang.Override - public com.google.cloud.iot.v1.DeviceRegistryOrBuilder getDeviceRegistryOrBuilder() { - return getDeviceRegistry(); - } - - private byte memoizedIsInitialized = -1; - - @java.lang.Override - public final boolean isInitialized() { - byte isInitialized = memoizedIsInitialized; - if (isInitialized == 1) return true; - if (isInitialized == 0) return false; - - memoizedIsInitialized = 1; - return true; - } - - @java.lang.Override - public void writeTo(com.google.protobuf.CodedOutputStream output) throws java.io.IOException { - if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(parent_)) { - com.google.protobuf.GeneratedMessageV3.writeString(output, 1, parent_); - } - if (deviceRegistry_ != null) { - output.writeMessage(2, getDeviceRegistry()); - } - getUnknownFields().writeTo(output); - } - - @java.lang.Override - public int getSerializedSize() { - int size = memoizedSize; - if (size != -1) return size; - - size = 0; - if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(parent_)) { - size += com.google.protobuf.GeneratedMessageV3.computeStringSize(1, parent_); - } - if (deviceRegistry_ != null) { - size += com.google.protobuf.CodedOutputStream.computeMessageSize(2, getDeviceRegistry()); - } - size += getUnknownFields().getSerializedSize(); - memoizedSize = size; - return size; - } - - @java.lang.Override - public boolean equals(final java.lang.Object obj) { - if (obj == this) { - return true; - } - if (!(obj instanceof com.google.cloud.iot.v1.CreateDeviceRegistryRequest)) { - return super.equals(obj); - } - com.google.cloud.iot.v1.CreateDeviceRegistryRequest other = - (com.google.cloud.iot.v1.CreateDeviceRegistryRequest) obj; - - if (!getParent().equals(other.getParent())) return false; - if (hasDeviceRegistry() != other.hasDeviceRegistry()) return false; - if (hasDeviceRegistry()) { - if (!getDeviceRegistry().equals(other.getDeviceRegistry())) return false; - } - if (!getUnknownFields().equals(other.getUnknownFields())) return false; - return true; - } - - @java.lang.Override - public int hashCode() { - if (memoizedHashCode != 0) { - return memoizedHashCode; - } - int hash = 41; - hash = (19 * hash) + getDescriptor().hashCode(); - hash = (37 * hash) + PARENT_FIELD_NUMBER; - hash = (53 * hash) + getParent().hashCode(); - if (hasDeviceRegistry()) { - hash = (37 * hash) + DEVICE_REGISTRY_FIELD_NUMBER; - hash = (53 * hash) + getDeviceRegistry().hashCode(); - } - hash = (29 * hash) + getUnknownFields().hashCode(); - memoizedHashCode = hash; - return hash; - } - - public static com.google.cloud.iot.v1.CreateDeviceRegistryRequest parseFrom( - java.nio.ByteBuffer data) throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); - } - - public static com.google.cloud.iot.v1.CreateDeviceRegistryRequest parseFrom( - java.nio.ByteBuffer data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); - } - - public static com.google.cloud.iot.v1.CreateDeviceRegistryRequest parseFrom( - com.google.protobuf.ByteString data) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); - } - - public static com.google.cloud.iot.v1.CreateDeviceRegistryRequest parseFrom( - com.google.protobuf.ByteString data, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); - } - - public static com.google.cloud.iot.v1.CreateDeviceRegistryRequest parseFrom(byte[] data) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); - } - - public static com.google.cloud.iot.v1.CreateDeviceRegistryRequest parseFrom( - byte[] data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); - } - - public static com.google.cloud.iot.v1.CreateDeviceRegistryRequest parseFrom( - java.io.InputStream input) throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input); - } - - public static com.google.cloud.iot.v1.CreateDeviceRegistryRequest parseFrom( - java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3.parseWithIOException( - PARSER, input, extensionRegistry); - } - - public static com.google.cloud.iot.v1.CreateDeviceRegistryRequest parseDelimitedFrom( - java.io.InputStream input) throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3.parseDelimitedWithIOException(PARSER, input); - } - - public static com.google.cloud.iot.v1.CreateDeviceRegistryRequest parseDelimitedFrom( - java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3.parseDelimitedWithIOException( - PARSER, input, extensionRegistry); - } - - public static com.google.cloud.iot.v1.CreateDeviceRegistryRequest parseFrom( - com.google.protobuf.CodedInputStream input) throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input); - } - - public static com.google.cloud.iot.v1.CreateDeviceRegistryRequest parseFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3.parseWithIOException( - PARSER, input, extensionRegistry); - } - - @java.lang.Override - public Builder newBuilderForType() { - return newBuilder(); - } - - public static Builder newBuilder() { - return DEFAULT_INSTANCE.toBuilder(); - } - - public static Builder newBuilder(com.google.cloud.iot.v1.CreateDeviceRegistryRequest prototype) { - return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); - } - - @java.lang.Override - public Builder toBuilder() { - return this == DEFAULT_INSTANCE ? new Builder() : new Builder().mergeFrom(this); - } - - @java.lang.Override - protected Builder newBuilderForType(com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { - Builder builder = new Builder(parent); - return builder; - } - /** - * - * - *
-   * Request for `CreateDeviceRegistry`.
-   * 
- * - * Protobuf type {@code google.cloud.iot.v1.CreateDeviceRegistryRequest} - */ - public static final class Builder extends com.google.protobuf.GeneratedMessageV3.Builder - implements - // @@protoc_insertion_point(builder_implements:google.cloud.iot.v1.CreateDeviceRegistryRequest) - com.google.cloud.iot.v1.CreateDeviceRegistryRequestOrBuilder { - public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { - return com.google.cloud.iot.v1.DeviceManagerProto - .internal_static_google_cloud_iot_v1_CreateDeviceRegistryRequest_descriptor; - } - - @java.lang.Override - protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable - internalGetFieldAccessorTable() { - return com.google.cloud.iot.v1.DeviceManagerProto - .internal_static_google_cloud_iot_v1_CreateDeviceRegistryRequest_fieldAccessorTable - .ensureFieldAccessorsInitialized( - com.google.cloud.iot.v1.CreateDeviceRegistryRequest.class, - com.google.cloud.iot.v1.CreateDeviceRegistryRequest.Builder.class); - } - - // Construct using com.google.cloud.iot.v1.CreateDeviceRegistryRequest.newBuilder() - private Builder() {} - - private Builder(com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { - super(parent); - } - - @java.lang.Override - public Builder clear() { - super.clear(); - parent_ = ""; - - if (deviceRegistryBuilder_ == null) { - deviceRegistry_ = null; - } else { - deviceRegistry_ = null; - deviceRegistryBuilder_ = null; - } - return this; - } - - @java.lang.Override - public com.google.protobuf.Descriptors.Descriptor getDescriptorForType() { - return com.google.cloud.iot.v1.DeviceManagerProto - .internal_static_google_cloud_iot_v1_CreateDeviceRegistryRequest_descriptor; - } - - @java.lang.Override - public com.google.cloud.iot.v1.CreateDeviceRegistryRequest getDefaultInstanceForType() { - return com.google.cloud.iot.v1.CreateDeviceRegistryRequest.getDefaultInstance(); - } - - @java.lang.Override - public com.google.cloud.iot.v1.CreateDeviceRegistryRequest build() { - com.google.cloud.iot.v1.CreateDeviceRegistryRequest result = buildPartial(); - if (!result.isInitialized()) { - throw newUninitializedMessageException(result); - } - return result; - } - - @java.lang.Override - public com.google.cloud.iot.v1.CreateDeviceRegistryRequest buildPartial() { - com.google.cloud.iot.v1.CreateDeviceRegistryRequest result = - new com.google.cloud.iot.v1.CreateDeviceRegistryRequest(this); - result.parent_ = parent_; - if (deviceRegistryBuilder_ == null) { - result.deviceRegistry_ = deviceRegistry_; - } else { - result.deviceRegistry_ = deviceRegistryBuilder_.build(); - } - onBuilt(); - return result; - } - - @java.lang.Override - public Builder clone() { - return super.clone(); - } - - @java.lang.Override - public Builder setField( - com.google.protobuf.Descriptors.FieldDescriptor field, java.lang.Object value) { - return super.setField(field, value); - } - - @java.lang.Override - public Builder clearField(com.google.protobuf.Descriptors.FieldDescriptor field) { - return super.clearField(field); - } - - @java.lang.Override - public Builder clearOneof(com.google.protobuf.Descriptors.OneofDescriptor oneof) { - return super.clearOneof(oneof); - } - - @java.lang.Override - public Builder setRepeatedField( - com.google.protobuf.Descriptors.FieldDescriptor field, int index, java.lang.Object value) { - return super.setRepeatedField(field, index, value); - } - - @java.lang.Override - public Builder addRepeatedField( - com.google.protobuf.Descriptors.FieldDescriptor field, java.lang.Object value) { - return super.addRepeatedField(field, value); - } - - @java.lang.Override - public Builder mergeFrom(com.google.protobuf.Message other) { - if (other instanceof com.google.cloud.iot.v1.CreateDeviceRegistryRequest) { - return mergeFrom((com.google.cloud.iot.v1.CreateDeviceRegistryRequest) other); - } else { - super.mergeFrom(other); - return this; - } - } - - public Builder mergeFrom(com.google.cloud.iot.v1.CreateDeviceRegistryRequest other) { - if (other == com.google.cloud.iot.v1.CreateDeviceRegistryRequest.getDefaultInstance()) - return this; - if (!other.getParent().isEmpty()) { - parent_ = other.parent_; - onChanged(); - } - if (other.hasDeviceRegistry()) { - mergeDeviceRegistry(other.getDeviceRegistry()); - } - this.mergeUnknownFields(other.getUnknownFields()); - onChanged(); - return this; - } - - @java.lang.Override - public final boolean isInitialized() { - return true; - } - - @java.lang.Override - public Builder mergeFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - if (extensionRegistry == null) { - throw new java.lang.NullPointerException(); - } - try { - boolean done = false; - while (!done) { - int tag = input.readTag(); - switch (tag) { - case 0: - done = true; - break; - case 10: - { - parent_ = input.readStringRequireUtf8(); - - break; - } // case 10 - case 18: - { - input.readMessage(getDeviceRegistryFieldBuilder().getBuilder(), extensionRegistry); - - break; - } // case 18 - default: - { - if (!super.parseUnknownField(input, extensionRegistry, tag)) { - done = true; // was an endgroup tag - } - break; - } // default: - } // switch (tag) - } // while (!done) - } catch (com.google.protobuf.InvalidProtocolBufferException e) { - throw e.unwrapIOException(); - } finally { - onChanged(); - } // finally - return this; - } - - private java.lang.Object parent_ = ""; - /** - * - * - *
-     * Required. The project and cloud region where this device registry must be created.
-     * For example, `projects/example-project/locations/us-central1`.
-     * 
- * - * - * string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } - * - * - * @return The parent. - */ - public java.lang.String getParent() { - java.lang.Object ref = parent_; - if (!(ref instanceof java.lang.String)) { - com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; - java.lang.String s = bs.toStringUtf8(); - parent_ = s; - return s; - } else { - return (java.lang.String) ref; - } - } - /** - * - * - *
-     * Required. The project and cloud region where this device registry must be created.
-     * For example, `projects/example-project/locations/us-central1`.
-     * 
- * - * - * string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } - * - * - * @return The bytes for parent. - */ - public com.google.protobuf.ByteString getParentBytes() { - java.lang.Object ref = parent_; - if (ref instanceof String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); - parent_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - /** - * - * - *
-     * Required. The project and cloud region where this device registry must be created.
-     * For example, `projects/example-project/locations/us-central1`.
-     * 
- * - * - * string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } - * - * - * @param value The parent to set. - * @return This builder for chaining. - */ - public Builder setParent(java.lang.String value) { - if (value == null) { - throw new NullPointerException(); - } - - parent_ = value; - onChanged(); - return this; - } - /** - * - * - *
-     * Required. The project and cloud region where this device registry must be created.
-     * For example, `projects/example-project/locations/us-central1`.
-     * 
- * - * - * string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } - * - * - * @return This builder for chaining. - */ - public Builder clearParent() { - - parent_ = getDefaultInstance().getParent(); - onChanged(); - return this; - } - /** - * - * - *
-     * Required. The project and cloud region where this device registry must be created.
-     * For example, `projects/example-project/locations/us-central1`.
-     * 
- * - * - * string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } - * - * - * @param value The bytes for parent to set. - * @return This builder for chaining. - */ - public Builder setParentBytes(com.google.protobuf.ByteString value) { - if (value == null) { - throw new NullPointerException(); - } - checkByteStringIsUtf8(value); - - parent_ = value; - onChanged(); - return this; - } - - private com.google.cloud.iot.v1.DeviceRegistry deviceRegistry_; - private com.google.protobuf.SingleFieldBuilderV3< - com.google.cloud.iot.v1.DeviceRegistry, - com.google.cloud.iot.v1.DeviceRegistry.Builder, - com.google.cloud.iot.v1.DeviceRegistryOrBuilder> - deviceRegistryBuilder_; - /** - * - * - *
-     * Required. The device registry. The field `name` must be empty. The server will
-     * generate that field from the device registry `id` provided and the
-     * `parent` field.
-     * 
- * - * - * .google.cloud.iot.v1.DeviceRegistry device_registry = 2 [(.google.api.field_behavior) = REQUIRED]; - * - * - * @return Whether the deviceRegistry field is set. - */ - public boolean hasDeviceRegistry() { - return deviceRegistryBuilder_ != null || deviceRegistry_ != null; - } - /** - * - * - *
-     * Required. The device registry. The field `name` must be empty. The server will
-     * generate that field from the device registry `id` provided and the
-     * `parent` field.
-     * 
- * - * - * .google.cloud.iot.v1.DeviceRegistry device_registry = 2 [(.google.api.field_behavior) = REQUIRED]; - * - * - * @return The deviceRegistry. - */ - public com.google.cloud.iot.v1.DeviceRegistry getDeviceRegistry() { - if (deviceRegistryBuilder_ == null) { - return deviceRegistry_ == null - ? com.google.cloud.iot.v1.DeviceRegistry.getDefaultInstance() - : deviceRegistry_; - } else { - return deviceRegistryBuilder_.getMessage(); - } - } - /** - * - * - *
-     * Required. The device registry. The field `name` must be empty. The server will
-     * generate that field from the device registry `id` provided and the
-     * `parent` field.
-     * 
- * - * - * .google.cloud.iot.v1.DeviceRegistry device_registry = 2 [(.google.api.field_behavior) = REQUIRED]; - * - */ - public Builder setDeviceRegistry(com.google.cloud.iot.v1.DeviceRegistry value) { - if (deviceRegistryBuilder_ == null) { - if (value == null) { - throw new NullPointerException(); - } - deviceRegistry_ = value; - onChanged(); - } else { - deviceRegistryBuilder_.setMessage(value); - } - - return this; - } - /** - * - * - *
-     * Required. The device registry. The field `name` must be empty. The server will
-     * generate that field from the device registry `id` provided and the
-     * `parent` field.
-     * 
- * - * - * .google.cloud.iot.v1.DeviceRegistry device_registry = 2 [(.google.api.field_behavior) = REQUIRED]; - * - */ - public Builder setDeviceRegistry( - com.google.cloud.iot.v1.DeviceRegistry.Builder builderForValue) { - if (deviceRegistryBuilder_ == null) { - deviceRegistry_ = builderForValue.build(); - onChanged(); - } else { - deviceRegistryBuilder_.setMessage(builderForValue.build()); - } - - return this; - } - /** - * - * - *
-     * Required. The device registry. The field `name` must be empty. The server will
-     * generate that field from the device registry `id` provided and the
-     * `parent` field.
-     * 
- * - * - * .google.cloud.iot.v1.DeviceRegistry device_registry = 2 [(.google.api.field_behavior) = REQUIRED]; - * - */ - public Builder mergeDeviceRegistry(com.google.cloud.iot.v1.DeviceRegistry value) { - if (deviceRegistryBuilder_ == null) { - if (deviceRegistry_ != null) { - deviceRegistry_ = - com.google.cloud.iot.v1.DeviceRegistry.newBuilder(deviceRegistry_) - .mergeFrom(value) - .buildPartial(); - } else { - deviceRegistry_ = value; - } - onChanged(); - } else { - deviceRegistryBuilder_.mergeFrom(value); - } - - return this; - } - /** - * - * - *
-     * Required. The device registry. The field `name` must be empty. The server will
-     * generate that field from the device registry `id` provided and the
-     * `parent` field.
-     * 
- * - * - * .google.cloud.iot.v1.DeviceRegistry device_registry = 2 [(.google.api.field_behavior) = REQUIRED]; - * - */ - public Builder clearDeviceRegistry() { - if (deviceRegistryBuilder_ == null) { - deviceRegistry_ = null; - onChanged(); - } else { - deviceRegistry_ = null; - deviceRegistryBuilder_ = null; - } - - return this; - } - /** - * - * - *
-     * Required. The device registry. The field `name` must be empty. The server will
-     * generate that field from the device registry `id` provided and the
-     * `parent` field.
-     * 
- * - * - * .google.cloud.iot.v1.DeviceRegistry device_registry = 2 [(.google.api.field_behavior) = REQUIRED]; - * - */ - public com.google.cloud.iot.v1.DeviceRegistry.Builder getDeviceRegistryBuilder() { - - onChanged(); - return getDeviceRegistryFieldBuilder().getBuilder(); - } - /** - * - * - *
-     * Required. The device registry. The field `name` must be empty. The server will
-     * generate that field from the device registry `id` provided and the
-     * `parent` field.
-     * 
- * - * - * .google.cloud.iot.v1.DeviceRegistry device_registry = 2 [(.google.api.field_behavior) = REQUIRED]; - * - */ - public com.google.cloud.iot.v1.DeviceRegistryOrBuilder getDeviceRegistryOrBuilder() { - if (deviceRegistryBuilder_ != null) { - return deviceRegistryBuilder_.getMessageOrBuilder(); - } else { - return deviceRegistry_ == null - ? com.google.cloud.iot.v1.DeviceRegistry.getDefaultInstance() - : deviceRegistry_; - } - } - /** - * - * - *
-     * Required. The device registry. The field `name` must be empty. The server will
-     * generate that field from the device registry `id` provided and the
-     * `parent` field.
-     * 
- * - * - * .google.cloud.iot.v1.DeviceRegistry device_registry = 2 [(.google.api.field_behavior) = REQUIRED]; - * - */ - private com.google.protobuf.SingleFieldBuilderV3< - com.google.cloud.iot.v1.DeviceRegistry, - com.google.cloud.iot.v1.DeviceRegistry.Builder, - com.google.cloud.iot.v1.DeviceRegistryOrBuilder> - getDeviceRegistryFieldBuilder() { - if (deviceRegistryBuilder_ == null) { - deviceRegistryBuilder_ = - new com.google.protobuf.SingleFieldBuilderV3< - com.google.cloud.iot.v1.DeviceRegistry, - com.google.cloud.iot.v1.DeviceRegistry.Builder, - com.google.cloud.iot.v1.DeviceRegistryOrBuilder>( - getDeviceRegistry(), getParentForChildren(), isClean()); - deviceRegistry_ = null; - } - return deviceRegistryBuilder_; - } - - @java.lang.Override - public final Builder setUnknownFields(final com.google.protobuf.UnknownFieldSet unknownFields) { - return super.setUnknownFields(unknownFields); - } - - @java.lang.Override - public final Builder mergeUnknownFields( - final com.google.protobuf.UnknownFieldSet unknownFields) { - return super.mergeUnknownFields(unknownFields); - } - - // @@protoc_insertion_point(builder_scope:google.cloud.iot.v1.CreateDeviceRegistryRequest) - } - - // @@protoc_insertion_point(class_scope:google.cloud.iot.v1.CreateDeviceRegistryRequest) - private static final com.google.cloud.iot.v1.CreateDeviceRegistryRequest DEFAULT_INSTANCE; - - static { - DEFAULT_INSTANCE = new com.google.cloud.iot.v1.CreateDeviceRegistryRequest(); - } - - public static com.google.cloud.iot.v1.CreateDeviceRegistryRequest getDefaultInstance() { - return DEFAULT_INSTANCE; - } - - private static final com.google.protobuf.Parser PARSER = - new com.google.protobuf.AbstractParser() { - @java.lang.Override - public CreateDeviceRegistryRequest parsePartialFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - Builder builder = newBuilder(); - try { - builder.mergeFrom(input, extensionRegistry); - } catch (com.google.protobuf.InvalidProtocolBufferException e) { - throw e.setUnfinishedMessage(builder.buildPartial()); - } catch (com.google.protobuf.UninitializedMessageException e) { - throw e.asInvalidProtocolBufferException().setUnfinishedMessage(builder.buildPartial()); - } catch (java.io.IOException e) { - throw new com.google.protobuf.InvalidProtocolBufferException(e) - .setUnfinishedMessage(builder.buildPartial()); - } - return builder.buildPartial(); - } - }; - - public static com.google.protobuf.Parser parser() { - return PARSER; - } - - @java.lang.Override - public com.google.protobuf.Parser getParserForType() { - return PARSER; - } - - @java.lang.Override - public com.google.cloud.iot.v1.CreateDeviceRegistryRequest getDefaultInstanceForType() { - return DEFAULT_INSTANCE; - } -} diff --git a/proto-google-cloud-iot-v1/src/main/java/com/google/cloud/iot/v1/CreateDeviceRegistryRequestOrBuilder.java b/proto-google-cloud-iot-v1/src/main/java/com/google/cloud/iot/v1/CreateDeviceRegistryRequestOrBuilder.java deleted file mode 100644 index 260d95a0..00000000 --- a/proto-google-cloud-iot-v1/src/main/java/com/google/cloud/iot/v1/CreateDeviceRegistryRequestOrBuilder.java +++ /dev/null @@ -1,103 +0,0 @@ -/* - * Copyright 2020 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. - */ -// Generated by the protocol buffer compiler. DO NOT EDIT! -// source: google/cloud/iot/v1/device_manager.proto - -package com.google.cloud.iot.v1; - -public interface CreateDeviceRegistryRequestOrBuilder - extends - // @@protoc_insertion_point(interface_extends:google.cloud.iot.v1.CreateDeviceRegistryRequest) - com.google.protobuf.MessageOrBuilder { - - /** - * - * - *
-   * Required. The project and cloud region where this device registry must be created.
-   * For example, `projects/example-project/locations/us-central1`.
-   * 
- * - * - * string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } - * - * - * @return The parent. - */ - java.lang.String getParent(); - /** - * - * - *
-   * Required. The project and cloud region where this device registry must be created.
-   * For example, `projects/example-project/locations/us-central1`.
-   * 
- * - * - * string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } - * - * - * @return The bytes for parent. - */ - com.google.protobuf.ByteString getParentBytes(); - - /** - * - * - *
-   * Required. The device registry. The field `name` must be empty. The server will
-   * generate that field from the device registry `id` provided and the
-   * `parent` field.
-   * 
- * - * - * .google.cloud.iot.v1.DeviceRegistry device_registry = 2 [(.google.api.field_behavior) = REQUIRED]; - * - * - * @return Whether the deviceRegistry field is set. - */ - boolean hasDeviceRegistry(); - /** - * - * - *
-   * Required. The device registry. The field `name` must be empty. The server will
-   * generate that field from the device registry `id` provided and the
-   * `parent` field.
-   * 
- * - * - * .google.cloud.iot.v1.DeviceRegistry device_registry = 2 [(.google.api.field_behavior) = REQUIRED]; - * - * - * @return The deviceRegistry. - */ - com.google.cloud.iot.v1.DeviceRegistry getDeviceRegistry(); - /** - * - * - *
-   * Required. The device registry. The field `name` must be empty. The server will
-   * generate that field from the device registry `id` provided and the
-   * `parent` field.
-   * 
- * - * - * .google.cloud.iot.v1.DeviceRegistry device_registry = 2 [(.google.api.field_behavior) = REQUIRED]; - * - */ - com.google.cloud.iot.v1.DeviceRegistryOrBuilder getDeviceRegistryOrBuilder(); -} diff --git a/proto-google-cloud-iot-v1/src/main/java/com/google/cloud/iot/v1/CreateDeviceRequest.java b/proto-google-cloud-iot-v1/src/main/java/com/google/cloud/iot/v1/CreateDeviceRequest.java deleted file mode 100644 index 6a16af62..00000000 --- a/proto-google-cloud-iot-v1/src/main/java/com/google/cloud/iot/v1/CreateDeviceRequest.java +++ /dev/null @@ -1,934 +0,0 @@ -/* - * Copyright 2020 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. - */ -// Generated by the protocol buffer compiler. DO NOT EDIT! -// source: google/cloud/iot/v1/device_manager.proto - -package com.google.cloud.iot.v1; - -/** - * - * - *
- * Request for `CreateDevice`.
- * 
- * - * Protobuf type {@code google.cloud.iot.v1.CreateDeviceRequest} - */ -public final class CreateDeviceRequest extends com.google.protobuf.GeneratedMessageV3 - implements - // @@protoc_insertion_point(message_implements:google.cloud.iot.v1.CreateDeviceRequest) - CreateDeviceRequestOrBuilder { - private static final long serialVersionUID = 0L; - // Use CreateDeviceRequest.newBuilder() to construct. - private CreateDeviceRequest(com.google.protobuf.GeneratedMessageV3.Builder builder) { - super(builder); - } - - private CreateDeviceRequest() { - parent_ = ""; - } - - @java.lang.Override - @SuppressWarnings({"unused"}) - protected java.lang.Object newInstance(UnusedPrivateParameter unused) { - return new CreateDeviceRequest(); - } - - @java.lang.Override - public final com.google.protobuf.UnknownFieldSet getUnknownFields() { - return this.unknownFields; - } - - public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { - return com.google.cloud.iot.v1.DeviceManagerProto - .internal_static_google_cloud_iot_v1_CreateDeviceRequest_descriptor; - } - - @java.lang.Override - protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable - internalGetFieldAccessorTable() { - return com.google.cloud.iot.v1.DeviceManagerProto - .internal_static_google_cloud_iot_v1_CreateDeviceRequest_fieldAccessorTable - .ensureFieldAccessorsInitialized( - com.google.cloud.iot.v1.CreateDeviceRequest.class, - com.google.cloud.iot.v1.CreateDeviceRequest.Builder.class); - } - - public static final int PARENT_FIELD_NUMBER = 1; - private volatile java.lang.Object parent_; - /** - * - * - *
-   * Required. The name of the device registry where this device should be created.
-   * For example,
-   * `projects/example-project/locations/us-central1/registries/my-registry`.
-   * 
- * - * - * string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } - * - * - * @return The parent. - */ - @java.lang.Override - public java.lang.String getParent() { - java.lang.Object ref = parent_; - if (ref instanceof java.lang.String) { - return (java.lang.String) ref; - } else { - com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; - java.lang.String s = bs.toStringUtf8(); - parent_ = s; - return s; - } - } - /** - * - * - *
-   * Required. The name of the device registry where this device should be created.
-   * For example,
-   * `projects/example-project/locations/us-central1/registries/my-registry`.
-   * 
- * - * - * string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } - * - * - * @return The bytes for parent. - */ - @java.lang.Override - public com.google.protobuf.ByteString getParentBytes() { - java.lang.Object ref = parent_; - if (ref instanceof java.lang.String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); - parent_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - - public static final int DEVICE_FIELD_NUMBER = 2; - private com.google.cloud.iot.v1.Device device_; - /** - * - * - *
-   * Required. The device registration details. The field `name` must be empty. The server
-   * generates `name` from the device registry `id` and the
-   * `parent` field.
-   * 
- * - * .google.cloud.iot.v1.Device device = 2 [(.google.api.field_behavior) = REQUIRED]; - * - * @return Whether the device field is set. - */ - @java.lang.Override - public boolean hasDevice() { - return device_ != null; - } - /** - * - * - *
-   * Required. The device registration details. The field `name` must be empty. The server
-   * generates `name` from the device registry `id` and the
-   * `parent` field.
-   * 
- * - * .google.cloud.iot.v1.Device device = 2 [(.google.api.field_behavior) = REQUIRED]; - * - * @return The device. - */ - @java.lang.Override - public com.google.cloud.iot.v1.Device getDevice() { - return device_ == null ? com.google.cloud.iot.v1.Device.getDefaultInstance() : device_; - } - /** - * - * - *
-   * Required. The device registration details. The field `name` must be empty. The server
-   * generates `name` from the device registry `id` and the
-   * `parent` field.
-   * 
- * - * .google.cloud.iot.v1.Device device = 2 [(.google.api.field_behavior) = REQUIRED]; - */ - @java.lang.Override - public com.google.cloud.iot.v1.DeviceOrBuilder getDeviceOrBuilder() { - return getDevice(); - } - - private byte memoizedIsInitialized = -1; - - @java.lang.Override - public final boolean isInitialized() { - byte isInitialized = memoizedIsInitialized; - if (isInitialized == 1) return true; - if (isInitialized == 0) return false; - - memoizedIsInitialized = 1; - return true; - } - - @java.lang.Override - public void writeTo(com.google.protobuf.CodedOutputStream output) throws java.io.IOException { - if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(parent_)) { - com.google.protobuf.GeneratedMessageV3.writeString(output, 1, parent_); - } - if (device_ != null) { - output.writeMessage(2, getDevice()); - } - getUnknownFields().writeTo(output); - } - - @java.lang.Override - public int getSerializedSize() { - int size = memoizedSize; - if (size != -1) return size; - - size = 0; - if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(parent_)) { - size += com.google.protobuf.GeneratedMessageV3.computeStringSize(1, parent_); - } - if (device_ != null) { - size += com.google.protobuf.CodedOutputStream.computeMessageSize(2, getDevice()); - } - size += getUnknownFields().getSerializedSize(); - memoizedSize = size; - return size; - } - - @java.lang.Override - public boolean equals(final java.lang.Object obj) { - if (obj == this) { - return true; - } - if (!(obj instanceof com.google.cloud.iot.v1.CreateDeviceRequest)) { - return super.equals(obj); - } - com.google.cloud.iot.v1.CreateDeviceRequest other = - (com.google.cloud.iot.v1.CreateDeviceRequest) obj; - - if (!getParent().equals(other.getParent())) return false; - if (hasDevice() != other.hasDevice()) return false; - if (hasDevice()) { - if (!getDevice().equals(other.getDevice())) return false; - } - if (!getUnknownFields().equals(other.getUnknownFields())) return false; - return true; - } - - @java.lang.Override - public int hashCode() { - if (memoizedHashCode != 0) { - return memoizedHashCode; - } - int hash = 41; - hash = (19 * hash) + getDescriptor().hashCode(); - hash = (37 * hash) + PARENT_FIELD_NUMBER; - hash = (53 * hash) + getParent().hashCode(); - if (hasDevice()) { - hash = (37 * hash) + DEVICE_FIELD_NUMBER; - hash = (53 * hash) + getDevice().hashCode(); - } - hash = (29 * hash) + getUnknownFields().hashCode(); - memoizedHashCode = hash; - return hash; - } - - public static com.google.cloud.iot.v1.CreateDeviceRequest parseFrom(java.nio.ByteBuffer data) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); - } - - public static com.google.cloud.iot.v1.CreateDeviceRequest parseFrom( - java.nio.ByteBuffer data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); - } - - public static com.google.cloud.iot.v1.CreateDeviceRequest parseFrom( - com.google.protobuf.ByteString data) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); - } - - public static com.google.cloud.iot.v1.CreateDeviceRequest parseFrom( - com.google.protobuf.ByteString data, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); - } - - public static com.google.cloud.iot.v1.CreateDeviceRequest parseFrom(byte[] data) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); - } - - public static com.google.cloud.iot.v1.CreateDeviceRequest parseFrom( - byte[] data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); - } - - public static com.google.cloud.iot.v1.CreateDeviceRequest parseFrom(java.io.InputStream input) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input); - } - - public static com.google.cloud.iot.v1.CreateDeviceRequest parseFrom( - java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3.parseWithIOException( - PARSER, input, extensionRegistry); - } - - public static com.google.cloud.iot.v1.CreateDeviceRequest parseDelimitedFrom( - java.io.InputStream input) throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3.parseDelimitedWithIOException(PARSER, input); - } - - public static com.google.cloud.iot.v1.CreateDeviceRequest parseDelimitedFrom( - java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3.parseDelimitedWithIOException( - PARSER, input, extensionRegistry); - } - - public static com.google.cloud.iot.v1.CreateDeviceRequest parseFrom( - com.google.protobuf.CodedInputStream input) throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input); - } - - public static com.google.cloud.iot.v1.CreateDeviceRequest parseFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3.parseWithIOException( - PARSER, input, extensionRegistry); - } - - @java.lang.Override - public Builder newBuilderForType() { - return newBuilder(); - } - - public static Builder newBuilder() { - return DEFAULT_INSTANCE.toBuilder(); - } - - public static Builder newBuilder(com.google.cloud.iot.v1.CreateDeviceRequest prototype) { - return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); - } - - @java.lang.Override - public Builder toBuilder() { - return this == DEFAULT_INSTANCE ? new Builder() : new Builder().mergeFrom(this); - } - - @java.lang.Override - protected Builder newBuilderForType(com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { - Builder builder = new Builder(parent); - return builder; - } - /** - * - * - *
-   * Request for `CreateDevice`.
-   * 
- * - * Protobuf type {@code google.cloud.iot.v1.CreateDeviceRequest} - */ - public static final class Builder extends com.google.protobuf.GeneratedMessageV3.Builder - implements - // @@protoc_insertion_point(builder_implements:google.cloud.iot.v1.CreateDeviceRequest) - com.google.cloud.iot.v1.CreateDeviceRequestOrBuilder { - public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { - return com.google.cloud.iot.v1.DeviceManagerProto - .internal_static_google_cloud_iot_v1_CreateDeviceRequest_descriptor; - } - - @java.lang.Override - protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable - internalGetFieldAccessorTable() { - return com.google.cloud.iot.v1.DeviceManagerProto - .internal_static_google_cloud_iot_v1_CreateDeviceRequest_fieldAccessorTable - .ensureFieldAccessorsInitialized( - com.google.cloud.iot.v1.CreateDeviceRequest.class, - com.google.cloud.iot.v1.CreateDeviceRequest.Builder.class); - } - - // Construct using com.google.cloud.iot.v1.CreateDeviceRequest.newBuilder() - private Builder() {} - - private Builder(com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { - super(parent); - } - - @java.lang.Override - public Builder clear() { - super.clear(); - parent_ = ""; - - if (deviceBuilder_ == null) { - device_ = null; - } else { - device_ = null; - deviceBuilder_ = null; - } - return this; - } - - @java.lang.Override - public com.google.protobuf.Descriptors.Descriptor getDescriptorForType() { - return com.google.cloud.iot.v1.DeviceManagerProto - .internal_static_google_cloud_iot_v1_CreateDeviceRequest_descriptor; - } - - @java.lang.Override - public com.google.cloud.iot.v1.CreateDeviceRequest getDefaultInstanceForType() { - return com.google.cloud.iot.v1.CreateDeviceRequest.getDefaultInstance(); - } - - @java.lang.Override - public com.google.cloud.iot.v1.CreateDeviceRequest build() { - com.google.cloud.iot.v1.CreateDeviceRequest result = buildPartial(); - if (!result.isInitialized()) { - throw newUninitializedMessageException(result); - } - return result; - } - - @java.lang.Override - public com.google.cloud.iot.v1.CreateDeviceRequest buildPartial() { - com.google.cloud.iot.v1.CreateDeviceRequest result = - new com.google.cloud.iot.v1.CreateDeviceRequest(this); - result.parent_ = parent_; - if (deviceBuilder_ == null) { - result.device_ = device_; - } else { - result.device_ = deviceBuilder_.build(); - } - onBuilt(); - return result; - } - - @java.lang.Override - public Builder clone() { - return super.clone(); - } - - @java.lang.Override - public Builder setField( - com.google.protobuf.Descriptors.FieldDescriptor field, java.lang.Object value) { - return super.setField(field, value); - } - - @java.lang.Override - public Builder clearField(com.google.protobuf.Descriptors.FieldDescriptor field) { - return super.clearField(field); - } - - @java.lang.Override - public Builder clearOneof(com.google.protobuf.Descriptors.OneofDescriptor oneof) { - return super.clearOneof(oneof); - } - - @java.lang.Override - public Builder setRepeatedField( - com.google.protobuf.Descriptors.FieldDescriptor field, int index, java.lang.Object value) { - return super.setRepeatedField(field, index, value); - } - - @java.lang.Override - public Builder addRepeatedField( - com.google.protobuf.Descriptors.FieldDescriptor field, java.lang.Object value) { - return super.addRepeatedField(field, value); - } - - @java.lang.Override - public Builder mergeFrom(com.google.protobuf.Message other) { - if (other instanceof com.google.cloud.iot.v1.CreateDeviceRequest) { - return mergeFrom((com.google.cloud.iot.v1.CreateDeviceRequest) other); - } else { - super.mergeFrom(other); - return this; - } - } - - public Builder mergeFrom(com.google.cloud.iot.v1.CreateDeviceRequest other) { - if (other == com.google.cloud.iot.v1.CreateDeviceRequest.getDefaultInstance()) return this; - if (!other.getParent().isEmpty()) { - parent_ = other.parent_; - onChanged(); - } - if (other.hasDevice()) { - mergeDevice(other.getDevice()); - } - this.mergeUnknownFields(other.getUnknownFields()); - onChanged(); - return this; - } - - @java.lang.Override - public final boolean isInitialized() { - return true; - } - - @java.lang.Override - public Builder mergeFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - if (extensionRegistry == null) { - throw new java.lang.NullPointerException(); - } - try { - boolean done = false; - while (!done) { - int tag = input.readTag(); - switch (tag) { - case 0: - done = true; - break; - case 10: - { - parent_ = input.readStringRequireUtf8(); - - break; - } // case 10 - case 18: - { - input.readMessage(getDeviceFieldBuilder().getBuilder(), extensionRegistry); - - break; - } // case 18 - default: - { - if (!super.parseUnknownField(input, extensionRegistry, tag)) { - done = true; // was an endgroup tag - } - break; - } // default: - } // switch (tag) - } // while (!done) - } catch (com.google.protobuf.InvalidProtocolBufferException e) { - throw e.unwrapIOException(); - } finally { - onChanged(); - } // finally - return this; - } - - private java.lang.Object parent_ = ""; - /** - * - * - *
-     * Required. The name of the device registry where this device should be created.
-     * For example,
-     * `projects/example-project/locations/us-central1/registries/my-registry`.
-     * 
- * - * - * string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } - * - * - * @return The parent. - */ - public java.lang.String getParent() { - java.lang.Object ref = parent_; - if (!(ref instanceof java.lang.String)) { - com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; - java.lang.String s = bs.toStringUtf8(); - parent_ = s; - return s; - } else { - return (java.lang.String) ref; - } - } - /** - * - * - *
-     * Required. The name of the device registry where this device should be created.
-     * For example,
-     * `projects/example-project/locations/us-central1/registries/my-registry`.
-     * 
- * - * - * string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } - * - * - * @return The bytes for parent. - */ - public com.google.protobuf.ByteString getParentBytes() { - java.lang.Object ref = parent_; - if (ref instanceof String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); - parent_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - /** - * - * - *
-     * Required. The name of the device registry where this device should be created.
-     * For example,
-     * `projects/example-project/locations/us-central1/registries/my-registry`.
-     * 
- * - * - * string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } - * - * - * @param value The parent to set. - * @return This builder for chaining. - */ - public Builder setParent(java.lang.String value) { - if (value == null) { - throw new NullPointerException(); - } - - parent_ = value; - onChanged(); - return this; - } - /** - * - * - *
-     * Required. The name of the device registry where this device should be created.
-     * For example,
-     * `projects/example-project/locations/us-central1/registries/my-registry`.
-     * 
- * - * - * string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } - * - * - * @return This builder for chaining. - */ - public Builder clearParent() { - - parent_ = getDefaultInstance().getParent(); - onChanged(); - return this; - } - /** - * - * - *
-     * Required. The name of the device registry where this device should be created.
-     * For example,
-     * `projects/example-project/locations/us-central1/registries/my-registry`.
-     * 
- * - * - * string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } - * - * - * @param value The bytes for parent to set. - * @return This builder for chaining. - */ - public Builder setParentBytes(com.google.protobuf.ByteString value) { - if (value == null) { - throw new NullPointerException(); - } - checkByteStringIsUtf8(value); - - parent_ = value; - onChanged(); - return this; - } - - private com.google.cloud.iot.v1.Device device_; - private com.google.protobuf.SingleFieldBuilderV3< - com.google.cloud.iot.v1.Device, - com.google.cloud.iot.v1.Device.Builder, - com.google.cloud.iot.v1.DeviceOrBuilder> - deviceBuilder_; - /** - * - * - *
-     * Required. The device registration details. The field `name` must be empty. The server
-     * generates `name` from the device registry `id` and the
-     * `parent` field.
-     * 
- * - * .google.cloud.iot.v1.Device device = 2 [(.google.api.field_behavior) = REQUIRED]; - * - * - * @return Whether the device field is set. - */ - public boolean hasDevice() { - return deviceBuilder_ != null || device_ != null; - } - /** - * - * - *
-     * Required. The device registration details. The field `name` must be empty. The server
-     * generates `name` from the device registry `id` and the
-     * `parent` field.
-     * 
- * - * .google.cloud.iot.v1.Device device = 2 [(.google.api.field_behavior) = REQUIRED]; - * - * - * @return The device. - */ - public com.google.cloud.iot.v1.Device getDevice() { - if (deviceBuilder_ == null) { - return device_ == null ? com.google.cloud.iot.v1.Device.getDefaultInstance() : device_; - } else { - return deviceBuilder_.getMessage(); - } - } - /** - * - * - *
-     * Required. The device registration details. The field `name` must be empty. The server
-     * generates `name` from the device registry `id` and the
-     * `parent` field.
-     * 
- * - * .google.cloud.iot.v1.Device device = 2 [(.google.api.field_behavior) = REQUIRED]; - * - */ - public Builder setDevice(com.google.cloud.iot.v1.Device value) { - if (deviceBuilder_ == null) { - if (value == null) { - throw new NullPointerException(); - } - device_ = value; - onChanged(); - } else { - deviceBuilder_.setMessage(value); - } - - return this; - } - /** - * - * - *
-     * Required. The device registration details. The field `name` must be empty. The server
-     * generates `name` from the device registry `id` and the
-     * `parent` field.
-     * 
- * - * .google.cloud.iot.v1.Device device = 2 [(.google.api.field_behavior) = REQUIRED]; - * - */ - public Builder setDevice(com.google.cloud.iot.v1.Device.Builder builderForValue) { - if (deviceBuilder_ == null) { - device_ = builderForValue.build(); - onChanged(); - } else { - deviceBuilder_.setMessage(builderForValue.build()); - } - - return this; - } - /** - * - * - *
-     * Required. The device registration details. The field `name` must be empty. The server
-     * generates `name` from the device registry `id` and the
-     * `parent` field.
-     * 
- * - * .google.cloud.iot.v1.Device device = 2 [(.google.api.field_behavior) = REQUIRED]; - * - */ - public Builder mergeDevice(com.google.cloud.iot.v1.Device value) { - if (deviceBuilder_ == null) { - if (device_ != null) { - device_ = - com.google.cloud.iot.v1.Device.newBuilder(device_).mergeFrom(value).buildPartial(); - } else { - device_ = value; - } - onChanged(); - } else { - deviceBuilder_.mergeFrom(value); - } - - return this; - } - /** - * - * - *
-     * Required. The device registration details. The field `name` must be empty. The server
-     * generates `name` from the device registry `id` and the
-     * `parent` field.
-     * 
- * - * .google.cloud.iot.v1.Device device = 2 [(.google.api.field_behavior) = REQUIRED]; - * - */ - public Builder clearDevice() { - if (deviceBuilder_ == null) { - device_ = null; - onChanged(); - } else { - device_ = null; - deviceBuilder_ = null; - } - - return this; - } - /** - * - * - *
-     * Required. The device registration details. The field `name` must be empty. The server
-     * generates `name` from the device registry `id` and the
-     * `parent` field.
-     * 
- * - * .google.cloud.iot.v1.Device device = 2 [(.google.api.field_behavior) = REQUIRED]; - * - */ - public com.google.cloud.iot.v1.Device.Builder getDeviceBuilder() { - - onChanged(); - return getDeviceFieldBuilder().getBuilder(); - } - /** - * - * - *
-     * Required. The device registration details. The field `name` must be empty. The server
-     * generates `name` from the device registry `id` and the
-     * `parent` field.
-     * 
- * - * .google.cloud.iot.v1.Device device = 2 [(.google.api.field_behavior) = REQUIRED]; - * - */ - public com.google.cloud.iot.v1.DeviceOrBuilder getDeviceOrBuilder() { - if (deviceBuilder_ != null) { - return deviceBuilder_.getMessageOrBuilder(); - } else { - return device_ == null ? com.google.cloud.iot.v1.Device.getDefaultInstance() : device_; - } - } - /** - * - * - *
-     * Required. The device registration details. The field `name` must be empty. The server
-     * generates `name` from the device registry `id` and the
-     * `parent` field.
-     * 
- * - * .google.cloud.iot.v1.Device device = 2 [(.google.api.field_behavior) = REQUIRED]; - * - */ - private com.google.protobuf.SingleFieldBuilderV3< - com.google.cloud.iot.v1.Device, - com.google.cloud.iot.v1.Device.Builder, - com.google.cloud.iot.v1.DeviceOrBuilder> - getDeviceFieldBuilder() { - if (deviceBuilder_ == null) { - deviceBuilder_ = - new com.google.protobuf.SingleFieldBuilderV3< - com.google.cloud.iot.v1.Device, - com.google.cloud.iot.v1.Device.Builder, - com.google.cloud.iot.v1.DeviceOrBuilder>( - getDevice(), getParentForChildren(), isClean()); - device_ = null; - } - return deviceBuilder_; - } - - @java.lang.Override - public final Builder setUnknownFields(final com.google.protobuf.UnknownFieldSet unknownFields) { - return super.setUnknownFields(unknownFields); - } - - @java.lang.Override - public final Builder mergeUnknownFields( - final com.google.protobuf.UnknownFieldSet unknownFields) { - return super.mergeUnknownFields(unknownFields); - } - - // @@protoc_insertion_point(builder_scope:google.cloud.iot.v1.CreateDeviceRequest) - } - - // @@protoc_insertion_point(class_scope:google.cloud.iot.v1.CreateDeviceRequest) - private static final com.google.cloud.iot.v1.CreateDeviceRequest DEFAULT_INSTANCE; - - static { - DEFAULT_INSTANCE = new com.google.cloud.iot.v1.CreateDeviceRequest(); - } - - public static com.google.cloud.iot.v1.CreateDeviceRequest getDefaultInstance() { - return DEFAULT_INSTANCE; - } - - private static final com.google.protobuf.Parser PARSER = - new com.google.protobuf.AbstractParser() { - @java.lang.Override - public CreateDeviceRequest parsePartialFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - Builder builder = newBuilder(); - try { - builder.mergeFrom(input, extensionRegistry); - } catch (com.google.protobuf.InvalidProtocolBufferException e) { - throw e.setUnfinishedMessage(builder.buildPartial()); - } catch (com.google.protobuf.UninitializedMessageException e) { - throw e.asInvalidProtocolBufferException().setUnfinishedMessage(builder.buildPartial()); - } catch (java.io.IOException e) { - throw new com.google.protobuf.InvalidProtocolBufferException(e) - .setUnfinishedMessage(builder.buildPartial()); - } - return builder.buildPartial(); - } - }; - - public static com.google.protobuf.Parser parser() { - return PARSER; - } - - @java.lang.Override - public com.google.protobuf.Parser getParserForType() { - return PARSER; - } - - @java.lang.Override - public com.google.cloud.iot.v1.CreateDeviceRequest getDefaultInstanceForType() { - return DEFAULT_INSTANCE; - } -} diff --git a/proto-google-cloud-iot-v1/src/main/java/com/google/cloud/iot/v1/CreateDeviceRequestOrBuilder.java b/proto-google-cloud-iot-v1/src/main/java/com/google/cloud/iot/v1/CreateDeviceRequestOrBuilder.java deleted file mode 100644 index 764d45cf..00000000 --- a/proto-google-cloud-iot-v1/src/main/java/com/google/cloud/iot/v1/CreateDeviceRequestOrBuilder.java +++ /dev/null @@ -1,99 +0,0 @@ -/* - * Copyright 2020 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. - */ -// Generated by the protocol buffer compiler. DO NOT EDIT! -// source: google/cloud/iot/v1/device_manager.proto - -package com.google.cloud.iot.v1; - -public interface CreateDeviceRequestOrBuilder - extends - // @@protoc_insertion_point(interface_extends:google.cloud.iot.v1.CreateDeviceRequest) - com.google.protobuf.MessageOrBuilder { - - /** - * - * - *
-   * Required. The name of the device registry where this device should be created.
-   * For example,
-   * `projects/example-project/locations/us-central1/registries/my-registry`.
-   * 
- * - * - * string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } - * - * - * @return The parent. - */ - java.lang.String getParent(); - /** - * - * - *
-   * Required. The name of the device registry where this device should be created.
-   * For example,
-   * `projects/example-project/locations/us-central1/registries/my-registry`.
-   * 
- * - * - * string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } - * - * - * @return The bytes for parent. - */ - com.google.protobuf.ByteString getParentBytes(); - - /** - * - * - *
-   * Required. The device registration details. The field `name` must be empty. The server
-   * generates `name` from the device registry `id` and the
-   * `parent` field.
-   * 
- * - * .google.cloud.iot.v1.Device device = 2 [(.google.api.field_behavior) = REQUIRED]; - * - * @return Whether the device field is set. - */ - boolean hasDevice(); - /** - * - * - *
-   * Required. The device registration details. The field `name` must be empty. The server
-   * generates `name` from the device registry `id` and the
-   * `parent` field.
-   * 
- * - * .google.cloud.iot.v1.Device device = 2 [(.google.api.field_behavior) = REQUIRED]; - * - * @return The device. - */ - com.google.cloud.iot.v1.Device getDevice(); - /** - * - * - *
-   * Required. The device registration details. The field `name` must be empty. The server
-   * generates `name` from the device registry `id` and the
-   * `parent` field.
-   * 
- * - * .google.cloud.iot.v1.Device device = 2 [(.google.api.field_behavior) = REQUIRED]; - */ - com.google.cloud.iot.v1.DeviceOrBuilder getDeviceOrBuilder(); -} diff --git a/proto-google-cloud-iot-v1/src/main/java/com/google/cloud/iot/v1/DeleteDeviceRegistryRequest.java b/proto-google-cloud-iot-v1/src/main/java/com/google/cloud/iot/v1/DeleteDeviceRegistryRequest.java deleted file mode 100644 index 12901f23..00000000 --- a/proto-google-cloud-iot-v1/src/main/java/com/google/cloud/iot/v1/DeleteDeviceRegistryRequest.java +++ /dev/null @@ -1,636 +0,0 @@ -/* - * Copyright 2020 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. - */ -// Generated by the protocol buffer compiler. DO NOT EDIT! -// source: google/cloud/iot/v1/device_manager.proto - -package com.google.cloud.iot.v1; - -/** - * - * - *
- * Request for `DeleteDeviceRegistry`.
- * 
- * - * Protobuf type {@code google.cloud.iot.v1.DeleteDeviceRegistryRequest} - */ -public final class DeleteDeviceRegistryRequest extends com.google.protobuf.GeneratedMessageV3 - implements - // @@protoc_insertion_point(message_implements:google.cloud.iot.v1.DeleteDeviceRegistryRequest) - DeleteDeviceRegistryRequestOrBuilder { - private static final long serialVersionUID = 0L; - // Use DeleteDeviceRegistryRequest.newBuilder() to construct. - private DeleteDeviceRegistryRequest(com.google.protobuf.GeneratedMessageV3.Builder builder) { - super(builder); - } - - private DeleteDeviceRegistryRequest() { - name_ = ""; - } - - @java.lang.Override - @SuppressWarnings({"unused"}) - protected java.lang.Object newInstance(UnusedPrivateParameter unused) { - return new DeleteDeviceRegistryRequest(); - } - - @java.lang.Override - public final com.google.protobuf.UnknownFieldSet getUnknownFields() { - return this.unknownFields; - } - - public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { - return com.google.cloud.iot.v1.DeviceManagerProto - .internal_static_google_cloud_iot_v1_DeleteDeviceRegistryRequest_descriptor; - } - - @java.lang.Override - protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable - internalGetFieldAccessorTable() { - return com.google.cloud.iot.v1.DeviceManagerProto - .internal_static_google_cloud_iot_v1_DeleteDeviceRegistryRequest_fieldAccessorTable - .ensureFieldAccessorsInitialized( - com.google.cloud.iot.v1.DeleteDeviceRegistryRequest.class, - com.google.cloud.iot.v1.DeleteDeviceRegistryRequest.Builder.class); - } - - public static final int NAME_FIELD_NUMBER = 1; - private volatile java.lang.Object name_; - /** - * - * - *
-   * Required. The name of the device registry. For example,
-   * `projects/example-project/locations/us-central1/registries/my-registry`.
-   * 
- * - * - * string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } - * - * - * @return The name. - */ - @java.lang.Override - public java.lang.String getName() { - java.lang.Object ref = name_; - if (ref instanceof java.lang.String) { - return (java.lang.String) ref; - } else { - com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; - java.lang.String s = bs.toStringUtf8(); - name_ = s; - return s; - } - } - /** - * - * - *
-   * Required. The name of the device registry. For example,
-   * `projects/example-project/locations/us-central1/registries/my-registry`.
-   * 
- * - * - * string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } - * - * - * @return The bytes for name. - */ - @java.lang.Override - public com.google.protobuf.ByteString getNameBytes() { - java.lang.Object ref = name_; - if (ref instanceof java.lang.String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); - name_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - - private byte memoizedIsInitialized = -1; - - @java.lang.Override - public final boolean isInitialized() { - byte isInitialized = memoizedIsInitialized; - if (isInitialized == 1) return true; - if (isInitialized == 0) return false; - - memoizedIsInitialized = 1; - return true; - } - - @java.lang.Override - public void writeTo(com.google.protobuf.CodedOutputStream output) throws java.io.IOException { - if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(name_)) { - com.google.protobuf.GeneratedMessageV3.writeString(output, 1, name_); - } - getUnknownFields().writeTo(output); - } - - @java.lang.Override - public int getSerializedSize() { - int size = memoizedSize; - if (size != -1) return size; - - size = 0; - if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(name_)) { - size += com.google.protobuf.GeneratedMessageV3.computeStringSize(1, name_); - } - size += getUnknownFields().getSerializedSize(); - memoizedSize = size; - return size; - } - - @java.lang.Override - public boolean equals(final java.lang.Object obj) { - if (obj == this) { - return true; - } - if (!(obj instanceof com.google.cloud.iot.v1.DeleteDeviceRegistryRequest)) { - return super.equals(obj); - } - com.google.cloud.iot.v1.DeleteDeviceRegistryRequest other = - (com.google.cloud.iot.v1.DeleteDeviceRegistryRequest) obj; - - if (!getName().equals(other.getName())) return false; - if (!getUnknownFields().equals(other.getUnknownFields())) return false; - return true; - } - - @java.lang.Override - public int hashCode() { - if (memoizedHashCode != 0) { - return memoizedHashCode; - } - int hash = 41; - hash = (19 * hash) + getDescriptor().hashCode(); - hash = (37 * hash) + NAME_FIELD_NUMBER; - hash = (53 * hash) + getName().hashCode(); - hash = (29 * hash) + getUnknownFields().hashCode(); - memoizedHashCode = hash; - return hash; - } - - public static com.google.cloud.iot.v1.DeleteDeviceRegistryRequest parseFrom( - java.nio.ByteBuffer data) throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); - } - - public static com.google.cloud.iot.v1.DeleteDeviceRegistryRequest parseFrom( - java.nio.ByteBuffer data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); - } - - public static com.google.cloud.iot.v1.DeleteDeviceRegistryRequest parseFrom( - com.google.protobuf.ByteString data) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); - } - - public static com.google.cloud.iot.v1.DeleteDeviceRegistryRequest parseFrom( - com.google.protobuf.ByteString data, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); - } - - public static com.google.cloud.iot.v1.DeleteDeviceRegistryRequest parseFrom(byte[] data) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); - } - - public static com.google.cloud.iot.v1.DeleteDeviceRegistryRequest parseFrom( - byte[] data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); - } - - public static com.google.cloud.iot.v1.DeleteDeviceRegistryRequest parseFrom( - java.io.InputStream input) throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input); - } - - public static com.google.cloud.iot.v1.DeleteDeviceRegistryRequest parseFrom( - java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3.parseWithIOException( - PARSER, input, extensionRegistry); - } - - public static com.google.cloud.iot.v1.DeleteDeviceRegistryRequest parseDelimitedFrom( - java.io.InputStream input) throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3.parseDelimitedWithIOException(PARSER, input); - } - - public static com.google.cloud.iot.v1.DeleteDeviceRegistryRequest parseDelimitedFrom( - java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3.parseDelimitedWithIOException( - PARSER, input, extensionRegistry); - } - - public static com.google.cloud.iot.v1.DeleteDeviceRegistryRequest parseFrom( - com.google.protobuf.CodedInputStream input) throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input); - } - - public static com.google.cloud.iot.v1.DeleteDeviceRegistryRequest parseFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3.parseWithIOException( - PARSER, input, extensionRegistry); - } - - @java.lang.Override - public Builder newBuilderForType() { - return newBuilder(); - } - - public static Builder newBuilder() { - return DEFAULT_INSTANCE.toBuilder(); - } - - public static Builder newBuilder(com.google.cloud.iot.v1.DeleteDeviceRegistryRequest prototype) { - return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); - } - - @java.lang.Override - public Builder toBuilder() { - return this == DEFAULT_INSTANCE ? new Builder() : new Builder().mergeFrom(this); - } - - @java.lang.Override - protected Builder newBuilderForType(com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { - Builder builder = new Builder(parent); - return builder; - } - /** - * - * - *
-   * Request for `DeleteDeviceRegistry`.
-   * 
- * - * Protobuf type {@code google.cloud.iot.v1.DeleteDeviceRegistryRequest} - */ - public static final class Builder extends com.google.protobuf.GeneratedMessageV3.Builder - implements - // @@protoc_insertion_point(builder_implements:google.cloud.iot.v1.DeleteDeviceRegistryRequest) - com.google.cloud.iot.v1.DeleteDeviceRegistryRequestOrBuilder { - public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { - return com.google.cloud.iot.v1.DeviceManagerProto - .internal_static_google_cloud_iot_v1_DeleteDeviceRegistryRequest_descriptor; - } - - @java.lang.Override - protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable - internalGetFieldAccessorTable() { - return com.google.cloud.iot.v1.DeviceManagerProto - .internal_static_google_cloud_iot_v1_DeleteDeviceRegistryRequest_fieldAccessorTable - .ensureFieldAccessorsInitialized( - com.google.cloud.iot.v1.DeleteDeviceRegistryRequest.class, - com.google.cloud.iot.v1.DeleteDeviceRegistryRequest.Builder.class); - } - - // Construct using com.google.cloud.iot.v1.DeleteDeviceRegistryRequest.newBuilder() - private Builder() {} - - private Builder(com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { - super(parent); - } - - @java.lang.Override - public Builder clear() { - super.clear(); - name_ = ""; - - return this; - } - - @java.lang.Override - public com.google.protobuf.Descriptors.Descriptor getDescriptorForType() { - return com.google.cloud.iot.v1.DeviceManagerProto - .internal_static_google_cloud_iot_v1_DeleteDeviceRegistryRequest_descriptor; - } - - @java.lang.Override - public com.google.cloud.iot.v1.DeleteDeviceRegistryRequest getDefaultInstanceForType() { - return com.google.cloud.iot.v1.DeleteDeviceRegistryRequest.getDefaultInstance(); - } - - @java.lang.Override - public com.google.cloud.iot.v1.DeleteDeviceRegistryRequest build() { - com.google.cloud.iot.v1.DeleteDeviceRegistryRequest result = buildPartial(); - if (!result.isInitialized()) { - throw newUninitializedMessageException(result); - } - return result; - } - - @java.lang.Override - public com.google.cloud.iot.v1.DeleteDeviceRegistryRequest buildPartial() { - com.google.cloud.iot.v1.DeleteDeviceRegistryRequest result = - new com.google.cloud.iot.v1.DeleteDeviceRegistryRequest(this); - result.name_ = name_; - onBuilt(); - return result; - } - - @java.lang.Override - public Builder clone() { - return super.clone(); - } - - @java.lang.Override - public Builder setField( - com.google.protobuf.Descriptors.FieldDescriptor field, java.lang.Object value) { - return super.setField(field, value); - } - - @java.lang.Override - public Builder clearField(com.google.protobuf.Descriptors.FieldDescriptor field) { - return super.clearField(field); - } - - @java.lang.Override - public Builder clearOneof(com.google.protobuf.Descriptors.OneofDescriptor oneof) { - return super.clearOneof(oneof); - } - - @java.lang.Override - public Builder setRepeatedField( - com.google.protobuf.Descriptors.FieldDescriptor field, int index, java.lang.Object value) { - return super.setRepeatedField(field, index, value); - } - - @java.lang.Override - public Builder addRepeatedField( - com.google.protobuf.Descriptors.FieldDescriptor field, java.lang.Object value) { - return super.addRepeatedField(field, value); - } - - @java.lang.Override - public Builder mergeFrom(com.google.protobuf.Message other) { - if (other instanceof com.google.cloud.iot.v1.DeleteDeviceRegistryRequest) { - return mergeFrom((com.google.cloud.iot.v1.DeleteDeviceRegistryRequest) other); - } else { - super.mergeFrom(other); - return this; - } - } - - public Builder mergeFrom(com.google.cloud.iot.v1.DeleteDeviceRegistryRequest other) { - if (other == com.google.cloud.iot.v1.DeleteDeviceRegistryRequest.getDefaultInstance()) - return this; - if (!other.getName().isEmpty()) { - name_ = other.name_; - onChanged(); - } - this.mergeUnknownFields(other.getUnknownFields()); - onChanged(); - return this; - } - - @java.lang.Override - public final boolean isInitialized() { - return true; - } - - @java.lang.Override - public Builder mergeFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - if (extensionRegistry == null) { - throw new java.lang.NullPointerException(); - } - try { - boolean done = false; - while (!done) { - int tag = input.readTag(); - switch (tag) { - case 0: - done = true; - break; - case 10: - { - name_ = input.readStringRequireUtf8(); - - break; - } // case 10 - default: - { - if (!super.parseUnknownField(input, extensionRegistry, tag)) { - done = true; // was an endgroup tag - } - break; - } // default: - } // switch (tag) - } // while (!done) - } catch (com.google.protobuf.InvalidProtocolBufferException e) { - throw e.unwrapIOException(); - } finally { - onChanged(); - } // finally - return this; - } - - private java.lang.Object name_ = ""; - /** - * - * - *
-     * Required. The name of the device registry. For example,
-     * `projects/example-project/locations/us-central1/registries/my-registry`.
-     * 
- * - * - * string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } - * - * - * @return The name. - */ - public java.lang.String getName() { - java.lang.Object ref = name_; - if (!(ref instanceof java.lang.String)) { - com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; - java.lang.String s = bs.toStringUtf8(); - name_ = s; - return s; - } else { - return (java.lang.String) ref; - } - } - /** - * - * - *
-     * Required. The name of the device registry. For example,
-     * `projects/example-project/locations/us-central1/registries/my-registry`.
-     * 
- * - * - * string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } - * - * - * @return The bytes for name. - */ - public com.google.protobuf.ByteString getNameBytes() { - java.lang.Object ref = name_; - if (ref instanceof String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); - name_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - /** - * - * - *
-     * Required. The name of the device registry. For example,
-     * `projects/example-project/locations/us-central1/registries/my-registry`.
-     * 
- * - * - * string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } - * - * - * @param value The name to set. - * @return This builder for chaining. - */ - public Builder setName(java.lang.String value) { - if (value == null) { - throw new NullPointerException(); - } - - name_ = value; - onChanged(); - return this; - } - /** - * - * - *
-     * Required. The name of the device registry. For example,
-     * `projects/example-project/locations/us-central1/registries/my-registry`.
-     * 
- * - * - * string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } - * - * - * @return This builder for chaining. - */ - public Builder clearName() { - - name_ = getDefaultInstance().getName(); - onChanged(); - return this; - } - /** - * - * - *
-     * Required. The name of the device registry. For example,
-     * `projects/example-project/locations/us-central1/registries/my-registry`.
-     * 
- * - * - * string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } - * - * - * @param value The bytes for name to set. - * @return This builder for chaining. - */ - public Builder setNameBytes(com.google.protobuf.ByteString value) { - if (value == null) { - throw new NullPointerException(); - } - checkByteStringIsUtf8(value); - - name_ = value; - onChanged(); - return this; - } - - @java.lang.Override - public final Builder setUnknownFields(final com.google.protobuf.UnknownFieldSet unknownFields) { - return super.setUnknownFields(unknownFields); - } - - @java.lang.Override - public final Builder mergeUnknownFields( - final com.google.protobuf.UnknownFieldSet unknownFields) { - return super.mergeUnknownFields(unknownFields); - } - - // @@protoc_insertion_point(builder_scope:google.cloud.iot.v1.DeleteDeviceRegistryRequest) - } - - // @@protoc_insertion_point(class_scope:google.cloud.iot.v1.DeleteDeviceRegistryRequest) - private static final com.google.cloud.iot.v1.DeleteDeviceRegistryRequest DEFAULT_INSTANCE; - - static { - DEFAULT_INSTANCE = new com.google.cloud.iot.v1.DeleteDeviceRegistryRequest(); - } - - public static com.google.cloud.iot.v1.DeleteDeviceRegistryRequest getDefaultInstance() { - return DEFAULT_INSTANCE; - } - - private static final com.google.protobuf.Parser PARSER = - new com.google.protobuf.AbstractParser() { - @java.lang.Override - public DeleteDeviceRegistryRequest parsePartialFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - Builder builder = newBuilder(); - try { - builder.mergeFrom(input, extensionRegistry); - } catch (com.google.protobuf.InvalidProtocolBufferException e) { - throw e.setUnfinishedMessage(builder.buildPartial()); - } catch (com.google.protobuf.UninitializedMessageException e) { - throw e.asInvalidProtocolBufferException().setUnfinishedMessage(builder.buildPartial()); - } catch (java.io.IOException e) { - throw new com.google.protobuf.InvalidProtocolBufferException(e) - .setUnfinishedMessage(builder.buildPartial()); - } - return builder.buildPartial(); - } - }; - - public static com.google.protobuf.Parser parser() { - return PARSER; - } - - @java.lang.Override - public com.google.protobuf.Parser getParserForType() { - return PARSER; - } - - @java.lang.Override - public com.google.cloud.iot.v1.DeleteDeviceRegistryRequest getDefaultInstanceForType() { - return DEFAULT_INSTANCE; - } -} diff --git a/proto-google-cloud-iot-v1/src/main/java/com/google/cloud/iot/v1/DeleteDeviceRegistryRequestOrBuilder.java b/proto-google-cloud-iot-v1/src/main/java/com/google/cloud/iot/v1/DeleteDeviceRegistryRequestOrBuilder.java deleted file mode 100644 index 17946cf9..00000000 --- a/proto-google-cloud-iot-v1/src/main/java/com/google/cloud/iot/v1/DeleteDeviceRegistryRequestOrBuilder.java +++ /dev/null @@ -1,56 +0,0 @@ -/* - * Copyright 2020 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. - */ -// Generated by the protocol buffer compiler. DO NOT EDIT! -// source: google/cloud/iot/v1/device_manager.proto - -package com.google.cloud.iot.v1; - -public interface DeleteDeviceRegistryRequestOrBuilder - extends - // @@protoc_insertion_point(interface_extends:google.cloud.iot.v1.DeleteDeviceRegistryRequest) - com.google.protobuf.MessageOrBuilder { - - /** - * - * - *
-   * Required. The name of the device registry. For example,
-   * `projects/example-project/locations/us-central1/registries/my-registry`.
-   * 
- * - * - * string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } - * - * - * @return The name. - */ - java.lang.String getName(); - /** - * - * - *
-   * Required. The name of the device registry. For example,
-   * `projects/example-project/locations/us-central1/registries/my-registry`.
-   * 
- * - * - * string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } - * - * - * @return The bytes for name. - */ - com.google.protobuf.ByteString getNameBytes(); -} diff --git a/proto-google-cloud-iot-v1/src/main/java/com/google/cloud/iot/v1/DeleteDeviceRequest.java b/proto-google-cloud-iot-v1/src/main/java/com/google/cloud/iot/v1/DeleteDeviceRequest.java deleted file mode 100644 index 33a078fc..00000000 --- a/proto-google-cloud-iot-v1/src/main/java/com/google/cloud/iot/v1/DeleteDeviceRequest.java +++ /dev/null @@ -1,642 +0,0 @@ -/* - * Copyright 2020 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. - */ -// Generated by the protocol buffer compiler. DO NOT EDIT! -// source: google/cloud/iot/v1/device_manager.proto - -package com.google.cloud.iot.v1; - -/** - * - * - *
- * Request for `DeleteDevice`.
- * 
- * - * Protobuf type {@code google.cloud.iot.v1.DeleteDeviceRequest} - */ -public final class DeleteDeviceRequest extends com.google.protobuf.GeneratedMessageV3 - implements - // @@protoc_insertion_point(message_implements:google.cloud.iot.v1.DeleteDeviceRequest) - DeleteDeviceRequestOrBuilder { - private static final long serialVersionUID = 0L; - // Use DeleteDeviceRequest.newBuilder() to construct. - private DeleteDeviceRequest(com.google.protobuf.GeneratedMessageV3.Builder builder) { - super(builder); - } - - private DeleteDeviceRequest() { - name_ = ""; - } - - @java.lang.Override - @SuppressWarnings({"unused"}) - protected java.lang.Object newInstance(UnusedPrivateParameter unused) { - return new DeleteDeviceRequest(); - } - - @java.lang.Override - public final com.google.protobuf.UnknownFieldSet getUnknownFields() { - return this.unknownFields; - } - - public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { - return com.google.cloud.iot.v1.DeviceManagerProto - .internal_static_google_cloud_iot_v1_DeleteDeviceRequest_descriptor; - } - - @java.lang.Override - protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable - internalGetFieldAccessorTable() { - return com.google.cloud.iot.v1.DeviceManagerProto - .internal_static_google_cloud_iot_v1_DeleteDeviceRequest_fieldAccessorTable - .ensureFieldAccessorsInitialized( - com.google.cloud.iot.v1.DeleteDeviceRequest.class, - com.google.cloud.iot.v1.DeleteDeviceRequest.Builder.class); - } - - public static final int NAME_FIELD_NUMBER = 1; - private volatile java.lang.Object name_; - /** - * - * - *
-   * Required. The name of the device. For example,
-   * `projects/p0/locations/us-central1/registries/registry0/devices/device0` or
-   * `projects/p0/locations/us-central1/registries/registry0/devices/{num_id}`.
-   * 
- * - * - * string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } - * - * - * @return The name. - */ - @java.lang.Override - public java.lang.String getName() { - java.lang.Object ref = name_; - if (ref instanceof java.lang.String) { - return (java.lang.String) ref; - } else { - com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; - java.lang.String s = bs.toStringUtf8(); - name_ = s; - return s; - } - } - /** - * - * - *
-   * Required. The name of the device. For example,
-   * `projects/p0/locations/us-central1/registries/registry0/devices/device0` or
-   * `projects/p0/locations/us-central1/registries/registry0/devices/{num_id}`.
-   * 
- * - * - * string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } - * - * - * @return The bytes for name. - */ - @java.lang.Override - public com.google.protobuf.ByteString getNameBytes() { - java.lang.Object ref = name_; - if (ref instanceof java.lang.String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); - name_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - - private byte memoizedIsInitialized = -1; - - @java.lang.Override - public final boolean isInitialized() { - byte isInitialized = memoizedIsInitialized; - if (isInitialized == 1) return true; - if (isInitialized == 0) return false; - - memoizedIsInitialized = 1; - return true; - } - - @java.lang.Override - public void writeTo(com.google.protobuf.CodedOutputStream output) throws java.io.IOException { - if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(name_)) { - com.google.protobuf.GeneratedMessageV3.writeString(output, 1, name_); - } - getUnknownFields().writeTo(output); - } - - @java.lang.Override - public int getSerializedSize() { - int size = memoizedSize; - if (size != -1) return size; - - size = 0; - if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(name_)) { - size += com.google.protobuf.GeneratedMessageV3.computeStringSize(1, name_); - } - size += getUnknownFields().getSerializedSize(); - memoizedSize = size; - return size; - } - - @java.lang.Override - public boolean equals(final java.lang.Object obj) { - if (obj == this) { - return true; - } - if (!(obj instanceof com.google.cloud.iot.v1.DeleteDeviceRequest)) { - return super.equals(obj); - } - com.google.cloud.iot.v1.DeleteDeviceRequest other = - (com.google.cloud.iot.v1.DeleteDeviceRequest) obj; - - if (!getName().equals(other.getName())) return false; - if (!getUnknownFields().equals(other.getUnknownFields())) return false; - return true; - } - - @java.lang.Override - public int hashCode() { - if (memoizedHashCode != 0) { - return memoizedHashCode; - } - int hash = 41; - hash = (19 * hash) + getDescriptor().hashCode(); - hash = (37 * hash) + NAME_FIELD_NUMBER; - hash = (53 * hash) + getName().hashCode(); - hash = (29 * hash) + getUnknownFields().hashCode(); - memoizedHashCode = hash; - return hash; - } - - public static com.google.cloud.iot.v1.DeleteDeviceRequest parseFrom(java.nio.ByteBuffer data) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); - } - - public static com.google.cloud.iot.v1.DeleteDeviceRequest parseFrom( - java.nio.ByteBuffer data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); - } - - public static com.google.cloud.iot.v1.DeleteDeviceRequest parseFrom( - com.google.protobuf.ByteString data) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); - } - - public static com.google.cloud.iot.v1.DeleteDeviceRequest parseFrom( - com.google.protobuf.ByteString data, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); - } - - public static com.google.cloud.iot.v1.DeleteDeviceRequest parseFrom(byte[] data) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); - } - - public static com.google.cloud.iot.v1.DeleteDeviceRequest parseFrom( - byte[] data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); - } - - public static com.google.cloud.iot.v1.DeleteDeviceRequest parseFrom(java.io.InputStream input) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input); - } - - public static com.google.cloud.iot.v1.DeleteDeviceRequest parseFrom( - java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3.parseWithIOException( - PARSER, input, extensionRegistry); - } - - public static com.google.cloud.iot.v1.DeleteDeviceRequest parseDelimitedFrom( - java.io.InputStream input) throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3.parseDelimitedWithIOException(PARSER, input); - } - - public static com.google.cloud.iot.v1.DeleteDeviceRequest parseDelimitedFrom( - java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3.parseDelimitedWithIOException( - PARSER, input, extensionRegistry); - } - - public static com.google.cloud.iot.v1.DeleteDeviceRequest parseFrom( - com.google.protobuf.CodedInputStream input) throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input); - } - - public static com.google.cloud.iot.v1.DeleteDeviceRequest parseFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3.parseWithIOException( - PARSER, input, extensionRegistry); - } - - @java.lang.Override - public Builder newBuilderForType() { - return newBuilder(); - } - - public static Builder newBuilder() { - return DEFAULT_INSTANCE.toBuilder(); - } - - public static Builder newBuilder(com.google.cloud.iot.v1.DeleteDeviceRequest prototype) { - return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); - } - - @java.lang.Override - public Builder toBuilder() { - return this == DEFAULT_INSTANCE ? new Builder() : new Builder().mergeFrom(this); - } - - @java.lang.Override - protected Builder newBuilderForType(com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { - Builder builder = new Builder(parent); - return builder; - } - /** - * - * - *
-   * Request for `DeleteDevice`.
-   * 
- * - * Protobuf type {@code google.cloud.iot.v1.DeleteDeviceRequest} - */ - public static final class Builder extends com.google.protobuf.GeneratedMessageV3.Builder - implements - // @@protoc_insertion_point(builder_implements:google.cloud.iot.v1.DeleteDeviceRequest) - com.google.cloud.iot.v1.DeleteDeviceRequestOrBuilder { - public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { - return com.google.cloud.iot.v1.DeviceManagerProto - .internal_static_google_cloud_iot_v1_DeleteDeviceRequest_descriptor; - } - - @java.lang.Override - protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable - internalGetFieldAccessorTable() { - return com.google.cloud.iot.v1.DeviceManagerProto - .internal_static_google_cloud_iot_v1_DeleteDeviceRequest_fieldAccessorTable - .ensureFieldAccessorsInitialized( - com.google.cloud.iot.v1.DeleteDeviceRequest.class, - com.google.cloud.iot.v1.DeleteDeviceRequest.Builder.class); - } - - // Construct using com.google.cloud.iot.v1.DeleteDeviceRequest.newBuilder() - private Builder() {} - - private Builder(com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { - super(parent); - } - - @java.lang.Override - public Builder clear() { - super.clear(); - name_ = ""; - - return this; - } - - @java.lang.Override - public com.google.protobuf.Descriptors.Descriptor getDescriptorForType() { - return com.google.cloud.iot.v1.DeviceManagerProto - .internal_static_google_cloud_iot_v1_DeleteDeviceRequest_descriptor; - } - - @java.lang.Override - public com.google.cloud.iot.v1.DeleteDeviceRequest getDefaultInstanceForType() { - return com.google.cloud.iot.v1.DeleteDeviceRequest.getDefaultInstance(); - } - - @java.lang.Override - public com.google.cloud.iot.v1.DeleteDeviceRequest build() { - com.google.cloud.iot.v1.DeleteDeviceRequest result = buildPartial(); - if (!result.isInitialized()) { - throw newUninitializedMessageException(result); - } - return result; - } - - @java.lang.Override - public com.google.cloud.iot.v1.DeleteDeviceRequest buildPartial() { - com.google.cloud.iot.v1.DeleteDeviceRequest result = - new com.google.cloud.iot.v1.DeleteDeviceRequest(this); - result.name_ = name_; - onBuilt(); - return result; - } - - @java.lang.Override - public Builder clone() { - return super.clone(); - } - - @java.lang.Override - public Builder setField( - com.google.protobuf.Descriptors.FieldDescriptor field, java.lang.Object value) { - return super.setField(field, value); - } - - @java.lang.Override - public Builder clearField(com.google.protobuf.Descriptors.FieldDescriptor field) { - return super.clearField(field); - } - - @java.lang.Override - public Builder clearOneof(com.google.protobuf.Descriptors.OneofDescriptor oneof) { - return super.clearOneof(oneof); - } - - @java.lang.Override - public Builder setRepeatedField( - com.google.protobuf.Descriptors.FieldDescriptor field, int index, java.lang.Object value) { - return super.setRepeatedField(field, index, value); - } - - @java.lang.Override - public Builder addRepeatedField( - com.google.protobuf.Descriptors.FieldDescriptor field, java.lang.Object value) { - return super.addRepeatedField(field, value); - } - - @java.lang.Override - public Builder mergeFrom(com.google.protobuf.Message other) { - if (other instanceof com.google.cloud.iot.v1.DeleteDeviceRequest) { - return mergeFrom((com.google.cloud.iot.v1.DeleteDeviceRequest) other); - } else { - super.mergeFrom(other); - return this; - } - } - - public Builder mergeFrom(com.google.cloud.iot.v1.DeleteDeviceRequest other) { - if (other == com.google.cloud.iot.v1.DeleteDeviceRequest.getDefaultInstance()) return this; - if (!other.getName().isEmpty()) { - name_ = other.name_; - onChanged(); - } - this.mergeUnknownFields(other.getUnknownFields()); - onChanged(); - return this; - } - - @java.lang.Override - public final boolean isInitialized() { - return true; - } - - @java.lang.Override - public Builder mergeFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - if (extensionRegistry == null) { - throw new java.lang.NullPointerException(); - } - try { - boolean done = false; - while (!done) { - int tag = input.readTag(); - switch (tag) { - case 0: - done = true; - break; - case 10: - { - name_ = input.readStringRequireUtf8(); - - break; - } // case 10 - default: - { - if (!super.parseUnknownField(input, extensionRegistry, tag)) { - done = true; // was an endgroup tag - } - break; - } // default: - } // switch (tag) - } // while (!done) - } catch (com.google.protobuf.InvalidProtocolBufferException e) { - throw e.unwrapIOException(); - } finally { - onChanged(); - } // finally - return this; - } - - private java.lang.Object name_ = ""; - /** - * - * - *
-     * Required. The name of the device. For example,
-     * `projects/p0/locations/us-central1/registries/registry0/devices/device0` or
-     * `projects/p0/locations/us-central1/registries/registry0/devices/{num_id}`.
-     * 
- * - * - * string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } - * - * - * @return The name. - */ - public java.lang.String getName() { - java.lang.Object ref = name_; - if (!(ref instanceof java.lang.String)) { - com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; - java.lang.String s = bs.toStringUtf8(); - name_ = s; - return s; - } else { - return (java.lang.String) ref; - } - } - /** - * - * - *
-     * Required. The name of the device. For example,
-     * `projects/p0/locations/us-central1/registries/registry0/devices/device0` or
-     * `projects/p0/locations/us-central1/registries/registry0/devices/{num_id}`.
-     * 
- * - * - * string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } - * - * - * @return The bytes for name. - */ - public com.google.protobuf.ByteString getNameBytes() { - java.lang.Object ref = name_; - if (ref instanceof String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); - name_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - /** - * - * - *
-     * Required. The name of the device. For example,
-     * `projects/p0/locations/us-central1/registries/registry0/devices/device0` or
-     * `projects/p0/locations/us-central1/registries/registry0/devices/{num_id}`.
-     * 
- * - * - * string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } - * - * - * @param value The name to set. - * @return This builder for chaining. - */ - public Builder setName(java.lang.String value) { - if (value == null) { - throw new NullPointerException(); - } - - name_ = value; - onChanged(); - return this; - } - /** - * - * - *
-     * Required. The name of the device. For example,
-     * `projects/p0/locations/us-central1/registries/registry0/devices/device0` or
-     * `projects/p0/locations/us-central1/registries/registry0/devices/{num_id}`.
-     * 
- * - * - * string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } - * - * - * @return This builder for chaining. - */ - public Builder clearName() { - - name_ = getDefaultInstance().getName(); - onChanged(); - return this; - } - /** - * - * - *
-     * Required. The name of the device. For example,
-     * `projects/p0/locations/us-central1/registries/registry0/devices/device0` or
-     * `projects/p0/locations/us-central1/registries/registry0/devices/{num_id}`.
-     * 
- * - * - * string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } - * - * - * @param value The bytes for name to set. - * @return This builder for chaining. - */ - public Builder setNameBytes(com.google.protobuf.ByteString value) { - if (value == null) { - throw new NullPointerException(); - } - checkByteStringIsUtf8(value); - - name_ = value; - onChanged(); - return this; - } - - @java.lang.Override - public final Builder setUnknownFields(final com.google.protobuf.UnknownFieldSet unknownFields) { - return super.setUnknownFields(unknownFields); - } - - @java.lang.Override - public final Builder mergeUnknownFields( - final com.google.protobuf.UnknownFieldSet unknownFields) { - return super.mergeUnknownFields(unknownFields); - } - - // @@protoc_insertion_point(builder_scope:google.cloud.iot.v1.DeleteDeviceRequest) - } - - // @@protoc_insertion_point(class_scope:google.cloud.iot.v1.DeleteDeviceRequest) - private static final com.google.cloud.iot.v1.DeleteDeviceRequest DEFAULT_INSTANCE; - - static { - DEFAULT_INSTANCE = new com.google.cloud.iot.v1.DeleteDeviceRequest(); - } - - public static com.google.cloud.iot.v1.DeleteDeviceRequest getDefaultInstance() { - return DEFAULT_INSTANCE; - } - - private static final com.google.protobuf.Parser PARSER = - new com.google.protobuf.AbstractParser() { - @java.lang.Override - public DeleteDeviceRequest parsePartialFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - Builder builder = newBuilder(); - try { - builder.mergeFrom(input, extensionRegistry); - } catch (com.google.protobuf.InvalidProtocolBufferException e) { - throw e.setUnfinishedMessage(builder.buildPartial()); - } catch (com.google.protobuf.UninitializedMessageException e) { - throw e.asInvalidProtocolBufferException().setUnfinishedMessage(builder.buildPartial()); - } catch (java.io.IOException e) { - throw new com.google.protobuf.InvalidProtocolBufferException(e) - .setUnfinishedMessage(builder.buildPartial()); - } - return builder.buildPartial(); - } - }; - - public static com.google.protobuf.Parser parser() { - return PARSER; - } - - @java.lang.Override - public com.google.protobuf.Parser getParserForType() { - return PARSER; - } - - @java.lang.Override - public com.google.cloud.iot.v1.DeleteDeviceRequest getDefaultInstanceForType() { - return DEFAULT_INSTANCE; - } -} diff --git a/proto-google-cloud-iot-v1/src/main/java/com/google/cloud/iot/v1/DeleteDeviceRequestOrBuilder.java b/proto-google-cloud-iot-v1/src/main/java/com/google/cloud/iot/v1/DeleteDeviceRequestOrBuilder.java deleted file mode 100644 index 86313705..00000000 --- a/proto-google-cloud-iot-v1/src/main/java/com/google/cloud/iot/v1/DeleteDeviceRequestOrBuilder.java +++ /dev/null @@ -1,58 +0,0 @@ -/* - * Copyright 2020 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. - */ -// Generated by the protocol buffer compiler. DO NOT EDIT! -// source: google/cloud/iot/v1/device_manager.proto - -package com.google.cloud.iot.v1; - -public interface DeleteDeviceRequestOrBuilder - extends - // @@protoc_insertion_point(interface_extends:google.cloud.iot.v1.DeleteDeviceRequest) - com.google.protobuf.MessageOrBuilder { - - /** - * - * - *
-   * Required. The name of the device. For example,
-   * `projects/p0/locations/us-central1/registries/registry0/devices/device0` or
-   * `projects/p0/locations/us-central1/registries/registry0/devices/{num_id}`.
-   * 
- * - * - * string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } - * - * - * @return The name. - */ - java.lang.String getName(); - /** - * - * - *
-   * Required. The name of the device. For example,
-   * `projects/p0/locations/us-central1/registries/registry0/devices/device0` or
-   * `projects/p0/locations/us-central1/registries/registry0/devices/{num_id}`.
-   * 
- * - * - * string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } - * - * - * @return The bytes for name. - */ - com.google.protobuf.ByteString getNameBytes(); -} diff --git a/proto-google-cloud-iot-v1/src/main/java/com/google/cloud/iot/v1/Device.java b/proto-google-cloud-iot-v1/src/main/java/com/google/cloud/iot/v1/Device.java deleted file mode 100644 index 1d37e7c2..00000000 --- a/proto-google-cloud-iot-v1/src/main/java/com/google/cloud/iot/v1/Device.java +++ /dev/null @@ -1,5113 +0,0 @@ -/* - * Copyright 2020 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. - */ -// Generated by the protocol buffer compiler. DO NOT EDIT! -// source: google/cloud/iot/v1/resources.proto - -package com.google.cloud.iot.v1; - -/** - * - * - *
- * The device resource.
- * 
- * - * Protobuf type {@code google.cloud.iot.v1.Device} - */ -public final class Device extends com.google.protobuf.GeneratedMessageV3 - implements - // @@protoc_insertion_point(message_implements:google.cloud.iot.v1.Device) - DeviceOrBuilder { - private static final long serialVersionUID = 0L; - // Use Device.newBuilder() to construct. - private Device(com.google.protobuf.GeneratedMessageV3.Builder builder) { - super(builder); - } - - private Device() { - id_ = ""; - name_ = ""; - credentials_ = java.util.Collections.emptyList(); - logLevel_ = 0; - } - - @java.lang.Override - @SuppressWarnings({"unused"}) - protected java.lang.Object newInstance(UnusedPrivateParameter unused) { - return new Device(); - } - - @java.lang.Override - public final com.google.protobuf.UnknownFieldSet getUnknownFields() { - return this.unknownFields; - } - - public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { - return com.google.cloud.iot.v1.ResourcesProto - .internal_static_google_cloud_iot_v1_Device_descriptor; - } - - @SuppressWarnings({"rawtypes"}) - @java.lang.Override - protected com.google.protobuf.MapField internalGetMapField(int number) { - switch (number) { - case 17: - return internalGetMetadata(); - default: - throw new RuntimeException("Invalid map field number: " + number); - } - } - - @java.lang.Override - protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable - internalGetFieldAccessorTable() { - return com.google.cloud.iot.v1.ResourcesProto - .internal_static_google_cloud_iot_v1_Device_fieldAccessorTable - .ensureFieldAccessorsInitialized( - com.google.cloud.iot.v1.Device.class, com.google.cloud.iot.v1.Device.Builder.class); - } - - public static final int ID_FIELD_NUMBER = 1; - private volatile java.lang.Object id_; - /** - * - * - *
-   * The user-defined device identifier. The device ID must be unique
-   * within a device registry.
-   * 
- * - * string id = 1; - * - * @return The id. - */ - @java.lang.Override - public java.lang.String getId() { - java.lang.Object ref = id_; - if (ref instanceof java.lang.String) { - return (java.lang.String) ref; - } else { - com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; - java.lang.String s = bs.toStringUtf8(); - id_ = s; - return s; - } - } - /** - * - * - *
-   * The user-defined device identifier. The device ID must be unique
-   * within a device registry.
-   * 
- * - * string id = 1; - * - * @return The bytes for id. - */ - @java.lang.Override - public com.google.protobuf.ByteString getIdBytes() { - java.lang.Object ref = id_; - if (ref instanceof java.lang.String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); - id_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - - public static final int NAME_FIELD_NUMBER = 2; - private volatile java.lang.Object name_; - /** - * - * - *
-   * The resource path name. For example,
-   * `projects/p1/locations/us-central1/registries/registry0/devices/dev0` or
-   * `projects/p1/locations/us-central1/registries/registry0/devices/{num_id}`.
-   * When `name` is populated as a response from the service, it always ends
-   * in the device numeric ID.
-   * 
- * - * string name = 2; - * - * @return The name. - */ - @java.lang.Override - public java.lang.String getName() { - java.lang.Object ref = name_; - if (ref instanceof java.lang.String) { - return (java.lang.String) ref; - } else { - com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; - java.lang.String s = bs.toStringUtf8(); - name_ = s; - return s; - } - } - /** - * - * - *
-   * The resource path name. For example,
-   * `projects/p1/locations/us-central1/registries/registry0/devices/dev0` or
-   * `projects/p1/locations/us-central1/registries/registry0/devices/{num_id}`.
-   * When `name` is populated as a response from the service, it always ends
-   * in the device numeric ID.
-   * 
- * - * string name = 2; - * - * @return The bytes for name. - */ - @java.lang.Override - public com.google.protobuf.ByteString getNameBytes() { - java.lang.Object ref = name_; - if (ref instanceof java.lang.String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); - name_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - - public static final int NUM_ID_FIELD_NUMBER = 3; - private long numId_; - /** - * - * - *
-   * [Output only] A server-defined unique numeric ID for the device. This is a
-   * more compact way to identify devices, and it is globally unique.
-   * 
- * - * uint64 num_id = 3; - * - * @return The numId. - */ - @java.lang.Override - public long getNumId() { - return numId_; - } - - public static final int CREDENTIALS_FIELD_NUMBER = 12; - private java.util.List credentials_; - /** - * - * - *
-   * The credentials used to authenticate this device. To allow credential
-   * rotation without interruption, multiple device credentials can be bound to
-   * this device. No more than 3 credentials can be bound to a single device at
-   * a time. When new credentials are added to a device, they are verified
-   * against the registry credentials. For details, see the description of the
-   * `DeviceRegistry.credentials` field.
-   * 
- * - * repeated .google.cloud.iot.v1.DeviceCredential credentials = 12; - */ - @java.lang.Override - public java.util.List getCredentialsList() { - return credentials_; - } - /** - * - * - *
-   * The credentials used to authenticate this device. To allow credential
-   * rotation without interruption, multiple device credentials can be bound to
-   * this device. No more than 3 credentials can be bound to a single device at
-   * a time. When new credentials are added to a device, they are verified
-   * against the registry credentials. For details, see the description of the
-   * `DeviceRegistry.credentials` field.
-   * 
- * - * repeated .google.cloud.iot.v1.DeviceCredential credentials = 12; - */ - @java.lang.Override - public java.util.List - getCredentialsOrBuilderList() { - return credentials_; - } - /** - * - * - *
-   * The credentials used to authenticate this device. To allow credential
-   * rotation without interruption, multiple device credentials can be bound to
-   * this device. No more than 3 credentials can be bound to a single device at
-   * a time. When new credentials are added to a device, they are verified
-   * against the registry credentials. For details, see the description of the
-   * `DeviceRegistry.credentials` field.
-   * 
- * - * repeated .google.cloud.iot.v1.DeviceCredential credentials = 12; - */ - @java.lang.Override - public int getCredentialsCount() { - return credentials_.size(); - } - /** - * - * - *
-   * The credentials used to authenticate this device. To allow credential
-   * rotation without interruption, multiple device credentials can be bound to
-   * this device. No more than 3 credentials can be bound to a single device at
-   * a time. When new credentials are added to a device, they are verified
-   * against the registry credentials. For details, see the description of the
-   * `DeviceRegistry.credentials` field.
-   * 
- * - * repeated .google.cloud.iot.v1.DeviceCredential credentials = 12; - */ - @java.lang.Override - public com.google.cloud.iot.v1.DeviceCredential getCredentials(int index) { - return credentials_.get(index); - } - /** - * - * - *
-   * The credentials used to authenticate this device. To allow credential
-   * rotation without interruption, multiple device credentials can be bound to
-   * this device. No more than 3 credentials can be bound to a single device at
-   * a time. When new credentials are added to a device, they are verified
-   * against the registry credentials. For details, see the description of the
-   * `DeviceRegistry.credentials` field.
-   * 
- * - * repeated .google.cloud.iot.v1.DeviceCredential credentials = 12; - */ - @java.lang.Override - public com.google.cloud.iot.v1.DeviceCredentialOrBuilder getCredentialsOrBuilder(int index) { - return credentials_.get(index); - } - - public static final int LAST_HEARTBEAT_TIME_FIELD_NUMBER = 7; - private com.google.protobuf.Timestamp lastHeartbeatTime_; - /** - * - * - *
-   * [Output only] The last time an MQTT `PINGREQ` was received. This field
-   * applies only to devices connecting through MQTT. MQTT clients usually only
-   * send `PINGREQ` messages if the connection is idle, and no other messages
-   * have been sent. Timestamps are periodically collected and written to
-   * storage; they may be stale by a few minutes.
-   * 
- * - * .google.protobuf.Timestamp last_heartbeat_time = 7; - * - * @return Whether the lastHeartbeatTime field is set. - */ - @java.lang.Override - public boolean hasLastHeartbeatTime() { - return lastHeartbeatTime_ != null; - } - /** - * - * - *
-   * [Output only] The last time an MQTT `PINGREQ` was received. This field
-   * applies only to devices connecting through MQTT. MQTT clients usually only
-   * send `PINGREQ` messages if the connection is idle, and no other messages
-   * have been sent. Timestamps are periodically collected and written to
-   * storage; they may be stale by a few minutes.
-   * 
- * - * .google.protobuf.Timestamp last_heartbeat_time = 7; - * - * @return The lastHeartbeatTime. - */ - @java.lang.Override - public com.google.protobuf.Timestamp getLastHeartbeatTime() { - return lastHeartbeatTime_ == null - ? com.google.protobuf.Timestamp.getDefaultInstance() - : lastHeartbeatTime_; - } - /** - * - * - *
-   * [Output only] The last time an MQTT `PINGREQ` was received. This field
-   * applies only to devices connecting through MQTT. MQTT clients usually only
-   * send `PINGREQ` messages if the connection is idle, and no other messages
-   * have been sent. Timestamps are periodically collected and written to
-   * storage; they may be stale by a few minutes.
-   * 
- * - * .google.protobuf.Timestamp last_heartbeat_time = 7; - */ - @java.lang.Override - public com.google.protobuf.TimestampOrBuilder getLastHeartbeatTimeOrBuilder() { - return getLastHeartbeatTime(); - } - - public static final int LAST_EVENT_TIME_FIELD_NUMBER = 8; - private com.google.protobuf.Timestamp lastEventTime_; - /** - * - * - *
-   * [Output only] The last time a telemetry event was received. Timestamps are
-   * periodically collected and written to storage; they may be stale by a few
-   * minutes.
-   * 
- * - * .google.protobuf.Timestamp last_event_time = 8; - * - * @return Whether the lastEventTime field is set. - */ - @java.lang.Override - public boolean hasLastEventTime() { - return lastEventTime_ != null; - } - /** - * - * - *
-   * [Output only] The last time a telemetry event was received. Timestamps are
-   * periodically collected and written to storage; they may be stale by a few
-   * minutes.
-   * 
- * - * .google.protobuf.Timestamp last_event_time = 8; - * - * @return The lastEventTime. - */ - @java.lang.Override - public com.google.protobuf.Timestamp getLastEventTime() { - return lastEventTime_ == null - ? com.google.protobuf.Timestamp.getDefaultInstance() - : lastEventTime_; - } - /** - * - * - *
-   * [Output only] The last time a telemetry event was received. Timestamps are
-   * periodically collected and written to storage; they may be stale by a few
-   * minutes.
-   * 
- * - * .google.protobuf.Timestamp last_event_time = 8; - */ - @java.lang.Override - public com.google.protobuf.TimestampOrBuilder getLastEventTimeOrBuilder() { - return getLastEventTime(); - } - - public static final int LAST_STATE_TIME_FIELD_NUMBER = 20; - private com.google.protobuf.Timestamp lastStateTime_; - /** - * - * - *
-   * [Output only] The last time a state event was received. Timestamps are
-   * periodically collected and written to storage; they may be stale by a few
-   * minutes.
-   * 
- * - * .google.protobuf.Timestamp last_state_time = 20; - * - * @return Whether the lastStateTime field is set. - */ - @java.lang.Override - public boolean hasLastStateTime() { - return lastStateTime_ != null; - } - /** - * - * - *
-   * [Output only] The last time a state event was received. Timestamps are
-   * periodically collected and written to storage; they may be stale by a few
-   * minutes.
-   * 
- * - * .google.protobuf.Timestamp last_state_time = 20; - * - * @return The lastStateTime. - */ - @java.lang.Override - public com.google.protobuf.Timestamp getLastStateTime() { - return lastStateTime_ == null - ? com.google.protobuf.Timestamp.getDefaultInstance() - : lastStateTime_; - } - /** - * - * - *
-   * [Output only] The last time a state event was received. Timestamps are
-   * periodically collected and written to storage; they may be stale by a few
-   * minutes.
-   * 
- * - * .google.protobuf.Timestamp last_state_time = 20; - */ - @java.lang.Override - public com.google.protobuf.TimestampOrBuilder getLastStateTimeOrBuilder() { - return getLastStateTime(); - } - - public static final int LAST_CONFIG_ACK_TIME_FIELD_NUMBER = 14; - private com.google.protobuf.Timestamp lastConfigAckTime_; - /** - * - * - *
-   * [Output only] The last time a cloud-to-device config version acknowledgment
-   * was received from the device. This field is only for configurations
-   * sent through MQTT.
-   * 
- * - * .google.protobuf.Timestamp last_config_ack_time = 14; - * - * @return Whether the lastConfigAckTime field is set. - */ - @java.lang.Override - public boolean hasLastConfigAckTime() { - return lastConfigAckTime_ != null; - } - /** - * - * - *
-   * [Output only] The last time a cloud-to-device config version acknowledgment
-   * was received from the device. This field is only for configurations
-   * sent through MQTT.
-   * 
- * - * .google.protobuf.Timestamp last_config_ack_time = 14; - * - * @return The lastConfigAckTime. - */ - @java.lang.Override - public com.google.protobuf.Timestamp getLastConfigAckTime() { - return lastConfigAckTime_ == null - ? com.google.protobuf.Timestamp.getDefaultInstance() - : lastConfigAckTime_; - } - /** - * - * - *
-   * [Output only] The last time a cloud-to-device config version acknowledgment
-   * was received from the device. This field is only for configurations
-   * sent through MQTT.
-   * 
- * - * .google.protobuf.Timestamp last_config_ack_time = 14; - */ - @java.lang.Override - public com.google.protobuf.TimestampOrBuilder getLastConfigAckTimeOrBuilder() { - return getLastConfigAckTime(); - } - - public static final int LAST_CONFIG_SEND_TIME_FIELD_NUMBER = 18; - private com.google.protobuf.Timestamp lastConfigSendTime_; - /** - * - * - *
-   * [Output only] The last time a cloud-to-device config version was sent to
-   * the device.
-   * 
- * - * .google.protobuf.Timestamp last_config_send_time = 18; - * - * @return Whether the lastConfigSendTime field is set. - */ - @java.lang.Override - public boolean hasLastConfigSendTime() { - return lastConfigSendTime_ != null; - } - /** - * - * - *
-   * [Output only] The last time a cloud-to-device config version was sent to
-   * the device.
-   * 
- * - * .google.protobuf.Timestamp last_config_send_time = 18; - * - * @return The lastConfigSendTime. - */ - @java.lang.Override - public com.google.protobuf.Timestamp getLastConfigSendTime() { - return lastConfigSendTime_ == null - ? com.google.protobuf.Timestamp.getDefaultInstance() - : lastConfigSendTime_; - } - /** - * - * - *
-   * [Output only] The last time a cloud-to-device config version was sent to
-   * the device.
-   * 
- * - * .google.protobuf.Timestamp last_config_send_time = 18; - */ - @java.lang.Override - public com.google.protobuf.TimestampOrBuilder getLastConfigSendTimeOrBuilder() { - return getLastConfigSendTime(); - } - - public static final int BLOCKED_FIELD_NUMBER = 19; - private boolean blocked_; - /** - * - * - *
-   * If a device is blocked, connections or requests from this device will fail.
-   * Can be used to temporarily prevent the device from connecting if, for
-   * example, the sensor is generating bad data and needs maintenance.
-   * 
- * - * bool blocked = 19; - * - * @return The blocked. - */ - @java.lang.Override - public boolean getBlocked() { - return blocked_; - } - - public static final int LAST_ERROR_TIME_FIELD_NUMBER = 10; - private com.google.protobuf.Timestamp lastErrorTime_; - /** - * - * - *
-   * [Output only] The time the most recent error occurred, such as a failure to
-   * publish to Cloud Pub/Sub. This field is the timestamp of
-   * 'last_error_status'.
-   * 
- * - * .google.protobuf.Timestamp last_error_time = 10; - * - * @return Whether the lastErrorTime field is set. - */ - @java.lang.Override - public boolean hasLastErrorTime() { - return lastErrorTime_ != null; - } - /** - * - * - *
-   * [Output only] The time the most recent error occurred, such as a failure to
-   * publish to Cloud Pub/Sub. This field is the timestamp of
-   * 'last_error_status'.
-   * 
- * - * .google.protobuf.Timestamp last_error_time = 10; - * - * @return The lastErrorTime. - */ - @java.lang.Override - public com.google.protobuf.Timestamp getLastErrorTime() { - return lastErrorTime_ == null - ? com.google.protobuf.Timestamp.getDefaultInstance() - : lastErrorTime_; - } - /** - * - * - *
-   * [Output only] The time the most recent error occurred, such as a failure to
-   * publish to Cloud Pub/Sub. This field is the timestamp of
-   * 'last_error_status'.
-   * 
- * - * .google.protobuf.Timestamp last_error_time = 10; - */ - @java.lang.Override - public com.google.protobuf.TimestampOrBuilder getLastErrorTimeOrBuilder() { - return getLastErrorTime(); - } - - public static final int LAST_ERROR_STATUS_FIELD_NUMBER = 11; - private com.google.rpc.Status lastErrorStatus_; - /** - * - * - *
-   * [Output only] The error message of the most recent error, such as a failure
-   * to publish to Cloud Pub/Sub. 'last_error_time' is the timestamp of this
-   * field. If no errors have occurred, this field has an empty message
-   * and the status code 0 == OK. Otherwise, this field is expected to have a
-   * status code other than OK.
-   * 
- * - * .google.rpc.Status last_error_status = 11; - * - * @return Whether the lastErrorStatus field is set. - */ - @java.lang.Override - public boolean hasLastErrorStatus() { - return lastErrorStatus_ != null; - } - /** - * - * - *
-   * [Output only] The error message of the most recent error, such as a failure
-   * to publish to Cloud Pub/Sub. 'last_error_time' is the timestamp of this
-   * field. If no errors have occurred, this field has an empty message
-   * and the status code 0 == OK. Otherwise, this field is expected to have a
-   * status code other than OK.
-   * 
- * - * .google.rpc.Status last_error_status = 11; - * - * @return The lastErrorStatus. - */ - @java.lang.Override - public com.google.rpc.Status getLastErrorStatus() { - return lastErrorStatus_ == null ? com.google.rpc.Status.getDefaultInstance() : lastErrorStatus_; - } - /** - * - * - *
-   * [Output only] The error message of the most recent error, such as a failure
-   * to publish to Cloud Pub/Sub. 'last_error_time' is the timestamp of this
-   * field. If no errors have occurred, this field has an empty message
-   * and the status code 0 == OK. Otherwise, this field is expected to have a
-   * status code other than OK.
-   * 
- * - * .google.rpc.Status last_error_status = 11; - */ - @java.lang.Override - public com.google.rpc.StatusOrBuilder getLastErrorStatusOrBuilder() { - return getLastErrorStatus(); - } - - public static final int CONFIG_FIELD_NUMBER = 13; - private com.google.cloud.iot.v1.DeviceConfig config_; - /** - * - * - *
-   * The most recent device configuration, which is eventually sent from
-   * Cloud IoT Core to the device. If not present on creation, the
-   * configuration will be initialized with an empty payload and version value
-   * of `1`. To update this field after creation, use the
-   * `DeviceManager.ModifyCloudToDeviceConfig` method.
-   * 
- * - * .google.cloud.iot.v1.DeviceConfig config = 13; - * - * @return Whether the config field is set. - */ - @java.lang.Override - public boolean hasConfig() { - return config_ != null; - } - /** - * - * - *
-   * The most recent device configuration, which is eventually sent from
-   * Cloud IoT Core to the device. If not present on creation, the
-   * configuration will be initialized with an empty payload and version value
-   * of `1`. To update this field after creation, use the
-   * `DeviceManager.ModifyCloudToDeviceConfig` method.
-   * 
- * - * .google.cloud.iot.v1.DeviceConfig config = 13; - * - * @return The config. - */ - @java.lang.Override - public com.google.cloud.iot.v1.DeviceConfig getConfig() { - return config_ == null ? com.google.cloud.iot.v1.DeviceConfig.getDefaultInstance() : config_; - } - /** - * - * - *
-   * The most recent device configuration, which is eventually sent from
-   * Cloud IoT Core to the device. If not present on creation, the
-   * configuration will be initialized with an empty payload and version value
-   * of `1`. To update this field after creation, use the
-   * `DeviceManager.ModifyCloudToDeviceConfig` method.
-   * 
- * - * .google.cloud.iot.v1.DeviceConfig config = 13; - */ - @java.lang.Override - public com.google.cloud.iot.v1.DeviceConfigOrBuilder getConfigOrBuilder() { - return getConfig(); - } - - public static final int STATE_FIELD_NUMBER = 16; - private com.google.cloud.iot.v1.DeviceState state_; - /** - * - * - *
-   * [Output only] The state most recently received from the device. If no state
-   * has been reported, this field is not present.
-   * 
- * - * .google.cloud.iot.v1.DeviceState state = 16; - * - * @return Whether the state field is set. - */ - @java.lang.Override - public boolean hasState() { - return state_ != null; - } - /** - * - * - *
-   * [Output only] The state most recently received from the device. If no state
-   * has been reported, this field is not present.
-   * 
- * - * .google.cloud.iot.v1.DeviceState state = 16; - * - * @return The state. - */ - @java.lang.Override - public com.google.cloud.iot.v1.DeviceState getState() { - return state_ == null ? com.google.cloud.iot.v1.DeviceState.getDefaultInstance() : state_; - } - /** - * - * - *
-   * [Output only] The state most recently received from the device. If no state
-   * has been reported, this field is not present.
-   * 
- * - * .google.cloud.iot.v1.DeviceState state = 16; - */ - @java.lang.Override - public com.google.cloud.iot.v1.DeviceStateOrBuilder getStateOrBuilder() { - return getState(); - } - - public static final int LOG_LEVEL_FIELD_NUMBER = 21; - private int logLevel_; - /** - * - * - *
-   * **Beta Feature**
-   * The logging verbosity for device activity. If unspecified,
-   * DeviceRegistry.log_level will be used.
-   * 
- * - * .google.cloud.iot.v1.LogLevel log_level = 21; - * - * @return The enum numeric value on the wire for logLevel. - */ - @java.lang.Override - public int getLogLevelValue() { - return logLevel_; - } - /** - * - * - *
-   * **Beta Feature**
-   * The logging verbosity for device activity. If unspecified,
-   * DeviceRegistry.log_level will be used.
-   * 
- * - * .google.cloud.iot.v1.LogLevel log_level = 21; - * - * @return The logLevel. - */ - @java.lang.Override - public com.google.cloud.iot.v1.LogLevel getLogLevel() { - @SuppressWarnings("deprecation") - com.google.cloud.iot.v1.LogLevel result = com.google.cloud.iot.v1.LogLevel.valueOf(logLevel_); - return result == null ? com.google.cloud.iot.v1.LogLevel.UNRECOGNIZED : result; - } - - public static final int METADATA_FIELD_NUMBER = 17; - - private static final class MetadataDefaultEntryHolder { - static final com.google.protobuf.MapEntry defaultEntry = - com.google.protobuf.MapEntry.newDefaultInstance( - com.google.cloud.iot.v1.ResourcesProto - .internal_static_google_cloud_iot_v1_Device_MetadataEntry_descriptor, - com.google.protobuf.WireFormat.FieldType.STRING, - "", - com.google.protobuf.WireFormat.FieldType.STRING, - ""); - } - - private com.google.protobuf.MapField metadata_; - - private com.google.protobuf.MapField internalGetMetadata() { - if (metadata_ == null) { - return com.google.protobuf.MapField.emptyMapField(MetadataDefaultEntryHolder.defaultEntry); - } - return metadata_; - } - - public int getMetadataCount() { - return internalGetMetadata().getMap().size(); - } - /** - * - * - *
-   * The metadata key-value pairs assigned to the device. This metadata is not
-   * interpreted or indexed by Cloud IoT Core. It can be used to add contextual
-   * information for the device.
-   * Keys must conform to the regular expression [a-zA-Z][a-zA-Z0-9-_.+~%]+ and
-   * be less than 128 bytes in length.
-   * Values are free-form strings. Each value must be less than or equal to 32
-   * KB in size.
-   * The total size of all keys and values must be less than 256 KB, and the
-   * maximum number of key-value pairs is 500.
-   * 
- * - * map<string, string> metadata = 17; - */ - @java.lang.Override - public boolean containsMetadata(java.lang.String key) { - if (key == null) { - throw new NullPointerException("map key"); - } - return internalGetMetadata().getMap().containsKey(key); - } - /** Use {@link #getMetadataMap()} instead. */ - @java.lang.Override - @java.lang.Deprecated - public java.util.Map getMetadata() { - return getMetadataMap(); - } - /** - * - * - *
-   * The metadata key-value pairs assigned to the device. This metadata is not
-   * interpreted or indexed by Cloud IoT Core. It can be used to add contextual
-   * information for the device.
-   * Keys must conform to the regular expression [a-zA-Z][a-zA-Z0-9-_.+~%]+ and
-   * be less than 128 bytes in length.
-   * Values are free-form strings. Each value must be less than or equal to 32
-   * KB in size.
-   * The total size of all keys and values must be less than 256 KB, and the
-   * maximum number of key-value pairs is 500.
-   * 
- * - * map<string, string> metadata = 17; - */ - @java.lang.Override - public java.util.Map getMetadataMap() { - return internalGetMetadata().getMap(); - } - /** - * - * - *
-   * The metadata key-value pairs assigned to the device. This metadata is not
-   * interpreted or indexed by Cloud IoT Core. It can be used to add contextual
-   * information for the device.
-   * Keys must conform to the regular expression [a-zA-Z][a-zA-Z0-9-_.+~%]+ and
-   * be less than 128 bytes in length.
-   * Values are free-form strings. Each value must be less than or equal to 32
-   * KB in size.
-   * The total size of all keys and values must be less than 256 KB, and the
-   * maximum number of key-value pairs is 500.
-   * 
- * - * map<string, string> metadata = 17; - */ - @java.lang.Override - public java.lang.String getMetadataOrDefault( - java.lang.String key, java.lang.String defaultValue) { - if (key == null) { - throw new NullPointerException("map key"); - } - java.util.Map map = internalGetMetadata().getMap(); - return map.containsKey(key) ? map.get(key) : defaultValue; - } - /** - * - * - *
-   * The metadata key-value pairs assigned to the device. This metadata is not
-   * interpreted or indexed by Cloud IoT Core. It can be used to add contextual
-   * information for the device.
-   * Keys must conform to the regular expression [a-zA-Z][a-zA-Z0-9-_.+~%]+ and
-   * be less than 128 bytes in length.
-   * Values are free-form strings. Each value must be less than or equal to 32
-   * KB in size.
-   * The total size of all keys and values must be less than 256 KB, and the
-   * maximum number of key-value pairs is 500.
-   * 
- * - * map<string, string> metadata = 17; - */ - @java.lang.Override - public java.lang.String getMetadataOrThrow(java.lang.String key) { - if (key == null) { - throw new NullPointerException("map key"); - } - java.util.Map map = internalGetMetadata().getMap(); - if (!map.containsKey(key)) { - throw new java.lang.IllegalArgumentException(); - } - return map.get(key); - } - - public static final int GATEWAY_CONFIG_FIELD_NUMBER = 24; - private com.google.cloud.iot.v1.GatewayConfig gatewayConfig_; - /** - * - * - *
-   * Gateway-related configuration and state.
-   * 
- * - * .google.cloud.iot.v1.GatewayConfig gateway_config = 24; - * - * @return Whether the gatewayConfig field is set. - */ - @java.lang.Override - public boolean hasGatewayConfig() { - return gatewayConfig_ != null; - } - /** - * - * - *
-   * Gateway-related configuration and state.
-   * 
- * - * .google.cloud.iot.v1.GatewayConfig gateway_config = 24; - * - * @return The gatewayConfig. - */ - @java.lang.Override - public com.google.cloud.iot.v1.GatewayConfig getGatewayConfig() { - return gatewayConfig_ == null - ? com.google.cloud.iot.v1.GatewayConfig.getDefaultInstance() - : gatewayConfig_; - } - /** - * - * - *
-   * Gateway-related configuration and state.
-   * 
- * - * .google.cloud.iot.v1.GatewayConfig gateway_config = 24; - */ - @java.lang.Override - public com.google.cloud.iot.v1.GatewayConfigOrBuilder getGatewayConfigOrBuilder() { - return getGatewayConfig(); - } - - private byte memoizedIsInitialized = -1; - - @java.lang.Override - public final boolean isInitialized() { - byte isInitialized = memoizedIsInitialized; - if (isInitialized == 1) return true; - if (isInitialized == 0) return false; - - memoizedIsInitialized = 1; - return true; - } - - @java.lang.Override - public void writeTo(com.google.protobuf.CodedOutputStream output) throws java.io.IOException { - if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(id_)) { - com.google.protobuf.GeneratedMessageV3.writeString(output, 1, id_); - } - if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(name_)) { - com.google.protobuf.GeneratedMessageV3.writeString(output, 2, name_); - } - if (numId_ != 0L) { - output.writeUInt64(3, numId_); - } - if (lastHeartbeatTime_ != null) { - output.writeMessage(7, getLastHeartbeatTime()); - } - if (lastEventTime_ != null) { - output.writeMessage(8, getLastEventTime()); - } - if (lastErrorTime_ != null) { - output.writeMessage(10, getLastErrorTime()); - } - if (lastErrorStatus_ != null) { - output.writeMessage(11, getLastErrorStatus()); - } - for (int i = 0; i < credentials_.size(); i++) { - output.writeMessage(12, credentials_.get(i)); - } - if (config_ != null) { - output.writeMessage(13, getConfig()); - } - if (lastConfigAckTime_ != null) { - output.writeMessage(14, getLastConfigAckTime()); - } - if (state_ != null) { - output.writeMessage(16, getState()); - } - com.google.protobuf.GeneratedMessageV3.serializeStringMapTo( - output, internalGetMetadata(), MetadataDefaultEntryHolder.defaultEntry, 17); - if (lastConfigSendTime_ != null) { - output.writeMessage(18, getLastConfigSendTime()); - } - if (blocked_ != false) { - output.writeBool(19, blocked_); - } - if (lastStateTime_ != null) { - output.writeMessage(20, getLastStateTime()); - } - if (logLevel_ != com.google.cloud.iot.v1.LogLevel.LOG_LEVEL_UNSPECIFIED.getNumber()) { - output.writeEnum(21, logLevel_); - } - if (gatewayConfig_ != null) { - output.writeMessage(24, getGatewayConfig()); - } - getUnknownFields().writeTo(output); - } - - @java.lang.Override - public int getSerializedSize() { - int size = memoizedSize; - if (size != -1) return size; - - size = 0; - if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(id_)) { - size += com.google.protobuf.GeneratedMessageV3.computeStringSize(1, id_); - } - if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(name_)) { - size += com.google.protobuf.GeneratedMessageV3.computeStringSize(2, name_); - } - if (numId_ != 0L) { - size += com.google.protobuf.CodedOutputStream.computeUInt64Size(3, numId_); - } - if (lastHeartbeatTime_ != null) { - size += com.google.protobuf.CodedOutputStream.computeMessageSize(7, getLastHeartbeatTime()); - } - if (lastEventTime_ != null) { - size += com.google.protobuf.CodedOutputStream.computeMessageSize(8, getLastEventTime()); - } - if (lastErrorTime_ != null) { - size += com.google.protobuf.CodedOutputStream.computeMessageSize(10, getLastErrorTime()); - } - if (lastErrorStatus_ != null) { - size += com.google.protobuf.CodedOutputStream.computeMessageSize(11, getLastErrorStatus()); - } - for (int i = 0; i < credentials_.size(); i++) { - size += com.google.protobuf.CodedOutputStream.computeMessageSize(12, credentials_.get(i)); - } - if (config_ != null) { - size += com.google.protobuf.CodedOutputStream.computeMessageSize(13, getConfig()); - } - if (lastConfigAckTime_ != null) { - size += com.google.protobuf.CodedOutputStream.computeMessageSize(14, getLastConfigAckTime()); - } - if (state_ != null) { - size += com.google.protobuf.CodedOutputStream.computeMessageSize(16, getState()); - } - for (java.util.Map.Entry entry : - internalGetMetadata().getMap().entrySet()) { - com.google.protobuf.MapEntry metadata__ = - MetadataDefaultEntryHolder.defaultEntry - .newBuilderForType() - .setKey(entry.getKey()) - .setValue(entry.getValue()) - .build(); - size += com.google.protobuf.CodedOutputStream.computeMessageSize(17, metadata__); - } - if (lastConfigSendTime_ != null) { - size += com.google.protobuf.CodedOutputStream.computeMessageSize(18, getLastConfigSendTime()); - } - if (blocked_ != false) { - size += com.google.protobuf.CodedOutputStream.computeBoolSize(19, blocked_); - } - if (lastStateTime_ != null) { - size += com.google.protobuf.CodedOutputStream.computeMessageSize(20, getLastStateTime()); - } - if (logLevel_ != com.google.cloud.iot.v1.LogLevel.LOG_LEVEL_UNSPECIFIED.getNumber()) { - size += com.google.protobuf.CodedOutputStream.computeEnumSize(21, logLevel_); - } - if (gatewayConfig_ != null) { - size += com.google.protobuf.CodedOutputStream.computeMessageSize(24, getGatewayConfig()); - } - size += getUnknownFields().getSerializedSize(); - memoizedSize = size; - return size; - } - - @java.lang.Override - public boolean equals(final java.lang.Object obj) { - if (obj == this) { - return true; - } - if (!(obj instanceof com.google.cloud.iot.v1.Device)) { - return super.equals(obj); - } - com.google.cloud.iot.v1.Device other = (com.google.cloud.iot.v1.Device) obj; - - if (!getId().equals(other.getId())) return false; - if (!getName().equals(other.getName())) return false; - if (getNumId() != other.getNumId()) return false; - if (!getCredentialsList().equals(other.getCredentialsList())) return false; - if (hasLastHeartbeatTime() != other.hasLastHeartbeatTime()) return false; - if (hasLastHeartbeatTime()) { - if (!getLastHeartbeatTime().equals(other.getLastHeartbeatTime())) return false; - } - if (hasLastEventTime() != other.hasLastEventTime()) return false; - if (hasLastEventTime()) { - if (!getLastEventTime().equals(other.getLastEventTime())) return false; - } - if (hasLastStateTime() != other.hasLastStateTime()) return false; - if (hasLastStateTime()) { - if (!getLastStateTime().equals(other.getLastStateTime())) return false; - } - if (hasLastConfigAckTime() != other.hasLastConfigAckTime()) return false; - if (hasLastConfigAckTime()) { - if (!getLastConfigAckTime().equals(other.getLastConfigAckTime())) return false; - } - if (hasLastConfigSendTime() != other.hasLastConfigSendTime()) return false; - if (hasLastConfigSendTime()) { - if (!getLastConfigSendTime().equals(other.getLastConfigSendTime())) return false; - } - if (getBlocked() != other.getBlocked()) return false; - if (hasLastErrorTime() != other.hasLastErrorTime()) return false; - if (hasLastErrorTime()) { - if (!getLastErrorTime().equals(other.getLastErrorTime())) return false; - } - if (hasLastErrorStatus() != other.hasLastErrorStatus()) return false; - if (hasLastErrorStatus()) { - if (!getLastErrorStatus().equals(other.getLastErrorStatus())) return false; - } - if (hasConfig() != other.hasConfig()) return false; - if (hasConfig()) { - if (!getConfig().equals(other.getConfig())) return false; - } - if (hasState() != other.hasState()) return false; - if (hasState()) { - if (!getState().equals(other.getState())) return false; - } - if (logLevel_ != other.logLevel_) return false; - if (!internalGetMetadata().equals(other.internalGetMetadata())) return false; - if (hasGatewayConfig() != other.hasGatewayConfig()) return false; - if (hasGatewayConfig()) { - if (!getGatewayConfig().equals(other.getGatewayConfig())) return false; - } - if (!getUnknownFields().equals(other.getUnknownFields())) return false; - return true; - } - - @java.lang.Override - public int hashCode() { - if (memoizedHashCode != 0) { - return memoizedHashCode; - } - int hash = 41; - hash = (19 * hash) + getDescriptor().hashCode(); - hash = (37 * hash) + ID_FIELD_NUMBER; - hash = (53 * hash) + getId().hashCode(); - hash = (37 * hash) + NAME_FIELD_NUMBER; - hash = (53 * hash) + getName().hashCode(); - hash = (37 * hash) + NUM_ID_FIELD_NUMBER; - hash = (53 * hash) + com.google.protobuf.Internal.hashLong(getNumId()); - if (getCredentialsCount() > 0) { - hash = (37 * hash) + CREDENTIALS_FIELD_NUMBER; - hash = (53 * hash) + getCredentialsList().hashCode(); - } - if (hasLastHeartbeatTime()) { - hash = (37 * hash) + LAST_HEARTBEAT_TIME_FIELD_NUMBER; - hash = (53 * hash) + getLastHeartbeatTime().hashCode(); - } - if (hasLastEventTime()) { - hash = (37 * hash) + LAST_EVENT_TIME_FIELD_NUMBER; - hash = (53 * hash) + getLastEventTime().hashCode(); - } - if (hasLastStateTime()) { - hash = (37 * hash) + LAST_STATE_TIME_FIELD_NUMBER; - hash = (53 * hash) + getLastStateTime().hashCode(); - } - if (hasLastConfigAckTime()) { - hash = (37 * hash) + LAST_CONFIG_ACK_TIME_FIELD_NUMBER; - hash = (53 * hash) + getLastConfigAckTime().hashCode(); - } - if (hasLastConfigSendTime()) { - hash = (37 * hash) + LAST_CONFIG_SEND_TIME_FIELD_NUMBER; - hash = (53 * hash) + getLastConfigSendTime().hashCode(); - } - hash = (37 * hash) + BLOCKED_FIELD_NUMBER; - hash = (53 * hash) + com.google.protobuf.Internal.hashBoolean(getBlocked()); - if (hasLastErrorTime()) { - hash = (37 * hash) + LAST_ERROR_TIME_FIELD_NUMBER; - hash = (53 * hash) + getLastErrorTime().hashCode(); - } - if (hasLastErrorStatus()) { - hash = (37 * hash) + LAST_ERROR_STATUS_FIELD_NUMBER; - hash = (53 * hash) + getLastErrorStatus().hashCode(); - } - if (hasConfig()) { - hash = (37 * hash) + CONFIG_FIELD_NUMBER; - hash = (53 * hash) + getConfig().hashCode(); - } - if (hasState()) { - hash = (37 * hash) + STATE_FIELD_NUMBER; - hash = (53 * hash) + getState().hashCode(); - } - hash = (37 * hash) + LOG_LEVEL_FIELD_NUMBER; - hash = (53 * hash) + logLevel_; - if (!internalGetMetadata().getMap().isEmpty()) { - hash = (37 * hash) + METADATA_FIELD_NUMBER; - hash = (53 * hash) + internalGetMetadata().hashCode(); - } - if (hasGatewayConfig()) { - hash = (37 * hash) + GATEWAY_CONFIG_FIELD_NUMBER; - hash = (53 * hash) + getGatewayConfig().hashCode(); - } - hash = (29 * hash) + getUnknownFields().hashCode(); - memoizedHashCode = hash; - return hash; - } - - public static com.google.cloud.iot.v1.Device parseFrom(java.nio.ByteBuffer data) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); - } - - public static com.google.cloud.iot.v1.Device parseFrom( - java.nio.ByteBuffer data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); - } - - public static com.google.cloud.iot.v1.Device parseFrom(com.google.protobuf.ByteString data) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); - } - - public static com.google.cloud.iot.v1.Device parseFrom( - com.google.protobuf.ByteString data, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); - } - - public static com.google.cloud.iot.v1.Device parseFrom(byte[] data) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); - } - - public static com.google.cloud.iot.v1.Device parseFrom( - byte[] data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); - } - - public static com.google.cloud.iot.v1.Device parseFrom(java.io.InputStream input) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input); - } - - public static com.google.cloud.iot.v1.Device parseFrom( - java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3.parseWithIOException( - PARSER, input, extensionRegistry); - } - - public static com.google.cloud.iot.v1.Device parseDelimitedFrom(java.io.InputStream input) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3.parseDelimitedWithIOException(PARSER, input); - } - - public static com.google.cloud.iot.v1.Device parseDelimitedFrom( - java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3.parseDelimitedWithIOException( - PARSER, input, extensionRegistry); - } - - public static com.google.cloud.iot.v1.Device parseFrom(com.google.protobuf.CodedInputStream input) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input); - } - - public static com.google.cloud.iot.v1.Device parseFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3.parseWithIOException( - PARSER, input, extensionRegistry); - } - - @java.lang.Override - public Builder newBuilderForType() { - return newBuilder(); - } - - public static Builder newBuilder() { - return DEFAULT_INSTANCE.toBuilder(); - } - - public static Builder newBuilder(com.google.cloud.iot.v1.Device prototype) { - return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); - } - - @java.lang.Override - public Builder toBuilder() { - return this == DEFAULT_INSTANCE ? new Builder() : new Builder().mergeFrom(this); - } - - @java.lang.Override - protected Builder newBuilderForType(com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { - Builder builder = new Builder(parent); - return builder; - } - /** - * - * - *
-   * The device resource.
-   * 
- * - * Protobuf type {@code google.cloud.iot.v1.Device} - */ - public static final class Builder extends com.google.protobuf.GeneratedMessageV3.Builder - implements - // @@protoc_insertion_point(builder_implements:google.cloud.iot.v1.Device) - com.google.cloud.iot.v1.DeviceOrBuilder { - public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { - return com.google.cloud.iot.v1.ResourcesProto - .internal_static_google_cloud_iot_v1_Device_descriptor; - } - - @SuppressWarnings({"rawtypes"}) - protected com.google.protobuf.MapField internalGetMapField(int number) { - switch (number) { - case 17: - return internalGetMetadata(); - default: - throw new RuntimeException("Invalid map field number: " + number); - } - } - - @SuppressWarnings({"rawtypes"}) - protected com.google.protobuf.MapField internalGetMutableMapField(int number) { - switch (number) { - case 17: - return internalGetMutableMetadata(); - default: - throw new RuntimeException("Invalid map field number: " + number); - } - } - - @java.lang.Override - protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable - internalGetFieldAccessorTable() { - return com.google.cloud.iot.v1.ResourcesProto - .internal_static_google_cloud_iot_v1_Device_fieldAccessorTable - .ensureFieldAccessorsInitialized( - com.google.cloud.iot.v1.Device.class, com.google.cloud.iot.v1.Device.Builder.class); - } - - // Construct using com.google.cloud.iot.v1.Device.newBuilder() - private Builder() {} - - private Builder(com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { - super(parent); - } - - @java.lang.Override - public Builder clear() { - super.clear(); - id_ = ""; - - name_ = ""; - - numId_ = 0L; - - if (credentialsBuilder_ == null) { - credentials_ = java.util.Collections.emptyList(); - } else { - credentials_ = null; - credentialsBuilder_.clear(); - } - bitField0_ = (bitField0_ & ~0x00000001); - if (lastHeartbeatTimeBuilder_ == null) { - lastHeartbeatTime_ = null; - } else { - lastHeartbeatTime_ = null; - lastHeartbeatTimeBuilder_ = null; - } - if (lastEventTimeBuilder_ == null) { - lastEventTime_ = null; - } else { - lastEventTime_ = null; - lastEventTimeBuilder_ = null; - } - if (lastStateTimeBuilder_ == null) { - lastStateTime_ = null; - } else { - lastStateTime_ = null; - lastStateTimeBuilder_ = null; - } - if (lastConfigAckTimeBuilder_ == null) { - lastConfigAckTime_ = null; - } else { - lastConfigAckTime_ = null; - lastConfigAckTimeBuilder_ = null; - } - if (lastConfigSendTimeBuilder_ == null) { - lastConfigSendTime_ = null; - } else { - lastConfigSendTime_ = null; - lastConfigSendTimeBuilder_ = null; - } - blocked_ = false; - - if (lastErrorTimeBuilder_ == null) { - lastErrorTime_ = null; - } else { - lastErrorTime_ = null; - lastErrorTimeBuilder_ = null; - } - if (lastErrorStatusBuilder_ == null) { - lastErrorStatus_ = null; - } else { - lastErrorStatus_ = null; - lastErrorStatusBuilder_ = null; - } - if (configBuilder_ == null) { - config_ = null; - } else { - config_ = null; - configBuilder_ = null; - } - if (stateBuilder_ == null) { - state_ = null; - } else { - state_ = null; - stateBuilder_ = null; - } - logLevel_ = 0; - - internalGetMutableMetadata().clear(); - if (gatewayConfigBuilder_ == null) { - gatewayConfig_ = null; - } else { - gatewayConfig_ = null; - gatewayConfigBuilder_ = null; - } - return this; - } - - @java.lang.Override - public com.google.protobuf.Descriptors.Descriptor getDescriptorForType() { - return com.google.cloud.iot.v1.ResourcesProto - .internal_static_google_cloud_iot_v1_Device_descriptor; - } - - @java.lang.Override - public com.google.cloud.iot.v1.Device getDefaultInstanceForType() { - return com.google.cloud.iot.v1.Device.getDefaultInstance(); - } - - @java.lang.Override - public com.google.cloud.iot.v1.Device build() { - com.google.cloud.iot.v1.Device result = buildPartial(); - if (!result.isInitialized()) { - throw newUninitializedMessageException(result); - } - return result; - } - - @java.lang.Override - public com.google.cloud.iot.v1.Device buildPartial() { - com.google.cloud.iot.v1.Device result = new com.google.cloud.iot.v1.Device(this); - int from_bitField0_ = bitField0_; - result.id_ = id_; - result.name_ = name_; - result.numId_ = numId_; - if (credentialsBuilder_ == null) { - if (((bitField0_ & 0x00000001) != 0)) { - credentials_ = java.util.Collections.unmodifiableList(credentials_); - bitField0_ = (bitField0_ & ~0x00000001); - } - result.credentials_ = credentials_; - } else { - result.credentials_ = credentialsBuilder_.build(); - } - if (lastHeartbeatTimeBuilder_ == null) { - result.lastHeartbeatTime_ = lastHeartbeatTime_; - } else { - result.lastHeartbeatTime_ = lastHeartbeatTimeBuilder_.build(); - } - if (lastEventTimeBuilder_ == null) { - result.lastEventTime_ = lastEventTime_; - } else { - result.lastEventTime_ = lastEventTimeBuilder_.build(); - } - if (lastStateTimeBuilder_ == null) { - result.lastStateTime_ = lastStateTime_; - } else { - result.lastStateTime_ = lastStateTimeBuilder_.build(); - } - if (lastConfigAckTimeBuilder_ == null) { - result.lastConfigAckTime_ = lastConfigAckTime_; - } else { - result.lastConfigAckTime_ = lastConfigAckTimeBuilder_.build(); - } - if (lastConfigSendTimeBuilder_ == null) { - result.lastConfigSendTime_ = lastConfigSendTime_; - } else { - result.lastConfigSendTime_ = lastConfigSendTimeBuilder_.build(); - } - result.blocked_ = blocked_; - if (lastErrorTimeBuilder_ == null) { - result.lastErrorTime_ = lastErrorTime_; - } else { - result.lastErrorTime_ = lastErrorTimeBuilder_.build(); - } - if (lastErrorStatusBuilder_ == null) { - result.lastErrorStatus_ = lastErrorStatus_; - } else { - result.lastErrorStatus_ = lastErrorStatusBuilder_.build(); - } - if (configBuilder_ == null) { - result.config_ = config_; - } else { - result.config_ = configBuilder_.build(); - } - if (stateBuilder_ == null) { - result.state_ = state_; - } else { - result.state_ = stateBuilder_.build(); - } - result.logLevel_ = logLevel_; - result.metadata_ = internalGetMetadata(); - result.metadata_.makeImmutable(); - if (gatewayConfigBuilder_ == null) { - result.gatewayConfig_ = gatewayConfig_; - } else { - result.gatewayConfig_ = gatewayConfigBuilder_.build(); - } - onBuilt(); - return result; - } - - @java.lang.Override - public Builder clone() { - return super.clone(); - } - - @java.lang.Override - public Builder setField( - com.google.protobuf.Descriptors.FieldDescriptor field, java.lang.Object value) { - return super.setField(field, value); - } - - @java.lang.Override - public Builder clearField(com.google.protobuf.Descriptors.FieldDescriptor field) { - return super.clearField(field); - } - - @java.lang.Override - public Builder clearOneof(com.google.protobuf.Descriptors.OneofDescriptor oneof) { - return super.clearOneof(oneof); - } - - @java.lang.Override - public Builder setRepeatedField( - com.google.protobuf.Descriptors.FieldDescriptor field, int index, java.lang.Object value) { - return super.setRepeatedField(field, index, value); - } - - @java.lang.Override - public Builder addRepeatedField( - com.google.protobuf.Descriptors.FieldDescriptor field, java.lang.Object value) { - return super.addRepeatedField(field, value); - } - - @java.lang.Override - public Builder mergeFrom(com.google.protobuf.Message other) { - if (other instanceof com.google.cloud.iot.v1.Device) { - return mergeFrom((com.google.cloud.iot.v1.Device) other); - } else { - super.mergeFrom(other); - return this; - } - } - - public Builder mergeFrom(com.google.cloud.iot.v1.Device other) { - if (other == com.google.cloud.iot.v1.Device.getDefaultInstance()) return this; - if (!other.getId().isEmpty()) { - id_ = other.id_; - onChanged(); - } - if (!other.getName().isEmpty()) { - name_ = other.name_; - onChanged(); - } - if (other.getNumId() != 0L) { - setNumId(other.getNumId()); - } - if (credentialsBuilder_ == null) { - if (!other.credentials_.isEmpty()) { - if (credentials_.isEmpty()) { - credentials_ = other.credentials_; - bitField0_ = (bitField0_ & ~0x00000001); - } else { - ensureCredentialsIsMutable(); - credentials_.addAll(other.credentials_); - } - onChanged(); - } - } else { - if (!other.credentials_.isEmpty()) { - if (credentialsBuilder_.isEmpty()) { - credentialsBuilder_.dispose(); - credentialsBuilder_ = null; - credentials_ = other.credentials_; - bitField0_ = (bitField0_ & ~0x00000001); - credentialsBuilder_ = - com.google.protobuf.GeneratedMessageV3.alwaysUseFieldBuilders - ? getCredentialsFieldBuilder() - : null; - } else { - credentialsBuilder_.addAllMessages(other.credentials_); - } - } - } - if (other.hasLastHeartbeatTime()) { - mergeLastHeartbeatTime(other.getLastHeartbeatTime()); - } - if (other.hasLastEventTime()) { - mergeLastEventTime(other.getLastEventTime()); - } - if (other.hasLastStateTime()) { - mergeLastStateTime(other.getLastStateTime()); - } - if (other.hasLastConfigAckTime()) { - mergeLastConfigAckTime(other.getLastConfigAckTime()); - } - if (other.hasLastConfigSendTime()) { - mergeLastConfigSendTime(other.getLastConfigSendTime()); - } - if (other.getBlocked() != false) { - setBlocked(other.getBlocked()); - } - if (other.hasLastErrorTime()) { - mergeLastErrorTime(other.getLastErrorTime()); - } - if (other.hasLastErrorStatus()) { - mergeLastErrorStatus(other.getLastErrorStatus()); - } - if (other.hasConfig()) { - mergeConfig(other.getConfig()); - } - if (other.hasState()) { - mergeState(other.getState()); - } - if (other.logLevel_ != 0) { - setLogLevelValue(other.getLogLevelValue()); - } - internalGetMutableMetadata().mergeFrom(other.internalGetMetadata()); - if (other.hasGatewayConfig()) { - mergeGatewayConfig(other.getGatewayConfig()); - } - this.mergeUnknownFields(other.getUnknownFields()); - onChanged(); - return this; - } - - @java.lang.Override - public final boolean isInitialized() { - return true; - } - - @java.lang.Override - public Builder mergeFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - if (extensionRegistry == null) { - throw new java.lang.NullPointerException(); - } - try { - boolean done = false; - while (!done) { - int tag = input.readTag(); - switch (tag) { - case 0: - done = true; - break; - case 10: - { - id_ = input.readStringRequireUtf8(); - - break; - } // case 10 - case 18: - { - name_ = input.readStringRequireUtf8(); - - break; - } // case 18 - case 24: - { - numId_ = input.readUInt64(); - - break; - } // case 24 - case 58: - { - input.readMessage( - getLastHeartbeatTimeFieldBuilder().getBuilder(), extensionRegistry); - - break; - } // case 58 - case 66: - { - input.readMessage(getLastEventTimeFieldBuilder().getBuilder(), extensionRegistry); - - break; - } // case 66 - case 82: - { - input.readMessage(getLastErrorTimeFieldBuilder().getBuilder(), extensionRegistry); - - break; - } // case 82 - case 90: - { - input.readMessage(getLastErrorStatusFieldBuilder().getBuilder(), extensionRegistry); - - break; - } // case 90 - case 98: - { - com.google.cloud.iot.v1.DeviceCredential m = - input.readMessage( - com.google.cloud.iot.v1.DeviceCredential.parser(), extensionRegistry); - if (credentialsBuilder_ == null) { - ensureCredentialsIsMutable(); - credentials_.add(m); - } else { - credentialsBuilder_.addMessage(m); - } - break; - } // case 98 - case 106: - { - input.readMessage(getConfigFieldBuilder().getBuilder(), extensionRegistry); - - break; - } // case 106 - case 114: - { - input.readMessage( - getLastConfigAckTimeFieldBuilder().getBuilder(), extensionRegistry); - - break; - } // case 114 - case 130: - { - input.readMessage(getStateFieldBuilder().getBuilder(), extensionRegistry); - - break; - } // case 130 - case 138: - { - com.google.protobuf.MapEntry metadata__ = - input.readMessage( - MetadataDefaultEntryHolder.defaultEntry.getParserForType(), - extensionRegistry); - internalGetMutableMetadata() - .getMutableMap() - .put(metadata__.getKey(), metadata__.getValue()); - break; - } // case 138 - case 146: - { - input.readMessage( - getLastConfigSendTimeFieldBuilder().getBuilder(), extensionRegistry); - - break; - } // case 146 - case 152: - { - blocked_ = input.readBool(); - - break; - } // case 152 - case 162: - { - input.readMessage(getLastStateTimeFieldBuilder().getBuilder(), extensionRegistry); - - break; - } // case 162 - case 168: - { - logLevel_ = input.readEnum(); - - break; - } // case 168 - case 194: - { - input.readMessage(getGatewayConfigFieldBuilder().getBuilder(), extensionRegistry); - - break; - } // case 194 - default: - { - if (!super.parseUnknownField(input, extensionRegistry, tag)) { - done = true; // was an endgroup tag - } - break; - } // default: - } // switch (tag) - } // while (!done) - } catch (com.google.protobuf.InvalidProtocolBufferException e) { - throw e.unwrapIOException(); - } finally { - onChanged(); - } // finally - return this; - } - - private int bitField0_; - - private java.lang.Object id_ = ""; - /** - * - * - *
-     * The user-defined device identifier. The device ID must be unique
-     * within a device registry.
-     * 
- * - * string id = 1; - * - * @return The id. - */ - public java.lang.String getId() { - java.lang.Object ref = id_; - if (!(ref instanceof java.lang.String)) { - com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; - java.lang.String s = bs.toStringUtf8(); - id_ = s; - return s; - } else { - return (java.lang.String) ref; - } - } - /** - * - * - *
-     * The user-defined device identifier. The device ID must be unique
-     * within a device registry.
-     * 
- * - * string id = 1; - * - * @return The bytes for id. - */ - public com.google.protobuf.ByteString getIdBytes() { - java.lang.Object ref = id_; - if (ref instanceof String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); - id_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - /** - * - * - *
-     * The user-defined device identifier. The device ID must be unique
-     * within a device registry.
-     * 
- * - * string id = 1; - * - * @param value The id to set. - * @return This builder for chaining. - */ - public Builder setId(java.lang.String value) { - if (value == null) { - throw new NullPointerException(); - } - - id_ = value; - onChanged(); - return this; - } - /** - * - * - *
-     * The user-defined device identifier. The device ID must be unique
-     * within a device registry.
-     * 
- * - * string id = 1; - * - * @return This builder for chaining. - */ - public Builder clearId() { - - id_ = getDefaultInstance().getId(); - onChanged(); - return this; - } - /** - * - * - *
-     * The user-defined device identifier. The device ID must be unique
-     * within a device registry.
-     * 
- * - * string id = 1; - * - * @param value The bytes for id to set. - * @return This builder for chaining. - */ - public Builder setIdBytes(com.google.protobuf.ByteString value) { - if (value == null) { - throw new NullPointerException(); - } - checkByteStringIsUtf8(value); - - id_ = value; - onChanged(); - return this; - } - - private java.lang.Object name_ = ""; - /** - * - * - *
-     * The resource path name. For example,
-     * `projects/p1/locations/us-central1/registries/registry0/devices/dev0` or
-     * `projects/p1/locations/us-central1/registries/registry0/devices/{num_id}`.
-     * When `name` is populated as a response from the service, it always ends
-     * in the device numeric ID.
-     * 
- * - * string name = 2; - * - * @return The name. - */ - public java.lang.String getName() { - java.lang.Object ref = name_; - if (!(ref instanceof java.lang.String)) { - com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; - java.lang.String s = bs.toStringUtf8(); - name_ = s; - return s; - } else { - return (java.lang.String) ref; - } - } - /** - * - * - *
-     * The resource path name. For example,
-     * `projects/p1/locations/us-central1/registries/registry0/devices/dev0` or
-     * `projects/p1/locations/us-central1/registries/registry0/devices/{num_id}`.
-     * When `name` is populated as a response from the service, it always ends
-     * in the device numeric ID.
-     * 
- * - * string name = 2; - * - * @return The bytes for name. - */ - public com.google.protobuf.ByteString getNameBytes() { - java.lang.Object ref = name_; - if (ref instanceof String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); - name_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - /** - * - * - *
-     * The resource path name. For example,
-     * `projects/p1/locations/us-central1/registries/registry0/devices/dev0` or
-     * `projects/p1/locations/us-central1/registries/registry0/devices/{num_id}`.
-     * When `name` is populated as a response from the service, it always ends
-     * in the device numeric ID.
-     * 
- * - * string name = 2; - * - * @param value The name to set. - * @return This builder for chaining. - */ - public Builder setName(java.lang.String value) { - if (value == null) { - throw new NullPointerException(); - } - - name_ = value; - onChanged(); - return this; - } - /** - * - * - *
-     * The resource path name. For example,
-     * `projects/p1/locations/us-central1/registries/registry0/devices/dev0` or
-     * `projects/p1/locations/us-central1/registries/registry0/devices/{num_id}`.
-     * When `name` is populated as a response from the service, it always ends
-     * in the device numeric ID.
-     * 
- * - * string name = 2; - * - * @return This builder for chaining. - */ - public Builder clearName() { - - name_ = getDefaultInstance().getName(); - onChanged(); - return this; - } - /** - * - * - *
-     * The resource path name. For example,
-     * `projects/p1/locations/us-central1/registries/registry0/devices/dev0` or
-     * `projects/p1/locations/us-central1/registries/registry0/devices/{num_id}`.
-     * When `name` is populated as a response from the service, it always ends
-     * in the device numeric ID.
-     * 
- * - * string name = 2; - * - * @param value The bytes for name to set. - * @return This builder for chaining. - */ - public Builder setNameBytes(com.google.protobuf.ByteString value) { - if (value == null) { - throw new NullPointerException(); - } - checkByteStringIsUtf8(value); - - name_ = value; - onChanged(); - return this; - } - - private long numId_; - /** - * - * - *
-     * [Output only] A server-defined unique numeric ID for the device. This is a
-     * more compact way to identify devices, and it is globally unique.
-     * 
- * - * uint64 num_id = 3; - * - * @return The numId. - */ - @java.lang.Override - public long getNumId() { - return numId_; - } - /** - * - * - *
-     * [Output only] A server-defined unique numeric ID for the device. This is a
-     * more compact way to identify devices, and it is globally unique.
-     * 
- * - * uint64 num_id = 3; - * - * @param value The numId to set. - * @return This builder for chaining. - */ - public Builder setNumId(long value) { - - numId_ = value; - onChanged(); - return this; - } - /** - * - * - *
-     * [Output only] A server-defined unique numeric ID for the device. This is a
-     * more compact way to identify devices, and it is globally unique.
-     * 
- * - * uint64 num_id = 3; - * - * @return This builder for chaining. - */ - public Builder clearNumId() { - - numId_ = 0L; - onChanged(); - return this; - } - - private java.util.List credentials_ = - java.util.Collections.emptyList(); - - private void ensureCredentialsIsMutable() { - if (!((bitField0_ & 0x00000001) != 0)) { - credentials_ = - new java.util.ArrayList(credentials_); - bitField0_ |= 0x00000001; - } - } - - private com.google.protobuf.RepeatedFieldBuilderV3< - com.google.cloud.iot.v1.DeviceCredential, - com.google.cloud.iot.v1.DeviceCredential.Builder, - com.google.cloud.iot.v1.DeviceCredentialOrBuilder> - credentialsBuilder_; - - /** - * - * - *
-     * The credentials used to authenticate this device. To allow credential
-     * rotation without interruption, multiple device credentials can be bound to
-     * this device. No more than 3 credentials can be bound to a single device at
-     * a time. When new credentials are added to a device, they are verified
-     * against the registry credentials. For details, see the description of the
-     * `DeviceRegistry.credentials` field.
-     * 
- * - * repeated .google.cloud.iot.v1.DeviceCredential credentials = 12; - */ - public java.util.List getCredentialsList() { - if (credentialsBuilder_ == null) { - return java.util.Collections.unmodifiableList(credentials_); - } else { - return credentialsBuilder_.getMessageList(); - } - } - /** - * - * - *
-     * The credentials used to authenticate this device. To allow credential
-     * rotation without interruption, multiple device credentials can be bound to
-     * this device. No more than 3 credentials can be bound to a single device at
-     * a time. When new credentials are added to a device, they are verified
-     * against the registry credentials. For details, see the description of the
-     * `DeviceRegistry.credentials` field.
-     * 
- * - * repeated .google.cloud.iot.v1.DeviceCredential credentials = 12; - */ - public int getCredentialsCount() { - if (credentialsBuilder_ == null) { - return credentials_.size(); - } else { - return credentialsBuilder_.getCount(); - } - } - /** - * - * - *
-     * The credentials used to authenticate this device. To allow credential
-     * rotation without interruption, multiple device credentials can be bound to
-     * this device. No more than 3 credentials can be bound to a single device at
-     * a time. When new credentials are added to a device, they are verified
-     * against the registry credentials. For details, see the description of the
-     * `DeviceRegistry.credentials` field.
-     * 
- * - * repeated .google.cloud.iot.v1.DeviceCredential credentials = 12; - */ - public com.google.cloud.iot.v1.DeviceCredential getCredentials(int index) { - if (credentialsBuilder_ == null) { - return credentials_.get(index); - } else { - return credentialsBuilder_.getMessage(index); - } - } - /** - * - * - *
-     * The credentials used to authenticate this device. To allow credential
-     * rotation without interruption, multiple device credentials can be bound to
-     * this device. No more than 3 credentials can be bound to a single device at
-     * a time. When new credentials are added to a device, they are verified
-     * against the registry credentials. For details, see the description of the
-     * `DeviceRegistry.credentials` field.
-     * 
- * - * repeated .google.cloud.iot.v1.DeviceCredential credentials = 12; - */ - public Builder setCredentials(int index, com.google.cloud.iot.v1.DeviceCredential value) { - if (credentialsBuilder_ == null) { - if (value == null) { - throw new NullPointerException(); - } - ensureCredentialsIsMutable(); - credentials_.set(index, value); - onChanged(); - } else { - credentialsBuilder_.setMessage(index, value); - } - return this; - } - /** - * - * - *
-     * The credentials used to authenticate this device. To allow credential
-     * rotation without interruption, multiple device credentials can be bound to
-     * this device. No more than 3 credentials can be bound to a single device at
-     * a time. When new credentials are added to a device, they are verified
-     * against the registry credentials. For details, see the description of the
-     * `DeviceRegistry.credentials` field.
-     * 
- * - * repeated .google.cloud.iot.v1.DeviceCredential credentials = 12; - */ - public Builder setCredentials( - int index, com.google.cloud.iot.v1.DeviceCredential.Builder builderForValue) { - if (credentialsBuilder_ == null) { - ensureCredentialsIsMutable(); - credentials_.set(index, builderForValue.build()); - onChanged(); - } else { - credentialsBuilder_.setMessage(index, builderForValue.build()); - } - return this; - } - /** - * - * - *
-     * The credentials used to authenticate this device. To allow credential
-     * rotation without interruption, multiple device credentials can be bound to
-     * this device. No more than 3 credentials can be bound to a single device at
-     * a time. When new credentials are added to a device, they are verified
-     * against the registry credentials. For details, see the description of the
-     * `DeviceRegistry.credentials` field.
-     * 
- * - * repeated .google.cloud.iot.v1.DeviceCredential credentials = 12; - */ - public Builder addCredentials(com.google.cloud.iot.v1.DeviceCredential value) { - if (credentialsBuilder_ == null) { - if (value == null) { - throw new NullPointerException(); - } - ensureCredentialsIsMutable(); - credentials_.add(value); - onChanged(); - } else { - credentialsBuilder_.addMessage(value); - } - return this; - } - /** - * - * - *
-     * The credentials used to authenticate this device. To allow credential
-     * rotation without interruption, multiple device credentials can be bound to
-     * this device. No more than 3 credentials can be bound to a single device at
-     * a time. When new credentials are added to a device, they are verified
-     * against the registry credentials. For details, see the description of the
-     * `DeviceRegistry.credentials` field.
-     * 
- * - * repeated .google.cloud.iot.v1.DeviceCredential credentials = 12; - */ - public Builder addCredentials(int index, com.google.cloud.iot.v1.DeviceCredential value) { - if (credentialsBuilder_ == null) { - if (value == null) { - throw new NullPointerException(); - } - ensureCredentialsIsMutable(); - credentials_.add(index, value); - onChanged(); - } else { - credentialsBuilder_.addMessage(index, value); - } - return this; - } - /** - * - * - *
-     * The credentials used to authenticate this device. To allow credential
-     * rotation without interruption, multiple device credentials can be bound to
-     * this device. No more than 3 credentials can be bound to a single device at
-     * a time. When new credentials are added to a device, they are verified
-     * against the registry credentials. For details, see the description of the
-     * `DeviceRegistry.credentials` field.
-     * 
- * - * repeated .google.cloud.iot.v1.DeviceCredential credentials = 12; - */ - public Builder addCredentials( - com.google.cloud.iot.v1.DeviceCredential.Builder builderForValue) { - if (credentialsBuilder_ == null) { - ensureCredentialsIsMutable(); - credentials_.add(builderForValue.build()); - onChanged(); - } else { - credentialsBuilder_.addMessage(builderForValue.build()); - } - return this; - } - /** - * - * - *
-     * The credentials used to authenticate this device. To allow credential
-     * rotation without interruption, multiple device credentials can be bound to
-     * this device. No more than 3 credentials can be bound to a single device at
-     * a time. When new credentials are added to a device, they are verified
-     * against the registry credentials. For details, see the description of the
-     * `DeviceRegistry.credentials` field.
-     * 
- * - * repeated .google.cloud.iot.v1.DeviceCredential credentials = 12; - */ - public Builder addCredentials( - int index, com.google.cloud.iot.v1.DeviceCredential.Builder builderForValue) { - if (credentialsBuilder_ == null) { - ensureCredentialsIsMutable(); - credentials_.add(index, builderForValue.build()); - onChanged(); - } else { - credentialsBuilder_.addMessage(index, builderForValue.build()); - } - return this; - } - /** - * - * - *
-     * The credentials used to authenticate this device. To allow credential
-     * rotation without interruption, multiple device credentials can be bound to
-     * this device. No more than 3 credentials can be bound to a single device at
-     * a time. When new credentials are added to a device, they are verified
-     * against the registry credentials. For details, see the description of the
-     * `DeviceRegistry.credentials` field.
-     * 
- * - * repeated .google.cloud.iot.v1.DeviceCredential credentials = 12; - */ - public Builder addAllCredentials( - java.lang.Iterable values) { - if (credentialsBuilder_ == null) { - ensureCredentialsIsMutable(); - com.google.protobuf.AbstractMessageLite.Builder.addAll(values, credentials_); - onChanged(); - } else { - credentialsBuilder_.addAllMessages(values); - } - return this; - } - /** - * - * - *
-     * The credentials used to authenticate this device. To allow credential
-     * rotation without interruption, multiple device credentials can be bound to
-     * this device. No more than 3 credentials can be bound to a single device at
-     * a time. When new credentials are added to a device, they are verified
-     * against the registry credentials. For details, see the description of the
-     * `DeviceRegistry.credentials` field.
-     * 
- * - * repeated .google.cloud.iot.v1.DeviceCredential credentials = 12; - */ - public Builder clearCredentials() { - if (credentialsBuilder_ == null) { - credentials_ = java.util.Collections.emptyList(); - bitField0_ = (bitField0_ & ~0x00000001); - onChanged(); - } else { - credentialsBuilder_.clear(); - } - return this; - } - /** - * - * - *
-     * The credentials used to authenticate this device. To allow credential
-     * rotation without interruption, multiple device credentials can be bound to
-     * this device. No more than 3 credentials can be bound to a single device at
-     * a time. When new credentials are added to a device, they are verified
-     * against the registry credentials. For details, see the description of the
-     * `DeviceRegistry.credentials` field.
-     * 
- * - * repeated .google.cloud.iot.v1.DeviceCredential credentials = 12; - */ - public Builder removeCredentials(int index) { - if (credentialsBuilder_ == null) { - ensureCredentialsIsMutable(); - credentials_.remove(index); - onChanged(); - } else { - credentialsBuilder_.remove(index); - } - return this; - } - /** - * - * - *
-     * The credentials used to authenticate this device. To allow credential
-     * rotation without interruption, multiple device credentials can be bound to
-     * this device. No more than 3 credentials can be bound to a single device at
-     * a time. When new credentials are added to a device, they are verified
-     * against the registry credentials. For details, see the description of the
-     * `DeviceRegistry.credentials` field.
-     * 
- * - * repeated .google.cloud.iot.v1.DeviceCredential credentials = 12; - */ - public com.google.cloud.iot.v1.DeviceCredential.Builder getCredentialsBuilder(int index) { - return getCredentialsFieldBuilder().getBuilder(index); - } - /** - * - * - *
-     * The credentials used to authenticate this device. To allow credential
-     * rotation without interruption, multiple device credentials can be bound to
-     * this device. No more than 3 credentials can be bound to a single device at
-     * a time. When new credentials are added to a device, they are verified
-     * against the registry credentials. For details, see the description of the
-     * `DeviceRegistry.credentials` field.
-     * 
- * - * repeated .google.cloud.iot.v1.DeviceCredential credentials = 12; - */ - public com.google.cloud.iot.v1.DeviceCredentialOrBuilder getCredentialsOrBuilder(int index) { - if (credentialsBuilder_ == null) { - return credentials_.get(index); - } else { - return credentialsBuilder_.getMessageOrBuilder(index); - } - } - /** - * - * - *
-     * The credentials used to authenticate this device. To allow credential
-     * rotation without interruption, multiple device credentials can be bound to
-     * this device. No more than 3 credentials can be bound to a single device at
-     * a time. When new credentials are added to a device, they are verified
-     * against the registry credentials. For details, see the description of the
-     * `DeviceRegistry.credentials` field.
-     * 
- * - * repeated .google.cloud.iot.v1.DeviceCredential credentials = 12; - */ - public java.util.List - getCredentialsOrBuilderList() { - if (credentialsBuilder_ != null) { - return credentialsBuilder_.getMessageOrBuilderList(); - } else { - return java.util.Collections.unmodifiableList(credentials_); - } - } - /** - * - * - *
-     * The credentials used to authenticate this device. To allow credential
-     * rotation without interruption, multiple device credentials can be bound to
-     * this device. No more than 3 credentials can be bound to a single device at
-     * a time. When new credentials are added to a device, they are verified
-     * against the registry credentials. For details, see the description of the
-     * `DeviceRegistry.credentials` field.
-     * 
- * - * repeated .google.cloud.iot.v1.DeviceCredential credentials = 12; - */ - public com.google.cloud.iot.v1.DeviceCredential.Builder addCredentialsBuilder() { - return getCredentialsFieldBuilder() - .addBuilder(com.google.cloud.iot.v1.DeviceCredential.getDefaultInstance()); - } - /** - * - * - *
-     * The credentials used to authenticate this device. To allow credential
-     * rotation without interruption, multiple device credentials can be bound to
-     * this device. No more than 3 credentials can be bound to a single device at
-     * a time. When new credentials are added to a device, they are verified
-     * against the registry credentials. For details, see the description of the
-     * `DeviceRegistry.credentials` field.
-     * 
- * - * repeated .google.cloud.iot.v1.DeviceCredential credentials = 12; - */ - public com.google.cloud.iot.v1.DeviceCredential.Builder addCredentialsBuilder(int index) { - return getCredentialsFieldBuilder() - .addBuilder(index, com.google.cloud.iot.v1.DeviceCredential.getDefaultInstance()); - } - /** - * - * - *
-     * The credentials used to authenticate this device. To allow credential
-     * rotation without interruption, multiple device credentials can be bound to
-     * this device. No more than 3 credentials can be bound to a single device at
-     * a time. When new credentials are added to a device, they are verified
-     * against the registry credentials. For details, see the description of the
-     * `DeviceRegistry.credentials` field.
-     * 
- * - * repeated .google.cloud.iot.v1.DeviceCredential credentials = 12; - */ - public java.util.List - getCredentialsBuilderList() { - return getCredentialsFieldBuilder().getBuilderList(); - } - - private com.google.protobuf.RepeatedFieldBuilderV3< - com.google.cloud.iot.v1.DeviceCredential, - com.google.cloud.iot.v1.DeviceCredential.Builder, - com.google.cloud.iot.v1.DeviceCredentialOrBuilder> - getCredentialsFieldBuilder() { - if (credentialsBuilder_ == null) { - credentialsBuilder_ = - new com.google.protobuf.RepeatedFieldBuilderV3< - com.google.cloud.iot.v1.DeviceCredential, - com.google.cloud.iot.v1.DeviceCredential.Builder, - com.google.cloud.iot.v1.DeviceCredentialOrBuilder>( - credentials_, ((bitField0_ & 0x00000001) != 0), getParentForChildren(), isClean()); - credentials_ = null; - } - return credentialsBuilder_; - } - - private com.google.protobuf.Timestamp lastHeartbeatTime_; - private com.google.protobuf.SingleFieldBuilderV3< - com.google.protobuf.Timestamp, - com.google.protobuf.Timestamp.Builder, - com.google.protobuf.TimestampOrBuilder> - lastHeartbeatTimeBuilder_; - /** - * - * - *
-     * [Output only] The last time an MQTT `PINGREQ` was received. This field
-     * applies only to devices connecting through MQTT. MQTT clients usually only
-     * send `PINGREQ` messages if the connection is idle, and no other messages
-     * have been sent. Timestamps are periodically collected and written to
-     * storage; they may be stale by a few minutes.
-     * 
- * - * .google.protobuf.Timestamp last_heartbeat_time = 7; - * - * @return Whether the lastHeartbeatTime field is set. - */ - public boolean hasLastHeartbeatTime() { - return lastHeartbeatTimeBuilder_ != null || lastHeartbeatTime_ != null; - } - /** - * - * - *
-     * [Output only] The last time an MQTT `PINGREQ` was received. This field
-     * applies only to devices connecting through MQTT. MQTT clients usually only
-     * send `PINGREQ` messages if the connection is idle, and no other messages
-     * have been sent. Timestamps are periodically collected and written to
-     * storage; they may be stale by a few minutes.
-     * 
- * - * .google.protobuf.Timestamp last_heartbeat_time = 7; - * - * @return The lastHeartbeatTime. - */ - public com.google.protobuf.Timestamp getLastHeartbeatTime() { - if (lastHeartbeatTimeBuilder_ == null) { - return lastHeartbeatTime_ == null - ? com.google.protobuf.Timestamp.getDefaultInstance() - : lastHeartbeatTime_; - } else { - return lastHeartbeatTimeBuilder_.getMessage(); - } - } - /** - * - * - *
-     * [Output only] The last time an MQTT `PINGREQ` was received. This field
-     * applies only to devices connecting through MQTT. MQTT clients usually only
-     * send `PINGREQ` messages if the connection is idle, and no other messages
-     * have been sent. Timestamps are periodically collected and written to
-     * storage; they may be stale by a few minutes.
-     * 
- * - * .google.protobuf.Timestamp last_heartbeat_time = 7; - */ - public Builder setLastHeartbeatTime(com.google.protobuf.Timestamp value) { - if (lastHeartbeatTimeBuilder_ == null) { - if (value == null) { - throw new NullPointerException(); - } - lastHeartbeatTime_ = value; - onChanged(); - } else { - lastHeartbeatTimeBuilder_.setMessage(value); - } - - return this; - } - /** - * - * - *
-     * [Output only] The last time an MQTT `PINGREQ` was received. This field
-     * applies only to devices connecting through MQTT. MQTT clients usually only
-     * send `PINGREQ` messages if the connection is idle, and no other messages
-     * have been sent. Timestamps are periodically collected and written to
-     * storage; they may be stale by a few minutes.
-     * 
- * - * .google.protobuf.Timestamp last_heartbeat_time = 7; - */ - public Builder setLastHeartbeatTime(com.google.protobuf.Timestamp.Builder builderForValue) { - if (lastHeartbeatTimeBuilder_ == null) { - lastHeartbeatTime_ = builderForValue.build(); - onChanged(); - } else { - lastHeartbeatTimeBuilder_.setMessage(builderForValue.build()); - } - - return this; - } - /** - * - * - *
-     * [Output only] The last time an MQTT `PINGREQ` was received. This field
-     * applies only to devices connecting through MQTT. MQTT clients usually only
-     * send `PINGREQ` messages if the connection is idle, and no other messages
-     * have been sent. Timestamps are periodically collected and written to
-     * storage; they may be stale by a few minutes.
-     * 
- * - * .google.protobuf.Timestamp last_heartbeat_time = 7; - */ - public Builder mergeLastHeartbeatTime(com.google.protobuf.Timestamp value) { - if (lastHeartbeatTimeBuilder_ == null) { - if (lastHeartbeatTime_ != null) { - lastHeartbeatTime_ = - com.google.protobuf.Timestamp.newBuilder(lastHeartbeatTime_) - .mergeFrom(value) - .buildPartial(); - } else { - lastHeartbeatTime_ = value; - } - onChanged(); - } else { - lastHeartbeatTimeBuilder_.mergeFrom(value); - } - - return this; - } - /** - * - * - *
-     * [Output only] The last time an MQTT `PINGREQ` was received. This field
-     * applies only to devices connecting through MQTT. MQTT clients usually only
-     * send `PINGREQ` messages if the connection is idle, and no other messages
-     * have been sent. Timestamps are periodically collected and written to
-     * storage; they may be stale by a few minutes.
-     * 
- * - * .google.protobuf.Timestamp last_heartbeat_time = 7; - */ - public Builder clearLastHeartbeatTime() { - if (lastHeartbeatTimeBuilder_ == null) { - lastHeartbeatTime_ = null; - onChanged(); - } else { - lastHeartbeatTime_ = null; - lastHeartbeatTimeBuilder_ = null; - } - - return this; - } - /** - * - * - *
-     * [Output only] The last time an MQTT `PINGREQ` was received. This field
-     * applies only to devices connecting through MQTT. MQTT clients usually only
-     * send `PINGREQ` messages if the connection is idle, and no other messages
-     * have been sent. Timestamps are periodically collected and written to
-     * storage; they may be stale by a few minutes.
-     * 
- * - * .google.protobuf.Timestamp last_heartbeat_time = 7; - */ - public com.google.protobuf.Timestamp.Builder getLastHeartbeatTimeBuilder() { - - onChanged(); - return getLastHeartbeatTimeFieldBuilder().getBuilder(); - } - /** - * - * - *
-     * [Output only] The last time an MQTT `PINGREQ` was received. This field
-     * applies only to devices connecting through MQTT. MQTT clients usually only
-     * send `PINGREQ` messages if the connection is idle, and no other messages
-     * have been sent. Timestamps are periodically collected and written to
-     * storage; they may be stale by a few minutes.
-     * 
- * - * .google.protobuf.Timestamp last_heartbeat_time = 7; - */ - public com.google.protobuf.TimestampOrBuilder getLastHeartbeatTimeOrBuilder() { - if (lastHeartbeatTimeBuilder_ != null) { - return lastHeartbeatTimeBuilder_.getMessageOrBuilder(); - } else { - return lastHeartbeatTime_ == null - ? com.google.protobuf.Timestamp.getDefaultInstance() - : lastHeartbeatTime_; - } - } - /** - * - * - *
-     * [Output only] The last time an MQTT `PINGREQ` was received. This field
-     * applies only to devices connecting through MQTT. MQTT clients usually only
-     * send `PINGREQ` messages if the connection is idle, and no other messages
-     * have been sent. Timestamps are periodically collected and written to
-     * storage; they may be stale by a few minutes.
-     * 
- * - * .google.protobuf.Timestamp last_heartbeat_time = 7; - */ - private com.google.protobuf.SingleFieldBuilderV3< - com.google.protobuf.Timestamp, - com.google.protobuf.Timestamp.Builder, - com.google.protobuf.TimestampOrBuilder> - getLastHeartbeatTimeFieldBuilder() { - if (lastHeartbeatTimeBuilder_ == null) { - lastHeartbeatTimeBuilder_ = - new com.google.protobuf.SingleFieldBuilderV3< - com.google.protobuf.Timestamp, - com.google.protobuf.Timestamp.Builder, - com.google.protobuf.TimestampOrBuilder>( - getLastHeartbeatTime(), getParentForChildren(), isClean()); - lastHeartbeatTime_ = null; - } - return lastHeartbeatTimeBuilder_; - } - - private com.google.protobuf.Timestamp lastEventTime_; - private com.google.protobuf.SingleFieldBuilderV3< - com.google.protobuf.Timestamp, - com.google.protobuf.Timestamp.Builder, - com.google.protobuf.TimestampOrBuilder> - lastEventTimeBuilder_; - /** - * - * - *
-     * [Output only] The last time a telemetry event was received. Timestamps are
-     * periodically collected and written to storage; they may be stale by a few
-     * minutes.
-     * 
- * - * .google.protobuf.Timestamp last_event_time = 8; - * - * @return Whether the lastEventTime field is set. - */ - public boolean hasLastEventTime() { - return lastEventTimeBuilder_ != null || lastEventTime_ != null; - } - /** - * - * - *
-     * [Output only] The last time a telemetry event was received. Timestamps are
-     * periodically collected and written to storage; they may be stale by a few
-     * minutes.
-     * 
- * - * .google.protobuf.Timestamp last_event_time = 8; - * - * @return The lastEventTime. - */ - public com.google.protobuf.Timestamp getLastEventTime() { - if (lastEventTimeBuilder_ == null) { - return lastEventTime_ == null - ? com.google.protobuf.Timestamp.getDefaultInstance() - : lastEventTime_; - } else { - return lastEventTimeBuilder_.getMessage(); - } - } - /** - * - * - *
-     * [Output only] The last time a telemetry event was received. Timestamps are
-     * periodically collected and written to storage; they may be stale by a few
-     * minutes.
-     * 
- * - * .google.protobuf.Timestamp last_event_time = 8; - */ - public Builder setLastEventTime(com.google.protobuf.Timestamp value) { - if (lastEventTimeBuilder_ == null) { - if (value == null) { - throw new NullPointerException(); - } - lastEventTime_ = value; - onChanged(); - } else { - lastEventTimeBuilder_.setMessage(value); - } - - return this; - } - /** - * - * - *
-     * [Output only] The last time a telemetry event was received. Timestamps are
-     * periodically collected and written to storage; they may be stale by a few
-     * minutes.
-     * 
- * - * .google.protobuf.Timestamp last_event_time = 8; - */ - public Builder setLastEventTime(com.google.protobuf.Timestamp.Builder builderForValue) { - if (lastEventTimeBuilder_ == null) { - lastEventTime_ = builderForValue.build(); - onChanged(); - } else { - lastEventTimeBuilder_.setMessage(builderForValue.build()); - } - - return this; - } - /** - * - * - *
-     * [Output only] The last time a telemetry event was received. Timestamps are
-     * periodically collected and written to storage; they may be stale by a few
-     * minutes.
-     * 
- * - * .google.protobuf.Timestamp last_event_time = 8; - */ - public Builder mergeLastEventTime(com.google.protobuf.Timestamp value) { - if (lastEventTimeBuilder_ == null) { - if (lastEventTime_ != null) { - lastEventTime_ = - com.google.protobuf.Timestamp.newBuilder(lastEventTime_) - .mergeFrom(value) - .buildPartial(); - } else { - lastEventTime_ = value; - } - onChanged(); - } else { - lastEventTimeBuilder_.mergeFrom(value); - } - - return this; - } - /** - * - * - *
-     * [Output only] The last time a telemetry event was received. Timestamps are
-     * periodically collected and written to storage; they may be stale by a few
-     * minutes.
-     * 
- * - * .google.protobuf.Timestamp last_event_time = 8; - */ - public Builder clearLastEventTime() { - if (lastEventTimeBuilder_ == null) { - lastEventTime_ = null; - onChanged(); - } else { - lastEventTime_ = null; - lastEventTimeBuilder_ = null; - } - - return this; - } - /** - * - * - *
-     * [Output only] The last time a telemetry event was received. Timestamps are
-     * periodically collected and written to storage; they may be stale by a few
-     * minutes.
-     * 
- * - * .google.protobuf.Timestamp last_event_time = 8; - */ - public com.google.protobuf.Timestamp.Builder getLastEventTimeBuilder() { - - onChanged(); - return getLastEventTimeFieldBuilder().getBuilder(); - } - /** - * - * - *
-     * [Output only] The last time a telemetry event was received. Timestamps are
-     * periodically collected and written to storage; they may be stale by a few
-     * minutes.
-     * 
- * - * .google.protobuf.Timestamp last_event_time = 8; - */ - public com.google.protobuf.TimestampOrBuilder getLastEventTimeOrBuilder() { - if (lastEventTimeBuilder_ != null) { - return lastEventTimeBuilder_.getMessageOrBuilder(); - } else { - return lastEventTime_ == null - ? com.google.protobuf.Timestamp.getDefaultInstance() - : lastEventTime_; - } - } - /** - * - * - *
-     * [Output only] The last time a telemetry event was received. Timestamps are
-     * periodically collected and written to storage; they may be stale by a few
-     * minutes.
-     * 
- * - * .google.protobuf.Timestamp last_event_time = 8; - */ - private com.google.protobuf.SingleFieldBuilderV3< - com.google.protobuf.Timestamp, - com.google.protobuf.Timestamp.Builder, - com.google.protobuf.TimestampOrBuilder> - getLastEventTimeFieldBuilder() { - if (lastEventTimeBuilder_ == null) { - lastEventTimeBuilder_ = - new com.google.protobuf.SingleFieldBuilderV3< - com.google.protobuf.Timestamp, - com.google.protobuf.Timestamp.Builder, - com.google.protobuf.TimestampOrBuilder>( - getLastEventTime(), getParentForChildren(), isClean()); - lastEventTime_ = null; - } - return lastEventTimeBuilder_; - } - - private com.google.protobuf.Timestamp lastStateTime_; - private com.google.protobuf.SingleFieldBuilderV3< - com.google.protobuf.Timestamp, - com.google.protobuf.Timestamp.Builder, - com.google.protobuf.TimestampOrBuilder> - lastStateTimeBuilder_; - /** - * - * - *
-     * [Output only] The last time a state event was received. Timestamps are
-     * periodically collected and written to storage; they may be stale by a few
-     * minutes.
-     * 
- * - * .google.protobuf.Timestamp last_state_time = 20; - * - * @return Whether the lastStateTime field is set. - */ - public boolean hasLastStateTime() { - return lastStateTimeBuilder_ != null || lastStateTime_ != null; - } - /** - * - * - *
-     * [Output only] The last time a state event was received. Timestamps are
-     * periodically collected and written to storage; they may be stale by a few
-     * minutes.
-     * 
- * - * .google.protobuf.Timestamp last_state_time = 20; - * - * @return The lastStateTime. - */ - public com.google.protobuf.Timestamp getLastStateTime() { - if (lastStateTimeBuilder_ == null) { - return lastStateTime_ == null - ? com.google.protobuf.Timestamp.getDefaultInstance() - : lastStateTime_; - } else { - return lastStateTimeBuilder_.getMessage(); - } - } - /** - * - * - *
-     * [Output only] The last time a state event was received. Timestamps are
-     * periodically collected and written to storage; they may be stale by a few
-     * minutes.
-     * 
- * - * .google.protobuf.Timestamp last_state_time = 20; - */ - public Builder setLastStateTime(com.google.protobuf.Timestamp value) { - if (lastStateTimeBuilder_ == null) { - if (value == null) { - throw new NullPointerException(); - } - lastStateTime_ = value; - onChanged(); - } else { - lastStateTimeBuilder_.setMessage(value); - } - - return this; - } - /** - * - * - *
-     * [Output only] The last time a state event was received. Timestamps are
-     * periodically collected and written to storage; they may be stale by a few
-     * minutes.
-     * 
- * - * .google.protobuf.Timestamp last_state_time = 20; - */ - public Builder setLastStateTime(com.google.protobuf.Timestamp.Builder builderForValue) { - if (lastStateTimeBuilder_ == null) { - lastStateTime_ = builderForValue.build(); - onChanged(); - } else { - lastStateTimeBuilder_.setMessage(builderForValue.build()); - } - - return this; - } - /** - * - * - *
-     * [Output only] The last time a state event was received. Timestamps are
-     * periodically collected and written to storage; they may be stale by a few
-     * minutes.
-     * 
- * - * .google.protobuf.Timestamp last_state_time = 20; - */ - public Builder mergeLastStateTime(com.google.protobuf.Timestamp value) { - if (lastStateTimeBuilder_ == null) { - if (lastStateTime_ != null) { - lastStateTime_ = - com.google.protobuf.Timestamp.newBuilder(lastStateTime_) - .mergeFrom(value) - .buildPartial(); - } else { - lastStateTime_ = value; - } - onChanged(); - } else { - lastStateTimeBuilder_.mergeFrom(value); - } - - return this; - } - /** - * - * - *
-     * [Output only] The last time a state event was received. Timestamps are
-     * periodically collected and written to storage; they may be stale by a few
-     * minutes.
-     * 
- * - * .google.protobuf.Timestamp last_state_time = 20; - */ - public Builder clearLastStateTime() { - if (lastStateTimeBuilder_ == null) { - lastStateTime_ = null; - onChanged(); - } else { - lastStateTime_ = null; - lastStateTimeBuilder_ = null; - } - - return this; - } - /** - * - * - *
-     * [Output only] The last time a state event was received. Timestamps are
-     * periodically collected and written to storage; they may be stale by a few
-     * minutes.
-     * 
- * - * .google.protobuf.Timestamp last_state_time = 20; - */ - public com.google.protobuf.Timestamp.Builder getLastStateTimeBuilder() { - - onChanged(); - return getLastStateTimeFieldBuilder().getBuilder(); - } - /** - * - * - *
-     * [Output only] The last time a state event was received. Timestamps are
-     * periodically collected and written to storage; they may be stale by a few
-     * minutes.
-     * 
- * - * .google.protobuf.Timestamp last_state_time = 20; - */ - public com.google.protobuf.TimestampOrBuilder getLastStateTimeOrBuilder() { - if (lastStateTimeBuilder_ != null) { - return lastStateTimeBuilder_.getMessageOrBuilder(); - } else { - return lastStateTime_ == null - ? com.google.protobuf.Timestamp.getDefaultInstance() - : lastStateTime_; - } - } - /** - * - * - *
-     * [Output only] The last time a state event was received. Timestamps are
-     * periodically collected and written to storage; they may be stale by a few
-     * minutes.
-     * 
- * - * .google.protobuf.Timestamp last_state_time = 20; - */ - private com.google.protobuf.SingleFieldBuilderV3< - com.google.protobuf.Timestamp, - com.google.protobuf.Timestamp.Builder, - com.google.protobuf.TimestampOrBuilder> - getLastStateTimeFieldBuilder() { - if (lastStateTimeBuilder_ == null) { - lastStateTimeBuilder_ = - new com.google.protobuf.SingleFieldBuilderV3< - com.google.protobuf.Timestamp, - com.google.protobuf.Timestamp.Builder, - com.google.protobuf.TimestampOrBuilder>( - getLastStateTime(), getParentForChildren(), isClean()); - lastStateTime_ = null; - } - return lastStateTimeBuilder_; - } - - private com.google.protobuf.Timestamp lastConfigAckTime_; - private com.google.protobuf.SingleFieldBuilderV3< - com.google.protobuf.Timestamp, - com.google.protobuf.Timestamp.Builder, - com.google.protobuf.TimestampOrBuilder> - lastConfigAckTimeBuilder_; - /** - * - * - *
-     * [Output only] The last time a cloud-to-device config version acknowledgment
-     * was received from the device. This field is only for configurations
-     * sent through MQTT.
-     * 
- * - * .google.protobuf.Timestamp last_config_ack_time = 14; - * - * @return Whether the lastConfigAckTime field is set. - */ - public boolean hasLastConfigAckTime() { - return lastConfigAckTimeBuilder_ != null || lastConfigAckTime_ != null; - } - /** - * - * - *
-     * [Output only] The last time a cloud-to-device config version acknowledgment
-     * was received from the device. This field is only for configurations
-     * sent through MQTT.
-     * 
- * - * .google.protobuf.Timestamp last_config_ack_time = 14; - * - * @return The lastConfigAckTime. - */ - public com.google.protobuf.Timestamp getLastConfigAckTime() { - if (lastConfigAckTimeBuilder_ == null) { - return lastConfigAckTime_ == null - ? com.google.protobuf.Timestamp.getDefaultInstance() - : lastConfigAckTime_; - } else { - return lastConfigAckTimeBuilder_.getMessage(); - } - } - /** - * - * - *
-     * [Output only] The last time a cloud-to-device config version acknowledgment
-     * was received from the device. This field is only for configurations
-     * sent through MQTT.
-     * 
- * - * .google.protobuf.Timestamp last_config_ack_time = 14; - */ - public Builder setLastConfigAckTime(com.google.protobuf.Timestamp value) { - if (lastConfigAckTimeBuilder_ == null) { - if (value == null) { - throw new NullPointerException(); - } - lastConfigAckTime_ = value; - onChanged(); - } else { - lastConfigAckTimeBuilder_.setMessage(value); - } - - return this; - } - /** - * - * - *
-     * [Output only] The last time a cloud-to-device config version acknowledgment
-     * was received from the device. This field is only for configurations
-     * sent through MQTT.
-     * 
- * - * .google.protobuf.Timestamp last_config_ack_time = 14; - */ - public Builder setLastConfigAckTime(com.google.protobuf.Timestamp.Builder builderForValue) { - if (lastConfigAckTimeBuilder_ == null) { - lastConfigAckTime_ = builderForValue.build(); - onChanged(); - } else { - lastConfigAckTimeBuilder_.setMessage(builderForValue.build()); - } - - return this; - } - /** - * - * - *
-     * [Output only] The last time a cloud-to-device config version acknowledgment
-     * was received from the device. This field is only for configurations
-     * sent through MQTT.
-     * 
- * - * .google.protobuf.Timestamp last_config_ack_time = 14; - */ - public Builder mergeLastConfigAckTime(com.google.protobuf.Timestamp value) { - if (lastConfigAckTimeBuilder_ == null) { - if (lastConfigAckTime_ != null) { - lastConfigAckTime_ = - com.google.protobuf.Timestamp.newBuilder(lastConfigAckTime_) - .mergeFrom(value) - .buildPartial(); - } else { - lastConfigAckTime_ = value; - } - onChanged(); - } else { - lastConfigAckTimeBuilder_.mergeFrom(value); - } - - return this; - } - /** - * - * - *
-     * [Output only] The last time a cloud-to-device config version acknowledgment
-     * was received from the device. This field is only for configurations
-     * sent through MQTT.
-     * 
- * - * .google.protobuf.Timestamp last_config_ack_time = 14; - */ - public Builder clearLastConfigAckTime() { - if (lastConfigAckTimeBuilder_ == null) { - lastConfigAckTime_ = null; - onChanged(); - } else { - lastConfigAckTime_ = null; - lastConfigAckTimeBuilder_ = null; - } - - return this; - } - /** - * - * - *
-     * [Output only] The last time a cloud-to-device config version acknowledgment
-     * was received from the device. This field is only for configurations
-     * sent through MQTT.
-     * 
- * - * .google.protobuf.Timestamp last_config_ack_time = 14; - */ - public com.google.protobuf.Timestamp.Builder getLastConfigAckTimeBuilder() { - - onChanged(); - return getLastConfigAckTimeFieldBuilder().getBuilder(); - } - /** - * - * - *
-     * [Output only] The last time a cloud-to-device config version acknowledgment
-     * was received from the device. This field is only for configurations
-     * sent through MQTT.
-     * 
- * - * .google.protobuf.Timestamp last_config_ack_time = 14; - */ - public com.google.protobuf.TimestampOrBuilder getLastConfigAckTimeOrBuilder() { - if (lastConfigAckTimeBuilder_ != null) { - return lastConfigAckTimeBuilder_.getMessageOrBuilder(); - } else { - return lastConfigAckTime_ == null - ? com.google.protobuf.Timestamp.getDefaultInstance() - : lastConfigAckTime_; - } - } - /** - * - * - *
-     * [Output only] The last time a cloud-to-device config version acknowledgment
-     * was received from the device. This field is only for configurations
-     * sent through MQTT.
-     * 
- * - * .google.protobuf.Timestamp last_config_ack_time = 14; - */ - private com.google.protobuf.SingleFieldBuilderV3< - com.google.protobuf.Timestamp, - com.google.protobuf.Timestamp.Builder, - com.google.protobuf.TimestampOrBuilder> - getLastConfigAckTimeFieldBuilder() { - if (lastConfigAckTimeBuilder_ == null) { - lastConfigAckTimeBuilder_ = - new com.google.protobuf.SingleFieldBuilderV3< - com.google.protobuf.Timestamp, - com.google.protobuf.Timestamp.Builder, - com.google.protobuf.TimestampOrBuilder>( - getLastConfigAckTime(), getParentForChildren(), isClean()); - lastConfigAckTime_ = null; - } - return lastConfigAckTimeBuilder_; - } - - private com.google.protobuf.Timestamp lastConfigSendTime_; - private com.google.protobuf.SingleFieldBuilderV3< - com.google.protobuf.Timestamp, - com.google.protobuf.Timestamp.Builder, - com.google.protobuf.TimestampOrBuilder> - lastConfigSendTimeBuilder_; - /** - * - * - *
-     * [Output only] The last time a cloud-to-device config version was sent to
-     * the device.
-     * 
- * - * .google.protobuf.Timestamp last_config_send_time = 18; - * - * @return Whether the lastConfigSendTime field is set. - */ - public boolean hasLastConfigSendTime() { - return lastConfigSendTimeBuilder_ != null || lastConfigSendTime_ != null; - } - /** - * - * - *
-     * [Output only] The last time a cloud-to-device config version was sent to
-     * the device.
-     * 
- * - * .google.protobuf.Timestamp last_config_send_time = 18; - * - * @return The lastConfigSendTime. - */ - public com.google.protobuf.Timestamp getLastConfigSendTime() { - if (lastConfigSendTimeBuilder_ == null) { - return lastConfigSendTime_ == null - ? com.google.protobuf.Timestamp.getDefaultInstance() - : lastConfigSendTime_; - } else { - return lastConfigSendTimeBuilder_.getMessage(); - } - } - /** - * - * - *
-     * [Output only] The last time a cloud-to-device config version was sent to
-     * the device.
-     * 
- * - * .google.protobuf.Timestamp last_config_send_time = 18; - */ - public Builder setLastConfigSendTime(com.google.protobuf.Timestamp value) { - if (lastConfigSendTimeBuilder_ == null) { - if (value == null) { - throw new NullPointerException(); - } - lastConfigSendTime_ = value; - onChanged(); - } else { - lastConfigSendTimeBuilder_.setMessage(value); - } - - return this; - } - /** - * - * - *
-     * [Output only] The last time a cloud-to-device config version was sent to
-     * the device.
-     * 
- * - * .google.protobuf.Timestamp last_config_send_time = 18; - */ - public Builder setLastConfigSendTime(com.google.protobuf.Timestamp.Builder builderForValue) { - if (lastConfigSendTimeBuilder_ == null) { - lastConfigSendTime_ = builderForValue.build(); - onChanged(); - } else { - lastConfigSendTimeBuilder_.setMessage(builderForValue.build()); - } - - return this; - } - /** - * - * - *
-     * [Output only] The last time a cloud-to-device config version was sent to
-     * the device.
-     * 
- * - * .google.protobuf.Timestamp last_config_send_time = 18; - */ - public Builder mergeLastConfigSendTime(com.google.protobuf.Timestamp value) { - if (lastConfigSendTimeBuilder_ == null) { - if (lastConfigSendTime_ != null) { - lastConfigSendTime_ = - com.google.protobuf.Timestamp.newBuilder(lastConfigSendTime_) - .mergeFrom(value) - .buildPartial(); - } else { - lastConfigSendTime_ = value; - } - onChanged(); - } else { - lastConfigSendTimeBuilder_.mergeFrom(value); - } - - return this; - } - /** - * - * - *
-     * [Output only] The last time a cloud-to-device config version was sent to
-     * the device.
-     * 
- * - * .google.protobuf.Timestamp last_config_send_time = 18; - */ - public Builder clearLastConfigSendTime() { - if (lastConfigSendTimeBuilder_ == null) { - lastConfigSendTime_ = null; - onChanged(); - } else { - lastConfigSendTime_ = null; - lastConfigSendTimeBuilder_ = null; - } - - return this; - } - /** - * - * - *
-     * [Output only] The last time a cloud-to-device config version was sent to
-     * the device.
-     * 
- * - * .google.protobuf.Timestamp last_config_send_time = 18; - */ - public com.google.protobuf.Timestamp.Builder getLastConfigSendTimeBuilder() { - - onChanged(); - return getLastConfigSendTimeFieldBuilder().getBuilder(); - } - /** - * - * - *
-     * [Output only] The last time a cloud-to-device config version was sent to
-     * the device.
-     * 
- * - * .google.protobuf.Timestamp last_config_send_time = 18; - */ - public com.google.protobuf.TimestampOrBuilder getLastConfigSendTimeOrBuilder() { - if (lastConfigSendTimeBuilder_ != null) { - return lastConfigSendTimeBuilder_.getMessageOrBuilder(); - } else { - return lastConfigSendTime_ == null - ? com.google.protobuf.Timestamp.getDefaultInstance() - : lastConfigSendTime_; - } - } - /** - * - * - *
-     * [Output only] The last time a cloud-to-device config version was sent to
-     * the device.
-     * 
- * - * .google.protobuf.Timestamp last_config_send_time = 18; - */ - private com.google.protobuf.SingleFieldBuilderV3< - com.google.protobuf.Timestamp, - com.google.protobuf.Timestamp.Builder, - com.google.protobuf.TimestampOrBuilder> - getLastConfigSendTimeFieldBuilder() { - if (lastConfigSendTimeBuilder_ == null) { - lastConfigSendTimeBuilder_ = - new com.google.protobuf.SingleFieldBuilderV3< - com.google.protobuf.Timestamp, - com.google.protobuf.Timestamp.Builder, - com.google.protobuf.TimestampOrBuilder>( - getLastConfigSendTime(), getParentForChildren(), isClean()); - lastConfigSendTime_ = null; - } - return lastConfigSendTimeBuilder_; - } - - private boolean blocked_; - /** - * - * - *
-     * If a device is blocked, connections or requests from this device will fail.
-     * Can be used to temporarily prevent the device from connecting if, for
-     * example, the sensor is generating bad data and needs maintenance.
-     * 
- * - * bool blocked = 19; - * - * @return The blocked. - */ - @java.lang.Override - public boolean getBlocked() { - return blocked_; - } - /** - * - * - *
-     * If a device is blocked, connections or requests from this device will fail.
-     * Can be used to temporarily prevent the device from connecting if, for
-     * example, the sensor is generating bad data and needs maintenance.
-     * 
- * - * bool blocked = 19; - * - * @param value The blocked to set. - * @return This builder for chaining. - */ - public Builder setBlocked(boolean value) { - - blocked_ = value; - onChanged(); - return this; - } - /** - * - * - *
-     * If a device is blocked, connections or requests from this device will fail.
-     * Can be used to temporarily prevent the device from connecting if, for
-     * example, the sensor is generating bad data and needs maintenance.
-     * 
- * - * bool blocked = 19; - * - * @return This builder for chaining. - */ - public Builder clearBlocked() { - - blocked_ = false; - onChanged(); - return this; - } - - private com.google.protobuf.Timestamp lastErrorTime_; - private com.google.protobuf.SingleFieldBuilderV3< - com.google.protobuf.Timestamp, - com.google.protobuf.Timestamp.Builder, - com.google.protobuf.TimestampOrBuilder> - lastErrorTimeBuilder_; - /** - * - * - *
-     * [Output only] The time the most recent error occurred, such as a failure to
-     * publish to Cloud Pub/Sub. This field is the timestamp of
-     * 'last_error_status'.
-     * 
- * - * .google.protobuf.Timestamp last_error_time = 10; - * - * @return Whether the lastErrorTime field is set. - */ - public boolean hasLastErrorTime() { - return lastErrorTimeBuilder_ != null || lastErrorTime_ != null; - } - /** - * - * - *
-     * [Output only] The time the most recent error occurred, such as a failure to
-     * publish to Cloud Pub/Sub. This field is the timestamp of
-     * 'last_error_status'.
-     * 
- * - * .google.protobuf.Timestamp last_error_time = 10; - * - * @return The lastErrorTime. - */ - public com.google.protobuf.Timestamp getLastErrorTime() { - if (lastErrorTimeBuilder_ == null) { - return lastErrorTime_ == null - ? com.google.protobuf.Timestamp.getDefaultInstance() - : lastErrorTime_; - } else { - return lastErrorTimeBuilder_.getMessage(); - } - } - /** - * - * - *
-     * [Output only] The time the most recent error occurred, such as a failure to
-     * publish to Cloud Pub/Sub. This field is the timestamp of
-     * 'last_error_status'.
-     * 
- * - * .google.protobuf.Timestamp last_error_time = 10; - */ - public Builder setLastErrorTime(com.google.protobuf.Timestamp value) { - if (lastErrorTimeBuilder_ == null) { - if (value == null) { - throw new NullPointerException(); - } - lastErrorTime_ = value; - onChanged(); - } else { - lastErrorTimeBuilder_.setMessage(value); - } - - return this; - } - /** - * - * - *
-     * [Output only] The time the most recent error occurred, such as a failure to
-     * publish to Cloud Pub/Sub. This field is the timestamp of
-     * 'last_error_status'.
-     * 
- * - * .google.protobuf.Timestamp last_error_time = 10; - */ - public Builder setLastErrorTime(com.google.protobuf.Timestamp.Builder builderForValue) { - if (lastErrorTimeBuilder_ == null) { - lastErrorTime_ = builderForValue.build(); - onChanged(); - } else { - lastErrorTimeBuilder_.setMessage(builderForValue.build()); - } - - return this; - } - /** - * - * - *
-     * [Output only] The time the most recent error occurred, such as a failure to
-     * publish to Cloud Pub/Sub. This field is the timestamp of
-     * 'last_error_status'.
-     * 
- * - * .google.protobuf.Timestamp last_error_time = 10; - */ - public Builder mergeLastErrorTime(com.google.protobuf.Timestamp value) { - if (lastErrorTimeBuilder_ == null) { - if (lastErrorTime_ != null) { - lastErrorTime_ = - com.google.protobuf.Timestamp.newBuilder(lastErrorTime_) - .mergeFrom(value) - .buildPartial(); - } else { - lastErrorTime_ = value; - } - onChanged(); - } else { - lastErrorTimeBuilder_.mergeFrom(value); - } - - return this; - } - /** - * - * - *
-     * [Output only] The time the most recent error occurred, such as a failure to
-     * publish to Cloud Pub/Sub. This field is the timestamp of
-     * 'last_error_status'.
-     * 
- * - * .google.protobuf.Timestamp last_error_time = 10; - */ - public Builder clearLastErrorTime() { - if (lastErrorTimeBuilder_ == null) { - lastErrorTime_ = null; - onChanged(); - } else { - lastErrorTime_ = null; - lastErrorTimeBuilder_ = null; - } - - return this; - } - /** - * - * - *
-     * [Output only] The time the most recent error occurred, such as a failure to
-     * publish to Cloud Pub/Sub. This field is the timestamp of
-     * 'last_error_status'.
-     * 
- * - * .google.protobuf.Timestamp last_error_time = 10; - */ - public com.google.protobuf.Timestamp.Builder getLastErrorTimeBuilder() { - - onChanged(); - return getLastErrorTimeFieldBuilder().getBuilder(); - } - /** - * - * - *
-     * [Output only] The time the most recent error occurred, such as a failure to
-     * publish to Cloud Pub/Sub. This field is the timestamp of
-     * 'last_error_status'.
-     * 
- * - * .google.protobuf.Timestamp last_error_time = 10; - */ - public com.google.protobuf.TimestampOrBuilder getLastErrorTimeOrBuilder() { - if (lastErrorTimeBuilder_ != null) { - return lastErrorTimeBuilder_.getMessageOrBuilder(); - } else { - return lastErrorTime_ == null - ? com.google.protobuf.Timestamp.getDefaultInstance() - : lastErrorTime_; - } - } - /** - * - * - *
-     * [Output only] The time the most recent error occurred, such as a failure to
-     * publish to Cloud Pub/Sub. This field is the timestamp of
-     * 'last_error_status'.
-     * 
- * - * .google.protobuf.Timestamp last_error_time = 10; - */ - private com.google.protobuf.SingleFieldBuilderV3< - com.google.protobuf.Timestamp, - com.google.protobuf.Timestamp.Builder, - com.google.protobuf.TimestampOrBuilder> - getLastErrorTimeFieldBuilder() { - if (lastErrorTimeBuilder_ == null) { - lastErrorTimeBuilder_ = - new com.google.protobuf.SingleFieldBuilderV3< - com.google.protobuf.Timestamp, - com.google.protobuf.Timestamp.Builder, - com.google.protobuf.TimestampOrBuilder>( - getLastErrorTime(), getParentForChildren(), isClean()); - lastErrorTime_ = null; - } - return lastErrorTimeBuilder_; - } - - private com.google.rpc.Status lastErrorStatus_; - private com.google.protobuf.SingleFieldBuilderV3< - com.google.rpc.Status, com.google.rpc.Status.Builder, com.google.rpc.StatusOrBuilder> - lastErrorStatusBuilder_; - /** - * - * - *
-     * [Output only] The error message of the most recent error, such as a failure
-     * to publish to Cloud Pub/Sub. 'last_error_time' is the timestamp of this
-     * field. If no errors have occurred, this field has an empty message
-     * and the status code 0 == OK. Otherwise, this field is expected to have a
-     * status code other than OK.
-     * 
- * - * .google.rpc.Status last_error_status = 11; - * - * @return Whether the lastErrorStatus field is set. - */ - public boolean hasLastErrorStatus() { - return lastErrorStatusBuilder_ != null || lastErrorStatus_ != null; - } - /** - * - * - *
-     * [Output only] The error message of the most recent error, such as a failure
-     * to publish to Cloud Pub/Sub. 'last_error_time' is the timestamp of this
-     * field. If no errors have occurred, this field has an empty message
-     * and the status code 0 == OK. Otherwise, this field is expected to have a
-     * status code other than OK.
-     * 
- * - * .google.rpc.Status last_error_status = 11; - * - * @return The lastErrorStatus. - */ - public com.google.rpc.Status getLastErrorStatus() { - if (lastErrorStatusBuilder_ == null) { - return lastErrorStatus_ == null - ? com.google.rpc.Status.getDefaultInstance() - : lastErrorStatus_; - } else { - return lastErrorStatusBuilder_.getMessage(); - } - } - /** - * - * - *
-     * [Output only] The error message of the most recent error, such as a failure
-     * to publish to Cloud Pub/Sub. 'last_error_time' is the timestamp of this
-     * field. If no errors have occurred, this field has an empty message
-     * and the status code 0 == OK. Otherwise, this field is expected to have a
-     * status code other than OK.
-     * 
- * - * .google.rpc.Status last_error_status = 11; - */ - public Builder setLastErrorStatus(com.google.rpc.Status value) { - if (lastErrorStatusBuilder_ == null) { - if (value == null) { - throw new NullPointerException(); - } - lastErrorStatus_ = value; - onChanged(); - } else { - lastErrorStatusBuilder_.setMessage(value); - } - - return this; - } - /** - * - * - *
-     * [Output only] The error message of the most recent error, such as a failure
-     * to publish to Cloud Pub/Sub. 'last_error_time' is the timestamp of this
-     * field. If no errors have occurred, this field has an empty message
-     * and the status code 0 == OK. Otherwise, this field is expected to have a
-     * status code other than OK.
-     * 
- * - * .google.rpc.Status last_error_status = 11; - */ - public Builder setLastErrorStatus(com.google.rpc.Status.Builder builderForValue) { - if (lastErrorStatusBuilder_ == null) { - lastErrorStatus_ = builderForValue.build(); - onChanged(); - } else { - lastErrorStatusBuilder_.setMessage(builderForValue.build()); - } - - return this; - } - /** - * - * - *
-     * [Output only] The error message of the most recent error, such as a failure
-     * to publish to Cloud Pub/Sub. 'last_error_time' is the timestamp of this
-     * field. If no errors have occurred, this field has an empty message
-     * and the status code 0 == OK. Otherwise, this field is expected to have a
-     * status code other than OK.
-     * 
- * - * .google.rpc.Status last_error_status = 11; - */ - public Builder mergeLastErrorStatus(com.google.rpc.Status value) { - if (lastErrorStatusBuilder_ == null) { - if (lastErrorStatus_ != null) { - lastErrorStatus_ = - com.google.rpc.Status.newBuilder(lastErrorStatus_).mergeFrom(value).buildPartial(); - } else { - lastErrorStatus_ = value; - } - onChanged(); - } else { - lastErrorStatusBuilder_.mergeFrom(value); - } - - return this; - } - /** - * - * - *
-     * [Output only] The error message of the most recent error, such as a failure
-     * to publish to Cloud Pub/Sub. 'last_error_time' is the timestamp of this
-     * field. If no errors have occurred, this field has an empty message
-     * and the status code 0 == OK. Otherwise, this field is expected to have a
-     * status code other than OK.
-     * 
- * - * .google.rpc.Status last_error_status = 11; - */ - public Builder clearLastErrorStatus() { - if (lastErrorStatusBuilder_ == null) { - lastErrorStatus_ = null; - onChanged(); - } else { - lastErrorStatus_ = null; - lastErrorStatusBuilder_ = null; - } - - return this; - } - /** - * - * - *
-     * [Output only] The error message of the most recent error, such as a failure
-     * to publish to Cloud Pub/Sub. 'last_error_time' is the timestamp of this
-     * field. If no errors have occurred, this field has an empty message
-     * and the status code 0 == OK. Otherwise, this field is expected to have a
-     * status code other than OK.
-     * 
- * - * .google.rpc.Status last_error_status = 11; - */ - public com.google.rpc.Status.Builder getLastErrorStatusBuilder() { - - onChanged(); - return getLastErrorStatusFieldBuilder().getBuilder(); - } - /** - * - * - *
-     * [Output only] The error message of the most recent error, such as a failure
-     * to publish to Cloud Pub/Sub. 'last_error_time' is the timestamp of this
-     * field. If no errors have occurred, this field has an empty message
-     * and the status code 0 == OK. Otherwise, this field is expected to have a
-     * status code other than OK.
-     * 
- * - * .google.rpc.Status last_error_status = 11; - */ - public com.google.rpc.StatusOrBuilder getLastErrorStatusOrBuilder() { - if (lastErrorStatusBuilder_ != null) { - return lastErrorStatusBuilder_.getMessageOrBuilder(); - } else { - return lastErrorStatus_ == null - ? com.google.rpc.Status.getDefaultInstance() - : lastErrorStatus_; - } - } - /** - * - * - *
-     * [Output only] The error message of the most recent error, such as a failure
-     * to publish to Cloud Pub/Sub. 'last_error_time' is the timestamp of this
-     * field. If no errors have occurred, this field has an empty message
-     * and the status code 0 == OK. Otherwise, this field is expected to have a
-     * status code other than OK.
-     * 
- * - * .google.rpc.Status last_error_status = 11; - */ - private com.google.protobuf.SingleFieldBuilderV3< - com.google.rpc.Status, com.google.rpc.Status.Builder, com.google.rpc.StatusOrBuilder> - getLastErrorStatusFieldBuilder() { - if (lastErrorStatusBuilder_ == null) { - lastErrorStatusBuilder_ = - new com.google.protobuf.SingleFieldBuilderV3< - com.google.rpc.Status, - com.google.rpc.Status.Builder, - com.google.rpc.StatusOrBuilder>( - getLastErrorStatus(), getParentForChildren(), isClean()); - lastErrorStatus_ = null; - } - return lastErrorStatusBuilder_; - } - - private com.google.cloud.iot.v1.DeviceConfig config_; - private com.google.protobuf.SingleFieldBuilderV3< - com.google.cloud.iot.v1.DeviceConfig, - com.google.cloud.iot.v1.DeviceConfig.Builder, - com.google.cloud.iot.v1.DeviceConfigOrBuilder> - configBuilder_; - /** - * - * - *
-     * The most recent device configuration, which is eventually sent from
-     * Cloud IoT Core to the device. If not present on creation, the
-     * configuration will be initialized with an empty payload and version value
-     * of `1`. To update this field after creation, use the
-     * `DeviceManager.ModifyCloudToDeviceConfig` method.
-     * 
- * - * .google.cloud.iot.v1.DeviceConfig config = 13; - * - * @return Whether the config field is set. - */ - public boolean hasConfig() { - return configBuilder_ != null || config_ != null; - } - /** - * - * - *
-     * The most recent device configuration, which is eventually sent from
-     * Cloud IoT Core to the device. If not present on creation, the
-     * configuration will be initialized with an empty payload and version value
-     * of `1`. To update this field after creation, use the
-     * `DeviceManager.ModifyCloudToDeviceConfig` method.
-     * 
- * - * .google.cloud.iot.v1.DeviceConfig config = 13; - * - * @return The config. - */ - public com.google.cloud.iot.v1.DeviceConfig getConfig() { - if (configBuilder_ == null) { - return config_ == null - ? com.google.cloud.iot.v1.DeviceConfig.getDefaultInstance() - : config_; - } else { - return configBuilder_.getMessage(); - } - } - /** - * - * - *
-     * The most recent device configuration, which is eventually sent from
-     * Cloud IoT Core to the device. If not present on creation, the
-     * configuration will be initialized with an empty payload and version value
-     * of `1`. To update this field after creation, use the
-     * `DeviceManager.ModifyCloudToDeviceConfig` method.
-     * 
- * - * .google.cloud.iot.v1.DeviceConfig config = 13; - */ - public Builder setConfig(com.google.cloud.iot.v1.DeviceConfig value) { - if (configBuilder_ == null) { - if (value == null) { - throw new NullPointerException(); - } - config_ = value; - onChanged(); - } else { - configBuilder_.setMessage(value); - } - - return this; - } - /** - * - * - *
-     * The most recent device configuration, which is eventually sent from
-     * Cloud IoT Core to the device. If not present on creation, the
-     * configuration will be initialized with an empty payload and version value
-     * of `1`. To update this field after creation, use the
-     * `DeviceManager.ModifyCloudToDeviceConfig` method.
-     * 
- * - * .google.cloud.iot.v1.DeviceConfig config = 13; - */ - public Builder setConfig(com.google.cloud.iot.v1.DeviceConfig.Builder builderForValue) { - if (configBuilder_ == null) { - config_ = builderForValue.build(); - onChanged(); - } else { - configBuilder_.setMessage(builderForValue.build()); - } - - return this; - } - /** - * - * - *
-     * The most recent device configuration, which is eventually sent from
-     * Cloud IoT Core to the device. If not present on creation, the
-     * configuration will be initialized with an empty payload and version value
-     * of `1`. To update this field after creation, use the
-     * `DeviceManager.ModifyCloudToDeviceConfig` method.
-     * 
- * - * .google.cloud.iot.v1.DeviceConfig config = 13; - */ - public Builder mergeConfig(com.google.cloud.iot.v1.DeviceConfig value) { - if (configBuilder_ == null) { - if (config_ != null) { - config_ = - com.google.cloud.iot.v1.DeviceConfig.newBuilder(config_) - .mergeFrom(value) - .buildPartial(); - } else { - config_ = value; - } - onChanged(); - } else { - configBuilder_.mergeFrom(value); - } - - return this; - } - /** - * - * - *
-     * The most recent device configuration, which is eventually sent from
-     * Cloud IoT Core to the device. If not present on creation, the
-     * configuration will be initialized with an empty payload and version value
-     * of `1`. To update this field after creation, use the
-     * `DeviceManager.ModifyCloudToDeviceConfig` method.
-     * 
- * - * .google.cloud.iot.v1.DeviceConfig config = 13; - */ - public Builder clearConfig() { - if (configBuilder_ == null) { - config_ = null; - onChanged(); - } else { - config_ = null; - configBuilder_ = null; - } - - return this; - } - /** - * - * - *
-     * The most recent device configuration, which is eventually sent from
-     * Cloud IoT Core to the device. If not present on creation, the
-     * configuration will be initialized with an empty payload and version value
-     * of `1`. To update this field after creation, use the
-     * `DeviceManager.ModifyCloudToDeviceConfig` method.
-     * 
- * - * .google.cloud.iot.v1.DeviceConfig config = 13; - */ - public com.google.cloud.iot.v1.DeviceConfig.Builder getConfigBuilder() { - - onChanged(); - return getConfigFieldBuilder().getBuilder(); - } - /** - * - * - *
-     * The most recent device configuration, which is eventually sent from
-     * Cloud IoT Core to the device. If not present on creation, the
-     * configuration will be initialized with an empty payload and version value
-     * of `1`. To update this field after creation, use the
-     * `DeviceManager.ModifyCloudToDeviceConfig` method.
-     * 
- * - * .google.cloud.iot.v1.DeviceConfig config = 13; - */ - public com.google.cloud.iot.v1.DeviceConfigOrBuilder getConfigOrBuilder() { - if (configBuilder_ != null) { - return configBuilder_.getMessageOrBuilder(); - } else { - return config_ == null - ? com.google.cloud.iot.v1.DeviceConfig.getDefaultInstance() - : config_; - } - } - /** - * - * - *
-     * The most recent device configuration, which is eventually sent from
-     * Cloud IoT Core to the device. If not present on creation, the
-     * configuration will be initialized with an empty payload and version value
-     * of `1`. To update this field after creation, use the
-     * `DeviceManager.ModifyCloudToDeviceConfig` method.
-     * 
- * - * .google.cloud.iot.v1.DeviceConfig config = 13; - */ - private com.google.protobuf.SingleFieldBuilderV3< - com.google.cloud.iot.v1.DeviceConfig, - com.google.cloud.iot.v1.DeviceConfig.Builder, - com.google.cloud.iot.v1.DeviceConfigOrBuilder> - getConfigFieldBuilder() { - if (configBuilder_ == null) { - configBuilder_ = - new com.google.protobuf.SingleFieldBuilderV3< - com.google.cloud.iot.v1.DeviceConfig, - com.google.cloud.iot.v1.DeviceConfig.Builder, - com.google.cloud.iot.v1.DeviceConfigOrBuilder>( - getConfig(), getParentForChildren(), isClean()); - config_ = null; - } - return configBuilder_; - } - - private com.google.cloud.iot.v1.DeviceState state_; - private com.google.protobuf.SingleFieldBuilderV3< - com.google.cloud.iot.v1.DeviceState, - com.google.cloud.iot.v1.DeviceState.Builder, - com.google.cloud.iot.v1.DeviceStateOrBuilder> - stateBuilder_; - /** - * - * - *
-     * [Output only] The state most recently received from the device. If no state
-     * has been reported, this field is not present.
-     * 
- * - * .google.cloud.iot.v1.DeviceState state = 16; - * - * @return Whether the state field is set. - */ - public boolean hasState() { - return stateBuilder_ != null || state_ != null; - } - /** - * - * - *
-     * [Output only] The state most recently received from the device. If no state
-     * has been reported, this field is not present.
-     * 
- * - * .google.cloud.iot.v1.DeviceState state = 16; - * - * @return The state. - */ - public com.google.cloud.iot.v1.DeviceState getState() { - if (stateBuilder_ == null) { - return state_ == null ? com.google.cloud.iot.v1.DeviceState.getDefaultInstance() : state_; - } else { - return stateBuilder_.getMessage(); - } - } - /** - * - * - *
-     * [Output only] The state most recently received from the device. If no state
-     * has been reported, this field is not present.
-     * 
- * - * .google.cloud.iot.v1.DeviceState state = 16; - */ - public Builder setState(com.google.cloud.iot.v1.DeviceState value) { - if (stateBuilder_ == null) { - if (value == null) { - throw new NullPointerException(); - } - state_ = value; - onChanged(); - } else { - stateBuilder_.setMessage(value); - } - - return this; - } - /** - * - * - *
-     * [Output only] The state most recently received from the device. If no state
-     * has been reported, this field is not present.
-     * 
- * - * .google.cloud.iot.v1.DeviceState state = 16; - */ - public Builder setState(com.google.cloud.iot.v1.DeviceState.Builder builderForValue) { - if (stateBuilder_ == null) { - state_ = builderForValue.build(); - onChanged(); - } else { - stateBuilder_.setMessage(builderForValue.build()); - } - - return this; - } - /** - * - * - *
-     * [Output only] The state most recently received from the device. If no state
-     * has been reported, this field is not present.
-     * 
- * - * .google.cloud.iot.v1.DeviceState state = 16; - */ - public Builder mergeState(com.google.cloud.iot.v1.DeviceState value) { - if (stateBuilder_ == null) { - if (state_ != null) { - state_ = - com.google.cloud.iot.v1.DeviceState.newBuilder(state_) - .mergeFrom(value) - .buildPartial(); - } else { - state_ = value; - } - onChanged(); - } else { - stateBuilder_.mergeFrom(value); - } - - return this; - } - /** - * - * - *
-     * [Output only] The state most recently received from the device. If no state
-     * has been reported, this field is not present.
-     * 
- * - * .google.cloud.iot.v1.DeviceState state = 16; - */ - public Builder clearState() { - if (stateBuilder_ == null) { - state_ = null; - onChanged(); - } else { - state_ = null; - stateBuilder_ = null; - } - - return this; - } - /** - * - * - *
-     * [Output only] The state most recently received from the device. If no state
-     * has been reported, this field is not present.
-     * 
- * - * .google.cloud.iot.v1.DeviceState state = 16; - */ - public com.google.cloud.iot.v1.DeviceState.Builder getStateBuilder() { - - onChanged(); - return getStateFieldBuilder().getBuilder(); - } - /** - * - * - *
-     * [Output only] The state most recently received from the device. If no state
-     * has been reported, this field is not present.
-     * 
- * - * .google.cloud.iot.v1.DeviceState state = 16; - */ - public com.google.cloud.iot.v1.DeviceStateOrBuilder getStateOrBuilder() { - if (stateBuilder_ != null) { - return stateBuilder_.getMessageOrBuilder(); - } else { - return state_ == null ? com.google.cloud.iot.v1.DeviceState.getDefaultInstance() : state_; - } - } - /** - * - * - *
-     * [Output only] The state most recently received from the device. If no state
-     * has been reported, this field is not present.
-     * 
- * - * .google.cloud.iot.v1.DeviceState state = 16; - */ - private com.google.protobuf.SingleFieldBuilderV3< - com.google.cloud.iot.v1.DeviceState, - com.google.cloud.iot.v1.DeviceState.Builder, - com.google.cloud.iot.v1.DeviceStateOrBuilder> - getStateFieldBuilder() { - if (stateBuilder_ == null) { - stateBuilder_ = - new com.google.protobuf.SingleFieldBuilderV3< - com.google.cloud.iot.v1.DeviceState, - com.google.cloud.iot.v1.DeviceState.Builder, - com.google.cloud.iot.v1.DeviceStateOrBuilder>( - getState(), getParentForChildren(), isClean()); - state_ = null; - } - return stateBuilder_; - } - - private int logLevel_ = 0; - /** - * - * - *
-     * **Beta Feature**
-     * The logging verbosity for device activity. If unspecified,
-     * DeviceRegistry.log_level will be used.
-     * 
- * - * .google.cloud.iot.v1.LogLevel log_level = 21; - * - * @return The enum numeric value on the wire for logLevel. - */ - @java.lang.Override - public int getLogLevelValue() { - return logLevel_; - } - /** - * - * - *
-     * **Beta Feature**
-     * The logging verbosity for device activity. If unspecified,
-     * DeviceRegistry.log_level will be used.
-     * 
- * - * .google.cloud.iot.v1.LogLevel log_level = 21; - * - * @param value The enum numeric value on the wire for logLevel to set. - * @return This builder for chaining. - */ - public Builder setLogLevelValue(int value) { - - logLevel_ = value; - onChanged(); - return this; - } - /** - * - * - *
-     * **Beta Feature**
-     * The logging verbosity for device activity. If unspecified,
-     * DeviceRegistry.log_level will be used.
-     * 
- * - * .google.cloud.iot.v1.LogLevel log_level = 21; - * - * @return The logLevel. - */ - @java.lang.Override - public com.google.cloud.iot.v1.LogLevel getLogLevel() { - @SuppressWarnings("deprecation") - com.google.cloud.iot.v1.LogLevel result = com.google.cloud.iot.v1.LogLevel.valueOf(logLevel_); - return result == null ? com.google.cloud.iot.v1.LogLevel.UNRECOGNIZED : result; - } - /** - * - * - *
-     * **Beta Feature**
-     * The logging verbosity for device activity. If unspecified,
-     * DeviceRegistry.log_level will be used.
-     * 
- * - * .google.cloud.iot.v1.LogLevel log_level = 21; - * - * @param value The logLevel to set. - * @return This builder for chaining. - */ - public Builder setLogLevel(com.google.cloud.iot.v1.LogLevel value) { - if (value == null) { - throw new NullPointerException(); - } - - logLevel_ = value.getNumber(); - onChanged(); - return this; - } - /** - * - * - *
-     * **Beta Feature**
-     * The logging verbosity for device activity. If unspecified,
-     * DeviceRegistry.log_level will be used.
-     * 
- * - * .google.cloud.iot.v1.LogLevel log_level = 21; - * - * @return This builder for chaining. - */ - public Builder clearLogLevel() { - - logLevel_ = 0; - onChanged(); - return this; - } - - private com.google.protobuf.MapField metadata_; - - private com.google.protobuf.MapField internalGetMetadata() { - if (metadata_ == null) { - return com.google.protobuf.MapField.emptyMapField(MetadataDefaultEntryHolder.defaultEntry); - } - return metadata_; - } - - private com.google.protobuf.MapField - internalGetMutableMetadata() { - onChanged(); - ; - if (metadata_ == null) { - metadata_ = - com.google.protobuf.MapField.newMapField(MetadataDefaultEntryHolder.defaultEntry); - } - if (!metadata_.isMutable()) { - metadata_ = metadata_.copy(); - } - return metadata_; - } - - public int getMetadataCount() { - return internalGetMetadata().getMap().size(); - } - /** - * - * - *
-     * The metadata key-value pairs assigned to the device. This metadata is not
-     * interpreted or indexed by Cloud IoT Core. It can be used to add contextual
-     * information for the device.
-     * Keys must conform to the regular expression [a-zA-Z][a-zA-Z0-9-_.+~%]+ and
-     * be less than 128 bytes in length.
-     * Values are free-form strings. Each value must be less than or equal to 32
-     * KB in size.
-     * The total size of all keys and values must be less than 256 KB, and the
-     * maximum number of key-value pairs is 500.
-     * 
- * - * map<string, string> metadata = 17; - */ - @java.lang.Override - public boolean containsMetadata(java.lang.String key) { - if (key == null) { - throw new NullPointerException("map key"); - } - return internalGetMetadata().getMap().containsKey(key); - } - /** Use {@link #getMetadataMap()} instead. */ - @java.lang.Override - @java.lang.Deprecated - public java.util.Map getMetadata() { - return getMetadataMap(); - } - /** - * - * - *
-     * The metadata key-value pairs assigned to the device. This metadata is not
-     * interpreted or indexed by Cloud IoT Core. It can be used to add contextual
-     * information for the device.
-     * Keys must conform to the regular expression [a-zA-Z][a-zA-Z0-9-_.+~%]+ and
-     * be less than 128 bytes in length.
-     * Values are free-form strings. Each value must be less than or equal to 32
-     * KB in size.
-     * The total size of all keys and values must be less than 256 KB, and the
-     * maximum number of key-value pairs is 500.
-     * 
- * - * map<string, string> metadata = 17; - */ - @java.lang.Override - public java.util.Map getMetadataMap() { - return internalGetMetadata().getMap(); - } - /** - * - * - *
-     * The metadata key-value pairs assigned to the device. This metadata is not
-     * interpreted or indexed by Cloud IoT Core. It can be used to add contextual
-     * information for the device.
-     * Keys must conform to the regular expression [a-zA-Z][a-zA-Z0-9-_.+~%]+ and
-     * be less than 128 bytes in length.
-     * Values are free-form strings. Each value must be less than or equal to 32
-     * KB in size.
-     * The total size of all keys and values must be less than 256 KB, and the
-     * maximum number of key-value pairs is 500.
-     * 
- * - * map<string, string> metadata = 17; - */ - @java.lang.Override - public java.lang.String getMetadataOrDefault( - java.lang.String key, java.lang.String defaultValue) { - if (key == null) { - throw new NullPointerException("map key"); - } - java.util.Map map = internalGetMetadata().getMap(); - return map.containsKey(key) ? map.get(key) : defaultValue; - } - /** - * - * - *
-     * The metadata key-value pairs assigned to the device. This metadata is not
-     * interpreted or indexed by Cloud IoT Core. It can be used to add contextual
-     * information for the device.
-     * Keys must conform to the regular expression [a-zA-Z][a-zA-Z0-9-_.+~%]+ and
-     * be less than 128 bytes in length.
-     * Values are free-form strings. Each value must be less than or equal to 32
-     * KB in size.
-     * The total size of all keys and values must be less than 256 KB, and the
-     * maximum number of key-value pairs is 500.
-     * 
- * - * map<string, string> metadata = 17; - */ - @java.lang.Override - public java.lang.String getMetadataOrThrow(java.lang.String key) { - if (key == null) { - throw new NullPointerException("map key"); - } - java.util.Map map = internalGetMetadata().getMap(); - if (!map.containsKey(key)) { - throw new java.lang.IllegalArgumentException(); - } - return map.get(key); - } - - public Builder clearMetadata() { - internalGetMutableMetadata().getMutableMap().clear(); - return this; - } - /** - * - * - *
-     * The metadata key-value pairs assigned to the device. This metadata is not
-     * interpreted or indexed by Cloud IoT Core. It can be used to add contextual
-     * information for the device.
-     * Keys must conform to the regular expression [a-zA-Z][a-zA-Z0-9-_.+~%]+ and
-     * be less than 128 bytes in length.
-     * Values are free-form strings. Each value must be less than or equal to 32
-     * KB in size.
-     * The total size of all keys and values must be less than 256 KB, and the
-     * maximum number of key-value pairs is 500.
-     * 
- * - * map<string, string> metadata = 17; - */ - public Builder removeMetadata(java.lang.String key) { - if (key == null) { - throw new NullPointerException("map key"); - } - internalGetMutableMetadata().getMutableMap().remove(key); - return this; - } - /** Use alternate mutation accessors instead. */ - @java.lang.Deprecated - public java.util.Map getMutableMetadata() { - return internalGetMutableMetadata().getMutableMap(); - } - /** - * - * - *
-     * The metadata key-value pairs assigned to the device. This metadata is not
-     * interpreted or indexed by Cloud IoT Core. It can be used to add contextual
-     * information for the device.
-     * Keys must conform to the regular expression [a-zA-Z][a-zA-Z0-9-_.+~%]+ and
-     * be less than 128 bytes in length.
-     * Values are free-form strings. Each value must be less than or equal to 32
-     * KB in size.
-     * The total size of all keys and values must be less than 256 KB, and the
-     * maximum number of key-value pairs is 500.
-     * 
- * - * map<string, string> metadata = 17; - */ - public Builder putMetadata(java.lang.String key, java.lang.String value) { - if (key == null) { - throw new NullPointerException("map key"); - } - if (value == null) { - throw new NullPointerException("map value"); - } - - internalGetMutableMetadata().getMutableMap().put(key, value); - return this; - } - /** - * - * - *
-     * The metadata key-value pairs assigned to the device. This metadata is not
-     * interpreted or indexed by Cloud IoT Core. It can be used to add contextual
-     * information for the device.
-     * Keys must conform to the regular expression [a-zA-Z][a-zA-Z0-9-_.+~%]+ and
-     * be less than 128 bytes in length.
-     * Values are free-form strings. Each value must be less than or equal to 32
-     * KB in size.
-     * The total size of all keys and values must be less than 256 KB, and the
-     * maximum number of key-value pairs is 500.
-     * 
- * - * map<string, string> metadata = 17; - */ - public Builder putAllMetadata(java.util.Map values) { - internalGetMutableMetadata().getMutableMap().putAll(values); - return this; - } - - private com.google.cloud.iot.v1.GatewayConfig gatewayConfig_; - private com.google.protobuf.SingleFieldBuilderV3< - com.google.cloud.iot.v1.GatewayConfig, - com.google.cloud.iot.v1.GatewayConfig.Builder, - com.google.cloud.iot.v1.GatewayConfigOrBuilder> - gatewayConfigBuilder_; - /** - * - * - *
-     * Gateway-related configuration and state.
-     * 
- * - * .google.cloud.iot.v1.GatewayConfig gateway_config = 24; - * - * @return Whether the gatewayConfig field is set. - */ - public boolean hasGatewayConfig() { - return gatewayConfigBuilder_ != null || gatewayConfig_ != null; - } - /** - * - * - *
-     * Gateway-related configuration and state.
-     * 
- * - * .google.cloud.iot.v1.GatewayConfig gateway_config = 24; - * - * @return The gatewayConfig. - */ - public com.google.cloud.iot.v1.GatewayConfig getGatewayConfig() { - if (gatewayConfigBuilder_ == null) { - return gatewayConfig_ == null - ? com.google.cloud.iot.v1.GatewayConfig.getDefaultInstance() - : gatewayConfig_; - } else { - return gatewayConfigBuilder_.getMessage(); - } - } - /** - * - * - *
-     * Gateway-related configuration and state.
-     * 
- * - * .google.cloud.iot.v1.GatewayConfig gateway_config = 24; - */ - public Builder setGatewayConfig(com.google.cloud.iot.v1.GatewayConfig value) { - if (gatewayConfigBuilder_ == null) { - if (value == null) { - throw new NullPointerException(); - } - gatewayConfig_ = value; - onChanged(); - } else { - gatewayConfigBuilder_.setMessage(value); - } - - return this; - } - /** - * - * - *
-     * Gateway-related configuration and state.
-     * 
- * - * .google.cloud.iot.v1.GatewayConfig gateway_config = 24; - */ - public Builder setGatewayConfig(com.google.cloud.iot.v1.GatewayConfig.Builder builderForValue) { - if (gatewayConfigBuilder_ == null) { - gatewayConfig_ = builderForValue.build(); - onChanged(); - } else { - gatewayConfigBuilder_.setMessage(builderForValue.build()); - } - - return this; - } - /** - * - * - *
-     * Gateway-related configuration and state.
-     * 
- * - * .google.cloud.iot.v1.GatewayConfig gateway_config = 24; - */ - public Builder mergeGatewayConfig(com.google.cloud.iot.v1.GatewayConfig value) { - if (gatewayConfigBuilder_ == null) { - if (gatewayConfig_ != null) { - gatewayConfig_ = - com.google.cloud.iot.v1.GatewayConfig.newBuilder(gatewayConfig_) - .mergeFrom(value) - .buildPartial(); - } else { - gatewayConfig_ = value; - } - onChanged(); - } else { - gatewayConfigBuilder_.mergeFrom(value); - } - - return this; - } - /** - * - * - *
-     * Gateway-related configuration and state.
-     * 
- * - * .google.cloud.iot.v1.GatewayConfig gateway_config = 24; - */ - public Builder clearGatewayConfig() { - if (gatewayConfigBuilder_ == null) { - gatewayConfig_ = null; - onChanged(); - } else { - gatewayConfig_ = null; - gatewayConfigBuilder_ = null; - } - - return this; - } - /** - * - * - *
-     * Gateway-related configuration and state.
-     * 
- * - * .google.cloud.iot.v1.GatewayConfig gateway_config = 24; - */ - public com.google.cloud.iot.v1.GatewayConfig.Builder getGatewayConfigBuilder() { - - onChanged(); - return getGatewayConfigFieldBuilder().getBuilder(); - } - /** - * - * - *
-     * Gateway-related configuration and state.
-     * 
- * - * .google.cloud.iot.v1.GatewayConfig gateway_config = 24; - */ - public com.google.cloud.iot.v1.GatewayConfigOrBuilder getGatewayConfigOrBuilder() { - if (gatewayConfigBuilder_ != null) { - return gatewayConfigBuilder_.getMessageOrBuilder(); - } else { - return gatewayConfig_ == null - ? com.google.cloud.iot.v1.GatewayConfig.getDefaultInstance() - : gatewayConfig_; - } - } - /** - * - * - *
-     * Gateway-related configuration and state.
-     * 
- * - * .google.cloud.iot.v1.GatewayConfig gateway_config = 24; - */ - private com.google.protobuf.SingleFieldBuilderV3< - com.google.cloud.iot.v1.GatewayConfig, - com.google.cloud.iot.v1.GatewayConfig.Builder, - com.google.cloud.iot.v1.GatewayConfigOrBuilder> - getGatewayConfigFieldBuilder() { - if (gatewayConfigBuilder_ == null) { - gatewayConfigBuilder_ = - new com.google.protobuf.SingleFieldBuilderV3< - com.google.cloud.iot.v1.GatewayConfig, - com.google.cloud.iot.v1.GatewayConfig.Builder, - com.google.cloud.iot.v1.GatewayConfigOrBuilder>( - getGatewayConfig(), getParentForChildren(), isClean()); - gatewayConfig_ = null; - } - return gatewayConfigBuilder_; - } - - @java.lang.Override - public final Builder setUnknownFields(final com.google.protobuf.UnknownFieldSet unknownFields) { - return super.setUnknownFields(unknownFields); - } - - @java.lang.Override - public final Builder mergeUnknownFields( - final com.google.protobuf.UnknownFieldSet unknownFields) { - return super.mergeUnknownFields(unknownFields); - } - - // @@protoc_insertion_point(builder_scope:google.cloud.iot.v1.Device) - } - - // @@protoc_insertion_point(class_scope:google.cloud.iot.v1.Device) - private static final com.google.cloud.iot.v1.Device DEFAULT_INSTANCE; - - static { - DEFAULT_INSTANCE = new com.google.cloud.iot.v1.Device(); - } - - public static com.google.cloud.iot.v1.Device getDefaultInstance() { - return DEFAULT_INSTANCE; - } - - private static final com.google.protobuf.Parser PARSER = - new com.google.protobuf.AbstractParser() { - @java.lang.Override - public Device parsePartialFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - Builder builder = newBuilder(); - try { - builder.mergeFrom(input, extensionRegistry); - } catch (com.google.protobuf.InvalidProtocolBufferException e) { - throw e.setUnfinishedMessage(builder.buildPartial()); - } catch (com.google.protobuf.UninitializedMessageException e) { - throw e.asInvalidProtocolBufferException().setUnfinishedMessage(builder.buildPartial()); - } catch (java.io.IOException e) { - throw new com.google.protobuf.InvalidProtocolBufferException(e) - .setUnfinishedMessage(builder.buildPartial()); - } - return builder.buildPartial(); - } - }; - - public static com.google.protobuf.Parser parser() { - return PARSER; - } - - @java.lang.Override - public com.google.protobuf.Parser getParserForType() { - return PARSER; - } - - @java.lang.Override - public com.google.cloud.iot.v1.Device getDefaultInstanceForType() { - return DEFAULT_INSTANCE; - } -} diff --git a/proto-google-cloud-iot-v1/src/main/java/com/google/cloud/iot/v1/DeviceConfig.java b/proto-google-cloud-iot-v1/src/main/java/com/google/cloud/iot/v1/DeviceConfig.java deleted file mode 100644 index 5d440635..00000000 --- a/proto-google-cloud-iot-v1/src/main/java/com/google/cloud/iot/v1/DeviceConfig.java +++ /dev/null @@ -1,1273 +0,0 @@ -/* - * Copyright 2020 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. - */ -// Generated by the protocol buffer compiler. DO NOT EDIT! -// source: google/cloud/iot/v1/resources.proto - -package com.google.cloud.iot.v1; - -/** - * - * - *
- * The device configuration. Eventually delivered to devices.
- * 
- * - * Protobuf type {@code google.cloud.iot.v1.DeviceConfig} - */ -public final class DeviceConfig extends com.google.protobuf.GeneratedMessageV3 - implements - // @@protoc_insertion_point(message_implements:google.cloud.iot.v1.DeviceConfig) - DeviceConfigOrBuilder { - private static final long serialVersionUID = 0L; - // Use DeviceConfig.newBuilder() to construct. - private DeviceConfig(com.google.protobuf.GeneratedMessageV3.Builder builder) { - super(builder); - } - - private DeviceConfig() { - binaryData_ = com.google.protobuf.ByteString.EMPTY; - } - - @java.lang.Override - @SuppressWarnings({"unused"}) - protected java.lang.Object newInstance(UnusedPrivateParameter unused) { - return new DeviceConfig(); - } - - @java.lang.Override - public final com.google.protobuf.UnknownFieldSet getUnknownFields() { - return this.unknownFields; - } - - public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { - return com.google.cloud.iot.v1.ResourcesProto - .internal_static_google_cloud_iot_v1_DeviceConfig_descriptor; - } - - @java.lang.Override - protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable - internalGetFieldAccessorTable() { - return com.google.cloud.iot.v1.ResourcesProto - .internal_static_google_cloud_iot_v1_DeviceConfig_fieldAccessorTable - .ensureFieldAccessorsInitialized( - com.google.cloud.iot.v1.DeviceConfig.class, - com.google.cloud.iot.v1.DeviceConfig.Builder.class); - } - - public static final int VERSION_FIELD_NUMBER = 1; - private long version_; - /** - * - * - *
-   * [Output only] The version of this update. The version number is assigned by
-   * the server, and is always greater than 0 after device creation. The
-   * version must be 0 on the `CreateDevice` request if a `config` is
-   * specified; the response of `CreateDevice` will always have a value of 1.
-   * 
- * - * int64 version = 1; - * - * @return The version. - */ - @java.lang.Override - public long getVersion() { - return version_; - } - - public static final int CLOUD_UPDATE_TIME_FIELD_NUMBER = 2; - private com.google.protobuf.Timestamp cloudUpdateTime_; - /** - * - * - *
-   * [Output only] The time at which this configuration version was updated in
-   * Cloud IoT Core. This timestamp is set by the server.
-   * 
- * - * .google.protobuf.Timestamp cloud_update_time = 2; - * - * @return Whether the cloudUpdateTime field is set. - */ - @java.lang.Override - public boolean hasCloudUpdateTime() { - return cloudUpdateTime_ != null; - } - /** - * - * - *
-   * [Output only] The time at which this configuration version was updated in
-   * Cloud IoT Core. This timestamp is set by the server.
-   * 
- * - * .google.protobuf.Timestamp cloud_update_time = 2; - * - * @return The cloudUpdateTime. - */ - @java.lang.Override - public com.google.protobuf.Timestamp getCloudUpdateTime() { - return cloudUpdateTime_ == null - ? com.google.protobuf.Timestamp.getDefaultInstance() - : cloudUpdateTime_; - } - /** - * - * - *
-   * [Output only] The time at which this configuration version was updated in
-   * Cloud IoT Core. This timestamp is set by the server.
-   * 
- * - * .google.protobuf.Timestamp cloud_update_time = 2; - */ - @java.lang.Override - public com.google.protobuf.TimestampOrBuilder getCloudUpdateTimeOrBuilder() { - return getCloudUpdateTime(); - } - - public static final int DEVICE_ACK_TIME_FIELD_NUMBER = 3; - private com.google.protobuf.Timestamp deviceAckTime_; - /** - * - * - *
-   * [Output only] The time at which Cloud IoT Core received the
-   * acknowledgment from the device, indicating that the device has received
-   * this configuration version. If this field is not present, the device has
-   * not yet acknowledged that it received this version. Note that when
-   * the config was sent to the device, many config versions may have been
-   * available in Cloud IoT Core while the device was disconnected, and on
-   * connection, only the latest version is sent to the device. Some
-   * versions may never be sent to the device, and therefore are never
-   * acknowledged. This timestamp is set by Cloud IoT Core.
-   * 
- * - * .google.protobuf.Timestamp device_ack_time = 3; - * - * @return Whether the deviceAckTime field is set. - */ - @java.lang.Override - public boolean hasDeviceAckTime() { - return deviceAckTime_ != null; - } - /** - * - * - *
-   * [Output only] The time at which Cloud IoT Core received the
-   * acknowledgment from the device, indicating that the device has received
-   * this configuration version. If this field is not present, the device has
-   * not yet acknowledged that it received this version. Note that when
-   * the config was sent to the device, many config versions may have been
-   * available in Cloud IoT Core while the device was disconnected, and on
-   * connection, only the latest version is sent to the device. Some
-   * versions may never be sent to the device, and therefore are never
-   * acknowledged. This timestamp is set by Cloud IoT Core.
-   * 
- * - * .google.protobuf.Timestamp device_ack_time = 3; - * - * @return The deviceAckTime. - */ - @java.lang.Override - public com.google.protobuf.Timestamp getDeviceAckTime() { - return deviceAckTime_ == null - ? com.google.protobuf.Timestamp.getDefaultInstance() - : deviceAckTime_; - } - /** - * - * - *
-   * [Output only] The time at which Cloud IoT Core received the
-   * acknowledgment from the device, indicating that the device has received
-   * this configuration version. If this field is not present, the device has
-   * not yet acknowledged that it received this version. Note that when
-   * the config was sent to the device, many config versions may have been
-   * available in Cloud IoT Core while the device was disconnected, and on
-   * connection, only the latest version is sent to the device. Some
-   * versions may never be sent to the device, and therefore are never
-   * acknowledged. This timestamp is set by Cloud IoT Core.
-   * 
- * - * .google.protobuf.Timestamp device_ack_time = 3; - */ - @java.lang.Override - public com.google.protobuf.TimestampOrBuilder getDeviceAckTimeOrBuilder() { - return getDeviceAckTime(); - } - - public static final int BINARY_DATA_FIELD_NUMBER = 4; - private com.google.protobuf.ByteString binaryData_; - /** - * - * - *
-   * The device configuration data.
-   * 
- * - * bytes binary_data = 4; - * - * @return The binaryData. - */ - @java.lang.Override - public com.google.protobuf.ByteString getBinaryData() { - return binaryData_; - } - - private byte memoizedIsInitialized = -1; - - @java.lang.Override - public final boolean isInitialized() { - byte isInitialized = memoizedIsInitialized; - if (isInitialized == 1) return true; - if (isInitialized == 0) return false; - - memoizedIsInitialized = 1; - return true; - } - - @java.lang.Override - public void writeTo(com.google.protobuf.CodedOutputStream output) throws java.io.IOException { - if (version_ != 0L) { - output.writeInt64(1, version_); - } - if (cloudUpdateTime_ != null) { - output.writeMessage(2, getCloudUpdateTime()); - } - if (deviceAckTime_ != null) { - output.writeMessage(3, getDeviceAckTime()); - } - if (!binaryData_.isEmpty()) { - output.writeBytes(4, binaryData_); - } - getUnknownFields().writeTo(output); - } - - @java.lang.Override - public int getSerializedSize() { - int size = memoizedSize; - if (size != -1) return size; - - size = 0; - if (version_ != 0L) { - size += com.google.protobuf.CodedOutputStream.computeInt64Size(1, version_); - } - if (cloudUpdateTime_ != null) { - size += com.google.protobuf.CodedOutputStream.computeMessageSize(2, getCloudUpdateTime()); - } - if (deviceAckTime_ != null) { - size += com.google.protobuf.CodedOutputStream.computeMessageSize(3, getDeviceAckTime()); - } - if (!binaryData_.isEmpty()) { - size += com.google.protobuf.CodedOutputStream.computeBytesSize(4, binaryData_); - } - size += getUnknownFields().getSerializedSize(); - memoizedSize = size; - return size; - } - - @java.lang.Override - public boolean equals(final java.lang.Object obj) { - if (obj == this) { - return true; - } - if (!(obj instanceof com.google.cloud.iot.v1.DeviceConfig)) { - return super.equals(obj); - } - com.google.cloud.iot.v1.DeviceConfig other = (com.google.cloud.iot.v1.DeviceConfig) obj; - - if (getVersion() != other.getVersion()) return false; - if (hasCloudUpdateTime() != other.hasCloudUpdateTime()) return false; - if (hasCloudUpdateTime()) { - if (!getCloudUpdateTime().equals(other.getCloudUpdateTime())) return false; - } - if (hasDeviceAckTime() != other.hasDeviceAckTime()) return false; - if (hasDeviceAckTime()) { - if (!getDeviceAckTime().equals(other.getDeviceAckTime())) return false; - } - if (!getBinaryData().equals(other.getBinaryData())) return false; - if (!getUnknownFields().equals(other.getUnknownFields())) return false; - return true; - } - - @java.lang.Override - public int hashCode() { - if (memoizedHashCode != 0) { - return memoizedHashCode; - } - int hash = 41; - hash = (19 * hash) + getDescriptor().hashCode(); - hash = (37 * hash) + VERSION_FIELD_NUMBER; - hash = (53 * hash) + com.google.protobuf.Internal.hashLong(getVersion()); - if (hasCloudUpdateTime()) { - hash = (37 * hash) + CLOUD_UPDATE_TIME_FIELD_NUMBER; - hash = (53 * hash) + getCloudUpdateTime().hashCode(); - } - if (hasDeviceAckTime()) { - hash = (37 * hash) + DEVICE_ACK_TIME_FIELD_NUMBER; - hash = (53 * hash) + getDeviceAckTime().hashCode(); - } - hash = (37 * hash) + BINARY_DATA_FIELD_NUMBER; - hash = (53 * hash) + getBinaryData().hashCode(); - hash = (29 * hash) + getUnknownFields().hashCode(); - memoizedHashCode = hash; - return hash; - } - - public static com.google.cloud.iot.v1.DeviceConfig parseFrom(java.nio.ByteBuffer data) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); - } - - public static com.google.cloud.iot.v1.DeviceConfig parseFrom( - java.nio.ByteBuffer data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); - } - - public static com.google.cloud.iot.v1.DeviceConfig parseFrom(com.google.protobuf.ByteString data) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); - } - - public static com.google.cloud.iot.v1.DeviceConfig parseFrom( - com.google.protobuf.ByteString data, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); - } - - public static com.google.cloud.iot.v1.DeviceConfig parseFrom(byte[] data) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); - } - - public static com.google.cloud.iot.v1.DeviceConfig parseFrom( - byte[] data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); - } - - public static com.google.cloud.iot.v1.DeviceConfig parseFrom(java.io.InputStream input) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input); - } - - public static com.google.cloud.iot.v1.DeviceConfig parseFrom( - java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3.parseWithIOException( - PARSER, input, extensionRegistry); - } - - public static com.google.cloud.iot.v1.DeviceConfig parseDelimitedFrom(java.io.InputStream input) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3.parseDelimitedWithIOException(PARSER, input); - } - - public static com.google.cloud.iot.v1.DeviceConfig parseDelimitedFrom( - java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3.parseDelimitedWithIOException( - PARSER, input, extensionRegistry); - } - - public static com.google.cloud.iot.v1.DeviceConfig parseFrom( - com.google.protobuf.CodedInputStream input) throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input); - } - - public static com.google.cloud.iot.v1.DeviceConfig parseFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3.parseWithIOException( - PARSER, input, extensionRegistry); - } - - @java.lang.Override - public Builder newBuilderForType() { - return newBuilder(); - } - - public static Builder newBuilder() { - return DEFAULT_INSTANCE.toBuilder(); - } - - public static Builder newBuilder(com.google.cloud.iot.v1.DeviceConfig prototype) { - return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); - } - - @java.lang.Override - public Builder toBuilder() { - return this == DEFAULT_INSTANCE ? new Builder() : new Builder().mergeFrom(this); - } - - @java.lang.Override - protected Builder newBuilderForType(com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { - Builder builder = new Builder(parent); - return builder; - } - /** - * - * - *
-   * The device configuration. Eventually delivered to devices.
-   * 
- * - * Protobuf type {@code google.cloud.iot.v1.DeviceConfig} - */ - public static final class Builder extends com.google.protobuf.GeneratedMessageV3.Builder - implements - // @@protoc_insertion_point(builder_implements:google.cloud.iot.v1.DeviceConfig) - com.google.cloud.iot.v1.DeviceConfigOrBuilder { - public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { - return com.google.cloud.iot.v1.ResourcesProto - .internal_static_google_cloud_iot_v1_DeviceConfig_descriptor; - } - - @java.lang.Override - protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable - internalGetFieldAccessorTable() { - return com.google.cloud.iot.v1.ResourcesProto - .internal_static_google_cloud_iot_v1_DeviceConfig_fieldAccessorTable - .ensureFieldAccessorsInitialized( - com.google.cloud.iot.v1.DeviceConfig.class, - com.google.cloud.iot.v1.DeviceConfig.Builder.class); - } - - // Construct using com.google.cloud.iot.v1.DeviceConfig.newBuilder() - private Builder() {} - - private Builder(com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { - super(parent); - } - - @java.lang.Override - public Builder clear() { - super.clear(); - version_ = 0L; - - if (cloudUpdateTimeBuilder_ == null) { - cloudUpdateTime_ = null; - } else { - cloudUpdateTime_ = null; - cloudUpdateTimeBuilder_ = null; - } - if (deviceAckTimeBuilder_ == null) { - deviceAckTime_ = null; - } else { - deviceAckTime_ = null; - deviceAckTimeBuilder_ = null; - } - binaryData_ = com.google.protobuf.ByteString.EMPTY; - - return this; - } - - @java.lang.Override - public com.google.protobuf.Descriptors.Descriptor getDescriptorForType() { - return com.google.cloud.iot.v1.ResourcesProto - .internal_static_google_cloud_iot_v1_DeviceConfig_descriptor; - } - - @java.lang.Override - public com.google.cloud.iot.v1.DeviceConfig getDefaultInstanceForType() { - return com.google.cloud.iot.v1.DeviceConfig.getDefaultInstance(); - } - - @java.lang.Override - public com.google.cloud.iot.v1.DeviceConfig build() { - com.google.cloud.iot.v1.DeviceConfig result = buildPartial(); - if (!result.isInitialized()) { - throw newUninitializedMessageException(result); - } - return result; - } - - @java.lang.Override - public com.google.cloud.iot.v1.DeviceConfig buildPartial() { - com.google.cloud.iot.v1.DeviceConfig result = new com.google.cloud.iot.v1.DeviceConfig(this); - result.version_ = version_; - if (cloudUpdateTimeBuilder_ == null) { - result.cloudUpdateTime_ = cloudUpdateTime_; - } else { - result.cloudUpdateTime_ = cloudUpdateTimeBuilder_.build(); - } - if (deviceAckTimeBuilder_ == null) { - result.deviceAckTime_ = deviceAckTime_; - } else { - result.deviceAckTime_ = deviceAckTimeBuilder_.build(); - } - result.binaryData_ = binaryData_; - onBuilt(); - return result; - } - - @java.lang.Override - public Builder clone() { - return super.clone(); - } - - @java.lang.Override - public Builder setField( - com.google.protobuf.Descriptors.FieldDescriptor field, java.lang.Object value) { - return super.setField(field, value); - } - - @java.lang.Override - public Builder clearField(com.google.protobuf.Descriptors.FieldDescriptor field) { - return super.clearField(field); - } - - @java.lang.Override - public Builder clearOneof(com.google.protobuf.Descriptors.OneofDescriptor oneof) { - return super.clearOneof(oneof); - } - - @java.lang.Override - public Builder setRepeatedField( - com.google.protobuf.Descriptors.FieldDescriptor field, int index, java.lang.Object value) { - return super.setRepeatedField(field, index, value); - } - - @java.lang.Override - public Builder addRepeatedField( - com.google.protobuf.Descriptors.FieldDescriptor field, java.lang.Object value) { - return super.addRepeatedField(field, value); - } - - @java.lang.Override - public Builder mergeFrom(com.google.protobuf.Message other) { - if (other instanceof com.google.cloud.iot.v1.DeviceConfig) { - return mergeFrom((com.google.cloud.iot.v1.DeviceConfig) other); - } else { - super.mergeFrom(other); - return this; - } - } - - public Builder mergeFrom(com.google.cloud.iot.v1.DeviceConfig other) { - if (other == com.google.cloud.iot.v1.DeviceConfig.getDefaultInstance()) return this; - if (other.getVersion() != 0L) { - setVersion(other.getVersion()); - } - if (other.hasCloudUpdateTime()) { - mergeCloudUpdateTime(other.getCloudUpdateTime()); - } - if (other.hasDeviceAckTime()) { - mergeDeviceAckTime(other.getDeviceAckTime()); - } - if (other.getBinaryData() != com.google.protobuf.ByteString.EMPTY) { - setBinaryData(other.getBinaryData()); - } - this.mergeUnknownFields(other.getUnknownFields()); - onChanged(); - return this; - } - - @java.lang.Override - public final boolean isInitialized() { - return true; - } - - @java.lang.Override - public Builder mergeFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - if (extensionRegistry == null) { - throw new java.lang.NullPointerException(); - } - try { - boolean done = false; - while (!done) { - int tag = input.readTag(); - switch (tag) { - case 0: - done = true; - break; - case 8: - { - version_ = input.readInt64(); - - break; - } // case 8 - case 18: - { - input.readMessage(getCloudUpdateTimeFieldBuilder().getBuilder(), extensionRegistry); - - break; - } // case 18 - case 26: - { - input.readMessage(getDeviceAckTimeFieldBuilder().getBuilder(), extensionRegistry); - - break; - } // case 26 - case 34: - { - binaryData_ = input.readBytes(); - - break; - } // case 34 - default: - { - if (!super.parseUnknownField(input, extensionRegistry, tag)) { - done = true; // was an endgroup tag - } - break; - } // default: - } // switch (tag) - } // while (!done) - } catch (com.google.protobuf.InvalidProtocolBufferException e) { - throw e.unwrapIOException(); - } finally { - onChanged(); - } // finally - return this; - } - - private long version_; - /** - * - * - *
-     * [Output only] The version of this update. The version number is assigned by
-     * the server, and is always greater than 0 after device creation. The
-     * version must be 0 on the `CreateDevice` request if a `config` is
-     * specified; the response of `CreateDevice` will always have a value of 1.
-     * 
- * - * int64 version = 1; - * - * @return The version. - */ - @java.lang.Override - public long getVersion() { - return version_; - } - /** - * - * - *
-     * [Output only] The version of this update. The version number is assigned by
-     * the server, and is always greater than 0 after device creation. The
-     * version must be 0 on the `CreateDevice` request if a `config` is
-     * specified; the response of `CreateDevice` will always have a value of 1.
-     * 
- * - * int64 version = 1; - * - * @param value The version to set. - * @return This builder for chaining. - */ - public Builder setVersion(long value) { - - version_ = value; - onChanged(); - return this; - } - /** - * - * - *
-     * [Output only] The version of this update. The version number is assigned by
-     * the server, and is always greater than 0 after device creation. The
-     * version must be 0 on the `CreateDevice` request if a `config` is
-     * specified; the response of `CreateDevice` will always have a value of 1.
-     * 
- * - * int64 version = 1; - * - * @return This builder for chaining. - */ - public Builder clearVersion() { - - version_ = 0L; - onChanged(); - return this; - } - - private com.google.protobuf.Timestamp cloudUpdateTime_; - private com.google.protobuf.SingleFieldBuilderV3< - com.google.protobuf.Timestamp, - com.google.protobuf.Timestamp.Builder, - com.google.protobuf.TimestampOrBuilder> - cloudUpdateTimeBuilder_; - /** - * - * - *
-     * [Output only] The time at which this configuration version was updated in
-     * Cloud IoT Core. This timestamp is set by the server.
-     * 
- * - * .google.protobuf.Timestamp cloud_update_time = 2; - * - * @return Whether the cloudUpdateTime field is set. - */ - public boolean hasCloudUpdateTime() { - return cloudUpdateTimeBuilder_ != null || cloudUpdateTime_ != null; - } - /** - * - * - *
-     * [Output only] The time at which this configuration version was updated in
-     * Cloud IoT Core. This timestamp is set by the server.
-     * 
- * - * .google.protobuf.Timestamp cloud_update_time = 2; - * - * @return The cloudUpdateTime. - */ - public com.google.protobuf.Timestamp getCloudUpdateTime() { - if (cloudUpdateTimeBuilder_ == null) { - return cloudUpdateTime_ == null - ? com.google.protobuf.Timestamp.getDefaultInstance() - : cloudUpdateTime_; - } else { - return cloudUpdateTimeBuilder_.getMessage(); - } - } - /** - * - * - *
-     * [Output only] The time at which this configuration version was updated in
-     * Cloud IoT Core. This timestamp is set by the server.
-     * 
- * - * .google.protobuf.Timestamp cloud_update_time = 2; - */ - public Builder setCloudUpdateTime(com.google.protobuf.Timestamp value) { - if (cloudUpdateTimeBuilder_ == null) { - if (value == null) { - throw new NullPointerException(); - } - cloudUpdateTime_ = value; - onChanged(); - } else { - cloudUpdateTimeBuilder_.setMessage(value); - } - - return this; - } - /** - * - * - *
-     * [Output only] The time at which this configuration version was updated in
-     * Cloud IoT Core. This timestamp is set by the server.
-     * 
- * - * .google.protobuf.Timestamp cloud_update_time = 2; - */ - public Builder setCloudUpdateTime(com.google.protobuf.Timestamp.Builder builderForValue) { - if (cloudUpdateTimeBuilder_ == null) { - cloudUpdateTime_ = builderForValue.build(); - onChanged(); - } else { - cloudUpdateTimeBuilder_.setMessage(builderForValue.build()); - } - - return this; - } - /** - * - * - *
-     * [Output only] The time at which this configuration version was updated in
-     * Cloud IoT Core. This timestamp is set by the server.
-     * 
- * - * .google.protobuf.Timestamp cloud_update_time = 2; - */ - public Builder mergeCloudUpdateTime(com.google.protobuf.Timestamp value) { - if (cloudUpdateTimeBuilder_ == null) { - if (cloudUpdateTime_ != null) { - cloudUpdateTime_ = - com.google.protobuf.Timestamp.newBuilder(cloudUpdateTime_) - .mergeFrom(value) - .buildPartial(); - } else { - cloudUpdateTime_ = value; - } - onChanged(); - } else { - cloudUpdateTimeBuilder_.mergeFrom(value); - } - - return this; - } - /** - * - * - *
-     * [Output only] The time at which this configuration version was updated in
-     * Cloud IoT Core. This timestamp is set by the server.
-     * 
- * - * .google.protobuf.Timestamp cloud_update_time = 2; - */ - public Builder clearCloudUpdateTime() { - if (cloudUpdateTimeBuilder_ == null) { - cloudUpdateTime_ = null; - onChanged(); - } else { - cloudUpdateTime_ = null; - cloudUpdateTimeBuilder_ = null; - } - - return this; - } - /** - * - * - *
-     * [Output only] The time at which this configuration version was updated in
-     * Cloud IoT Core. This timestamp is set by the server.
-     * 
- * - * .google.protobuf.Timestamp cloud_update_time = 2; - */ - public com.google.protobuf.Timestamp.Builder getCloudUpdateTimeBuilder() { - - onChanged(); - return getCloudUpdateTimeFieldBuilder().getBuilder(); - } - /** - * - * - *
-     * [Output only] The time at which this configuration version was updated in
-     * Cloud IoT Core. This timestamp is set by the server.
-     * 
- * - * .google.protobuf.Timestamp cloud_update_time = 2; - */ - public com.google.protobuf.TimestampOrBuilder getCloudUpdateTimeOrBuilder() { - if (cloudUpdateTimeBuilder_ != null) { - return cloudUpdateTimeBuilder_.getMessageOrBuilder(); - } else { - return cloudUpdateTime_ == null - ? com.google.protobuf.Timestamp.getDefaultInstance() - : cloudUpdateTime_; - } - } - /** - * - * - *
-     * [Output only] The time at which this configuration version was updated in
-     * Cloud IoT Core. This timestamp is set by the server.
-     * 
- * - * .google.protobuf.Timestamp cloud_update_time = 2; - */ - private com.google.protobuf.SingleFieldBuilderV3< - com.google.protobuf.Timestamp, - com.google.protobuf.Timestamp.Builder, - com.google.protobuf.TimestampOrBuilder> - getCloudUpdateTimeFieldBuilder() { - if (cloudUpdateTimeBuilder_ == null) { - cloudUpdateTimeBuilder_ = - new com.google.protobuf.SingleFieldBuilderV3< - com.google.protobuf.Timestamp, - com.google.protobuf.Timestamp.Builder, - com.google.protobuf.TimestampOrBuilder>( - getCloudUpdateTime(), getParentForChildren(), isClean()); - cloudUpdateTime_ = null; - } - return cloudUpdateTimeBuilder_; - } - - private com.google.protobuf.Timestamp deviceAckTime_; - private com.google.protobuf.SingleFieldBuilderV3< - com.google.protobuf.Timestamp, - com.google.protobuf.Timestamp.Builder, - com.google.protobuf.TimestampOrBuilder> - deviceAckTimeBuilder_; - /** - * - * - *
-     * [Output only] The time at which Cloud IoT Core received the
-     * acknowledgment from the device, indicating that the device has received
-     * this configuration version. If this field is not present, the device has
-     * not yet acknowledged that it received this version. Note that when
-     * the config was sent to the device, many config versions may have been
-     * available in Cloud IoT Core while the device was disconnected, and on
-     * connection, only the latest version is sent to the device. Some
-     * versions may never be sent to the device, and therefore are never
-     * acknowledged. This timestamp is set by Cloud IoT Core.
-     * 
- * - * .google.protobuf.Timestamp device_ack_time = 3; - * - * @return Whether the deviceAckTime field is set. - */ - public boolean hasDeviceAckTime() { - return deviceAckTimeBuilder_ != null || deviceAckTime_ != null; - } - /** - * - * - *
-     * [Output only] The time at which Cloud IoT Core received the
-     * acknowledgment from the device, indicating that the device has received
-     * this configuration version. If this field is not present, the device has
-     * not yet acknowledged that it received this version. Note that when
-     * the config was sent to the device, many config versions may have been
-     * available in Cloud IoT Core while the device was disconnected, and on
-     * connection, only the latest version is sent to the device. Some
-     * versions may never be sent to the device, and therefore are never
-     * acknowledged. This timestamp is set by Cloud IoT Core.
-     * 
- * - * .google.protobuf.Timestamp device_ack_time = 3; - * - * @return The deviceAckTime. - */ - public com.google.protobuf.Timestamp getDeviceAckTime() { - if (deviceAckTimeBuilder_ == null) { - return deviceAckTime_ == null - ? com.google.protobuf.Timestamp.getDefaultInstance() - : deviceAckTime_; - } else { - return deviceAckTimeBuilder_.getMessage(); - } - } - /** - * - * - *
-     * [Output only] The time at which Cloud IoT Core received the
-     * acknowledgment from the device, indicating that the device has received
-     * this configuration version. If this field is not present, the device has
-     * not yet acknowledged that it received this version. Note that when
-     * the config was sent to the device, many config versions may have been
-     * available in Cloud IoT Core while the device was disconnected, and on
-     * connection, only the latest version is sent to the device. Some
-     * versions may never be sent to the device, and therefore are never
-     * acknowledged. This timestamp is set by Cloud IoT Core.
-     * 
- * - * .google.protobuf.Timestamp device_ack_time = 3; - */ - public Builder setDeviceAckTime(com.google.protobuf.Timestamp value) { - if (deviceAckTimeBuilder_ == null) { - if (value == null) { - throw new NullPointerException(); - } - deviceAckTime_ = value; - onChanged(); - } else { - deviceAckTimeBuilder_.setMessage(value); - } - - return this; - } - /** - * - * - *
-     * [Output only] The time at which Cloud IoT Core received the
-     * acknowledgment from the device, indicating that the device has received
-     * this configuration version. If this field is not present, the device has
-     * not yet acknowledged that it received this version. Note that when
-     * the config was sent to the device, many config versions may have been
-     * available in Cloud IoT Core while the device was disconnected, and on
-     * connection, only the latest version is sent to the device. Some
-     * versions may never be sent to the device, and therefore are never
-     * acknowledged. This timestamp is set by Cloud IoT Core.
-     * 
- * - * .google.protobuf.Timestamp device_ack_time = 3; - */ - public Builder setDeviceAckTime(com.google.protobuf.Timestamp.Builder builderForValue) { - if (deviceAckTimeBuilder_ == null) { - deviceAckTime_ = builderForValue.build(); - onChanged(); - } else { - deviceAckTimeBuilder_.setMessage(builderForValue.build()); - } - - return this; - } - /** - * - * - *
-     * [Output only] The time at which Cloud IoT Core received the
-     * acknowledgment from the device, indicating that the device has received
-     * this configuration version. If this field is not present, the device has
-     * not yet acknowledged that it received this version. Note that when
-     * the config was sent to the device, many config versions may have been
-     * available in Cloud IoT Core while the device was disconnected, and on
-     * connection, only the latest version is sent to the device. Some
-     * versions may never be sent to the device, and therefore are never
-     * acknowledged. This timestamp is set by Cloud IoT Core.
-     * 
- * - * .google.protobuf.Timestamp device_ack_time = 3; - */ - public Builder mergeDeviceAckTime(com.google.protobuf.Timestamp value) { - if (deviceAckTimeBuilder_ == null) { - if (deviceAckTime_ != null) { - deviceAckTime_ = - com.google.protobuf.Timestamp.newBuilder(deviceAckTime_) - .mergeFrom(value) - .buildPartial(); - } else { - deviceAckTime_ = value; - } - onChanged(); - } else { - deviceAckTimeBuilder_.mergeFrom(value); - } - - return this; - } - /** - * - * - *
-     * [Output only] The time at which Cloud IoT Core received the
-     * acknowledgment from the device, indicating that the device has received
-     * this configuration version. If this field is not present, the device has
-     * not yet acknowledged that it received this version. Note that when
-     * the config was sent to the device, many config versions may have been
-     * available in Cloud IoT Core while the device was disconnected, and on
-     * connection, only the latest version is sent to the device. Some
-     * versions may never be sent to the device, and therefore are never
-     * acknowledged. This timestamp is set by Cloud IoT Core.
-     * 
- * - * .google.protobuf.Timestamp device_ack_time = 3; - */ - public Builder clearDeviceAckTime() { - if (deviceAckTimeBuilder_ == null) { - deviceAckTime_ = null; - onChanged(); - } else { - deviceAckTime_ = null; - deviceAckTimeBuilder_ = null; - } - - return this; - } - /** - * - * - *
-     * [Output only] The time at which Cloud IoT Core received the
-     * acknowledgment from the device, indicating that the device has received
-     * this configuration version. If this field is not present, the device has
-     * not yet acknowledged that it received this version. Note that when
-     * the config was sent to the device, many config versions may have been
-     * available in Cloud IoT Core while the device was disconnected, and on
-     * connection, only the latest version is sent to the device. Some
-     * versions may never be sent to the device, and therefore are never
-     * acknowledged. This timestamp is set by Cloud IoT Core.
-     * 
- * - * .google.protobuf.Timestamp device_ack_time = 3; - */ - public com.google.protobuf.Timestamp.Builder getDeviceAckTimeBuilder() { - - onChanged(); - return getDeviceAckTimeFieldBuilder().getBuilder(); - } - /** - * - * - *
-     * [Output only] The time at which Cloud IoT Core received the
-     * acknowledgment from the device, indicating that the device has received
-     * this configuration version. If this field is not present, the device has
-     * not yet acknowledged that it received this version. Note that when
-     * the config was sent to the device, many config versions may have been
-     * available in Cloud IoT Core while the device was disconnected, and on
-     * connection, only the latest version is sent to the device. Some
-     * versions may never be sent to the device, and therefore are never
-     * acknowledged. This timestamp is set by Cloud IoT Core.
-     * 
- * - * .google.protobuf.Timestamp device_ack_time = 3; - */ - public com.google.protobuf.TimestampOrBuilder getDeviceAckTimeOrBuilder() { - if (deviceAckTimeBuilder_ != null) { - return deviceAckTimeBuilder_.getMessageOrBuilder(); - } else { - return deviceAckTime_ == null - ? com.google.protobuf.Timestamp.getDefaultInstance() - : deviceAckTime_; - } - } - /** - * - * - *
-     * [Output only] The time at which Cloud IoT Core received the
-     * acknowledgment from the device, indicating that the device has received
-     * this configuration version. If this field is not present, the device has
-     * not yet acknowledged that it received this version. Note that when
-     * the config was sent to the device, many config versions may have been
-     * available in Cloud IoT Core while the device was disconnected, and on
-     * connection, only the latest version is sent to the device. Some
-     * versions may never be sent to the device, and therefore are never
-     * acknowledged. This timestamp is set by Cloud IoT Core.
-     * 
- * - * .google.protobuf.Timestamp device_ack_time = 3; - */ - private com.google.protobuf.SingleFieldBuilderV3< - com.google.protobuf.Timestamp, - com.google.protobuf.Timestamp.Builder, - com.google.protobuf.TimestampOrBuilder> - getDeviceAckTimeFieldBuilder() { - if (deviceAckTimeBuilder_ == null) { - deviceAckTimeBuilder_ = - new com.google.protobuf.SingleFieldBuilderV3< - com.google.protobuf.Timestamp, - com.google.protobuf.Timestamp.Builder, - com.google.protobuf.TimestampOrBuilder>( - getDeviceAckTime(), getParentForChildren(), isClean()); - deviceAckTime_ = null; - } - return deviceAckTimeBuilder_; - } - - private com.google.protobuf.ByteString binaryData_ = com.google.protobuf.ByteString.EMPTY; - /** - * - * - *
-     * The device configuration data.
-     * 
- * - * bytes binary_data = 4; - * - * @return The binaryData. - */ - @java.lang.Override - public com.google.protobuf.ByteString getBinaryData() { - return binaryData_; - } - /** - * - * - *
-     * The device configuration data.
-     * 
- * - * bytes binary_data = 4; - * - * @param value The binaryData to set. - * @return This builder for chaining. - */ - public Builder setBinaryData(com.google.protobuf.ByteString value) { - if (value == null) { - throw new NullPointerException(); - } - - binaryData_ = value; - onChanged(); - return this; - } - /** - * - * - *
-     * The device configuration data.
-     * 
- * - * bytes binary_data = 4; - * - * @return This builder for chaining. - */ - public Builder clearBinaryData() { - - binaryData_ = getDefaultInstance().getBinaryData(); - onChanged(); - return this; - } - - @java.lang.Override - public final Builder setUnknownFields(final com.google.protobuf.UnknownFieldSet unknownFields) { - return super.setUnknownFields(unknownFields); - } - - @java.lang.Override - public final Builder mergeUnknownFields( - final com.google.protobuf.UnknownFieldSet unknownFields) { - return super.mergeUnknownFields(unknownFields); - } - - // @@protoc_insertion_point(builder_scope:google.cloud.iot.v1.DeviceConfig) - } - - // @@protoc_insertion_point(class_scope:google.cloud.iot.v1.DeviceConfig) - private static final com.google.cloud.iot.v1.DeviceConfig DEFAULT_INSTANCE; - - static { - DEFAULT_INSTANCE = new com.google.cloud.iot.v1.DeviceConfig(); - } - - public static com.google.cloud.iot.v1.DeviceConfig getDefaultInstance() { - return DEFAULT_INSTANCE; - } - - private static final com.google.protobuf.Parser PARSER = - new com.google.protobuf.AbstractParser() { - @java.lang.Override - public DeviceConfig parsePartialFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - Builder builder = newBuilder(); - try { - builder.mergeFrom(input, extensionRegistry); - } catch (com.google.protobuf.InvalidProtocolBufferException e) { - throw e.setUnfinishedMessage(builder.buildPartial()); - } catch (com.google.protobuf.UninitializedMessageException e) { - throw e.asInvalidProtocolBufferException().setUnfinishedMessage(builder.buildPartial()); - } catch (java.io.IOException e) { - throw new com.google.protobuf.InvalidProtocolBufferException(e) - .setUnfinishedMessage(builder.buildPartial()); - } - return builder.buildPartial(); - } - }; - - public static com.google.protobuf.Parser parser() { - return PARSER; - } - - @java.lang.Override - public com.google.protobuf.Parser getParserForType() { - return PARSER; - } - - @java.lang.Override - public com.google.cloud.iot.v1.DeviceConfig getDefaultInstanceForType() { - return DEFAULT_INSTANCE; - } -} diff --git a/proto-google-cloud-iot-v1/src/main/java/com/google/cloud/iot/v1/DeviceConfigOrBuilder.java b/proto-google-cloud-iot-v1/src/main/java/com/google/cloud/iot/v1/DeviceConfigOrBuilder.java deleted file mode 100644 index 762a4f2d..00000000 --- a/proto-google-cloud-iot-v1/src/main/java/com/google/cloud/iot/v1/DeviceConfigOrBuilder.java +++ /dev/null @@ -1,151 +0,0 @@ -/* - * Copyright 2020 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. - */ -// Generated by the protocol buffer compiler. DO NOT EDIT! -// source: google/cloud/iot/v1/resources.proto - -package com.google.cloud.iot.v1; - -public interface DeviceConfigOrBuilder - extends - // @@protoc_insertion_point(interface_extends:google.cloud.iot.v1.DeviceConfig) - com.google.protobuf.MessageOrBuilder { - - /** - * - * - *
-   * [Output only] The version of this update. The version number is assigned by
-   * the server, and is always greater than 0 after device creation. The
-   * version must be 0 on the `CreateDevice` request if a `config` is
-   * specified; the response of `CreateDevice` will always have a value of 1.
-   * 
- * - * int64 version = 1; - * - * @return The version. - */ - long getVersion(); - - /** - * - * - *
-   * [Output only] The time at which this configuration version was updated in
-   * Cloud IoT Core. This timestamp is set by the server.
-   * 
- * - * .google.protobuf.Timestamp cloud_update_time = 2; - * - * @return Whether the cloudUpdateTime field is set. - */ - boolean hasCloudUpdateTime(); - /** - * - * - *
-   * [Output only] The time at which this configuration version was updated in
-   * Cloud IoT Core. This timestamp is set by the server.
-   * 
- * - * .google.protobuf.Timestamp cloud_update_time = 2; - * - * @return The cloudUpdateTime. - */ - com.google.protobuf.Timestamp getCloudUpdateTime(); - /** - * - * - *
-   * [Output only] The time at which this configuration version was updated in
-   * Cloud IoT Core. This timestamp is set by the server.
-   * 
- * - * .google.protobuf.Timestamp cloud_update_time = 2; - */ - com.google.protobuf.TimestampOrBuilder getCloudUpdateTimeOrBuilder(); - - /** - * - * - *
-   * [Output only] The time at which Cloud IoT Core received the
-   * acknowledgment from the device, indicating that the device has received
-   * this configuration version. If this field is not present, the device has
-   * not yet acknowledged that it received this version. Note that when
-   * the config was sent to the device, many config versions may have been
-   * available in Cloud IoT Core while the device was disconnected, and on
-   * connection, only the latest version is sent to the device. Some
-   * versions may never be sent to the device, and therefore are never
-   * acknowledged. This timestamp is set by Cloud IoT Core.
-   * 
- * - * .google.protobuf.Timestamp device_ack_time = 3; - * - * @return Whether the deviceAckTime field is set. - */ - boolean hasDeviceAckTime(); - /** - * - * - *
-   * [Output only] The time at which Cloud IoT Core received the
-   * acknowledgment from the device, indicating that the device has received
-   * this configuration version. If this field is not present, the device has
-   * not yet acknowledged that it received this version. Note that when
-   * the config was sent to the device, many config versions may have been
-   * available in Cloud IoT Core while the device was disconnected, and on
-   * connection, only the latest version is sent to the device. Some
-   * versions may never be sent to the device, and therefore are never
-   * acknowledged. This timestamp is set by Cloud IoT Core.
-   * 
- * - * .google.protobuf.Timestamp device_ack_time = 3; - * - * @return The deviceAckTime. - */ - com.google.protobuf.Timestamp getDeviceAckTime(); - /** - * - * - *
-   * [Output only] The time at which Cloud IoT Core received the
-   * acknowledgment from the device, indicating that the device has received
-   * this configuration version. If this field is not present, the device has
-   * not yet acknowledged that it received this version. Note that when
-   * the config was sent to the device, many config versions may have been
-   * available in Cloud IoT Core while the device was disconnected, and on
-   * connection, only the latest version is sent to the device. Some
-   * versions may never be sent to the device, and therefore are never
-   * acknowledged. This timestamp is set by Cloud IoT Core.
-   * 
- * - * .google.protobuf.Timestamp device_ack_time = 3; - */ - com.google.protobuf.TimestampOrBuilder getDeviceAckTimeOrBuilder(); - - /** - * - * - *
-   * The device configuration data.
-   * 
- * - * bytes binary_data = 4; - * - * @return The binaryData. - */ - com.google.protobuf.ByteString getBinaryData(); -} diff --git a/proto-google-cloud-iot-v1/src/main/java/com/google/cloud/iot/v1/DeviceCredential.java b/proto-google-cloud-iot-v1/src/main/java/com/google/cloud/iot/v1/DeviceCredential.java deleted file mode 100644 index 34be7d7f..00000000 --- a/proto-google-cloud-iot-v1/src/main/java/com/google/cloud/iot/v1/DeviceCredential.java +++ /dev/null @@ -1,1218 +0,0 @@ -/* - * Copyright 2020 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. - */ -// Generated by the protocol buffer compiler. DO NOT EDIT! -// source: google/cloud/iot/v1/resources.proto - -package com.google.cloud.iot.v1; - -/** - * - * - *
- * A server-stored device credential used for authentication.
- * 
- * - * Protobuf type {@code google.cloud.iot.v1.DeviceCredential} - */ -public final class DeviceCredential extends com.google.protobuf.GeneratedMessageV3 - implements - // @@protoc_insertion_point(message_implements:google.cloud.iot.v1.DeviceCredential) - DeviceCredentialOrBuilder { - private static final long serialVersionUID = 0L; - // Use DeviceCredential.newBuilder() to construct. - private DeviceCredential(com.google.protobuf.GeneratedMessageV3.Builder builder) { - super(builder); - } - - private DeviceCredential() {} - - @java.lang.Override - @SuppressWarnings({"unused"}) - protected java.lang.Object newInstance(UnusedPrivateParameter unused) { - return new DeviceCredential(); - } - - @java.lang.Override - public final com.google.protobuf.UnknownFieldSet getUnknownFields() { - return this.unknownFields; - } - - public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { - return com.google.cloud.iot.v1.ResourcesProto - .internal_static_google_cloud_iot_v1_DeviceCredential_descriptor; - } - - @java.lang.Override - protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable - internalGetFieldAccessorTable() { - return com.google.cloud.iot.v1.ResourcesProto - .internal_static_google_cloud_iot_v1_DeviceCredential_fieldAccessorTable - .ensureFieldAccessorsInitialized( - com.google.cloud.iot.v1.DeviceCredential.class, - com.google.cloud.iot.v1.DeviceCredential.Builder.class); - } - - private int credentialCase_ = 0; - private java.lang.Object credential_; - - public enum CredentialCase - implements - com.google.protobuf.Internal.EnumLite, - com.google.protobuf.AbstractMessage.InternalOneOfEnum { - PUBLIC_KEY(2), - CREDENTIAL_NOT_SET(0); - private final int value; - - private CredentialCase(int value) { - this.value = value; - } - /** - * @param value The number of the enum to look for. - * @return The enum associated with the given number. - * @deprecated Use {@link #forNumber(int)} instead. - */ - @java.lang.Deprecated - public static CredentialCase valueOf(int value) { - return forNumber(value); - } - - public static CredentialCase forNumber(int value) { - switch (value) { - case 2: - return PUBLIC_KEY; - case 0: - return CREDENTIAL_NOT_SET; - default: - return null; - } - } - - public int getNumber() { - return this.value; - } - }; - - public CredentialCase getCredentialCase() { - return CredentialCase.forNumber(credentialCase_); - } - - public static final int PUBLIC_KEY_FIELD_NUMBER = 2; - /** - * - * - *
-   * A public key used to verify the signature of JSON Web Tokens (JWTs).
-   * When adding a new device credential, either via device creation or via
-   * modifications, this public key credential may be required to be signed by
-   * one of the registry level certificates. More specifically, if the
-   * registry contains at least one certificate, any new device credential
-   * must be signed by one of the registry certificates. As a result,
-   * when the registry contains certificates, only X.509 certificates are
-   * accepted as device credentials. However, if the registry does
-   * not contain a certificate, self-signed certificates and public keys will
-   * be accepted. New device credentials must be different from every
-   * registry-level certificate.
-   * 
- * - * .google.cloud.iot.v1.PublicKeyCredential public_key = 2; - * - * @return Whether the publicKey field is set. - */ - @java.lang.Override - public boolean hasPublicKey() { - return credentialCase_ == 2; - } - /** - * - * - *
-   * A public key used to verify the signature of JSON Web Tokens (JWTs).
-   * When adding a new device credential, either via device creation or via
-   * modifications, this public key credential may be required to be signed by
-   * one of the registry level certificates. More specifically, if the
-   * registry contains at least one certificate, any new device credential
-   * must be signed by one of the registry certificates. As a result,
-   * when the registry contains certificates, only X.509 certificates are
-   * accepted as device credentials. However, if the registry does
-   * not contain a certificate, self-signed certificates and public keys will
-   * be accepted. New device credentials must be different from every
-   * registry-level certificate.
-   * 
- * - * .google.cloud.iot.v1.PublicKeyCredential public_key = 2; - * - * @return The publicKey. - */ - @java.lang.Override - public com.google.cloud.iot.v1.PublicKeyCredential getPublicKey() { - if (credentialCase_ == 2) { - return (com.google.cloud.iot.v1.PublicKeyCredential) credential_; - } - return com.google.cloud.iot.v1.PublicKeyCredential.getDefaultInstance(); - } - /** - * - * - *
-   * A public key used to verify the signature of JSON Web Tokens (JWTs).
-   * When adding a new device credential, either via device creation or via
-   * modifications, this public key credential may be required to be signed by
-   * one of the registry level certificates. More specifically, if the
-   * registry contains at least one certificate, any new device credential
-   * must be signed by one of the registry certificates. As a result,
-   * when the registry contains certificates, only X.509 certificates are
-   * accepted as device credentials. However, if the registry does
-   * not contain a certificate, self-signed certificates and public keys will
-   * be accepted. New device credentials must be different from every
-   * registry-level certificate.
-   * 
- * - * .google.cloud.iot.v1.PublicKeyCredential public_key = 2; - */ - @java.lang.Override - public com.google.cloud.iot.v1.PublicKeyCredentialOrBuilder getPublicKeyOrBuilder() { - if (credentialCase_ == 2) { - return (com.google.cloud.iot.v1.PublicKeyCredential) credential_; - } - return com.google.cloud.iot.v1.PublicKeyCredential.getDefaultInstance(); - } - - public static final int EXPIRATION_TIME_FIELD_NUMBER = 6; - private com.google.protobuf.Timestamp expirationTime_; - /** - * - * - *
-   * [Optional] The time at which this credential becomes invalid. This
-   * credential will be ignored for new client authentication requests after
-   * this timestamp; however, it will not be automatically deleted.
-   * 
- * - * .google.protobuf.Timestamp expiration_time = 6; - * - * @return Whether the expirationTime field is set. - */ - @java.lang.Override - public boolean hasExpirationTime() { - return expirationTime_ != null; - } - /** - * - * - *
-   * [Optional] The time at which this credential becomes invalid. This
-   * credential will be ignored for new client authentication requests after
-   * this timestamp; however, it will not be automatically deleted.
-   * 
- * - * .google.protobuf.Timestamp expiration_time = 6; - * - * @return The expirationTime. - */ - @java.lang.Override - public com.google.protobuf.Timestamp getExpirationTime() { - return expirationTime_ == null - ? com.google.protobuf.Timestamp.getDefaultInstance() - : expirationTime_; - } - /** - * - * - *
-   * [Optional] The time at which this credential becomes invalid. This
-   * credential will be ignored for new client authentication requests after
-   * this timestamp; however, it will not be automatically deleted.
-   * 
- * - * .google.protobuf.Timestamp expiration_time = 6; - */ - @java.lang.Override - public com.google.protobuf.TimestampOrBuilder getExpirationTimeOrBuilder() { - return getExpirationTime(); - } - - private byte memoizedIsInitialized = -1; - - @java.lang.Override - public final boolean isInitialized() { - byte isInitialized = memoizedIsInitialized; - if (isInitialized == 1) return true; - if (isInitialized == 0) return false; - - memoizedIsInitialized = 1; - return true; - } - - @java.lang.Override - public void writeTo(com.google.protobuf.CodedOutputStream output) throws java.io.IOException { - if (credentialCase_ == 2) { - output.writeMessage(2, (com.google.cloud.iot.v1.PublicKeyCredential) credential_); - } - if (expirationTime_ != null) { - output.writeMessage(6, getExpirationTime()); - } - getUnknownFields().writeTo(output); - } - - @java.lang.Override - public int getSerializedSize() { - int size = memoizedSize; - if (size != -1) return size; - - size = 0; - if (credentialCase_ == 2) { - size += - com.google.protobuf.CodedOutputStream.computeMessageSize( - 2, (com.google.cloud.iot.v1.PublicKeyCredential) credential_); - } - if (expirationTime_ != null) { - size += com.google.protobuf.CodedOutputStream.computeMessageSize(6, getExpirationTime()); - } - size += getUnknownFields().getSerializedSize(); - memoizedSize = size; - return size; - } - - @java.lang.Override - public boolean equals(final java.lang.Object obj) { - if (obj == this) { - return true; - } - if (!(obj instanceof com.google.cloud.iot.v1.DeviceCredential)) { - return super.equals(obj); - } - com.google.cloud.iot.v1.DeviceCredential other = (com.google.cloud.iot.v1.DeviceCredential) obj; - - if (hasExpirationTime() != other.hasExpirationTime()) return false; - if (hasExpirationTime()) { - if (!getExpirationTime().equals(other.getExpirationTime())) return false; - } - if (!getCredentialCase().equals(other.getCredentialCase())) return false; - switch (credentialCase_) { - case 2: - if (!getPublicKey().equals(other.getPublicKey())) return false; - break; - case 0: - default: - } - if (!getUnknownFields().equals(other.getUnknownFields())) return false; - return true; - } - - @java.lang.Override - public int hashCode() { - if (memoizedHashCode != 0) { - return memoizedHashCode; - } - int hash = 41; - hash = (19 * hash) + getDescriptor().hashCode(); - if (hasExpirationTime()) { - hash = (37 * hash) + EXPIRATION_TIME_FIELD_NUMBER; - hash = (53 * hash) + getExpirationTime().hashCode(); - } - switch (credentialCase_) { - case 2: - hash = (37 * hash) + PUBLIC_KEY_FIELD_NUMBER; - hash = (53 * hash) + getPublicKey().hashCode(); - break; - case 0: - default: - } - hash = (29 * hash) + getUnknownFields().hashCode(); - memoizedHashCode = hash; - return hash; - } - - public static com.google.cloud.iot.v1.DeviceCredential parseFrom(java.nio.ByteBuffer data) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); - } - - public static com.google.cloud.iot.v1.DeviceCredential parseFrom( - java.nio.ByteBuffer data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); - } - - public static com.google.cloud.iot.v1.DeviceCredential parseFrom( - com.google.protobuf.ByteString data) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); - } - - public static com.google.cloud.iot.v1.DeviceCredential parseFrom( - com.google.protobuf.ByteString data, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); - } - - public static com.google.cloud.iot.v1.DeviceCredential parseFrom(byte[] data) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); - } - - public static com.google.cloud.iot.v1.DeviceCredential parseFrom( - byte[] data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); - } - - public static com.google.cloud.iot.v1.DeviceCredential parseFrom(java.io.InputStream input) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input); - } - - public static com.google.cloud.iot.v1.DeviceCredential parseFrom( - java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3.parseWithIOException( - PARSER, input, extensionRegistry); - } - - public static com.google.cloud.iot.v1.DeviceCredential parseDelimitedFrom( - java.io.InputStream input) throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3.parseDelimitedWithIOException(PARSER, input); - } - - public static com.google.cloud.iot.v1.DeviceCredential parseDelimitedFrom( - java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3.parseDelimitedWithIOException( - PARSER, input, extensionRegistry); - } - - public static com.google.cloud.iot.v1.DeviceCredential parseFrom( - com.google.protobuf.CodedInputStream input) throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input); - } - - public static com.google.cloud.iot.v1.DeviceCredential parseFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3.parseWithIOException( - PARSER, input, extensionRegistry); - } - - @java.lang.Override - public Builder newBuilderForType() { - return newBuilder(); - } - - public static Builder newBuilder() { - return DEFAULT_INSTANCE.toBuilder(); - } - - public static Builder newBuilder(com.google.cloud.iot.v1.DeviceCredential prototype) { - return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); - } - - @java.lang.Override - public Builder toBuilder() { - return this == DEFAULT_INSTANCE ? new Builder() : new Builder().mergeFrom(this); - } - - @java.lang.Override - protected Builder newBuilderForType(com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { - Builder builder = new Builder(parent); - return builder; - } - /** - * - * - *
-   * A server-stored device credential used for authentication.
-   * 
- * - * Protobuf type {@code google.cloud.iot.v1.DeviceCredential} - */ - public static final class Builder extends com.google.protobuf.GeneratedMessageV3.Builder - implements - // @@protoc_insertion_point(builder_implements:google.cloud.iot.v1.DeviceCredential) - com.google.cloud.iot.v1.DeviceCredentialOrBuilder { - public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { - return com.google.cloud.iot.v1.ResourcesProto - .internal_static_google_cloud_iot_v1_DeviceCredential_descriptor; - } - - @java.lang.Override - protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable - internalGetFieldAccessorTable() { - return com.google.cloud.iot.v1.ResourcesProto - .internal_static_google_cloud_iot_v1_DeviceCredential_fieldAccessorTable - .ensureFieldAccessorsInitialized( - com.google.cloud.iot.v1.DeviceCredential.class, - com.google.cloud.iot.v1.DeviceCredential.Builder.class); - } - - // Construct using com.google.cloud.iot.v1.DeviceCredential.newBuilder() - private Builder() {} - - private Builder(com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { - super(parent); - } - - @java.lang.Override - public Builder clear() { - super.clear(); - if (publicKeyBuilder_ != null) { - publicKeyBuilder_.clear(); - } - if (expirationTimeBuilder_ == null) { - expirationTime_ = null; - } else { - expirationTime_ = null; - expirationTimeBuilder_ = null; - } - credentialCase_ = 0; - credential_ = null; - return this; - } - - @java.lang.Override - public com.google.protobuf.Descriptors.Descriptor getDescriptorForType() { - return com.google.cloud.iot.v1.ResourcesProto - .internal_static_google_cloud_iot_v1_DeviceCredential_descriptor; - } - - @java.lang.Override - public com.google.cloud.iot.v1.DeviceCredential getDefaultInstanceForType() { - return com.google.cloud.iot.v1.DeviceCredential.getDefaultInstance(); - } - - @java.lang.Override - public com.google.cloud.iot.v1.DeviceCredential build() { - com.google.cloud.iot.v1.DeviceCredential result = buildPartial(); - if (!result.isInitialized()) { - throw newUninitializedMessageException(result); - } - return result; - } - - @java.lang.Override - public com.google.cloud.iot.v1.DeviceCredential buildPartial() { - com.google.cloud.iot.v1.DeviceCredential result = - new com.google.cloud.iot.v1.DeviceCredential(this); - if (credentialCase_ == 2) { - if (publicKeyBuilder_ == null) { - result.credential_ = credential_; - } else { - result.credential_ = publicKeyBuilder_.build(); - } - } - if (expirationTimeBuilder_ == null) { - result.expirationTime_ = expirationTime_; - } else { - result.expirationTime_ = expirationTimeBuilder_.build(); - } - result.credentialCase_ = credentialCase_; - onBuilt(); - return result; - } - - @java.lang.Override - public Builder clone() { - return super.clone(); - } - - @java.lang.Override - public Builder setField( - com.google.protobuf.Descriptors.FieldDescriptor field, java.lang.Object value) { - return super.setField(field, value); - } - - @java.lang.Override - public Builder clearField(com.google.protobuf.Descriptors.FieldDescriptor field) { - return super.clearField(field); - } - - @java.lang.Override - public Builder clearOneof(com.google.protobuf.Descriptors.OneofDescriptor oneof) { - return super.clearOneof(oneof); - } - - @java.lang.Override - public Builder setRepeatedField( - com.google.protobuf.Descriptors.FieldDescriptor field, int index, java.lang.Object value) { - return super.setRepeatedField(field, index, value); - } - - @java.lang.Override - public Builder addRepeatedField( - com.google.protobuf.Descriptors.FieldDescriptor field, java.lang.Object value) { - return super.addRepeatedField(field, value); - } - - @java.lang.Override - public Builder mergeFrom(com.google.protobuf.Message other) { - if (other instanceof com.google.cloud.iot.v1.DeviceCredential) { - return mergeFrom((com.google.cloud.iot.v1.DeviceCredential) other); - } else { - super.mergeFrom(other); - return this; - } - } - - public Builder mergeFrom(com.google.cloud.iot.v1.DeviceCredential other) { - if (other == com.google.cloud.iot.v1.DeviceCredential.getDefaultInstance()) return this; - if (other.hasExpirationTime()) { - mergeExpirationTime(other.getExpirationTime()); - } - switch (other.getCredentialCase()) { - case PUBLIC_KEY: - { - mergePublicKey(other.getPublicKey()); - break; - } - case CREDENTIAL_NOT_SET: - { - break; - } - } - this.mergeUnknownFields(other.getUnknownFields()); - onChanged(); - return this; - } - - @java.lang.Override - public final boolean isInitialized() { - return true; - } - - @java.lang.Override - public Builder mergeFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - if (extensionRegistry == null) { - throw new java.lang.NullPointerException(); - } - try { - boolean done = false; - while (!done) { - int tag = input.readTag(); - switch (tag) { - case 0: - done = true; - break; - case 18: - { - input.readMessage(getPublicKeyFieldBuilder().getBuilder(), extensionRegistry); - credentialCase_ = 2; - break; - } // case 18 - case 50: - { - input.readMessage(getExpirationTimeFieldBuilder().getBuilder(), extensionRegistry); - - break; - } // case 50 - default: - { - if (!super.parseUnknownField(input, extensionRegistry, tag)) { - done = true; // was an endgroup tag - } - break; - } // default: - } // switch (tag) - } // while (!done) - } catch (com.google.protobuf.InvalidProtocolBufferException e) { - throw e.unwrapIOException(); - } finally { - onChanged(); - } // finally - return this; - } - - private int credentialCase_ = 0; - private java.lang.Object credential_; - - public CredentialCase getCredentialCase() { - return CredentialCase.forNumber(credentialCase_); - } - - public Builder clearCredential() { - credentialCase_ = 0; - credential_ = null; - onChanged(); - return this; - } - - private com.google.protobuf.SingleFieldBuilderV3< - com.google.cloud.iot.v1.PublicKeyCredential, - com.google.cloud.iot.v1.PublicKeyCredential.Builder, - com.google.cloud.iot.v1.PublicKeyCredentialOrBuilder> - publicKeyBuilder_; - /** - * - * - *
-     * A public key used to verify the signature of JSON Web Tokens (JWTs).
-     * When adding a new device credential, either via device creation or via
-     * modifications, this public key credential may be required to be signed by
-     * one of the registry level certificates. More specifically, if the
-     * registry contains at least one certificate, any new device credential
-     * must be signed by one of the registry certificates. As a result,
-     * when the registry contains certificates, only X.509 certificates are
-     * accepted as device credentials. However, if the registry does
-     * not contain a certificate, self-signed certificates and public keys will
-     * be accepted. New device credentials must be different from every
-     * registry-level certificate.
-     * 
- * - * .google.cloud.iot.v1.PublicKeyCredential public_key = 2; - * - * @return Whether the publicKey field is set. - */ - @java.lang.Override - public boolean hasPublicKey() { - return credentialCase_ == 2; - } - /** - * - * - *
-     * A public key used to verify the signature of JSON Web Tokens (JWTs).
-     * When adding a new device credential, either via device creation or via
-     * modifications, this public key credential may be required to be signed by
-     * one of the registry level certificates. More specifically, if the
-     * registry contains at least one certificate, any new device credential
-     * must be signed by one of the registry certificates. As a result,
-     * when the registry contains certificates, only X.509 certificates are
-     * accepted as device credentials. However, if the registry does
-     * not contain a certificate, self-signed certificates and public keys will
-     * be accepted. New device credentials must be different from every
-     * registry-level certificate.
-     * 
- * - * .google.cloud.iot.v1.PublicKeyCredential public_key = 2; - * - * @return The publicKey. - */ - @java.lang.Override - public com.google.cloud.iot.v1.PublicKeyCredential getPublicKey() { - if (publicKeyBuilder_ == null) { - if (credentialCase_ == 2) { - return (com.google.cloud.iot.v1.PublicKeyCredential) credential_; - } - return com.google.cloud.iot.v1.PublicKeyCredential.getDefaultInstance(); - } else { - if (credentialCase_ == 2) { - return publicKeyBuilder_.getMessage(); - } - return com.google.cloud.iot.v1.PublicKeyCredential.getDefaultInstance(); - } - } - /** - * - * - *
-     * A public key used to verify the signature of JSON Web Tokens (JWTs).
-     * When adding a new device credential, either via device creation or via
-     * modifications, this public key credential may be required to be signed by
-     * one of the registry level certificates. More specifically, if the
-     * registry contains at least one certificate, any new device credential
-     * must be signed by one of the registry certificates. As a result,
-     * when the registry contains certificates, only X.509 certificates are
-     * accepted as device credentials. However, if the registry does
-     * not contain a certificate, self-signed certificates and public keys will
-     * be accepted. New device credentials must be different from every
-     * registry-level certificate.
-     * 
- * - * .google.cloud.iot.v1.PublicKeyCredential public_key = 2; - */ - public Builder setPublicKey(com.google.cloud.iot.v1.PublicKeyCredential value) { - if (publicKeyBuilder_ == null) { - if (value == null) { - throw new NullPointerException(); - } - credential_ = value; - onChanged(); - } else { - publicKeyBuilder_.setMessage(value); - } - credentialCase_ = 2; - return this; - } - /** - * - * - *
-     * A public key used to verify the signature of JSON Web Tokens (JWTs).
-     * When adding a new device credential, either via device creation or via
-     * modifications, this public key credential may be required to be signed by
-     * one of the registry level certificates. More specifically, if the
-     * registry contains at least one certificate, any new device credential
-     * must be signed by one of the registry certificates. As a result,
-     * when the registry contains certificates, only X.509 certificates are
-     * accepted as device credentials. However, if the registry does
-     * not contain a certificate, self-signed certificates and public keys will
-     * be accepted. New device credentials must be different from every
-     * registry-level certificate.
-     * 
- * - * .google.cloud.iot.v1.PublicKeyCredential public_key = 2; - */ - public Builder setPublicKey( - com.google.cloud.iot.v1.PublicKeyCredential.Builder builderForValue) { - if (publicKeyBuilder_ == null) { - credential_ = builderForValue.build(); - onChanged(); - } else { - publicKeyBuilder_.setMessage(builderForValue.build()); - } - credentialCase_ = 2; - return this; - } - /** - * - * - *
-     * A public key used to verify the signature of JSON Web Tokens (JWTs).
-     * When adding a new device credential, either via device creation or via
-     * modifications, this public key credential may be required to be signed by
-     * one of the registry level certificates. More specifically, if the
-     * registry contains at least one certificate, any new device credential
-     * must be signed by one of the registry certificates. As a result,
-     * when the registry contains certificates, only X.509 certificates are
-     * accepted as device credentials. However, if the registry does
-     * not contain a certificate, self-signed certificates and public keys will
-     * be accepted. New device credentials must be different from every
-     * registry-level certificate.
-     * 
- * - * .google.cloud.iot.v1.PublicKeyCredential public_key = 2; - */ - public Builder mergePublicKey(com.google.cloud.iot.v1.PublicKeyCredential value) { - if (publicKeyBuilder_ == null) { - if (credentialCase_ == 2 - && credential_ != com.google.cloud.iot.v1.PublicKeyCredential.getDefaultInstance()) { - credential_ = - com.google.cloud.iot.v1.PublicKeyCredential.newBuilder( - (com.google.cloud.iot.v1.PublicKeyCredential) credential_) - .mergeFrom(value) - .buildPartial(); - } else { - credential_ = value; - } - onChanged(); - } else { - if (credentialCase_ == 2) { - publicKeyBuilder_.mergeFrom(value); - } else { - publicKeyBuilder_.setMessage(value); - } - } - credentialCase_ = 2; - return this; - } - /** - * - * - *
-     * A public key used to verify the signature of JSON Web Tokens (JWTs).
-     * When adding a new device credential, either via device creation or via
-     * modifications, this public key credential may be required to be signed by
-     * one of the registry level certificates. More specifically, if the
-     * registry contains at least one certificate, any new device credential
-     * must be signed by one of the registry certificates. As a result,
-     * when the registry contains certificates, only X.509 certificates are
-     * accepted as device credentials. However, if the registry does
-     * not contain a certificate, self-signed certificates and public keys will
-     * be accepted. New device credentials must be different from every
-     * registry-level certificate.
-     * 
- * - * .google.cloud.iot.v1.PublicKeyCredential public_key = 2; - */ - public Builder clearPublicKey() { - if (publicKeyBuilder_ == null) { - if (credentialCase_ == 2) { - credentialCase_ = 0; - credential_ = null; - onChanged(); - } - } else { - if (credentialCase_ == 2) { - credentialCase_ = 0; - credential_ = null; - } - publicKeyBuilder_.clear(); - } - return this; - } - /** - * - * - *
-     * A public key used to verify the signature of JSON Web Tokens (JWTs).
-     * When adding a new device credential, either via device creation or via
-     * modifications, this public key credential may be required to be signed by
-     * one of the registry level certificates. More specifically, if the
-     * registry contains at least one certificate, any new device credential
-     * must be signed by one of the registry certificates. As a result,
-     * when the registry contains certificates, only X.509 certificates are
-     * accepted as device credentials. However, if the registry does
-     * not contain a certificate, self-signed certificates and public keys will
-     * be accepted. New device credentials must be different from every
-     * registry-level certificate.
-     * 
- * - * .google.cloud.iot.v1.PublicKeyCredential public_key = 2; - */ - public com.google.cloud.iot.v1.PublicKeyCredential.Builder getPublicKeyBuilder() { - return getPublicKeyFieldBuilder().getBuilder(); - } - /** - * - * - *
-     * A public key used to verify the signature of JSON Web Tokens (JWTs).
-     * When adding a new device credential, either via device creation or via
-     * modifications, this public key credential may be required to be signed by
-     * one of the registry level certificates. More specifically, if the
-     * registry contains at least one certificate, any new device credential
-     * must be signed by one of the registry certificates. As a result,
-     * when the registry contains certificates, only X.509 certificates are
-     * accepted as device credentials. However, if the registry does
-     * not contain a certificate, self-signed certificates and public keys will
-     * be accepted. New device credentials must be different from every
-     * registry-level certificate.
-     * 
- * - * .google.cloud.iot.v1.PublicKeyCredential public_key = 2; - */ - @java.lang.Override - public com.google.cloud.iot.v1.PublicKeyCredentialOrBuilder getPublicKeyOrBuilder() { - if ((credentialCase_ == 2) && (publicKeyBuilder_ != null)) { - return publicKeyBuilder_.getMessageOrBuilder(); - } else { - if (credentialCase_ == 2) { - return (com.google.cloud.iot.v1.PublicKeyCredential) credential_; - } - return com.google.cloud.iot.v1.PublicKeyCredential.getDefaultInstance(); - } - } - /** - * - * - *
-     * A public key used to verify the signature of JSON Web Tokens (JWTs).
-     * When adding a new device credential, either via device creation or via
-     * modifications, this public key credential may be required to be signed by
-     * one of the registry level certificates. More specifically, if the
-     * registry contains at least one certificate, any new device credential
-     * must be signed by one of the registry certificates. As a result,
-     * when the registry contains certificates, only X.509 certificates are
-     * accepted as device credentials. However, if the registry does
-     * not contain a certificate, self-signed certificates and public keys will
-     * be accepted. New device credentials must be different from every
-     * registry-level certificate.
-     * 
- * - * .google.cloud.iot.v1.PublicKeyCredential public_key = 2; - */ - private com.google.protobuf.SingleFieldBuilderV3< - com.google.cloud.iot.v1.PublicKeyCredential, - com.google.cloud.iot.v1.PublicKeyCredential.Builder, - com.google.cloud.iot.v1.PublicKeyCredentialOrBuilder> - getPublicKeyFieldBuilder() { - if (publicKeyBuilder_ == null) { - if (!(credentialCase_ == 2)) { - credential_ = com.google.cloud.iot.v1.PublicKeyCredential.getDefaultInstance(); - } - publicKeyBuilder_ = - new com.google.protobuf.SingleFieldBuilderV3< - com.google.cloud.iot.v1.PublicKeyCredential, - com.google.cloud.iot.v1.PublicKeyCredential.Builder, - com.google.cloud.iot.v1.PublicKeyCredentialOrBuilder>( - (com.google.cloud.iot.v1.PublicKeyCredential) credential_, - getParentForChildren(), - isClean()); - credential_ = null; - } - credentialCase_ = 2; - onChanged(); - ; - return publicKeyBuilder_; - } - - private com.google.protobuf.Timestamp expirationTime_; - private com.google.protobuf.SingleFieldBuilderV3< - com.google.protobuf.Timestamp, - com.google.protobuf.Timestamp.Builder, - com.google.protobuf.TimestampOrBuilder> - expirationTimeBuilder_; - /** - * - * - *
-     * [Optional] The time at which this credential becomes invalid. This
-     * credential will be ignored for new client authentication requests after
-     * this timestamp; however, it will not be automatically deleted.
-     * 
- * - * .google.protobuf.Timestamp expiration_time = 6; - * - * @return Whether the expirationTime field is set. - */ - public boolean hasExpirationTime() { - return expirationTimeBuilder_ != null || expirationTime_ != null; - } - /** - * - * - *
-     * [Optional] The time at which this credential becomes invalid. This
-     * credential will be ignored for new client authentication requests after
-     * this timestamp; however, it will not be automatically deleted.
-     * 
- * - * .google.protobuf.Timestamp expiration_time = 6; - * - * @return The expirationTime. - */ - public com.google.protobuf.Timestamp getExpirationTime() { - if (expirationTimeBuilder_ == null) { - return expirationTime_ == null - ? com.google.protobuf.Timestamp.getDefaultInstance() - : expirationTime_; - } else { - return expirationTimeBuilder_.getMessage(); - } - } - /** - * - * - *
-     * [Optional] The time at which this credential becomes invalid. This
-     * credential will be ignored for new client authentication requests after
-     * this timestamp; however, it will not be automatically deleted.
-     * 
- * - * .google.protobuf.Timestamp expiration_time = 6; - */ - public Builder setExpirationTime(com.google.protobuf.Timestamp value) { - if (expirationTimeBuilder_ == null) { - if (value == null) { - throw new NullPointerException(); - } - expirationTime_ = value; - onChanged(); - } else { - expirationTimeBuilder_.setMessage(value); - } - - return this; - } - /** - * - * - *
-     * [Optional] The time at which this credential becomes invalid. This
-     * credential will be ignored for new client authentication requests after
-     * this timestamp; however, it will not be automatically deleted.
-     * 
- * - * .google.protobuf.Timestamp expiration_time = 6; - */ - public Builder setExpirationTime(com.google.protobuf.Timestamp.Builder builderForValue) { - if (expirationTimeBuilder_ == null) { - expirationTime_ = builderForValue.build(); - onChanged(); - } else { - expirationTimeBuilder_.setMessage(builderForValue.build()); - } - - return this; - } - /** - * - * - *
-     * [Optional] The time at which this credential becomes invalid. This
-     * credential will be ignored for new client authentication requests after
-     * this timestamp; however, it will not be automatically deleted.
-     * 
- * - * .google.protobuf.Timestamp expiration_time = 6; - */ - public Builder mergeExpirationTime(com.google.protobuf.Timestamp value) { - if (expirationTimeBuilder_ == null) { - if (expirationTime_ != null) { - expirationTime_ = - com.google.protobuf.Timestamp.newBuilder(expirationTime_) - .mergeFrom(value) - .buildPartial(); - } else { - expirationTime_ = value; - } - onChanged(); - } else { - expirationTimeBuilder_.mergeFrom(value); - } - - return this; - } - /** - * - * - *
-     * [Optional] The time at which this credential becomes invalid. This
-     * credential will be ignored for new client authentication requests after
-     * this timestamp; however, it will not be automatically deleted.
-     * 
- * - * .google.protobuf.Timestamp expiration_time = 6; - */ - public Builder clearExpirationTime() { - if (expirationTimeBuilder_ == null) { - expirationTime_ = null; - onChanged(); - } else { - expirationTime_ = null; - expirationTimeBuilder_ = null; - } - - return this; - } - /** - * - * - *
-     * [Optional] The time at which this credential becomes invalid. This
-     * credential will be ignored for new client authentication requests after
-     * this timestamp; however, it will not be automatically deleted.
-     * 
- * - * .google.protobuf.Timestamp expiration_time = 6; - */ - public com.google.protobuf.Timestamp.Builder getExpirationTimeBuilder() { - - onChanged(); - return getExpirationTimeFieldBuilder().getBuilder(); - } - /** - * - * - *
-     * [Optional] The time at which this credential becomes invalid. This
-     * credential will be ignored for new client authentication requests after
-     * this timestamp; however, it will not be automatically deleted.
-     * 
- * - * .google.protobuf.Timestamp expiration_time = 6; - */ - public com.google.protobuf.TimestampOrBuilder getExpirationTimeOrBuilder() { - if (expirationTimeBuilder_ != null) { - return expirationTimeBuilder_.getMessageOrBuilder(); - } else { - return expirationTime_ == null - ? com.google.protobuf.Timestamp.getDefaultInstance() - : expirationTime_; - } - } - /** - * - * - *
-     * [Optional] The time at which this credential becomes invalid. This
-     * credential will be ignored for new client authentication requests after
-     * this timestamp; however, it will not be automatically deleted.
-     * 
- * - * .google.protobuf.Timestamp expiration_time = 6; - */ - private com.google.protobuf.SingleFieldBuilderV3< - com.google.protobuf.Timestamp, - com.google.protobuf.Timestamp.Builder, - com.google.protobuf.TimestampOrBuilder> - getExpirationTimeFieldBuilder() { - if (expirationTimeBuilder_ == null) { - expirationTimeBuilder_ = - new com.google.protobuf.SingleFieldBuilderV3< - com.google.protobuf.Timestamp, - com.google.protobuf.Timestamp.Builder, - com.google.protobuf.TimestampOrBuilder>( - getExpirationTime(), getParentForChildren(), isClean()); - expirationTime_ = null; - } - return expirationTimeBuilder_; - } - - @java.lang.Override - public final Builder setUnknownFields(final com.google.protobuf.UnknownFieldSet unknownFields) { - return super.setUnknownFields(unknownFields); - } - - @java.lang.Override - public final Builder mergeUnknownFields( - final com.google.protobuf.UnknownFieldSet unknownFields) { - return super.mergeUnknownFields(unknownFields); - } - - // @@protoc_insertion_point(builder_scope:google.cloud.iot.v1.DeviceCredential) - } - - // @@protoc_insertion_point(class_scope:google.cloud.iot.v1.DeviceCredential) - private static final com.google.cloud.iot.v1.DeviceCredential DEFAULT_INSTANCE; - - static { - DEFAULT_INSTANCE = new com.google.cloud.iot.v1.DeviceCredential(); - } - - public static com.google.cloud.iot.v1.DeviceCredential getDefaultInstance() { - return DEFAULT_INSTANCE; - } - - private static final com.google.protobuf.Parser PARSER = - new com.google.protobuf.AbstractParser() { - @java.lang.Override - public DeviceCredential parsePartialFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - Builder builder = newBuilder(); - try { - builder.mergeFrom(input, extensionRegistry); - } catch (com.google.protobuf.InvalidProtocolBufferException e) { - throw e.setUnfinishedMessage(builder.buildPartial()); - } catch (com.google.protobuf.UninitializedMessageException e) { - throw e.asInvalidProtocolBufferException().setUnfinishedMessage(builder.buildPartial()); - } catch (java.io.IOException e) { - throw new com.google.protobuf.InvalidProtocolBufferException(e) - .setUnfinishedMessage(builder.buildPartial()); - } - return builder.buildPartial(); - } - }; - - public static com.google.protobuf.Parser parser() { - return PARSER; - } - - @java.lang.Override - public com.google.protobuf.Parser getParserForType() { - return PARSER; - } - - @java.lang.Override - public com.google.cloud.iot.v1.DeviceCredential getDefaultInstanceForType() { - return DEFAULT_INSTANCE; - } -} diff --git a/proto-google-cloud-iot-v1/src/main/java/com/google/cloud/iot/v1/DeviceCredentialOrBuilder.java b/proto-google-cloud-iot-v1/src/main/java/com/google/cloud/iot/v1/DeviceCredentialOrBuilder.java deleted file mode 100644 index 6f59a8f7..00000000 --- a/proto-google-cloud-iot-v1/src/main/java/com/google/cloud/iot/v1/DeviceCredentialOrBuilder.java +++ /dev/null @@ -1,133 +0,0 @@ -/* - * Copyright 2020 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. - */ -// Generated by the protocol buffer compiler. DO NOT EDIT! -// source: google/cloud/iot/v1/resources.proto - -package com.google.cloud.iot.v1; - -public interface DeviceCredentialOrBuilder - extends - // @@protoc_insertion_point(interface_extends:google.cloud.iot.v1.DeviceCredential) - com.google.protobuf.MessageOrBuilder { - - /** - * - * - *
-   * A public key used to verify the signature of JSON Web Tokens (JWTs).
-   * When adding a new device credential, either via device creation or via
-   * modifications, this public key credential may be required to be signed by
-   * one of the registry level certificates. More specifically, if the
-   * registry contains at least one certificate, any new device credential
-   * must be signed by one of the registry certificates. As a result,
-   * when the registry contains certificates, only X.509 certificates are
-   * accepted as device credentials. However, if the registry does
-   * not contain a certificate, self-signed certificates and public keys will
-   * be accepted. New device credentials must be different from every
-   * registry-level certificate.
-   * 
- * - * .google.cloud.iot.v1.PublicKeyCredential public_key = 2; - * - * @return Whether the publicKey field is set. - */ - boolean hasPublicKey(); - /** - * - * - *
-   * A public key used to verify the signature of JSON Web Tokens (JWTs).
-   * When adding a new device credential, either via device creation or via
-   * modifications, this public key credential may be required to be signed by
-   * one of the registry level certificates. More specifically, if the
-   * registry contains at least one certificate, any new device credential
-   * must be signed by one of the registry certificates. As a result,
-   * when the registry contains certificates, only X.509 certificates are
-   * accepted as device credentials. However, if the registry does
-   * not contain a certificate, self-signed certificates and public keys will
-   * be accepted. New device credentials must be different from every
-   * registry-level certificate.
-   * 
- * - * .google.cloud.iot.v1.PublicKeyCredential public_key = 2; - * - * @return The publicKey. - */ - com.google.cloud.iot.v1.PublicKeyCredential getPublicKey(); - /** - * - * - *
-   * A public key used to verify the signature of JSON Web Tokens (JWTs).
-   * When adding a new device credential, either via device creation or via
-   * modifications, this public key credential may be required to be signed by
-   * one of the registry level certificates. More specifically, if the
-   * registry contains at least one certificate, any new device credential
-   * must be signed by one of the registry certificates. As a result,
-   * when the registry contains certificates, only X.509 certificates are
-   * accepted as device credentials. However, if the registry does
-   * not contain a certificate, self-signed certificates and public keys will
-   * be accepted. New device credentials must be different from every
-   * registry-level certificate.
-   * 
- * - * .google.cloud.iot.v1.PublicKeyCredential public_key = 2; - */ - com.google.cloud.iot.v1.PublicKeyCredentialOrBuilder getPublicKeyOrBuilder(); - - /** - * - * - *
-   * [Optional] The time at which this credential becomes invalid. This
-   * credential will be ignored for new client authentication requests after
-   * this timestamp; however, it will not be automatically deleted.
-   * 
- * - * .google.protobuf.Timestamp expiration_time = 6; - * - * @return Whether the expirationTime field is set. - */ - boolean hasExpirationTime(); - /** - * - * - *
-   * [Optional] The time at which this credential becomes invalid. This
-   * credential will be ignored for new client authentication requests after
-   * this timestamp; however, it will not be automatically deleted.
-   * 
- * - * .google.protobuf.Timestamp expiration_time = 6; - * - * @return The expirationTime. - */ - com.google.protobuf.Timestamp getExpirationTime(); - /** - * - * - *
-   * [Optional] The time at which this credential becomes invalid. This
-   * credential will be ignored for new client authentication requests after
-   * this timestamp; however, it will not be automatically deleted.
-   * 
- * - * .google.protobuf.Timestamp expiration_time = 6; - */ - com.google.protobuf.TimestampOrBuilder getExpirationTimeOrBuilder(); - - public com.google.cloud.iot.v1.DeviceCredential.CredentialCase getCredentialCase(); -} diff --git a/proto-google-cloud-iot-v1/src/main/java/com/google/cloud/iot/v1/DeviceManagerProto.java b/proto-google-cloud-iot-v1/src/main/java/com/google/cloud/iot/v1/DeviceManagerProto.java deleted file mode 100644 index 2a170d40..00000000 --- a/proto-google-cloud-iot-v1/src/main/java/com/google/cloud/iot/v1/DeviceManagerProto.java +++ /dev/null @@ -1,568 +0,0 @@ -/* - * Copyright 2020 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. - */ -// Generated by the protocol buffer compiler. DO NOT EDIT! -// source: google/cloud/iot/v1/device_manager.proto - -package com.google.cloud.iot.v1; - -public final class DeviceManagerProto { - private DeviceManagerProto() {} - - public static void registerAllExtensions(com.google.protobuf.ExtensionRegistryLite registry) {} - - public static void registerAllExtensions(com.google.protobuf.ExtensionRegistry registry) { - registerAllExtensions((com.google.protobuf.ExtensionRegistryLite) registry); - } - - static final com.google.protobuf.Descriptors.Descriptor - internal_static_google_cloud_iot_v1_CreateDeviceRegistryRequest_descriptor; - static final com.google.protobuf.GeneratedMessageV3.FieldAccessorTable - internal_static_google_cloud_iot_v1_CreateDeviceRegistryRequest_fieldAccessorTable; - static final com.google.protobuf.Descriptors.Descriptor - internal_static_google_cloud_iot_v1_GetDeviceRegistryRequest_descriptor; - static final com.google.protobuf.GeneratedMessageV3.FieldAccessorTable - internal_static_google_cloud_iot_v1_GetDeviceRegistryRequest_fieldAccessorTable; - static final com.google.protobuf.Descriptors.Descriptor - internal_static_google_cloud_iot_v1_DeleteDeviceRegistryRequest_descriptor; - static final com.google.protobuf.GeneratedMessageV3.FieldAccessorTable - internal_static_google_cloud_iot_v1_DeleteDeviceRegistryRequest_fieldAccessorTable; - static final com.google.protobuf.Descriptors.Descriptor - internal_static_google_cloud_iot_v1_UpdateDeviceRegistryRequest_descriptor; - static final com.google.protobuf.GeneratedMessageV3.FieldAccessorTable - internal_static_google_cloud_iot_v1_UpdateDeviceRegistryRequest_fieldAccessorTable; - static final com.google.protobuf.Descriptors.Descriptor - internal_static_google_cloud_iot_v1_ListDeviceRegistriesRequest_descriptor; - static final com.google.protobuf.GeneratedMessageV3.FieldAccessorTable - internal_static_google_cloud_iot_v1_ListDeviceRegistriesRequest_fieldAccessorTable; - static final com.google.protobuf.Descriptors.Descriptor - internal_static_google_cloud_iot_v1_ListDeviceRegistriesResponse_descriptor; - static final com.google.protobuf.GeneratedMessageV3.FieldAccessorTable - internal_static_google_cloud_iot_v1_ListDeviceRegistriesResponse_fieldAccessorTable; - static final com.google.protobuf.Descriptors.Descriptor - internal_static_google_cloud_iot_v1_CreateDeviceRequest_descriptor; - static final com.google.protobuf.GeneratedMessageV3.FieldAccessorTable - internal_static_google_cloud_iot_v1_CreateDeviceRequest_fieldAccessorTable; - static final com.google.protobuf.Descriptors.Descriptor - internal_static_google_cloud_iot_v1_GetDeviceRequest_descriptor; - static final com.google.protobuf.GeneratedMessageV3.FieldAccessorTable - internal_static_google_cloud_iot_v1_GetDeviceRequest_fieldAccessorTable; - static final com.google.protobuf.Descriptors.Descriptor - internal_static_google_cloud_iot_v1_UpdateDeviceRequest_descriptor; - static final com.google.protobuf.GeneratedMessageV3.FieldAccessorTable - internal_static_google_cloud_iot_v1_UpdateDeviceRequest_fieldAccessorTable; - static final com.google.protobuf.Descriptors.Descriptor - internal_static_google_cloud_iot_v1_DeleteDeviceRequest_descriptor; - static final com.google.protobuf.GeneratedMessageV3.FieldAccessorTable - internal_static_google_cloud_iot_v1_DeleteDeviceRequest_fieldAccessorTable; - static final com.google.protobuf.Descriptors.Descriptor - internal_static_google_cloud_iot_v1_ListDevicesRequest_descriptor; - static final com.google.protobuf.GeneratedMessageV3.FieldAccessorTable - internal_static_google_cloud_iot_v1_ListDevicesRequest_fieldAccessorTable; - static final com.google.protobuf.Descriptors.Descriptor - internal_static_google_cloud_iot_v1_GatewayListOptions_descriptor; - static final com.google.protobuf.GeneratedMessageV3.FieldAccessorTable - internal_static_google_cloud_iot_v1_GatewayListOptions_fieldAccessorTable; - static final com.google.protobuf.Descriptors.Descriptor - internal_static_google_cloud_iot_v1_ListDevicesResponse_descriptor; - static final com.google.protobuf.GeneratedMessageV3.FieldAccessorTable - internal_static_google_cloud_iot_v1_ListDevicesResponse_fieldAccessorTable; - static final com.google.protobuf.Descriptors.Descriptor - internal_static_google_cloud_iot_v1_ModifyCloudToDeviceConfigRequest_descriptor; - static final com.google.protobuf.GeneratedMessageV3.FieldAccessorTable - internal_static_google_cloud_iot_v1_ModifyCloudToDeviceConfigRequest_fieldAccessorTable; - static final com.google.protobuf.Descriptors.Descriptor - internal_static_google_cloud_iot_v1_ListDeviceConfigVersionsRequest_descriptor; - static final com.google.protobuf.GeneratedMessageV3.FieldAccessorTable - internal_static_google_cloud_iot_v1_ListDeviceConfigVersionsRequest_fieldAccessorTable; - static final com.google.protobuf.Descriptors.Descriptor - internal_static_google_cloud_iot_v1_ListDeviceConfigVersionsResponse_descriptor; - static final com.google.protobuf.GeneratedMessageV3.FieldAccessorTable - internal_static_google_cloud_iot_v1_ListDeviceConfigVersionsResponse_fieldAccessorTable; - static final com.google.protobuf.Descriptors.Descriptor - internal_static_google_cloud_iot_v1_ListDeviceStatesRequest_descriptor; - static final com.google.protobuf.GeneratedMessageV3.FieldAccessorTable - internal_static_google_cloud_iot_v1_ListDeviceStatesRequest_fieldAccessorTable; - static final com.google.protobuf.Descriptors.Descriptor - internal_static_google_cloud_iot_v1_ListDeviceStatesResponse_descriptor; - static final com.google.protobuf.GeneratedMessageV3.FieldAccessorTable - internal_static_google_cloud_iot_v1_ListDeviceStatesResponse_fieldAccessorTable; - static final com.google.protobuf.Descriptors.Descriptor - internal_static_google_cloud_iot_v1_SendCommandToDeviceRequest_descriptor; - static final com.google.protobuf.GeneratedMessageV3.FieldAccessorTable - internal_static_google_cloud_iot_v1_SendCommandToDeviceRequest_fieldAccessorTable; - static final com.google.protobuf.Descriptors.Descriptor - internal_static_google_cloud_iot_v1_SendCommandToDeviceResponse_descriptor; - static final com.google.protobuf.GeneratedMessageV3.FieldAccessorTable - internal_static_google_cloud_iot_v1_SendCommandToDeviceResponse_fieldAccessorTable; - static final com.google.protobuf.Descriptors.Descriptor - internal_static_google_cloud_iot_v1_BindDeviceToGatewayRequest_descriptor; - static final com.google.protobuf.GeneratedMessageV3.FieldAccessorTable - internal_static_google_cloud_iot_v1_BindDeviceToGatewayRequest_fieldAccessorTable; - static final com.google.protobuf.Descriptors.Descriptor - internal_static_google_cloud_iot_v1_BindDeviceToGatewayResponse_descriptor; - static final com.google.protobuf.GeneratedMessageV3.FieldAccessorTable - internal_static_google_cloud_iot_v1_BindDeviceToGatewayResponse_fieldAccessorTable; - static final com.google.protobuf.Descriptors.Descriptor - internal_static_google_cloud_iot_v1_UnbindDeviceFromGatewayRequest_descriptor; - static final com.google.protobuf.GeneratedMessageV3.FieldAccessorTable - internal_static_google_cloud_iot_v1_UnbindDeviceFromGatewayRequest_fieldAccessorTable; - static final com.google.protobuf.Descriptors.Descriptor - internal_static_google_cloud_iot_v1_UnbindDeviceFromGatewayResponse_descriptor; - static final com.google.protobuf.GeneratedMessageV3.FieldAccessorTable - internal_static_google_cloud_iot_v1_UnbindDeviceFromGatewayResponse_fieldAccessorTable; - - public static com.google.protobuf.Descriptors.FileDescriptor getDescriptor() { - return descriptor; - } - - private static com.google.protobuf.Descriptors.FileDescriptor descriptor; - - static { - java.lang.String[] descriptorData = { - "\n(google/cloud/iot/v1/device_manager.pro" - + "to\022\023google.cloud.iot.v1\032\034google/api/anno" - + "tations.proto\032\027google/api/client.proto\032\037" - + "google/api/field_behavior.proto\032\031google/" - + "api/resource.proto\032#google/cloud/iot/v1/" - + "resources.proto\032\036google/iam/v1/iam_polic" - + "y.proto\032\032google/iam/v1/policy.proto\032\033goo" - + "gle/protobuf/empty.proto\032 google/protobu" - + "f/field_mask.proto\"\233\001\n\033CreateDeviceRegis" - + "tryRequest\0229\n\006parent\030\001 \001(\tB)\340A\002\372A#\n!loca" - + "tions.googleapis.com/Location\022A\n\017device_" - + "registry\030\002 \001(\0132#.google.cloud.iot.v1.Dev" - + "iceRegistryB\003\340A\002\"R\n\030GetDeviceRegistryReq" - + "uest\0226\n\004name\030\001 \001(\tB(\340A\002\372A\"\n cloudiot.goo" - + "gleapis.com/Registry\"U\n\033DeleteDeviceRegi" - + "stryRequest\0226\n\004name\030\001 \001(\tB(\340A\002\372A\"\n cloud" - + "iot.googleapis.com/Registry\"\226\001\n\033UpdateDe" - + "viceRegistryRequest\022A\n\017device_registry\030\001" - + " \001(\0132#.google.cloud.iot.v1.DeviceRegistr" - + "yB\003\340A\002\0224\n\013update_mask\030\002 \001(\0132\032.google.pro" - + "tobuf.FieldMaskB\003\340A\002\"\177\n\033ListDeviceRegist" - + "riesRequest\0229\n\006parent\030\001 \001(\tB)\340A\002\372A#\n!loc" - + "ations.googleapis.com/Location\022\021\n\tpage_s" - + "ize\030\002 \001(\005\022\022\n\npage_token\030\003 \001(\t\"w\n\034ListDev" - + "iceRegistriesResponse\022>\n\021device_registri" - + "es\030\001 \003(\0132#.google.cloud.iot.v1.DeviceReg" - + "istry\022\027\n\017next_page_token\030\002 \001(\t\"\201\001\n\023Creat" - + "eDeviceRequest\0228\n\006parent\030\001 \001(\tB(\340A\002\372A\"\n " - + "cloudiot.googleapis.com/Registry\0220\n\006devi" - + "ce\030\002 \001(\0132\033.google.cloud.iot.v1.DeviceB\003\340" - + "A\002\"x\n\020GetDeviceRequest\0224\n\004name\030\001 \001(\tB&\340A" - + "\002\372A \n\036cloudiot.googleapis.com/Device\022.\n\n" - + "field_mask\030\002 \001(\0132\032.google.protobuf.Field" - + "Mask\"}\n\023UpdateDeviceRequest\0220\n\006device\030\002 " - + "\001(\0132\033.google.cloud.iot.v1.DeviceB\003\340A\002\0224\n" - + "\013update_mask\030\003 \001(\0132\032.google.protobuf.Fie" - + "ldMaskB\003\340A\002\"K\n\023DeleteDeviceRequest\0224\n\004na" - + "me\030\001 \001(\tB&\340A\002\372A \n\036cloudiot.googleapis.co" - + "m/Device\"\230\002\n\022ListDevicesRequest\0228\n\006paren" - + "t\030\001 \001(\tB(\340A\002\372A\"\n cloudiot.googleapis.com" - + "/Registry\022\026\n\016device_num_ids\030\002 \003(\004\022\022\n\ndev" - + "ice_ids\030\003 \003(\t\022.\n\nfield_mask\030\004 \001(\0132\032.goog" - + "le.protobuf.FieldMask\022E\n\024gateway_list_op" - + "tions\030\006 \001(\0132\'.google.cloud.iot.v1.Gatewa" - + "yListOptions\022\021\n\tpage_size\030d \001(\005\022\022\n\npage_" - + "token\030e \001(\t\"\235\001\n\022GatewayListOptions\0228\n\014ga" - + "teway_type\030\001 \001(\0162 .google.cloud.iot.v1.G" - + "atewayTypeH\000\022!\n\027associations_gateway_id\030" - + "\002 \001(\tH\000\022 \n\026associations_device_id\030\003 \001(\tH" - + "\000B\010\n\006filter\"\\\n\023ListDevicesResponse\022,\n\007de" - + "vices\030\001 \003(\0132\033.google.cloud.iot.v1.Device" - + "\022\027\n\017next_page_token\030\002 \001(\t\"\215\001\n ModifyClou" - + "dToDeviceConfigRequest\0224\n\004name\030\001 \001(\tB&\340A" - + "\002\372A \n\036cloudiot.googleapis.com/Device\022\031\n\021" - + "version_to_update\030\002 \001(\003\022\030\n\013binary_data\030\003" - + " \001(\014B\003\340A\002\"m\n\037ListDeviceConfigVersionsReq" - + "uest\0224\n\004name\030\001 \001(\tB&\340A\002\372A \n\036cloudiot.goo" - + "gleapis.com/Device\022\024\n\014num_versions\030\002 \001(\005" - + "\"]\n ListDeviceConfigVersionsResponse\0229\n\016" - + "device_configs\030\001 \003(\0132!.google.cloud.iot." - + "v1.DeviceConfig\"c\n\027ListDeviceStatesReque" - + "st\0224\n\004name\030\001 \001(\tB&\340A\002\372A \n\036cloudiot.googl" - + "eapis.com/Device\022\022\n\nnum_states\030\002 \001(\005\"S\n\030" - + "ListDeviceStatesResponse\0227\n\rdevice_state" - + "s\030\001 \003(\0132 .google.cloud.iot.v1.DeviceStat" - + "e\"\177\n\032SendCommandToDeviceRequest\0224\n\004name\030" - + "\001 \001(\tB&\340A\002\372A \n\036cloudiot.googleapis.com/D" - + "evice\022\030\n\013binary_data\030\002 \001(\014B\003\340A\002\022\021\n\tsubfo" - + "lder\030\003 \001(\t\"\035\n\033SendCommandToDeviceRespons" - + "e\"\207\001\n\032BindDeviceToGatewayRequest\0228\n\006pare" - + "nt\030\001 \001(\tB(\340A\002\372A\"\n cloudiot.googleapis.co" - + "m/Registry\022\027\n\ngateway_id\030\002 \001(\tB\003\340A\002\022\026\n\td" - + "evice_id\030\003 \001(\tB\003\340A\002\"\035\n\033BindDeviceToGatew" - + "ayResponse\"\213\001\n\036UnbindDeviceFromGatewayRe" - + "quest\0228\n\006parent\030\001 \001(\tB(\340A\002\372A\"\n cloudiot." - + "googleapis.com/Registry\022\027\n\ngateway_id\030\002 " - + "\001(\tB\003\340A\002\022\026\n\tdevice_id\030\003 \001(\tB\003\340A\002\"!\n\037Unbi" - + "ndDeviceFromGatewayResponse2\246&\n\rDeviceMa" - + "nager\022\317\001\n\024CreateDeviceRegistry\0220.google." - + "cloud.iot.v1.CreateDeviceRegistryRequest" - + "\032#.google.cloud.iot.v1.DeviceRegistry\"`\202" - + "\323\344\223\002A\"./v1/{parent=projects/*/locations/" - + "*}/registries:\017device_registry\332A\026parent," - + "device_registry\022\246\001\n\021GetDeviceRegistry\022-." - + "google.cloud.iot.v1.GetDeviceRegistryReq" - + "uest\032#.google.cloud.iot.v1.DeviceRegistr" - + "y\"=\202\323\344\223\0020\022./v1/{name=projects/*/location" - + "s/*/registries/*}\332A\004name\022\344\001\n\024UpdateDevic" - + "eRegistry\0220.google.cloud.iot.v1.UpdateDe" - + "viceRegistryRequest\032#.google.cloud.iot.v" - + "1.DeviceRegistry\"u\202\323\344\223\002Q2>/v1/{device_re" - + "gistry.name=projects/*/locations/*/regis" - + "tries/*}:\017device_registry\332A\033device_regis" - + "try,update_mask\022\237\001\n\024DeleteDeviceRegistry" - + "\0220.google.cloud.iot.v1.DeleteDeviceRegis" - + "tryRequest\032\026.google.protobuf.Empty\"=\202\323\344\223" - + "\0020*./v1/{name=projects/*/locations/*/reg" - + "istries/*}\332A\004name\022\274\001\n\024ListDeviceRegistri" - + "es\0220.google.cloud.iot.v1.ListDeviceRegis" - + "triesRequest\0321.google.cloud.iot.v1.ListD" - + "eviceRegistriesResponse\"?\202\323\344\223\0020\022./v1/{pa" - + "rent=projects/*/locations/*}/registries\332" - + "A\006parent\022\257\001\n\014CreateDevice\022(.google.cloud" - + ".iot.v1.CreateDeviceRequest\032\033.google.clo" - + "ud.iot.v1.Device\"X\202\323\344\223\002B\"8/v1/{parent=pr" - + "ojects/*/locations/*/registries/*}/devic" - + "es:\006device\332A\rparent,device\022\336\001\n\tGetDevice" - + "\022%.google.cloud.iot.v1.GetDeviceRequest\032" - + "\033.google.cloud.iot.v1.Device\"\214\001\202\323\344\223\002\177\0228/" - + "v1/{name=projects/*/locations/*/registri" - + "es/*/devices/*}ZC\022A/v1/{name=projects/*/" - + "locations/*/registries/*/groups/*/device" - + "s/*}\332A\004name\022\221\002\n\014UpdateDevice\022(.google.cl" - + "oud.iot.v1.UpdateDeviceRequest\032\033.google." - + "cloud.iot.v1.Device\"\271\001\202\323\344\223\002\235\0012?/v1/{devi" - + "ce.name=projects/*/locations/*/registrie" - + "s/*/devices/*}:\006deviceZR2H/v1/{device.na" - + "me=projects/*/locations/*/registries/*/g" - + "roups/*/devices/*}:\006device\332A\022device,upda" - + "te_mask\022\231\001\n\014DeleteDevice\022(.google.cloud." - + "iot.v1.DeleteDeviceRequest\032\026.google.prot" - + "obuf.Empty\"G\202\323\344\223\002:*8/v1/{name=projects/*" - + "/locations/*/registries/*/devices/*}\332A\004n" - + "ame\022\361\001\n\013ListDevices\022\'.google.cloud.iot.v" - + "1.ListDevicesRequest\032(.google.cloud.iot." - + "v1.ListDevicesResponse\"\216\001\202\323\344\223\002\177\0228/v1/{pa" - + "rent=projects/*/locations/*/registries/*" - + "}/devicesZC\022A/v1/{parent=projects/*/loca" - + "tions/*/registries/*/groups/*}/devices\332A" - + "\006parent\022\313\002\n\031ModifyCloudToDeviceConfig\0225." - + "google.cloud.iot.v1.ModifyCloudToDeviceC" - + "onfigRequest\032!.google.cloud.iot.v1.Devic" - + "eConfig\"\323\001\202\323\344\223\002\271\001\"R/v1/{name=projects/*/" - + "locations/*/registries/*/devices/*}:modi" - + "fyCloudToDeviceConfig:\001*Z`\"[/v1/{name=pr" - + "ojects/*/locations/*/registries/*/groups" - + "/*/devices/*}:modifyCloudToDeviceConfig:" - + "\001*\332A\020name,binary_data\022\265\002\n\030ListDeviceConf" - + "igVersions\0224.google.cloud.iot.v1.ListDev" - + "iceConfigVersionsRequest\0325.google.cloud." - + "iot.v1.ListDeviceConfigVersionsResponse\"" - + "\253\001\202\323\344\223\002\235\001\022G/v1/{name=projects/*/location" - + "s/*/registries/*/devices/*}/configVersio" - + "nsZR\022P/v1/{name=projects/*/locations/*/r" - + "egistries/*/groups/*/devices/*}/configVe" - + "rsions\332A\004name\022\215\002\n\020ListDeviceStates\022,.goo" - + "gle.cloud.iot.v1.ListDeviceStatesRequest" - + "\032-.google.cloud.iot.v1.ListDeviceStatesR" - + "esponse\"\233\001\202\323\344\223\002\215\001\022?/v1/{name=projects/*/" - + "locations/*/registries/*/devices/*}/stat" - + "esZJ\022H/v1/{name=projects/*/locations/*/r" - + "egistries/*/groups/*/devices/*}/states\332A" - + "\004name\022\370\001\n\014SetIamPolicy\022\".google.iam.v1.S" - + "etIamPolicyRequest\032\025.google.iam.v1.Polic" - + "y\"\254\001\202\323\344\223\002\223\001\"?/v1/{resource=projects/*/lo" - + "cations/*/registries/*}:setIamPolicy:\001*Z" - + "M\"H/v1/{resource=projects/*/locations/*/" - + "registries/*/groups/*}:setIamPolicy:\001*\332A" - + "\017resource,policy\022\361\001\n\014GetIamPolicy\022\".goog" - + "le.iam.v1.GetIamPolicyRequest\032\025.google.i" - + "am.v1.Policy\"\245\001\202\323\344\223\002\223\001\"?/v1/{resource=pr" - + "ojects/*/locations/*/registries/*}:getIa" - + "mPolicy:\001*ZM\"H/v1/{resource=projects/*/l" - + "ocations/*/registries/*/groups/*}:getIam" - + "Policy:\001*\332A\010resource\022\251\002\n\022TestIamPermissi" - + "ons\022(.google.iam.v1.TestIamPermissionsRe" - + "quest\032).google.iam.v1.TestIamPermissions" - + "Response\"\275\001\202\323\344\223\002\237\001\"E/v1/{resource=projec" - + "ts/*/locations/*/registries/*}:testIamPe" - + "rmissions:\001*ZS\"N/v1/{resource=projects/*" - + "/locations/*/registries/*/groups/*}:test" - + "IamPermissions:\001*\332A\024resource,permissions" - + "\022\337\002\n\023SendCommandToDevice\022/.google.cloud." - + "iot.v1.SendCommandToDeviceRequest\0320.goog" - + "le.cloud.iot.v1.SendCommandToDeviceRespo" - + "nse\"\344\001\202\323\344\223\002\255\001\"L/v1/{name=projects/*/loca" - + "tions/*/registries/*/devices/*}:sendComm" - + "andToDevice:\001*ZZ\"U/v1/{name=projects/*/l" - + "ocations/*/registries/*/groups/*/devices" - + "/*}:sendCommandToDevice:\001*\332A\020name,binary" - + "_data\332A\032name,binary_data,subfolder\022\275\002\n\023B" - + "indDeviceToGateway\022/.google.cloud.iot.v1" - + ".BindDeviceToGatewayRequest\0320.google.clo" - + "ud.iot.v1.BindDeviceToGatewayResponse\"\302\001" - + "\202\323\344\223\002\235\001\"D/v1/{parent=projects/*/location" - + "s/*/registries/*}:bindDeviceToGateway:\001*" - + "ZR\"M/v1/{parent=projects/*/locations/*/r" - + "egistries/*/groups/*}:bindDeviceToGatewa" - + "y:\001*\332A\033parent,gateway_id,device_id\022\321\002\n\027U" - + "nbindDeviceFromGateway\0223.google.cloud.io" - + "t.v1.UnbindDeviceFromGatewayRequest\0324.go" - + "ogle.cloud.iot.v1.UnbindDeviceFromGatewa" - + "yResponse\"\312\001\202\323\344\223\002\245\001\"H/v1/{parent=project" - + "s/*/locations/*/registries/*}:unbindDevi" - + "ceFromGateway:\001*ZV\"Q/v1/{parent=projects" - + "/*/locations/*/registries/*/groups/*}:un" - + "bindDeviceFromGateway:\001*\332A\033parent,gatewa" - + "y_id,device_id\032t\312A\027cloudiot.googleapis.c" - + "om\322AWhttps://www.googleapis.com/auth/clo" - + "ud-platform,https://www.googleapis.com/a" - + "uth/cloudiotBj\n\027com.google.cloud.iot.v1B" - + "\022DeviceManagerProtoP\001Z6google.golang.org" - + "/genproto/googleapis/cloud/iot/v1;iot\370\001\001" - + "b\006proto3" - }; - descriptor = - com.google.protobuf.Descriptors.FileDescriptor.internalBuildGeneratedFileFrom( - descriptorData, - new com.google.protobuf.Descriptors.FileDescriptor[] { - com.google.api.AnnotationsProto.getDescriptor(), - com.google.api.ClientProto.getDescriptor(), - com.google.api.FieldBehaviorProto.getDescriptor(), - com.google.api.ResourceProto.getDescriptor(), - com.google.cloud.iot.v1.ResourcesProto.getDescriptor(), - com.google.iam.v1.IamPolicyProto.getDescriptor(), - com.google.iam.v1.PolicyProto.getDescriptor(), - com.google.protobuf.EmptyProto.getDescriptor(), - com.google.protobuf.FieldMaskProto.getDescriptor(), - }); - internal_static_google_cloud_iot_v1_CreateDeviceRegistryRequest_descriptor = - getDescriptor().getMessageTypes().get(0); - internal_static_google_cloud_iot_v1_CreateDeviceRegistryRequest_fieldAccessorTable = - new com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( - internal_static_google_cloud_iot_v1_CreateDeviceRegistryRequest_descriptor, - new java.lang.String[] { - "Parent", "DeviceRegistry", - }); - internal_static_google_cloud_iot_v1_GetDeviceRegistryRequest_descriptor = - getDescriptor().getMessageTypes().get(1); - internal_static_google_cloud_iot_v1_GetDeviceRegistryRequest_fieldAccessorTable = - new com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( - internal_static_google_cloud_iot_v1_GetDeviceRegistryRequest_descriptor, - new java.lang.String[] { - "Name", - }); - internal_static_google_cloud_iot_v1_DeleteDeviceRegistryRequest_descriptor = - getDescriptor().getMessageTypes().get(2); - internal_static_google_cloud_iot_v1_DeleteDeviceRegistryRequest_fieldAccessorTable = - new com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( - internal_static_google_cloud_iot_v1_DeleteDeviceRegistryRequest_descriptor, - new java.lang.String[] { - "Name", - }); - internal_static_google_cloud_iot_v1_UpdateDeviceRegistryRequest_descriptor = - getDescriptor().getMessageTypes().get(3); - internal_static_google_cloud_iot_v1_UpdateDeviceRegistryRequest_fieldAccessorTable = - new com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( - internal_static_google_cloud_iot_v1_UpdateDeviceRegistryRequest_descriptor, - new java.lang.String[] { - "DeviceRegistry", "UpdateMask", - }); - internal_static_google_cloud_iot_v1_ListDeviceRegistriesRequest_descriptor = - getDescriptor().getMessageTypes().get(4); - internal_static_google_cloud_iot_v1_ListDeviceRegistriesRequest_fieldAccessorTable = - new com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( - internal_static_google_cloud_iot_v1_ListDeviceRegistriesRequest_descriptor, - new java.lang.String[] { - "Parent", "PageSize", "PageToken", - }); - internal_static_google_cloud_iot_v1_ListDeviceRegistriesResponse_descriptor = - getDescriptor().getMessageTypes().get(5); - internal_static_google_cloud_iot_v1_ListDeviceRegistriesResponse_fieldAccessorTable = - new com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( - internal_static_google_cloud_iot_v1_ListDeviceRegistriesResponse_descriptor, - new java.lang.String[] { - "DeviceRegistries", "NextPageToken", - }); - internal_static_google_cloud_iot_v1_CreateDeviceRequest_descriptor = - getDescriptor().getMessageTypes().get(6); - internal_static_google_cloud_iot_v1_CreateDeviceRequest_fieldAccessorTable = - new com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( - internal_static_google_cloud_iot_v1_CreateDeviceRequest_descriptor, - new java.lang.String[] { - "Parent", "Device", - }); - internal_static_google_cloud_iot_v1_GetDeviceRequest_descriptor = - getDescriptor().getMessageTypes().get(7); - internal_static_google_cloud_iot_v1_GetDeviceRequest_fieldAccessorTable = - new com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( - internal_static_google_cloud_iot_v1_GetDeviceRequest_descriptor, - new java.lang.String[] { - "Name", "FieldMask", - }); - internal_static_google_cloud_iot_v1_UpdateDeviceRequest_descriptor = - getDescriptor().getMessageTypes().get(8); - internal_static_google_cloud_iot_v1_UpdateDeviceRequest_fieldAccessorTable = - new com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( - internal_static_google_cloud_iot_v1_UpdateDeviceRequest_descriptor, - new java.lang.String[] { - "Device", "UpdateMask", - }); - internal_static_google_cloud_iot_v1_DeleteDeviceRequest_descriptor = - getDescriptor().getMessageTypes().get(9); - internal_static_google_cloud_iot_v1_DeleteDeviceRequest_fieldAccessorTable = - new com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( - internal_static_google_cloud_iot_v1_DeleteDeviceRequest_descriptor, - new java.lang.String[] { - "Name", - }); - internal_static_google_cloud_iot_v1_ListDevicesRequest_descriptor = - getDescriptor().getMessageTypes().get(10); - internal_static_google_cloud_iot_v1_ListDevicesRequest_fieldAccessorTable = - new com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( - internal_static_google_cloud_iot_v1_ListDevicesRequest_descriptor, - new java.lang.String[] { - "Parent", - "DeviceNumIds", - "DeviceIds", - "FieldMask", - "GatewayListOptions", - "PageSize", - "PageToken", - }); - internal_static_google_cloud_iot_v1_GatewayListOptions_descriptor = - getDescriptor().getMessageTypes().get(11); - internal_static_google_cloud_iot_v1_GatewayListOptions_fieldAccessorTable = - new com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( - internal_static_google_cloud_iot_v1_GatewayListOptions_descriptor, - new java.lang.String[] { - "GatewayType", "AssociationsGatewayId", "AssociationsDeviceId", "Filter", - }); - internal_static_google_cloud_iot_v1_ListDevicesResponse_descriptor = - getDescriptor().getMessageTypes().get(12); - internal_static_google_cloud_iot_v1_ListDevicesResponse_fieldAccessorTable = - new com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( - internal_static_google_cloud_iot_v1_ListDevicesResponse_descriptor, - new java.lang.String[] { - "Devices", "NextPageToken", - }); - internal_static_google_cloud_iot_v1_ModifyCloudToDeviceConfigRequest_descriptor = - getDescriptor().getMessageTypes().get(13); - internal_static_google_cloud_iot_v1_ModifyCloudToDeviceConfigRequest_fieldAccessorTable = - new com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( - internal_static_google_cloud_iot_v1_ModifyCloudToDeviceConfigRequest_descriptor, - new java.lang.String[] { - "Name", "VersionToUpdate", "BinaryData", - }); - internal_static_google_cloud_iot_v1_ListDeviceConfigVersionsRequest_descriptor = - getDescriptor().getMessageTypes().get(14); - internal_static_google_cloud_iot_v1_ListDeviceConfigVersionsRequest_fieldAccessorTable = - new com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( - internal_static_google_cloud_iot_v1_ListDeviceConfigVersionsRequest_descriptor, - new java.lang.String[] { - "Name", "NumVersions", - }); - internal_static_google_cloud_iot_v1_ListDeviceConfigVersionsResponse_descriptor = - getDescriptor().getMessageTypes().get(15); - internal_static_google_cloud_iot_v1_ListDeviceConfigVersionsResponse_fieldAccessorTable = - new com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( - internal_static_google_cloud_iot_v1_ListDeviceConfigVersionsResponse_descriptor, - new java.lang.String[] { - "DeviceConfigs", - }); - internal_static_google_cloud_iot_v1_ListDeviceStatesRequest_descriptor = - getDescriptor().getMessageTypes().get(16); - internal_static_google_cloud_iot_v1_ListDeviceStatesRequest_fieldAccessorTable = - new com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( - internal_static_google_cloud_iot_v1_ListDeviceStatesRequest_descriptor, - new java.lang.String[] { - "Name", "NumStates", - }); - internal_static_google_cloud_iot_v1_ListDeviceStatesResponse_descriptor = - getDescriptor().getMessageTypes().get(17); - internal_static_google_cloud_iot_v1_ListDeviceStatesResponse_fieldAccessorTable = - new com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( - internal_static_google_cloud_iot_v1_ListDeviceStatesResponse_descriptor, - new java.lang.String[] { - "DeviceStates", - }); - internal_static_google_cloud_iot_v1_SendCommandToDeviceRequest_descriptor = - getDescriptor().getMessageTypes().get(18); - internal_static_google_cloud_iot_v1_SendCommandToDeviceRequest_fieldAccessorTable = - new com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( - internal_static_google_cloud_iot_v1_SendCommandToDeviceRequest_descriptor, - new java.lang.String[] { - "Name", "BinaryData", "Subfolder", - }); - internal_static_google_cloud_iot_v1_SendCommandToDeviceResponse_descriptor = - getDescriptor().getMessageTypes().get(19); - internal_static_google_cloud_iot_v1_SendCommandToDeviceResponse_fieldAccessorTable = - new com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( - internal_static_google_cloud_iot_v1_SendCommandToDeviceResponse_descriptor, - new java.lang.String[] {}); - internal_static_google_cloud_iot_v1_BindDeviceToGatewayRequest_descriptor = - getDescriptor().getMessageTypes().get(20); - internal_static_google_cloud_iot_v1_BindDeviceToGatewayRequest_fieldAccessorTable = - new com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( - internal_static_google_cloud_iot_v1_BindDeviceToGatewayRequest_descriptor, - new java.lang.String[] { - "Parent", "GatewayId", "DeviceId", - }); - internal_static_google_cloud_iot_v1_BindDeviceToGatewayResponse_descriptor = - getDescriptor().getMessageTypes().get(21); - internal_static_google_cloud_iot_v1_BindDeviceToGatewayResponse_fieldAccessorTable = - new com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( - internal_static_google_cloud_iot_v1_BindDeviceToGatewayResponse_descriptor, - new java.lang.String[] {}); - internal_static_google_cloud_iot_v1_UnbindDeviceFromGatewayRequest_descriptor = - getDescriptor().getMessageTypes().get(22); - internal_static_google_cloud_iot_v1_UnbindDeviceFromGatewayRequest_fieldAccessorTable = - new com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( - internal_static_google_cloud_iot_v1_UnbindDeviceFromGatewayRequest_descriptor, - new java.lang.String[] { - "Parent", "GatewayId", "DeviceId", - }); - internal_static_google_cloud_iot_v1_UnbindDeviceFromGatewayResponse_descriptor = - getDescriptor().getMessageTypes().get(23); - internal_static_google_cloud_iot_v1_UnbindDeviceFromGatewayResponse_fieldAccessorTable = - new com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( - internal_static_google_cloud_iot_v1_UnbindDeviceFromGatewayResponse_descriptor, - new java.lang.String[] {}); - com.google.protobuf.ExtensionRegistry registry = - com.google.protobuf.ExtensionRegistry.newInstance(); - registry.add(com.google.api.ClientProto.defaultHost); - registry.add(com.google.api.FieldBehaviorProto.fieldBehavior); - registry.add(com.google.api.AnnotationsProto.http); - registry.add(com.google.api.ClientProto.methodSignature); - registry.add(com.google.api.ClientProto.oauthScopes); - registry.add(com.google.api.ResourceProto.resourceReference); - com.google.protobuf.Descriptors.FileDescriptor.internalUpdateFileDescriptor( - descriptor, registry); - com.google.api.AnnotationsProto.getDescriptor(); - com.google.api.ClientProto.getDescriptor(); - com.google.api.FieldBehaviorProto.getDescriptor(); - com.google.api.ResourceProto.getDescriptor(); - com.google.cloud.iot.v1.ResourcesProto.getDescriptor(); - com.google.iam.v1.IamPolicyProto.getDescriptor(); - com.google.iam.v1.PolicyProto.getDescriptor(); - com.google.protobuf.EmptyProto.getDescriptor(); - com.google.protobuf.FieldMaskProto.getDescriptor(); - } - - // @@protoc_insertion_point(outer_class_scope) -} diff --git a/proto-google-cloud-iot-v1/src/main/java/com/google/cloud/iot/v1/DeviceName.java b/proto-google-cloud-iot-v1/src/main/java/com/google/cloud/iot/v1/DeviceName.java deleted file mode 100644 index 124201d6..00000000 --- a/proto-google-cloud-iot-v1/src/main/java/com/google/cloud/iot/v1/DeviceName.java +++ /dev/null @@ -1,257 +0,0 @@ -/* - * 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 com.google.api.pathtemplate.PathTemplate; -import com.google.api.resourcenames.ResourceName; -import com.google.common.base.Preconditions; -import com.google.common.collect.ImmutableMap; -import java.util.ArrayList; -import java.util.List; -import java.util.Map; -import java.util.Objects; -import javax.annotation.Generated; - -// AUTO-GENERATED DOCUMENTATION AND CLASS. -@Generated("by gapic-generator-java") -public class DeviceName implements ResourceName { - private static final PathTemplate PROJECT_LOCATION_REGISTRY_DEVICE = - PathTemplate.createWithoutUrlEncoding( - "projects/{project}/locations/{location}/registries/{registry}/devices/{device}"); - private volatile Map fieldValuesMap; - private final String project; - private final String location; - private final String registry; - private final String device; - - @Deprecated - protected DeviceName() { - project = null; - location = null; - registry = null; - device = null; - } - - private DeviceName(Builder builder) { - project = Preconditions.checkNotNull(builder.getProject()); - location = Preconditions.checkNotNull(builder.getLocation()); - registry = Preconditions.checkNotNull(builder.getRegistry()); - device = Preconditions.checkNotNull(builder.getDevice()); - } - - public String getProject() { - return project; - } - - public String getLocation() { - return location; - } - - public String getRegistry() { - return registry; - } - - public String getDevice() { - return device; - } - - public static Builder newBuilder() { - return new Builder(); - } - - public Builder toBuilder() { - return new Builder(this); - } - - public static DeviceName of(String project, String location, String registry, String device) { - return newBuilder() - .setProject(project) - .setLocation(location) - .setRegistry(registry) - .setDevice(device) - .build(); - } - - public static String format(String project, String location, String registry, String device) { - return newBuilder() - .setProject(project) - .setLocation(location) - .setRegistry(registry) - .setDevice(device) - .build() - .toString(); - } - - public static DeviceName parse(String formattedString) { - if (formattedString.isEmpty()) { - return null; - } - Map matchMap = - PROJECT_LOCATION_REGISTRY_DEVICE.validatedMatch( - formattedString, "DeviceName.parse: formattedString not in valid format"); - return of( - matchMap.get("project"), - matchMap.get("location"), - matchMap.get("registry"), - matchMap.get("device")); - } - - public static List parseList(List formattedStrings) { - List list = new ArrayList<>(formattedStrings.size()); - for (String formattedString : formattedStrings) { - list.add(parse(formattedString)); - } - return list; - } - - public static List toStringList(List values) { - List list = new ArrayList<>(values.size()); - for (DeviceName value : values) { - if (value == null) { - list.add(""); - } else { - list.add(value.toString()); - } - } - return list; - } - - public static boolean isParsableFrom(String formattedString) { - return PROJECT_LOCATION_REGISTRY_DEVICE.matches(formattedString); - } - - @Override - public Map getFieldValuesMap() { - if (fieldValuesMap == null) { - synchronized (this) { - if (fieldValuesMap == null) { - ImmutableMap.Builder fieldMapBuilder = ImmutableMap.builder(); - if (project != null) { - fieldMapBuilder.put("project", project); - } - if (location != null) { - fieldMapBuilder.put("location", location); - } - if (registry != null) { - fieldMapBuilder.put("registry", registry); - } - if (device != null) { - fieldMapBuilder.put("device", device); - } - fieldValuesMap = fieldMapBuilder.build(); - } - } - } - return fieldValuesMap; - } - - public String getFieldValue(String fieldName) { - return getFieldValuesMap().get(fieldName); - } - - @Override - public String toString() { - return PROJECT_LOCATION_REGISTRY_DEVICE.instantiate( - "project", project, "location", location, "registry", registry, "device", device); - } - - @Override - public boolean equals(Object o) { - if (o == this) { - return true; - } - if (o != null || getClass() == o.getClass()) { - DeviceName that = ((DeviceName) o); - return Objects.equals(this.project, that.project) - && Objects.equals(this.location, that.location) - && Objects.equals(this.registry, that.registry) - && Objects.equals(this.device, that.device); - } - return false; - } - - @Override - public int hashCode() { - int h = 1; - h *= 1000003; - h ^= Objects.hashCode(project); - h *= 1000003; - h ^= Objects.hashCode(location); - h *= 1000003; - h ^= Objects.hashCode(registry); - h *= 1000003; - h ^= Objects.hashCode(device); - return h; - } - - /** Builder for projects/{project}/locations/{location}/registries/{registry}/devices/{device}. */ - public static class Builder { - private String project; - private String location; - private String registry; - private String device; - - protected Builder() {} - - public String getProject() { - return project; - } - - public String getLocation() { - return location; - } - - public String getRegistry() { - return registry; - } - - public String getDevice() { - return device; - } - - public Builder setProject(String project) { - this.project = project; - return this; - } - - public Builder setLocation(String location) { - this.location = location; - return this; - } - - public Builder setRegistry(String registry) { - this.registry = registry; - return this; - } - - public Builder setDevice(String device) { - this.device = device; - return this; - } - - private Builder(DeviceName deviceName) { - this.project = deviceName.project; - this.location = deviceName.location; - this.registry = deviceName.registry; - this.device = deviceName.device; - } - - public DeviceName build() { - return new DeviceName(this); - } - } -} diff --git a/proto-google-cloud-iot-v1/src/main/java/com/google/cloud/iot/v1/DeviceOrBuilder.java b/proto-google-cloud-iot-v1/src/main/java/com/google/cloud/iot/v1/DeviceOrBuilder.java deleted file mode 100644 index 7596ff3f..00000000 --- a/proto-google-cloud-iot-v1/src/main/java/com/google/cloud/iot/v1/DeviceOrBuilder.java +++ /dev/null @@ -1,735 +0,0 @@ -/* - * Copyright 2020 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. - */ -// Generated by the protocol buffer compiler. DO NOT EDIT! -// source: google/cloud/iot/v1/resources.proto - -package com.google.cloud.iot.v1; - -public interface DeviceOrBuilder - extends - // @@protoc_insertion_point(interface_extends:google.cloud.iot.v1.Device) - com.google.protobuf.MessageOrBuilder { - - /** - * - * - *
-   * The user-defined device identifier. The device ID must be unique
-   * within a device registry.
-   * 
- * - * string id = 1; - * - * @return The id. - */ - java.lang.String getId(); - /** - * - * - *
-   * The user-defined device identifier. The device ID must be unique
-   * within a device registry.
-   * 
- * - * string id = 1; - * - * @return The bytes for id. - */ - com.google.protobuf.ByteString getIdBytes(); - - /** - * - * - *
-   * The resource path name. For example,
-   * `projects/p1/locations/us-central1/registries/registry0/devices/dev0` or
-   * `projects/p1/locations/us-central1/registries/registry0/devices/{num_id}`.
-   * When `name` is populated as a response from the service, it always ends
-   * in the device numeric ID.
-   * 
- * - * string name = 2; - * - * @return The name. - */ - java.lang.String getName(); - /** - * - * - *
-   * The resource path name. For example,
-   * `projects/p1/locations/us-central1/registries/registry0/devices/dev0` or
-   * `projects/p1/locations/us-central1/registries/registry0/devices/{num_id}`.
-   * When `name` is populated as a response from the service, it always ends
-   * in the device numeric ID.
-   * 
- * - * string name = 2; - * - * @return The bytes for name. - */ - com.google.protobuf.ByteString getNameBytes(); - - /** - * - * - *
-   * [Output only] A server-defined unique numeric ID for the device. This is a
-   * more compact way to identify devices, and it is globally unique.
-   * 
- * - * uint64 num_id = 3; - * - * @return The numId. - */ - long getNumId(); - - /** - * - * - *
-   * The credentials used to authenticate this device. To allow credential
-   * rotation without interruption, multiple device credentials can be bound to
-   * this device. No more than 3 credentials can be bound to a single device at
-   * a time. When new credentials are added to a device, they are verified
-   * against the registry credentials. For details, see the description of the
-   * `DeviceRegistry.credentials` field.
-   * 
- * - * repeated .google.cloud.iot.v1.DeviceCredential credentials = 12; - */ - java.util.List getCredentialsList(); - /** - * - * - *
-   * The credentials used to authenticate this device. To allow credential
-   * rotation without interruption, multiple device credentials can be bound to
-   * this device. No more than 3 credentials can be bound to a single device at
-   * a time. When new credentials are added to a device, they are verified
-   * against the registry credentials. For details, see the description of the
-   * `DeviceRegistry.credentials` field.
-   * 
- * - * repeated .google.cloud.iot.v1.DeviceCredential credentials = 12; - */ - com.google.cloud.iot.v1.DeviceCredential getCredentials(int index); - /** - * - * - *
-   * The credentials used to authenticate this device. To allow credential
-   * rotation without interruption, multiple device credentials can be bound to
-   * this device. No more than 3 credentials can be bound to a single device at
-   * a time. When new credentials are added to a device, they are verified
-   * against the registry credentials. For details, see the description of the
-   * `DeviceRegistry.credentials` field.
-   * 
- * - * repeated .google.cloud.iot.v1.DeviceCredential credentials = 12; - */ - int getCredentialsCount(); - /** - * - * - *
-   * The credentials used to authenticate this device. To allow credential
-   * rotation without interruption, multiple device credentials can be bound to
-   * this device. No more than 3 credentials can be bound to a single device at
-   * a time. When new credentials are added to a device, they are verified
-   * against the registry credentials. For details, see the description of the
-   * `DeviceRegistry.credentials` field.
-   * 
- * - * repeated .google.cloud.iot.v1.DeviceCredential credentials = 12; - */ - java.util.List - getCredentialsOrBuilderList(); - /** - * - * - *
-   * The credentials used to authenticate this device. To allow credential
-   * rotation without interruption, multiple device credentials can be bound to
-   * this device. No more than 3 credentials can be bound to a single device at
-   * a time. When new credentials are added to a device, they are verified
-   * against the registry credentials. For details, see the description of the
-   * `DeviceRegistry.credentials` field.
-   * 
- * - * repeated .google.cloud.iot.v1.DeviceCredential credentials = 12; - */ - com.google.cloud.iot.v1.DeviceCredentialOrBuilder getCredentialsOrBuilder(int index); - - /** - * - * - *
-   * [Output only] The last time an MQTT `PINGREQ` was received. This field
-   * applies only to devices connecting through MQTT. MQTT clients usually only
-   * send `PINGREQ` messages if the connection is idle, and no other messages
-   * have been sent. Timestamps are periodically collected and written to
-   * storage; they may be stale by a few minutes.
-   * 
- * - * .google.protobuf.Timestamp last_heartbeat_time = 7; - * - * @return Whether the lastHeartbeatTime field is set. - */ - boolean hasLastHeartbeatTime(); - /** - * - * - *
-   * [Output only] The last time an MQTT `PINGREQ` was received. This field
-   * applies only to devices connecting through MQTT. MQTT clients usually only
-   * send `PINGREQ` messages if the connection is idle, and no other messages
-   * have been sent. Timestamps are periodically collected and written to
-   * storage; they may be stale by a few minutes.
-   * 
- * - * .google.protobuf.Timestamp last_heartbeat_time = 7; - * - * @return The lastHeartbeatTime. - */ - com.google.protobuf.Timestamp getLastHeartbeatTime(); - /** - * - * - *
-   * [Output only] The last time an MQTT `PINGREQ` was received. This field
-   * applies only to devices connecting through MQTT. MQTT clients usually only
-   * send `PINGREQ` messages if the connection is idle, and no other messages
-   * have been sent. Timestamps are periodically collected and written to
-   * storage; they may be stale by a few minutes.
-   * 
- * - * .google.protobuf.Timestamp last_heartbeat_time = 7; - */ - com.google.protobuf.TimestampOrBuilder getLastHeartbeatTimeOrBuilder(); - - /** - * - * - *
-   * [Output only] The last time a telemetry event was received. Timestamps are
-   * periodically collected and written to storage; they may be stale by a few
-   * minutes.
-   * 
- * - * .google.protobuf.Timestamp last_event_time = 8; - * - * @return Whether the lastEventTime field is set. - */ - boolean hasLastEventTime(); - /** - * - * - *
-   * [Output only] The last time a telemetry event was received. Timestamps are
-   * periodically collected and written to storage; they may be stale by a few
-   * minutes.
-   * 
- * - * .google.protobuf.Timestamp last_event_time = 8; - * - * @return The lastEventTime. - */ - com.google.protobuf.Timestamp getLastEventTime(); - /** - * - * - *
-   * [Output only] The last time a telemetry event was received. Timestamps are
-   * periodically collected and written to storage; they may be stale by a few
-   * minutes.
-   * 
- * - * .google.protobuf.Timestamp last_event_time = 8; - */ - com.google.protobuf.TimestampOrBuilder getLastEventTimeOrBuilder(); - - /** - * - * - *
-   * [Output only] The last time a state event was received. Timestamps are
-   * periodically collected and written to storage; they may be stale by a few
-   * minutes.
-   * 
- * - * .google.protobuf.Timestamp last_state_time = 20; - * - * @return Whether the lastStateTime field is set. - */ - boolean hasLastStateTime(); - /** - * - * - *
-   * [Output only] The last time a state event was received. Timestamps are
-   * periodically collected and written to storage; they may be stale by a few
-   * minutes.
-   * 
- * - * .google.protobuf.Timestamp last_state_time = 20; - * - * @return The lastStateTime. - */ - com.google.protobuf.Timestamp getLastStateTime(); - /** - * - * - *
-   * [Output only] The last time a state event was received. Timestamps are
-   * periodically collected and written to storage; they may be stale by a few
-   * minutes.
-   * 
- * - * .google.protobuf.Timestamp last_state_time = 20; - */ - com.google.protobuf.TimestampOrBuilder getLastStateTimeOrBuilder(); - - /** - * - * - *
-   * [Output only] The last time a cloud-to-device config version acknowledgment
-   * was received from the device. This field is only for configurations
-   * sent through MQTT.
-   * 
- * - * .google.protobuf.Timestamp last_config_ack_time = 14; - * - * @return Whether the lastConfigAckTime field is set. - */ - boolean hasLastConfigAckTime(); - /** - * - * - *
-   * [Output only] The last time a cloud-to-device config version acknowledgment
-   * was received from the device. This field is only for configurations
-   * sent through MQTT.
-   * 
- * - * .google.protobuf.Timestamp last_config_ack_time = 14; - * - * @return The lastConfigAckTime. - */ - com.google.protobuf.Timestamp getLastConfigAckTime(); - /** - * - * - *
-   * [Output only] The last time a cloud-to-device config version acknowledgment
-   * was received from the device. This field is only for configurations
-   * sent through MQTT.
-   * 
- * - * .google.protobuf.Timestamp last_config_ack_time = 14; - */ - com.google.protobuf.TimestampOrBuilder getLastConfigAckTimeOrBuilder(); - - /** - * - * - *
-   * [Output only] The last time a cloud-to-device config version was sent to
-   * the device.
-   * 
- * - * .google.protobuf.Timestamp last_config_send_time = 18; - * - * @return Whether the lastConfigSendTime field is set. - */ - boolean hasLastConfigSendTime(); - /** - * - * - *
-   * [Output only] The last time a cloud-to-device config version was sent to
-   * the device.
-   * 
- * - * .google.protobuf.Timestamp last_config_send_time = 18; - * - * @return The lastConfigSendTime. - */ - com.google.protobuf.Timestamp getLastConfigSendTime(); - /** - * - * - *
-   * [Output only] The last time a cloud-to-device config version was sent to
-   * the device.
-   * 
- * - * .google.protobuf.Timestamp last_config_send_time = 18; - */ - com.google.protobuf.TimestampOrBuilder getLastConfigSendTimeOrBuilder(); - - /** - * - * - *
-   * If a device is blocked, connections or requests from this device will fail.
-   * Can be used to temporarily prevent the device from connecting if, for
-   * example, the sensor is generating bad data and needs maintenance.
-   * 
- * - * bool blocked = 19; - * - * @return The blocked. - */ - boolean getBlocked(); - - /** - * - * - *
-   * [Output only] The time the most recent error occurred, such as a failure to
-   * publish to Cloud Pub/Sub. This field is the timestamp of
-   * 'last_error_status'.
-   * 
- * - * .google.protobuf.Timestamp last_error_time = 10; - * - * @return Whether the lastErrorTime field is set. - */ - boolean hasLastErrorTime(); - /** - * - * - *
-   * [Output only] The time the most recent error occurred, such as a failure to
-   * publish to Cloud Pub/Sub. This field is the timestamp of
-   * 'last_error_status'.
-   * 
- * - * .google.protobuf.Timestamp last_error_time = 10; - * - * @return The lastErrorTime. - */ - com.google.protobuf.Timestamp getLastErrorTime(); - /** - * - * - *
-   * [Output only] The time the most recent error occurred, such as a failure to
-   * publish to Cloud Pub/Sub. This field is the timestamp of
-   * 'last_error_status'.
-   * 
- * - * .google.protobuf.Timestamp last_error_time = 10; - */ - com.google.protobuf.TimestampOrBuilder getLastErrorTimeOrBuilder(); - - /** - * - * - *
-   * [Output only] The error message of the most recent error, such as a failure
-   * to publish to Cloud Pub/Sub. 'last_error_time' is the timestamp of this
-   * field. If no errors have occurred, this field has an empty message
-   * and the status code 0 == OK. Otherwise, this field is expected to have a
-   * status code other than OK.
-   * 
- * - * .google.rpc.Status last_error_status = 11; - * - * @return Whether the lastErrorStatus field is set. - */ - boolean hasLastErrorStatus(); - /** - * - * - *
-   * [Output only] The error message of the most recent error, such as a failure
-   * to publish to Cloud Pub/Sub. 'last_error_time' is the timestamp of this
-   * field. If no errors have occurred, this field has an empty message
-   * and the status code 0 == OK. Otherwise, this field is expected to have a
-   * status code other than OK.
-   * 
- * - * .google.rpc.Status last_error_status = 11; - * - * @return The lastErrorStatus. - */ - com.google.rpc.Status getLastErrorStatus(); - /** - * - * - *
-   * [Output only] The error message of the most recent error, such as a failure
-   * to publish to Cloud Pub/Sub. 'last_error_time' is the timestamp of this
-   * field. If no errors have occurred, this field has an empty message
-   * and the status code 0 == OK. Otherwise, this field is expected to have a
-   * status code other than OK.
-   * 
- * - * .google.rpc.Status last_error_status = 11; - */ - com.google.rpc.StatusOrBuilder getLastErrorStatusOrBuilder(); - - /** - * - * - *
-   * The most recent device configuration, which is eventually sent from
-   * Cloud IoT Core to the device. If not present on creation, the
-   * configuration will be initialized with an empty payload and version value
-   * of `1`. To update this field after creation, use the
-   * `DeviceManager.ModifyCloudToDeviceConfig` method.
-   * 
- * - * .google.cloud.iot.v1.DeviceConfig config = 13; - * - * @return Whether the config field is set. - */ - boolean hasConfig(); - /** - * - * - *
-   * The most recent device configuration, which is eventually sent from
-   * Cloud IoT Core to the device. If not present on creation, the
-   * configuration will be initialized with an empty payload and version value
-   * of `1`. To update this field after creation, use the
-   * `DeviceManager.ModifyCloudToDeviceConfig` method.
-   * 
- * - * .google.cloud.iot.v1.DeviceConfig config = 13; - * - * @return The config. - */ - com.google.cloud.iot.v1.DeviceConfig getConfig(); - /** - * - * - *
-   * The most recent device configuration, which is eventually sent from
-   * Cloud IoT Core to the device. If not present on creation, the
-   * configuration will be initialized with an empty payload and version value
-   * of `1`. To update this field after creation, use the
-   * `DeviceManager.ModifyCloudToDeviceConfig` method.
-   * 
- * - * .google.cloud.iot.v1.DeviceConfig config = 13; - */ - com.google.cloud.iot.v1.DeviceConfigOrBuilder getConfigOrBuilder(); - - /** - * - * - *
-   * [Output only] The state most recently received from the device. If no state
-   * has been reported, this field is not present.
-   * 
- * - * .google.cloud.iot.v1.DeviceState state = 16; - * - * @return Whether the state field is set. - */ - boolean hasState(); - /** - * - * - *
-   * [Output only] The state most recently received from the device. If no state
-   * has been reported, this field is not present.
-   * 
- * - * .google.cloud.iot.v1.DeviceState state = 16; - * - * @return The state. - */ - com.google.cloud.iot.v1.DeviceState getState(); - /** - * - * - *
-   * [Output only] The state most recently received from the device. If no state
-   * has been reported, this field is not present.
-   * 
- * - * .google.cloud.iot.v1.DeviceState state = 16; - */ - com.google.cloud.iot.v1.DeviceStateOrBuilder getStateOrBuilder(); - - /** - * - * - *
-   * **Beta Feature**
-   * The logging verbosity for device activity. If unspecified,
-   * DeviceRegistry.log_level will be used.
-   * 
- * - * .google.cloud.iot.v1.LogLevel log_level = 21; - * - * @return The enum numeric value on the wire for logLevel. - */ - int getLogLevelValue(); - /** - * - * - *
-   * **Beta Feature**
-   * The logging verbosity for device activity. If unspecified,
-   * DeviceRegistry.log_level will be used.
-   * 
- * - * .google.cloud.iot.v1.LogLevel log_level = 21; - * - * @return The logLevel. - */ - com.google.cloud.iot.v1.LogLevel getLogLevel(); - - /** - * - * - *
-   * The metadata key-value pairs assigned to the device. This metadata is not
-   * interpreted or indexed by Cloud IoT Core. It can be used to add contextual
-   * information for the device.
-   * Keys must conform to the regular expression [a-zA-Z][a-zA-Z0-9-_.+~%]+ and
-   * be less than 128 bytes in length.
-   * Values are free-form strings. Each value must be less than or equal to 32
-   * KB in size.
-   * The total size of all keys and values must be less than 256 KB, and the
-   * maximum number of key-value pairs is 500.
-   * 
- * - * map<string, string> metadata = 17; - */ - int getMetadataCount(); - /** - * - * - *
-   * The metadata key-value pairs assigned to the device. This metadata is not
-   * interpreted or indexed by Cloud IoT Core. It can be used to add contextual
-   * information for the device.
-   * Keys must conform to the regular expression [a-zA-Z][a-zA-Z0-9-_.+~%]+ and
-   * be less than 128 bytes in length.
-   * Values are free-form strings. Each value must be less than or equal to 32
-   * KB in size.
-   * The total size of all keys and values must be less than 256 KB, and the
-   * maximum number of key-value pairs is 500.
-   * 
- * - * map<string, string> metadata = 17; - */ - boolean containsMetadata(java.lang.String key); - /** Use {@link #getMetadataMap()} instead. */ - @java.lang.Deprecated - java.util.Map getMetadata(); - /** - * - * - *
-   * The metadata key-value pairs assigned to the device. This metadata is not
-   * interpreted or indexed by Cloud IoT Core. It can be used to add contextual
-   * information for the device.
-   * Keys must conform to the regular expression [a-zA-Z][a-zA-Z0-9-_.+~%]+ and
-   * be less than 128 bytes in length.
-   * Values are free-form strings. Each value must be less than or equal to 32
-   * KB in size.
-   * The total size of all keys and values must be less than 256 KB, and the
-   * maximum number of key-value pairs is 500.
-   * 
- * - * map<string, string> metadata = 17; - */ - java.util.Map getMetadataMap(); - /** - * - * - *
-   * The metadata key-value pairs assigned to the device. This metadata is not
-   * interpreted or indexed by Cloud IoT Core. It can be used to add contextual
-   * information for the device.
-   * Keys must conform to the regular expression [a-zA-Z][a-zA-Z0-9-_.+~%]+ and
-   * be less than 128 bytes in length.
-   * Values are free-form strings. Each value must be less than or equal to 32
-   * KB in size.
-   * The total size of all keys and values must be less than 256 KB, and the
-   * maximum number of key-value pairs is 500.
-   * 
- * - * map<string, string> metadata = 17; - */ - - /* nullable */ - java.lang.String getMetadataOrDefault( - java.lang.String key, - /* nullable */ - java.lang.String defaultValue); - /** - * - * - *
-   * The metadata key-value pairs assigned to the device. This metadata is not
-   * interpreted or indexed by Cloud IoT Core. It can be used to add contextual
-   * information for the device.
-   * Keys must conform to the regular expression [a-zA-Z][a-zA-Z0-9-_.+~%]+ and
-   * be less than 128 bytes in length.
-   * Values are free-form strings. Each value must be less than or equal to 32
-   * KB in size.
-   * The total size of all keys and values must be less than 256 KB, and the
-   * maximum number of key-value pairs is 500.
-   * 
- * - * map<string, string> metadata = 17; - */ - java.lang.String getMetadataOrThrow(java.lang.String key); - - /** - * - * - *
-   * Gateway-related configuration and state.
-   * 
- * - * .google.cloud.iot.v1.GatewayConfig gateway_config = 24; - * - * @return Whether the gatewayConfig field is set. - */ - boolean hasGatewayConfig(); - /** - * - * - *
-   * Gateway-related configuration and state.
-   * 
- * - * .google.cloud.iot.v1.GatewayConfig gateway_config = 24; - * - * @return The gatewayConfig. - */ - com.google.cloud.iot.v1.GatewayConfig getGatewayConfig(); - /** - * - * - *
-   * Gateway-related configuration and state.
-   * 
- * - * .google.cloud.iot.v1.GatewayConfig gateway_config = 24; - */ - com.google.cloud.iot.v1.GatewayConfigOrBuilder getGatewayConfigOrBuilder(); -} diff --git a/proto-google-cloud-iot-v1/src/main/java/com/google/cloud/iot/v1/DeviceRegistry.java b/proto-google-cloud-iot-v1/src/main/java/com/google/cloud/iot/v1/DeviceRegistry.java deleted file mode 100644 index 734cab5f..00000000 --- a/proto-google-cloud-iot-v1/src/main/java/com/google/cloud/iot/v1/DeviceRegistry.java +++ /dev/null @@ -1,3240 +0,0 @@ -/* - * Copyright 2020 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. - */ -// Generated by the protocol buffer compiler. DO NOT EDIT! -// source: google/cloud/iot/v1/resources.proto - -package com.google.cloud.iot.v1; - -/** - * - * - *
- * A container for a group of devices.
- * 
- * - * Protobuf type {@code google.cloud.iot.v1.DeviceRegistry} - */ -public final class DeviceRegistry extends com.google.protobuf.GeneratedMessageV3 - implements - // @@protoc_insertion_point(message_implements:google.cloud.iot.v1.DeviceRegistry) - DeviceRegistryOrBuilder { - private static final long serialVersionUID = 0L; - // Use DeviceRegistry.newBuilder() to construct. - private DeviceRegistry(com.google.protobuf.GeneratedMessageV3.Builder builder) { - super(builder); - } - - private DeviceRegistry() { - id_ = ""; - name_ = ""; - eventNotificationConfigs_ = java.util.Collections.emptyList(); - logLevel_ = 0; - credentials_ = java.util.Collections.emptyList(); - } - - @java.lang.Override - @SuppressWarnings({"unused"}) - protected java.lang.Object newInstance(UnusedPrivateParameter unused) { - return new DeviceRegistry(); - } - - @java.lang.Override - public final com.google.protobuf.UnknownFieldSet getUnknownFields() { - return this.unknownFields; - } - - public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { - return com.google.cloud.iot.v1.ResourcesProto - .internal_static_google_cloud_iot_v1_DeviceRegistry_descriptor; - } - - @java.lang.Override - protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable - internalGetFieldAccessorTable() { - return com.google.cloud.iot.v1.ResourcesProto - .internal_static_google_cloud_iot_v1_DeviceRegistry_fieldAccessorTable - .ensureFieldAccessorsInitialized( - com.google.cloud.iot.v1.DeviceRegistry.class, - com.google.cloud.iot.v1.DeviceRegistry.Builder.class); - } - - public static final int ID_FIELD_NUMBER = 1; - private volatile java.lang.Object id_; - /** - * - * - *
-   * The identifier of this device registry. For example, `myRegistry`.
-   * 
- * - * string id = 1; - * - * @return The id. - */ - @java.lang.Override - public java.lang.String getId() { - java.lang.Object ref = id_; - if (ref instanceof java.lang.String) { - return (java.lang.String) ref; - } else { - com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; - java.lang.String s = bs.toStringUtf8(); - id_ = s; - return s; - } - } - /** - * - * - *
-   * The identifier of this device registry. For example, `myRegistry`.
-   * 
- * - * string id = 1; - * - * @return The bytes for id. - */ - @java.lang.Override - public com.google.protobuf.ByteString getIdBytes() { - java.lang.Object ref = id_; - if (ref instanceof java.lang.String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); - id_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - - public static final int NAME_FIELD_NUMBER = 2; - private volatile java.lang.Object name_; - /** - * - * - *
-   * The resource path name. For example,
-   * `projects/example-project/locations/us-central1/registries/my-registry`.
-   * 
- * - * string name = 2; - * - * @return The name. - */ - @java.lang.Override - public java.lang.String getName() { - java.lang.Object ref = name_; - if (ref instanceof java.lang.String) { - return (java.lang.String) ref; - } else { - com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; - java.lang.String s = bs.toStringUtf8(); - name_ = s; - return s; - } - } - /** - * - * - *
-   * The resource path name. For example,
-   * `projects/example-project/locations/us-central1/registries/my-registry`.
-   * 
- * - * string name = 2; - * - * @return The bytes for name. - */ - @java.lang.Override - public com.google.protobuf.ByteString getNameBytes() { - java.lang.Object ref = name_; - if (ref instanceof java.lang.String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); - name_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - - public static final int EVENT_NOTIFICATION_CONFIGS_FIELD_NUMBER = 10; - private java.util.List eventNotificationConfigs_; - /** - * - * - *
-   * The configuration for notification of telemetry events received from the
-   * device. All telemetry events that were successfully published by the
-   * device and acknowledged by Cloud IoT Core are guaranteed to be
-   * delivered to Cloud Pub/Sub. If multiple configurations match a message,
-   * only the first matching configuration is used. If you try to publish a
-   * device telemetry event using MQTT without specifying a Cloud Pub/Sub topic
-   * for the device's registry, the connection closes automatically. If you try
-   * to do so using an HTTP connection, an error is returned. Up to 10
-   * configurations may be provided.
-   * 
- * - * repeated .google.cloud.iot.v1.EventNotificationConfig event_notification_configs = 10; - * - */ - @java.lang.Override - public java.util.List - getEventNotificationConfigsList() { - return eventNotificationConfigs_; - } - /** - * - * - *
-   * The configuration for notification of telemetry events received from the
-   * device. All telemetry events that were successfully published by the
-   * device and acknowledged by Cloud IoT Core are guaranteed to be
-   * delivered to Cloud Pub/Sub. If multiple configurations match a message,
-   * only the first matching configuration is used. If you try to publish a
-   * device telemetry event using MQTT without specifying a Cloud Pub/Sub topic
-   * for the device's registry, the connection closes automatically. If you try
-   * to do so using an HTTP connection, an error is returned. Up to 10
-   * configurations may be provided.
-   * 
- * - * repeated .google.cloud.iot.v1.EventNotificationConfig event_notification_configs = 10; - * - */ - @java.lang.Override - public java.util.List - getEventNotificationConfigsOrBuilderList() { - return eventNotificationConfigs_; - } - /** - * - * - *
-   * The configuration for notification of telemetry events received from the
-   * device. All telemetry events that were successfully published by the
-   * device and acknowledged by Cloud IoT Core are guaranteed to be
-   * delivered to Cloud Pub/Sub. If multiple configurations match a message,
-   * only the first matching configuration is used. If you try to publish a
-   * device telemetry event using MQTT without specifying a Cloud Pub/Sub topic
-   * for the device's registry, the connection closes automatically. If you try
-   * to do so using an HTTP connection, an error is returned. Up to 10
-   * configurations may be provided.
-   * 
- * - * repeated .google.cloud.iot.v1.EventNotificationConfig event_notification_configs = 10; - * - */ - @java.lang.Override - public int getEventNotificationConfigsCount() { - return eventNotificationConfigs_.size(); - } - /** - * - * - *
-   * The configuration for notification of telemetry events received from the
-   * device. All telemetry events that were successfully published by the
-   * device and acknowledged by Cloud IoT Core are guaranteed to be
-   * delivered to Cloud Pub/Sub. If multiple configurations match a message,
-   * only the first matching configuration is used. If you try to publish a
-   * device telemetry event using MQTT without specifying a Cloud Pub/Sub topic
-   * for the device's registry, the connection closes automatically. If you try
-   * to do so using an HTTP connection, an error is returned. Up to 10
-   * configurations may be provided.
-   * 
- * - * repeated .google.cloud.iot.v1.EventNotificationConfig event_notification_configs = 10; - * - */ - @java.lang.Override - public com.google.cloud.iot.v1.EventNotificationConfig getEventNotificationConfigs(int index) { - return eventNotificationConfigs_.get(index); - } - /** - * - * - *
-   * The configuration for notification of telemetry events received from the
-   * device. All telemetry events that were successfully published by the
-   * device and acknowledged by Cloud IoT Core are guaranteed to be
-   * delivered to Cloud Pub/Sub. If multiple configurations match a message,
-   * only the first matching configuration is used. If you try to publish a
-   * device telemetry event using MQTT without specifying a Cloud Pub/Sub topic
-   * for the device's registry, the connection closes automatically. If you try
-   * to do so using an HTTP connection, an error is returned. Up to 10
-   * configurations may be provided.
-   * 
- * - * repeated .google.cloud.iot.v1.EventNotificationConfig event_notification_configs = 10; - * - */ - @java.lang.Override - public com.google.cloud.iot.v1.EventNotificationConfigOrBuilder - getEventNotificationConfigsOrBuilder(int index) { - return eventNotificationConfigs_.get(index); - } - - public static final int STATE_NOTIFICATION_CONFIG_FIELD_NUMBER = 7; - private com.google.cloud.iot.v1.StateNotificationConfig stateNotificationConfig_; - /** - * - * - *
-   * The configuration for notification of new states received from the device.
-   * State updates are guaranteed to be stored in the state history, but
-   * notifications to Cloud Pub/Sub are not guaranteed. For example, if
-   * permissions are misconfigured or the specified topic doesn't exist, no
-   * notification will be published but the state will still be stored in Cloud
-   * IoT Core.
-   * 
- * - * .google.cloud.iot.v1.StateNotificationConfig state_notification_config = 7; - * - * @return Whether the stateNotificationConfig field is set. - */ - @java.lang.Override - public boolean hasStateNotificationConfig() { - return stateNotificationConfig_ != null; - } - /** - * - * - *
-   * The configuration for notification of new states received from the device.
-   * State updates are guaranteed to be stored in the state history, but
-   * notifications to Cloud Pub/Sub are not guaranteed. For example, if
-   * permissions are misconfigured or the specified topic doesn't exist, no
-   * notification will be published but the state will still be stored in Cloud
-   * IoT Core.
-   * 
- * - * .google.cloud.iot.v1.StateNotificationConfig state_notification_config = 7; - * - * @return The stateNotificationConfig. - */ - @java.lang.Override - public com.google.cloud.iot.v1.StateNotificationConfig getStateNotificationConfig() { - return stateNotificationConfig_ == null - ? com.google.cloud.iot.v1.StateNotificationConfig.getDefaultInstance() - : stateNotificationConfig_; - } - /** - * - * - *
-   * The configuration for notification of new states received from the device.
-   * State updates are guaranteed to be stored in the state history, but
-   * notifications to Cloud Pub/Sub are not guaranteed. For example, if
-   * permissions are misconfigured or the specified topic doesn't exist, no
-   * notification will be published but the state will still be stored in Cloud
-   * IoT Core.
-   * 
- * - * .google.cloud.iot.v1.StateNotificationConfig state_notification_config = 7; - */ - @java.lang.Override - public com.google.cloud.iot.v1.StateNotificationConfigOrBuilder - getStateNotificationConfigOrBuilder() { - return getStateNotificationConfig(); - } - - public static final int MQTT_CONFIG_FIELD_NUMBER = 4; - private com.google.cloud.iot.v1.MqttConfig mqttConfig_; - /** - * - * - *
-   * The MQTT configuration for this device registry.
-   * 
- * - * .google.cloud.iot.v1.MqttConfig mqtt_config = 4; - * - * @return Whether the mqttConfig field is set. - */ - @java.lang.Override - public boolean hasMqttConfig() { - return mqttConfig_ != null; - } - /** - * - * - *
-   * The MQTT configuration for this device registry.
-   * 
- * - * .google.cloud.iot.v1.MqttConfig mqtt_config = 4; - * - * @return The mqttConfig. - */ - @java.lang.Override - public com.google.cloud.iot.v1.MqttConfig getMqttConfig() { - return mqttConfig_ == null - ? com.google.cloud.iot.v1.MqttConfig.getDefaultInstance() - : mqttConfig_; - } - /** - * - * - *
-   * The MQTT configuration for this device registry.
-   * 
- * - * .google.cloud.iot.v1.MqttConfig mqtt_config = 4; - */ - @java.lang.Override - public com.google.cloud.iot.v1.MqttConfigOrBuilder getMqttConfigOrBuilder() { - return getMqttConfig(); - } - - public static final int HTTP_CONFIG_FIELD_NUMBER = 9; - private com.google.cloud.iot.v1.HttpConfig httpConfig_; - /** - * - * - *
-   * The DeviceService (HTTP) configuration for this device registry.
-   * 
- * - * .google.cloud.iot.v1.HttpConfig http_config = 9; - * - * @return Whether the httpConfig field is set. - */ - @java.lang.Override - public boolean hasHttpConfig() { - return httpConfig_ != null; - } - /** - * - * - *
-   * The DeviceService (HTTP) configuration for this device registry.
-   * 
- * - * .google.cloud.iot.v1.HttpConfig http_config = 9; - * - * @return The httpConfig. - */ - @java.lang.Override - public com.google.cloud.iot.v1.HttpConfig getHttpConfig() { - return httpConfig_ == null - ? com.google.cloud.iot.v1.HttpConfig.getDefaultInstance() - : httpConfig_; - } - /** - * - * - *
-   * The DeviceService (HTTP) configuration for this device registry.
-   * 
- * - * .google.cloud.iot.v1.HttpConfig http_config = 9; - */ - @java.lang.Override - public com.google.cloud.iot.v1.HttpConfigOrBuilder getHttpConfigOrBuilder() { - return getHttpConfig(); - } - - public static final int LOG_LEVEL_FIELD_NUMBER = 11; - private int logLevel_; - /** - * - * - *
-   * **Beta Feature**
-   * The default logging verbosity for activity from devices in this registry.
-   * The verbosity level can be overridden by Device.log_level.
-   * 
- * - * .google.cloud.iot.v1.LogLevel log_level = 11; - * - * @return The enum numeric value on the wire for logLevel. - */ - @java.lang.Override - public int getLogLevelValue() { - return logLevel_; - } - /** - * - * - *
-   * **Beta Feature**
-   * The default logging verbosity for activity from devices in this registry.
-   * The verbosity level can be overridden by Device.log_level.
-   * 
- * - * .google.cloud.iot.v1.LogLevel log_level = 11; - * - * @return The logLevel. - */ - @java.lang.Override - public com.google.cloud.iot.v1.LogLevel getLogLevel() { - @SuppressWarnings("deprecation") - com.google.cloud.iot.v1.LogLevel result = com.google.cloud.iot.v1.LogLevel.valueOf(logLevel_); - return result == null ? com.google.cloud.iot.v1.LogLevel.UNRECOGNIZED : result; - } - - public static final int CREDENTIALS_FIELD_NUMBER = 8; - private java.util.List credentials_; - /** - * - * - *
-   * The credentials used to verify the device credentials. No more than 10
-   * credentials can be bound to a single registry at a time. The verification
-   * process occurs at the time of device creation or update. If this field is
-   * empty, no verification is performed. Otherwise, the credentials of a newly
-   * created device or added credentials of an updated device should be signed
-   * with one of these registry credentials.
-   * Note, however, that existing devices will never be affected by
-   * modifications to this list of credentials: after a device has been
-   * successfully created in a registry, it should be able to connect even if
-   * its registry credentials are revoked, deleted, or modified.
-   * 
- * - * repeated .google.cloud.iot.v1.RegistryCredential credentials = 8; - */ - @java.lang.Override - public java.util.List getCredentialsList() { - return credentials_; - } - /** - * - * - *
-   * The credentials used to verify the device credentials. No more than 10
-   * credentials can be bound to a single registry at a time. The verification
-   * process occurs at the time of device creation or update. If this field is
-   * empty, no verification is performed. Otherwise, the credentials of a newly
-   * created device or added credentials of an updated device should be signed
-   * with one of these registry credentials.
-   * Note, however, that existing devices will never be affected by
-   * modifications to this list of credentials: after a device has been
-   * successfully created in a registry, it should be able to connect even if
-   * its registry credentials are revoked, deleted, or modified.
-   * 
- * - * repeated .google.cloud.iot.v1.RegistryCredential credentials = 8; - */ - @java.lang.Override - public java.util.List - getCredentialsOrBuilderList() { - return credentials_; - } - /** - * - * - *
-   * The credentials used to verify the device credentials. No more than 10
-   * credentials can be bound to a single registry at a time. The verification
-   * process occurs at the time of device creation or update. If this field is
-   * empty, no verification is performed. Otherwise, the credentials of a newly
-   * created device or added credentials of an updated device should be signed
-   * with one of these registry credentials.
-   * Note, however, that existing devices will never be affected by
-   * modifications to this list of credentials: after a device has been
-   * successfully created in a registry, it should be able to connect even if
-   * its registry credentials are revoked, deleted, or modified.
-   * 
- * - * repeated .google.cloud.iot.v1.RegistryCredential credentials = 8; - */ - @java.lang.Override - public int getCredentialsCount() { - return credentials_.size(); - } - /** - * - * - *
-   * The credentials used to verify the device credentials. No more than 10
-   * credentials can be bound to a single registry at a time. The verification
-   * process occurs at the time of device creation or update. If this field is
-   * empty, no verification is performed. Otherwise, the credentials of a newly
-   * created device or added credentials of an updated device should be signed
-   * with one of these registry credentials.
-   * Note, however, that existing devices will never be affected by
-   * modifications to this list of credentials: after a device has been
-   * successfully created in a registry, it should be able to connect even if
-   * its registry credentials are revoked, deleted, or modified.
-   * 
- * - * repeated .google.cloud.iot.v1.RegistryCredential credentials = 8; - */ - @java.lang.Override - public com.google.cloud.iot.v1.RegistryCredential getCredentials(int index) { - return credentials_.get(index); - } - /** - * - * - *
-   * The credentials used to verify the device credentials. No more than 10
-   * credentials can be bound to a single registry at a time. The verification
-   * process occurs at the time of device creation or update. If this field is
-   * empty, no verification is performed. Otherwise, the credentials of a newly
-   * created device or added credentials of an updated device should be signed
-   * with one of these registry credentials.
-   * Note, however, that existing devices will never be affected by
-   * modifications to this list of credentials: after a device has been
-   * successfully created in a registry, it should be able to connect even if
-   * its registry credentials are revoked, deleted, or modified.
-   * 
- * - * repeated .google.cloud.iot.v1.RegistryCredential credentials = 8; - */ - @java.lang.Override - public com.google.cloud.iot.v1.RegistryCredentialOrBuilder getCredentialsOrBuilder(int index) { - return credentials_.get(index); - } - - private byte memoizedIsInitialized = -1; - - @java.lang.Override - public final boolean isInitialized() { - byte isInitialized = memoizedIsInitialized; - if (isInitialized == 1) return true; - if (isInitialized == 0) return false; - - memoizedIsInitialized = 1; - return true; - } - - @java.lang.Override - public void writeTo(com.google.protobuf.CodedOutputStream output) throws java.io.IOException { - if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(id_)) { - com.google.protobuf.GeneratedMessageV3.writeString(output, 1, id_); - } - if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(name_)) { - com.google.protobuf.GeneratedMessageV3.writeString(output, 2, name_); - } - if (mqttConfig_ != null) { - output.writeMessage(4, getMqttConfig()); - } - if (stateNotificationConfig_ != null) { - output.writeMessage(7, getStateNotificationConfig()); - } - for (int i = 0; i < credentials_.size(); i++) { - output.writeMessage(8, credentials_.get(i)); - } - if (httpConfig_ != null) { - output.writeMessage(9, getHttpConfig()); - } - for (int i = 0; i < eventNotificationConfigs_.size(); i++) { - output.writeMessage(10, eventNotificationConfigs_.get(i)); - } - if (logLevel_ != com.google.cloud.iot.v1.LogLevel.LOG_LEVEL_UNSPECIFIED.getNumber()) { - output.writeEnum(11, logLevel_); - } - getUnknownFields().writeTo(output); - } - - @java.lang.Override - public int getSerializedSize() { - int size = memoizedSize; - if (size != -1) return size; - - size = 0; - if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(id_)) { - size += com.google.protobuf.GeneratedMessageV3.computeStringSize(1, id_); - } - if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(name_)) { - size += com.google.protobuf.GeneratedMessageV3.computeStringSize(2, name_); - } - if (mqttConfig_ != null) { - size += com.google.protobuf.CodedOutputStream.computeMessageSize(4, getMqttConfig()); - } - if (stateNotificationConfig_ != null) { - size += - com.google.protobuf.CodedOutputStream.computeMessageSize(7, getStateNotificationConfig()); - } - for (int i = 0; i < credentials_.size(); i++) { - size += com.google.protobuf.CodedOutputStream.computeMessageSize(8, credentials_.get(i)); - } - if (httpConfig_ != null) { - size += com.google.protobuf.CodedOutputStream.computeMessageSize(9, getHttpConfig()); - } - for (int i = 0; i < eventNotificationConfigs_.size(); i++) { - size += - com.google.protobuf.CodedOutputStream.computeMessageSize( - 10, eventNotificationConfigs_.get(i)); - } - if (logLevel_ != com.google.cloud.iot.v1.LogLevel.LOG_LEVEL_UNSPECIFIED.getNumber()) { - size += com.google.protobuf.CodedOutputStream.computeEnumSize(11, logLevel_); - } - size += getUnknownFields().getSerializedSize(); - memoizedSize = size; - return size; - } - - @java.lang.Override - public boolean equals(final java.lang.Object obj) { - if (obj == this) { - return true; - } - if (!(obj instanceof com.google.cloud.iot.v1.DeviceRegistry)) { - return super.equals(obj); - } - com.google.cloud.iot.v1.DeviceRegistry other = (com.google.cloud.iot.v1.DeviceRegistry) obj; - - if (!getId().equals(other.getId())) return false; - if (!getName().equals(other.getName())) return false; - if (!getEventNotificationConfigsList().equals(other.getEventNotificationConfigsList())) - return false; - if (hasStateNotificationConfig() != other.hasStateNotificationConfig()) return false; - if (hasStateNotificationConfig()) { - if (!getStateNotificationConfig().equals(other.getStateNotificationConfig())) return false; - } - if (hasMqttConfig() != other.hasMqttConfig()) return false; - if (hasMqttConfig()) { - if (!getMqttConfig().equals(other.getMqttConfig())) return false; - } - if (hasHttpConfig() != other.hasHttpConfig()) return false; - if (hasHttpConfig()) { - if (!getHttpConfig().equals(other.getHttpConfig())) return false; - } - if (logLevel_ != other.logLevel_) return false; - if (!getCredentialsList().equals(other.getCredentialsList())) return false; - if (!getUnknownFields().equals(other.getUnknownFields())) return false; - return true; - } - - @java.lang.Override - public int hashCode() { - if (memoizedHashCode != 0) { - return memoizedHashCode; - } - int hash = 41; - hash = (19 * hash) + getDescriptor().hashCode(); - hash = (37 * hash) + ID_FIELD_NUMBER; - hash = (53 * hash) + getId().hashCode(); - hash = (37 * hash) + NAME_FIELD_NUMBER; - hash = (53 * hash) + getName().hashCode(); - if (getEventNotificationConfigsCount() > 0) { - hash = (37 * hash) + EVENT_NOTIFICATION_CONFIGS_FIELD_NUMBER; - hash = (53 * hash) + getEventNotificationConfigsList().hashCode(); - } - if (hasStateNotificationConfig()) { - hash = (37 * hash) + STATE_NOTIFICATION_CONFIG_FIELD_NUMBER; - hash = (53 * hash) + getStateNotificationConfig().hashCode(); - } - if (hasMqttConfig()) { - hash = (37 * hash) + MQTT_CONFIG_FIELD_NUMBER; - hash = (53 * hash) + getMqttConfig().hashCode(); - } - if (hasHttpConfig()) { - hash = (37 * hash) + HTTP_CONFIG_FIELD_NUMBER; - hash = (53 * hash) + getHttpConfig().hashCode(); - } - hash = (37 * hash) + LOG_LEVEL_FIELD_NUMBER; - hash = (53 * hash) + logLevel_; - if (getCredentialsCount() > 0) { - hash = (37 * hash) + CREDENTIALS_FIELD_NUMBER; - hash = (53 * hash) + getCredentialsList().hashCode(); - } - hash = (29 * hash) + getUnknownFields().hashCode(); - memoizedHashCode = hash; - return hash; - } - - public static com.google.cloud.iot.v1.DeviceRegistry parseFrom(java.nio.ByteBuffer data) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); - } - - public static com.google.cloud.iot.v1.DeviceRegistry parseFrom( - java.nio.ByteBuffer data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); - } - - public static com.google.cloud.iot.v1.DeviceRegistry parseFrom( - com.google.protobuf.ByteString data) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); - } - - public static com.google.cloud.iot.v1.DeviceRegistry parseFrom( - com.google.protobuf.ByteString data, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); - } - - public static com.google.cloud.iot.v1.DeviceRegistry parseFrom(byte[] data) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); - } - - public static com.google.cloud.iot.v1.DeviceRegistry parseFrom( - byte[] data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); - } - - public static com.google.cloud.iot.v1.DeviceRegistry parseFrom(java.io.InputStream input) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input); - } - - public static com.google.cloud.iot.v1.DeviceRegistry parseFrom( - java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3.parseWithIOException( - PARSER, input, extensionRegistry); - } - - public static com.google.cloud.iot.v1.DeviceRegistry parseDelimitedFrom(java.io.InputStream input) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3.parseDelimitedWithIOException(PARSER, input); - } - - public static com.google.cloud.iot.v1.DeviceRegistry parseDelimitedFrom( - java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3.parseDelimitedWithIOException( - PARSER, input, extensionRegistry); - } - - public static com.google.cloud.iot.v1.DeviceRegistry parseFrom( - com.google.protobuf.CodedInputStream input) throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input); - } - - public static com.google.cloud.iot.v1.DeviceRegistry parseFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3.parseWithIOException( - PARSER, input, extensionRegistry); - } - - @java.lang.Override - public Builder newBuilderForType() { - return newBuilder(); - } - - public static Builder newBuilder() { - return DEFAULT_INSTANCE.toBuilder(); - } - - public static Builder newBuilder(com.google.cloud.iot.v1.DeviceRegistry prototype) { - return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); - } - - @java.lang.Override - public Builder toBuilder() { - return this == DEFAULT_INSTANCE ? new Builder() : new Builder().mergeFrom(this); - } - - @java.lang.Override - protected Builder newBuilderForType(com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { - Builder builder = new Builder(parent); - return builder; - } - /** - * - * - *
-   * A container for a group of devices.
-   * 
- * - * Protobuf type {@code google.cloud.iot.v1.DeviceRegistry} - */ - public static final class Builder extends com.google.protobuf.GeneratedMessageV3.Builder - implements - // @@protoc_insertion_point(builder_implements:google.cloud.iot.v1.DeviceRegistry) - com.google.cloud.iot.v1.DeviceRegistryOrBuilder { - public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { - return com.google.cloud.iot.v1.ResourcesProto - .internal_static_google_cloud_iot_v1_DeviceRegistry_descriptor; - } - - @java.lang.Override - protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable - internalGetFieldAccessorTable() { - return com.google.cloud.iot.v1.ResourcesProto - .internal_static_google_cloud_iot_v1_DeviceRegistry_fieldAccessorTable - .ensureFieldAccessorsInitialized( - com.google.cloud.iot.v1.DeviceRegistry.class, - com.google.cloud.iot.v1.DeviceRegistry.Builder.class); - } - - // Construct using com.google.cloud.iot.v1.DeviceRegistry.newBuilder() - private Builder() {} - - private Builder(com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { - super(parent); - } - - @java.lang.Override - public Builder clear() { - super.clear(); - id_ = ""; - - name_ = ""; - - if (eventNotificationConfigsBuilder_ == null) { - eventNotificationConfigs_ = java.util.Collections.emptyList(); - } else { - eventNotificationConfigs_ = null; - eventNotificationConfigsBuilder_.clear(); - } - bitField0_ = (bitField0_ & ~0x00000001); - if (stateNotificationConfigBuilder_ == null) { - stateNotificationConfig_ = null; - } else { - stateNotificationConfig_ = null; - stateNotificationConfigBuilder_ = null; - } - if (mqttConfigBuilder_ == null) { - mqttConfig_ = null; - } else { - mqttConfig_ = null; - mqttConfigBuilder_ = null; - } - if (httpConfigBuilder_ == null) { - httpConfig_ = null; - } else { - httpConfig_ = null; - httpConfigBuilder_ = null; - } - logLevel_ = 0; - - if (credentialsBuilder_ == null) { - credentials_ = java.util.Collections.emptyList(); - } else { - credentials_ = null; - credentialsBuilder_.clear(); - } - bitField0_ = (bitField0_ & ~0x00000002); - return this; - } - - @java.lang.Override - public com.google.protobuf.Descriptors.Descriptor getDescriptorForType() { - return com.google.cloud.iot.v1.ResourcesProto - .internal_static_google_cloud_iot_v1_DeviceRegistry_descriptor; - } - - @java.lang.Override - public com.google.cloud.iot.v1.DeviceRegistry getDefaultInstanceForType() { - return com.google.cloud.iot.v1.DeviceRegistry.getDefaultInstance(); - } - - @java.lang.Override - public com.google.cloud.iot.v1.DeviceRegistry build() { - com.google.cloud.iot.v1.DeviceRegistry result = buildPartial(); - if (!result.isInitialized()) { - throw newUninitializedMessageException(result); - } - return result; - } - - @java.lang.Override - public com.google.cloud.iot.v1.DeviceRegistry buildPartial() { - com.google.cloud.iot.v1.DeviceRegistry result = - new com.google.cloud.iot.v1.DeviceRegistry(this); - int from_bitField0_ = bitField0_; - result.id_ = id_; - result.name_ = name_; - if (eventNotificationConfigsBuilder_ == null) { - if (((bitField0_ & 0x00000001) != 0)) { - eventNotificationConfigs_ = - java.util.Collections.unmodifiableList(eventNotificationConfigs_); - bitField0_ = (bitField0_ & ~0x00000001); - } - result.eventNotificationConfigs_ = eventNotificationConfigs_; - } else { - result.eventNotificationConfigs_ = eventNotificationConfigsBuilder_.build(); - } - if (stateNotificationConfigBuilder_ == null) { - result.stateNotificationConfig_ = stateNotificationConfig_; - } else { - result.stateNotificationConfig_ = stateNotificationConfigBuilder_.build(); - } - if (mqttConfigBuilder_ == null) { - result.mqttConfig_ = mqttConfig_; - } else { - result.mqttConfig_ = mqttConfigBuilder_.build(); - } - if (httpConfigBuilder_ == null) { - result.httpConfig_ = httpConfig_; - } else { - result.httpConfig_ = httpConfigBuilder_.build(); - } - result.logLevel_ = logLevel_; - if (credentialsBuilder_ == null) { - if (((bitField0_ & 0x00000002) != 0)) { - credentials_ = java.util.Collections.unmodifiableList(credentials_); - bitField0_ = (bitField0_ & ~0x00000002); - } - result.credentials_ = credentials_; - } else { - result.credentials_ = credentialsBuilder_.build(); - } - onBuilt(); - return result; - } - - @java.lang.Override - public Builder clone() { - return super.clone(); - } - - @java.lang.Override - public Builder setField( - com.google.protobuf.Descriptors.FieldDescriptor field, java.lang.Object value) { - return super.setField(field, value); - } - - @java.lang.Override - public Builder clearField(com.google.protobuf.Descriptors.FieldDescriptor field) { - return super.clearField(field); - } - - @java.lang.Override - public Builder clearOneof(com.google.protobuf.Descriptors.OneofDescriptor oneof) { - return super.clearOneof(oneof); - } - - @java.lang.Override - public Builder setRepeatedField( - com.google.protobuf.Descriptors.FieldDescriptor field, int index, java.lang.Object value) { - return super.setRepeatedField(field, index, value); - } - - @java.lang.Override - public Builder addRepeatedField( - com.google.protobuf.Descriptors.FieldDescriptor field, java.lang.Object value) { - return super.addRepeatedField(field, value); - } - - @java.lang.Override - public Builder mergeFrom(com.google.protobuf.Message other) { - if (other instanceof com.google.cloud.iot.v1.DeviceRegistry) { - return mergeFrom((com.google.cloud.iot.v1.DeviceRegistry) other); - } else { - super.mergeFrom(other); - return this; - } - } - - public Builder mergeFrom(com.google.cloud.iot.v1.DeviceRegistry other) { - if (other == com.google.cloud.iot.v1.DeviceRegistry.getDefaultInstance()) return this; - if (!other.getId().isEmpty()) { - id_ = other.id_; - onChanged(); - } - if (!other.getName().isEmpty()) { - name_ = other.name_; - onChanged(); - } - if (eventNotificationConfigsBuilder_ == null) { - if (!other.eventNotificationConfigs_.isEmpty()) { - if (eventNotificationConfigs_.isEmpty()) { - eventNotificationConfigs_ = other.eventNotificationConfigs_; - bitField0_ = (bitField0_ & ~0x00000001); - } else { - ensureEventNotificationConfigsIsMutable(); - eventNotificationConfigs_.addAll(other.eventNotificationConfigs_); - } - onChanged(); - } - } else { - if (!other.eventNotificationConfigs_.isEmpty()) { - if (eventNotificationConfigsBuilder_.isEmpty()) { - eventNotificationConfigsBuilder_.dispose(); - eventNotificationConfigsBuilder_ = null; - eventNotificationConfigs_ = other.eventNotificationConfigs_; - bitField0_ = (bitField0_ & ~0x00000001); - eventNotificationConfigsBuilder_ = - com.google.protobuf.GeneratedMessageV3.alwaysUseFieldBuilders - ? getEventNotificationConfigsFieldBuilder() - : null; - } else { - eventNotificationConfigsBuilder_.addAllMessages(other.eventNotificationConfigs_); - } - } - } - if (other.hasStateNotificationConfig()) { - mergeStateNotificationConfig(other.getStateNotificationConfig()); - } - if (other.hasMqttConfig()) { - mergeMqttConfig(other.getMqttConfig()); - } - if (other.hasHttpConfig()) { - mergeHttpConfig(other.getHttpConfig()); - } - if (other.logLevel_ != 0) { - setLogLevelValue(other.getLogLevelValue()); - } - if (credentialsBuilder_ == null) { - if (!other.credentials_.isEmpty()) { - if (credentials_.isEmpty()) { - credentials_ = other.credentials_; - bitField0_ = (bitField0_ & ~0x00000002); - } else { - ensureCredentialsIsMutable(); - credentials_.addAll(other.credentials_); - } - onChanged(); - } - } else { - if (!other.credentials_.isEmpty()) { - if (credentialsBuilder_.isEmpty()) { - credentialsBuilder_.dispose(); - credentialsBuilder_ = null; - credentials_ = other.credentials_; - bitField0_ = (bitField0_ & ~0x00000002); - credentialsBuilder_ = - com.google.protobuf.GeneratedMessageV3.alwaysUseFieldBuilders - ? getCredentialsFieldBuilder() - : null; - } else { - credentialsBuilder_.addAllMessages(other.credentials_); - } - } - } - this.mergeUnknownFields(other.getUnknownFields()); - onChanged(); - return this; - } - - @java.lang.Override - public final boolean isInitialized() { - return true; - } - - @java.lang.Override - public Builder mergeFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - if (extensionRegistry == null) { - throw new java.lang.NullPointerException(); - } - try { - boolean done = false; - while (!done) { - int tag = input.readTag(); - switch (tag) { - case 0: - done = true; - break; - case 10: - { - id_ = input.readStringRequireUtf8(); - - break; - } // case 10 - case 18: - { - name_ = input.readStringRequireUtf8(); - - break; - } // case 18 - case 34: - { - input.readMessage(getMqttConfigFieldBuilder().getBuilder(), extensionRegistry); - - break; - } // case 34 - case 58: - { - input.readMessage( - getStateNotificationConfigFieldBuilder().getBuilder(), extensionRegistry); - - break; - } // case 58 - case 66: - { - com.google.cloud.iot.v1.RegistryCredential m = - input.readMessage( - com.google.cloud.iot.v1.RegistryCredential.parser(), extensionRegistry); - if (credentialsBuilder_ == null) { - ensureCredentialsIsMutable(); - credentials_.add(m); - } else { - credentialsBuilder_.addMessage(m); - } - break; - } // case 66 - case 74: - { - input.readMessage(getHttpConfigFieldBuilder().getBuilder(), extensionRegistry); - - break; - } // case 74 - case 82: - { - com.google.cloud.iot.v1.EventNotificationConfig m = - input.readMessage( - com.google.cloud.iot.v1.EventNotificationConfig.parser(), - extensionRegistry); - if (eventNotificationConfigsBuilder_ == null) { - ensureEventNotificationConfigsIsMutable(); - eventNotificationConfigs_.add(m); - } else { - eventNotificationConfigsBuilder_.addMessage(m); - } - break; - } // case 82 - case 88: - { - logLevel_ = input.readEnum(); - - break; - } // case 88 - default: - { - if (!super.parseUnknownField(input, extensionRegistry, tag)) { - done = true; // was an endgroup tag - } - break; - } // default: - } // switch (tag) - } // while (!done) - } catch (com.google.protobuf.InvalidProtocolBufferException e) { - throw e.unwrapIOException(); - } finally { - onChanged(); - } // finally - return this; - } - - private int bitField0_; - - private java.lang.Object id_ = ""; - /** - * - * - *
-     * The identifier of this device registry. For example, `myRegistry`.
-     * 
- * - * string id = 1; - * - * @return The id. - */ - public java.lang.String getId() { - java.lang.Object ref = id_; - if (!(ref instanceof java.lang.String)) { - com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; - java.lang.String s = bs.toStringUtf8(); - id_ = s; - return s; - } else { - return (java.lang.String) ref; - } - } - /** - * - * - *
-     * The identifier of this device registry. For example, `myRegistry`.
-     * 
- * - * string id = 1; - * - * @return The bytes for id. - */ - public com.google.protobuf.ByteString getIdBytes() { - java.lang.Object ref = id_; - if (ref instanceof String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); - id_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - /** - * - * - *
-     * The identifier of this device registry. For example, `myRegistry`.
-     * 
- * - * string id = 1; - * - * @param value The id to set. - * @return This builder for chaining. - */ - public Builder setId(java.lang.String value) { - if (value == null) { - throw new NullPointerException(); - } - - id_ = value; - onChanged(); - return this; - } - /** - * - * - *
-     * The identifier of this device registry. For example, `myRegistry`.
-     * 
- * - * string id = 1; - * - * @return This builder for chaining. - */ - public Builder clearId() { - - id_ = getDefaultInstance().getId(); - onChanged(); - return this; - } - /** - * - * - *
-     * The identifier of this device registry. For example, `myRegistry`.
-     * 
- * - * string id = 1; - * - * @param value The bytes for id to set. - * @return This builder for chaining. - */ - public Builder setIdBytes(com.google.protobuf.ByteString value) { - if (value == null) { - throw new NullPointerException(); - } - checkByteStringIsUtf8(value); - - id_ = value; - onChanged(); - return this; - } - - private java.lang.Object name_ = ""; - /** - * - * - *
-     * The resource path name. For example,
-     * `projects/example-project/locations/us-central1/registries/my-registry`.
-     * 
- * - * string name = 2; - * - * @return The name. - */ - public java.lang.String getName() { - java.lang.Object ref = name_; - if (!(ref instanceof java.lang.String)) { - com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; - java.lang.String s = bs.toStringUtf8(); - name_ = s; - return s; - } else { - return (java.lang.String) ref; - } - } - /** - * - * - *
-     * The resource path name. For example,
-     * `projects/example-project/locations/us-central1/registries/my-registry`.
-     * 
- * - * string name = 2; - * - * @return The bytes for name. - */ - public com.google.protobuf.ByteString getNameBytes() { - java.lang.Object ref = name_; - if (ref instanceof String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); - name_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - /** - * - * - *
-     * The resource path name. For example,
-     * `projects/example-project/locations/us-central1/registries/my-registry`.
-     * 
- * - * string name = 2; - * - * @param value The name to set. - * @return This builder for chaining. - */ - public Builder setName(java.lang.String value) { - if (value == null) { - throw new NullPointerException(); - } - - name_ = value; - onChanged(); - return this; - } - /** - * - * - *
-     * The resource path name. For example,
-     * `projects/example-project/locations/us-central1/registries/my-registry`.
-     * 
- * - * string name = 2; - * - * @return This builder for chaining. - */ - public Builder clearName() { - - name_ = getDefaultInstance().getName(); - onChanged(); - return this; - } - /** - * - * - *
-     * The resource path name. For example,
-     * `projects/example-project/locations/us-central1/registries/my-registry`.
-     * 
- * - * string name = 2; - * - * @param value The bytes for name to set. - * @return This builder for chaining. - */ - public Builder setNameBytes(com.google.protobuf.ByteString value) { - if (value == null) { - throw new NullPointerException(); - } - checkByteStringIsUtf8(value); - - name_ = value; - onChanged(); - return this; - } - - private java.util.List - eventNotificationConfigs_ = java.util.Collections.emptyList(); - - private void ensureEventNotificationConfigsIsMutable() { - if (!((bitField0_ & 0x00000001) != 0)) { - eventNotificationConfigs_ = - new java.util.ArrayList( - eventNotificationConfigs_); - bitField0_ |= 0x00000001; - } - } - - private com.google.protobuf.RepeatedFieldBuilderV3< - com.google.cloud.iot.v1.EventNotificationConfig, - com.google.cloud.iot.v1.EventNotificationConfig.Builder, - com.google.cloud.iot.v1.EventNotificationConfigOrBuilder> - eventNotificationConfigsBuilder_; - - /** - * - * - *
-     * The configuration for notification of telemetry events received from the
-     * device. All telemetry events that were successfully published by the
-     * device and acknowledged by Cloud IoT Core are guaranteed to be
-     * delivered to Cloud Pub/Sub. If multiple configurations match a message,
-     * only the first matching configuration is used. If you try to publish a
-     * device telemetry event using MQTT without specifying a Cloud Pub/Sub topic
-     * for the device's registry, the connection closes automatically. If you try
-     * to do so using an HTTP connection, an error is returned. Up to 10
-     * configurations may be provided.
-     * 
- * - * repeated .google.cloud.iot.v1.EventNotificationConfig event_notification_configs = 10; - * - */ - public java.util.List - getEventNotificationConfigsList() { - if (eventNotificationConfigsBuilder_ == null) { - return java.util.Collections.unmodifiableList(eventNotificationConfigs_); - } else { - return eventNotificationConfigsBuilder_.getMessageList(); - } - } - /** - * - * - *
-     * The configuration for notification of telemetry events received from the
-     * device. All telemetry events that were successfully published by the
-     * device and acknowledged by Cloud IoT Core are guaranteed to be
-     * delivered to Cloud Pub/Sub. If multiple configurations match a message,
-     * only the first matching configuration is used. If you try to publish a
-     * device telemetry event using MQTT without specifying a Cloud Pub/Sub topic
-     * for the device's registry, the connection closes automatically. If you try
-     * to do so using an HTTP connection, an error is returned. Up to 10
-     * configurations may be provided.
-     * 
- * - * repeated .google.cloud.iot.v1.EventNotificationConfig event_notification_configs = 10; - * - */ - public int getEventNotificationConfigsCount() { - if (eventNotificationConfigsBuilder_ == null) { - return eventNotificationConfigs_.size(); - } else { - return eventNotificationConfigsBuilder_.getCount(); - } - } - /** - * - * - *
-     * The configuration for notification of telemetry events received from the
-     * device. All telemetry events that were successfully published by the
-     * device and acknowledged by Cloud IoT Core are guaranteed to be
-     * delivered to Cloud Pub/Sub. If multiple configurations match a message,
-     * only the first matching configuration is used. If you try to publish a
-     * device telemetry event using MQTT without specifying a Cloud Pub/Sub topic
-     * for the device's registry, the connection closes automatically. If you try
-     * to do so using an HTTP connection, an error is returned. Up to 10
-     * configurations may be provided.
-     * 
- * - * repeated .google.cloud.iot.v1.EventNotificationConfig event_notification_configs = 10; - * - */ - public com.google.cloud.iot.v1.EventNotificationConfig getEventNotificationConfigs(int index) { - if (eventNotificationConfigsBuilder_ == null) { - return eventNotificationConfigs_.get(index); - } else { - return eventNotificationConfigsBuilder_.getMessage(index); - } - } - /** - * - * - *
-     * The configuration for notification of telemetry events received from the
-     * device. All telemetry events that were successfully published by the
-     * device and acknowledged by Cloud IoT Core are guaranteed to be
-     * delivered to Cloud Pub/Sub. If multiple configurations match a message,
-     * only the first matching configuration is used. If you try to publish a
-     * device telemetry event using MQTT without specifying a Cloud Pub/Sub topic
-     * for the device's registry, the connection closes automatically. If you try
-     * to do so using an HTTP connection, an error is returned. Up to 10
-     * configurations may be provided.
-     * 
- * - * repeated .google.cloud.iot.v1.EventNotificationConfig event_notification_configs = 10; - * - */ - public Builder setEventNotificationConfigs( - int index, com.google.cloud.iot.v1.EventNotificationConfig value) { - if (eventNotificationConfigsBuilder_ == null) { - if (value == null) { - throw new NullPointerException(); - } - ensureEventNotificationConfigsIsMutable(); - eventNotificationConfigs_.set(index, value); - onChanged(); - } else { - eventNotificationConfigsBuilder_.setMessage(index, value); - } - return this; - } - /** - * - * - *
-     * The configuration for notification of telemetry events received from the
-     * device. All telemetry events that were successfully published by the
-     * device and acknowledged by Cloud IoT Core are guaranteed to be
-     * delivered to Cloud Pub/Sub. If multiple configurations match a message,
-     * only the first matching configuration is used. If you try to publish a
-     * device telemetry event using MQTT without specifying a Cloud Pub/Sub topic
-     * for the device's registry, the connection closes automatically. If you try
-     * to do so using an HTTP connection, an error is returned. Up to 10
-     * configurations may be provided.
-     * 
- * - * repeated .google.cloud.iot.v1.EventNotificationConfig event_notification_configs = 10; - * - */ - public Builder setEventNotificationConfigs( - int index, com.google.cloud.iot.v1.EventNotificationConfig.Builder builderForValue) { - if (eventNotificationConfigsBuilder_ == null) { - ensureEventNotificationConfigsIsMutable(); - eventNotificationConfigs_.set(index, builderForValue.build()); - onChanged(); - } else { - eventNotificationConfigsBuilder_.setMessage(index, builderForValue.build()); - } - return this; - } - /** - * - * - *
-     * The configuration for notification of telemetry events received from the
-     * device. All telemetry events that were successfully published by the
-     * device and acknowledged by Cloud IoT Core are guaranteed to be
-     * delivered to Cloud Pub/Sub. If multiple configurations match a message,
-     * only the first matching configuration is used. If you try to publish a
-     * device telemetry event using MQTT without specifying a Cloud Pub/Sub topic
-     * for the device's registry, the connection closes automatically. If you try
-     * to do so using an HTTP connection, an error is returned. Up to 10
-     * configurations may be provided.
-     * 
- * - * repeated .google.cloud.iot.v1.EventNotificationConfig event_notification_configs = 10; - * - */ - public Builder addEventNotificationConfigs( - com.google.cloud.iot.v1.EventNotificationConfig value) { - if (eventNotificationConfigsBuilder_ == null) { - if (value == null) { - throw new NullPointerException(); - } - ensureEventNotificationConfigsIsMutable(); - eventNotificationConfigs_.add(value); - onChanged(); - } else { - eventNotificationConfigsBuilder_.addMessage(value); - } - return this; - } - /** - * - * - *
-     * The configuration for notification of telemetry events received from the
-     * device. All telemetry events that were successfully published by the
-     * device and acknowledged by Cloud IoT Core are guaranteed to be
-     * delivered to Cloud Pub/Sub. If multiple configurations match a message,
-     * only the first matching configuration is used. If you try to publish a
-     * device telemetry event using MQTT without specifying a Cloud Pub/Sub topic
-     * for the device's registry, the connection closes automatically. If you try
-     * to do so using an HTTP connection, an error is returned. Up to 10
-     * configurations may be provided.
-     * 
- * - * repeated .google.cloud.iot.v1.EventNotificationConfig event_notification_configs = 10; - * - */ - public Builder addEventNotificationConfigs( - int index, com.google.cloud.iot.v1.EventNotificationConfig value) { - if (eventNotificationConfigsBuilder_ == null) { - if (value == null) { - throw new NullPointerException(); - } - ensureEventNotificationConfigsIsMutable(); - eventNotificationConfigs_.add(index, value); - onChanged(); - } else { - eventNotificationConfigsBuilder_.addMessage(index, value); - } - return this; - } - /** - * - * - *
-     * The configuration for notification of telemetry events received from the
-     * device. All telemetry events that were successfully published by the
-     * device and acknowledged by Cloud IoT Core are guaranteed to be
-     * delivered to Cloud Pub/Sub. If multiple configurations match a message,
-     * only the first matching configuration is used. If you try to publish a
-     * device telemetry event using MQTT without specifying a Cloud Pub/Sub topic
-     * for the device's registry, the connection closes automatically. If you try
-     * to do so using an HTTP connection, an error is returned. Up to 10
-     * configurations may be provided.
-     * 
- * - * repeated .google.cloud.iot.v1.EventNotificationConfig event_notification_configs = 10; - * - */ - public Builder addEventNotificationConfigs( - com.google.cloud.iot.v1.EventNotificationConfig.Builder builderForValue) { - if (eventNotificationConfigsBuilder_ == null) { - ensureEventNotificationConfigsIsMutable(); - eventNotificationConfigs_.add(builderForValue.build()); - onChanged(); - } else { - eventNotificationConfigsBuilder_.addMessage(builderForValue.build()); - } - return this; - } - /** - * - * - *
-     * The configuration for notification of telemetry events received from the
-     * device. All telemetry events that were successfully published by the
-     * device and acknowledged by Cloud IoT Core are guaranteed to be
-     * delivered to Cloud Pub/Sub. If multiple configurations match a message,
-     * only the first matching configuration is used. If you try to publish a
-     * device telemetry event using MQTT without specifying a Cloud Pub/Sub topic
-     * for the device's registry, the connection closes automatically. If you try
-     * to do so using an HTTP connection, an error is returned. Up to 10
-     * configurations may be provided.
-     * 
- * - * repeated .google.cloud.iot.v1.EventNotificationConfig event_notification_configs = 10; - * - */ - public Builder addEventNotificationConfigs( - int index, com.google.cloud.iot.v1.EventNotificationConfig.Builder builderForValue) { - if (eventNotificationConfigsBuilder_ == null) { - ensureEventNotificationConfigsIsMutable(); - eventNotificationConfigs_.add(index, builderForValue.build()); - onChanged(); - } else { - eventNotificationConfigsBuilder_.addMessage(index, builderForValue.build()); - } - return this; - } - /** - * - * - *
-     * The configuration for notification of telemetry events received from the
-     * device. All telemetry events that were successfully published by the
-     * device and acknowledged by Cloud IoT Core are guaranteed to be
-     * delivered to Cloud Pub/Sub. If multiple configurations match a message,
-     * only the first matching configuration is used. If you try to publish a
-     * device telemetry event using MQTT without specifying a Cloud Pub/Sub topic
-     * for the device's registry, the connection closes automatically. If you try
-     * to do so using an HTTP connection, an error is returned. Up to 10
-     * configurations may be provided.
-     * 
- * - * repeated .google.cloud.iot.v1.EventNotificationConfig event_notification_configs = 10; - * - */ - public Builder addAllEventNotificationConfigs( - java.lang.Iterable values) { - if (eventNotificationConfigsBuilder_ == null) { - ensureEventNotificationConfigsIsMutable(); - com.google.protobuf.AbstractMessageLite.Builder.addAll(values, eventNotificationConfigs_); - onChanged(); - } else { - eventNotificationConfigsBuilder_.addAllMessages(values); - } - return this; - } - /** - * - * - *
-     * The configuration for notification of telemetry events received from the
-     * device. All telemetry events that were successfully published by the
-     * device and acknowledged by Cloud IoT Core are guaranteed to be
-     * delivered to Cloud Pub/Sub. If multiple configurations match a message,
-     * only the first matching configuration is used. If you try to publish a
-     * device telemetry event using MQTT without specifying a Cloud Pub/Sub topic
-     * for the device's registry, the connection closes automatically. If you try
-     * to do so using an HTTP connection, an error is returned. Up to 10
-     * configurations may be provided.
-     * 
- * - * repeated .google.cloud.iot.v1.EventNotificationConfig event_notification_configs = 10; - * - */ - public Builder clearEventNotificationConfigs() { - if (eventNotificationConfigsBuilder_ == null) { - eventNotificationConfigs_ = java.util.Collections.emptyList(); - bitField0_ = (bitField0_ & ~0x00000001); - onChanged(); - } else { - eventNotificationConfigsBuilder_.clear(); - } - return this; - } - /** - * - * - *
-     * The configuration for notification of telemetry events received from the
-     * device. All telemetry events that were successfully published by the
-     * device and acknowledged by Cloud IoT Core are guaranteed to be
-     * delivered to Cloud Pub/Sub. If multiple configurations match a message,
-     * only the first matching configuration is used. If you try to publish a
-     * device telemetry event using MQTT without specifying a Cloud Pub/Sub topic
-     * for the device's registry, the connection closes automatically. If you try
-     * to do so using an HTTP connection, an error is returned. Up to 10
-     * configurations may be provided.
-     * 
- * - * repeated .google.cloud.iot.v1.EventNotificationConfig event_notification_configs = 10; - * - */ - public Builder removeEventNotificationConfigs(int index) { - if (eventNotificationConfigsBuilder_ == null) { - ensureEventNotificationConfigsIsMutable(); - eventNotificationConfigs_.remove(index); - onChanged(); - } else { - eventNotificationConfigsBuilder_.remove(index); - } - return this; - } - /** - * - * - *
-     * The configuration for notification of telemetry events received from the
-     * device. All telemetry events that were successfully published by the
-     * device and acknowledged by Cloud IoT Core are guaranteed to be
-     * delivered to Cloud Pub/Sub. If multiple configurations match a message,
-     * only the first matching configuration is used. If you try to publish a
-     * device telemetry event using MQTT without specifying a Cloud Pub/Sub topic
-     * for the device's registry, the connection closes automatically. If you try
-     * to do so using an HTTP connection, an error is returned. Up to 10
-     * configurations may be provided.
-     * 
- * - * repeated .google.cloud.iot.v1.EventNotificationConfig event_notification_configs = 10; - * - */ - public com.google.cloud.iot.v1.EventNotificationConfig.Builder - getEventNotificationConfigsBuilder(int index) { - return getEventNotificationConfigsFieldBuilder().getBuilder(index); - } - /** - * - * - *
-     * The configuration for notification of telemetry events received from the
-     * device. All telemetry events that were successfully published by the
-     * device and acknowledged by Cloud IoT Core are guaranteed to be
-     * delivered to Cloud Pub/Sub. If multiple configurations match a message,
-     * only the first matching configuration is used. If you try to publish a
-     * device telemetry event using MQTT without specifying a Cloud Pub/Sub topic
-     * for the device's registry, the connection closes automatically. If you try
-     * to do so using an HTTP connection, an error is returned. Up to 10
-     * configurations may be provided.
-     * 
- * - * repeated .google.cloud.iot.v1.EventNotificationConfig event_notification_configs = 10; - * - */ - public com.google.cloud.iot.v1.EventNotificationConfigOrBuilder - getEventNotificationConfigsOrBuilder(int index) { - if (eventNotificationConfigsBuilder_ == null) { - return eventNotificationConfigs_.get(index); - } else { - return eventNotificationConfigsBuilder_.getMessageOrBuilder(index); - } - } - /** - * - * - *
-     * The configuration for notification of telemetry events received from the
-     * device. All telemetry events that were successfully published by the
-     * device and acknowledged by Cloud IoT Core are guaranteed to be
-     * delivered to Cloud Pub/Sub. If multiple configurations match a message,
-     * only the first matching configuration is used. If you try to publish a
-     * device telemetry event using MQTT without specifying a Cloud Pub/Sub topic
-     * for the device's registry, the connection closes automatically. If you try
-     * to do so using an HTTP connection, an error is returned. Up to 10
-     * configurations may be provided.
-     * 
- * - * repeated .google.cloud.iot.v1.EventNotificationConfig event_notification_configs = 10; - * - */ - public java.util.List - getEventNotificationConfigsOrBuilderList() { - if (eventNotificationConfigsBuilder_ != null) { - return eventNotificationConfigsBuilder_.getMessageOrBuilderList(); - } else { - return java.util.Collections.unmodifiableList(eventNotificationConfigs_); - } - } - /** - * - * - *
-     * The configuration for notification of telemetry events received from the
-     * device. All telemetry events that were successfully published by the
-     * device and acknowledged by Cloud IoT Core are guaranteed to be
-     * delivered to Cloud Pub/Sub. If multiple configurations match a message,
-     * only the first matching configuration is used. If you try to publish a
-     * device telemetry event using MQTT without specifying a Cloud Pub/Sub topic
-     * for the device's registry, the connection closes automatically. If you try
-     * to do so using an HTTP connection, an error is returned. Up to 10
-     * configurations may be provided.
-     * 
- * - * repeated .google.cloud.iot.v1.EventNotificationConfig event_notification_configs = 10; - * - */ - public com.google.cloud.iot.v1.EventNotificationConfig.Builder - addEventNotificationConfigsBuilder() { - return getEventNotificationConfigsFieldBuilder() - .addBuilder(com.google.cloud.iot.v1.EventNotificationConfig.getDefaultInstance()); - } - /** - * - * - *
-     * The configuration for notification of telemetry events received from the
-     * device. All telemetry events that were successfully published by the
-     * device and acknowledged by Cloud IoT Core are guaranteed to be
-     * delivered to Cloud Pub/Sub. If multiple configurations match a message,
-     * only the first matching configuration is used. If you try to publish a
-     * device telemetry event using MQTT without specifying a Cloud Pub/Sub topic
-     * for the device's registry, the connection closes automatically. If you try
-     * to do so using an HTTP connection, an error is returned. Up to 10
-     * configurations may be provided.
-     * 
- * - * repeated .google.cloud.iot.v1.EventNotificationConfig event_notification_configs = 10; - * - */ - public com.google.cloud.iot.v1.EventNotificationConfig.Builder - addEventNotificationConfigsBuilder(int index) { - return getEventNotificationConfigsFieldBuilder() - .addBuilder(index, com.google.cloud.iot.v1.EventNotificationConfig.getDefaultInstance()); - } - /** - * - * - *
-     * The configuration for notification of telemetry events received from the
-     * device. All telemetry events that were successfully published by the
-     * device and acknowledged by Cloud IoT Core are guaranteed to be
-     * delivered to Cloud Pub/Sub. If multiple configurations match a message,
-     * only the first matching configuration is used. If you try to publish a
-     * device telemetry event using MQTT without specifying a Cloud Pub/Sub topic
-     * for the device's registry, the connection closes automatically. If you try
-     * to do so using an HTTP connection, an error is returned. Up to 10
-     * configurations may be provided.
-     * 
- * - * repeated .google.cloud.iot.v1.EventNotificationConfig event_notification_configs = 10; - * - */ - public java.util.List - getEventNotificationConfigsBuilderList() { - return getEventNotificationConfigsFieldBuilder().getBuilderList(); - } - - private com.google.protobuf.RepeatedFieldBuilderV3< - com.google.cloud.iot.v1.EventNotificationConfig, - com.google.cloud.iot.v1.EventNotificationConfig.Builder, - com.google.cloud.iot.v1.EventNotificationConfigOrBuilder> - getEventNotificationConfigsFieldBuilder() { - if (eventNotificationConfigsBuilder_ == null) { - eventNotificationConfigsBuilder_ = - new com.google.protobuf.RepeatedFieldBuilderV3< - com.google.cloud.iot.v1.EventNotificationConfig, - com.google.cloud.iot.v1.EventNotificationConfig.Builder, - com.google.cloud.iot.v1.EventNotificationConfigOrBuilder>( - eventNotificationConfigs_, - ((bitField0_ & 0x00000001) != 0), - getParentForChildren(), - isClean()); - eventNotificationConfigs_ = null; - } - return eventNotificationConfigsBuilder_; - } - - private com.google.cloud.iot.v1.StateNotificationConfig stateNotificationConfig_; - private com.google.protobuf.SingleFieldBuilderV3< - com.google.cloud.iot.v1.StateNotificationConfig, - com.google.cloud.iot.v1.StateNotificationConfig.Builder, - com.google.cloud.iot.v1.StateNotificationConfigOrBuilder> - stateNotificationConfigBuilder_; - /** - * - * - *
-     * The configuration for notification of new states received from the device.
-     * State updates are guaranteed to be stored in the state history, but
-     * notifications to Cloud Pub/Sub are not guaranteed. For example, if
-     * permissions are misconfigured or the specified topic doesn't exist, no
-     * notification will be published but the state will still be stored in Cloud
-     * IoT Core.
-     * 
- * - * .google.cloud.iot.v1.StateNotificationConfig state_notification_config = 7; - * - * @return Whether the stateNotificationConfig field is set. - */ - public boolean hasStateNotificationConfig() { - return stateNotificationConfigBuilder_ != null || stateNotificationConfig_ != null; - } - /** - * - * - *
-     * The configuration for notification of new states received from the device.
-     * State updates are guaranteed to be stored in the state history, but
-     * notifications to Cloud Pub/Sub are not guaranteed. For example, if
-     * permissions are misconfigured or the specified topic doesn't exist, no
-     * notification will be published but the state will still be stored in Cloud
-     * IoT Core.
-     * 
- * - * .google.cloud.iot.v1.StateNotificationConfig state_notification_config = 7; - * - * @return The stateNotificationConfig. - */ - public com.google.cloud.iot.v1.StateNotificationConfig getStateNotificationConfig() { - if (stateNotificationConfigBuilder_ == null) { - return stateNotificationConfig_ == null - ? com.google.cloud.iot.v1.StateNotificationConfig.getDefaultInstance() - : stateNotificationConfig_; - } else { - return stateNotificationConfigBuilder_.getMessage(); - } - } - /** - * - * - *
-     * The configuration for notification of new states received from the device.
-     * State updates are guaranteed to be stored in the state history, but
-     * notifications to Cloud Pub/Sub are not guaranteed. For example, if
-     * permissions are misconfigured or the specified topic doesn't exist, no
-     * notification will be published but the state will still be stored in Cloud
-     * IoT Core.
-     * 
- * - * .google.cloud.iot.v1.StateNotificationConfig state_notification_config = 7; - */ - public Builder setStateNotificationConfig( - com.google.cloud.iot.v1.StateNotificationConfig value) { - if (stateNotificationConfigBuilder_ == null) { - if (value == null) { - throw new NullPointerException(); - } - stateNotificationConfig_ = value; - onChanged(); - } else { - stateNotificationConfigBuilder_.setMessage(value); - } - - return this; - } - /** - * - * - *
-     * The configuration for notification of new states received from the device.
-     * State updates are guaranteed to be stored in the state history, but
-     * notifications to Cloud Pub/Sub are not guaranteed. For example, if
-     * permissions are misconfigured or the specified topic doesn't exist, no
-     * notification will be published but the state will still be stored in Cloud
-     * IoT Core.
-     * 
- * - * .google.cloud.iot.v1.StateNotificationConfig state_notification_config = 7; - */ - public Builder setStateNotificationConfig( - com.google.cloud.iot.v1.StateNotificationConfig.Builder builderForValue) { - if (stateNotificationConfigBuilder_ == null) { - stateNotificationConfig_ = builderForValue.build(); - onChanged(); - } else { - stateNotificationConfigBuilder_.setMessage(builderForValue.build()); - } - - return this; - } - /** - * - * - *
-     * The configuration for notification of new states received from the device.
-     * State updates are guaranteed to be stored in the state history, but
-     * notifications to Cloud Pub/Sub are not guaranteed. For example, if
-     * permissions are misconfigured or the specified topic doesn't exist, no
-     * notification will be published but the state will still be stored in Cloud
-     * IoT Core.
-     * 
- * - * .google.cloud.iot.v1.StateNotificationConfig state_notification_config = 7; - */ - public Builder mergeStateNotificationConfig( - com.google.cloud.iot.v1.StateNotificationConfig value) { - if (stateNotificationConfigBuilder_ == null) { - if (stateNotificationConfig_ != null) { - stateNotificationConfig_ = - com.google.cloud.iot.v1.StateNotificationConfig.newBuilder(stateNotificationConfig_) - .mergeFrom(value) - .buildPartial(); - } else { - stateNotificationConfig_ = value; - } - onChanged(); - } else { - stateNotificationConfigBuilder_.mergeFrom(value); - } - - return this; - } - /** - * - * - *
-     * The configuration for notification of new states received from the device.
-     * State updates are guaranteed to be stored in the state history, but
-     * notifications to Cloud Pub/Sub are not guaranteed. For example, if
-     * permissions are misconfigured or the specified topic doesn't exist, no
-     * notification will be published but the state will still be stored in Cloud
-     * IoT Core.
-     * 
- * - * .google.cloud.iot.v1.StateNotificationConfig state_notification_config = 7; - */ - public Builder clearStateNotificationConfig() { - if (stateNotificationConfigBuilder_ == null) { - stateNotificationConfig_ = null; - onChanged(); - } else { - stateNotificationConfig_ = null; - stateNotificationConfigBuilder_ = null; - } - - return this; - } - /** - * - * - *
-     * The configuration for notification of new states received from the device.
-     * State updates are guaranteed to be stored in the state history, but
-     * notifications to Cloud Pub/Sub are not guaranteed. For example, if
-     * permissions are misconfigured or the specified topic doesn't exist, no
-     * notification will be published but the state will still be stored in Cloud
-     * IoT Core.
-     * 
- * - * .google.cloud.iot.v1.StateNotificationConfig state_notification_config = 7; - */ - public com.google.cloud.iot.v1.StateNotificationConfig.Builder - getStateNotificationConfigBuilder() { - - onChanged(); - return getStateNotificationConfigFieldBuilder().getBuilder(); - } - /** - * - * - *
-     * The configuration for notification of new states received from the device.
-     * State updates are guaranteed to be stored in the state history, but
-     * notifications to Cloud Pub/Sub are not guaranteed. For example, if
-     * permissions are misconfigured or the specified topic doesn't exist, no
-     * notification will be published but the state will still be stored in Cloud
-     * IoT Core.
-     * 
- * - * .google.cloud.iot.v1.StateNotificationConfig state_notification_config = 7; - */ - public com.google.cloud.iot.v1.StateNotificationConfigOrBuilder - getStateNotificationConfigOrBuilder() { - if (stateNotificationConfigBuilder_ != null) { - return stateNotificationConfigBuilder_.getMessageOrBuilder(); - } else { - return stateNotificationConfig_ == null - ? com.google.cloud.iot.v1.StateNotificationConfig.getDefaultInstance() - : stateNotificationConfig_; - } - } - /** - * - * - *
-     * The configuration for notification of new states received from the device.
-     * State updates are guaranteed to be stored in the state history, but
-     * notifications to Cloud Pub/Sub are not guaranteed. For example, if
-     * permissions are misconfigured or the specified topic doesn't exist, no
-     * notification will be published but the state will still be stored in Cloud
-     * IoT Core.
-     * 
- * - * .google.cloud.iot.v1.StateNotificationConfig state_notification_config = 7; - */ - private com.google.protobuf.SingleFieldBuilderV3< - com.google.cloud.iot.v1.StateNotificationConfig, - com.google.cloud.iot.v1.StateNotificationConfig.Builder, - com.google.cloud.iot.v1.StateNotificationConfigOrBuilder> - getStateNotificationConfigFieldBuilder() { - if (stateNotificationConfigBuilder_ == null) { - stateNotificationConfigBuilder_ = - new com.google.protobuf.SingleFieldBuilderV3< - com.google.cloud.iot.v1.StateNotificationConfig, - com.google.cloud.iot.v1.StateNotificationConfig.Builder, - com.google.cloud.iot.v1.StateNotificationConfigOrBuilder>( - getStateNotificationConfig(), getParentForChildren(), isClean()); - stateNotificationConfig_ = null; - } - return stateNotificationConfigBuilder_; - } - - private com.google.cloud.iot.v1.MqttConfig mqttConfig_; - private com.google.protobuf.SingleFieldBuilderV3< - com.google.cloud.iot.v1.MqttConfig, - com.google.cloud.iot.v1.MqttConfig.Builder, - com.google.cloud.iot.v1.MqttConfigOrBuilder> - mqttConfigBuilder_; - /** - * - * - *
-     * The MQTT configuration for this device registry.
-     * 
- * - * .google.cloud.iot.v1.MqttConfig mqtt_config = 4; - * - * @return Whether the mqttConfig field is set. - */ - public boolean hasMqttConfig() { - return mqttConfigBuilder_ != null || mqttConfig_ != null; - } - /** - * - * - *
-     * The MQTT configuration for this device registry.
-     * 
- * - * .google.cloud.iot.v1.MqttConfig mqtt_config = 4; - * - * @return The mqttConfig. - */ - public com.google.cloud.iot.v1.MqttConfig getMqttConfig() { - if (mqttConfigBuilder_ == null) { - return mqttConfig_ == null - ? com.google.cloud.iot.v1.MqttConfig.getDefaultInstance() - : mqttConfig_; - } else { - return mqttConfigBuilder_.getMessage(); - } - } - /** - * - * - *
-     * The MQTT configuration for this device registry.
-     * 
- * - * .google.cloud.iot.v1.MqttConfig mqtt_config = 4; - */ - public Builder setMqttConfig(com.google.cloud.iot.v1.MqttConfig value) { - if (mqttConfigBuilder_ == null) { - if (value == null) { - throw new NullPointerException(); - } - mqttConfig_ = value; - onChanged(); - } else { - mqttConfigBuilder_.setMessage(value); - } - - return this; - } - /** - * - * - *
-     * The MQTT configuration for this device registry.
-     * 
- * - * .google.cloud.iot.v1.MqttConfig mqtt_config = 4; - */ - public Builder setMqttConfig(com.google.cloud.iot.v1.MqttConfig.Builder builderForValue) { - if (mqttConfigBuilder_ == null) { - mqttConfig_ = builderForValue.build(); - onChanged(); - } else { - mqttConfigBuilder_.setMessage(builderForValue.build()); - } - - return this; - } - /** - * - * - *
-     * The MQTT configuration for this device registry.
-     * 
- * - * .google.cloud.iot.v1.MqttConfig mqtt_config = 4; - */ - public Builder mergeMqttConfig(com.google.cloud.iot.v1.MqttConfig value) { - if (mqttConfigBuilder_ == null) { - if (mqttConfig_ != null) { - mqttConfig_ = - com.google.cloud.iot.v1.MqttConfig.newBuilder(mqttConfig_) - .mergeFrom(value) - .buildPartial(); - } else { - mqttConfig_ = value; - } - onChanged(); - } else { - mqttConfigBuilder_.mergeFrom(value); - } - - return this; - } - /** - * - * - *
-     * The MQTT configuration for this device registry.
-     * 
- * - * .google.cloud.iot.v1.MqttConfig mqtt_config = 4; - */ - public Builder clearMqttConfig() { - if (mqttConfigBuilder_ == null) { - mqttConfig_ = null; - onChanged(); - } else { - mqttConfig_ = null; - mqttConfigBuilder_ = null; - } - - return this; - } - /** - * - * - *
-     * The MQTT configuration for this device registry.
-     * 
- * - * .google.cloud.iot.v1.MqttConfig mqtt_config = 4; - */ - public com.google.cloud.iot.v1.MqttConfig.Builder getMqttConfigBuilder() { - - onChanged(); - return getMqttConfigFieldBuilder().getBuilder(); - } - /** - * - * - *
-     * The MQTT configuration for this device registry.
-     * 
- * - * .google.cloud.iot.v1.MqttConfig mqtt_config = 4; - */ - public com.google.cloud.iot.v1.MqttConfigOrBuilder getMqttConfigOrBuilder() { - if (mqttConfigBuilder_ != null) { - return mqttConfigBuilder_.getMessageOrBuilder(); - } else { - return mqttConfig_ == null - ? com.google.cloud.iot.v1.MqttConfig.getDefaultInstance() - : mqttConfig_; - } - } - /** - * - * - *
-     * The MQTT configuration for this device registry.
-     * 
- * - * .google.cloud.iot.v1.MqttConfig mqtt_config = 4; - */ - private com.google.protobuf.SingleFieldBuilderV3< - com.google.cloud.iot.v1.MqttConfig, - com.google.cloud.iot.v1.MqttConfig.Builder, - com.google.cloud.iot.v1.MqttConfigOrBuilder> - getMqttConfigFieldBuilder() { - if (mqttConfigBuilder_ == null) { - mqttConfigBuilder_ = - new com.google.protobuf.SingleFieldBuilderV3< - com.google.cloud.iot.v1.MqttConfig, - com.google.cloud.iot.v1.MqttConfig.Builder, - com.google.cloud.iot.v1.MqttConfigOrBuilder>( - getMqttConfig(), getParentForChildren(), isClean()); - mqttConfig_ = null; - } - return mqttConfigBuilder_; - } - - private com.google.cloud.iot.v1.HttpConfig httpConfig_; - private com.google.protobuf.SingleFieldBuilderV3< - com.google.cloud.iot.v1.HttpConfig, - com.google.cloud.iot.v1.HttpConfig.Builder, - com.google.cloud.iot.v1.HttpConfigOrBuilder> - httpConfigBuilder_; - /** - * - * - *
-     * The DeviceService (HTTP) configuration for this device registry.
-     * 
- * - * .google.cloud.iot.v1.HttpConfig http_config = 9; - * - * @return Whether the httpConfig field is set. - */ - public boolean hasHttpConfig() { - return httpConfigBuilder_ != null || httpConfig_ != null; - } - /** - * - * - *
-     * The DeviceService (HTTP) configuration for this device registry.
-     * 
- * - * .google.cloud.iot.v1.HttpConfig http_config = 9; - * - * @return The httpConfig. - */ - public com.google.cloud.iot.v1.HttpConfig getHttpConfig() { - if (httpConfigBuilder_ == null) { - return httpConfig_ == null - ? com.google.cloud.iot.v1.HttpConfig.getDefaultInstance() - : httpConfig_; - } else { - return httpConfigBuilder_.getMessage(); - } - } - /** - * - * - *
-     * The DeviceService (HTTP) configuration for this device registry.
-     * 
- * - * .google.cloud.iot.v1.HttpConfig http_config = 9; - */ - public Builder setHttpConfig(com.google.cloud.iot.v1.HttpConfig value) { - if (httpConfigBuilder_ == null) { - if (value == null) { - throw new NullPointerException(); - } - httpConfig_ = value; - onChanged(); - } else { - httpConfigBuilder_.setMessage(value); - } - - return this; - } - /** - * - * - *
-     * The DeviceService (HTTP) configuration for this device registry.
-     * 
- * - * .google.cloud.iot.v1.HttpConfig http_config = 9; - */ - public Builder setHttpConfig(com.google.cloud.iot.v1.HttpConfig.Builder builderForValue) { - if (httpConfigBuilder_ == null) { - httpConfig_ = builderForValue.build(); - onChanged(); - } else { - httpConfigBuilder_.setMessage(builderForValue.build()); - } - - return this; - } - /** - * - * - *
-     * The DeviceService (HTTP) configuration for this device registry.
-     * 
- * - * .google.cloud.iot.v1.HttpConfig http_config = 9; - */ - public Builder mergeHttpConfig(com.google.cloud.iot.v1.HttpConfig value) { - if (httpConfigBuilder_ == null) { - if (httpConfig_ != null) { - httpConfig_ = - com.google.cloud.iot.v1.HttpConfig.newBuilder(httpConfig_) - .mergeFrom(value) - .buildPartial(); - } else { - httpConfig_ = value; - } - onChanged(); - } else { - httpConfigBuilder_.mergeFrom(value); - } - - return this; - } - /** - * - * - *
-     * The DeviceService (HTTP) configuration for this device registry.
-     * 
- * - * .google.cloud.iot.v1.HttpConfig http_config = 9; - */ - public Builder clearHttpConfig() { - if (httpConfigBuilder_ == null) { - httpConfig_ = null; - onChanged(); - } else { - httpConfig_ = null; - httpConfigBuilder_ = null; - } - - return this; - } - /** - * - * - *
-     * The DeviceService (HTTP) configuration for this device registry.
-     * 
- * - * .google.cloud.iot.v1.HttpConfig http_config = 9; - */ - public com.google.cloud.iot.v1.HttpConfig.Builder getHttpConfigBuilder() { - - onChanged(); - return getHttpConfigFieldBuilder().getBuilder(); - } - /** - * - * - *
-     * The DeviceService (HTTP) configuration for this device registry.
-     * 
- * - * .google.cloud.iot.v1.HttpConfig http_config = 9; - */ - public com.google.cloud.iot.v1.HttpConfigOrBuilder getHttpConfigOrBuilder() { - if (httpConfigBuilder_ != null) { - return httpConfigBuilder_.getMessageOrBuilder(); - } else { - return httpConfig_ == null - ? com.google.cloud.iot.v1.HttpConfig.getDefaultInstance() - : httpConfig_; - } - } - /** - * - * - *
-     * The DeviceService (HTTP) configuration for this device registry.
-     * 
- * - * .google.cloud.iot.v1.HttpConfig http_config = 9; - */ - private com.google.protobuf.SingleFieldBuilderV3< - com.google.cloud.iot.v1.HttpConfig, - com.google.cloud.iot.v1.HttpConfig.Builder, - com.google.cloud.iot.v1.HttpConfigOrBuilder> - getHttpConfigFieldBuilder() { - if (httpConfigBuilder_ == null) { - httpConfigBuilder_ = - new com.google.protobuf.SingleFieldBuilderV3< - com.google.cloud.iot.v1.HttpConfig, - com.google.cloud.iot.v1.HttpConfig.Builder, - com.google.cloud.iot.v1.HttpConfigOrBuilder>( - getHttpConfig(), getParentForChildren(), isClean()); - httpConfig_ = null; - } - return httpConfigBuilder_; - } - - private int logLevel_ = 0; - /** - * - * - *
-     * **Beta Feature**
-     * The default logging verbosity for activity from devices in this registry.
-     * The verbosity level can be overridden by Device.log_level.
-     * 
- * - * .google.cloud.iot.v1.LogLevel log_level = 11; - * - * @return The enum numeric value on the wire for logLevel. - */ - @java.lang.Override - public int getLogLevelValue() { - return logLevel_; - } - /** - * - * - *
-     * **Beta Feature**
-     * The default logging verbosity for activity from devices in this registry.
-     * The verbosity level can be overridden by Device.log_level.
-     * 
- * - * .google.cloud.iot.v1.LogLevel log_level = 11; - * - * @param value The enum numeric value on the wire for logLevel to set. - * @return This builder for chaining. - */ - public Builder setLogLevelValue(int value) { - - logLevel_ = value; - onChanged(); - return this; - } - /** - * - * - *
-     * **Beta Feature**
-     * The default logging verbosity for activity from devices in this registry.
-     * The verbosity level can be overridden by Device.log_level.
-     * 
- * - * .google.cloud.iot.v1.LogLevel log_level = 11; - * - * @return The logLevel. - */ - @java.lang.Override - public com.google.cloud.iot.v1.LogLevel getLogLevel() { - @SuppressWarnings("deprecation") - com.google.cloud.iot.v1.LogLevel result = com.google.cloud.iot.v1.LogLevel.valueOf(logLevel_); - return result == null ? com.google.cloud.iot.v1.LogLevel.UNRECOGNIZED : result; - } - /** - * - * - *
-     * **Beta Feature**
-     * The default logging verbosity for activity from devices in this registry.
-     * The verbosity level can be overridden by Device.log_level.
-     * 
- * - * .google.cloud.iot.v1.LogLevel log_level = 11; - * - * @param value The logLevel to set. - * @return This builder for chaining. - */ - public Builder setLogLevel(com.google.cloud.iot.v1.LogLevel value) { - if (value == null) { - throw new NullPointerException(); - } - - logLevel_ = value.getNumber(); - onChanged(); - return this; - } - /** - * - * - *
-     * **Beta Feature**
-     * The default logging verbosity for activity from devices in this registry.
-     * The verbosity level can be overridden by Device.log_level.
-     * 
- * - * .google.cloud.iot.v1.LogLevel log_level = 11; - * - * @return This builder for chaining. - */ - public Builder clearLogLevel() { - - logLevel_ = 0; - onChanged(); - return this; - } - - private java.util.List credentials_ = - java.util.Collections.emptyList(); - - private void ensureCredentialsIsMutable() { - if (!((bitField0_ & 0x00000002) != 0)) { - credentials_ = - new java.util.ArrayList(credentials_); - bitField0_ |= 0x00000002; - } - } - - private com.google.protobuf.RepeatedFieldBuilderV3< - com.google.cloud.iot.v1.RegistryCredential, - com.google.cloud.iot.v1.RegistryCredential.Builder, - com.google.cloud.iot.v1.RegistryCredentialOrBuilder> - credentialsBuilder_; - - /** - * - * - *
-     * The credentials used to verify the device credentials. No more than 10
-     * credentials can be bound to a single registry at a time. The verification
-     * process occurs at the time of device creation or update. If this field is
-     * empty, no verification is performed. Otherwise, the credentials of a newly
-     * created device or added credentials of an updated device should be signed
-     * with one of these registry credentials.
-     * Note, however, that existing devices will never be affected by
-     * modifications to this list of credentials: after a device has been
-     * successfully created in a registry, it should be able to connect even if
-     * its registry credentials are revoked, deleted, or modified.
-     * 
- * - * repeated .google.cloud.iot.v1.RegistryCredential credentials = 8; - */ - public java.util.List getCredentialsList() { - if (credentialsBuilder_ == null) { - return java.util.Collections.unmodifiableList(credentials_); - } else { - return credentialsBuilder_.getMessageList(); - } - } - /** - * - * - *
-     * The credentials used to verify the device credentials. No more than 10
-     * credentials can be bound to a single registry at a time. The verification
-     * process occurs at the time of device creation or update. If this field is
-     * empty, no verification is performed. Otherwise, the credentials of a newly
-     * created device or added credentials of an updated device should be signed
-     * with one of these registry credentials.
-     * Note, however, that existing devices will never be affected by
-     * modifications to this list of credentials: after a device has been
-     * successfully created in a registry, it should be able to connect even if
-     * its registry credentials are revoked, deleted, or modified.
-     * 
- * - * repeated .google.cloud.iot.v1.RegistryCredential credentials = 8; - */ - public int getCredentialsCount() { - if (credentialsBuilder_ == null) { - return credentials_.size(); - } else { - return credentialsBuilder_.getCount(); - } - } - /** - * - * - *
-     * The credentials used to verify the device credentials. No more than 10
-     * credentials can be bound to a single registry at a time. The verification
-     * process occurs at the time of device creation or update. If this field is
-     * empty, no verification is performed. Otherwise, the credentials of a newly
-     * created device or added credentials of an updated device should be signed
-     * with one of these registry credentials.
-     * Note, however, that existing devices will never be affected by
-     * modifications to this list of credentials: after a device has been
-     * successfully created in a registry, it should be able to connect even if
-     * its registry credentials are revoked, deleted, or modified.
-     * 
- * - * repeated .google.cloud.iot.v1.RegistryCredential credentials = 8; - */ - public com.google.cloud.iot.v1.RegistryCredential getCredentials(int index) { - if (credentialsBuilder_ == null) { - return credentials_.get(index); - } else { - return credentialsBuilder_.getMessage(index); - } - } - /** - * - * - *
-     * The credentials used to verify the device credentials. No more than 10
-     * credentials can be bound to a single registry at a time. The verification
-     * process occurs at the time of device creation or update. If this field is
-     * empty, no verification is performed. Otherwise, the credentials of a newly
-     * created device or added credentials of an updated device should be signed
-     * with one of these registry credentials.
-     * Note, however, that existing devices will never be affected by
-     * modifications to this list of credentials: after a device has been
-     * successfully created in a registry, it should be able to connect even if
-     * its registry credentials are revoked, deleted, or modified.
-     * 
- * - * repeated .google.cloud.iot.v1.RegistryCredential credentials = 8; - */ - public Builder setCredentials(int index, com.google.cloud.iot.v1.RegistryCredential value) { - if (credentialsBuilder_ == null) { - if (value == null) { - throw new NullPointerException(); - } - ensureCredentialsIsMutable(); - credentials_.set(index, value); - onChanged(); - } else { - credentialsBuilder_.setMessage(index, value); - } - return this; - } - /** - * - * - *
-     * The credentials used to verify the device credentials. No more than 10
-     * credentials can be bound to a single registry at a time. The verification
-     * process occurs at the time of device creation or update. If this field is
-     * empty, no verification is performed. Otherwise, the credentials of a newly
-     * created device or added credentials of an updated device should be signed
-     * with one of these registry credentials.
-     * Note, however, that existing devices will never be affected by
-     * modifications to this list of credentials: after a device has been
-     * successfully created in a registry, it should be able to connect even if
-     * its registry credentials are revoked, deleted, or modified.
-     * 
- * - * repeated .google.cloud.iot.v1.RegistryCredential credentials = 8; - */ - public Builder setCredentials( - int index, com.google.cloud.iot.v1.RegistryCredential.Builder builderForValue) { - if (credentialsBuilder_ == null) { - ensureCredentialsIsMutable(); - credentials_.set(index, builderForValue.build()); - onChanged(); - } else { - credentialsBuilder_.setMessage(index, builderForValue.build()); - } - return this; - } - /** - * - * - *
-     * The credentials used to verify the device credentials. No more than 10
-     * credentials can be bound to a single registry at a time. The verification
-     * process occurs at the time of device creation or update. If this field is
-     * empty, no verification is performed. Otherwise, the credentials of a newly
-     * created device or added credentials of an updated device should be signed
-     * with one of these registry credentials.
-     * Note, however, that existing devices will never be affected by
-     * modifications to this list of credentials: after a device has been
-     * successfully created in a registry, it should be able to connect even if
-     * its registry credentials are revoked, deleted, or modified.
-     * 
- * - * repeated .google.cloud.iot.v1.RegistryCredential credentials = 8; - */ - public Builder addCredentials(com.google.cloud.iot.v1.RegistryCredential value) { - if (credentialsBuilder_ == null) { - if (value == null) { - throw new NullPointerException(); - } - ensureCredentialsIsMutable(); - credentials_.add(value); - onChanged(); - } else { - credentialsBuilder_.addMessage(value); - } - return this; - } - /** - * - * - *
-     * The credentials used to verify the device credentials. No more than 10
-     * credentials can be bound to a single registry at a time. The verification
-     * process occurs at the time of device creation or update. If this field is
-     * empty, no verification is performed. Otherwise, the credentials of a newly
-     * created device or added credentials of an updated device should be signed
-     * with one of these registry credentials.
-     * Note, however, that existing devices will never be affected by
-     * modifications to this list of credentials: after a device has been
-     * successfully created in a registry, it should be able to connect even if
-     * its registry credentials are revoked, deleted, or modified.
-     * 
- * - * repeated .google.cloud.iot.v1.RegistryCredential credentials = 8; - */ - public Builder addCredentials(int index, com.google.cloud.iot.v1.RegistryCredential value) { - if (credentialsBuilder_ == null) { - if (value == null) { - throw new NullPointerException(); - } - ensureCredentialsIsMutable(); - credentials_.add(index, value); - onChanged(); - } else { - credentialsBuilder_.addMessage(index, value); - } - return this; - } - /** - * - * - *
-     * The credentials used to verify the device credentials. No more than 10
-     * credentials can be bound to a single registry at a time. The verification
-     * process occurs at the time of device creation or update. If this field is
-     * empty, no verification is performed. Otherwise, the credentials of a newly
-     * created device or added credentials of an updated device should be signed
-     * with one of these registry credentials.
-     * Note, however, that existing devices will never be affected by
-     * modifications to this list of credentials: after a device has been
-     * successfully created in a registry, it should be able to connect even if
-     * its registry credentials are revoked, deleted, or modified.
-     * 
- * - * repeated .google.cloud.iot.v1.RegistryCredential credentials = 8; - */ - public Builder addCredentials( - com.google.cloud.iot.v1.RegistryCredential.Builder builderForValue) { - if (credentialsBuilder_ == null) { - ensureCredentialsIsMutable(); - credentials_.add(builderForValue.build()); - onChanged(); - } else { - credentialsBuilder_.addMessage(builderForValue.build()); - } - return this; - } - /** - * - * - *
-     * The credentials used to verify the device credentials. No more than 10
-     * credentials can be bound to a single registry at a time. The verification
-     * process occurs at the time of device creation or update. If this field is
-     * empty, no verification is performed. Otherwise, the credentials of a newly
-     * created device or added credentials of an updated device should be signed
-     * with one of these registry credentials.
-     * Note, however, that existing devices will never be affected by
-     * modifications to this list of credentials: after a device has been
-     * successfully created in a registry, it should be able to connect even if
-     * its registry credentials are revoked, deleted, or modified.
-     * 
- * - * repeated .google.cloud.iot.v1.RegistryCredential credentials = 8; - */ - public Builder addCredentials( - int index, com.google.cloud.iot.v1.RegistryCredential.Builder builderForValue) { - if (credentialsBuilder_ == null) { - ensureCredentialsIsMutable(); - credentials_.add(index, builderForValue.build()); - onChanged(); - } else { - credentialsBuilder_.addMessage(index, builderForValue.build()); - } - return this; - } - /** - * - * - *
-     * The credentials used to verify the device credentials. No more than 10
-     * credentials can be bound to a single registry at a time. The verification
-     * process occurs at the time of device creation or update. If this field is
-     * empty, no verification is performed. Otherwise, the credentials of a newly
-     * created device or added credentials of an updated device should be signed
-     * with one of these registry credentials.
-     * Note, however, that existing devices will never be affected by
-     * modifications to this list of credentials: after a device has been
-     * successfully created in a registry, it should be able to connect even if
-     * its registry credentials are revoked, deleted, or modified.
-     * 
- * - * repeated .google.cloud.iot.v1.RegistryCredential credentials = 8; - */ - public Builder addAllCredentials( - java.lang.Iterable values) { - if (credentialsBuilder_ == null) { - ensureCredentialsIsMutable(); - com.google.protobuf.AbstractMessageLite.Builder.addAll(values, credentials_); - onChanged(); - } else { - credentialsBuilder_.addAllMessages(values); - } - return this; - } - /** - * - * - *
-     * The credentials used to verify the device credentials. No more than 10
-     * credentials can be bound to a single registry at a time. The verification
-     * process occurs at the time of device creation or update. If this field is
-     * empty, no verification is performed. Otherwise, the credentials of a newly
-     * created device or added credentials of an updated device should be signed
-     * with one of these registry credentials.
-     * Note, however, that existing devices will never be affected by
-     * modifications to this list of credentials: after a device has been
-     * successfully created in a registry, it should be able to connect even if
-     * its registry credentials are revoked, deleted, or modified.
-     * 
- * - * repeated .google.cloud.iot.v1.RegistryCredential credentials = 8; - */ - public Builder clearCredentials() { - if (credentialsBuilder_ == null) { - credentials_ = java.util.Collections.emptyList(); - bitField0_ = (bitField0_ & ~0x00000002); - onChanged(); - } else { - credentialsBuilder_.clear(); - } - return this; - } - /** - * - * - *
-     * The credentials used to verify the device credentials. No more than 10
-     * credentials can be bound to a single registry at a time. The verification
-     * process occurs at the time of device creation or update. If this field is
-     * empty, no verification is performed. Otherwise, the credentials of a newly
-     * created device or added credentials of an updated device should be signed
-     * with one of these registry credentials.
-     * Note, however, that existing devices will never be affected by
-     * modifications to this list of credentials: after a device has been
-     * successfully created in a registry, it should be able to connect even if
-     * its registry credentials are revoked, deleted, or modified.
-     * 
- * - * repeated .google.cloud.iot.v1.RegistryCredential credentials = 8; - */ - public Builder removeCredentials(int index) { - if (credentialsBuilder_ == null) { - ensureCredentialsIsMutable(); - credentials_.remove(index); - onChanged(); - } else { - credentialsBuilder_.remove(index); - } - return this; - } - /** - * - * - *
-     * The credentials used to verify the device credentials. No more than 10
-     * credentials can be bound to a single registry at a time. The verification
-     * process occurs at the time of device creation or update. If this field is
-     * empty, no verification is performed. Otherwise, the credentials of a newly
-     * created device or added credentials of an updated device should be signed
-     * with one of these registry credentials.
-     * Note, however, that existing devices will never be affected by
-     * modifications to this list of credentials: after a device has been
-     * successfully created in a registry, it should be able to connect even if
-     * its registry credentials are revoked, deleted, or modified.
-     * 
- * - * repeated .google.cloud.iot.v1.RegistryCredential credentials = 8; - */ - public com.google.cloud.iot.v1.RegistryCredential.Builder getCredentialsBuilder(int index) { - return getCredentialsFieldBuilder().getBuilder(index); - } - /** - * - * - *
-     * The credentials used to verify the device credentials. No more than 10
-     * credentials can be bound to a single registry at a time. The verification
-     * process occurs at the time of device creation or update. If this field is
-     * empty, no verification is performed. Otherwise, the credentials of a newly
-     * created device or added credentials of an updated device should be signed
-     * with one of these registry credentials.
-     * Note, however, that existing devices will never be affected by
-     * modifications to this list of credentials: after a device has been
-     * successfully created in a registry, it should be able to connect even if
-     * its registry credentials are revoked, deleted, or modified.
-     * 
- * - * repeated .google.cloud.iot.v1.RegistryCredential credentials = 8; - */ - public com.google.cloud.iot.v1.RegistryCredentialOrBuilder getCredentialsOrBuilder(int index) { - if (credentialsBuilder_ == null) { - return credentials_.get(index); - } else { - return credentialsBuilder_.getMessageOrBuilder(index); - } - } - /** - * - * - *
-     * The credentials used to verify the device credentials. No more than 10
-     * credentials can be bound to a single registry at a time. The verification
-     * process occurs at the time of device creation or update. If this field is
-     * empty, no verification is performed. Otherwise, the credentials of a newly
-     * created device or added credentials of an updated device should be signed
-     * with one of these registry credentials.
-     * Note, however, that existing devices will never be affected by
-     * modifications to this list of credentials: after a device has been
-     * successfully created in a registry, it should be able to connect even if
-     * its registry credentials are revoked, deleted, or modified.
-     * 
- * - * repeated .google.cloud.iot.v1.RegistryCredential credentials = 8; - */ - public java.util.List - getCredentialsOrBuilderList() { - if (credentialsBuilder_ != null) { - return credentialsBuilder_.getMessageOrBuilderList(); - } else { - return java.util.Collections.unmodifiableList(credentials_); - } - } - /** - * - * - *
-     * The credentials used to verify the device credentials. No more than 10
-     * credentials can be bound to a single registry at a time. The verification
-     * process occurs at the time of device creation or update. If this field is
-     * empty, no verification is performed. Otherwise, the credentials of a newly
-     * created device or added credentials of an updated device should be signed
-     * with one of these registry credentials.
-     * Note, however, that existing devices will never be affected by
-     * modifications to this list of credentials: after a device has been
-     * successfully created in a registry, it should be able to connect even if
-     * its registry credentials are revoked, deleted, or modified.
-     * 
- * - * repeated .google.cloud.iot.v1.RegistryCredential credentials = 8; - */ - public com.google.cloud.iot.v1.RegistryCredential.Builder addCredentialsBuilder() { - return getCredentialsFieldBuilder() - .addBuilder(com.google.cloud.iot.v1.RegistryCredential.getDefaultInstance()); - } - /** - * - * - *
-     * The credentials used to verify the device credentials. No more than 10
-     * credentials can be bound to a single registry at a time. The verification
-     * process occurs at the time of device creation or update. If this field is
-     * empty, no verification is performed. Otherwise, the credentials of a newly
-     * created device or added credentials of an updated device should be signed
-     * with one of these registry credentials.
-     * Note, however, that existing devices will never be affected by
-     * modifications to this list of credentials: after a device has been
-     * successfully created in a registry, it should be able to connect even if
-     * its registry credentials are revoked, deleted, or modified.
-     * 
- * - * repeated .google.cloud.iot.v1.RegistryCredential credentials = 8; - */ - public com.google.cloud.iot.v1.RegistryCredential.Builder addCredentialsBuilder(int index) { - return getCredentialsFieldBuilder() - .addBuilder(index, com.google.cloud.iot.v1.RegistryCredential.getDefaultInstance()); - } - /** - * - * - *
-     * The credentials used to verify the device credentials. No more than 10
-     * credentials can be bound to a single registry at a time. The verification
-     * process occurs at the time of device creation or update. If this field is
-     * empty, no verification is performed. Otherwise, the credentials of a newly
-     * created device or added credentials of an updated device should be signed
-     * with one of these registry credentials.
-     * Note, however, that existing devices will never be affected by
-     * modifications to this list of credentials: after a device has been
-     * successfully created in a registry, it should be able to connect even if
-     * its registry credentials are revoked, deleted, or modified.
-     * 
- * - * repeated .google.cloud.iot.v1.RegistryCredential credentials = 8; - */ - public java.util.List - getCredentialsBuilderList() { - return getCredentialsFieldBuilder().getBuilderList(); - } - - private com.google.protobuf.RepeatedFieldBuilderV3< - com.google.cloud.iot.v1.RegistryCredential, - com.google.cloud.iot.v1.RegistryCredential.Builder, - com.google.cloud.iot.v1.RegistryCredentialOrBuilder> - getCredentialsFieldBuilder() { - if (credentialsBuilder_ == null) { - credentialsBuilder_ = - new com.google.protobuf.RepeatedFieldBuilderV3< - com.google.cloud.iot.v1.RegistryCredential, - com.google.cloud.iot.v1.RegistryCredential.Builder, - com.google.cloud.iot.v1.RegistryCredentialOrBuilder>( - credentials_, ((bitField0_ & 0x00000002) != 0), getParentForChildren(), isClean()); - credentials_ = null; - } - return credentialsBuilder_; - } - - @java.lang.Override - public final Builder setUnknownFields(final com.google.protobuf.UnknownFieldSet unknownFields) { - return super.setUnknownFields(unknownFields); - } - - @java.lang.Override - public final Builder mergeUnknownFields( - final com.google.protobuf.UnknownFieldSet unknownFields) { - return super.mergeUnknownFields(unknownFields); - } - - // @@protoc_insertion_point(builder_scope:google.cloud.iot.v1.DeviceRegistry) - } - - // @@protoc_insertion_point(class_scope:google.cloud.iot.v1.DeviceRegistry) - private static final com.google.cloud.iot.v1.DeviceRegistry DEFAULT_INSTANCE; - - static { - DEFAULT_INSTANCE = new com.google.cloud.iot.v1.DeviceRegistry(); - } - - public static com.google.cloud.iot.v1.DeviceRegistry getDefaultInstance() { - return DEFAULT_INSTANCE; - } - - private static final com.google.protobuf.Parser PARSER = - new com.google.protobuf.AbstractParser() { - @java.lang.Override - public DeviceRegistry parsePartialFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - Builder builder = newBuilder(); - try { - builder.mergeFrom(input, extensionRegistry); - } catch (com.google.protobuf.InvalidProtocolBufferException e) { - throw e.setUnfinishedMessage(builder.buildPartial()); - } catch (com.google.protobuf.UninitializedMessageException e) { - throw e.asInvalidProtocolBufferException().setUnfinishedMessage(builder.buildPartial()); - } catch (java.io.IOException e) { - throw new com.google.protobuf.InvalidProtocolBufferException(e) - .setUnfinishedMessage(builder.buildPartial()); - } - return builder.buildPartial(); - } - }; - - public static com.google.protobuf.Parser parser() { - return PARSER; - } - - @java.lang.Override - public com.google.protobuf.Parser getParserForType() { - return PARSER; - } - - @java.lang.Override - public com.google.cloud.iot.v1.DeviceRegistry getDefaultInstanceForType() { - return DEFAULT_INSTANCE; - } -} diff --git a/proto-google-cloud-iot-v1/src/main/java/com/google/cloud/iot/v1/DeviceRegistryOrBuilder.java b/proto-google-cloud-iot-v1/src/main/java/com/google/cloud/iot/v1/DeviceRegistryOrBuilder.java deleted file mode 100644 index 21b4b684..00000000 --- a/proto-google-cloud-iot-v1/src/main/java/com/google/cloud/iot/v1/DeviceRegistryOrBuilder.java +++ /dev/null @@ -1,421 +0,0 @@ -/* - * Copyright 2020 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. - */ -// Generated by the protocol buffer compiler. DO NOT EDIT! -// source: google/cloud/iot/v1/resources.proto - -package com.google.cloud.iot.v1; - -public interface DeviceRegistryOrBuilder - extends - // @@protoc_insertion_point(interface_extends:google.cloud.iot.v1.DeviceRegistry) - com.google.protobuf.MessageOrBuilder { - - /** - * - * - *
-   * The identifier of this device registry. For example, `myRegistry`.
-   * 
- * - * string id = 1; - * - * @return The id. - */ - java.lang.String getId(); - /** - * - * - *
-   * The identifier of this device registry. For example, `myRegistry`.
-   * 
- * - * string id = 1; - * - * @return The bytes for id. - */ - com.google.protobuf.ByteString getIdBytes(); - - /** - * - * - *
-   * The resource path name. For example,
-   * `projects/example-project/locations/us-central1/registries/my-registry`.
-   * 
- * - * string name = 2; - * - * @return The name. - */ - java.lang.String getName(); - /** - * - * - *
-   * The resource path name. For example,
-   * `projects/example-project/locations/us-central1/registries/my-registry`.
-   * 
- * - * string name = 2; - * - * @return The bytes for name. - */ - com.google.protobuf.ByteString getNameBytes(); - - /** - * - * - *
-   * The configuration for notification of telemetry events received from the
-   * device. All telemetry events that were successfully published by the
-   * device and acknowledged by Cloud IoT Core are guaranteed to be
-   * delivered to Cloud Pub/Sub. If multiple configurations match a message,
-   * only the first matching configuration is used. If you try to publish a
-   * device telemetry event using MQTT without specifying a Cloud Pub/Sub topic
-   * for the device's registry, the connection closes automatically. If you try
-   * to do so using an HTTP connection, an error is returned. Up to 10
-   * configurations may be provided.
-   * 
- * - * repeated .google.cloud.iot.v1.EventNotificationConfig event_notification_configs = 10; - * - */ - java.util.List getEventNotificationConfigsList(); - /** - * - * - *
-   * The configuration for notification of telemetry events received from the
-   * device. All telemetry events that were successfully published by the
-   * device and acknowledged by Cloud IoT Core are guaranteed to be
-   * delivered to Cloud Pub/Sub. If multiple configurations match a message,
-   * only the first matching configuration is used. If you try to publish a
-   * device telemetry event using MQTT without specifying a Cloud Pub/Sub topic
-   * for the device's registry, the connection closes automatically. If you try
-   * to do so using an HTTP connection, an error is returned. Up to 10
-   * configurations may be provided.
-   * 
- * - * repeated .google.cloud.iot.v1.EventNotificationConfig event_notification_configs = 10; - * - */ - com.google.cloud.iot.v1.EventNotificationConfig getEventNotificationConfigs(int index); - /** - * - * - *
-   * The configuration for notification of telemetry events received from the
-   * device. All telemetry events that were successfully published by the
-   * device and acknowledged by Cloud IoT Core are guaranteed to be
-   * delivered to Cloud Pub/Sub. If multiple configurations match a message,
-   * only the first matching configuration is used. If you try to publish a
-   * device telemetry event using MQTT without specifying a Cloud Pub/Sub topic
-   * for the device's registry, the connection closes automatically. If you try
-   * to do so using an HTTP connection, an error is returned. Up to 10
-   * configurations may be provided.
-   * 
- * - * repeated .google.cloud.iot.v1.EventNotificationConfig event_notification_configs = 10; - * - */ - int getEventNotificationConfigsCount(); - /** - * - * - *
-   * The configuration for notification of telemetry events received from the
-   * device. All telemetry events that were successfully published by the
-   * device and acknowledged by Cloud IoT Core are guaranteed to be
-   * delivered to Cloud Pub/Sub. If multiple configurations match a message,
-   * only the first matching configuration is used. If you try to publish a
-   * device telemetry event using MQTT without specifying a Cloud Pub/Sub topic
-   * for the device's registry, the connection closes automatically. If you try
-   * to do so using an HTTP connection, an error is returned. Up to 10
-   * configurations may be provided.
-   * 
- * - * repeated .google.cloud.iot.v1.EventNotificationConfig event_notification_configs = 10; - * - */ - java.util.List - getEventNotificationConfigsOrBuilderList(); - /** - * - * - *
-   * The configuration for notification of telemetry events received from the
-   * device. All telemetry events that were successfully published by the
-   * device and acknowledged by Cloud IoT Core are guaranteed to be
-   * delivered to Cloud Pub/Sub. If multiple configurations match a message,
-   * only the first matching configuration is used. If you try to publish a
-   * device telemetry event using MQTT without specifying a Cloud Pub/Sub topic
-   * for the device's registry, the connection closes automatically. If you try
-   * to do so using an HTTP connection, an error is returned. Up to 10
-   * configurations may be provided.
-   * 
- * - * repeated .google.cloud.iot.v1.EventNotificationConfig event_notification_configs = 10; - * - */ - com.google.cloud.iot.v1.EventNotificationConfigOrBuilder getEventNotificationConfigsOrBuilder( - int index); - - /** - * - * - *
-   * The configuration for notification of new states received from the device.
-   * State updates are guaranteed to be stored in the state history, but
-   * notifications to Cloud Pub/Sub are not guaranteed. For example, if
-   * permissions are misconfigured or the specified topic doesn't exist, no
-   * notification will be published but the state will still be stored in Cloud
-   * IoT Core.
-   * 
- * - * .google.cloud.iot.v1.StateNotificationConfig state_notification_config = 7; - * - * @return Whether the stateNotificationConfig field is set. - */ - boolean hasStateNotificationConfig(); - /** - * - * - *
-   * The configuration for notification of new states received from the device.
-   * State updates are guaranteed to be stored in the state history, but
-   * notifications to Cloud Pub/Sub are not guaranteed. For example, if
-   * permissions are misconfigured or the specified topic doesn't exist, no
-   * notification will be published but the state will still be stored in Cloud
-   * IoT Core.
-   * 
- * - * .google.cloud.iot.v1.StateNotificationConfig state_notification_config = 7; - * - * @return The stateNotificationConfig. - */ - com.google.cloud.iot.v1.StateNotificationConfig getStateNotificationConfig(); - /** - * - * - *
-   * The configuration for notification of new states received from the device.
-   * State updates are guaranteed to be stored in the state history, but
-   * notifications to Cloud Pub/Sub are not guaranteed. For example, if
-   * permissions are misconfigured or the specified topic doesn't exist, no
-   * notification will be published but the state will still be stored in Cloud
-   * IoT Core.
-   * 
- * - * .google.cloud.iot.v1.StateNotificationConfig state_notification_config = 7; - */ - com.google.cloud.iot.v1.StateNotificationConfigOrBuilder getStateNotificationConfigOrBuilder(); - - /** - * - * - *
-   * The MQTT configuration for this device registry.
-   * 
- * - * .google.cloud.iot.v1.MqttConfig mqtt_config = 4; - * - * @return Whether the mqttConfig field is set. - */ - boolean hasMqttConfig(); - /** - * - * - *
-   * The MQTT configuration for this device registry.
-   * 
- * - * .google.cloud.iot.v1.MqttConfig mqtt_config = 4; - * - * @return The mqttConfig. - */ - com.google.cloud.iot.v1.MqttConfig getMqttConfig(); - /** - * - * - *
-   * The MQTT configuration for this device registry.
-   * 
- * - * .google.cloud.iot.v1.MqttConfig mqtt_config = 4; - */ - com.google.cloud.iot.v1.MqttConfigOrBuilder getMqttConfigOrBuilder(); - - /** - * - * - *
-   * The DeviceService (HTTP) configuration for this device registry.
-   * 
- * - * .google.cloud.iot.v1.HttpConfig http_config = 9; - * - * @return Whether the httpConfig field is set. - */ - boolean hasHttpConfig(); - /** - * - * - *
-   * The DeviceService (HTTP) configuration for this device registry.
-   * 
- * - * .google.cloud.iot.v1.HttpConfig http_config = 9; - * - * @return The httpConfig. - */ - com.google.cloud.iot.v1.HttpConfig getHttpConfig(); - /** - * - * - *
-   * The DeviceService (HTTP) configuration for this device registry.
-   * 
- * - * .google.cloud.iot.v1.HttpConfig http_config = 9; - */ - com.google.cloud.iot.v1.HttpConfigOrBuilder getHttpConfigOrBuilder(); - - /** - * - * - *
-   * **Beta Feature**
-   * The default logging verbosity for activity from devices in this registry.
-   * The verbosity level can be overridden by Device.log_level.
-   * 
- * - * .google.cloud.iot.v1.LogLevel log_level = 11; - * - * @return The enum numeric value on the wire for logLevel. - */ - int getLogLevelValue(); - /** - * - * - *
-   * **Beta Feature**
-   * The default logging verbosity for activity from devices in this registry.
-   * The verbosity level can be overridden by Device.log_level.
-   * 
- * - * .google.cloud.iot.v1.LogLevel log_level = 11; - * - * @return The logLevel. - */ - com.google.cloud.iot.v1.LogLevel getLogLevel(); - - /** - * - * - *
-   * The credentials used to verify the device credentials. No more than 10
-   * credentials can be bound to a single registry at a time. The verification
-   * process occurs at the time of device creation or update. If this field is
-   * empty, no verification is performed. Otherwise, the credentials of a newly
-   * created device or added credentials of an updated device should be signed
-   * with one of these registry credentials.
-   * Note, however, that existing devices will never be affected by
-   * modifications to this list of credentials: after a device has been
-   * successfully created in a registry, it should be able to connect even if
-   * its registry credentials are revoked, deleted, or modified.
-   * 
- * - * repeated .google.cloud.iot.v1.RegistryCredential credentials = 8; - */ - java.util.List getCredentialsList(); - /** - * - * - *
-   * The credentials used to verify the device credentials. No more than 10
-   * credentials can be bound to a single registry at a time. The verification
-   * process occurs at the time of device creation or update. If this field is
-   * empty, no verification is performed. Otherwise, the credentials of a newly
-   * created device or added credentials of an updated device should be signed
-   * with one of these registry credentials.
-   * Note, however, that existing devices will never be affected by
-   * modifications to this list of credentials: after a device has been
-   * successfully created in a registry, it should be able to connect even if
-   * its registry credentials are revoked, deleted, or modified.
-   * 
- * - * repeated .google.cloud.iot.v1.RegistryCredential credentials = 8; - */ - com.google.cloud.iot.v1.RegistryCredential getCredentials(int index); - /** - * - * - *
-   * The credentials used to verify the device credentials. No more than 10
-   * credentials can be bound to a single registry at a time. The verification
-   * process occurs at the time of device creation or update. If this field is
-   * empty, no verification is performed. Otherwise, the credentials of a newly
-   * created device or added credentials of an updated device should be signed
-   * with one of these registry credentials.
-   * Note, however, that existing devices will never be affected by
-   * modifications to this list of credentials: after a device has been
-   * successfully created in a registry, it should be able to connect even if
-   * its registry credentials are revoked, deleted, or modified.
-   * 
- * - * repeated .google.cloud.iot.v1.RegistryCredential credentials = 8; - */ - int getCredentialsCount(); - /** - * - * - *
-   * The credentials used to verify the device credentials. No more than 10
-   * credentials can be bound to a single registry at a time. The verification
-   * process occurs at the time of device creation or update. If this field is
-   * empty, no verification is performed. Otherwise, the credentials of a newly
-   * created device or added credentials of an updated device should be signed
-   * with one of these registry credentials.
-   * Note, however, that existing devices will never be affected by
-   * modifications to this list of credentials: after a device has been
-   * successfully created in a registry, it should be able to connect even if
-   * its registry credentials are revoked, deleted, or modified.
-   * 
- * - * repeated .google.cloud.iot.v1.RegistryCredential credentials = 8; - */ - java.util.List - getCredentialsOrBuilderList(); - /** - * - * - *
-   * The credentials used to verify the device credentials. No more than 10
-   * credentials can be bound to a single registry at a time. The verification
-   * process occurs at the time of device creation or update. If this field is
-   * empty, no verification is performed. Otherwise, the credentials of a newly
-   * created device or added credentials of an updated device should be signed
-   * with one of these registry credentials.
-   * Note, however, that existing devices will never be affected by
-   * modifications to this list of credentials: after a device has been
-   * successfully created in a registry, it should be able to connect even if
-   * its registry credentials are revoked, deleted, or modified.
-   * 
- * - * repeated .google.cloud.iot.v1.RegistryCredential credentials = 8; - */ - com.google.cloud.iot.v1.RegistryCredentialOrBuilder getCredentialsOrBuilder(int index); -} diff --git a/proto-google-cloud-iot-v1/src/main/java/com/google/cloud/iot/v1/DeviceState.java b/proto-google-cloud-iot-v1/src/main/java/com/google/cloud/iot/v1/DeviceState.java deleted file mode 100644 index 3a201467..00000000 --- a/proto-google-cloud-iot-v1/src/main/java/com/google/cloud/iot/v1/DeviceState.java +++ /dev/null @@ -1,803 +0,0 @@ -/* - * Copyright 2020 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. - */ -// Generated by the protocol buffer compiler. DO NOT EDIT! -// source: google/cloud/iot/v1/resources.proto - -package com.google.cloud.iot.v1; - -/** - * - * - *
- * The device state, as reported by the device.
- * 
- * - * Protobuf type {@code google.cloud.iot.v1.DeviceState} - */ -public final class DeviceState extends com.google.protobuf.GeneratedMessageV3 - implements - // @@protoc_insertion_point(message_implements:google.cloud.iot.v1.DeviceState) - DeviceStateOrBuilder { - private static final long serialVersionUID = 0L; - // Use DeviceState.newBuilder() to construct. - private DeviceState(com.google.protobuf.GeneratedMessageV3.Builder builder) { - super(builder); - } - - private DeviceState() { - binaryData_ = com.google.protobuf.ByteString.EMPTY; - } - - @java.lang.Override - @SuppressWarnings({"unused"}) - protected java.lang.Object newInstance(UnusedPrivateParameter unused) { - return new DeviceState(); - } - - @java.lang.Override - public final com.google.protobuf.UnknownFieldSet getUnknownFields() { - return this.unknownFields; - } - - public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { - return com.google.cloud.iot.v1.ResourcesProto - .internal_static_google_cloud_iot_v1_DeviceState_descriptor; - } - - @java.lang.Override - protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable - internalGetFieldAccessorTable() { - return com.google.cloud.iot.v1.ResourcesProto - .internal_static_google_cloud_iot_v1_DeviceState_fieldAccessorTable - .ensureFieldAccessorsInitialized( - com.google.cloud.iot.v1.DeviceState.class, - com.google.cloud.iot.v1.DeviceState.Builder.class); - } - - public static final int UPDATE_TIME_FIELD_NUMBER = 1; - private com.google.protobuf.Timestamp updateTime_; - /** - * - * - *
-   * [Output only] The time at which this state version was updated in Cloud
-   * IoT Core.
-   * 
- * - * .google.protobuf.Timestamp update_time = 1; - * - * @return Whether the updateTime field is set. - */ - @java.lang.Override - public boolean hasUpdateTime() { - return updateTime_ != null; - } - /** - * - * - *
-   * [Output only] The time at which this state version was updated in Cloud
-   * IoT Core.
-   * 
- * - * .google.protobuf.Timestamp update_time = 1; - * - * @return The updateTime. - */ - @java.lang.Override - public com.google.protobuf.Timestamp getUpdateTime() { - return updateTime_ == null ? com.google.protobuf.Timestamp.getDefaultInstance() : updateTime_; - } - /** - * - * - *
-   * [Output only] The time at which this state version was updated in Cloud
-   * IoT Core.
-   * 
- * - * .google.protobuf.Timestamp update_time = 1; - */ - @java.lang.Override - public com.google.protobuf.TimestampOrBuilder getUpdateTimeOrBuilder() { - return getUpdateTime(); - } - - public static final int BINARY_DATA_FIELD_NUMBER = 2; - private com.google.protobuf.ByteString binaryData_; - /** - * - * - *
-   * The device state data.
-   * 
- * - * bytes binary_data = 2; - * - * @return The binaryData. - */ - @java.lang.Override - public com.google.protobuf.ByteString getBinaryData() { - return binaryData_; - } - - private byte memoizedIsInitialized = -1; - - @java.lang.Override - public final boolean isInitialized() { - byte isInitialized = memoizedIsInitialized; - if (isInitialized == 1) return true; - if (isInitialized == 0) return false; - - memoizedIsInitialized = 1; - return true; - } - - @java.lang.Override - public void writeTo(com.google.protobuf.CodedOutputStream output) throws java.io.IOException { - if (updateTime_ != null) { - output.writeMessage(1, getUpdateTime()); - } - if (!binaryData_.isEmpty()) { - output.writeBytes(2, binaryData_); - } - getUnknownFields().writeTo(output); - } - - @java.lang.Override - public int getSerializedSize() { - int size = memoizedSize; - if (size != -1) return size; - - size = 0; - if (updateTime_ != null) { - size += com.google.protobuf.CodedOutputStream.computeMessageSize(1, getUpdateTime()); - } - if (!binaryData_.isEmpty()) { - size += com.google.protobuf.CodedOutputStream.computeBytesSize(2, binaryData_); - } - size += getUnknownFields().getSerializedSize(); - memoizedSize = size; - return size; - } - - @java.lang.Override - public boolean equals(final java.lang.Object obj) { - if (obj == this) { - return true; - } - if (!(obj instanceof com.google.cloud.iot.v1.DeviceState)) { - return super.equals(obj); - } - com.google.cloud.iot.v1.DeviceState other = (com.google.cloud.iot.v1.DeviceState) obj; - - if (hasUpdateTime() != other.hasUpdateTime()) return false; - if (hasUpdateTime()) { - if (!getUpdateTime().equals(other.getUpdateTime())) return false; - } - if (!getBinaryData().equals(other.getBinaryData())) return false; - if (!getUnknownFields().equals(other.getUnknownFields())) return false; - return true; - } - - @java.lang.Override - public int hashCode() { - if (memoizedHashCode != 0) { - return memoizedHashCode; - } - int hash = 41; - hash = (19 * hash) + getDescriptor().hashCode(); - if (hasUpdateTime()) { - hash = (37 * hash) + UPDATE_TIME_FIELD_NUMBER; - hash = (53 * hash) + getUpdateTime().hashCode(); - } - hash = (37 * hash) + BINARY_DATA_FIELD_NUMBER; - hash = (53 * hash) + getBinaryData().hashCode(); - hash = (29 * hash) + getUnknownFields().hashCode(); - memoizedHashCode = hash; - return hash; - } - - public static com.google.cloud.iot.v1.DeviceState parseFrom(java.nio.ByteBuffer data) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); - } - - public static com.google.cloud.iot.v1.DeviceState parseFrom( - java.nio.ByteBuffer data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); - } - - public static com.google.cloud.iot.v1.DeviceState parseFrom(com.google.protobuf.ByteString data) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); - } - - public static com.google.cloud.iot.v1.DeviceState parseFrom( - com.google.protobuf.ByteString data, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); - } - - public static com.google.cloud.iot.v1.DeviceState parseFrom(byte[] data) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); - } - - public static com.google.cloud.iot.v1.DeviceState parseFrom( - byte[] data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); - } - - public static com.google.cloud.iot.v1.DeviceState parseFrom(java.io.InputStream input) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input); - } - - public static com.google.cloud.iot.v1.DeviceState parseFrom( - java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3.parseWithIOException( - PARSER, input, extensionRegistry); - } - - public static com.google.cloud.iot.v1.DeviceState parseDelimitedFrom(java.io.InputStream input) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3.parseDelimitedWithIOException(PARSER, input); - } - - public static com.google.cloud.iot.v1.DeviceState parseDelimitedFrom( - java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3.parseDelimitedWithIOException( - PARSER, input, extensionRegistry); - } - - public static com.google.cloud.iot.v1.DeviceState parseFrom( - com.google.protobuf.CodedInputStream input) throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input); - } - - public static com.google.cloud.iot.v1.DeviceState parseFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3.parseWithIOException( - PARSER, input, extensionRegistry); - } - - @java.lang.Override - public Builder newBuilderForType() { - return newBuilder(); - } - - public static Builder newBuilder() { - return DEFAULT_INSTANCE.toBuilder(); - } - - public static Builder newBuilder(com.google.cloud.iot.v1.DeviceState prototype) { - return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); - } - - @java.lang.Override - public Builder toBuilder() { - return this == DEFAULT_INSTANCE ? new Builder() : new Builder().mergeFrom(this); - } - - @java.lang.Override - protected Builder newBuilderForType(com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { - Builder builder = new Builder(parent); - return builder; - } - /** - * - * - *
-   * The device state, as reported by the device.
-   * 
- * - * Protobuf type {@code google.cloud.iot.v1.DeviceState} - */ - public static final class Builder extends com.google.protobuf.GeneratedMessageV3.Builder - implements - // @@protoc_insertion_point(builder_implements:google.cloud.iot.v1.DeviceState) - com.google.cloud.iot.v1.DeviceStateOrBuilder { - public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { - return com.google.cloud.iot.v1.ResourcesProto - .internal_static_google_cloud_iot_v1_DeviceState_descriptor; - } - - @java.lang.Override - protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable - internalGetFieldAccessorTable() { - return com.google.cloud.iot.v1.ResourcesProto - .internal_static_google_cloud_iot_v1_DeviceState_fieldAccessorTable - .ensureFieldAccessorsInitialized( - com.google.cloud.iot.v1.DeviceState.class, - com.google.cloud.iot.v1.DeviceState.Builder.class); - } - - // Construct using com.google.cloud.iot.v1.DeviceState.newBuilder() - private Builder() {} - - private Builder(com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { - super(parent); - } - - @java.lang.Override - public Builder clear() { - super.clear(); - if (updateTimeBuilder_ == null) { - updateTime_ = null; - } else { - updateTime_ = null; - updateTimeBuilder_ = null; - } - binaryData_ = com.google.protobuf.ByteString.EMPTY; - - return this; - } - - @java.lang.Override - public com.google.protobuf.Descriptors.Descriptor getDescriptorForType() { - return com.google.cloud.iot.v1.ResourcesProto - .internal_static_google_cloud_iot_v1_DeviceState_descriptor; - } - - @java.lang.Override - public com.google.cloud.iot.v1.DeviceState getDefaultInstanceForType() { - return com.google.cloud.iot.v1.DeviceState.getDefaultInstance(); - } - - @java.lang.Override - public com.google.cloud.iot.v1.DeviceState build() { - com.google.cloud.iot.v1.DeviceState result = buildPartial(); - if (!result.isInitialized()) { - throw newUninitializedMessageException(result); - } - return result; - } - - @java.lang.Override - public com.google.cloud.iot.v1.DeviceState buildPartial() { - com.google.cloud.iot.v1.DeviceState result = new com.google.cloud.iot.v1.DeviceState(this); - if (updateTimeBuilder_ == null) { - result.updateTime_ = updateTime_; - } else { - result.updateTime_ = updateTimeBuilder_.build(); - } - result.binaryData_ = binaryData_; - onBuilt(); - return result; - } - - @java.lang.Override - public Builder clone() { - return super.clone(); - } - - @java.lang.Override - public Builder setField( - com.google.protobuf.Descriptors.FieldDescriptor field, java.lang.Object value) { - return super.setField(field, value); - } - - @java.lang.Override - public Builder clearField(com.google.protobuf.Descriptors.FieldDescriptor field) { - return super.clearField(field); - } - - @java.lang.Override - public Builder clearOneof(com.google.protobuf.Descriptors.OneofDescriptor oneof) { - return super.clearOneof(oneof); - } - - @java.lang.Override - public Builder setRepeatedField( - com.google.protobuf.Descriptors.FieldDescriptor field, int index, java.lang.Object value) { - return super.setRepeatedField(field, index, value); - } - - @java.lang.Override - public Builder addRepeatedField( - com.google.protobuf.Descriptors.FieldDescriptor field, java.lang.Object value) { - return super.addRepeatedField(field, value); - } - - @java.lang.Override - public Builder mergeFrom(com.google.protobuf.Message other) { - if (other instanceof com.google.cloud.iot.v1.DeviceState) { - return mergeFrom((com.google.cloud.iot.v1.DeviceState) other); - } else { - super.mergeFrom(other); - return this; - } - } - - public Builder mergeFrom(com.google.cloud.iot.v1.DeviceState other) { - if (other == com.google.cloud.iot.v1.DeviceState.getDefaultInstance()) return this; - if (other.hasUpdateTime()) { - mergeUpdateTime(other.getUpdateTime()); - } - if (other.getBinaryData() != com.google.protobuf.ByteString.EMPTY) { - setBinaryData(other.getBinaryData()); - } - this.mergeUnknownFields(other.getUnknownFields()); - onChanged(); - return this; - } - - @java.lang.Override - public final boolean isInitialized() { - return true; - } - - @java.lang.Override - public Builder mergeFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - if (extensionRegistry == null) { - throw new java.lang.NullPointerException(); - } - try { - boolean done = false; - while (!done) { - int tag = input.readTag(); - switch (tag) { - case 0: - done = true; - break; - case 10: - { - input.readMessage(getUpdateTimeFieldBuilder().getBuilder(), extensionRegistry); - - break; - } // case 10 - case 18: - { - binaryData_ = input.readBytes(); - - break; - } // case 18 - default: - { - if (!super.parseUnknownField(input, extensionRegistry, tag)) { - done = true; // was an endgroup tag - } - break; - } // default: - } // switch (tag) - } // while (!done) - } catch (com.google.protobuf.InvalidProtocolBufferException e) { - throw e.unwrapIOException(); - } finally { - onChanged(); - } // finally - return this; - } - - private com.google.protobuf.Timestamp updateTime_; - private com.google.protobuf.SingleFieldBuilderV3< - com.google.protobuf.Timestamp, - com.google.protobuf.Timestamp.Builder, - com.google.protobuf.TimestampOrBuilder> - updateTimeBuilder_; - /** - * - * - *
-     * [Output only] The time at which this state version was updated in Cloud
-     * IoT Core.
-     * 
- * - * .google.protobuf.Timestamp update_time = 1; - * - * @return Whether the updateTime field is set. - */ - public boolean hasUpdateTime() { - return updateTimeBuilder_ != null || updateTime_ != null; - } - /** - * - * - *
-     * [Output only] The time at which this state version was updated in Cloud
-     * IoT Core.
-     * 
- * - * .google.protobuf.Timestamp update_time = 1; - * - * @return The updateTime. - */ - public com.google.protobuf.Timestamp getUpdateTime() { - if (updateTimeBuilder_ == null) { - return updateTime_ == null - ? com.google.protobuf.Timestamp.getDefaultInstance() - : updateTime_; - } else { - return updateTimeBuilder_.getMessage(); - } - } - /** - * - * - *
-     * [Output only] The time at which this state version was updated in Cloud
-     * IoT Core.
-     * 
- * - * .google.protobuf.Timestamp update_time = 1; - */ - public Builder setUpdateTime(com.google.protobuf.Timestamp value) { - if (updateTimeBuilder_ == null) { - if (value == null) { - throw new NullPointerException(); - } - updateTime_ = value; - onChanged(); - } else { - updateTimeBuilder_.setMessage(value); - } - - return this; - } - /** - * - * - *
-     * [Output only] The time at which this state version was updated in Cloud
-     * IoT Core.
-     * 
- * - * .google.protobuf.Timestamp update_time = 1; - */ - public Builder setUpdateTime(com.google.protobuf.Timestamp.Builder builderForValue) { - if (updateTimeBuilder_ == null) { - updateTime_ = builderForValue.build(); - onChanged(); - } else { - updateTimeBuilder_.setMessage(builderForValue.build()); - } - - return this; - } - /** - * - * - *
-     * [Output only] The time at which this state version was updated in Cloud
-     * IoT Core.
-     * 
- * - * .google.protobuf.Timestamp update_time = 1; - */ - public Builder mergeUpdateTime(com.google.protobuf.Timestamp value) { - if (updateTimeBuilder_ == null) { - if (updateTime_ != null) { - updateTime_ = - com.google.protobuf.Timestamp.newBuilder(updateTime_).mergeFrom(value).buildPartial(); - } else { - updateTime_ = value; - } - onChanged(); - } else { - updateTimeBuilder_.mergeFrom(value); - } - - return this; - } - /** - * - * - *
-     * [Output only] The time at which this state version was updated in Cloud
-     * IoT Core.
-     * 
- * - * .google.protobuf.Timestamp update_time = 1; - */ - public Builder clearUpdateTime() { - if (updateTimeBuilder_ == null) { - updateTime_ = null; - onChanged(); - } else { - updateTime_ = null; - updateTimeBuilder_ = null; - } - - return this; - } - /** - * - * - *
-     * [Output only] The time at which this state version was updated in Cloud
-     * IoT Core.
-     * 
- * - * .google.protobuf.Timestamp update_time = 1; - */ - public com.google.protobuf.Timestamp.Builder getUpdateTimeBuilder() { - - onChanged(); - return getUpdateTimeFieldBuilder().getBuilder(); - } - /** - * - * - *
-     * [Output only] The time at which this state version was updated in Cloud
-     * IoT Core.
-     * 
- * - * .google.protobuf.Timestamp update_time = 1; - */ - public com.google.protobuf.TimestampOrBuilder getUpdateTimeOrBuilder() { - if (updateTimeBuilder_ != null) { - return updateTimeBuilder_.getMessageOrBuilder(); - } else { - return updateTime_ == null - ? com.google.protobuf.Timestamp.getDefaultInstance() - : updateTime_; - } - } - /** - * - * - *
-     * [Output only] The time at which this state version was updated in Cloud
-     * IoT Core.
-     * 
- * - * .google.protobuf.Timestamp update_time = 1; - */ - private com.google.protobuf.SingleFieldBuilderV3< - com.google.protobuf.Timestamp, - com.google.protobuf.Timestamp.Builder, - com.google.protobuf.TimestampOrBuilder> - getUpdateTimeFieldBuilder() { - if (updateTimeBuilder_ == null) { - updateTimeBuilder_ = - new com.google.protobuf.SingleFieldBuilderV3< - com.google.protobuf.Timestamp, - com.google.protobuf.Timestamp.Builder, - com.google.protobuf.TimestampOrBuilder>( - getUpdateTime(), getParentForChildren(), isClean()); - updateTime_ = null; - } - return updateTimeBuilder_; - } - - private com.google.protobuf.ByteString binaryData_ = com.google.protobuf.ByteString.EMPTY; - /** - * - * - *
-     * The device state data.
-     * 
- * - * bytes binary_data = 2; - * - * @return The binaryData. - */ - @java.lang.Override - public com.google.protobuf.ByteString getBinaryData() { - return binaryData_; - } - /** - * - * - *
-     * The device state data.
-     * 
- * - * bytes binary_data = 2; - * - * @param value The binaryData to set. - * @return This builder for chaining. - */ - public Builder setBinaryData(com.google.protobuf.ByteString value) { - if (value == null) { - throw new NullPointerException(); - } - - binaryData_ = value; - onChanged(); - return this; - } - /** - * - * - *
-     * The device state data.
-     * 
- * - * bytes binary_data = 2; - * - * @return This builder for chaining. - */ - public Builder clearBinaryData() { - - binaryData_ = getDefaultInstance().getBinaryData(); - onChanged(); - return this; - } - - @java.lang.Override - public final Builder setUnknownFields(final com.google.protobuf.UnknownFieldSet unknownFields) { - return super.setUnknownFields(unknownFields); - } - - @java.lang.Override - public final Builder mergeUnknownFields( - final com.google.protobuf.UnknownFieldSet unknownFields) { - return super.mergeUnknownFields(unknownFields); - } - - // @@protoc_insertion_point(builder_scope:google.cloud.iot.v1.DeviceState) - } - - // @@protoc_insertion_point(class_scope:google.cloud.iot.v1.DeviceState) - private static final com.google.cloud.iot.v1.DeviceState DEFAULT_INSTANCE; - - static { - DEFAULT_INSTANCE = new com.google.cloud.iot.v1.DeviceState(); - } - - public static com.google.cloud.iot.v1.DeviceState getDefaultInstance() { - return DEFAULT_INSTANCE; - } - - private static final com.google.protobuf.Parser PARSER = - new com.google.protobuf.AbstractParser() { - @java.lang.Override - public DeviceState parsePartialFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - Builder builder = newBuilder(); - try { - builder.mergeFrom(input, extensionRegistry); - } catch (com.google.protobuf.InvalidProtocolBufferException e) { - throw e.setUnfinishedMessage(builder.buildPartial()); - } catch (com.google.protobuf.UninitializedMessageException e) { - throw e.asInvalidProtocolBufferException().setUnfinishedMessage(builder.buildPartial()); - } catch (java.io.IOException e) { - throw new com.google.protobuf.InvalidProtocolBufferException(e) - .setUnfinishedMessage(builder.buildPartial()); - } - return builder.buildPartial(); - } - }; - - public static com.google.protobuf.Parser parser() { - return PARSER; - } - - @java.lang.Override - public com.google.protobuf.Parser getParserForType() { - return PARSER; - } - - @java.lang.Override - public com.google.cloud.iot.v1.DeviceState getDefaultInstanceForType() { - return DEFAULT_INSTANCE; - } -} diff --git a/proto-google-cloud-iot-v1/src/main/java/com/google/cloud/iot/v1/DeviceStateOrBuilder.java b/proto-google-cloud-iot-v1/src/main/java/com/google/cloud/iot/v1/DeviceStateOrBuilder.java deleted file mode 100644 index e47221c1..00000000 --- a/proto-google-cloud-iot-v1/src/main/java/com/google/cloud/iot/v1/DeviceStateOrBuilder.java +++ /dev/null @@ -1,76 +0,0 @@ -/* - * Copyright 2020 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. - */ -// Generated by the protocol buffer compiler. DO NOT EDIT! -// source: google/cloud/iot/v1/resources.proto - -package com.google.cloud.iot.v1; - -public interface DeviceStateOrBuilder - extends - // @@protoc_insertion_point(interface_extends:google.cloud.iot.v1.DeviceState) - com.google.protobuf.MessageOrBuilder { - - /** - * - * - *
-   * [Output only] The time at which this state version was updated in Cloud
-   * IoT Core.
-   * 
- * - * .google.protobuf.Timestamp update_time = 1; - * - * @return Whether the updateTime field is set. - */ - boolean hasUpdateTime(); - /** - * - * - *
-   * [Output only] The time at which this state version was updated in Cloud
-   * IoT Core.
-   * 
- * - * .google.protobuf.Timestamp update_time = 1; - * - * @return The updateTime. - */ - com.google.protobuf.Timestamp getUpdateTime(); - /** - * - * - *
-   * [Output only] The time at which this state version was updated in Cloud
-   * IoT Core.
-   * 
- * - * .google.protobuf.Timestamp update_time = 1; - */ - com.google.protobuf.TimestampOrBuilder getUpdateTimeOrBuilder(); - - /** - * - * - *
-   * The device state data.
-   * 
- * - * bytes binary_data = 2; - * - * @return The binaryData. - */ - com.google.protobuf.ByteString getBinaryData(); -} diff --git a/proto-google-cloud-iot-v1/src/main/java/com/google/cloud/iot/v1/EventNotificationConfig.java b/proto-google-cloud-iot-v1/src/main/java/com/google/cloud/iot/v1/EventNotificationConfig.java deleted file mode 100644 index 7a32aa03..00000000 --- a/proto-google-cloud-iot-v1/src/main/java/com/google/cloud/iot/v1/EventNotificationConfig.java +++ /dev/null @@ -1,821 +0,0 @@ -/* - * Copyright 2020 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. - */ -// Generated by the protocol buffer compiler. DO NOT EDIT! -// source: google/cloud/iot/v1/resources.proto - -package com.google.cloud.iot.v1; - -/** - * - * - *
- * The configuration for forwarding telemetry events.
- * 
- * - * Protobuf type {@code google.cloud.iot.v1.EventNotificationConfig} - */ -public final class EventNotificationConfig extends com.google.protobuf.GeneratedMessageV3 - implements - // @@protoc_insertion_point(message_implements:google.cloud.iot.v1.EventNotificationConfig) - EventNotificationConfigOrBuilder { - private static final long serialVersionUID = 0L; - // Use EventNotificationConfig.newBuilder() to construct. - private EventNotificationConfig(com.google.protobuf.GeneratedMessageV3.Builder builder) { - super(builder); - } - - private EventNotificationConfig() { - subfolderMatches_ = ""; - pubsubTopicName_ = ""; - } - - @java.lang.Override - @SuppressWarnings({"unused"}) - protected java.lang.Object newInstance(UnusedPrivateParameter unused) { - return new EventNotificationConfig(); - } - - @java.lang.Override - public final com.google.protobuf.UnknownFieldSet getUnknownFields() { - return this.unknownFields; - } - - public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { - return com.google.cloud.iot.v1.ResourcesProto - .internal_static_google_cloud_iot_v1_EventNotificationConfig_descriptor; - } - - @java.lang.Override - protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable - internalGetFieldAccessorTable() { - return com.google.cloud.iot.v1.ResourcesProto - .internal_static_google_cloud_iot_v1_EventNotificationConfig_fieldAccessorTable - .ensureFieldAccessorsInitialized( - com.google.cloud.iot.v1.EventNotificationConfig.class, - com.google.cloud.iot.v1.EventNotificationConfig.Builder.class); - } - - public static final int SUBFOLDER_MATCHES_FIELD_NUMBER = 2; - private volatile java.lang.Object subfolderMatches_; - /** - * - * - *
-   * If the subfolder name matches this string exactly, this configuration will
-   * be used. The string must not include the leading '/' character. If empty,
-   * all strings are matched. This field is used only for telemetry events;
-   * subfolders are not supported for state changes.
-   * 
- * - * string subfolder_matches = 2; - * - * @return The subfolderMatches. - */ - @java.lang.Override - public java.lang.String getSubfolderMatches() { - java.lang.Object ref = subfolderMatches_; - if (ref instanceof java.lang.String) { - return (java.lang.String) ref; - } else { - com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; - java.lang.String s = bs.toStringUtf8(); - subfolderMatches_ = s; - return s; - } - } - /** - * - * - *
-   * If the subfolder name matches this string exactly, this configuration will
-   * be used. The string must not include the leading '/' character. If empty,
-   * all strings are matched. This field is used only for telemetry events;
-   * subfolders are not supported for state changes.
-   * 
- * - * string subfolder_matches = 2; - * - * @return The bytes for subfolderMatches. - */ - @java.lang.Override - public com.google.protobuf.ByteString getSubfolderMatchesBytes() { - java.lang.Object ref = subfolderMatches_; - if (ref instanceof java.lang.String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); - subfolderMatches_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - - public static final int PUBSUB_TOPIC_NAME_FIELD_NUMBER = 1; - private volatile java.lang.Object pubsubTopicName_; - /** - * - * - *
-   * A Cloud Pub/Sub topic name. For example,
-   * `projects/myProject/topics/deviceEvents`.
-   * 
- * - * string pubsub_topic_name = 1; - * - * @return The pubsubTopicName. - */ - @java.lang.Override - public java.lang.String getPubsubTopicName() { - java.lang.Object ref = pubsubTopicName_; - if (ref instanceof java.lang.String) { - return (java.lang.String) ref; - } else { - com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; - java.lang.String s = bs.toStringUtf8(); - pubsubTopicName_ = s; - return s; - } - } - /** - * - * - *
-   * A Cloud Pub/Sub topic name. For example,
-   * `projects/myProject/topics/deviceEvents`.
-   * 
- * - * string pubsub_topic_name = 1; - * - * @return The bytes for pubsubTopicName. - */ - @java.lang.Override - public com.google.protobuf.ByteString getPubsubTopicNameBytes() { - java.lang.Object ref = pubsubTopicName_; - if (ref instanceof java.lang.String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); - pubsubTopicName_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - - private byte memoizedIsInitialized = -1; - - @java.lang.Override - public final boolean isInitialized() { - byte isInitialized = memoizedIsInitialized; - if (isInitialized == 1) return true; - if (isInitialized == 0) return false; - - memoizedIsInitialized = 1; - return true; - } - - @java.lang.Override - public void writeTo(com.google.protobuf.CodedOutputStream output) throws java.io.IOException { - if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(pubsubTopicName_)) { - com.google.protobuf.GeneratedMessageV3.writeString(output, 1, pubsubTopicName_); - } - if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(subfolderMatches_)) { - com.google.protobuf.GeneratedMessageV3.writeString(output, 2, subfolderMatches_); - } - getUnknownFields().writeTo(output); - } - - @java.lang.Override - public int getSerializedSize() { - int size = memoizedSize; - if (size != -1) return size; - - size = 0; - if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(pubsubTopicName_)) { - size += com.google.protobuf.GeneratedMessageV3.computeStringSize(1, pubsubTopicName_); - } - if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(subfolderMatches_)) { - size += com.google.protobuf.GeneratedMessageV3.computeStringSize(2, subfolderMatches_); - } - size += getUnknownFields().getSerializedSize(); - memoizedSize = size; - return size; - } - - @java.lang.Override - public boolean equals(final java.lang.Object obj) { - if (obj == this) { - return true; - } - if (!(obj instanceof com.google.cloud.iot.v1.EventNotificationConfig)) { - return super.equals(obj); - } - com.google.cloud.iot.v1.EventNotificationConfig other = - (com.google.cloud.iot.v1.EventNotificationConfig) obj; - - if (!getSubfolderMatches().equals(other.getSubfolderMatches())) return false; - if (!getPubsubTopicName().equals(other.getPubsubTopicName())) return false; - if (!getUnknownFields().equals(other.getUnknownFields())) return false; - return true; - } - - @java.lang.Override - public int hashCode() { - if (memoizedHashCode != 0) { - return memoizedHashCode; - } - int hash = 41; - hash = (19 * hash) + getDescriptor().hashCode(); - hash = (37 * hash) + SUBFOLDER_MATCHES_FIELD_NUMBER; - hash = (53 * hash) + getSubfolderMatches().hashCode(); - hash = (37 * hash) + PUBSUB_TOPIC_NAME_FIELD_NUMBER; - hash = (53 * hash) + getPubsubTopicName().hashCode(); - hash = (29 * hash) + getUnknownFields().hashCode(); - memoizedHashCode = hash; - return hash; - } - - public static com.google.cloud.iot.v1.EventNotificationConfig parseFrom(java.nio.ByteBuffer data) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); - } - - public static com.google.cloud.iot.v1.EventNotificationConfig parseFrom( - java.nio.ByteBuffer data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); - } - - public static com.google.cloud.iot.v1.EventNotificationConfig parseFrom( - com.google.protobuf.ByteString data) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); - } - - public static com.google.cloud.iot.v1.EventNotificationConfig parseFrom( - com.google.protobuf.ByteString data, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); - } - - public static com.google.cloud.iot.v1.EventNotificationConfig parseFrom(byte[] data) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); - } - - public static com.google.cloud.iot.v1.EventNotificationConfig parseFrom( - byte[] data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); - } - - public static com.google.cloud.iot.v1.EventNotificationConfig parseFrom(java.io.InputStream input) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input); - } - - public static com.google.cloud.iot.v1.EventNotificationConfig parseFrom( - java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3.parseWithIOException( - PARSER, input, extensionRegistry); - } - - public static com.google.cloud.iot.v1.EventNotificationConfig parseDelimitedFrom( - java.io.InputStream input) throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3.parseDelimitedWithIOException(PARSER, input); - } - - public static com.google.cloud.iot.v1.EventNotificationConfig parseDelimitedFrom( - java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3.parseDelimitedWithIOException( - PARSER, input, extensionRegistry); - } - - public static com.google.cloud.iot.v1.EventNotificationConfig parseFrom( - com.google.protobuf.CodedInputStream input) throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input); - } - - public static com.google.cloud.iot.v1.EventNotificationConfig parseFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3.parseWithIOException( - PARSER, input, extensionRegistry); - } - - @java.lang.Override - public Builder newBuilderForType() { - return newBuilder(); - } - - public static Builder newBuilder() { - return DEFAULT_INSTANCE.toBuilder(); - } - - public static Builder newBuilder(com.google.cloud.iot.v1.EventNotificationConfig prototype) { - return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); - } - - @java.lang.Override - public Builder toBuilder() { - return this == DEFAULT_INSTANCE ? new Builder() : new Builder().mergeFrom(this); - } - - @java.lang.Override - protected Builder newBuilderForType(com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { - Builder builder = new Builder(parent); - return builder; - } - /** - * - * - *
-   * The configuration for forwarding telemetry events.
-   * 
- * - * Protobuf type {@code google.cloud.iot.v1.EventNotificationConfig} - */ - public static final class Builder extends com.google.protobuf.GeneratedMessageV3.Builder - implements - // @@protoc_insertion_point(builder_implements:google.cloud.iot.v1.EventNotificationConfig) - com.google.cloud.iot.v1.EventNotificationConfigOrBuilder { - public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { - return com.google.cloud.iot.v1.ResourcesProto - .internal_static_google_cloud_iot_v1_EventNotificationConfig_descriptor; - } - - @java.lang.Override - protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable - internalGetFieldAccessorTable() { - return com.google.cloud.iot.v1.ResourcesProto - .internal_static_google_cloud_iot_v1_EventNotificationConfig_fieldAccessorTable - .ensureFieldAccessorsInitialized( - com.google.cloud.iot.v1.EventNotificationConfig.class, - com.google.cloud.iot.v1.EventNotificationConfig.Builder.class); - } - - // Construct using com.google.cloud.iot.v1.EventNotificationConfig.newBuilder() - private Builder() {} - - private Builder(com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { - super(parent); - } - - @java.lang.Override - public Builder clear() { - super.clear(); - subfolderMatches_ = ""; - - pubsubTopicName_ = ""; - - return this; - } - - @java.lang.Override - public com.google.protobuf.Descriptors.Descriptor getDescriptorForType() { - return com.google.cloud.iot.v1.ResourcesProto - .internal_static_google_cloud_iot_v1_EventNotificationConfig_descriptor; - } - - @java.lang.Override - public com.google.cloud.iot.v1.EventNotificationConfig getDefaultInstanceForType() { - return com.google.cloud.iot.v1.EventNotificationConfig.getDefaultInstance(); - } - - @java.lang.Override - public com.google.cloud.iot.v1.EventNotificationConfig build() { - com.google.cloud.iot.v1.EventNotificationConfig result = buildPartial(); - if (!result.isInitialized()) { - throw newUninitializedMessageException(result); - } - return result; - } - - @java.lang.Override - public com.google.cloud.iot.v1.EventNotificationConfig buildPartial() { - com.google.cloud.iot.v1.EventNotificationConfig result = - new com.google.cloud.iot.v1.EventNotificationConfig(this); - result.subfolderMatches_ = subfolderMatches_; - result.pubsubTopicName_ = pubsubTopicName_; - onBuilt(); - return result; - } - - @java.lang.Override - public Builder clone() { - return super.clone(); - } - - @java.lang.Override - public Builder setField( - com.google.protobuf.Descriptors.FieldDescriptor field, java.lang.Object value) { - return super.setField(field, value); - } - - @java.lang.Override - public Builder clearField(com.google.protobuf.Descriptors.FieldDescriptor field) { - return super.clearField(field); - } - - @java.lang.Override - public Builder clearOneof(com.google.protobuf.Descriptors.OneofDescriptor oneof) { - return super.clearOneof(oneof); - } - - @java.lang.Override - public Builder setRepeatedField( - com.google.protobuf.Descriptors.FieldDescriptor field, int index, java.lang.Object value) { - return super.setRepeatedField(field, index, value); - } - - @java.lang.Override - public Builder addRepeatedField( - com.google.protobuf.Descriptors.FieldDescriptor field, java.lang.Object value) { - return super.addRepeatedField(field, value); - } - - @java.lang.Override - public Builder mergeFrom(com.google.protobuf.Message other) { - if (other instanceof com.google.cloud.iot.v1.EventNotificationConfig) { - return mergeFrom((com.google.cloud.iot.v1.EventNotificationConfig) other); - } else { - super.mergeFrom(other); - return this; - } - } - - public Builder mergeFrom(com.google.cloud.iot.v1.EventNotificationConfig other) { - if (other == com.google.cloud.iot.v1.EventNotificationConfig.getDefaultInstance()) - return this; - if (!other.getSubfolderMatches().isEmpty()) { - subfolderMatches_ = other.subfolderMatches_; - onChanged(); - } - if (!other.getPubsubTopicName().isEmpty()) { - pubsubTopicName_ = other.pubsubTopicName_; - onChanged(); - } - this.mergeUnknownFields(other.getUnknownFields()); - onChanged(); - return this; - } - - @java.lang.Override - public final boolean isInitialized() { - return true; - } - - @java.lang.Override - public Builder mergeFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - if (extensionRegistry == null) { - throw new java.lang.NullPointerException(); - } - try { - boolean done = false; - while (!done) { - int tag = input.readTag(); - switch (tag) { - case 0: - done = true; - break; - case 10: - { - pubsubTopicName_ = input.readStringRequireUtf8(); - - break; - } // case 10 - case 18: - { - subfolderMatches_ = input.readStringRequireUtf8(); - - break; - } // case 18 - default: - { - if (!super.parseUnknownField(input, extensionRegistry, tag)) { - done = true; // was an endgroup tag - } - break; - } // default: - } // switch (tag) - } // while (!done) - } catch (com.google.protobuf.InvalidProtocolBufferException e) { - throw e.unwrapIOException(); - } finally { - onChanged(); - } // finally - return this; - } - - private java.lang.Object subfolderMatches_ = ""; - /** - * - * - *
-     * If the subfolder name matches this string exactly, this configuration will
-     * be used. The string must not include the leading '/' character. If empty,
-     * all strings are matched. This field is used only for telemetry events;
-     * subfolders are not supported for state changes.
-     * 
- * - * string subfolder_matches = 2; - * - * @return The subfolderMatches. - */ - public java.lang.String getSubfolderMatches() { - java.lang.Object ref = subfolderMatches_; - if (!(ref instanceof java.lang.String)) { - com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; - java.lang.String s = bs.toStringUtf8(); - subfolderMatches_ = s; - return s; - } else { - return (java.lang.String) ref; - } - } - /** - * - * - *
-     * If the subfolder name matches this string exactly, this configuration will
-     * be used. The string must not include the leading '/' character. If empty,
-     * all strings are matched. This field is used only for telemetry events;
-     * subfolders are not supported for state changes.
-     * 
- * - * string subfolder_matches = 2; - * - * @return The bytes for subfolderMatches. - */ - public com.google.protobuf.ByteString getSubfolderMatchesBytes() { - java.lang.Object ref = subfolderMatches_; - if (ref instanceof String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); - subfolderMatches_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - /** - * - * - *
-     * If the subfolder name matches this string exactly, this configuration will
-     * be used. The string must not include the leading '/' character. If empty,
-     * all strings are matched. This field is used only for telemetry events;
-     * subfolders are not supported for state changes.
-     * 
- * - * string subfolder_matches = 2; - * - * @param value The subfolderMatches to set. - * @return This builder for chaining. - */ - public Builder setSubfolderMatches(java.lang.String value) { - if (value == null) { - throw new NullPointerException(); - } - - subfolderMatches_ = value; - onChanged(); - return this; - } - /** - * - * - *
-     * If the subfolder name matches this string exactly, this configuration will
-     * be used. The string must not include the leading '/' character. If empty,
-     * all strings are matched. This field is used only for telemetry events;
-     * subfolders are not supported for state changes.
-     * 
- * - * string subfolder_matches = 2; - * - * @return This builder for chaining. - */ - public Builder clearSubfolderMatches() { - - subfolderMatches_ = getDefaultInstance().getSubfolderMatches(); - onChanged(); - return this; - } - /** - * - * - *
-     * If the subfolder name matches this string exactly, this configuration will
-     * be used. The string must not include the leading '/' character. If empty,
-     * all strings are matched. This field is used only for telemetry events;
-     * subfolders are not supported for state changes.
-     * 
- * - * string subfolder_matches = 2; - * - * @param value The bytes for subfolderMatches to set. - * @return This builder for chaining. - */ - public Builder setSubfolderMatchesBytes(com.google.protobuf.ByteString value) { - if (value == null) { - throw new NullPointerException(); - } - checkByteStringIsUtf8(value); - - subfolderMatches_ = value; - onChanged(); - return this; - } - - private java.lang.Object pubsubTopicName_ = ""; - /** - * - * - *
-     * A Cloud Pub/Sub topic name. For example,
-     * `projects/myProject/topics/deviceEvents`.
-     * 
- * - * string pubsub_topic_name = 1; - * - * @return The pubsubTopicName. - */ - public java.lang.String getPubsubTopicName() { - java.lang.Object ref = pubsubTopicName_; - if (!(ref instanceof java.lang.String)) { - com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; - java.lang.String s = bs.toStringUtf8(); - pubsubTopicName_ = s; - return s; - } else { - return (java.lang.String) ref; - } - } - /** - * - * - *
-     * A Cloud Pub/Sub topic name. For example,
-     * `projects/myProject/topics/deviceEvents`.
-     * 
- * - * string pubsub_topic_name = 1; - * - * @return The bytes for pubsubTopicName. - */ - public com.google.protobuf.ByteString getPubsubTopicNameBytes() { - java.lang.Object ref = pubsubTopicName_; - if (ref instanceof String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); - pubsubTopicName_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - /** - * - * - *
-     * A Cloud Pub/Sub topic name. For example,
-     * `projects/myProject/topics/deviceEvents`.
-     * 
- * - * string pubsub_topic_name = 1; - * - * @param value The pubsubTopicName to set. - * @return This builder for chaining. - */ - public Builder setPubsubTopicName(java.lang.String value) { - if (value == null) { - throw new NullPointerException(); - } - - pubsubTopicName_ = value; - onChanged(); - return this; - } - /** - * - * - *
-     * A Cloud Pub/Sub topic name. For example,
-     * `projects/myProject/topics/deviceEvents`.
-     * 
- * - * string pubsub_topic_name = 1; - * - * @return This builder for chaining. - */ - public Builder clearPubsubTopicName() { - - pubsubTopicName_ = getDefaultInstance().getPubsubTopicName(); - onChanged(); - return this; - } - /** - * - * - *
-     * A Cloud Pub/Sub topic name. For example,
-     * `projects/myProject/topics/deviceEvents`.
-     * 
- * - * string pubsub_topic_name = 1; - * - * @param value The bytes for pubsubTopicName to set. - * @return This builder for chaining. - */ - public Builder setPubsubTopicNameBytes(com.google.protobuf.ByteString value) { - if (value == null) { - throw new NullPointerException(); - } - checkByteStringIsUtf8(value); - - pubsubTopicName_ = value; - onChanged(); - return this; - } - - @java.lang.Override - public final Builder setUnknownFields(final com.google.protobuf.UnknownFieldSet unknownFields) { - return super.setUnknownFields(unknownFields); - } - - @java.lang.Override - public final Builder mergeUnknownFields( - final com.google.protobuf.UnknownFieldSet unknownFields) { - return super.mergeUnknownFields(unknownFields); - } - - // @@protoc_insertion_point(builder_scope:google.cloud.iot.v1.EventNotificationConfig) - } - - // @@protoc_insertion_point(class_scope:google.cloud.iot.v1.EventNotificationConfig) - private static final com.google.cloud.iot.v1.EventNotificationConfig DEFAULT_INSTANCE; - - static { - DEFAULT_INSTANCE = new com.google.cloud.iot.v1.EventNotificationConfig(); - } - - public static com.google.cloud.iot.v1.EventNotificationConfig getDefaultInstance() { - return DEFAULT_INSTANCE; - } - - private static final com.google.protobuf.Parser PARSER = - new com.google.protobuf.AbstractParser() { - @java.lang.Override - public EventNotificationConfig parsePartialFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - Builder builder = newBuilder(); - try { - builder.mergeFrom(input, extensionRegistry); - } catch (com.google.protobuf.InvalidProtocolBufferException e) { - throw e.setUnfinishedMessage(builder.buildPartial()); - } catch (com.google.protobuf.UninitializedMessageException e) { - throw e.asInvalidProtocolBufferException().setUnfinishedMessage(builder.buildPartial()); - } catch (java.io.IOException e) { - throw new com.google.protobuf.InvalidProtocolBufferException(e) - .setUnfinishedMessage(builder.buildPartial()); - } - return builder.buildPartial(); - } - }; - - public static com.google.protobuf.Parser parser() { - return PARSER; - } - - @java.lang.Override - public com.google.protobuf.Parser getParserForType() { - return PARSER; - } - - @java.lang.Override - public com.google.cloud.iot.v1.EventNotificationConfig getDefaultInstanceForType() { - return DEFAULT_INSTANCE; - } -} diff --git a/proto-google-cloud-iot-v1/src/main/java/com/google/cloud/iot/v1/EventNotificationConfigOrBuilder.java b/proto-google-cloud-iot-v1/src/main/java/com/google/cloud/iot/v1/EventNotificationConfigOrBuilder.java deleted file mode 100644 index 40cd05f7..00000000 --- a/proto-google-cloud-iot-v1/src/main/java/com/google/cloud/iot/v1/EventNotificationConfigOrBuilder.java +++ /dev/null @@ -1,83 +0,0 @@ -/* - * Copyright 2020 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. - */ -// Generated by the protocol buffer compiler. DO NOT EDIT! -// source: google/cloud/iot/v1/resources.proto - -package com.google.cloud.iot.v1; - -public interface EventNotificationConfigOrBuilder - extends - // @@protoc_insertion_point(interface_extends:google.cloud.iot.v1.EventNotificationConfig) - com.google.protobuf.MessageOrBuilder { - - /** - * - * - *
-   * If the subfolder name matches this string exactly, this configuration will
-   * be used. The string must not include the leading '/' character. If empty,
-   * all strings are matched. This field is used only for telemetry events;
-   * subfolders are not supported for state changes.
-   * 
- * - * string subfolder_matches = 2; - * - * @return The subfolderMatches. - */ - java.lang.String getSubfolderMatches(); - /** - * - * - *
-   * If the subfolder name matches this string exactly, this configuration will
-   * be used. The string must not include the leading '/' character. If empty,
-   * all strings are matched. This field is used only for telemetry events;
-   * subfolders are not supported for state changes.
-   * 
- * - * string subfolder_matches = 2; - * - * @return The bytes for subfolderMatches. - */ - com.google.protobuf.ByteString getSubfolderMatchesBytes(); - - /** - * - * - *
-   * A Cloud Pub/Sub topic name. For example,
-   * `projects/myProject/topics/deviceEvents`.
-   * 
- * - * string pubsub_topic_name = 1; - * - * @return The pubsubTopicName. - */ - java.lang.String getPubsubTopicName(); - /** - * - * - *
-   * A Cloud Pub/Sub topic name. For example,
-   * `projects/myProject/topics/deviceEvents`.
-   * 
- * - * string pubsub_topic_name = 1; - * - * @return The bytes for pubsubTopicName. - */ - com.google.protobuf.ByteString getPubsubTopicNameBytes(); -} diff --git a/proto-google-cloud-iot-v1/src/main/java/com/google/cloud/iot/v1/GatewayAuthMethod.java b/proto-google-cloud-iot-v1/src/main/java/com/google/cloud/iot/v1/GatewayAuthMethod.java deleted file mode 100644 index d4088e00..00000000 --- a/proto-google-cloud-iot-v1/src/main/java/com/google/cloud/iot/v1/GatewayAuthMethod.java +++ /dev/null @@ -1,211 +0,0 @@ -/* - * Copyright 2020 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. - */ -// Generated by the protocol buffer compiler. DO NOT EDIT! -// source: google/cloud/iot/v1/resources.proto - -package com.google.cloud.iot.v1; - -/** - * - * - *
- * The gateway authorization/authentication method. This setting determines how
- * Cloud IoT Core authorizes/authenticate devices to access the gateway.
- * 
- * - * Protobuf enum {@code google.cloud.iot.v1.GatewayAuthMethod} - */ -public enum GatewayAuthMethod implements com.google.protobuf.ProtocolMessageEnum { - /** - * - * - *
-   * No authentication/authorization method specified. No devices are allowed to
-   * access the gateway.
-   * 
- * - * GATEWAY_AUTH_METHOD_UNSPECIFIED = 0; - */ - GATEWAY_AUTH_METHOD_UNSPECIFIED(0), - /** - * - * - *
-   * The device is authenticated through the gateway association only. Device
-   * credentials are ignored even if provided.
-   * 
- * - * ASSOCIATION_ONLY = 1; - */ - ASSOCIATION_ONLY(1), - /** - * - * - *
-   * The device is authenticated through its own credentials. Gateway
-   * association is not checked.
-   * 
- * - * DEVICE_AUTH_TOKEN_ONLY = 2; - */ - DEVICE_AUTH_TOKEN_ONLY(2), - /** - * - * - *
-   * The device is authenticated through both device credentials and gateway
-   * association. The device must be bound to the gateway and must provide its
-   * own credentials.
-   * 
- * - * ASSOCIATION_AND_DEVICE_AUTH_TOKEN = 3; - */ - ASSOCIATION_AND_DEVICE_AUTH_TOKEN(3), - UNRECOGNIZED(-1), - ; - - /** - * - * - *
-   * No authentication/authorization method specified. No devices are allowed to
-   * access the gateway.
-   * 
- * - * GATEWAY_AUTH_METHOD_UNSPECIFIED = 0; - */ - public static final int GATEWAY_AUTH_METHOD_UNSPECIFIED_VALUE = 0; - /** - * - * - *
-   * The device is authenticated through the gateway association only. Device
-   * credentials are ignored even if provided.
-   * 
- * - * ASSOCIATION_ONLY = 1; - */ - public static final int ASSOCIATION_ONLY_VALUE = 1; - /** - * - * - *
-   * The device is authenticated through its own credentials. Gateway
-   * association is not checked.
-   * 
- * - * DEVICE_AUTH_TOKEN_ONLY = 2; - */ - public static final int DEVICE_AUTH_TOKEN_ONLY_VALUE = 2; - /** - * - * - *
-   * The device is authenticated through both device credentials and gateway
-   * association. The device must be bound to the gateway and must provide its
-   * own credentials.
-   * 
- * - * ASSOCIATION_AND_DEVICE_AUTH_TOKEN = 3; - */ - public static final int ASSOCIATION_AND_DEVICE_AUTH_TOKEN_VALUE = 3; - - public final int getNumber() { - if (this == UNRECOGNIZED) { - throw new java.lang.IllegalArgumentException( - "Can't get the number of an unknown enum value."); - } - return value; - } - - /** - * @param value The numeric wire value of the corresponding enum entry. - * @return The enum associated with the given numeric wire value. - * @deprecated Use {@link #forNumber(int)} instead. - */ - @java.lang.Deprecated - public static GatewayAuthMethod valueOf(int value) { - return forNumber(value); - } - - /** - * @param value The numeric wire value of the corresponding enum entry. - * @return The enum associated with the given numeric wire value. - */ - public static GatewayAuthMethod forNumber(int value) { - switch (value) { - case 0: - return GATEWAY_AUTH_METHOD_UNSPECIFIED; - case 1: - return ASSOCIATION_ONLY; - case 2: - return DEVICE_AUTH_TOKEN_ONLY; - case 3: - return ASSOCIATION_AND_DEVICE_AUTH_TOKEN; - default: - return null; - } - } - - public static com.google.protobuf.Internal.EnumLiteMap internalGetValueMap() { - return internalValueMap; - } - - private static final com.google.protobuf.Internal.EnumLiteMap - internalValueMap = - new com.google.protobuf.Internal.EnumLiteMap() { - public GatewayAuthMethod findValueByNumber(int number) { - return GatewayAuthMethod.forNumber(number); - } - }; - - public final com.google.protobuf.Descriptors.EnumValueDescriptor getValueDescriptor() { - if (this == UNRECOGNIZED) { - throw new java.lang.IllegalStateException( - "Can't get the descriptor of an unrecognized enum value."); - } - return getDescriptor().getValues().get(ordinal()); - } - - public final com.google.protobuf.Descriptors.EnumDescriptor getDescriptorForType() { - return getDescriptor(); - } - - public static final com.google.protobuf.Descriptors.EnumDescriptor getDescriptor() { - return com.google.cloud.iot.v1.ResourcesProto.getDescriptor().getEnumTypes().get(4); - } - - private static final GatewayAuthMethod[] VALUES = values(); - - public static GatewayAuthMethod valueOf( - com.google.protobuf.Descriptors.EnumValueDescriptor desc) { - if (desc.getType() != getDescriptor()) { - throw new java.lang.IllegalArgumentException("EnumValueDescriptor is not for this type."); - } - if (desc.getIndex() == -1) { - return UNRECOGNIZED; - } - return VALUES[desc.getIndex()]; - } - - private final int value; - - private GatewayAuthMethod(int value) { - this.value = value; - } - - // @@protoc_insertion_point(enum_scope:google.cloud.iot.v1.GatewayAuthMethod) -} diff --git a/proto-google-cloud-iot-v1/src/main/java/com/google/cloud/iot/v1/GatewayConfig.java b/proto-google-cloud-iot-v1/src/main/java/com/google/cloud/iot/v1/GatewayConfig.java deleted file mode 100644 index 7bbc38f4..00000000 --- a/proto-google-cloud-iot-v1/src/main/java/com/google/cloud/iot/v1/GatewayConfig.java +++ /dev/null @@ -1,1201 +0,0 @@ -/* - * Copyright 2020 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. - */ -// Generated by the protocol buffer compiler. DO NOT EDIT! -// source: google/cloud/iot/v1/resources.proto - -package com.google.cloud.iot.v1; - -/** - * - * - *
- * Gateway-related configuration and state.
- * 
- * - * Protobuf type {@code google.cloud.iot.v1.GatewayConfig} - */ -public final class GatewayConfig extends com.google.protobuf.GeneratedMessageV3 - implements - // @@protoc_insertion_point(message_implements:google.cloud.iot.v1.GatewayConfig) - GatewayConfigOrBuilder { - private static final long serialVersionUID = 0L; - // Use GatewayConfig.newBuilder() to construct. - private GatewayConfig(com.google.protobuf.GeneratedMessageV3.Builder builder) { - super(builder); - } - - private GatewayConfig() { - gatewayType_ = 0; - gatewayAuthMethod_ = 0; - lastAccessedGatewayId_ = ""; - } - - @java.lang.Override - @SuppressWarnings({"unused"}) - protected java.lang.Object newInstance(UnusedPrivateParameter unused) { - return new GatewayConfig(); - } - - @java.lang.Override - public final com.google.protobuf.UnknownFieldSet getUnknownFields() { - return this.unknownFields; - } - - public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { - return com.google.cloud.iot.v1.ResourcesProto - .internal_static_google_cloud_iot_v1_GatewayConfig_descriptor; - } - - @java.lang.Override - protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable - internalGetFieldAccessorTable() { - return com.google.cloud.iot.v1.ResourcesProto - .internal_static_google_cloud_iot_v1_GatewayConfig_fieldAccessorTable - .ensureFieldAccessorsInitialized( - com.google.cloud.iot.v1.GatewayConfig.class, - com.google.cloud.iot.v1.GatewayConfig.Builder.class); - } - - public static final int GATEWAY_TYPE_FIELD_NUMBER = 1; - private int gatewayType_; - /** - * - * - *
-   * Indicates whether the device is a gateway.
-   * 
- * - * .google.cloud.iot.v1.GatewayType gateway_type = 1; - * - * @return The enum numeric value on the wire for gatewayType. - */ - @java.lang.Override - public int getGatewayTypeValue() { - return gatewayType_; - } - /** - * - * - *
-   * Indicates whether the device is a gateway.
-   * 
- * - * .google.cloud.iot.v1.GatewayType gateway_type = 1; - * - * @return The gatewayType. - */ - @java.lang.Override - public com.google.cloud.iot.v1.GatewayType getGatewayType() { - @SuppressWarnings("deprecation") - com.google.cloud.iot.v1.GatewayType result = - com.google.cloud.iot.v1.GatewayType.valueOf(gatewayType_); - return result == null ? com.google.cloud.iot.v1.GatewayType.UNRECOGNIZED : result; - } - - public static final int GATEWAY_AUTH_METHOD_FIELD_NUMBER = 2; - private int gatewayAuthMethod_; - /** - * - * - *
-   * Indicates how to authorize and/or authenticate devices to access the
-   * gateway.
-   * 
- * - * .google.cloud.iot.v1.GatewayAuthMethod gateway_auth_method = 2; - * - * @return The enum numeric value on the wire for gatewayAuthMethod. - */ - @java.lang.Override - public int getGatewayAuthMethodValue() { - return gatewayAuthMethod_; - } - /** - * - * - *
-   * Indicates how to authorize and/or authenticate devices to access the
-   * gateway.
-   * 
- * - * .google.cloud.iot.v1.GatewayAuthMethod gateway_auth_method = 2; - * - * @return The gatewayAuthMethod. - */ - @java.lang.Override - public com.google.cloud.iot.v1.GatewayAuthMethod getGatewayAuthMethod() { - @SuppressWarnings("deprecation") - com.google.cloud.iot.v1.GatewayAuthMethod result = - com.google.cloud.iot.v1.GatewayAuthMethod.valueOf(gatewayAuthMethod_); - return result == null ? com.google.cloud.iot.v1.GatewayAuthMethod.UNRECOGNIZED : result; - } - - public static final int LAST_ACCESSED_GATEWAY_ID_FIELD_NUMBER = 3; - private volatile java.lang.Object lastAccessedGatewayId_; - /** - * - * - *
-   * [Output only] The ID of the gateway the device accessed most recently.
-   * 
- * - * string last_accessed_gateway_id = 3; - * - * @return The lastAccessedGatewayId. - */ - @java.lang.Override - public java.lang.String getLastAccessedGatewayId() { - java.lang.Object ref = lastAccessedGatewayId_; - if (ref instanceof java.lang.String) { - return (java.lang.String) ref; - } else { - com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; - java.lang.String s = bs.toStringUtf8(); - lastAccessedGatewayId_ = s; - return s; - } - } - /** - * - * - *
-   * [Output only] The ID of the gateway the device accessed most recently.
-   * 
- * - * string last_accessed_gateway_id = 3; - * - * @return The bytes for lastAccessedGatewayId. - */ - @java.lang.Override - public com.google.protobuf.ByteString getLastAccessedGatewayIdBytes() { - java.lang.Object ref = lastAccessedGatewayId_; - if (ref instanceof java.lang.String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); - lastAccessedGatewayId_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - - public static final int LAST_ACCESSED_GATEWAY_TIME_FIELD_NUMBER = 4; - private com.google.protobuf.Timestamp lastAccessedGatewayTime_; - /** - * - * - *
-   * [Output only] The most recent time at which the device accessed the gateway
-   * specified in `last_accessed_gateway`.
-   * 
- * - * .google.protobuf.Timestamp last_accessed_gateway_time = 4; - * - * @return Whether the lastAccessedGatewayTime field is set. - */ - @java.lang.Override - public boolean hasLastAccessedGatewayTime() { - return lastAccessedGatewayTime_ != null; - } - /** - * - * - *
-   * [Output only] The most recent time at which the device accessed the gateway
-   * specified in `last_accessed_gateway`.
-   * 
- * - * .google.protobuf.Timestamp last_accessed_gateway_time = 4; - * - * @return The lastAccessedGatewayTime. - */ - @java.lang.Override - public com.google.protobuf.Timestamp getLastAccessedGatewayTime() { - return lastAccessedGatewayTime_ == null - ? com.google.protobuf.Timestamp.getDefaultInstance() - : lastAccessedGatewayTime_; - } - /** - * - * - *
-   * [Output only] The most recent time at which the device accessed the gateway
-   * specified in `last_accessed_gateway`.
-   * 
- * - * .google.protobuf.Timestamp last_accessed_gateway_time = 4; - */ - @java.lang.Override - public com.google.protobuf.TimestampOrBuilder getLastAccessedGatewayTimeOrBuilder() { - return getLastAccessedGatewayTime(); - } - - private byte memoizedIsInitialized = -1; - - @java.lang.Override - public final boolean isInitialized() { - byte isInitialized = memoizedIsInitialized; - if (isInitialized == 1) return true; - if (isInitialized == 0) return false; - - memoizedIsInitialized = 1; - return true; - } - - @java.lang.Override - public void writeTo(com.google.protobuf.CodedOutputStream output) throws java.io.IOException { - if (gatewayType_ != com.google.cloud.iot.v1.GatewayType.GATEWAY_TYPE_UNSPECIFIED.getNumber()) { - output.writeEnum(1, gatewayType_); - } - if (gatewayAuthMethod_ - != com.google.cloud.iot.v1.GatewayAuthMethod.GATEWAY_AUTH_METHOD_UNSPECIFIED.getNumber()) { - output.writeEnum(2, gatewayAuthMethod_); - } - if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(lastAccessedGatewayId_)) { - com.google.protobuf.GeneratedMessageV3.writeString(output, 3, lastAccessedGatewayId_); - } - if (lastAccessedGatewayTime_ != null) { - output.writeMessage(4, getLastAccessedGatewayTime()); - } - getUnknownFields().writeTo(output); - } - - @java.lang.Override - public int getSerializedSize() { - int size = memoizedSize; - if (size != -1) return size; - - size = 0; - if (gatewayType_ != com.google.cloud.iot.v1.GatewayType.GATEWAY_TYPE_UNSPECIFIED.getNumber()) { - size += com.google.protobuf.CodedOutputStream.computeEnumSize(1, gatewayType_); - } - if (gatewayAuthMethod_ - != com.google.cloud.iot.v1.GatewayAuthMethod.GATEWAY_AUTH_METHOD_UNSPECIFIED.getNumber()) { - size += com.google.protobuf.CodedOutputStream.computeEnumSize(2, gatewayAuthMethod_); - } - if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(lastAccessedGatewayId_)) { - size += com.google.protobuf.GeneratedMessageV3.computeStringSize(3, lastAccessedGatewayId_); - } - if (lastAccessedGatewayTime_ != null) { - size += - com.google.protobuf.CodedOutputStream.computeMessageSize(4, getLastAccessedGatewayTime()); - } - size += getUnknownFields().getSerializedSize(); - memoizedSize = size; - return size; - } - - @java.lang.Override - public boolean equals(final java.lang.Object obj) { - if (obj == this) { - return true; - } - if (!(obj instanceof com.google.cloud.iot.v1.GatewayConfig)) { - return super.equals(obj); - } - com.google.cloud.iot.v1.GatewayConfig other = (com.google.cloud.iot.v1.GatewayConfig) obj; - - if (gatewayType_ != other.gatewayType_) return false; - if (gatewayAuthMethod_ != other.gatewayAuthMethod_) return false; - if (!getLastAccessedGatewayId().equals(other.getLastAccessedGatewayId())) return false; - if (hasLastAccessedGatewayTime() != other.hasLastAccessedGatewayTime()) return false; - if (hasLastAccessedGatewayTime()) { - if (!getLastAccessedGatewayTime().equals(other.getLastAccessedGatewayTime())) return false; - } - if (!getUnknownFields().equals(other.getUnknownFields())) return false; - return true; - } - - @java.lang.Override - public int hashCode() { - if (memoizedHashCode != 0) { - return memoizedHashCode; - } - int hash = 41; - hash = (19 * hash) + getDescriptor().hashCode(); - hash = (37 * hash) + GATEWAY_TYPE_FIELD_NUMBER; - hash = (53 * hash) + gatewayType_; - hash = (37 * hash) + GATEWAY_AUTH_METHOD_FIELD_NUMBER; - hash = (53 * hash) + gatewayAuthMethod_; - hash = (37 * hash) + LAST_ACCESSED_GATEWAY_ID_FIELD_NUMBER; - hash = (53 * hash) + getLastAccessedGatewayId().hashCode(); - if (hasLastAccessedGatewayTime()) { - hash = (37 * hash) + LAST_ACCESSED_GATEWAY_TIME_FIELD_NUMBER; - hash = (53 * hash) + getLastAccessedGatewayTime().hashCode(); - } - hash = (29 * hash) + getUnknownFields().hashCode(); - memoizedHashCode = hash; - return hash; - } - - public static com.google.cloud.iot.v1.GatewayConfig parseFrom(java.nio.ByteBuffer data) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); - } - - public static com.google.cloud.iot.v1.GatewayConfig parseFrom( - java.nio.ByteBuffer data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); - } - - public static com.google.cloud.iot.v1.GatewayConfig parseFrom(com.google.protobuf.ByteString data) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); - } - - public static com.google.cloud.iot.v1.GatewayConfig parseFrom( - com.google.protobuf.ByteString data, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); - } - - public static com.google.cloud.iot.v1.GatewayConfig parseFrom(byte[] data) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); - } - - public static com.google.cloud.iot.v1.GatewayConfig parseFrom( - byte[] data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); - } - - public static com.google.cloud.iot.v1.GatewayConfig parseFrom(java.io.InputStream input) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input); - } - - public static com.google.cloud.iot.v1.GatewayConfig parseFrom( - java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3.parseWithIOException( - PARSER, input, extensionRegistry); - } - - public static com.google.cloud.iot.v1.GatewayConfig parseDelimitedFrom(java.io.InputStream input) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3.parseDelimitedWithIOException(PARSER, input); - } - - public static com.google.cloud.iot.v1.GatewayConfig parseDelimitedFrom( - java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3.parseDelimitedWithIOException( - PARSER, input, extensionRegistry); - } - - public static com.google.cloud.iot.v1.GatewayConfig parseFrom( - com.google.protobuf.CodedInputStream input) throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input); - } - - public static com.google.cloud.iot.v1.GatewayConfig parseFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3.parseWithIOException( - PARSER, input, extensionRegistry); - } - - @java.lang.Override - public Builder newBuilderForType() { - return newBuilder(); - } - - public static Builder newBuilder() { - return DEFAULT_INSTANCE.toBuilder(); - } - - public static Builder newBuilder(com.google.cloud.iot.v1.GatewayConfig prototype) { - return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); - } - - @java.lang.Override - public Builder toBuilder() { - return this == DEFAULT_INSTANCE ? new Builder() : new Builder().mergeFrom(this); - } - - @java.lang.Override - protected Builder newBuilderForType(com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { - Builder builder = new Builder(parent); - return builder; - } - /** - * - * - *
-   * Gateway-related configuration and state.
-   * 
- * - * Protobuf type {@code google.cloud.iot.v1.GatewayConfig} - */ - public static final class Builder extends com.google.protobuf.GeneratedMessageV3.Builder - implements - // @@protoc_insertion_point(builder_implements:google.cloud.iot.v1.GatewayConfig) - com.google.cloud.iot.v1.GatewayConfigOrBuilder { - public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { - return com.google.cloud.iot.v1.ResourcesProto - .internal_static_google_cloud_iot_v1_GatewayConfig_descriptor; - } - - @java.lang.Override - protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable - internalGetFieldAccessorTable() { - return com.google.cloud.iot.v1.ResourcesProto - .internal_static_google_cloud_iot_v1_GatewayConfig_fieldAccessorTable - .ensureFieldAccessorsInitialized( - com.google.cloud.iot.v1.GatewayConfig.class, - com.google.cloud.iot.v1.GatewayConfig.Builder.class); - } - - // Construct using com.google.cloud.iot.v1.GatewayConfig.newBuilder() - private Builder() {} - - private Builder(com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { - super(parent); - } - - @java.lang.Override - public Builder clear() { - super.clear(); - gatewayType_ = 0; - - gatewayAuthMethod_ = 0; - - lastAccessedGatewayId_ = ""; - - if (lastAccessedGatewayTimeBuilder_ == null) { - lastAccessedGatewayTime_ = null; - } else { - lastAccessedGatewayTime_ = null; - lastAccessedGatewayTimeBuilder_ = null; - } - return this; - } - - @java.lang.Override - public com.google.protobuf.Descriptors.Descriptor getDescriptorForType() { - return com.google.cloud.iot.v1.ResourcesProto - .internal_static_google_cloud_iot_v1_GatewayConfig_descriptor; - } - - @java.lang.Override - public com.google.cloud.iot.v1.GatewayConfig getDefaultInstanceForType() { - return com.google.cloud.iot.v1.GatewayConfig.getDefaultInstance(); - } - - @java.lang.Override - public com.google.cloud.iot.v1.GatewayConfig build() { - com.google.cloud.iot.v1.GatewayConfig result = buildPartial(); - if (!result.isInitialized()) { - throw newUninitializedMessageException(result); - } - return result; - } - - @java.lang.Override - public com.google.cloud.iot.v1.GatewayConfig buildPartial() { - com.google.cloud.iot.v1.GatewayConfig result = - new com.google.cloud.iot.v1.GatewayConfig(this); - result.gatewayType_ = gatewayType_; - result.gatewayAuthMethod_ = gatewayAuthMethod_; - result.lastAccessedGatewayId_ = lastAccessedGatewayId_; - if (lastAccessedGatewayTimeBuilder_ == null) { - result.lastAccessedGatewayTime_ = lastAccessedGatewayTime_; - } else { - result.lastAccessedGatewayTime_ = lastAccessedGatewayTimeBuilder_.build(); - } - onBuilt(); - return result; - } - - @java.lang.Override - public Builder clone() { - return super.clone(); - } - - @java.lang.Override - public Builder setField( - com.google.protobuf.Descriptors.FieldDescriptor field, java.lang.Object value) { - return super.setField(field, value); - } - - @java.lang.Override - public Builder clearField(com.google.protobuf.Descriptors.FieldDescriptor field) { - return super.clearField(field); - } - - @java.lang.Override - public Builder clearOneof(com.google.protobuf.Descriptors.OneofDescriptor oneof) { - return super.clearOneof(oneof); - } - - @java.lang.Override - public Builder setRepeatedField( - com.google.protobuf.Descriptors.FieldDescriptor field, int index, java.lang.Object value) { - return super.setRepeatedField(field, index, value); - } - - @java.lang.Override - public Builder addRepeatedField( - com.google.protobuf.Descriptors.FieldDescriptor field, java.lang.Object value) { - return super.addRepeatedField(field, value); - } - - @java.lang.Override - public Builder mergeFrom(com.google.protobuf.Message other) { - if (other instanceof com.google.cloud.iot.v1.GatewayConfig) { - return mergeFrom((com.google.cloud.iot.v1.GatewayConfig) other); - } else { - super.mergeFrom(other); - return this; - } - } - - public Builder mergeFrom(com.google.cloud.iot.v1.GatewayConfig other) { - if (other == com.google.cloud.iot.v1.GatewayConfig.getDefaultInstance()) return this; - if (other.gatewayType_ != 0) { - setGatewayTypeValue(other.getGatewayTypeValue()); - } - if (other.gatewayAuthMethod_ != 0) { - setGatewayAuthMethodValue(other.getGatewayAuthMethodValue()); - } - if (!other.getLastAccessedGatewayId().isEmpty()) { - lastAccessedGatewayId_ = other.lastAccessedGatewayId_; - onChanged(); - } - if (other.hasLastAccessedGatewayTime()) { - mergeLastAccessedGatewayTime(other.getLastAccessedGatewayTime()); - } - this.mergeUnknownFields(other.getUnknownFields()); - onChanged(); - return this; - } - - @java.lang.Override - public final boolean isInitialized() { - return true; - } - - @java.lang.Override - public Builder mergeFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - if (extensionRegistry == null) { - throw new java.lang.NullPointerException(); - } - try { - boolean done = false; - while (!done) { - int tag = input.readTag(); - switch (tag) { - case 0: - done = true; - break; - case 8: - { - gatewayType_ = input.readEnum(); - - break; - } // case 8 - case 16: - { - gatewayAuthMethod_ = input.readEnum(); - - break; - } // case 16 - case 26: - { - lastAccessedGatewayId_ = input.readStringRequireUtf8(); - - break; - } // case 26 - case 34: - { - input.readMessage( - getLastAccessedGatewayTimeFieldBuilder().getBuilder(), extensionRegistry); - - break; - } // case 34 - default: - { - if (!super.parseUnknownField(input, extensionRegistry, tag)) { - done = true; // was an endgroup tag - } - break; - } // default: - } // switch (tag) - } // while (!done) - } catch (com.google.protobuf.InvalidProtocolBufferException e) { - throw e.unwrapIOException(); - } finally { - onChanged(); - } // finally - return this; - } - - private int gatewayType_ = 0; - /** - * - * - *
-     * Indicates whether the device is a gateway.
-     * 
- * - * .google.cloud.iot.v1.GatewayType gateway_type = 1; - * - * @return The enum numeric value on the wire for gatewayType. - */ - @java.lang.Override - public int getGatewayTypeValue() { - return gatewayType_; - } - /** - * - * - *
-     * Indicates whether the device is a gateway.
-     * 
- * - * .google.cloud.iot.v1.GatewayType gateway_type = 1; - * - * @param value The enum numeric value on the wire for gatewayType to set. - * @return This builder for chaining. - */ - public Builder setGatewayTypeValue(int value) { - - gatewayType_ = value; - onChanged(); - return this; - } - /** - * - * - *
-     * Indicates whether the device is a gateway.
-     * 
- * - * .google.cloud.iot.v1.GatewayType gateway_type = 1; - * - * @return The gatewayType. - */ - @java.lang.Override - public com.google.cloud.iot.v1.GatewayType getGatewayType() { - @SuppressWarnings("deprecation") - com.google.cloud.iot.v1.GatewayType result = - com.google.cloud.iot.v1.GatewayType.valueOf(gatewayType_); - return result == null ? com.google.cloud.iot.v1.GatewayType.UNRECOGNIZED : result; - } - /** - * - * - *
-     * Indicates whether the device is a gateway.
-     * 
- * - * .google.cloud.iot.v1.GatewayType gateway_type = 1; - * - * @param value The gatewayType to set. - * @return This builder for chaining. - */ - public Builder setGatewayType(com.google.cloud.iot.v1.GatewayType value) { - if (value == null) { - throw new NullPointerException(); - } - - gatewayType_ = value.getNumber(); - onChanged(); - return this; - } - /** - * - * - *
-     * Indicates whether the device is a gateway.
-     * 
- * - * .google.cloud.iot.v1.GatewayType gateway_type = 1; - * - * @return This builder for chaining. - */ - public Builder clearGatewayType() { - - gatewayType_ = 0; - onChanged(); - return this; - } - - private int gatewayAuthMethod_ = 0; - /** - * - * - *
-     * Indicates how to authorize and/or authenticate devices to access the
-     * gateway.
-     * 
- * - * .google.cloud.iot.v1.GatewayAuthMethod gateway_auth_method = 2; - * - * @return The enum numeric value on the wire for gatewayAuthMethod. - */ - @java.lang.Override - public int getGatewayAuthMethodValue() { - return gatewayAuthMethod_; - } - /** - * - * - *
-     * Indicates how to authorize and/or authenticate devices to access the
-     * gateway.
-     * 
- * - * .google.cloud.iot.v1.GatewayAuthMethod gateway_auth_method = 2; - * - * @param value The enum numeric value on the wire for gatewayAuthMethod to set. - * @return This builder for chaining. - */ - public Builder setGatewayAuthMethodValue(int value) { - - gatewayAuthMethod_ = value; - onChanged(); - return this; - } - /** - * - * - *
-     * Indicates how to authorize and/or authenticate devices to access the
-     * gateway.
-     * 
- * - * .google.cloud.iot.v1.GatewayAuthMethod gateway_auth_method = 2; - * - * @return The gatewayAuthMethod. - */ - @java.lang.Override - public com.google.cloud.iot.v1.GatewayAuthMethod getGatewayAuthMethod() { - @SuppressWarnings("deprecation") - com.google.cloud.iot.v1.GatewayAuthMethod result = - com.google.cloud.iot.v1.GatewayAuthMethod.valueOf(gatewayAuthMethod_); - return result == null ? com.google.cloud.iot.v1.GatewayAuthMethod.UNRECOGNIZED : result; - } - /** - * - * - *
-     * Indicates how to authorize and/or authenticate devices to access the
-     * gateway.
-     * 
- * - * .google.cloud.iot.v1.GatewayAuthMethod gateway_auth_method = 2; - * - * @param value The gatewayAuthMethod to set. - * @return This builder for chaining. - */ - public Builder setGatewayAuthMethod(com.google.cloud.iot.v1.GatewayAuthMethod value) { - if (value == null) { - throw new NullPointerException(); - } - - gatewayAuthMethod_ = value.getNumber(); - onChanged(); - return this; - } - /** - * - * - *
-     * Indicates how to authorize and/or authenticate devices to access the
-     * gateway.
-     * 
- * - * .google.cloud.iot.v1.GatewayAuthMethod gateway_auth_method = 2; - * - * @return This builder for chaining. - */ - public Builder clearGatewayAuthMethod() { - - gatewayAuthMethod_ = 0; - onChanged(); - return this; - } - - private java.lang.Object lastAccessedGatewayId_ = ""; - /** - * - * - *
-     * [Output only] The ID of the gateway the device accessed most recently.
-     * 
- * - * string last_accessed_gateway_id = 3; - * - * @return The lastAccessedGatewayId. - */ - public java.lang.String getLastAccessedGatewayId() { - java.lang.Object ref = lastAccessedGatewayId_; - if (!(ref instanceof java.lang.String)) { - com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; - java.lang.String s = bs.toStringUtf8(); - lastAccessedGatewayId_ = s; - return s; - } else { - return (java.lang.String) ref; - } - } - /** - * - * - *
-     * [Output only] The ID of the gateway the device accessed most recently.
-     * 
- * - * string last_accessed_gateway_id = 3; - * - * @return The bytes for lastAccessedGatewayId. - */ - public com.google.protobuf.ByteString getLastAccessedGatewayIdBytes() { - java.lang.Object ref = lastAccessedGatewayId_; - if (ref instanceof String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); - lastAccessedGatewayId_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - /** - * - * - *
-     * [Output only] The ID of the gateway the device accessed most recently.
-     * 
- * - * string last_accessed_gateway_id = 3; - * - * @param value The lastAccessedGatewayId to set. - * @return This builder for chaining. - */ - public Builder setLastAccessedGatewayId(java.lang.String value) { - if (value == null) { - throw new NullPointerException(); - } - - lastAccessedGatewayId_ = value; - onChanged(); - return this; - } - /** - * - * - *
-     * [Output only] The ID of the gateway the device accessed most recently.
-     * 
- * - * string last_accessed_gateway_id = 3; - * - * @return This builder for chaining. - */ - public Builder clearLastAccessedGatewayId() { - - lastAccessedGatewayId_ = getDefaultInstance().getLastAccessedGatewayId(); - onChanged(); - return this; - } - /** - * - * - *
-     * [Output only] The ID of the gateway the device accessed most recently.
-     * 
- * - * string last_accessed_gateway_id = 3; - * - * @param value The bytes for lastAccessedGatewayId to set. - * @return This builder for chaining. - */ - public Builder setLastAccessedGatewayIdBytes(com.google.protobuf.ByteString value) { - if (value == null) { - throw new NullPointerException(); - } - checkByteStringIsUtf8(value); - - lastAccessedGatewayId_ = value; - onChanged(); - return this; - } - - private com.google.protobuf.Timestamp lastAccessedGatewayTime_; - private com.google.protobuf.SingleFieldBuilderV3< - com.google.protobuf.Timestamp, - com.google.protobuf.Timestamp.Builder, - com.google.protobuf.TimestampOrBuilder> - lastAccessedGatewayTimeBuilder_; - /** - * - * - *
-     * [Output only] The most recent time at which the device accessed the gateway
-     * specified in `last_accessed_gateway`.
-     * 
- * - * .google.protobuf.Timestamp last_accessed_gateway_time = 4; - * - * @return Whether the lastAccessedGatewayTime field is set. - */ - public boolean hasLastAccessedGatewayTime() { - return lastAccessedGatewayTimeBuilder_ != null || lastAccessedGatewayTime_ != null; - } - /** - * - * - *
-     * [Output only] The most recent time at which the device accessed the gateway
-     * specified in `last_accessed_gateway`.
-     * 
- * - * .google.protobuf.Timestamp last_accessed_gateway_time = 4; - * - * @return The lastAccessedGatewayTime. - */ - public com.google.protobuf.Timestamp getLastAccessedGatewayTime() { - if (lastAccessedGatewayTimeBuilder_ == null) { - return lastAccessedGatewayTime_ == null - ? com.google.protobuf.Timestamp.getDefaultInstance() - : lastAccessedGatewayTime_; - } else { - return lastAccessedGatewayTimeBuilder_.getMessage(); - } - } - /** - * - * - *
-     * [Output only] The most recent time at which the device accessed the gateway
-     * specified in `last_accessed_gateway`.
-     * 
- * - * .google.protobuf.Timestamp last_accessed_gateway_time = 4; - */ - public Builder setLastAccessedGatewayTime(com.google.protobuf.Timestamp value) { - if (lastAccessedGatewayTimeBuilder_ == null) { - if (value == null) { - throw new NullPointerException(); - } - lastAccessedGatewayTime_ = value; - onChanged(); - } else { - lastAccessedGatewayTimeBuilder_.setMessage(value); - } - - return this; - } - /** - * - * - *
-     * [Output only] The most recent time at which the device accessed the gateway
-     * specified in `last_accessed_gateway`.
-     * 
- * - * .google.protobuf.Timestamp last_accessed_gateway_time = 4; - */ - public Builder setLastAccessedGatewayTime( - com.google.protobuf.Timestamp.Builder builderForValue) { - if (lastAccessedGatewayTimeBuilder_ == null) { - lastAccessedGatewayTime_ = builderForValue.build(); - onChanged(); - } else { - lastAccessedGatewayTimeBuilder_.setMessage(builderForValue.build()); - } - - return this; - } - /** - * - * - *
-     * [Output only] The most recent time at which the device accessed the gateway
-     * specified in `last_accessed_gateway`.
-     * 
- * - * .google.protobuf.Timestamp last_accessed_gateway_time = 4; - */ - public Builder mergeLastAccessedGatewayTime(com.google.protobuf.Timestamp value) { - if (lastAccessedGatewayTimeBuilder_ == null) { - if (lastAccessedGatewayTime_ != null) { - lastAccessedGatewayTime_ = - com.google.protobuf.Timestamp.newBuilder(lastAccessedGatewayTime_) - .mergeFrom(value) - .buildPartial(); - } else { - lastAccessedGatewayTime_ = value; - } - onChanged(); - } else { - lastAccessedGatewayTimeBuilder_.mergeFrom(value); - } - - return this; - } - /** - * - * - *
-     * [Output only] The most recent time at which the device accessed the gateway
-     * specified in `last_accessed_gateway`.
-     * 
- * - * .google.protobuf.Timestamp last_accessed_gateway_time = 4; - */ - public Builder clearLastAccessedGatewayTime() { - if (lastAccessedGatewayTimeBuilder_ == null) { - lastAccessedGatewayTime_ = null; - onChanged(); - } else { - lastAccessedGatewayTime_ = null; - lastAccessedGatewayTimeBuilder_ = null; - } - - return this; - } - /** - * - * - *
-     * [Output only] The most recent time at which the device accessed the gateway
-     * specified in `last_accessed_gateway`.
-     * 
- * - * .google.protobuf.Timestamp last_accessed_gateway_time = 4; - */ - public com.google.protobuf.Timestamp.Builder getLastAccessedGatewayTimeBuilder() { - - onChanged(); - return getLastAccessedGatewayTimeFieldBuilder().getBuilder(); - } - /** - * - * - *
-     * [Output only] The most recent time at which the device accessed the gateway
-     * specified in `last_accessed_gateway`.
-     * 
- * - * .google.protobuf.Timestamp last_accessed_gateway_time = 4; - */ - public com.google.protobuf.TimestampOrBuilder getLastAccessedGatewayTimeOrBuilder() { - if (lastAccessedGatewayTimeBuilder_ != null) { - return lastAccessedGatewayTimeBuilder_.getMessageOrBuilder(); - } else { - return lastAccessedGatewayTime_ == null - ? com.google.protobuf.Timestamp.getDefaultInstance() - : lastAccessedGatewayTime_; - } - } - /** - * - * - *
-     * [Output only] The most recent time at which the device accessed the gateway
-     * specified in `last_accessed_gateway`.
-     * 
- * - * .google.protobuf.Timestamp last_accessed_gateway_time = 4; - */ - private com.google.protobuf.SingleFieldBuilderV3< - com.google.protobuf.Timestamp, - com.google.protobuf.Timestamp.Builder, - com.google.protobuf.TimestampOrBuilder> - getLastAccessedGatewayTimeFieldBuilder() { - if (lastAccessedGatewayTimeBuilder_ == null) { - lastAccessedGatewayTimeBuilder_ = - new com.google.protobuf.SingleFieldBuilderV3< - com.google.protobuf.Timestamp, - com.google.protobuf.Timestamp.Builder, - com.google.protobuf.TimestampOrBuilder>( - getLastAccessedGatewayTime(), getParentForChildren(), isClean()); - lastAccessedGatewayTime_ = null; - } - return lastAccessedGatewayTimeBuilder_; - } - - @java.lang.Override - public final Builder setUnknownFields(final com.google.protobuf.UnknownFieldSet unknownFields) { - return super.setUnknownFields(unknownFields); - } - - @java.lang.Override - public final Builder mergeUnknownFields( - final com.google.protobuf.UnknownFieldSet unknownFields) { - return super.mergeUnknownFields(unknownFields); - } - - // @@protoc_insertion_point(builder_scope:google.cloud.iot.v1.GatewayConfig) - } - - // @@protoc_insertion_point(class_scope:google.cloud.iot.v1.GatewayConfig) - private static final com.google.cloud.iot.v1.GatewayConfig DEFAULT_INSTANCE; - - static { - DEFAULT_INSTANCE = new com.google.cloud.iot.v1.GatewayConfig(); - } - - public static com.google.cloud.iot.v1.GatewayConfig getDefaultInstance() { - return DEFAULT_INSTANCE; - } - - private static final com.google.protobuf.Parser PARSER = - new com.google.protobuf.AbstractParser() { - @java.lang.Override - public GatewayConfig parsePartialFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - Builder builder = newBuilder(); - try { - builder.mergeFrom(input, extensionRegistry); - } catch (com.google.protobuf.InvalidProtocolBufferException e) { - throw e.setUnfinishedMessage(builder.buildPartial()); - } catch (com.google.protobuf.UninitializedMessageException e) { - throw e.asInvalidProtocolBufferException().setUnfinishedMessage(builder.buildPartial()); - } catch (java.io.IOException e) { - throw new com.google.protobuf.InvalidProtocolBufferException(e) - .setUnfinishedMessage(builder.buildPartial()); - } - return builder.buildPartial(); - } - }; - - public static com.google.protobuf.Parser parser() { - return PARSER; - } - - @java.lang.Override - public com.google.protobuf.Parser getParserForType() { - return PARSER; - } - - @java.lang.Override - public com.google.cloud.iot.v1.GatewayConfig getDefaultInstanceForType() { - return DEFAULT_INSTANCE; - } -} diff --git a/proto-google-cloud-iot-v1/src/main/java/com/google/cloud/iot/v1/GatewayConfigOrBuilder.java b/proto-google-cloud-iot-v1/src/main/java/com/google/cloud/iot/v1/GatewayConfigOrBuilder.java deleted file mode 100644 index 1268e4a0..00000000 --- a/proto-google-cloud-iot-v1/src/main/java/com/google/cloud/iot/v1/GatewayConfigOrBuilder.java +++ /dev/null @@ -1,140 +0,0 @@ -/* - * Copyright 2020 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. - */ -// Generated by the protocol buffer compiler. DO NOT EDIT! -// source: google/cloud/iot/v1/resources.proto - -package com.google.cloud.iot.v1; - -public interface GatewayConfigOrBuilder - extends - // @@protoc_insertion_point(interface_extends:google.cloud.iot.v1.GatewayConfig) - com.google.protobuf.MessageOrBuilder { - - /** - * - * - *
-   * Indicates whether the device is a gateway.
-   * 
- * - * .google.cloud.iot.v1.GatewayType gateway_type = 1; - * - * @return The enum numeric value on the wire for gatewayType. - */ - int getGatewayTypeValue(); - /** - * - * - *
-   * Indicates whether the device is a gateway.
-   * 
- * - * .google.cloud.iot.v1.GatewayType gateway_type = 1; - * - * @return The gatewayType. - */ - com.google.cloud.iot.v1.GatewayType getGatewayType(); - - /** - * - * - *
-   * Indicates how to authorize and/or authenticate devices to access the
-   * gateway.
-   * 
- * - * .google.cloud.iot.v1.GatewayAuthMethod gateway_auth_method = 2; - * - * @return The enum numeric value on the wire for gatewayAuthMethod. - */ - int getGatewayAuthMethodValue(); - /** - * - * - *
-   * Indicates how to authorize and/or authenticate devices to access the
-   * gateway.
-   * 
- * - * .google.cloud.iot.v1.GatewayAuthMethod gateway_auth_method = 2; - * - * @return The gatewayAuthMethod. - */ - com.google.cloud.iot.v1.GatewayAuthMethod getGatewayAuthMethod(); - - /** - * - * - *
-   * [Output only] The ID of the gateway the device accessed most recently.
-   * 
- * - * string last_accessed_gateway_id = 3; - * - * @return The lastAccessedGatewayId. - */ - java.lang.String getLastAccessedGatewayId(); - /** - * - * - *
-   * [Output only] The ID of the gateway the device accessed most recently.
-   * 
- * - * string last_accessed_gateway_id = 3; - * - * @return The bytes for lastAccessedGatewayId. - */ - com.google.protobuf.ByteString getLastAccessedGatewayIdBytes(); - - /** - * - * - *
-   * [Output only] The most recent time at which the device accessed the gateway
-   * specified in `last_accessed_gateway`.
-   * 
- * - * .google.protobuf.Timestamp last_accessed_gateway_time = 4; - * - * @return Whether the lastAccessedGatewayTime field is set. - */ - boolean hasLastAccessedGatewayTime(); - /** - * - * - *
-   * [Output only] The most recent time at which the device accessed the gateway
-   * specified in `last_accessed_gateway`.
-   * 
- * - * .google.protobuf.Timestamp last_accessed_gateway_time = 4; - * - * @return The lastAccessedGatewayTime. - */ - com.google.protobuf.Timestamp getLastAccessedGatewayTime(); - /** - * - * - *
-   * [Output only] The most recent time at which the device accessed the gateway
-   * specified in `last_accessed_gateway`.
-   * 
- * - * .google.protobuf.Timestamp last_accessed_gateway_time = 4; - */ - com.google.protobuf.TimestampOrBuilder getLastAccessedGatewayTimeOrBuilder(); -} diff --git a/proto-google-cloud-iot-v1/src/main/java/com/google/cloud/iot/v1/GatewayListOptions.java b/proto-google-cloud-iot-v1/src/main/java/com/google/cloud/iot/v1/GatewayListOptions.java deleted file mode 100644 index 6a97e87d..00000000 --- a/proto-google-cloud-iot-v1/src/main/java/com/google/cloud/iot/v1/GatewayListOptions.java +++ /dev/null @@ -1,1252 +0,0 @@ -/* - * Copyright 2020 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. - */ -// Generated by the protocol buffer compiler. DO NOT EDIT! -// source: google/cloud/iot/v1/device_manager.proto - -package com.google.cloud.iot.v1; - -/** - * - * - *
- * Options for limiting the list based on gateway type and associations.
- * 
- * - * Protobuf type {@code google.cloud.iot.v1.GatewayListOptions} - */ -public final class GatewayListOptions extends com.google.protobuf.GeneratedMessageV3 - implements - // @@protoc_insertion_point(message_implements:google.cloud.iot.v1.GatewayListOptions) - GatewayListOptionsOrBuilder { - private static final long serialVersionUID = 0L; - // Use GatewayListOptions.newBuilder() to construct. - private GatewayListOptions(com.google.protobuf.GeneratedMessageV3.Builder builder) { - super(builder); - } - - private GatewayListOptions() {} - - @java.lang.Override - @SuppressWarnings({"unused"}) - protected java.lang.Object newInstance(UnusedPrivateParameter unused) { - return new GatewayListOptions(); - } - - @java.lang.Override - public final com.google.protobuf.UnknownFieldSet getUnknownFields() { - return this.unknownFields; - } - - public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { - return com.google.cloud.iot.v1.DeviceManagerProto - .internal_static_google_cloud_iot_v1_GatewayListOptions_descriptor; - } - - @java.lang.Override - protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable - internalGetFieldAccessorTable() { - return com.google.cloud.iot.v1.DeviceManagerProto - .internal_static_google_cloud_iot_v1_GatewayListOptions_fieldAccessorTable - .ensureFieldAccessorsInitialized( - com.google.cloud.iot.v1.GatewayListOptions.class, - com.google.cloud.iot.v1.GatewayListOptions.Builder.class); - } - - private int filterCase_ = 0; - private java.lang.Object filter_; - - public enum FilterCase - implements - com.google.protobuf.Internal.EnumLite, - com.google.protobuf.AbstractMessage.InternalOneOfEnum { - GATEWAY_TYPE(1), - ASSOCIATIONS_GATEWAY_ID(2), - ASSOCIATIONS_DEVICE_ID(3), - FILTER_NOT_SET(0); - private final int value; - - private FilterCase(int value) { - this.value = value; - } - /** - * @param value The number of the enum to look for. - * @return The enum associated with the given number. - * @deprecated Use {@link #forNumber(int)} instead. - */ - @java.lang.Deprecated - public static FilterCase valueOf(int value) { - return forNumber(value); - } - - public static FilterCase forNumber(int value) { - switch (value) { - case 1: - return GATEWAY_TYPE; - case 2: - return ASSOCIATIONS_GATEWAY_ID; - case 3: - return ASSOCIATIONS_DEVICE_ID; - case 0: - return FILTER_NOT_SET; - default: - return null; - } - } - - public int getNumber() { - return this.value; - } - }; - - public FilterCase getFilterCase() { - return FilterCase.forNumber(filterCase_); - } - - public static final int GATEWAY_TYPE_FIELD_NUMBER = 1; - /** - * - * - *
-   * If `GATEWAY` is specified, only gateways are returned. If `NON_GATEWAY`
-   * is specified, only non-gateway devices are returned. If
-   * `GATEWAY_TYPE_UNSPECIFIED` is specified, all devices are returned.
-   * 
- * - * .google.cloud.iot.v1.GatewayType gateway_type = 1; - * - * @return Whether the gatewayType field is set. - */ - public boolean hasGatewayType() { - return filterCase_ == 1; - } - /** - * - * - *
-   * If `GATEWAY` is specified, only gateways are returned. If `NON_GATEWAY`
-   * is specified, only non-gateway devices are returned. If
-   * `GATEWAY_TYPE_UNSPECIFIED` is specified, all devices are returned.
-   * 
- * - * .google.cloud.iot.v1.GatewayType gateway_type = 1; - * - * @return The enum numeric value on the wire for gatewayType. - */ - public int getGatewayTypeValue() { - if (filterCase_ == 1) { - return (java.lang.Integer) filter_; - } - return 0; - } - /** - * - * - *
-   * If `GATEWAY` is specified, only gateways are returned. If `NON_GATEWAY`
-   * is specified, only non-gateway devices are returned. If
-   * `GATEWAY_TYPE_UNSPECIFIED` is specified, all devices are returned.
-   * 
- * - * .google.cloud.iot.v1.GatewayType gateway_type = 1; - * - * @return The gatewayType. - */ - public com.google.cloud.iot.v1.GatewayType getGatewayType() { - if (filterCase_ == 1) { - @SuppressWarnings("deprecation") - com.google.cloud.iot.v1.GatewayType result = - com.google.cloud.iot.v1.GatewayType.valueOf((java.lang.Integer) filter_); - return result == null ? com.google.cloud.iot.v1.GatewayType.UNRECOGNIZED : result; - } - return com.google.cloud.iot.v1.GatewayType.GATEWAY_TYPE_UNSPECIFIED; - } - - public static final int ASSOCIATIONS_GATEWAY_ID_FIELD_NUMBER = 2; - /** - * - * - *
-   * If set, only devices associated with the specified gateway are returned.
-   * The gateway ID can be numeric (`num_id`) or the user-defined string
-   * (`id`). For example, if `123` is specified, only devices bound to the
-   * gateway with `num_id` 123 are returned.
-   * 
- * - * string associations_gateway_id = 2; - * - * @return Whether the associationsGatewayId field is set. - */ - public boolean hasAssociationsGatewayId() { - return filterCase_ == 2; - } - /** - * - * - *
-   * If set, only devices associated with the specified gateway are returned.
-   * The gateway ID can be numeric (`num_id`) or the user-defined string
-   * (`id`). For example, if `123` is specified, only devices bound to the
-   * gateway with `num_id` 123 are returned.
-   * 
- * - * string associations_gateway_id = 2; - * - * @return The associationsGatewayId. - */ - public java.lang.String getAssociationsGatewayId() { - java.lang.Object ref = ""; - if (filterCase_ == 2) { - ref = filter_; - } - if (ref instanceof java.lang.String) { - return (java.lang.String) ref; - } else { - com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; - java.lang.String s = bs.toStringUtf8(); - if (filterCase_ == 2) { - filter_ = s; - } - return s; - } - } - /** - * - * - *
-   * If set, only devices associated with the specified gateway are returned.
-   * The gateway ID can be numeric (`num_id`) or the user-defined string
-   * (`id`). For example, if `123` is specified, only devices bound to the
-   * gateway with `num_id` 123 are returned.
-   * 
- * - * string associations_gateway_id = 2; - * - * @return The bytes for associationsGatewayId. - */ - public com.google.protobuf.ByteString getAssociationsGatewayIdBytes() { - java.lang.Object ref = ""; - if (filterCase_ == 2) { - ref = filter_; - } - if (ref instanceof java.lang.String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); - if (filterCase_ == 2) { - filter_ = b; - } - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - - public static final int ASSOCIATIONS_DEVICE_ID_FIELD_NUMBER = 3; - /** - * - * - *
-   * If set, returns only the gateways with which the specified device is
-   * associated. The device ID can be numeric (`num_id`) or the user-defined
-   * string (`id`). For example, if `456` is specified, returns only the
-   * gateways to which the device with `num_id` 456 is bound.
-   * 
- * - * string associations_device_id = 3; - * - * @return Whether the associationsDeviceId field is set. - */ - public boolean hasAssociationsDeviceId() { - return filterCase_ == 3; - } - /** - * - * - *
-   * If set, returns only the gateways with which the specified device is
-   * associated. The device ID can be numeric (`num_id`) or the user-defined
-   * string (`id`). For example, if `456` is specified, returns only the
-   * gateways to which the device with `num_id` 456 is bound.
-   * 
- * - * string associations_device_id = 3; - * - * @return The associationsDeviceId. - */ - public java.lang.String getAssociationsDeviceId() { - java.lang.Object ref = ""; - if (filterCase_ == 3) { - ref = filter_; - } - if (ref instanceof java.lang.String) { - return (java.lang.String) ref; - } else { - com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; - java.lang.String s = bs.toStringUtf8(); - if (filterCase_ == 3) { - filter_ = s; - } - return s; - } - } - /** - * - * - *
-   * If set, returns only the gateways with which the specified device is
-   * associated. The device ID can be numeric (`num_id`) or the user-defined
-   * string (`id`). For example, if `456` is specified, returns only the
-   * gateways to which the device with `num_id` 456 is bound.
-   * 
- * - * string associations_device_id = 3; - * - * @return The bytes for associationsDeviceId. - */ - public com.google.protobuf.ByteString getAssociationsDeviceIdBytes() { - java.lang.Object ref = ""; - if (filterCase_ == 3) { - ref = filter_; - } - if (ref instanceof java.lang.String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); - if (filterCase_ == 3) { - filter_ = b; - } - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - - private byte memoizedIsInitialized = -1; - - @java.lang.Override - public final boolean isInitialized() { - byte isInitialized = memoizedIsInitialized; - if (isInitialized == 1) return true; - if (isInitialized == 0) return false; - - memoizedIsInitialized = 1; - return true; - } - - @java.lang.Override - public void writeTo(com.google.protobuf.CodedOutputStream output) throws java.io.IOException { - if (filterCase_ == 1) { - output.writeEnum(1, ((java.lang.Integer) filter_)); - } - if (filterCase_ == 2) { - com.google.protobuf.GeneratedMessageV3.writeString(output, 2, filter_); - } - if (filterCase_ == 3) { - com.google.protobuf.GeneratedMessageV3.writeString(output, 3, filter_); - } - getUnknownFields().writeTo(output); - } - - @java.lang.Override - public int getSerializedSize() { - int size = memoizedSize; - if (size != -1) return size; - - size = 0; - if (filterCase_ == 1) { - size += - com.google.protobuf.CodedOutputStream.computeEnumSize(1, ((java.lang.Integer) filter_)); - } - if (filterCase_ == 2) { - size += com.google.protobuf.GeneratedMessageV3.computeStringSize(2, filter_); - } - if (filterCase_ == 3) { - size += com.google.protobuf.GeneratedMessageV3.computeStringSize(3, filter_); - } - size += getUnknownFields().getSerializedSize(); - memoizedSize = size; - return size; - } - - @java.lang.Override - public boolean equals(final java.lang.Object obj) { - if (obj == this) { - return true; - } - if (!(obj instanceof com.google.cloud.iot.v1.GatewayListOptions)) { - return super.equals(obj); - } - com.google.cloud.iot.v1.GatewayListOptions other = - (com.google.cloud.iot.v1.GatewayListOptions) obj; - - if (!getFilterCase().equals(other.getFilterCase())) return false; - switch (filterCase_) { - case 1: - if (getGatewayTypeValue() != other.getGatewayTypeValue()) return false; - break; - case 2: - if (!getAssociationsGatewayId().equals(other.getAssociationsGatewayId())) return false; - break; - case 3: - if (!getAssociationsDeviceId().equals(other.getAssociationsDeviceId())) return false; - break; - case 0: - default: - } - if (!getUnknownFields().equals(other.getUnknownFields())) return false; - return true; - } - - @java.lang.Override - public int hashCode() { - if (memoizedHashCode != 0) { - return memoizedHashCode; - } - int hash = 41; - hash = (19 * hash) + getDescriptor().hashCode(); - switch (filterCase_) { - case 1: - hash = (37 * hash) + GATEWAY_TYPE_FIELD_NUMBER; - hash = (53 * hash) + getGatewayTypeValue(); - break; - case 2: - hash = (37 * hash) + ASSOCIATIONS_GATEWAY_ID_FIELD_NUMBER; - hash = (53 * hash) + getAssociationsGatewayId().hashCode(); - break; - case 3: - hash = (37 * hash) + ASSOCIATIONS_DEVICE_ID_FIELD_NUMBER; - hash = (53 * hash) + getAssociationsDeviceId().hashCode(); - break; - case 0: - default: - } - hash = (29 * hash) + getUnknownFields().hashCode(); - memoizedHashCode = hash; - return hash; - } - - public static com.google.cloud.iot.v1.GatewayListOptions parseFrom(java.nio.ByteBuffer data) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); - } - - public static com.google.cloud.iot.v1.GatewayListOptions parseFrom( - java.nio.ByteBuffer data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); - } - - public static com.google.cloud.iot.v1.GatewayListOptions parseFrom( - com.google.protobuf.ByteString data) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); - } - - public static com.google.cloud.iot.v1.GatewayListOptions parseFrom( - com.google.protobuf.ByteString data, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); - } - - public static com.google.cloud.iot.v1.GatewayListOptions parseFrom(byte[] data) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); - } - - public static com.google.cloud.iot.v1.GatewayListOptions parseFrom( - byte[] data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); - } - - public static com.google.cloud.iot.v1.GatewayListOptions parseFrom(java.io.InputStream input) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input); - } - - public static com.google.cloud.iot.v1.GatewayListOptions parseFrom( - java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3.parseWithIOException( - PARSER, input, extensionRegistry); - } - - public static com.google.cloud.iot.v1.GatewayListOptions parseDelimitedFrom( - java.io.InputStream input) throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3.parseDelimitedWithIOException(PARSER, input); - } - - public static com.google.cloud.iot.v1.GatewayListOptions parseDelimitedFrom( - java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3.parseDelimitedWithIOException( - PARSER, input, extensionRegistry); - } - - public static com.google.cloud.iot.v1.GatewayListOptions parseFrom( - com.google.protobuf.CodedInputStream input) throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input); - } - - public static com.google.cloud.iot.v1.GatewayListOptions parseFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3.parseWithIOException( - PARSER, input, extensionRegistry); - } - - @java.lang.Override - public Builder newBuilderForType() { - return newBuilder(); - } - - public static Builder newBuilder() { - return DEFAULT_INSTANCE.toBuilder(); - } - - public static Builder newBuilder(com.google.cloud.iot.v1.GatewayListOptions prototype) { - return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); - } - - @java.lang.Override - public Builder toBuilder() { - return this == DEFAULT_INSTANCE ? new Builder() : new Builder().mergeFrom(this); - } - - @java.lang.Override - protected Builder newBuilderForType(com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { - Builder builder = new Builder(parent); - return builder; - } - /** - * - * - *
-   * Options for limiting the list based on gateway type and associations.
-   * 
- * - * Protobuf type {@code google.cloud.iot.v1.GatewayListOptions} - */ - public static final class Builder extends com.google.protobuf.GeneratedMessageV3.Builder - implements - // @@protoc_insertion_point(builder_implements:google.cloud.iot.v1.GatewayListOptions) - com.google.cloud.iot.v1.GatewayListOptionsOrBuilder { - public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { - return com.google.cloud.iot.v1.DeviceManagerProto - .internal_static_google_cloud_iot_v1_GatewayListOptions_descriptor; - } - - @java.lang.Override - protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable - internalGetFieldAccessorTable() { - return com.google.cloud.iot.v1.DeviceManagerProto - .internal_static_google_cloud_iot_v1_GatewayListOptions_fieldAccessorTable - .ensureFieldAccessorsInitialized( - com.google.cloud.iot.v1.GatewayListOptions.class, - com.google.cloud.iot.v1.GatewayListOptions.Builder.class); - } - - // Construct using com.google.cloud.iot.v1.GatewayListOptions.newBuilder() - private Builder() {} - - private Builder(com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { - super(parent); - } - - @java.lang.Override - public Builder clear() { - super.clear(); - filterCase_ = 0; - filter_ = null; - return this; - } - - @java.lang.Override - public com.google.protobuf.Descriptors.Descriptor getDescriptorForType() { - return com.google.cloud.iot.v1.DeviceManagerProto - .internal_static_google_cloud_iot_v1_GatewayListOptions_descriptor; - } - - @java.lang.Override - public com.google.cloud.iot.v1.GatewayListOptions getDefaultInstanceForType() { - return com.google.cloud.iot.v1.GatewayListOptions.getDefaultInstance(); - } - - @java.lang.Override - public com.google.cloud.iot.v1.GatewayListOptions build() { - com.google.cloud.iot.v1.GatewayListOptions result = buildPartial(); - if (!result.isInitialized()) { - throw newUninitializedMessageException(result); - } - return result; - } - - @java.lang.Override - public com.google.cloud.iot.v1.GatewayListOptions buildPartial() { - com.google.cloud.iot.v1.GatewayListOptions result = - new com.google.cloud.iot.v1.GatewayListOptions(this); - if (filterCase_ == 1) { - result.filter_ = filter_; - } - if (filterCase_ == 2) { - result.filter_ = filter_; - } - if (filterCase_ == 3) { - result.filter_ = filter_; - } - result.filterCase_ = filterCase_; - onBuilt(); - return result; - } - - @java.lang.Override - public Builder clone() { - return super.clone(); - } - - @java.lang.Override - public Builder setField( - com.google.protobuf.Descriptors.FieldDescriptor field, java.lang.Object value) { - return super.setField(field, value); - } - - @java.lang.Override - public Builder clearField(com.google.protobuf.Descriptors.FieldDescriptor field) { - return super.clearField(field); - } - - @java.lang.Override - public Builder clearOneof(com.google.protobuf.Descriptors.OneofDescriptor oneof) { - return super.clearOneof(oneof); - } - - @java.lang.Override - public Builder setRepeatedField( - com.google.protobuf.Descriptors.FieldDescriptor field, int index, java.lang.Object value) { - return super.setRepeatedField(field, index, value); - } - - @java.lang.Override - public Builder addRepeatedField( - com.google.protobuf.Descriptors.FieldDescriptor field, java.lang.Object value) { - return super.addRepeatedField(field, value); - } - - @java.lang.Override - public Builder mergeFrom(com.google.protobuf.Message other) { - if (other instanceof com.google.cloud.iot.v1.GatewayListOptions) { - return mergeFrom((com.google.cloud.iot.v1.GatewayListOptions) other); - } else { - super.mergeFrom(other); - return this; - } - } - - public Builder mergeFrom(com.google.cloud.iot.v1.GatewayListOptions other) { - if (other == com.google.cloud.iot.v1.GatewayListOptions.getDefaultInstance()) return this; - switch (other.getFilterCase()) { - case GATEWAY_TYPE: - { - setGatewayTypeValue(other.getGatewayTypeValue()); - break; - } - case ASSOCIATIONS_GATEWAY_ID: - { - filterCase_ = 2; - filter_ = other.filter_; - onChanged(); - break; - } - case ASSOCIATIONS_DEVICE_ID: - { - filterCase_ = 3; - filter_ = other.filter_; - onChanged(); - break; - } - case FILTER_NOT_SET: - { - break; - } - } - this.mergeUnknownFields(other.getUnknownFields()); - onChanged(); - return this; - } - - @java.lang.Override - public final boolean isInitialized() { - return true; - } - - @java.lang.Override - public Builder mergeFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - if (extensionRegistry == null) { - throw new java.lang.NullPointerException(); - } - try { - boolean done = false; - while (!done) { - int tag = input.readTag(); - switch (tag) { - case 0: - done = true; - break; - case 8: - { - int rawValue = input.readEnum(); - filterCase_ = 1; - filter_ = rawValue; - break; - } // case 8 - case 18: - { - java.lang.String s = input.readStringRequireUtf8(); - filterCase_ = 2; - filter_ = s; - break; - } // case 18 - case 26: - { - java.lang.String s = input.readStringRequireUtf8(); - filterCase_ = 3; - filter_ = s; - break; - } // case 26 - default: - { - if (!super.parseUnknownField(input, extensionRegistry, tag)) { - done = true; // was an endgroup tag - } - break; - } // default: - } // switch (tag) - } // while (!done) - } catch (com.google.protobuf.InvalidProtocolBufferException e) { - throw e.unwrapIOException(); - } finally { - onChanged(); - } // finally - return this; - } - - private int filterCase_ = 0; - private java.lang.Object filter_; - - public FilterCase getFilterCase() { - return FilterCase.forNumber(filterCase_); - } - - public Builder clearFilter() { - filterCase_ = 0; - filter_ = null; - onChanged(); - return this; - } - - /** - * - * - *
-     * If `GATEWAY` is specified, only gateways are returned. If `NON_GATEWAY`
-     * is specified, only non-gateway devices are returned. If
-     * `GATEWAY_TYPE_UNSPECIFIED` is specified, all devices are returned.
-     * 
- * - * .google.cloud.iot.v1.GatewayType gateway_type = 1; - * - * @return Whether the gatewayType field is set. - */ - @java.lang.Override - public boolean hasGatewayType() { - return filterCase_ == 1; - } - /** - * - * - *
-     * If `GATEWAY` is specified, only gateways are returned. If `NON_GATEWAY`
-     * is specified, only non-gateway devices are returned. If
-     * `GATEWAY_TYPE_UNSPECIFIED` is specified, all devices are returned.
-     * 
- * - * .google.cloud.iot.v1.GatewayType gateway_type = 1; - * - * @return The enum numeric value on the wire for gatewayType. - */ - @java.lang.Override - public int getGatewayTypeValue() { - if (filterCase_ == 1) { - return ((java.lang.Integer) filter_).intValue(); - } - return 0; - } - /** - * - * - *
-     * If `GATEWAY` is specified, only gateways are returned. If `NON_GATEWAY`
-     * is specified, only non-gateway devices are returned. If
-     * `GATEWAY_TYPE_UNSPECIFIED` is specified, all devices are returned.
-     * 
- * - * .google.cloud.iot.v1.GatewayType gateway_type = 1; - * - * @param value The enum numeric value on the wire for gatewayType to set. - * @return This builder for chaining. - */ - public Builder setGatewayTypeValue(int value) { - filterCase_ = 1; - filter_ = value; - onChanged(); - return this; - } - /** - * - * - *
-     * If `GATEWAY` is specified, only gateways are returned. If `NON_GATEWAY`
-     * is specified, only non-gateway devices are returned. If
-     * `GATEWAY_TYPE_UNSPECIFIED` is specified, all devices are returned.
-     * 
- * - * .google.cloud.iot.v1.GatewayType gateway_type = 1; - * - * @return The gatewayType. - */ - @java.lang.Override - public com.google.cloud.iot.v1.GatewayType getGatewayType() { - if (filterCase_ == 1) { - @SuppressWarnings("deprecation") - com.google.cloud.iot.v1.GatewayType result = - com.google.cloud.iot.v1.GatewayType.valueOf((java.lang.Integer) filter_); - return result == null ? com.google.cloud.iot.v1.GatewayType.UNRECOGNIZED : result; - } - return com.google.cloud.iot.v1.GatewayType.GATEWAY_TYPE_UNSPECIFIED; - } - /** - * - * - *
-     * If `GATEWAY` is specified, only gateways are returned. If `NON_GATEWAY`
-     * is specified, only non-gateway devices are returned. If
-     * `GATEWAY_TYPE_UNSPECIFIED` is specified, all devices are returned.
-     * 
- * - * .google.cloud.iot.v1.GatewayType gateway_type = 1; - * - * @param value The gatewayType to set. - * @return This builder for chaining. - */ - public Builder setGatewayType(com.google.cloud.iot.v1.GatewayType value) { - if (value == null) { - throw new NullPointerException(); - } - filterCase_ = 1; - filter_ = value.getNumber(); - onChanged(); - return this; - } - /** - * - * - *
-     * If `GATEWAY` is specified, only gateways are returned. If `NON_GATEWAY`
-     * is specified, only non-gateway devices are returned. If
-     * `GATEWAY_TYPE_UNSPECIFIED` is specified, all devices are returned.
-     * 
- * - * .google.cloud.iot.v1.GatewayType gateway_type = 1; - * - * @return This builder for chaining. - */ - public Builder clearGatewayType() { - if (filterCase_ == 1) { - filterCase_ = 0; - filter_ = null; - onChanged(); - } - return this; - } - - /** - * - * - *
-     * If set, only devices associated with the specified gateway are returned.
-     * The gateway ID can be numeric (`num_id`) or the user-defined string
-     * (`id`). For example, if `123` is specified, only devices bound to the
-     * gateway with `num_id` 123 are returned.
-     * 
- * - * string associations_gateway_id = 2; - * - * @return Whether the associationsGatewayId field is set. - */ - @java.lang.Override - public boolean hasAssociationsGatewayId() { - return filterCase_ == 2; - } - /** - * - * - *
-     * If set, only devices associated with the specified gateway are returned.
-     * The gateway ID can be numeric (`num_id`) or the user-defined string
-     * (`id`). For example, if `123` is specified, only devices bound to the
-     * gateway with `num_id` 123 are returned.
-     * 
- * - * string associations_gateway_id = 2; - * - * @return The associationsGatewayId. - */ - @java.lang.Override - public java.lang.String getAssociationsGatewayId() { - java.lang.Object ref = ""; - if (filterCase_ == 2) { - ref = filter_; - } - if (!(ref instanceof java.lang.String)) { - com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; - java.lang.String s = bs.toStringUtf8(); - if (filterCase_ == 2) { - filter_ = s; - } - return s; - } else { - return (java.lang.String) ref; - } - } - /** - * - * - *
-     * If set, only devices associated with the specified gateway are returned.
-     * The gateway ID can be numeric (`num_id`) or the user-defined string
-     * (`id`). For example, if `123` is specified, only devices bound to the
-     * gateway with `num_id` 123 are returned.
-     * 
- * - * string associations_gateway_id = 2; - * - * @return The bytes for associationsGatewayId. - */ - @java.lang.Override - public com.google.protobuf.ByteString getAssociationsGatewayIdBytes() { - java.lang.Object ref = ""; - if (filterCase_ == 2) { - ref = filter_; - } - if (ref instanceof String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); - if (filterCase_ == 2) { - filter_ = b; - } - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - /** - * - * - *
-     * If set, only devices associated with the specified gateway are returned.
-     * The gateway ID can be numeric (`num_id`) or the user-defined string
-     * (`id`). For example, if `123` is specified, only devices bound to the
-     * gateway with `num_id` 123 are returned.
-     * 
- * - * string associations_gateway_id = 2; - * - * @param value The associationsGatewayId to set. - * @return This builder for chaining. - */ - public Builder setAssociationsGatewayId(java.lang.String value) { - if (value == null) { - throw new NullPointerException(); - } - filterCase_ = 2; - filter_ = value; - onChanged(); - return this; - } - /** - * - * - *
-     * If set, only devices associated with the specified gateway are returned.
-     * The gateway ID can be numeric (`num_id`) or the user-defined string
-     * (`id`). For example, if `123` is specified, only devices bound to the
-     * gateway with `num_id` 123 are returned.
-     * 
- * - * string associations_gateway_id = 2; - * - * @return This builder for chaining. - */ - public Builder clearAssociationsGatewayId() { - if (filterCase_ == 2) { - filterCase_ = 0; - filter_ = null; - onChanged(); - } - return this; - } - /** - * - * - *
-     * If set, only devices associated with the specified gateway are returned.
-     * The gateway ID can be numeric (`num_id`) or the user-defined string
-     * (`id`). For example, if `123` is specified, only devices bound to the
-     * gateway with `num_id` 123 are returned.
-     * 
- * - * string associations_gateway_id = 2; - * - * @param value The bytes for associationsGatewayId to set. - * @return This builder for chaining. - */ - public Builder setAssociationsGatewayIdBytes(com.google.protobuf.ByteString value) { - if (value == null) { - throw new NullPointerException(); - } - checkByteStringIsUtf8(value); - filterCase_ = 2; - filter_ = value; - onChanged(); - return this; - } - - /** - * - * - *
-     * If set, returns only the gateways with which the specified device is
-     * associated. The device ID can be numeric (`num_id`) or the user-defined
-     * string (`id`). For example, if `456` is specified, returns only the
-     * gateways to which the device with `num_id` 456 is bound.
-     * 
- * - * string associations_device_id = 3; - * - * @return Whether the associationsDeviceId field is set. - */ - @java.lang.Override - public boolean hasAssociationsDeviceId() { - return filterCase_ == 3; - } - /** - * - * - *
-     * If set, returns only the gateways with which the specified device is
-     * associated. The device ID can be numeric (`num_id`) or the user-defined
-     * string (`id`). For example, if `456` is specified, returns only the
-     * gateways to which the device with `num_id` 456 is bound.
-     * 
- * - * string associations_device_id = 3; - * - * @return The associationsDeviceId. - */ - @java.lang.Override - public java.lang.String getAssociationsDeviceId() { - java.lang.Object ref = ""; - if (filterCase_ == 3) { - ref = filter_; - } - if (!(ref instanceof java.lang.String)) { - com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; - java.lang.String s = bs.toStringUtf8(); - if (filterCase_ == 3) { - filter_ = s; - } - return s; - } else { - return (java.lang.String) ref; - } - } - /** - * - * - *
-     * If set, returns only the gateways with which the specified device is
-     * associated. The device ID can be numeric (`num_id`) or the user-defined
-     * string (`id`). For example, if `456` is specified, returns only the
-     * gateways to which the device with `num_id` 456 is bound.
-     * 
- * - * string associations_device_id = 3; - * - * @return The bytes for associationsDeviceId. - */ - @java.lang.Override - public com.google.protobuf.ByteString getAssociationsDeviceIdBytes() { - java.lang.Object ref = ""; - if (filterCase_ == 3) { - ref = filter_; - } - if (ref instanceof String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); - if (filterCase_ == 3) { - filter_ = b; - } - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - /** - * - * - *
-     * If set, returns only the gateways with which the specified device is
-     * associated. The device ID can be numeric (`num_id`) or the user-defined
-     * string (`id`). For example, if `456` is specified, returns only the
-     * gateways to which the device with `num_id` 456 is bound.
-     * 
- * - * string associations_device_id = 3; - * - * @param value The associationsDeviceId to set. - * @return This builder for chaining. - */ - public Builder setAssociationsDeviceId(java.lang.String value) { - if (value == null) { - throw new NullPointerException(); - } - filterCase_ = 3; - filter_ = value; - onChanged(); - return this; - } - /** - * - * - *
-     * If set, returns only the gateways with which the specified device is
-     * associated. The device ID can be numeric (`num_id`) or the user-defined
-     * string (`id`). For example, if `456` is specified, returns only the
-     * gateways to which the device with `num_id` 456 is bound.
-     * 
- * - * string associations_device_id = 3; - * - * @return This builder for chaining. - */ - public Builder clearAssociationsDeviceId() { - if (filterCase_ == 3) { - filterCase_ = 0; - filter_ = null; - onChanged(); - } - return this; - } - /** - * - * - *
-     * If set, returns only the gateways with which the specified device is
-     * associated. The device ID can be numeric (`num_id`) or the user-defined
-     * string (`id`). For example, if `456` is specified, returns only the
-     * gateways to which the device with `num_id` 456 is bound.
-     * 
- * - * string associations_device_id = 3; - * - * @param value The bytes for associationsDeviceId to set. - * @return This builder for chaining. - */ - public Builder setAssociationsDeviceIdBytes(com.google.protobuf.ByteString value) { - if (value == null) { - throw new NullPointerException(); - } - checkByteStringIsUtf8(value); - filterCase_ = 3; - filter_ = value; - onChanged(); - return this; - } - - @java.lang.Override - public final Builder setUnknownFields(final com.google.protobuf.UnknownFieldSet unknownFields) { - return super.setUnknownFields(unknownFields); - } - - @java.lang.Override - public final Builder mergeUnknownFields( - final com.google.protobuf.UnknownFieldSet unknownFields) { - return super.mergeUnknownFields(unknownFields); - } - - // @@protoc_insertion_point(builder_scope:google.cloud.iot.v1.GatewayListOptions) - } - - // @@protoc_insertion_point(class_scope:google.cloud.iot.v1.GatewayListOptions) - private static final com.google.cloud.iot.v1.GatewayListOptions DEFAULT_INSTANCE; - - static { - DEFAULT_INSTANCE = new com.google.cloud.iot.v1.GatewayListOptions(); - } - - public static com.google.cloud.iot.v1.GatewayListOptions getDefaultInstance() { - return DEFAULT_INSTANCE; - } - - private static final com.google.protobuf.Parser PARSER = - new com.google.protobuf.AbstractParser() { - @java.lang.Override - public GatewayListOptions parsePartialFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - Builder builder = newBuilder(); - try { - builder.mergeFrom(input, extensionRegistry); - } catch (com.google.protobuf.InvalidProtocolBufferException e) { - throw e.setUnfinishedMessage(builder.buildPartial()); - } catch (com.google.protobuf.UninitializedMessageException e) { - throw e.asInvalidProtocolBufferException().setUnfinishedMessage(builder.buildPartial()); - } catch (java.io.IOException e) { - throw new com.google.protobuf.InvalidProtocolBufferException(e) - .setUnfinishedMessage(builder.buildPartial()); - } - return builder.buildPartial(); - } - }; - - public static com.google.protobuf.Parser parser() { - return PARSER; - } - - @java.lang.Override - public com.google.protobuf.Parser getParserForType() { - return PARSER; - } - - @java.lang.Override - public com.google.cloud.iot.v1.GatewayListOptions getDefaultInstanceForType() { - return DEFAULT_INSTANCE; - } -} diff --git a/proto-google-cloud-iot-v1/src/main/java/com/google/cloud/iot/v1/GatewayListOptionsOrBuilder.java b/proto-google-cloud-iot-v1/src/main/java/com/google/cloud/iot/v1/GatewayListOptionsOrBuilder.java deleted file mode 100644 index e0b4861e..00000000 --- a/proto-google-cloud-iot-v1/src/main/java/com/google/cloud/iot/v1/GatewayListOptionsOrBuilder.java +++ /dev/null @@ -1,162 +0,0 @@ -/* - * Copyright 2020 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. - */ -// Generated by the protocol buffer compiler. DO NOT EDIT! -// source: google/cloud/iot/v1/device_manager.proto - -package com.google.cloud.iot.v1; - -public interface GatewayListOptionsOrBuilder - extends - // @@protoc_insertion_point(interface_extends:google.cloud.iot.v1.GatewayListOptions) - com.google.protobuf.MessageOrBuilder { - - /** - * - * - *
-   * If `GATEWAY` is specified, only gateways are returned. If `NON_GATEWAY`
-   * is specified, only non-gateway devices are returned. If
-   * `GATEWAY_TYPE_UNSPECIFIED` is specified, all devices are returned.
-   * 
- * - * .google.cloud.iot.v1.GatewayType gateway_type = 1; - * - * @return Whether the gatewayType field is set. - */ - boolean hasGatewayType(); - /** - * - * - *
-   * If `GATEWAY` is specified, only gateways are returned. If `NON_GATEWAY`
-   * is specified, only non-gateway devices are returned. If
-   * `GATEWAY_TYPE_UNSPECIFIED` is specified, all devices are returned.
-   * 
- * - * .google.cloud.iot.v1.GatewayType gateway_type = 1; - * - * @return The enum numeric value on the wire for gatewayType. - */ - int getGatewayTypeValue(); - /** - * - * - *
-   * If `GATEWAY` is specified, only gateways are returned. If `NON_GATEWAY`
-   * is specified, only non-gateway devices are returned. If
-   * `GATEWAY_TYPE_UNSPECIFIED` is specified, all devices are returned.
-   * 
- * - * .google.cloud.iot.v1.GatewayType gateway_type = 1; - * - * @return The gatewayType. - */ - com.google.cloud.iot.v1.GatewayType getGatewayType(); - - /** - * - * - *
-   * If set, only devices associated with the specified gateway are returned.
-   * The gateway ID can be numeric (`num_id`) or the user-defined string
-   * (`id`). For example, if `123` is specified, only devices bound to the
-   * gateway with `num_id` 123 are returned.
-   * 
- * - * string associations_gateway_id = 2; - * - * @return Whether the associationsGatewayId field is set. - */ - boolean hasAssociationsGatewayId(); - /** - * - * - *
-   * If set, only devices associated with the specified gateway are returned.
-   * The gateway ID can be numeric (`num_id`) or the user-defined string
-   * (`id`). For example, if `123` is specified, only devices bound to the
-   * gateway with `num_id` 123 are returned.
-   * 
- * - * string associations_gateway_id = 2; - * - * @return The associationsGatewayId. - */ - java.lang.String getAssociationsGatewayId(); - /** - * - * - *
-   * If set, only devices associated with the specified gateway are returned.
-   * The gateway ID can be numeric (`num_id`) or the user-defined string
-   * (`id`). For example, if `123` is specified, only devices bound to the
-   * gateway with `num_id` 123 are returned.
-   * 
- * - * string associations_gateway_id = 2; - * - * @return The bytes for associationsGatewayId. - */ - com.google.protobuf.ByteString getAssociationsGatewayIdBytes(); - - /** - * - * - *
-   * If set, returns only the gateways with which the specified device is
-   * associated. The device ID can be numeric (`num_id`) or the user-defined
-   * string (`id`). For example, if `456` is specified, returns only the
-   * gateways to which the device with `num_id` 456 is bound.
-   * 
- * - * string associations_device_id = 3; - * - * @return Whether the associationsDeviceId field is set. - */ - boolean hasAssociationsDeviceId(); - /** - * - * - *
-   * If set, returns only the gateways with which the specified device is
-   * associated. The device ID can be numeric (`num_id`) or the user-defined
-   * string (`id`). For example, if `456` is specified, returns only the
-   * gateways to which the device with `num_id` 456 is bound.
-   * 
- * - * string associations_device_id = 3; - * - * @return The associationsDeviceId. - */ - java.lang.String getAssociationsDeviceId(); - /** - * - * - *
-   * If set, returns only the gateways with which the specified device is
-   * associated. The device ID can be numeric (`num_id`) or the user-defined
-   * string (`id`). For example, if `456` is specified, returns only the
-   * gateways to which the device with `num_id` 456 is bound.
-   * 
- * - * string associations_device_id = 3; - * - * @return The bytes for associationsDeviceId. - */ - com.google.protobuf.ByteString getAssociationsDeviceIdBytes(); - - public com.google.cloud.iot.v1.GatewayListOptions.FilterCase getFilterCase(); -} diff --git a/proto-google-cloud-iot-v1/src/main/java/com/google/cloud/iot/v1/GatewayType.java b/proto-google-cloud-iot-v1/src/main/java/com/google/cloud/iot/v1/GatewayType.java deleted file mode 100644 index 569e6959..00000000 --- a/proto-google-cloud-iot-v1/src/main/java/com/google/cloud/iot/v1/GatewayType.java +++ /dev/null @@ -1,176 +0,0 @@ -/* - * Copyright 2020 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. - */ -// Generated by the protocol buffer compiler. DO NOT EDIT! -// source: google/cloud/iot/v1/resources.proto - -package com.google.cloud.iot.v1; - -/** - * - * - *
- * Gateway type.
- * 
- * - * Protobuf enum {@code google.cloud.iot.v1.GatewayType} - */ -public enum GatewayType implements com.google.protobuf.ProtocolMessageEnum { - /** - * - * - *
-   * If unspecified, the device is considered a non-gateway device.
-   * 
- * - * GATEWAY_TYPE_UNSPECIFIED = 0; - */ - GATEWAY_TYPE_UNSPECIFIED(0), - /** - * - * - *
-   * The device is a gateway.
-   * 
- * - * GATEWAY = 1; - */ - GATEWAY(1), - /** - * - * - *
-   * The device is not a gateway.
-   * 
- * - * NON_GATEWAY = 2; - */ - NON_GATEWAY(2), - UNRECOGNIZED(-1), - ; - - /** - * - * - *
-   * If unspecified, the device is considered a non-gateway device.
-   * 
- * - * GATEWAY_TYPE_UNSPECIFIED = 0; - */ - public static final int GATEWAY_TYPE_UNSPECIFIED_VALUE = 0; - /** - * - * - *
-   * The device is a gateway.
-   * 
- * - * GATEWAY = 1; - */ - public static final int GATEWAY_VALUE = 1; - /** - * - * - *
-   * The device is not a gateway.
-   * 
- * - * NON_GATEWAY = 2; - */ - public static final int NON_GATEWAY_VALUE = 2; - - public final int getNumber() { - if (this == UNRECOGNIZED) { - throw new java.lang.IllegalArgumentException( - "Can't get the number of an unknown enum value."); - } - return value; - } - - /** - * @param value The numeric wire value of the corresponding enum entry. - * @return The enum associated with the given numeric wire value. - * @deprecated Use {@link #forNumber(int)} instead. - */ - @java.lang.Deprecated - public static GatewayType valueOf(int value) { - return forNumber(value); - } - - /** - * @param value The numeric wire value of the corresponding enum entry. - * @return The enum associated with the given numeric wire value. - */ - public static GatewayType forNumber(int value) { - switch (value) { - case 0: - return GATEWAY_TYPE_UNSPECIFIED; - case 1: - return GATEWAY; - case 2: - return NON_GATEWAY; - default: - return null; - } - } - - public static com.google.protobuf.Internal.EnumLiteMap internalGetValueMap() { - return internalValueMap; - } - - private static final com.google.protobuf.Internal.EnumLiteMap internalValueMap = - new com.google.protobuf.Internal.EnumLiteMap() { - public GatewayType findValueByNumber(int number) { - return GatewayType.forNumber(number); - } - }; - - public final com.google.protobuf.Descriptors.EnumValueDescriptor getValueDescriptor() { - if (this == UNRECOGNIZED) { - throw new java.lang.IllegalStateException( - "Can't get the descriptor of an unrecognized enum value."); - } - return getDescriptor().getValues().get(ordinal()); - } - - public final com.google.protobuf.Descriptors.EnumDescriptor getDescriptorForType() { - return getDescriptor(); - } - - public static final com.google.protobuf.Descriptors.EnumDescriptor getDescriptor() { - return com.google.cloud.iot.v1.ResourcesProto.getDescriptor().getEnumTypes().get(3); - } - - private static final GatewayType[] VALUES = values(); - - public static GatewayType valueOf(com.google.protobuf.Descriptors.EnumValueDescriptor desc) { - if (desc.getType() != getDescriptor()) { - throw new java.lang.IllegalArgumentException("EnumValueDescriptor is not for this type."); - } - if (desc.getIndex() == -1) { - return UNRECOGNIZED; - } - return VALUES[desc.getIndex()]; - } - - private final int value; - - private GatewayType(int value) { - this.value = value; - } - - // @@protoc_insertion_point(enum_scope:google.cloud.iot.v1.GatewayType) -} diff --git a/proto-google-cloud-iot-v1/src/main/java/com/google/cloud/iot/v1/GetDeviceRegistryRequest.java b/proto-google-cloud-iot-v1/src/main/java/com/google/cloud/iot/v1/GetDeviceRegistryRequest.java deleted file mode 100644 index 6169b8c8..00000000 --- a/proto-google-cloud-iot-v1/src/main/java/com/google/cloud/iot/v1/GetDeviceRegistryRequest.java +++ /dev/null @@ -1,636 +0,0 @@ -/* - * Copyright 2020 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. - */ -// Generated by the protocol buffer compiler. DO NOT EDIT! -// source: google/cloud/iot/v1/device_manager.proto - -package com.google.cloud.iot.v1; - -/** - * - * - *
- * Request for `GetDeviceRegistry`.
- * 
- * - * Protobuf type {@code google.cloud.iot.v1.GetDeviceRegistryRequest} - */ -public final class GetDeviceRegistryRequest extends com.google.protobuf.GeneratedMessageV3 - implements - // @@protoc_insertion_point(message_implements:google.cloud.iot.v1.GetDeviceRegistryRequest) - GetDeviceRegistryRequestOrBuilder { - private static final long serialVersionUID = 0L; - // Use GetDeviceRegistryRequest.newBuilder() to construct. - private GetDeviceRegistryRequest(com.google.protobuf.GeneratedMessageV3.Builder builder) { - super(builder); - } - - private GetDeviceRegistryRequest() { - name_ = ""; - } - - @java.lang.Override - @SuppressWarnings({"unused"}) - protected java.lang.Object newInstance(UnusedPrivateParameter unused) { - return new GetDeviceRegistryRequest(); - } - - @java.lang.Override - public final com.google.protobuf.UnknownFieldSet getUnknownFields() { - return this.unknownFields; - } - - public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { - return com.google.cloud.iot.v1.DeviceManagerProto - .internal_static_google_cloud_iot_v1_GetDeviceRegistryRequest_descriptor; - } - - @java.lang.Override - protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable - internalGetFieldAccessorTable() { - return com.google.cloud.iot.v1.DeviceManagerProto - .internal_static_google_cloud_iot_v1_GetDeviceRegistryRequest_fieldAccessorTable - .ensureFieldAccessorsInitialized( - com.google.cloud.iot.v1.GetDeviceRegistryRequest.class, - com.google.cloud.iot.v1.GetDeviceRegistryRequest.Builder.class); - } - - public static final int NAME_FIELD_NUMBER = 1; - private volatile java.lang.Object name_; - /** - * - * - *
-   * Required. The name of the device registry. For example,
-   * `projects/example-project/locations/us-central1/registries/my-registry`.
-   * 
- * - * - * string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } - * - * - * @return The name. - */ - @java.lang.Override - public java.lang.String getName() { - java.lang.Object ref = name_; - if (ref instanceof java.lang.String) { - return (java.lang.String) ref; - } else { - com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; - java.lang.String s = bs.toStringUtf8(); - name_ = s; - return s; - } - } - /** - * - * - *
-   * Required. The name of the device registry. For example,
-   * `projects/example-project/locations/us-central1/registries/my-registry`.
-   * 
- * - * - * string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } - * - * - * @return The bytes for name. - */ - @java.lang.Override - public com.google.protobuf.ByteString getNameBytes() { - java.lang.Object ref = name_; - if (ref instanceof java.lang.String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); - name_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - - private byte memoizedIsInitialized = -1; - - @java.lang.Override - public final boolean isInitialized() { - byte isInitialized = memoizedIsInitialized; - if (isInitialized == 1) return true; - if (isInitialized == 0) return false; - - memoizedIsInitialized = 1; - return true; - } - - @java.lang.Override - public void writeTo(com.google.protobuf.CodedOutputStream output) throws java.io.IOException { - if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(name_)) { - com.google.protobuf.GeneratedMessageV3.writeString(output, 1, name_); - } - getUnknownFields().writeTo(output); - } - - @java.lang.Override - public int getSerializedSize() { - int size = memoizedSize; - if (size != -1) return size; - - size = 0; - if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(name_)) { - size += com.google.protobuf.GeneratedMessageV3.computeStringSize(1, name_); - } - size += getUnknownFields().getSerializedSize(); - memoizedSize = size; - return size; - } - - @java.lang.Override - public boolean equals(final java.lang.Object obj) { - if (obj == this) { - return true; - } - if (!(obj instanceof com.google.cloud.iot.v1.GetDeviceRegistryRequest)) { - return super.equals(obj); - } - com.google.cloud.iot.v1.GetDeviceRegistryRequest other = - (com.google.cloud.iot.v1.GetDeviceRegistryRequest) obj; - - if (!getName().equals(other.getName())) return false; - if (!getUnknownFields().equals(other.getUnknownFields())) return false; - return true; - } - - @java.lang.Override - public int hashCode() { - if (memoizedHashCode != 0) { - return memoizedHashCode; - } - int hash = 41; - hash = (19 * hash) + getDescriptor().hashCode(); - hash = (37 * hash) + NAME_FIELD_NUMBER; - hash = (53 * hash) + getName().hashCode(); - hash = (29 * hash) + getUnknownFields().hashCode(); - memoizedHashCode = hash; - return hash; - } - - public static com.google.cloud.iot.v1.GetDeviceRegistryRequest parseFrom(java.nio.ByteBuffer data) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); - } - - public static com.google.cloud.iot.v1.GetDeviceRegistryRequest parseFrom( - java.nio.ByteBuffer data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); - } - - public static com.google.cloud.iot.v1.GetDeviceRegistryRequest parseFrom( - com.google.protobuf.ByteString data) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); - } - - public static com.google.cloud.iot.v1.GetDeviceRegistryRequest parseFrom( - com.google.protobuf.ByteString data, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); - } - - public static com.google.cloud.iot.v1.GetDeviceRegistryRequest parseFrom(byte[] data) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); - } - - public static com.google.cloud.iot.v1.GetDeviceRegistryRequest parseFrom( - byte[] data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); - } - - public static com.google.cloud.iot.v1.GetDeviceRegistryRequest parseFrom( - java.io.InputStream input) throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input); - } - - public static com.google.cloud.iot.v1.GetDeviceRegistryRequest parseFrom( - java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3.parseWithIOException( - PARSER, input, extensionRegistry); - } - - public static com.google.cloud.iot.v1.GetDeviceRegistryRequest parseDelimitedFrom( - java.io.InputStream input) throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3.parseDelimitedWithIOException(PARSER, input); - } - - public static com.google.cloud.iot.v1.GetDeviceRegistryRequest parseDelimitedFrom( - java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3.parseDelimitedWithIOException( - PARSER, input, extensionRegistry); - } - - public static com.google.cloud.iot.v1.GetDeviceRegistryRequest parseFrom( - com.google.protobuf.CodedInputStream input) throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input); - } - - public static com.google.cloud.iot.v1.GetDeviceRegistryRequest parseFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3.parseWithIOException( - PARSER, input, extensionRegistry); - } - - @java.lang.Override - public Builder newBuilderForType() { - return newBuilder(); - } - - public static Builder newBuilder() { - return DEFAULT_INSTANCE.toBuilder(); - } - - public static Builder newBuilder(com.google.cloud.iot.v1.GetDeviceRegistryRequest prototype) { - return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); - } - - @java.lang.Override - public Builder toBuilder() { - return this == DEFAULT_INSTANCE ? new Builder() : new Builder().mergeFrom(this); - } - - @java.lang.Override - protected Builder newBuilderForType(com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { - Builder builder = new Builder(parent); - return builder; - } - /** - * - * - *
-   * Request for `GetDeviceRegistry`.
-   * 
- * - * Protobuf type {@code google.cloud.iot.v1.GetDeviceRegistryRequest} - */ - public static final class Builder extends com.google.protobuf.GeneratedMessageV3.Builder - implements - // @@protoc_insertion_point(builder_implements:google.cloud.iot.v1.GetDeviceRegistryRequest) - com.google.cloud.iot.v1.GetDeviceRegistryRequestOrBuilder { - public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { - return com.google.cloud.iot.v1.DeviceManagerProto - .internal_static_google_cloud_iot_v1_GetDeviceRegistryRequest_descriptor; - } - - @java.lang.Override - protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable - internalGetFieldAccessorTable() { - return com.google.cloud.iot.v1.DeviceManagerProto - .internal_static_google_cloud_iot_v1_GetDeviceRegistryRequest_fieldAccessorTable - .ensureFieldAccessorsInitialized( - com.google.cloud.iot.v1.GetDeviceRegistryRequest.class, - com.google.cloud.iot.v1.GetDeviceRegistryRequest.Builder.class); - } - - // Construct using com.google.cloud.iot.v1.GetDeviceRegistryRequest.newBuilder() - private Builder() {} - - private Builder(com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { - super(parent); - } - - @java.lang.Override - public Builder clear() { - super.clear(); - name_ = ""; - - return this; - } - - @java.lang.Override - public com.google.protobuf.Descriptors.Descriptor getDescriptorForType() { - return com.google.cloud.iot.v1.DeviceManagerProto - .internal_static_google_cloud_iot_v1_GetDeviceRegistryRequest_descriptor; - } - - @java.lang.Override - public com.google.cloud.iot.v1.GetDeviceRegistryRequest getDefaultInstanceForType() { - return com.google.cloud.iot.v1.GetDeviceRegistryRequest.getDefaultInstance(); - } - - @java.lang.Override - public com.google.cloud.iot.v1.GetDeviceRegistryRequest build() { - com.google.cloud.iot.v1.GetDeviceRegistryRequest result = buildPartial(); - if (!result.isInitialized()) { - throw newUninitializedMessageException(result); - } - return result; - } - - @java.lang.Override - public com.google.cloud.iot.v1.GetDeviceRegistryRequest buildPartial() { - com.google.cloud.iot.v1.GetDeviceRegistryRequest result = - new com.google.cloud.iot.v1.GetDeviceRegistryRequest(this); - result.name_ = name_; - onBuilt(); - return result; - } - - @java.lang.Override - public Builder clone() { - return super.clone(); - } - - @java.lang.Override - public Builder setField( - com.google.protobuf.Descriptors.FieldDescriptor field, java.lang.Object value) { - return super.setField(field, value); - } - - @java.lang.Override - public Builder clearField(com.google.protobuf.Descriptors.FieldDescriptor field) { - return super.clearField(field); - } - - @java.lang.Override - public Builder clearOneof(com.google.protobuf.Descriptors.OneofDescriptor oneof) { - return super.clearOneof(oneof); - } - - @java.lang.Override - public Builder setRepeatedField( - com.google.protobuf.Descriptors.FieldDescriptor field, int index, java.lang.Object value) { - return super.setRepeatedField(field, index, value); - } - - @java.lang.Override - public Builder addRepeatedField( - com.google.protobuf.Descriptors.FieldDescriptor field, java.lang.Object value) { - return super.addRepeatedField(field, value); - } - - @java.lang.Override - public Builder mergeFrom(com.google.protobuf.Message other) { - if (other instanceof com.google.cloud.iot.v1.GetDeviceRegistryRequest) { - return mergeFrom((com.google.cloud.iot.v1.GetDeviceRegistryRequest) other); - } else { - super.mergeFrom(other); - return this; - } - } - - public Builder mergeFrom(com.google.cloud.iot.v1.GetDeviceRegistryRequest other) { - if (other == com.google.cloud.iot.v1.GetDeviceRegistryRequest.getDefaultInstance()) - return this; - if (!other.getName().isEmpty()) { - name_ = other.name_; - onChanged(); - } - this.mergeUnknownFields(other.getUnknownFields()); - onChanged(); - return this; - } - - @java.lang.Override - public final boolean isInitialized() { - return true; - } - - @java.lang.Override - public Builder mergeFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - if (extensionRegistry == null) { - throw new java.lang.NullPointerException(); - } - try { - boolean done = false; - while (!done) { - int tag = input.readTag(); - switch (tag) { - case 0: - done = true; - break; - case 10: - { - name_ = input.readStringRequireUtf8(); - - break; - } // case 10 - default: - { - if (!super.parseUnknownField(input, extensionRegistry, tag)) { - done = true; // was an endgroup tag - } - break; - } // default: - } // switch (tag) - } // while (!done) - } catch (com.google.protobuf.InvalidProtocolBufferException e) { - throw e.unwrapIOException(); - } finally { - onChanged(); - } // finally - return this; - } - - private java.lang.Object name_ = ""; - /** - * - * - *
-     * Required. The name of the device registry. For example,
-     * `projects/example-project/locations/us-central1/registries/my-registry`.
-     * 
- * - * - * string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } - * - * - * @return The name. - */ - public java.lang.String getName() { - java.lang.Object ref = name_; - if (!(ref instanceof java.lang.String)) { - com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; - java.lang.String s = bs.toStringUtf8(); - name_ = s; - return s; - } else { - return (java.lang.String) ref; - } - } - /** - * - * - *
-     * Required. The name of the device registry. For example,
-     * `projects/example-project/locations/us-central1/registries/my-registry`.
-     * 
- * - * - * string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } - * - * - * @return The bytes for name. - */ - public com.google.protobuf.ByteString getNameBytes() { - java.lang.Object ref = name_; - if (ref instanceof String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); - name_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - /** - * - * - *
-     * Required. The name of the device registry. For example,
-     * `projects/example-project/locations/us-central1/registries/my-registry`.
-     * 
- * - * - * string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } - * - * - * @param value The name to set. - * @return This builder for chaining. - */ - public Builder setName(java.lang.String value) { - if (value == null) { - throw new NullPointerException(); - } - - name_ = value; - onChanged(); - return this; - } - /** - * - * - *
-     * Required. The name of the device registry. For example,
-     * `projects/example-project/locations/us-central1/registries/my-registry`.
-     * 
- * - * - * string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } - * - * - * @return This builder for chaining. - */ - public Builder clearName() { - - name_ = getDefaultInstance().getName(); - onChanged(); - return this; - } - /** - * - * - *
-     * Required. The name of the device registry. For example,
-     * `projects/example-project/locations/us-central1/registries/my-registry`.
-     * 
- * - * - * string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } - * - * - * @param value The bytes for name to set. - * @return This builder for chaining. - */ - public Builder setNameBytes(com.google.protobuf.ByteString value) { - if (value == null) { - throw new NullPointerException(); - } - checkByteStringIsUtf8(value); - - name_ = value; - onChanged(); - return this; - } - - @java.lang.Override - public final Builder setUnknownFields(final com.google.protobuf.UnknownFieldSet unknownFields) { - return super.setUnknownFields(unknownFields); - } - - @java.lang.Override - public final Builder mergeUnknownFields( - final com.google.protobuf.UnknownFieldSet unknownFields) { - return super.mergeUnknownFields(unknownFields); - } - - // @@protoc_insertion_point(builder_scope:google.cloud.iot.v1.GetDeviceRegistryRequest) - } - - // @@protoc_insertion_point(class_scope:google.cloud.iot.v1.GetDeviceRegistryRequest) - private static final com.google.cloud.iot.v1.GetDeviceRegistryRequest DEFAULT_INSTANCE; - - static { - DEFAULT_INSTANCE = new com.google.cloud.iot.v1.GetDeviceRegistryRequest(); - } - - public static com.google.cloud.iot.v1.GetDeviceRegistryRequest getDefaultInstance() { - return DEFAULT_INSTANCE; - } - - private static final com.google.protobuf.Parser PARSER = - new com.google.protobuf.AbstractParser() { - @java.lang.Override - public GetDeviceRegistryRequest parsePartialFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - Builder builder = newBuilder(); - try { - builder.mergeFrom(input, extensionRegistry); - } catch (com.google.protobuf.InvalidProtocolBufferException e) { - throw e.setUnfinishedMessage(builder.buildPartial()); - } catch (com.google.protobuf.UninitializedMessageException e) { - throw e.asInvalidProtocolBufferException().setUnfinishedMessage(builder.buildPartial()); - } catch (java.io.IOException e) { - throw new com.google.protobuf.InvalidProtocolBufferException(e) - .setUnfinishedMessage(builder.buildPartial()); - } - return builder.buildPartial(); - } - }; - - public static com.google.protobuf.Parser parser() { - return PARSER; - } - - @java.lang.Override - public com.google.protobuf.Parser getParserForType() { - return PARSER; - } - - @java.lang.Override - public com.google.cloud.iot.v1.GetDeviceRegistryRequest getDefaultInstanceForType() { - return DEFAULT_INSTANCE; - } -} diff --git a/proto-google-cloud-iot-v1/src/main/java/com/google/cloud/iot/v1/GetDeviceRegistryRequestOrBuilder.java b/proto-google-cloud-iot-v1/src/main/java/com/google/cloud/iot/v1/GetDeviceRegistryRequestOrBuilder.java deleted file mode 100644 index 36c5a33a..00000000 --- a/proto-google-cloud-iot-v1/src/main/java/com/google/cloud/iot/v1/GetDeviceRegistryRequestOrBuilder.java +++ /dev/null @@ -1,56 +0,0 @@ -/* - * Copyright 2020 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. - */ -// Generated by the protocol buffer compiler. DO NOT EDIT! -// source: google/cloud/iot/v1/device_manager.proto - -package com.google.cloud.iot.v1; - -public interface GetDeviceRegistryRequestOrBuilder - extends - // @@protoc_insertion_point(interface_extends:google.cloud.iot.v1.GetDeviceRegistryRequest) - com.google.protobuf.MessageOrBuilder { - - /** - * - * - *
-   * Required. The name of the device registry. For example,
-   * `projects/example-project/locations/us-central1/registries/my-registry`.
-   * 
- * - * - * string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } - * - * - * @return The name. - */ - java.lang.String getName(); - /** - * - * - *
-   * Required. The name of the device registry. For example,
-   * `projects/example-project/locations/us-central1/registries/my-registry`.
-   * 
- * - * - * string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } - * - * - * @return The bytes for name. - */ - com.google.protobuf.ByteString getNameBytes(); -} diff --git a/proto-google-cloud-iot-v1/src/main/java/com/google/cloud/iot/v1/GetDeviceRequest.java b/proto-google-cloud-iot-v1/src/main/java/com/google/cloud/iot/v1/GetDeviceRequest.java deleted file mode 100644 index 6e497644..00000000 --- a/proto-google-cloud-iot-v1/src/main/java/com/google/cloud/iot/v1/GetDeviceRequest.java +++ /dev/null @@ -1,924 +0,0 @@ -/* - * Copyright 2020 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. - */ -// Generated by the protocol buffer compiler. DO NOT EDIT! -// source: google/cloud/iot/v1/device_manager.proto - -package com.google.cloud.iot.v1; - -/** - * - * - *
- * Request for `GetDevice`.
- * 
- * - * Protobuf type {@code google.cloud.iot.v1.GetDeviceRequest} - */ -public final class GetDeviceRequest extends com.google.protobuf.GeneratedMessageV3 - implements - // @@protoc_insertion_point(message_implements:google.cloud.iot.v1.GetDeviceRequest) - GetDeviceRequestOrBuilder { - private static final long serialVersionUID = 0L; - // Use GetDeviceRequest.newBuilder() to construct. - private GetDeviceRequest(com.google.protobuf.GeneratedMessageV3.Builder builder) { - super(builder); - } - - private GetDeviceRequest() { - name_ = ""; - } - - @java.lang.Override - @SuppressWarnings({"unused"}) - protected java.lang.Object newInstance(UnusedPrivateParameter unused) { - return new GetDeviceRequest(); - } - - @java.lang.Override - public final com.google.protobuf.UnknownFieldSet getUnknownFields() { - return this.unknownFields; - } - - public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { - return com.google.cloud.iot.v1.DeviceManagerProto - .internal_static_google_cloud_iot_v1_GetDeviceRequest_descriptor; - } - - @java.lang.Override - protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable - internalGetFieldAccessorTable() { - return com.google.cloud.iot.v1.DeviceManagerProto - .internal_static_google_cloud_iot_v1_GetDeviceRequest_fieldAccessorTable - .ensureFieldAccessorsInitialized( - com.google.cloud.iot.v1.GetDeviceRequest.class, - com.google.cloud.iot.v1.GetDeviceRequest.Builder.class); - } - - public static final int NAME_FIELD_NUMBER = 1; - private volatile java.lang.Object name_; - /** - * - * - *
-   * Required. The name of the device. For example,
-   * `projects/p0/locations/us-central1/registries/registry0/devices/device0` or
-   * `projects/p0/locations/us-central1/registries/registry0/devices/{num_id}`.
-   * 
- * - * - * string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } - * - * - * @return The name. - */ - @java.lang.Override - public java.lang.String getName() { - java.lang.Object ref = name_; - if (ref instanceof java.lang.String) { - return (java.lang.String) ref; - } else { - com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; - java.lang.String s = bs.toStringUtf8(); - name_ = s; - return s; - } - } - /** - * - * - *
-   * Required. The name of the device. For example,
-   * `projects/p0/locations/us-central1/registries/registry0/devices/device0` or
-   * `projects/p0/locations/us-central1/registries/registry0/devices/{num_id}`.
-   * 
- * - * - * string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } - * - * - * @return The bytes for name. - */ - @java.lang.Override - public com.google.protobuf.ByteString getNameBytes() { - java.lang.Object ref = name_; - if (ref instanceof java.lang.String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); - name_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - - public static final int FIELD_MASK_FIELD_NUMBER = 2; - private com.google.protobuf.FieldMask fieldMask_; - /** - * - * - *
-   * The fields of the `Device` resource to be returned in the response. If the
-   * field mask is unset or empty, all fields are returned. Fields have to be
-   * provided in snake_case format, for example: `last_heartbeat_time`.
-   * 
- * - * .google.protobuf.FieldMask field_mask = 2; - * - * @return Whether the fieldMask field is set. - */ - @java.lang.Override - public boolean hasFieldMask() { - return fieldMask_ != null; - } - /** - * - * - *
-   * The fields of the `Device` resource to be returned in the response. If the
-   * field mask is unset or empty, all fields are returned. Fields have to be
-   * provided in snake_case format, for example: `last_heartbeat_time`.
-   * 
- * - * .google.protobuf.FieldMask field_mask = 2; - * - * @return The fieldMask. - */ - @java.lang.Override - public com.google.protobuf.FieldMask getFieldMask() { - return fieldMask_ == null ? com.google.protobuf.FieldMask.getDefaultInstance() : fieldMask_; - } - /** - * - * - *
-   * The fields of the `Device` resource to be returned in the response. If the
-   * field mask is unset or empty, all fields are returned. Fields have to be
-   * provided in snake_case format, for example: `last_heartbeat_time`.
-   * 
- * - * .google.protobuf.FieldMask field_mask = 2; - */ - @java.lang.Override - public com.google.protobuf.FieldMaskOrBuilder getFieldMaskOrBuilder() { - return getFieldMask(); - } - - private byte memoizedIsInitialized = -1; - - @java.lang.Override - public final boolean isInitialized() { - byte isInitialized = memoizedIsInitialized; - if (isInitialized == 1) return true; - if (isInitialized == 0) return false; - - memoizedIsInitialized = 1; - return true; - } - - @java.lang.Override - public void writeTo(com.google.protobuf.CodedOutputStream output) throws java.io.IOException { - if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(name_)) { - com.google.protobuf.GeneratedMessageV3.writeString(output, 1, name_); - } - if (fieldMask_ != null) { - output.writeMessage(2, getFieldMask()); - } - getUnknownFields().writeTo(output); - } - - @java.lang.Override - public int getSerializedSize() { - int size = memoizedSize; - if (size != -1) return size; - - size = 0; - if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(name_)) { - size += com.google.protobuf.GeneratedMessageV3.computeStringSize(1, name_); - } - if (fieldMask_ != null) { - size += com.google.protobuf.CodedOutputStream.computeMessageSize(2, getFieldMask()); - } - size += getUnknownFields().getSerializedSize(); - memoizedSize = size; - return size; - } - - @java.lang.Override - public boolean equals(final java.lang.Object obj) { - if (obj == this) { - return true; - } - if (!(obj instanceof com.google.cloud.iot.v1.GetDeviceRequest)) { - return super.equals(obj); - } - com.google.cloud.iot.v1.GetDeviceRequest other = (com.google.cloud.iot.v1.GetDeviceRequest) obj; - - if (!getName().equals(other.getName())) return false; - if (hasFieldMask() != other.hasFieldMask()) return false; - if (hasFieldMask()) { - if (!getFieldMask().equals(other.getFieldMask())) return false; - } - if (!getUnknownFields().equals(other.getUnknownFields())) return false; - return true; - } - - @java.lang.Override - public int hashCode() { - if (memoizedHashCode != 0) { - return memoizedHashCode; - } - int hash = 41; - hash = (19 * hash) + getDescriptor().hashCode(); - hash = (37 * hash) + NAME_FIELD_NUMBER; - hash = (53 * hash) + getName().hashCode(); - if (hasFieldMask()) { - hash = (37 * hash) + FIELD_MASK_FIELD_NUMBER; - hash = (53 * hash) + getFieldMask().hashCode(); - } - hash = (29 * hash) + getUnknownFields().hashCode(); - memoizedHashCode = hash; - return hash; - } - - public static com.google.cloud.iot.v1.GetDeviceRequest parseFrom(java.nio.ByteBuffer data) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); - } - - public static com.google.cloud.iot.v1.GetDeviceRequest parseFrom( - java.nio.ByteBuffer data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); - } - - public static com.google.cloud.iot.v1.GetDeviceRequest parseFrom( - com.google.protobuf.ByteString data) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); - } - - public static com.google.cloud.iot.v1.GetDeviceRequest parseFrom( - com.google.protobuf.ByteString data, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); - } - - public static com.google.cloud.iot.v1.GetDeviceRequest parseFrom(byte[] data) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); - } - - public static com.google.cloud.iot.v1.GetDeviceRequest parseFrom( - byte[] data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); - } - - public static com.google.cloud.iot.v1.GetDeviceRequest parseFrom(java.io.InputStream input) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input); - } - - public static com.google.cloud.iot.v1.GetDeviceRequest parseFrom( - java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3.parseWithIOException( - PARSER, input, extensionRegistry); - } - - public static com.google.cloud.iot.v1.GetDeviceRequest parseDelimitedFrom( - java.io.InputStream input) throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3.parseDelimitedWithIOException(PARSER, input); - } - - public static com.google.cloud.iot.v1.GetDeviceRequest parseDelimitedFrom( - java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3.parseDelimitedWithIOException( - PARSER, input, extensionRegistry); - } - - public static com.google.cloud.iot.v1.GetDeviceRequest parseFrom( - com.google.protobuf.CodedInputStream input) throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input); - } - - public static com.google.cloud.iot.v1.GetDeviceRequest parseFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3.parseWithIOException( - PARSER, input, extensionRegistry); - } - - @java.lang.Override - public Builder newBuilderForType() { - return newBuilder(); - } - - public static Builder newBuilder() { - return DEFAULT_INSTANCE.toBuilder(); - } - - public static Builder newBuilder(com.google.cloud.iot.v1.GetDeviceRequest prototype) { - return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); - } - - @java.lang.Override - public Builder toBuilder() { - return this == DEFAULT_INSTANCE ? new Builder() : new Builder().mergeFrom(this); - } - - @java.lang.Override - protected Builder newBuilderForType(com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { - Builder builder = new Builder(parent); - return builder; - } - /** - * - * - *
-   * Request for `GetDevice`.
-   * 
- * - * Protobuf type {@code google.cloud.iot.v1.GetDeviceRequest} - */ - public static final class Builder extends com.google.protobuf.GeneratedMessageV3.Builder - implements - // @@protoc_insertion_point(builder_implements:google.cloud.iot.v1.GetDeviceRequest) - com.google.cloud.iot.v1.GetDeviceRequestOrBuilder { - public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { - return com.google.cloud.iot.v1.DeviceManagerProto - .internal_static_google_cloud_iot_v1_GetDeviceRequest_descriptor; - } - - @java.lang.Override - protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable - internalGetFieldAccessorTable() { - return com.google.cloud.iot.v1.DeviceManagerProto - .internal_static_google_cloud_iot_v1_GetDeviceRequest_fieldAccessorTable - .ensureFieldAccessorsInitialized( - com.google.cloud.iot.v1.GetDeviceRequest.class, - com.google.cloud.iot.v1.GetDeviceRequest.Builder.class); - } - - // Construct using com.google.cloud.iot.v1.GetDeviceRequest.newBuilder() - private Builder() {} - - private Builder(com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { - super(parent); - } - - @java.lang.Override - public Builder clear() { - super.clear(); - name_ = ""; - - if (fieldMaskBuilder_ == null) { - fieldMask_ = null; - } else { - fieldMask_ = null; - fieldMaskBuilder_ = null; - } - return this; - } - - @java.lang.Override - public com.google.protobuf.Descriptors.Descriptor getDescriptorForType() { - return com.google.cloud.iot.v1.DeviceManagerProto - .internal_static_google_cloud_iot_v1_GetDeviceRequest_descriptor; - } - - @java.lang.Override - public com.google.cloud.iot.v1.GetDeviceRequest getDefaultInstanceForType() { - return com.google.cloud.iot.v1.GetDeviceRequest.getDefaultInstance(); - } - - @java.lang.Override - public com.google.cloud.iot.v1.GetDeviceRequest build() { - com.google.cloud.iot.v1.GetDeviceRequest result = buildPartial(); - if (!result.isInitialized()) { - throw newUninitializedMessageException(result); - } - return result; - } - - @java.lang.Override - public com.google.cloud.iot.v1.GetDeviceRequest buildPartial() { - com.google.cloud.iot.v1.GetDeviceRequest result = - new com.google.cloud.iot.v1.GetDeviceRequest(this); - result.name_ = name_; - if (fieldMaskBuilder_ == null) { - result.fieldMask_ = fieldMask_; - } else { - result.fieldMask_ = fieldMaskBuilder_.build(); - } - onBuilt(); - return result; - } - - @java.lang.Override - public Builder clone() { - return super.clone(); - } - - @java.lang.Override - public Builder setField( - com.google.protobuf.Descriptors.FieldDescriptor field, java.lang.Object value) { - return super.setField(field, value); - } - - @java.lang.Override - public Builder clearField(com.google.protobuf.Descriptors.FieldDescriptor field) { - return super.clearField(field); - } - - @java.lang.Override - public Builder clearOneof(com.google.protobuf.Descriptors.OneofDescriptor oneof) { - return super.clearOneof(oneof); - } - - @java.lang.Override - public Builder setRepeatedField( - com.google.protobuf.Descriptors.FieldDescriptor field, int index, java.lang.Object value) { - return super.setRepeatedField(field, index, value); - } - - @java.lang.Override - public Builder addRepeatedField( - com.google.protobuf.Descriptors.FieldDescriptor field, java.lang.Object value) { - return super.addRepeatedField(field, value); - } - - @java.lang.Override - public Builder mergeFrom(com.google.protobuf.Message other) { - if (other instanceof com.google.cloud.iot.v1.GetDeviceRequest) { - return mergeFrom((com.google.cloud.iot.v1.GetDeviceRequest) other); - } else { - super.mergeFrom(other); - return this; - } - } - - public Builder mergeFrom(com.google.cloud.iot.v1.GetDeviceRequest other) { - if (other == com.google.cloud.iot.v1.GetDeviceRequest.getDefaultInstance()) return this; - if (!other.getName().isEmpty()) { - name_ = other.name_; - onChanged(); - } - if (other.hasFieldMask()) { - mergeFieldMask(other.getFieldMask()); - } - this.mergeUnknownFields(other.getUnknownFields()); - onChanged(); - return this; - } - - @java.lang.Override - public final boolean isInitialized() { - return true; - } - - @java.lang.Override - public Builder mergeFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - if (extensionRegistry == null) { - throw new java.lang.NullPointerException(); - } - try { - boolean done = false; - while (!done) { - int tag = input.readTag(); - switch (tag) { - case 0: - done = true; - break; - case 10: - { - name_ = input.readStringRequireUtf8(); - - break; - } // case 10 - case 18: - { - input.readMessage(getFieldMaskFieldBuilder().getBuilder(), extensionRegistry); - - break; - } // case 18 - default: - { - if (!super.parseUnknownField(input, extensionRegistry, tag)) { - done = true; // was an endgroup tag - } - break; - } // default: - } // switch (tag) - } // while (!done) - } catch (com.google.protobuf.InvalidProtocolBufferException e) { - throw e.unwrapIOException(); - } finally { - onChanged(); - } // finally - return this; - } - - private java.lang.Object name_ = ""; - /** - * - * - *
-     * Required. The name of the device. For example,
-     * `projects/p0/locations/us-central1/registries/registry0/devices/device0` or
-     * `projects/p0/locations/us-central1/registries/registry0/devices/{num_id}`.
-     * 
- * - * - * string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } - * - * - * @return The name. - */ - public java.lang.String getName() { - java.lang.Object ref = name_; - if (!(ref instanceof java.lang.String)) { - com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; - java.lang.String s = bs.toStringUtf8(); - name_ = s; - return s; - } else { - return (java.lang.String) ref; - } - } - /** - * - * - *
-     * Required. The name of the device. For example,
-     * `projects/p0/locations/us-central1/registries/registry0/devices/device0` or
-     * `projects/p0/locations/us-central1/registries/registry0/devices/{num_id}`.
-     * 
- * - * - * string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } - * - * - * @return The bytes for name. - */ - public com.google.protobuf.ByteString getNameBytes() { - java.lang.Object ref = name_; - if (ref instanceof String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); - name_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - /** - * - * - *
-     * Required. The name of the device. For example,
-     * `projects/p0/locations/us-central1/registries/registry0/devices/device0` or
-     * `projects/p0/locations/us-central1/registries/registry0/devices/{num_id}`.
-     * 
- * - * - * string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } - * - * - * @param value The name to set. - * @return This builder for chaining. - */ - public Builder setName(java.lang.String value) { - if (value == null) { - throw new NullPointerException(); - } - - name_ = value; - onChanged(); - return this; - } - /** - * - * - *
-     * Required. The name of the device. For example,
-     * `projects/p0/locations/us-central1/registries/registry0/devices/device0` or
-     * `projects/p0/locations/us-central1/registries/registry0/devices/{num_id}`.
-     * 
- * - * - * string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } - * - * - * @return This builder for chaining. - */ - public Builder clearName() { - - name_ = getDefaultInstance().getName(); - onChanged(); - return this; - } - /** - * - * - *
-     * Required. The name of the device. For example,
-     * `projects/p0/locations/us-central1/registries/registry0/devices/device0` or
-     * `projects/p0/locations/us-central1/registries/registry0/devices/{num_id}`.
-     * 
- * - * - * string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } - * - * - * @param value The bytes for name to set. - * @return This builder for chaining. - */ - public Builder setNameBytes(com.google.protobuf.ByteString value) { - if (value == null) { - throw new NullPointerException(); - } - checkByteStringIsUtf8(value); - - name_ = value; - onChanged(); - return this; - } - - private com.google.protobuf.FieldMask fieldMask_; - private com.google.protobuf.SingleFieldBuilderV3< - com.google.protobuf.FieldMask, - com.google.protobuf.FieldMask.Builder, - com.google.protobuf.FieldMaskOrBuilder> - fieldMaskBuilder_; - /** - * - * - *
-     * The fields of the `Device` resource to be returned in the response. If the
-     * field mask is unset or empty, all fields are returned. Fields have to be
-     * provided in snake_case format, for example: `last_heartbeat_time`.
-     * 
- * - * .google.protobuf.FieldMask field_mask = 2; - * - * @return Whether the fieldMask field is set. - */ - public boolean hasFieldMask() { - return fieldMaskBuilder_ != null || fieldMask_ != null; - } - /** - * - * - *
-     * The fields of the `Device` resource to be returned in the response. If the
-     * field mask is unset or empty, all fields are returned. Fields have to be
-     * provided in snake_case format, for example: `last_heartbeat_time`.
-     * 
- * - * .google.protobuf.FieldMask field_mask = 2; - * - * @return The fieldMask. - */ - public com.google.protobuf.FieldMask getFieldMask() { - if (fieldMaskBuilder_ == null) { - return fieldMask_ == null ? com.google.protobuf.FieldMask.getDefaultInstance() : fieldMask_; - } else { - return fieldMaskBuilder_.getMessage(); - } - } - /** - * - * - *
-     * The fields of the `Device` resource to be returned in the response. If the
-     * field mask is unset or empty, all fields are returned. Fields have to be
-     * provided in snake_case format, for example: `last_heartbeat_time`.
-     * 
- * - * .google.protobuf.FieldMask field_mask = 2; - */ - public Builder setFieldMask(com.google.protobuf.FieldMask value) { - if (fieldMaskBuilder_ == null) { - if (value == null) { - throw new NullPointerException(); - } - fieldMask_ = value; - onChanged(); - } else { - fieldMaskBuilder_.setMessage(value); - } - - return this; - } - /** - * - * - *
-     * The fields of the `Device` resource to be returned in the response. If the
-     * field mask is unset or empty, all fields are returned. Fields have to be
-     * provided in snake_case format, for example: `last_heartbeat_time`.
-     * 
- * - * .google.protobuf.FieldMask field_mask = 2; - */ - public Builder setFieldMask(com.google.protobuf.FieldMask.Builder builderForValue) { - if (fieldMaskBuilder_ == null) { - fieldMask_ = builderForValue.build(); - onChanged(); - } else { - fieldMaskBuilder_.setMessage(builderForValue.build()); - } - - return this; - } - /** - * - * - *
-     * The fields of the `Device` resource to be returned in the response. If the
-     * field mask is unset or empty, all fields are returned. Fields have to be
-     * provided in snake_case format, for example: `last_heartbeat_time`.
-     * 
- * - * .google.protobuf.FieldMask field_mask = 2; - */ - public Builder mergeFieldMask(com.google.protobuf.FieldMask value) { - if (fieldMaskBuilder_ == null) { - if (fieldMask_ != null) { - fieldMask_ = - com.google.protobuf.FieldMask.newBuilder(fieldMask_).mergeFrom(value).buildPartial(); - } else { - fieldMask_ = value; - } - onChanged(); - } else { - fieldMaskBuilder_.mergeFrom(value); - } - - return this; - } - /** - * - * - *
-     * The fields of the `Device` resource to be returned in the response. If the
-     * field mask is unset or empty, all fields are returned. Fields have to be
-     * provided in snake_case format, for example: `last_heartbeat_time`.
-     * 
- * - * .google.protobuf.FieldMask field_mask = 2; - */ - public Builder clearFieldMask() { - if (fieldMaskBuilder_ == null) { - fieldMask_ = null; - onChanged(); - } else { - fieldMask_ = null; - fieldMaskBuilder_ = null; - } - - return this; - } - /** - * - * - *
-     * The fields of the `Device` resource to be returned in the response. If the
-     * field mask is unset or empty, all fields are returned. Fields have to be
-     * provided in snake_case format, for example: `last_heartbeat_time`.
-     * 
- * - * .google.protobuf.FieldMask field_mask = 2; - */ - public com.google.protobuf.FieldMask.Builder getFieldMaskBuilder() { - - onChanged(); - return getFieldMaskFieldBuilder().getBuilder(); - } - /** - * - * - *
-     * The fields of the `Device` resource to be returned in the response. If the
-     * field mask is unset or empty, all fields are returned. Fields have to be
-     * provided in snake_case format, for example: `last_heartbeat_time`.
-     * 
- * - * .google.protobuf.FieldMask field_mask = 2; - */ - public com.google.protobuf.FieldMaskOrBuilder getFieldMaskOrBuilder() { - if (fieldMaskBuilder_ != null) { - return fieldMaskBuilder_.getMessageOrBuilder(); - } else { - return fieldMask_ == null ? com.google.protobuf.FieldMask.getDefaultInstance() : fieldMask_; - } - } - /** - * - * - *
-     * The fields of the `Device` resource to be returned in the response. If the
-     * field mask is unset or empty, all fields are returned. Fields have to be
-     * provided in snake_case format, for example: `last_heartbeat_time`.
-     * 
- * - * .google.protobuf.FieldMask field_mask = 2; - */ - private com.google.protobuf.SingleFieldBuilderV3< - com.google.protobuf.FieldMask, - com.google.protobuf.FieldMask.Builder, - com.google.protobuf.FieldMaskOrBuilder> - getFieldMaskFieldBuilder() { - if (fieldMaskBuilder_ == null) { - fieldMaskBuilder_ = - new com.google.protobuf.SingleFieldBuilderV3< - com.google.protobuf.FieldMask, - com.google.protobuf.FieldMask.Builder, - com.google.protobuf.FieldMaskOrBuilder>( - getFieldMask(), getParentForChildren(), isClean()); - fieldMask_ = null; - } - return fieldMaskBuilder_; - } - - @java.lang.Override - public final Builder setUnknownFields(final com.google.protobuf.UnknownFieldSet unknownFields) { - return super.setUnknownFields(unknownFields); - } - - @java.lang.Override - public final Builder mergeUnknownFields( - final com.google.protobuf.UnknownFieldSet unknownFields) { - return super.mergeUnknownFields(unknownFields); - } - - // @@protoc_insertion_point(builder_scope:google.cloud.iot.v1.GetDeviceRequest) - } - - // @@protoc_insertion_point(class_scope:google.cloud.iot.v1.GetDeviceRequest) - private static final com.google.cloud.iot.v1.GetDeviceRequest DEFAULT_INSTANCE; - - static { - DEFAULT_INSTANCE = new com.google.cloud.iot.v1.GetDeviceRequest(); - } - - public static com.google.cloud.iot.v1.GetDeviceRequest getDefaultInstance() { - return DEFAULT_INSTANCE; - } - - private static final com.google.protobuf.Parser PARSER = - new com.google.protobuf.AbstractParser() { - @java.lang.Override - public GetDeviceRequest parsePartialFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - Builder builder = newBuilder(); - try { - builder.mergeFrom(input, extensionRegistry); - } catch (com.google.protobuf.InvalidProtocolBufferException e) { - throw e.setUnfinishedMessage(builder.buildPartial()); - } catch (com.google.protobuf.UninitializedMessageException e) { - throw e.asInvalidProtocolBufferException().setUnfinishedMessage(builder.buildPartial()); - } catch (java.io.IOException e) { - throw new com.google.protobuf.InvalidProtocolBufferException(e) - .setUnfinishedMessage(builder.buildPartial()); - } - return builder.buildPartial(); - } - }; - - public static com.google.protobuf.Parser parser() { - return PARSER; - } - - @java.lang.Override - public com.google.protobuf.Parser getParserForType() { - return PARSER; - } - - @java.lang.Override - public com.google.cloud.iot.v1.GetDeviceRequest getDefaultInstanceForType() { - return DEFAULT_INSTANCE; - } -} diff --git a/proto-google-cloud-iot-v1/src/main/java/com/google/cloud/iot/v1/GetDeviceRequestOrBuilder.java b/proto-google-cloud-iot-v1/src/main/java/com/google/cloud/iot/v1/GetDeviceRequestOrBuilder.java deleted file mode 100644 index 424790a6..00000000 --- a/proto-google-cloud-iot-v1/src/main/java/com/google/cloud/iot/v1/GetDeviceRequestOrBuilder.java +++ /dev/null @@ -1,99 +0,0 @@ -/* - * Copyright 2020 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. - */ -// Generated by the protocol buffer compiler. DO NOT EDIT! -// source: google/cloud/iot/v1/device_manager.proto - -package com.google.cloud.iot.v1; - -public interface GetDeviceRequestOrBuilder - extends - // @@protoc_insertion_point(interface_extends:google.cloud.iot.v1.GetDeviceRequest) - com.google.protobuf.MessageOrBuilder { - - /** - * - * - *
-   * Required. The name of the device. For example,
-   * `projects/p0/locations/us-central1/registries/registry0/devices/device0` or
-   * `projects/p0/locations/us-central1/registries/registry0/devices/{num_id}`.
-   * 
- * - * - * string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } - * - * - * @return The name. - */ - java.lang.String getName(); - /** - * - * - *
-   * Required. The name of the device. For example,
-   * `projects/p0/locations/us-central1/registries/registry0/devices/device0` or
-   * `projects/p0/locations/us-central1/registries/registry0/devices/{num_id}`.
-   * 
- * - * - * string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } - * - * - * @return The bytes for name. - */ - com.google.protobuf.ByteString getNameBytes(); - - /** - * - * - *
-   * The fields of the `Device` resource to be returned in the response. If the
-   * field mask is unset or empty, all fields are returned. Fields have to be
-   * provided in snake_case format, for example: `last_heartbeat_time`.
-   * 
- * - * .google.protobuf.FieldMask field_mask = 2; - * - * @return Whether the fieldMask field is set. - */ - boolean hasFieldMask(); - /** - * - * - *
-   * The fields of the `Device` resource to be returned in the response. If the
-   * field mask is unset or empty, all fields are returned. Fields have to be
-   * provided in snake_case format, for example: `last_heartbeat_time`.
-   * 
- * - * .google.protobuf.FieldMask field_mask = 2; - * - * @return The fieldMask. - */ - com.google.protobuf.FieldMask getFieldMask(); - /** - * - * - *
-   * The fields of the `Device` resource to be returned in the response. If the
-   * field mask is unset or empty, all fields are returned. Fields have to be
-   * provided in snake_case format, for example: `last_heartbeat_time`.
-   * 
- * - * .google.protobuf.FieldMask field_mask = 2; - */ - com.google.protobuf.FieldMaskOrBuilder getFieldMaskOrBuilder(); -} diff --git a/proto-google-cloud-iot-v1/src/main/java/com/google/cloud/iot/v1/HttpConfig.java b/proto-google-cloud-iot-v1/src/main/java/com/google/cloud/iot/v1/HttpConfig.java deleted file mode 100644 index 3de1ec01..00000000 --- a/proto-google-cloud-iot-v1/src/main/java/com/google/cloud/iot/v1/HttpConfig.java +++ /dev/null @@ -1,589 +0,0 @@ -/* - * Copyright 2020 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. - */ -// Generated by the protocol buffer compiler. DO NOT EDIT! -// source: google/cloud/iot/v1/resources.proto - -package com.google.cloud.iot.v1; - -/** - * - * - *
- * The configuration of the HTTP bridge for a device registry.
- * 
- * - * Protobuf type {@code google.cloud.iot.v1.HttpConfig} - */ -public final class HttpConfig extends com.google.protobuf.GeneratedMessageV3 - implements - // @@protoc_insertion_point(message_implements:google.cloud.iot.v1.HttpConfig) - HttpConfigOrBuilder { - private static final long serialVersionUID = 0L; - // Use HttpConfig.newBuilder() to construct. - private HttpConfig(com.google.protobuf.GeneratedMessageV3.Builder builder) { - super(builder); - } - - private HttpConfig() { - httpEnabledState_ = 0; - } - - @java.lang.Override - @SuppressWarnings({"unused"}) - protected java.lang.Object newInstance(UnusedPrivateParameter unused) { - return new HttpConfig(); - } - - @java.lang.Override - public final com.google.protobuf.UnknownFieldSet getUnknownFields() { - return this.unknownFields; - } - - public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { - return com.google.cloud.iot.v1.ResourcesProto - .internal_static_google_cloud_iot_v1_HttpConfig_descriptor; - } - - @java.lang.Override - protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable - internalGetFieldAccessorTable() { - return com.google.cloud.iot.v1.ResourcesProto - .internal_static_google_cloud_iot_v1_HttpConfig_fieldAccessorTable - .ensureFieldAccessorsInitialized( - com.google.cloud.iot.v1.HttpConfig.class, - com.google.cloud.iot.v1.HttpConfig.Builder.class); - } - - public static final int HTTP_ENABLED_STATE_FIELD_NUMBER = 1; - private int httpEnabledState_; - /** - * - * - *
-   * If enabled, allows devices to use DeviceService via the HTTP protocol.
-   * Otherwise, any requests to DeviceService will fail for this registry.
-   * 
- * - * .google.cloud.iot.v1.HttpState http_enabled_state = 1; - * - * @return The enum numeric value on the wire for httpEnabledState. - */ - @java.lang.Override - public int getHttpEnabledStateValue() { - return httpEnabledState_; - } - /** - * - * - *
-   * If enabled, allows devices to use DeviceService via the HTTP protocol.
-   * Otherwise, any requests to DeviceService will fail for this registry.
-   * 
- * - * .google.cloud.iot.v1.HttpState http_enabled_state = 1; - * - * @return The httpEnabledState. - */ - @java.lang.Override - public com.google.cloud.iot.v1.HttpState getHttpEnabledState() { - @SuppressWarnings("deprecation") - com.google.cloud.iot.v1.HttpState result = - com.google.cloud.iot.v1.HttpState.valueOf(httpEnabledState_); - return result == null ? com.google.cloud.iot.v1.HttpState.UNRECOGNIZED : result; - } - - private byte memoizedIsInitialized = -1; - - @java.lang.Override - public final boolean isInitialized() { - byte isInitialized = memoizedIsInitialized; - if (isInitialized == 1) return true; - if (isInitialized == 0) return false; - - memoizedIsInitialized = 1; - return true; - } - - @java.lang.Override - public void writeTo(com.google.protobuf.CodedOutputStream output) throws java.io.IOException { - if (httpEnabledState_ != com.google.cloud.iot.v1.HttpState.HTTP_STATE_UNSPECIFIED.getNumber()) { - output.writeEnum(1, httpEnabledState_); - } - getUnknownFields().writeTo(output); - } - - @java.lang.Override - public int getSerializedSize() { - int size = memoizedSize; - if (size != -1) return size; - - size = 0; - if (httpEnabledState_ != com.google.cloud.iot.v1.HttpState.HTTP_STATE_UNSPECIFIED.getNumber()) { - size += com.google.protobuf.CodedOutputStream.computeEnumSize(1, httpEnabledState_); - } - size += getUnknownFields().getSerializedSize(); - memoizedSize = size; - return size; - } - - @java.lang.Override - public boolean equals(final java.lang.Object obj) { - if (obj == this) { - return true; - } - if (!(obj instanceof com.google.cloud.iot.v1.HttpConfig)) { - return super.equals(obj); - } - com.google.cloud.iot.v1.HttpConfig other = (com.google.cloud.iot.v1.HttpConfig) obj; - - if (httpEnabledState_ != other.httpEnabledState_) return false; - if (!getUnknownFields().equals(other.getUnknownFields())) return false; - return true; - } - - @java.lang.Override - public int hashCode() { - if (memoizedHashCode != 0) { - return memoizedHashCode; - } - int hash = 41; - hash = (19 * hash) + getDescriptor().hashCode(); - hash = (37 * hash) + HTTP_ENABLED_STATE_FIELD_NUMBER; - hash = (53 * hash) + httpEnabledState_; - hash = (29 * hash) + getUnknownFields().hashCode(); - memoizedHashCode = hash; - return hash; - } - - public static com.google.cloud.iot.v1.HttpConfig parseFrom(java.nio.ByteBuffer data) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); - } - - public static com.google.cloud.iot.v1.HttpConfig parseFrom( - java.nio.ByteBuffer data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); - } - - public static com.google.cloud.iot.v1.HttpConfig parseFrom(com.google.protobuf.ByteString data) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); - } - - public static com.google.cloud.iot.v1.HttpConfig parseFrom( - com.google.protobuf.ByteString data, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); - } - - public static com.google.cloud.iot.v1.HttpConfig parseFrom(byte[] data) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); - } - - public static com.google.cloud.iot.v1.HttpConfig parseFrom( - byte[] data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); - } - - public static com.google.cloud.iot.v1.HttpConfig parseFrom(java.io.InputStream input) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input); - } - - public static com.google.cloud.iot.v1.HttpConfig parseFrom( - java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3.parseWithIOException( - PARSER, input, extensionRegistry); - } - - public static com.google.cloud.iot.v1.HttpConfig parseDelimitedFrom(java.io.InputStream input) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3.parseDelimitedWithIOException(PARSER, input); - } - - public static com.google.cloud.iot.v1.HttpConfig parseDelimitedFrom( - java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3.parseDelimitedWithIOException( - PARSER, input, extensionRegistry); - } - - public static com.google.cloud.iot.v1.HttpConfig parseFrom( - com.google.protobuf.CodedInputStream input) throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input); - } - - public static com.google.cloud.iot.v1.HttpConfig parseFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3.parseWithIOException( - PARSER, input, extensionRegistry); - } - - @java.lang.Override - public Builder newBuilderForType() { - return newBuilder(); - } - - public static Builder newBuilder() { - return DEFAULT_INSTANCE.toBuilder(); - } - - public static Builder newBuilder(com.google.cloud.iot.v1.HttpConfig prototype) { - return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); - } - - @java.lang.Override - public Builder toBuilder() { - return this == DEFAULT_INSTANCE ? new Builder() : new Builder().mergeFrom(this); - } - - @java.lang.Override - protected Builder newBuilderForType(com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { - Builder builder = new Builder(parent); - return builder; - } - /** - * - * - *
-   * The configuration of the HTTP bridge for a device registry.
-   * 
- * - * Protobuf type {@code google.cloud.iot.v1.HttpConfig} - */ - public static final class Builder extends com.google.protobuf.GeneratedMessageV3.Builder - implements - // @@protoc_insertion_point(builder_implements:google.cloud.iot.v1.HttpConfig) - com.google.cloud.iot.v1.HttpConfigOrBuilder { - public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { - return com.google.cloud.iot.v1.ResourcesProto - .internal_static_google_cloud_iot_v1_HttpConfig_descriptor; - } - - @java.lang.Override - protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable - internalGetFieldAccessorTable() { - return com.google.cloud.iot.v1.ResourcesProto - .internal_static_google_cloud_iot_v1_HttpConfig_fieldAccessorTable - .ensureFieldAccessorsInitialized( - com.google.cloud.iot.v1.HttpConfig.class, - com.google.cloud.iot.v1.HttpConfig.Builder.class); - } - - // Construct using com.google.cloud.iot.v1.HttpConfig.newBuilder() - private Builder() {} - - private Builder(com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { - super(parent); - } - - @java.lang.Override - public Builder clear() { - super.clear(); - httpEnabledState_ = 0; - - return this; - } - - @java.lang.Override - public com.google.protobuf.Descriptors.Descriptor getDescriptorForType() { - return com.google.cloud.iot.v1.ResourcesProto - .internal_static_google_cloud_iot_v1_HttpConfig_descriptor; - } - - @java.lang.Override - public com.google.cloud.iot.v1.HttpConfig getDefaultInstanceForType() { - return com.google.cloud.iot.v1.HttpConfig.getDefaultInstance(); - } - - @java.lang.Override - public com.google.cloud.iot.v1.HttpConfig build() { - com.google.cloud.iot.v1.HttpConfig result = buildPartial(); - if (!result.isInitialized()) { - throw newUninitializedMessageException(result); - } - return result; - } - - @java.lang.Override - public com.google.cloud.iot.v1.HttpConfig buildPartial() { - com.google.cloud.iot.v1.HttpConfig result = new com.google.cloud.iot.v1.HttpConfig(this); - result.httpEnabledState_ = httpEnabledState_; - onBuilt(); - return result; - } - - @java.lang.Override - public Builder clone() { - return super.clone(); - } - - @java.lang.Override - public Builder setField( - com.google.protobuf.Descriptors.FieldDescriptor field, java.lang.Object value) { - return super.setField(field, value); - } - - @java.lang.Override - public Builder clearField(com.google.protobuf.Descriptors.FieldDescriptor field) { - return super.clearField(field); - } - - @java.lang.Override - public Builder clearOneof(com.google.protobuf.Descriptors.OneofDescriptor oneof) { - return super.clearOneof(oneof); - } - - @java.lang.Override - public Builder setRepeatedField( - com.google.protobuf.Descriptors.FieldDescriptor field, int index, java.lang.Object value) { - return super.setRepeatedField(field, index, value); - } - - @java.lang.Override - public Builder addRepeatedField( - com.google.protobuf.Descriptors.FieldDescriptor field, java.lang.Object value) { - return super.addRepeatedField(field, value); - } - - @java.lang.Override - public Builder mergeFrom(com.google.protobuf.Message other) { - if (other instanceof com.google.cloud.iot.v1.HttpConfig) { - return mergeFrom((com.google.cloud.iot.v1.HttpConfig) other); - } else { - super.mergeFrom(other); - return this; - } - } - - public Builder mergeFrom(com.google.cloud.iot.v1.HttpConfig other) { - if (other == com.google.cloud.iot.v1.HttpConfig.getDefaultInstance()) return this; - if (other.httpEnabledState_ != 0) { - setHttpEnabledStateValue(other.getHttpEnabledStateValue()); - } - this.mergeUnknownFields(other.getUnknownFields()); - onChanged(); - return this; - } - - @java.lang.Override - public final boolean isInitialized() { - return true; - } - - @java.lang.Override - public Builder mergeFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - if (extensionRegistry == null) { - throw new java.lang.NullPointerException(); - } - try { - boolean done = false; - while (!done) { - int tag = input.readTag(); - switch (tag) { - case 0: - done = true; - break; - case 8: - { - httpEnabledState_ = input.readEnum(); - - break; - } // case 8 - default: - { - if (!super.parseUnknownField(input, extensionRegistry, tag)) { - done = true; // was an endgroup tag - } - break; - } // default: - } // switch (tag) - } // while (!done) - } catch (com.google.protobuf.InvalidProtocolBufferException e) { - throw e.unwrapIOException(); - } finally { - onChanged(); - } // finally - return this; - } - - private int httpEnabledState_ = 0; - /** - * - * - *
-     * If enabled, allows devices to use DeviceService via the HTTP protocol.
-     * Otherwise, any requests to DeviceService will fail for this registry.
-     * 
- * - * .google.cloud.iot.v1.HttpState http_enabled_state = 1; - * - * @return The enum numeric value on the wire for httpEnabledState. - */ - @java.lang.Override - public int getHttpEnabledStateValue() { - return httpEnabledState_; - } - /** - * - * - *
-     * If enabled, allows devices to use DeviceService via the HTTP protocol.
-     * Otherwise, any requests to DeviceService will fail for this registry.
-     * 
- * - * .google.cloud.iot.v1.HttpState http_enabled_state = 1; - * - * @param value The enum numeric value on the wire for httpEnabledState to set. - * @return This builder for chaining. - */ - public Builder setHttpEnabledStateValue(int value) { - - httpEnabledState_ = value; - onChanged(); - return this; - } - /** - * - * - *
-     * If enabled, allows devices to use DeviceService via the HTTP protocol.
-     * Otherwise, any requests to DeviceService will fail for this registry.
-     * 
- * - * .google.cloud.iot.v1.HttpState http_enabled_state = 1; - * - * @return The httpEnabledState. - */ - @java.lang.Override - public com.google.cloud.iot.v1.HttpState getHttpEnabledState() { - @SuppressWarnings("deprecation") - com.google.cloud.iot.v1.HttpState result = - com.google.cloud.iot.v1.HttpState.valueOf(httpEnabledState_); - return result == null ? com.google.cloud.iot.v1.HttpState.UNRECOGNIZED : result; - } - /** - * - * - *
-     * If enabled, allows devices to use DeviceService via the HTTP protocol.
-     * Otherwise, any requests to DeviceService will fail for this registry.
-     * 
- * - * .google.cloud.iot.v1.HttpState http_enabled_state = 1; - * - * @param value The httpEnabledState to set. - * @return This builder for chaining. - */ - public Builder setHttpEnabledState(com.google.cloud.iot.v1.HttpState value) { - if (value == null) { - throw new NullPointerException(); - } - - httpEnabledState_ = value.getNumber(); - onChanged(); - return this; - } - /** - * - * - *
-     * If enabled, allows devices to use DeviceService via the HTTP protocol.
-     * Otherwise, any requests to DeviceService will fail for this registry.
-     * 
- * - * .google.cloud.iot.v1.HttpState http_enabled_state = 1; - * - * @return This builder for chaining. - */ - public Builder clearHttpEnabledState() { - - httpEnabledState_ = 0; - onChanged(); - return this; - } - - @java.lang.Override - public final Builder setUnknownFields(final com.google.protobuf.UnknownFieldSet unknownFields) { - return super.setUnknownFields(unknownFields); - } - - @java.lang.Override - public final Builder mergeUnknownFields( - final com.google.protobuf.UnknownFieldSet unknownFields) { - return super.mergeUnknownFields(unknownFields); - } - - // @@protoc_insertion_point(builder_scope:google.cloud.iot.v1.HttpConfig) - } - - // @@protoc_insertion_point(class_scope:google.cloud.iot.v1.HttpConfig) - private static final com.google.cloud.iot.v1.HttpConfig DEFAULT_INSTANCE; - - static { - DEFAULT_INSTANCE = new com.google.cloud.iot.v1.HttpConfig(); - } - - public static com.google.cloud.iot.v1.HttpConfig getDefaultInstance() { - return DEFAULT_INSTANCE; - } - - private static final com.google.protobuf.Parser PARSER = - new com.google.protobuf.AbstractParser() { - @java.lang.Override - public HttpConfig parsePartialFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - Builder builder = newBuilder(); - try { - builder.mergeFrom(input, extensionRegistry); - } catch (com.google.protobuf.InvalidProtocolBufferException e) { - throw e.setUnfinishedMessage(builder.buildPartial()); - } catch (com.google.protobuf.UninitializedMessageException e) { - throw e.asInvalidProtocolBufferException().setUnfinishedMessage(builder.buildPartial()); - } catch (java.io.IOException e) { - throw new com.google.protobuf.InvalidProtocolBufferException(e) - .setUnfinishedMessage(builder.buildPartial()); - } - return builder.buildPartial(); - } - }; - - public static com.google.protobuf.Parser parser() { - return PARSER; - } - - @java.lang.Override - public com.google.protobuf.Parser getParserForType() { - return PARSER; - } - - @java.lang.Override - public com.google.cloud.iot.v1.HttpConfig getDefaultInstanceForType() { - return DEFAULT_INSTANCE; - } -} diff --git a/proto-google-cloud-iot-v1/src/main/java/com/google/cloud/iot/v1/HttpConfigOrBuilder.java b/proto-google-cloud-iot-v1/src/main/java/com/google/cloud/iot/v1/HttpConfigOrBuilder.java deleted file mode 100644 index 843fcde6..00000000 --- a/proto-google-cloud-iot-v1/src/main/java/com/google/cloud/iot/v1/HttpConfigOrBuilder.java +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Copyright 2020 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. - */ -// Generated by the protocol buffer compiler. DO NOT EDIT! -// source: google/cloud/iot/v1/resources.proto - -package com.google.cloud.iot.v1; - -public interface HttpConfigOrBuilder - extends - // @@protoc_insertion_point(interface_extends:google.cloud.iot.v1.HttpConfig) - com.google.protobuf.MessageOrBuilder { - - /** - * - * - *
-   * If enabled, allows devices to use DeviceService via the HTTP protocol.
-   * Otherwise, any requests to DeviceService will fail for this registry.
-   * 
- * - * .google.cloud.iot.v1.HttpState http_enabled_state = 1; - * - * @return The enum numeric value on the wire for httpEnabledState. - */ - int getHttpEnabledStateValue(); - /** - * - * - *
-   * If enabled, allows devices to use DeviceService via the HTTP protocol.
-   * Otherwise, any requests to DeviceService will fail for this registry.
-   * 
- * - * .google.cloud.iot.v1.HttpState http_enabled_state = 1; - * - * @return The httpEnabledState. - */ - com.google.cloud.iot.v1.HttpState getHttpEnabledState(); -} diff --git a/proto-google-cloud-iot-v1/src/main/java/com/google/cloud/iot/v1/HttpState.java b/proto-google-cloud-iot-v1/src/main/java/com/google/cloud/iot/v1/HttpState.java deleted file mode 100644 index 10a5efb1..00000000 --- a/proto-google-cloud-iot-v1/src/main/java/com/google/cloud/iot/v1/HttpState.java +++ /dev/null @@ -1,179 +0,0 @@ -/* - * Copyright 2020 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. - */ -// Generated by the protocol buffer compiler. DO NOT EDIT! -// source: google/cloud/iot/v1/resources.proto - -package com.google.cloud.iot.v1; - -/** - * - * - *
- * Indicates whether DeviceService (HTTP) is enabled or disabled for the
- * registry. See the field description for details.
- * 
- * - * Protobuf enum {@code google.cloud.iot.v1.HttpState} - */ -public enum HttpState implements com.google.protobuf.ProtocolMessageEnum { - /** - * - * - *
-   * No HTTP state specified. If not specified, DeviceService will be
-   * enabled by default.
-   * 
- * - * HTTP_STATE_UNSPECIFIED = 0; - */ - HTTP_STATE_UNSPECIFIED(0), - /** - * - * - *
-   * Enables DeviceService (HTTP) service for the registry.
-   * 
- * - * HTTP_ENABLED = 1; - */ - HTTP_ENABLED(1), - /** - * - * - *
-   * Disables DeviceService (HTTP) service for the registry.
-   * 
- * - * HTTP_DISABLED = 2; - */ - HTTP_DISABLED(2), - UNRECOGNIZED(-1), - ; - - /** - * - * - *
-   * No HTTP state specified. If not specified, DeviceService will be
-   * enabled by default.
-   * 
- * - * HTTP_STATE_UNSPECIFIED = 0; - */ - public static final int HTTP_STATE_UNSPECIFIED_VALUE = 0; - /** - * - * - *
-   * Enables DeviceService (HTTP) service for the registry.
-   * 
- * - * HTTP_ENABLED = 1; - */ - public static final int HTTP_ENABLED_VALUE = 1; - /** - * - * - *
-   * Disables DeviceService (HTTP) service for the registry.
-   * 
- * - * HTTP_DISABLED = 2; - */ - public static final int HTTP_DISABLED_VALUE = 2; - - public final int getNumber() { - if (this == UNRECOGNIZED) { - throw new java.lang.IllegalArgumentException( - "Can't get the number of an unknown enum value."); - } - return value; - } - - /** - * @param value The numeric wire value of the corresponding enum entry. - * @return The enum associated with the given numeric wire value. - * @deprecated Use {@link #forNumber(int)} instead. - */ - @java.lang.Deprecated - public static HttpState valueOf(int value) { - return forNumber(value); - } - - /** - * @param value The numeric wire value of the corresponding enum entry. - * @return The enum associated with the given numeric wire value. - */ - public static HttpState forNumber(int value) { - switch (value) { - case 0: - return HTTP_STATE_UNSPECIFIED; - case 1: - return HTTP_ENABLED; - case 2: - return HTTP_DISABLED; - default: - return null; - } - } - - public static com.google.protobuf.Internal.EnumLiteMap internalGetValueMap() { - return internalValueMap; - } - - private static final com.google.protobuf.Internal.EnumLiteMap internalValueMap = - new com.google.protobuf.Internal.EnumLiteMap() { - public HttpState findValueByNumber(int number) { - return HttpState.forNumber(number); - } - }; - - public final com.google.protobuf.Descriptors.EnumValueDescriptor getValueDescriptor() { - if (this == UNRECOGNIZED) { - throw new java.lang.IllegalStateException( - "Can't get the descriptor of an unrecognized enum value."); - } - return getDescriptor().getValues().get(ordinal()); - } - - public final com.google.protobuf.Descriptors.EnumDescriptor getDescriptorForType() { - return getDescriptor(); - } - - public static final com.google.protobuf.Descriptors.EnumDescriptor getDescriptor() { - return com.google.cloud.iot.v1.ResourcesProto.getDescriptor().getEnumTypes().get(1); - } - - private static final HttpState[] VALUES = values(); - - public static HttpState valueOf(com.google.protobuf.Descriptors.EnumValueDescriptor desc) { - if (desc.getType() != getDescriptor()) { - throw new java.lang.IllegalArgumentException("EnumValueDescriptor is not for this type."); - } - if (desc.getIndex() == -1) { - return UNRECOGNIZED; - } - return VALUES[desc.getIndex()]; - } - - private final int value; - - private HttpState(int value) { - this.value = value; - } - - // @@protoc_insertion_point(enum_scope:google.cloud.iot.v1.HttpState) -} diff --git a/proto-google-cloud-iot-v1/src/main/java/com/google/cloud/iot/v1/ListDeviceConfigVersionsRequest.java b/proto-google-cloud-iot-v1/src/main/java/com/google/cloud/iot/v1/ListDeviceConfigVersionsRequest.java deleted file mode 100644 index aec376a1..00000000 --- a/proto-google-cloud-iot-v1/src/main/java/com/google/cloud/iot/v1/ListDeviceConfigVersionsRequest.java +++ /dev/null @@ -1,744 +0,0 @@ -/* - * Copyright 2020 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. - */ -// Generated by the protocol buffer compiler. DO NOT EDIT! -// source: google/cloud/iot/v1/device_manager.proto - -package com.google.cloud.iot.v1; - -/** - * - * - *
- * Request for `ListDeviceConfigVersions`.
- * 
- * - * Protobuf type {@code google.cloud.iot.v1.ListDeviceConfigVersionsRequest} - */ -public final class ListDeviceConfigVersionsRequest extends com.google.protobuf.GeneratedMessageV3 - implements - // @@protoc_insertion_point(message_implements:google.cloud.iot.v1.ListDeviceConfigVersionsRequest) - ListDeviceConfigVersionsRequestOrBuilder { - private static final long serialVersionUID = 0L; - // Use ListDeviceConfigVersionsRequest.newBuilder() to construct. - private ListDeviceConfigVersionsRequest( - com.google.protobuf.GeneratedMessageV3.Builder builder) { - super(builder); - } - - private ListDeviceConfigVersionsRequest() { - name_ = ""; - } - - @java.lang.Override - @SuppressWarnings({"unused"}) - protected java.lang.Object newInstance(UnusedPrivateParameter unused) { - return new ListDeviceConfigVersionsRequest(); - } - - @java.lang.Override - public final com.google.protobuf.UnknownFieldSet getUnknownFields() { - return this.unknownFields; - } - - public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { - return com.google.cloud.iot.v1.DeviceManagerProto - .internal_static_google_cloud_iot_v1_ListDeviceConfigVersionsRequest_descriptor; - } - - @java.lang.Override - protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable - internalGetFieldAccessorTable() { - return com.google.cloud.iot.v1.DeviceManagerProto - .internal_static_google_cloud_iot_v1_ListDeviceConfigVersionsRequest_fieldAccessorTable - .ensureFieldAccessorsInitialized( - com.google.cloud.iot.v1.ListDeviceConfigVersionsRequest.class, - com.google.cloud.iot.v1.ListDeviceConfigVersionsRequest.Builder.class); - } - - public static final int NAME_FIELD_NUMBER = 1; - private volatile java.lang.Object name_; - /** - * - * - *
-   * Required. The name of the device. For example,
-   * `projects/p0/locations/us-central1/registries/registry0/devices/device0` or
-   * `projects/p0/locations/us-central1/registries/registry0/devices/{num_id}`.
-   * 
- * - * - * string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } - * - * - * @return The name. - */ - @java.lang.Override - public java.lang.String getName() { - java.lang.Object ref = name_; - if (ref instanceof java.lang.String) { - return (java.lang.String) ref; - } else { - com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; - java.lang.String s = bs.toStringUtf8(); - name_ = s; - return s; - } - } - /** - * - * - *
-   * Required. The name of the device. For example,
-   * `projects/p0/locations/us-central1/registries/registry0/devices/device0` or
-   * `projects/p0/locations/us-central1/registries/registry0/devices/{num_id}`.
-   * 
- * - * - * string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } - * - * - * @return The bytes for name. - */ - @java.lang.Override - public com.google.protobuf.ByteString getNameBytes() { - java.lang.Object ref = name_; - if (ref instanceof java.lang.String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); - name_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - - public static final int NUM_VERSIONS_FIELD_NUMBER = 2; - private int numVersions_; - /** - * - * - *
-   * The number of versions to list. Versions are listed in decreasing order of
-   * the version number. The maximum number of versions retained is 10. If this
-   * value is zero, it will return all the versions available.
-   * 
- * - * int32 num_versions = 2; - * - * @return The numVersions. - */ - @java.lang.Override - public int getNumVersions() { - return numVersions_; - } - - private byte memoizedIsInitialized = -1; - - @java.lang.Override - public final boolean isInitialized() { - byte isInitialized = memoizedIsInitialized; - if (isInitialized == 1) return true; - if (isInitialized == 0) return false; - - memoizedIsInitialized = 1; - return true; - } - - @java.lang.Override - public void writeTo(com.google.protobuf.CodedOutputStream output) throws java.io.IOException { - if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(name_)) { - com.google.protobuf.GeneratedMessageV3.writeString(output, 1, name_); - } - if (numVersions_ != 0) { - output.writeInt32(2, numVersions_); - } - getUnknownFields().writeTo(output); - } - - @java.lang.Override - public int getSerializedSize() { - int size = memoizedSize; - if (size != -1) return size; - - size = 0; - if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(name_)) { - size += com.google.protobuf.GeneratedMessageV3.computeStringSize(1, name_); - } - if (numVersions_ != 0) { - size += com.google.protobuf.CodedOutputStream.computeInt32Size(2, numVersions_); - } - size += getUnknownFields().getSerializedSize(); - memoizedSize = size; - return size; - } - - @java.lang.Override - public boolean equals(final java.lang.Object obj) { - if (obj == this) { - return true; - } - if (!(obj instanceof com.google.cloud.iot.v1.ListDeviceConfigVersionsRequest)) { - return super.equals(obj); - } - com.google.cloud.iot.v1.ListDeviceConfigVersionsRequest other = - (com.google.cloud.iot.v1.ListDeviceConfigVersionsRequest) obj; - - if (!getName().equals(other.getName())) return false; - if (getNumVersions() != other.getNumVersions()) return false; - if (!getUnknownFields().equals(other.getUnknownFields())) return false; - return true; - } - - @java.lang.Override - public int hashCode() { - if (memoizedHashCode != 0) { - return memoizedHashCode; - } - int hash = 41; - hash = (19 * hash) + getDescriptor().hashCode(); - hash = (37 * hash) + NAME_FIELD_NUMBER; - hash = (53 * hash) + getName().hashCode(); - hash = (37 * hash) + NUM_VERSIONS_FIELD_NUMBER; - hash = (53 * hash) + getNumVersions(); - hash = (29 * hash) + getUnknownFields().hashCode(); - memoizedHashCode = hash; - return hash; - } - - public static com.google.cloud.iot.v1.ListDeviceConfigVersionsRequest parseFrom( - java.nio.ByteBuffer data) throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); - } - - public static com.google.cloud.iot.v1.ListDeviceConfigVersionsRequest parseFrom( - java.nio.ByteBuffer data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); - } - - public static com.google.cloud.iot.v1.ListDeviceConfigVersionsRequest parseFrom( - com.google.protobuf.ByteString data) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); - } - - public static com.google.cloud.iot.v1.ListDeviceConfigVersionsRequest parseFrom( - com.google.protobuf.ByteString data, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); - } - - public static com.google.cloud.iot.v1.ListDeviceConfigVersionsRequest parseFrom(byte[] data) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); - } - - public static com.google.cloud.iot.v1.ListDeviceConfigVersionsRequest parseFrom( - byte[] data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); - } - - public static com.google.cloud.iot.v1.ListDeviceConfigVersionsRequest parseFrom( - java.io.InputStream input) throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input); - } - - public static com.google.cloud.iot.v1.ListDeviceConfigVersionsRequest parseFrom( - java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3.parseWithIOException( - PARSER, input, extensionRegistry); - } - - public static com.google.cloud.iot.v1.ListDeviceConfigVersionsRequest parseDelimitedFrom( - java.io.InputStream input) throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3.parseDelimitedWithIOException(PARSER, input); - } - - public static com.google.cloud.iot.v1.ListDeviceConfigVersionsRequest parseDelimitedFrom( - java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3.parseDelimitedWithIOException( - PARSER, input, extensionRegistry); - } - - public static com.google.cloud.iot.v1.ListDeviceConfigVersionsRequest parseFrom( - com.google.protobuf.CodedInputStream input) throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input); - } - - public static com.google.cloud.iot.v1.ListDeviceConfigVersionsRequest parseFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3.parseWithIOException( - PARSER, input, extensionRegistry); - } - - @java.lang.Override - public Builder newBuilderForType() { - return newBuilder(); - } - - public static Builder newBuilder() { - return DEFAULT_INSTANCE.toBuilder(); - } - - public static Builder newBuilder( - com.google.cloud.iot.v1.ListDeviceConfigVersionsRequest prototype) { - return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); - } - - @java.lang.Override - public Builder toBuilder() { - return this == DEFAULT_INSTANCE ? new Builder() : new Builder().mergeFrom(this); - } - - @java.lang.Override - protected Builder newBuilderForType(com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { - Builder builder = new Builder(parent); - return builder; - } - /** - * - * - *
-   * Request for `ListDeviceConfigVersions`.
-   * 
- * - * Protobuf type {@code google.cloud.iot.v1.ListDeviceConfigVersionsRequest} - */ - public static final class Builder extends com.google.protobuf.GeneratedMessageV3.Builder - implements - // @@protoc_insertion_point(builder_implements:google.cloud.iot.v1.ListDeviceConfigVersionsRequest) - com.google.cloud.iot.v1.ListDeviceConfigVersionsRequestOrBuilder { - public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { - return com.google.cloud.iot.v1.DeviceManagerProto - .internal_static_google_cloud_iot_v1_ListDeviceConfigVersionsRequest_descriptor; - } - - @java.lang.Override - protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable - internalGetFieldAccessorTable() { - return com.google.cloud.iot.v1.DeviceManagerProto - .internal_static_google_cloud_iot_v1_ListDeviceConfigVersionsRequest_fieldAccessorTable - .ensureFieldAccessorsInitialized( - com.google.cloud.iot.v1.ListDeviceConfigVersionsRequest.class, - com.google.cloud.iot.v1.ListDeviceConfigVersionsRequest.Builder.class); - } - - // Construct using com.google.cloud.iot.v1.ListDeviceConfigVersionsRequest.newBuilder() - private Builder() {} - - private Builder(com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { - super(parent); - } - - @java.lang.Override - public Builder clear() { - super.clear(); - name_ = ""; - - numVersions_ = 0; - - return this; - } - - @java.lang.Override - public com.google.protobuf.Descriptors.Descriptor getDescriptorForType() { - return com.google.cloud.iot.v1.DeviceManagerProto - .internal_static_google_cloud_iot_v1_ListDeviceConfigVersionsRequest_descriptor; - } - - @java.lang.Override - public com.google.cloud.iot.v1.ListDeviceConfigVersionsRequest getDefaultInstanceForType() { - return com.google.cloud.iot.v1.ListDeviceConfigVersionsRequest.getDefaultInstance(); - } - - @java.lang.Override - public com.google.cloud.iot.v1.ListDeviceConfigVersionsRequest build() { - com.google.cloud.iot.v1.ListDeviceConfigVersionsRequest result = buildPartial(); - if (!result.isInitialized()) { - throw newUninitializedMessageException(result); - } - return result; - } - - @java.lang.Override - public com.google.cloud.iot.v1.ListDeviceConfigVersionsRequest buildPartial() { - com.google.cloud.iot.v1.ListDeviceConfigVersionsRequest result = - new com.google.cloud.iot.v1.ListDeviceConfigVersionsRequest(this); - result.name_ = name_; - result.numVersions_ = numVersions_; - onBuilt(); - return result; - } - - @java.lang.Override - public Builder clone() { - return super.clone(); - } - - @java.lang.Override - public Builder setField( - com.google.protobuf.Descriptors.FieldDescriptor field, java.lang.Object value) { - return super.setField(field, value); - } - - @java.lang.Override - public Builder clearField(com.google.protobuf.Descriptors.FieldDescriptor field) { - return super.clearField(field); - } - - @java.lang.Override - public Builder clearOneof(com.google.protobuf.Descriptors.OneofDescriptor oneof) { - return super.clearOneof(oneof); - } - - @java.lang.Override - public Builder setRepeatedField( - com.google.protobuf.Descriptors.FieldDescriptor field, int index, java.lang.Object value) { - return super.setRepeatedField(field, index, value); - } - - @java.lang.Override - public Builder addRepeatedField( - com.google.protobuf.Descriptors.FieldDescriptor field, java.lang.Object value) { - return super.addRepeatedField(field, value); - } - - @java.lang.Override - public Builder mergeFrom(com.google.protobuf.Message other) { - if (other instanceof com.google.cloud.iot.v1.ListDeviceConfigVersionsRequest) { - return mergeFrom((com.google.cloud.iot.v1.ListDeviceConfigVersionsRequest) other); - } else { - super.mergeFrom(other); - return this; - } - } - - public Builder mergeFrom(com.google.cloud.iot.v1.ListDeviceConfigVersionsRequest other) { - if (other == com.google.cloud.iot.v1.ListDeviceConfigVersionsRequest.getDefaultInstance()) - return this; - if (!other.getName().isEmpty()) { - name_ = other.name_; - onChanged(); - } - if (other.getNumVersions() != 0) { - setNumVersions(other.getNumVersions()); - } - this.mergeUnknownFields(other.getUnknownFields()); - onChanged(); - return this; - } - - @java.lang.Override - public final boolean isInitialized() { - return true; - } - - @java.lang.Override - public Builder mergeFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - if (extensionRegistry == null) { - throw new java.lang.NullPointerException(); - } - try { - boolean done = false; - while (!done) { - int tag = input.readTag(); - switch (tag) { - case 0: - done = true; - break; - case 10: - { - name_ = input.readStringRequireUtf8(); - - break; - } // case 10 - case 16: - { - numVersions_ = input.readInt32(); - - break; - } // case 16 - default: - { - if (!super.parseUnknownField(input, extensionRegistry, tag)) { - done = true; // was an endgroup tag - } - break; - } // default: - } // switch (tag) - } // while (!done) - } catch (com.google.protobuf.InvalidProtocolBufferException e) { - throw e.unwrapIOException(); - } finally { - onChanged(); - } // finally - return this; - } - - private java.lang.Object name_ = ""; - /** - * - * - *
-     * Required. The name of the device. For example,
-     * `projects/p0/locations/us-central1/registries/registry0/devices/device0` or
-     * `projects/p0/locations/us-central1/registries/registry0/devices/{num_id}`.
-     * 
- * - * - * string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } - * - * - * @return The name. - */ - public java.lang.String getName() { - java.lang.Object ref = name_; - if (!(ref instanceof java.lang.String)) { - com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; - java.lang.String s = bs.toStringUtf8(); - name_ = s; - return s; - } else { - return (java.lang.String) ref; - } - } - /** - * - * - *
-     * Required. The name of the device. For example,
-     * `projects/p0/locations/us-central1/registries/registry0/devices/device0` or
-     * `projects/p0/locations/us-central1/registries/registry0/devices/{num_id}`.
-     * 
- * - * - * string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } - * - * - * @return The bytes for name. - */ - public com.google.protobuf.ByteString getNameBytes() { - java.lang.Object ref = name_; - if (ref instanceof String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); - name_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - /** - * - * - *
-     * Required. The name of the device. For example,
-     * `projects/p0/locations/us-central1/registries/registry0/devices/device0` or
-     * `projects/p0/locations/us-central1/registries/registry0/devices/{num_id}`.
-     * 
- * - * - * string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } - * - * - * @param value The name to set. - * @return This builder for chaining. - */ - public Builder setName(java.lang.String value) { - if (value == null) { - throw new NullPointerException(); - } - - name_ = value; - onChanged(); - return this; - } - /** - * - * - *
-     * Required. The name of the device. For example,
-     * `projects/p0/locations/us-central1/registries/registry0/devices/device0` or
-     * `projects/p0/locations/us-central1/registries/registry0/devices/{num_id}`.
-     * 
- * - * - * string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } - * - * - * @return This builder for chaining. - */ - public Builder clearName() { - - name_ = getDefaultInstance().getName(); - onChanged(); - return this; - } - /** - * - * - *
-     * Required. The name of the device. For example,
-     * `projects/p0/locations/us-central1/registries/registry0/devices/device0` or
-     * `projects/p0/locations/us-central1/registries/registry0/devices/{num_id}`.
-     * 
- * - * - * string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } - * - * - * @param value The bytes for name to set. - * @return This builder for chaining. - */ - public Builder setNameBytes(com.google.protobuf.ByteString value) { - if (value == null) { - throw new NullPointerException(); - } - checkByteStringIsUtf8(value); - - name_ = value; - onChanged(); - return this; - } - - private int numVersions_; - /** - * - * - *
-     * The number of versions to list. Versions are listed in decreasing order of
-     * the version number. The maximum number of versions retained is 10. If this
-     * value is zero, it will return all the versions available.
-     * 
- * - * int32 num_versions = 2; - * - * @return The numVersions. - */ - @java.lang.Override - public int getNumVersions() { - return numVersions_; - } - /** - * - * - *
-     * The number of versions to list. Versions are listed in decreasing order of
-     * the version number. The maximum number of versions retained is 10. If this
-     * value is zero, it will return all the versions available.
-     * 
- * - * int32 num_versions = 2; - * - * @param value The numVersions to set. - * @return This builder for chaining. - */ - public Builder setNumVersions(int value) { - - numVersions_ = value; - onChanged(); - return this; - } - /** - * - * - *
-     * The number of versions to list. Versions are listed in decreasing order of
-     * the version number. The maximum number of versions retained is 10. If this
-     * value is zero, it will return all the versions available.
-     * 
- * - * int32 num_versions = 2; - * - * @return This builder for chaining. - */ - public Builder clearNumVersions() { - - numVersions_ = 0; - onChanged(); - return this; - } - - @java.lang.Override - public final Builder setUnknownFields(final com.google.protobuf.UnknownFieldSet unknownFields) { - return super.setUnknownFields(unknownFields); - } - - @java.lang.Override - public final Builder mergeUnknownFields( - final com.google.protobuf.UnknownFieldSet unknownFields) { - return super.mergeUnknownFields(unknownFields); - } - - // @@protoc_insertion_point(builder_scope:google.cloud.iot.v1.ListDeviceConfigVersionsRequest) - } - - // @@protoc_insertion_point(class_scope:google.cloud.iot.v1.ListDeviceConfigVersionsRequest) - private static final com.google.cloud.iot.v1.ListDeviceConfigVersionsRequest DEFAULT_INSTANCE; - - static { - DEFAULT_INSTANCE = new com.google.cloud.iot.v1.ListDeviceConfigVersionsRequest(); - } - - public static com.google.cloud.iot.v1.ListDeviceConfigVersionsRequest getDefaultInstance() { - return DEFAULT_INSTANCE; - } - - private static final com.google.protobuf.Parser PARSER = - new com.google.protobuf.AbstractParser() { - @java.lang.Override - public ListDeviceConfigVersionsRequest parsePartialFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - Builder builder = newBuilder(); - try { - builder.mergeFrom(input, extensionRegistry); - } catch (com.google.protobuf.InvalidProtocolBufferException e) { - throw e.setUnfinishedMessage(builder.buildPartial()); - } catch (com.google.protobuf.UninitializedMessageException e) { - throw e.asInvalidProtocolBufferException().setUnfinishedMessage(builder.buildPartial()); - } catch (java.io.IOException e) { - throw new com.google.protobuf.InvalidProtocolBufferException(e) - .setUnfinishedMessage(builder.buildPartial()); - } - return builder.buildPartial(); - } - }; - - public static com.google.protobuf.Parser parser() { - return PARSER; - } - - @java.lang.Override - public com.google.protobuf.Parser getParserForType() { - return PARSER; - } - - @java.lang.Override - public com.google.cloud.iot.v1.ListDeviceConfigVersionsRequest getDefaultInstanceForType() { - return DEFAULT_INSTANCE; - } -} diff --git a/proto-google-cloud-iot-v1/src/main/java/com/google/cloud/iot/v1/ListDeviceConfigVersionsRequestOrBuilder.java b/proto-google-cloud-iot-v1/src/main/java/com/google/cloud/iot/v1/ListDeviceConfigVersionsRequestOrBuilder.java deleted file mode 100644 index ee1066be..00000000 --- a/proto-google-cloud-iot-v1/src/main/java/com/google/cloud/iot/v1/ListDeviceConfigVersionsRequestOrBuilder.java +++ /dev/null @@ -1,73 +0,0 @@ -/* - * Copyright 2020 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. - */ -// Generated by the protocol buffer compiler. DO NOT EDIT! -// source: google/cloud/iot/v1/device_manager.proto - -package com.google.cloud.iot.v1; - -public interface ListDeviceConfigVersionsRequestOrBuilder - extends - // @@protoc_insertion_point(interface_extends:google.cloud.iot.v1.ListDeviceConfigVersionsRequest) - com.google.protobuf.MessageOrBuilder { - - /** - * - * - *
-   * Required. The name of the device. For example,
-   * `projects/p0/locations/us-central1/registries/registry0/devices/device0` or
-   * `projects/p0/locations/us-central1/registries/registry0/devices/{num_id}`.
-   * 
- * - * - * string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } - * - * - * @return The name. - */ - java.lang.String getName(); - /** - * - * - *
-   * Required. The name of the device. For example,
-   * `projects/p0/locations/us-central1/registries/registry0/devices/device0` or
-   * `projects/p0/locations/us-central1/registries/registry0/devices/{num_id}`.
-   * 
- * - * - * string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } - * - * - * @return The bytes for name. - */ - com.google.protobuf.ByteString getNameBytes(); - - /** - * - * - *
-   * The number of versions to list. Versions are listed in decreasing order of
-   * the version number. The maximum number of versions retained is 10. If this
-   * value is zero, it will return all the versions available.
-   * 
- * - * int32 num_versions = 2; - * - * @return The numVersions. - */ - int getNumVersions(); -} diff --git a/proto-google-cloud-iot-v1/src/main/java/com/google/cloud/iot/v1/ListDeviceConfigVersionsResponse.java b/proto-google-cloud-iot-v1/src/main/java/com/google/cloud/iot/v1/ListDeviceConfigVersionsResponse.java deleted file mode 100644 index 4efe80a6..00000000 --- a/proto-google-cloud-iot-v1/src/main/java/com/google/cloud/iot/v1/ListDeviceConfigVersionsResponse.java +++ /dev/null @@ -1,955 +0,0 @@ -/* - * Copyright 2020 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. - */ -// Generated by the protocol buffer compiler. DO NOT EDIT! -// source: google/cloud/iot/v1/device_manager.proto - -package com.google.cloud.iot.v1; - -/** - * - * - *
- * Response for `ListDeviceConfigVersions`.
- * 
- * - * Protobuf type {@code google.cloud.iot.v1.ListDeviceConfigVersionsResponse} - */ -public final class ListDeviceConfigVersionsResponse extends com.google.protobuf.GeneratedMessageV3 - implements - // @@protoc_insertion_point(message_implements:google.cloud.iot.v1.ListDeviceConfigVersionsResponse) - ListDeviceConfigVersionsResponseOrBuilder { - private static final long serialVersionUID = 0L; - // Use ListDeviceConfigVersionsResponse.newBuilder() to construct. - private ListDeviceConfigVersionsResponse( - com.google.protobuf.GeneratedMessageV3.Builder builder) { - super(builder); - } - - private ListDeviceConfigVersionsResponse() { - deviceConfigs_ = java.util.Collections.emptyList(); - } - - @java.lang.Override - @SuppressWarnings({"unused"}) - protected java.lang.Object newInstance(UnusedPrivateParameter unused) { - return new ListDeviceConfigVersionsResponse(); - } - - @java.lang.Override - public final com.google.protobuf.UnknownFieldSet getUnknownFields() { - return this.unknownFields; - } - - public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { - return com.google.cloud.iot.v1.DeviceManagerProto - .internal_static_google_cloud_iot_v1_ListDeviceConfigVersionsResponse_descriptor; - } - - @java.lang.Override - protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable - internalGetFieldAccessorTable() { - return com.google.cloud.iot.v1.DeviceManagerProto - .internal_static_google_cloud_iot_v1_ListDeviceConfigVersionsResponse_fieldAccessorTable - .ensureFieldAccessorsInitialized( - com.google.cloud.iot.v1.ListDeviceConfigVersionsResponse.class, - com.google.cloud.iot.v1.ListDeviceConfigVersionsResponse.Builder.class); - } - - public static final int DEVICE_CONFIGS_FIELD_NUMBER = 1; - private java.util.List deviceConfigs_; - /** - * - * - *
-   * The device configuration for the last few versions. Versions are listed
-   * in decreasing order, starting from the most recent one.
-   * 
- * - * repeated .google.cloud.iot.v1.DeviceConfig device_configs = 1; - */ - @java.lang.Override - public java.util.List getDeviceConfigsList() { - return deviceConfigs_; - } - /** - * - * - *
-   * The device configuration for the last few versions. Versions are listed
-   * in decreasing order, starting from the most recent one.
-   * 
- * - * repeated .google.cloud.iot.v1.DeviceConfig device_configs = 1; - */ - @java.lang.Override - public java.util.List - getDeviceConfigsOrBuilderList() { - return deviceConfigs_; - } - /** - * - * - *
-   * The device configuration for the last few versions. Versions are listed
-   * in decreasing order, starting from the most recent one.
-   * 
- * - * repeated .google.cloud.iot.v1.DeviceConfig device_configs = 1; - */ - @java.lang.Override - public int getDeviceConfigsCount() { - return deviceConfigs_.size(); - } - /** - * - * - *
-   * The device configuration for the last few versions. Versions are listed
-   * in decreasing order, starting from the most recent one.
-   * 
- * - * repeated .google.cloud.iot.v1.DeviceConfig device_configs = 1; - */ - @java.lang.Override - public com.google.cloud.iot.v1.DeviceConfig getDeviceConfigs(int index) { - return deviceConfigs_.get(index); - } - /** - * - * - *
-   * The device configuration for the last few versions. Versions are listed
-   * in decreasing order, starting from the most recent one.
-   * 
- * - * repeated .google.cloud.iot.v1.DeviceConfig device_configs = 1; - */ - @java.lang.Override - public com.google.cloud.iot.v1.DeviceConfigOrBuilder getDeviceConfigsOrBuilder(int index) { - return deviceConfigs_.get(index); - } - - private byte memoizedIsInitialized = -1; - - @java.lang.Override - public final boolean isInitialized() { - byte isInitialized = memoizedIsInitialized; - if (isInitialized == 1) return true; - if (isInitialized == 0) return false; - - memoizedIsInitialized = 1; - return true; - } - - @java.lang.Override - public void writeTo(com.google.protobuf.CodedOutputStream output) throws java.io.IOException { - for (int i = 0; i < deviceConfigs_.size(); i++) { - output.writeMessage(1, deviceConfigs_.get(i)); - } - getUnknownFields().writeTo(output); - } - - @java.lang.Override - public int getSerializedSize() { - int size = memoizedSize; - if (size != -1) return size; - - size = 0; - for (int i = 0; i < deviceConfigs_.size(); i++) { - size += com.google.protobuf.CodedOutputStream.computeMessageSize(1, deviceConfigs_.get(i)); - } - size += getUnknownFields().getSerializedSize(); - memoizedSize = size; - return size; - } - - @java.lang.Override - public boolean equals(final java.lang.Object obj) { - if (obj == this) { - return true; - } - if (!(obj instanceof com.google.cloud.iot.v1.ListDeviceConfigVersionsResponse)) { - return super.equals(obj); - } - com.google.cloud.iot.v1.ListDeviceConfigVersionsResponse other = - (com.google.cloud.iot.v1.ListDeviceConfigVersionsResponse) obj; - - if (!getDeviceConfigsList().equals(other.getDeviceConfigsList())) return false; - if (!getUnknownFields().equals(other.getUnknownFields())) return false; - return true; - } - - @java.lang.Override - public int hashCode() { - if (memoizedHashCode != 0) { - return memoizedHashCode; - } - int hash = 41; - hash = (19 * hash) + getDescriptor().hashCode(); - if (getDeviceConfigsCount() > 0) { - hash = (37 * hash) + DEVICE_CONFIGS_FIELD_NUMBER; - hash = (53 * hash) + getDeviceConfigsList().hashCode(); - } - hash = (29 * hash) + getUnknownFields().hashCode(); - memoizedHashCode = hash; - return hash; - } - - public static com.google.cloud.iot.v1.ListDeviceConfigVersionsResponse parseFrom( - java.nio.ByteBuffer data) throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); - } - - public static com.google.cloud.iot.v1.ListDeviceConfigVersionsResponse parseFrom( - java.nio.ByteBuffer data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); - } - - public static com.google.cloud.iot.v1.ListDeviceConfigVersionsResponse parseFrom( - com.google.protobuf.ByteString data) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); - } - - public static com.google.cloud.iot.v1.ListDeviceConfigVersionsResponse parseFrom( - com.google.protobuf.ByteString data, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); - } - - public static com.google.cloud.iot.v1.ListDeviceConfigVersionsResponse parseFrom(byte[] data) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); - } - - public static com.google.cloud.iot.v1.ListDeviceConfigVersionsResponse parseFrom( - byte[] data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); - } - - public static com.google.cloud.iot.v1.ListDeviceConfigVersionsResponse parseFrom( - java.io.InputStream input) throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input); - } - - public static com.google.cloud.iot.v1.ListDeviceConfigVersionsResponse parseFrom( - java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3.parseWithIOException( - PARSER, input, extensionRegistry); - } - - public static com.google.cloud.iot.v1.ListDeviceConfigVersionsResponse parseDelimitedFrom( - java.io.InputStream input) throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3.parseDelimitedWithIOException(PARSER, input); - } - - public static com.google.cloud.iot.v1.ListDeviceConfigVersionsResponse parseDelimitedFrom( - java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3.parseDelimitedWithIOException( - PARSER, input, extensionRegistry); - } - - public static com.google.cloud.iot.v1.ListDeviceConfigVersionsResponse parseFrom( - com.google.protobuf.CodedInputStream input) throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input); - } - - public static com.google.cloud.iot.v1.ListDeviceConfigVersionsResponse parseFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3.parseWithIOException( - PARSER, input, extensionRegistry); - } - - @java.lang.Override - public Builder newBuilderForType() { - return newBuilder(); - } - - public static Builder newBuilder() { - return DEFAULT_INSTANCE.toBuilder(); - } - - public static Builder newBuilder( - com.google.cloud.iot.v1.ListDeviceConfigVersionsResponse prototype) { - return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); - } - - @java.lang.Override - public Builder toBuilder() { - return this == DEFAULT_INSTANCE ? new Builder() : new Builder().mergeFrom(this); - } - - @java.lang.Override - protected Builder newBuilderForType(com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { - Builder builder = new Builder(parent); - return builder; - } - /** - * - * - *
-   * Response for `ListDeviceConfigVersions`.
-   * 
- * - * Protobuf type {@code google.cloud.iot.v1.ListDeviceConfigVersionsResponse} - */ - public static final class Builder extends com.google.protobuf.GeneratedMessageV3.Builder - implements - // @@protoc_insertion_point(builder_implements:google.cloud.iot.v1.ListDeviceConfigVersionsResponse) - com.google.cloud.iot.v1.ListDeviceConfigVersionsResponseOrBuilder { - public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { - return com.google.cloud.iot.v1.DeviceManagerProto - .internal_static_google_cloud_iot_v1_ListDeviceConfigVersionsResponse_descriptor; - } - - @java.lang.Override - protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable - internalGetFieldAccessorTable() { - return com.google.cloud.iot.v1.DeviceManagerProto - .internal_static_google_cloud_iot_v1_ListDeviceConfigVersionsResponse_fieldAccessorTable - .ensureFieldAccessorsInitialized( - com.google.cloud.iot.v1.ListDeviceConfigVersionsResponse.class, - com.google.cloud.iot.v1.ListDeviceConfigVersionsResponse.Builder.class); - } - - // Construct using com.google.cloud.iot.v1.ListDeviceConfigVersionsResponse.newBuilder() - private Builder() {} - - private Builder(com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { - super(parent); - } - - @java.lang.Override - public Builder clear() { - super.clear(); - if (deviceConfigsBuilder_ == null) { - deviceConfigs_ = java.util.Collections.emptyList(); - } else { - deviceConfigs_ = null; - deviceConfigsBuilder_.clear(); - } - bitField0_ = (bitField0_ & ~0x00000001); - return this; - } - - @java.lang.Override - public com.google.protobuf.Descriptors.Descriptor getDescriptorForType() { - return com.google.cloud.iot.v1.DeviceManagerProto - .internal_static_google_cloud_iot_v1_ListDeviceConfigVersionsResponse_descriptor; - } - - @java.lang.Override - public com.google.cloud.iot.v1.ListDeviceConfigVersionsResponse getDefaultInstanceForType() { - return com.google.cloud.iot.v1.ListDeviceConfigVersionsResponse.getDefaultInstance(); - } - - @java.lang.Override - public com.google.cloud.iot.v1.ListDeviceConfigVersionsResponse build() { - com.google.cloud.iot.v1.ListDeviceConfigVersionsResponse result = buildPartial(); - if (!result.isInitialized()) { - throw newUninitializedMessageException(result); - } - return result; - } - - @java.lang.Override - public com.google.cloud.iot.v1.ListDeviceConfigVersionsResponse buildPartial() { - com.google.cloud.iot.v1.ListDeviceConfigVersionsResponse result = - new com.google.cloud.iot.v1.ListDeviceConfigVersionsResponse(this); - int from_bitField0_ = bitField0_; - if (deviceConfigsBuilder_ == null) { - if (((bitField0_ & 0x00000001) != 0)) { - deviceConfigs_ = java.util.Collections.unmodifiableList(deviceConfigs_); - bitField0_ = (bitField0_ & ~0x00000001); - } - result.deviceConfigs_ = deviceConfigs_; - } else { - result.deviceConfigs_ = deviceConfigsBuilder_.build(); - } - onBuilt(); - return result; - } - - @java.lang.Override - public Builder clone() { - return super.clone(); - } - - @java.lang.Override - public Builder setField( - com.google.protobuf.Descriptors.FieldDescriptor field, java.lang.Object value) { - return super.setField(field, value); - } - - @java.lang.Override - public Builder clearField(com.google.protobuf.Descriptors.FieldDescriptor field) { - return super.clearField(field); - } - - @java.lang.Override - public Builder clearOneof(com.google.protobuf.Descriptors.OneofDescriptor oneof) { - return super.clearOneof(oneof); - } - - @java.lang.Override - public Builder setRepeatedField( - com.google.protobuf.Descriptors.FieldDescriptor field, int index, java.lang.Object value) { - return super.setRepeatedField(field, index, value); - } - - @java.lang.Override - public Builder addRepeatedField( - com.google.protobuf.Descriptors.FieldDescriptor field, java.lang.Object value) { - return super.addRepeatedField(field, value); - } - - @java.lang.Override - public Builder mergeFrom(com.google.protobuf.Message other) { - if (other instanceof com.google.cloud.iot.v1.ListDeviceConfigVersionsResponse) { - return mergeFrom((com.google.cloud.iot.v1.ListDeviceConfigVersionsResponse) other); - } else { - super.mergeFrom(other); - return this; - } - } - - public Builder mergeFrom(com.google.cloud.iot.v1.ListDeviceConfigVersionsResponse other) { - if (other == com.google.cloud.iot.v1.ListDeviceConfigVersionsResponse.getDefaultInstance()) - return this; - if (deviceConfigsBuilder_ == null) { - if (!other.deviceConfigs_.isEmpty()) { - if (deviceConfigs_.isEmpty()) { - deviceConfigs_ = other.deviceConfigs_; - bitField0_ = (bitField0_ & ~0x00000001); - } else { - ensureDeviceConfigsIsMutable(); - deviceConfigs_.addAll(other.deviceConfigs_); - } - onChanged(); - } - } else { - if (!other.deviceConfigs_.isEmpty()) { - if (deviceConfigsBuilder_.isEmpty()) { - deviceConfigsBuilder_.dispose(); - deviceConfigsBuilder_ = null; - deviceConfigs_ = other.deviceConfigs_; - bitField0_ = (bitField0_ & ~0x00000001); - deviceConfigsBuilder_ = - com.google.protobuf.GeneratedMessageV3.alwaysUseFieldBuilders - ? getDeviceConfigsFieldBuilder() - : null; - } else { - deviceConfigsBuilder_.addAllMessages(other.deviceConfigs_); - } - } - } - this.mergeUnknownFields(other.getUnknownFields()); - onChanged(); - return this; - } - - @java.lang.Override - public final boolean isInitialized() { - return true; - } - - @java.lang.Override - public Builder mergeFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - if (extensionRegistry == null) { - throw new java.lang.NullPointerException(); - } - try { - boolean done = false; - while (!done) { - int tag = input.readTag(); - switch (tag) { - case 0: - done = true; - break; - case 10: - { - com.google.cloud.iot.v1.DeviceConfig m = - input.readMessage( - com.google.cloud.iot.v1.DeviceConfig.parser(), extensionRegistry); - if (deviceConfigsBuilder_ == null) { - ensureDeviceConfigsIsMutable(); - deviceConfigs_.add(m); - } else { - deviceConfigsBuilder_.addMessage(m); - } - break; - } // case 10 - default: - { - if (!super.parseUnknownField(input, extensionRegistry, tag)) { - done = true; // was an endgroup tag - } - break; - } // default: - } // switch (tag) - } // while (!done) - } catch (com.google.protobuf.InvalidProtocolBufferException e) { - throw e.unwrapIOException(); - } finally { - onChanged(); - } // finally - return this; - } - - private int bitField0_; - - private java.util.List deviceConfigs_ = - java.util.Collections.emptyList(); - - private void ensureDeviceConfigsIsMutable() { - if (!((bitField0_ & 0x00000001) != 0)) { - deviceConfigs_ = - new java.util.ArrayList(deviceConfigs_); - bitField0_ |= 0x00000001; - } - } - - private com.google.protobuf.RepeatedFieldBuilderV3< - com.google.cloud.iot.v1.DeviceConfig, - com.google.cloud.iot.v1.DeviceConfig.Builder, - com.google.cloud.iot.v1.DeviceConfigOrBuilder> - deviceConfigsBuilder_; - - /** - * - * - *
-     * The device configuration for the last few versions. Versions are listed
-     * in decreasing order, starting from the most recent one.
-     * 
- * - * repeated .google.cloud.iot.v1.DeviceConfig device_configs = 1; - */ - public java.util.List getDeviceConfigsList() { - if (deviceConfigsBuilder_ == null) { - return java.util.Collections.unmodifiableList(deviceConfigs_); - } else { - return deviceConfigsBuilder_.getMessageList(); - } - } - /** - * - * - *
-     * The device configuration for the last few versions. Versions are listed
-     * in decreasing order, starting from the most recent one.
-     * 
- * - * repeated .google.cloud.iot.v1.DeviceConfig device_configs = 1; - */ - public int getDeviceConfigsCount() { - if (deviceConfigsBuilder_ == null) { - return deviceConfigs_.size(); - } else { - return deviceConfigsBuilder_.getCount(); - } - } - /** - * - * - *
-     * The device configuration for the last few versions. Versions are listed
-     * in decreasing order, starting from the most recent one.
-     * 
- * - * repeated .google.cloud.iot.v1.DeviceConfig device_configs = 1; - */ - public com.google.cloud.iot.v1.DeviceConfig getDeviceConfigs(int index) { - if (deviceConfigsBuilder_ == null) { - return deviceConfigs_.get(index); - } else { - return deviceConfigsBuilder_.getMessage(index); - } - } - /** - * - * - *
-     * The device configuration for the last few versions. Versions are listed
-     * in decreasing order, starting from the most recent one.
-     * 
- * - * repeated .google.cloud.iot.v1.DeviceConfig device_configs = 1; - */ - public Builder setDeviceConfigs(int index, com.google.cloud.iot.v1.DeviceConfig value) { - if (deviceConfigsBuilder_ == null) { - if (value == null) { - throw new NullPointerException(); - } - ensureDeviceConfigsIsMutable(); - deviceConfigs_.set(index, value); - onChanged(); - } else { - deviceConfigsBuilder_.setMessage(index, value); - } - return this; - } - /** - * - * - *
-     * The device configuration for the last few versions. Versions are listed
-     * in decreasing order, starting from the most recent one.
-     * 
- * - * repeated .google.cloud.iot.v1.DeviceConfig device_configs = 1; - */ - public Builder setDeviceConfigs( - int index, com.google.cloud.iot.v1.DeviceConfig.Builder builderForValue) { - if (deviceConfigsBuilder_ == null) { - ensureDeviceConfigsIsMutable(); - deviceConfigs_.set(index, builderForValue.build()); - onChanged(); - } else { - deviceConfigsBuilder_.setMessage(index, builderForValue.build()); - } - return this; - } - /** - * - * - *
-     * The device configuration for the last few versions. Versions are listed
-     * in decreasing order, starting from the most recent one.
-     * 
- * - * repeated .google.cloud.iot.v1.DeviceConfig device_configs = 1; - */ - public Builder addDeviceConfigs(com.google.cloud.iot.v1.DeviceConfig value) { - if (deviceConfigsBuilder_ == null) { - if (value == null) { - throw new NullPointerException(); - } - ensureDeviceConfigsIsMutable(); - deviceConfigs_.add(value); - onChanged(); - } else { - deviceConfigsBuilder_.addMessage(value); - } - return this; - } - /** - * - * - *
-     * The device configuration for the last few versions. Versions are listed
-     * in decreasing order, starting from the most recent one.
-     * 
- * - * repeated .google.cloud.iot.v1.DeviceConfig device_configs = 1; - */ - public Builder addDeviceConfigs(int index, com.google.cloud.iot.v1.DeviceConfig value) { - if (deviceConfigsBuilder_ == null) { - if (value == null) { - throw new NullPointerException(); - } - ensureDeviceConfigsIsMutable(); - deviceConfigs_.add(index, value); - onChanged(); - } else { - deviceConfigsBuilder_.addMessage(index, value); - } - return this; - } - /** - * - * - *
-     * The device configuration for the last few versions. Versions are listed
-     * in decreasing order, starting from the most recent one.
-     * 
- * - * repeated .google.cloud.iot.v1.DeviceConfig device_configs = 1; - */ - public Builder addDeviceConfigs(com.google.cloud.iot.v1.DeviceConfig.Builder builderForValue) { - if (deviceConfigsBuilder_ == null) { - ensureDeviceConfigsIsMutable(); - deviceConfigs_.add(builderForValue.build()); - onChanged(); - } else { - deviceConfigsBuilder_.addMessage(builderForValue.build()); - } - return this; - } - /** - * - * - *
-     * The device configuration for the last few versions. Versions are listed
-     * in decreasing order, starting from the most recent one.
-     * 
- * - * repeated .google.cloud.iot.v1.DeviceConfig device_configs = 1; - */ - public Builder addDeviceConfigs( - int index, com.google.cloud.iot.v1.DeviceConfig.Builder builderForValue) { - if (deviceConfigsBuilder_ == null) { - ensureDeviceConfigsIsMutable(); - deviceConfigs_.add(index, builderForValue.build()); - onChanged(); - } else { - deviceConfigsBuilder_.addMessage(index, builderForValue.build()); - } - return this; - } - /** - * - * - *
-     * The device configuration for the last few versions. Versions are listed
-     * in decreasing order, starting from the most recent one.
-     * 
- * - * repeated .google.cloud.iot.v1.DeviceConfig device_configs = 1; - */ - public Builder addAllDeviceConfigs( - java.lang.Iterable values) { - if (deviceConfigsBuilder_ == null) { - ensureDeviceConfigsIsMutable(); - com.google.protobuf.AbstractMessageLite.Builder.addAll(values, deviceConfigs_); - onChanged(); - } else { - deviceConfigsBuilder_.addAllMessages(values); - } - return this; - } - /** - * - * - *
-     * The device configuration for the last few versions. Versions are listed
-     * in decreasing order, starting from the most recent one.
-     * 
- * - * repeated .google.cloud.iot.v1.DeviceConfig device_configs = 1; - */ - public Builder clearDeviceConfigs() { - if (deviceConfigsBuilder_ == null) { - deviceConfigs_ = java.util.Collections.emptyList(); - bitField0_ = (bitField0_ & ~0x00000001); - onChanged(); - } else { - deviceConfigsBuilder_.clear(); - } - return this; - } - /** - * - * - *
-     * The device configuration for the last few versions. Versions are listed
-     * in decreasing order, starting from the most recent one.
-     * 
- * - * repeated .google.cloud.iot.v1.DeviceConfig device_configs = 1; - */ - public Builder removeDeviceConfigs(int index) { - if (deviceConfigsBuilder_ == null) { - ensureDeviceConfigsIsMutable(); - deviceConfigs_.remove(index); - onChanged(); - } else { - deviceConfigsBuilder_.remove(index); - } - return this; - } - /** - * - * - *
-     * The device configuration for the last few versions. Versions are listed
-     * in decreasing order, starting from the most recent one.
-     * 
- * - * repeated .google.cloud.iot.v1.DeviceConfig device_configs = 1; - */ - public com.google.cloud.iot.v1.DeviceConfig.Builder getDeviceConfigsBuilder(int index) { - return getDeviceConfigsFieldBuilder().getBuilder(index); - } - /** - * - * - *
-     * The device configuration for the last few versions. Versions are listed
-     * in decreasing order, starting from the most recent one.
-     * 
- * - * repeated .google.cloud.iot.v1.DeviceConfig device_configs = 1; - */ - public com.google.cloud.iot.v1.DeviceConfigOrBuilder getDeviceConfigsOrBuilder(int index) { - if (deviceConfigsBuilder_ == null) { - return deviceConfigs_.get(index); - } else { - return deviceConfigsBuilder_.getMessageOrBuilder(index); - } - } - /** - * - * - *
-     * The device configuration for the last few versions. Versions are listed
-     * in decreasing order, starting from the most recent one.
-     * 
- * - * repeated .google.cloud.iot.v1.DeviceConfig device_configs = 1; - */ - public java.util.List - getDeviceConfigsOrBuilderList() { - if (deviceConfigsBuilder_ != null) { - return deviceConfigsBuilder_.getMessageOrBuilderList(); - } else { - return java.util.Collections.unmodifiableList(deviceConfigs_); - } - } - /** - * - * - *
-     * The device configuration for the last few versions. Versions are listed
-     * in decreasing order, starting from the most recent one.
-     * 
- * - * repeated .google.cloud.iot.v1.DeviceConfig device_configs = 1; - */ - public com.google.cloud.iot.v1.DeviceConfig.Builder addDeviceConfigsBuilder() { - return getDeviceConfigsFieldBuilder() - .addBuilder(com.google.cloud.iot.v1.DeviceConfig.getDefaultInstance()); - } - /** - * - * - *
-     * The device configuration for the last few versions. Versions are listed
-     * in decreasing order, starting from the most recent one.
-     * 
- * - * repeated .google.cloud.iot.v1.DeviceConfig device_configs = 1; - */ - public com.google.cloud.iot.v1.DeviceConfig.Builder addDeviceConfigsBuilder(int index) { - return getDeviceConfigsFieldBuilder() - .addBuilder(index, com.google.cloud.iot.v1.DeviceConfig.getDefaultInstance()); - } - /** - * - * - *
-     * The device configuration for the last few versions. Versions are listed
-     * in decreasing order, starting from the most recent one.
-     * 
- * - * repeated .google.cloud.iot.v1.DeviceConfig device_configs = 1; - */ - public java.util.List - getDeviceConfigsBuilderList() { - return getDeviceConfigsFieldBuilder().getBuilderList(); - } - - private com.google.protobuf.RepeatedFieldBuilderV3< - com.google.cloud.iot.v1.DeviceConfig, - com.google.cloud.iot.v1.DeviceConfig.Builder, - com.google.cloud.iot.v1.DeviceConfigOrBuilder> - getDeviceConfigsFieldBuilder() { - if (deviceConfigsBuilder_ == null) { - deviceConfigsBuilder_ = - new com.google.protobuf.RepeatedFieldBuilderV3< - com.google.cloud.iot.v1.DeviceConfig, - com.google.cloud.iot.v1.DeviceConfig.Builder, - com.google.cloud.iot.v1.DeviceConfigOrBuilder>( - deviceConfigs_, - ((bitField0_ & 0x00000001) != 0), - getParentForChildren(), - isClean()); - deviceConfigs_ = null; - } - return deviceConfigsBuilder_; - } - - @java.lang.Override - public final Builder setUnknownFields(final com.google.protobuf.UnknownFieldSet unknownFields) { - return super.setUnknownFields(unknownFields); - } - - @java.lang.Override - public final Builder mergeUnknownFields( - final com.google.protobuf.UnknownFieldSet unknownFields) { - return super.mergeUnknownFields(unknownFields); - } - - // @@protoc_insertion_point(builder_scope:google.cloud.iot.v1.ListDeviceConfigVersionsResponse) - } - - // @@protoc_insertion_point(class_scope:google.cloud.iot.v1.ListDeviceConfigVersionsResponse) - private static final com.google.cloud.iot.v1.ListDeviceConfigVersionsResponse DEFAULT_INSTANCE; - - static { - DEFAULT_INSTANCE = new com.google.cloud.iot.v1.ListDeviceConfigVersionsResponse(); - } - - public static com.google.cloud.iot.v1.ListDeviceConfigVersionsResponse getDefaultInstance() { - return DEFAULT_INSTANCE; - } - - private static final com.google.protobuf.Parser PARSER = - new com.google.protobuf.AbstractParser() { - @java.lang.Override - public ListDeviceConfigVersionsResponse parsePartialFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - Builder builder = newBuilder(); - try { - builder.mergeFrom(input, extensionRegistry); - } catch (com.google.protobuf.InvalidProtocolBufferException e) { - throw e.setUnfinishedMessage(builder.buildPartial()); - } catch (com.google.protobuf.UninitializedMessageException e) { - throw e.asInvalidProtocolBufferException().setUnfinishedMessage(builder.buildPartial()); - } catch (java.io.IOException e) { - throw new com.google.protobuf.InvalidProtocolBufferException(e) - .setUnfinishedMessage(builder.buildPartial()); - } - return builder.buildPartial(); - } - }; - - public static com.google.protobuf.Parser parser() { - return PARSER; - } - - @java.lang.Override - public com.google.protobuf.Parser getParserForType() { - return PARSER; - } - - @java.lang.Override - public com.google.cloud.iot.v1.ListDeviceConfigVersionsResponse getDefaultInstanceForType() { - return DEFAULT_INSTANCE; - } -} diff --git a/proto-google-cloud-iot-v1/src/main/java/com/google/cloud/iot/v1/ListDeviceConfigVersionsResponseOrBuilder.java b/proto-google-cloud-iot-v1/src/main/java/com/google/cloud/iot/v1/ListDeviceConfigVersionsResponseOrBuilder.java deleted file mode 100644 index 2784e68a..00000000 --- a/proto-google-cloud-iot-v1/src/main/java/com/google/cloud/iot/v1/ListDeviceConfigVersionsResponseOrBuilder.java +++ /dev/null @@ -1,82 +0,0 @@ -/* - * Copyright 2020 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. - */ -// Generated by the protocol buffer compiler. DO NOT EDIT! -// source: google/cloud/iot/v1/device_manager.proto - -package com.google.cloud.iot.v1; - -public interface ListDeviceConfigVersionsResponseOrBuilder - extends - // @@protoc_insertion_point(interface_extends:google.cloud.iot.v1.ListDeviceConfigVersionsResponse) - com.google.protobuf.MessageOrBuilder { - - /** - * - * - *
-   * The device configuration for the last few versions. Versions are listed
-   * in decreasing order, starting from the most recent one.
-   * 
- * - * repeated .google.cloud.iot.v1.DeviceConfig device_configs = 1; - */ - java.util.List getDeviceConfigsList(); - /** - * - * - *
-   * The device configuration for the last few versions. Versions are listed
-   * in decreasing order, starting from the most recent one.
-   * 
- * - * repeated .google.cloud.iot.v1.DeviceConfig device_configs = 1; - */ - com.google.cloud.iot.v1.DeviceConfig getDeviceConfigs(int index); - /** - * - * - *
-   * The device configuration for the last few versions. Versions are listed
-   * in decreasing order, starting from the most recent one.
-   * 
- * - * repeated .google.cloud.iot.v1.DeviceConfig device_configs = 1; - */ - int getDeviceConfigsCount(); - /** - * - * - *
-   * The device configuration for the last few versions. Versions are listed
-   * in decreasing order, starting from the most recent one.
-   * 
- * - * repeated .google.cloud.iot.v1.DeviceConfig device_configs = 1; - */ - java.util.List - getDeviceConfigsOrBuilderList(); - /** - * - * - *
-   * The device configuration for the last few versions. Versions are listed
-   * in decreasing order, starting from the most recent one.
-   * 
- * - * repeated .google.cloud.iot.v1.DeviceConfig device_configs = 1; - */ - com.google.cloud.iot.v1.DeviceConfigOrBuilder getDeviceConfigsOrBuilder(int index); -} diff --git a/proto-google-cloud-iot-v1/src/main/java/com/google/cloud/iot/v1/ListDeviceRegistriesRequest.java b/proto-google-cloud-iot-v1/src/main/java/com/google/cloud/iot/v1/ListDeviceRegistriesRequest.java deleted file mode 100644 index 31ea44d5..00000000 --- a/proto-google-cloud-iot-v1/src/main/java/com/google/cloud/iot/v1/ListDeviceRegistriesRequest.java +++ /dev/null @@ -1,931 +0,0 @@ -/* - * Copyright 2020 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. - */ -// Generated by the protocol buffer compiler. DO NOT EDIT! -// source: google/cloud/iot/v1/device_manager.proto - -package com.google.cloud.iot.v1; - -/** - * - * - *
- * Request for `ListDeviceRegistries`.
- * 
- * - * Protobuf type {@code google.cloud.iot.v1.ListDeviceRegistriesRequest} - */ -public final class ListDeviceRegistriesRequest extends com.google.protobuf.GeneratedMessageV3 - implements - // @@protoc_insertion_point(message_implements:google.cloud.iot.v1.ListDeviceRegistriesRequest) - ListDeviceRegistriesRequestOrBuilder { - private static final long serialVersionUID = 0L; - // Use ListDeviceRegistriesRequest.newBuilder() to construct. - private ListDeviceRegistriesRequest(com.google.protobuf.GeneratedMessageV3.Builder builder) { - super(builder); - } - - private ListDeviceRegistriesRequest() { - parent_ = ""; - pageToken_ = ""; - } - - @java.lang.Override - @SuppressWarnings({"unused"}) - protected java.lang.Object newInstance(UnusedPrivateParameter unused) { - return new ListDeviceRegistriesRequest(); - } - - @java.lang.Override - public final com.google.protobuf.UnknownFieldSet getUnknownFields() { - return this.unknownFields; - } - - public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { - return com.google.cloud.iot.v1.DeviceManagerProto - .internal_static_google_cloud_iot_v1_ListDeviceRegistriesRequest_descriptor; - } - - @java.lang.Override - protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable - internalGetFieldAccessorTable() { - return com.google.cloud.iot.v1.DeviceManagerProto - .internal_static_google_cloud_iot_v1_ListDeviceRegistriesRequest_fieldAccessorTable - .ensureFieldAccessorsInitialized( - com.google.cloud.iot.v1.ListDeviceRegistriesRequest.class, - com.google.cloud.iot.v1.ListDeviceRegistriesRequest.Builder.class); - } - - public static final int PARENT_FIELD_NUMBER = 1; - private volatile java.lang.Object parent_; - /** - * - * - *
-   * Required. The project and cloud region path. For example,
-   * `projects/example-project/locations/us-central1`.
-   * 
- * - * - * string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } - * - * - * @return The parent. - */ - @java.lang.Override - public java.lang.String getParent() { - java.lang.Object ref = parent_; - if (ref instanceof java.lang.String) { - return (java.lang.String) ref; - } else { - com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; - java.lang.String s = bs.toStringUtf8(); - parent_ = s; - return s; - } - } - /** - * - * - *
-   * Required. The project and cloud region path. For example,
-   * `projects/example-project/locations/us-central1`.
-   * 
- * - * - * string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } - * - * - * @return The bytes for parent. - */ - @java.lang.Override - public com.google.protobuf.ByteString getParentBytes() { - java.lang.Object ref = parent_; - if (ref instanceof java.lang.String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); - parent_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - - public static final int PAGE_SIZE_FIELD_NUMBER = 2; - private int pageSize_; - /** - * - * - *
-   * The maximum number of registries to return in the response. If this value
-   * is zero, the service will select a default size. A call may return fewer
-   * objects than requested. A non-empty `next_page_token` in the response
-   * indicates that more data is available.
-   * 
- * - * int32 page_size = 2; - * - * @return The pageSize. - */ - @java.lang.Override - public int getPageSize() { - return pageSize_; - } - - public static final int PAGE_TOKEN_FIELD_NUMBER = 3; - private volatile java.lang.Object pageToken_; - /** - * - * - *
-   * The value returned by the last `ListDeviceRegistriesResponse`; indicates
-   * that this is a continuation of a prior `ListDeviceRegistries` call and
-   * the system should return the next page of data.
-   * 
- * - * string page_token = 3; - * - * @return The pageToken. - */ - @java.lang.Override - public java.lang.String getPageToken() { - java.lang.Object ref = pageToken_; - if (ref instanceof java.lang.String) { - return (java.lang.String) ref; - } else { - com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; - java.lang.String s = bs.toStringUtf8(); - pageToken_ = s; - return s; - } - } - /** - * - * - *
-   * The value returned by the last `ListDeviceRegistriesResponse`; indicates
-   * that this is a continuation of a prior `ListDeviceRegistries` call and
-   * the system should return the next page of data.
-   * 
- * - * string page_token = 3; - * - * @return The bytes for pageToken. - */ - @java.lang.Override - public com.google.protobuf.ByteString getPageTokenBytes() { - java.lang.Object ref = pageToken_; - if (ref instanceof java.lang.String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); - pageToken_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - - private byte memoizedIsInitialized = -1; - - @java.lang.Override - public final boolean isInitialized() { - byte isInitialized = memoizedIsInitialized; - if (isInitialized == 1) return true; - if (isInitialized == 0) return false; - - memoizedIsInitialized = 1; - return true; - } - - @java.lang.Override - public void writeTo(com.google.protobuf.CodedOutputStream output) throws java.io.IOException { - if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(parent_)) { - com.google.protobuf.GeneratedMessageV3.writeString(output, 1, parent_); - } - if (pageSize_ != 0) { - output.writeInt32(2, pageSize_); - } - if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(pageToken_)) { - com.google.protobuf.GeneratedMessageV3.writeString(output, 3, pageToken_); - } - getUnknownFields().writeTo(output); - } - - @java.lang.Override - public int getSerializedSize() { - int size = memoizedSize; - if (size != -1) return size; - - size = 0; - if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(parent_)) { - size += com.google.protobuf.GeneratedMessageV3.computeStringSize(1, parent_); - } - if (pageSize_ != 0) { - size += com.google.protobuf.CodedOutputStream.computeInt32Size(2, pageSize_); - } - if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(pageToken_)) { - size += com.google.protobuf.GeneratedMessageV3.computeStringSize(3, pageToken_); - } - size += getUnknownFields().getSerializedSize(); - memoizedSize = size; - return size; - } - - @java.lang.Override - public boolean equals(final java.lang.Object obj) { - if (obj == this) { - return true; - } - if (!(obj instanceof com.google.cloud.iot.v1.ListDeviceRegistriesRequest)) { - return super.equals(obj); - } - com.google.cloud.iot.v1.ListDeviceRegistriesRequest other = - (com.google.cloud.iot.v1.ListDeviceRegistriesRequest) obj; - - if (!getParent().equals(other.getParent())) return false; - if (getPageSize() != other.getPageSize()) return false; - if (!getPageToken().equals(other.getPageToken())) return false; - if (!getUnknownFields().equals(other.getUnknownFields())) return false; - return true; - } - - @java.lang.Override - public int hashCode() { - if (memoizedHashCode != 0) { - return memoizedHashCode; - } - int hash = 41; - hash = (19 * hash) + getDescriptor().hashCode(); - hash = (37 * hash) + PARENT_FIELD_NUMBER; - hash = (53 * hash) + getParent().hashCode(); - hash = (37 * hash) + PAGE_SIZE_FIELD_NUMBER; - hash = (53 * hash) + getPageSize(); - hash = (37 * hash) + PAGE_TOKEN_FIELD_NUMBER; - hash = (53 * hash) + getPageToken().hashCode(); - hash = (29 * hash) + getUnknownFields().hashCode(); - memoizedHashCode = hash; - return hash; - } - - public static com.google.cloud.iot.v1.ListDeviceRegistriesRequest parseFrom( - java.nio.ByteBuffer data) throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); - } - - public static com.google.cloud.iot.v1.ListDeviceRegistriesRequest parseFrom( - java.nio.ByteBuffer data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); - } - - public static com.google.cloud.iot.v1.ListDeviceRegistriesRequest parseFrom( - com.google.protobuf.ByteString data) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); - } - - public static com.google.cloud.iot.v1.ListDeviceRegistriesRequest parseFrom( - com.google.protobuf.ByteString data, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); - } - - public static com.google.cloud.iot.v1.ListDeviceRegistriesRequest parseFrom(byte[] data) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); - } - - public static com.google.cloud.iot.v1.ListDeviceRegistriesRequest parseFrom( - byte[] data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); - } - - public static com.google.cloud.iot.v1.ListDeviceRegistriesRequest parseFrom( - java.io.InputStream input) throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input); - } - - public static com.google.cloud.iot.v1.ListDeviceRegistriesRequest parseFrom( - java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3.parseWithIOException( - PARSER, input, extensionRegistry); - } - - public static com.google.cloud.iot.v1.ListDeviceRegistriesRequest parseDelimitedFrom( - java.io.InputStream input) throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3.parseDelimitedWithIOException(PARSER, input); - } - - public static com.google.cloud.iot.v1.ListDeviceRegistriesRequest parseDelimitedFrom( - java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3.parseDelimitedWithIOException( - PARSER, input, extensionRegistry); - } - - public static com.google.cloud.iot.v1.ListDeviceRegistriesRequest parseFrom( - com.google.protobuf.CodedInputStream input) throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input); - } - - public static com.google.cloud.iot.v1.ListDeviceRegistriesRequest parseFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3.parseWithIOException( - PARSER, input, extensionRegistry); - } - - @java.lang.Override - public Builder newBuilderForType() { - return newBuilder(); - } - - public static Builder newBuilder() { - return DEFAULT_INSTANCE.toBuilder(); - } - - public static Builder newBuilder(com.google.cloud.iot.v1.ListDeviceRegistriesRequest prototype) { - return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); - } - - @java.lang.Override - public Builder toBuilder() { - return this == DEFAULT_INSTANCE ? new Builder() : new Builder().mergeFrom(this); - } - - @java.lang.Override - protected Builder newBuilderForType(com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { - Builder builder = new Builder(parent); - return builder; - } - /** - * - * - *
-   * Request for `ListDeviceRegistries`.
-   * 
- * - * Protobuf type {@code google.cloud.iot.v1.ListDeviceRegistriesRequest} - */ - public static final class Builder extends com.google.protobuf.GeneratedMessageV3.Builder - implements - // @@protoc_insertion_point(builder_implements:google.cloud.iot.v1.ListDeviceRegistriesRequest) - com.google.cloud.iot.v1.ListDeviceRegistriesRequestOrBuilder { - public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { - return com.google.cloud.iot.v1.DeviceManagerProto - .internal_static_google_cloud_iot_v1_ListDeviceRegistriesRequest_descriptor; - } - - @java.lang.Override - protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable - internalGetFieldAccessorTable() { - return com.google.cloud.iot.v1.DeviceManagerProto - .internal_static_google_cloud_iot_v1_ListDeviceRegistriesRequest_fieldAccessorTable - .ensureFieldAccessorsInitialized( - com.google.cloud.iot.v1.ListDeviceRegistriesRequest.class, - com.google.cloud.iot.v1.ListDeviceRegistriesRequest.Builder.class); - } - - // Construct using com.google.cloud.iot.v1.ListDeviceRegistriesRequest.newBuilder() - private Builder() {} - - private Builder(com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { - super(parent); - } - - @java.lang.Override - public Builder clear() { - super.clear(); - parent_ = ""; - - pageSize_ = 0; - - pageToken_ = ""; - - return this; - } - - @java.lang.Override - public com.google.protobuf.Descriptors.Descriptor getDescriptorForType() { - return com.google.cloud.iot.v1.DeviceManagerProto - .internal_static_google_cloud_iot_v1_ListDeviceRegistriesRequest_descriptor; - } - - @java.lang.Override - public com.google.cloud.iot.v1.ListDeviceRegistriesRequest getDefaultInstanceForType() { - return com.google.cloud.iot.v1.ListDeviceRegistriesRequest.getDefaultInstance(); - } - - @java.lang.Override - public com.google.cloud.iot.v1.ListDeviceRegistriesRequest build() { - com.google.cloud.iot.v1.ListDeviceRegistriesRequest result = buildPartial(); - if (!result.isInitialized()) { - throw newUninitializedMessageException(result); - } - return result; - } - - @java.lang.Override - public com.google.cloud.iot.v1.ListDeviceRegistriesRequest buildPartial() { - com.google.cloud.iot.v1.ListDeviceRegistriesRequest result = - new com.google.cloud.iot.v1.ListDeviceRegistriesRequest(this); - result.parent_ = parent_; - result.pageSize_ = pageSize_; - result.pageToken_ = pageToken_; - onBuilt(); - return result; - } - - @java.lang.Override - public Builder clone() { - return super.clone(); - } - - @java.lang.Override - public Builder setField( - com.google.protobuf.Descriptors.FieldDescriptor field, java.lang.Object value) { - return super.setField(field, value); - } - - @java.lang.Override - public Builder clearField(com.google.protobuf.Descriptors.FieldDescriptor field) { - return super.clearField(field); - } - - @java.lang.Override - public Builder clearOneof(com.google.protobuf.Descriptors.OneofDescriptor oneof) { - return super.clearOneof(oneof); - } - - @java.lang.Override - public Builder setRepeatedField( - com.google.protobuf.Descriptors.FieldDescriptor field, int index, java.lang.Object value) { - return super.setRepeatedField(field, index, value); - } - - @java.lang.Override - public Builder addRepeatedField( - com.google.protobuf.Descriptors.FieldDescriptor field, java.lang.Object value) { - return super.addRepeatedField(field, value); - } - - @java.lang.Override - public Builder mergeFrom(com.google.protobuf.Message other) { - if (other instanceof com.google.cloud.iot.v1.ListDeviceRegistriesRequest) { - return mergeFrom((com.google.cloud.iot.v1.ListDeviceRegistriesRequest) other); - } else { - super.mergeFrom(other); - return this; - } - } - - public Builder mergeFrom(com.google.cloud.iot.v1.ListDeviceRegistriesRequest other) { - if (other == com.google.cloud.iot.v1.ListDeviceRegistriesRequest.getDefaultInstance()) - return this; - if (!other.getParent().isEmpty()) { - parent_ = other.parent_; - onChanged(); - } - if (other.getPageSize() != 0) { - setPageSize(other.getPageSize()); - } - if (!other.getPageToken().isEmpty()) { - pageToken_ = other.pageToken_; - onChanged(); - } - this.mergeUnknownFields(other.getUnknownFields()); - onChanged(); - return this; - } - - @java.lang.Override - public final boolean isInitialized() { - return true; - } - - @java.lang.Override - public Builder mergeFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - if (extensionRegistry == null) { - throw new java.lang.NullPointerException(); - } - try { - boolean done = false; - while (!done) { - int tag = input.readTag(); - switch (tag) { - case 0: - done = true; - break; - case 10: - { - parent_ = input.readStringRequireUtf8(); - - break; - } // case 10 - case 16: - { - pageSize_ = input.readInt32(); - - break; - } // case 16 - case 26: - { - pageToken_ = input.readStringRequireUtf8(); - - break; - } // case 26 - default: - { - if (!super.parseUnknownField(input, extensionRegistry, tag)) { - done = true; // was an endgroup tag - } - break; - } // default: - } // switch (tag) - } // while (!done) - } catch (com.google.protobuf.InvalidProtocolBufferException e) { - throw e.unwrapIOException(); - } finally { - onChanged(); - } // finally - return this; - } - - private java.lang.Object parent_ = ""; - /** - * - * - *
-     * Required. The project and cloud region path. For example,
-     * `projects/example-project/locations/us-central1`.
-     * 
- * - * - * string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } - * - * - * @return The parent. - */ - public java.lang.String getParent() { - java.lang.Object ref = parent_; - if (!(ref instanceof java.lang.String)) { - com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; - java.lang.String s = bs.toStringUtf8(); - parent_ = s; - return s; - } else { - return (java.lang.String) ref; - } - } - /** - * - * - *
-     * Required. The project and cloud region path. For example,
-     * `projects/example-project/locations/us-central1`.
-     * 
- * - * - * string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } - * - * - * @return The bytes for parent. - */ - public com.google.protobuf.ByteString getParentBytes() { - java.lang.Object ref = parent_; - if (ref instanceof String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); - parent_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - /** - * - * - *
-     * Required. The project and cloud region path. For example,
-     * `projects/example-project/locations/us-central1`.
-     * 
- * - * - * string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } - * - * - * @param value The parent to set. - * @return This builder for chaining. - */ - public Builder setParent(java.lang.String value) { - if (value == null) { - throw new NullPointerException(); - } - - parent_ = value; - onChanged(); - return this; - } - /** - * - * - *
-     * Required. The project and cloud region path. For example,
-     * `projects/example-project/locations/us-central1`.
-     * 
- * - * - * string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } - * - * - * @return This builder for chaining. - */ - public Builder clearParent() { - - parent_ = getDefaultInstance().getParent(); - onChanged(); - return this; - } - /** - * - * - *
-     * Required. The project and cloud region path. For example,
-     * `projects/example-project/locations/us-central1`.
-     * 
- * - * - * string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } - * - * - * @param value The bytes for parent to set. - * @return This builder for chaining. - */ - public Builder setParentBytes(com.google.protobuf.ByteString value) { - if (value == null) { - throw new NullPointerException(); - } - checkByteStringIsUtf8(value); - - parent_ = value; - onChanged(); - return this; - } - - private int pageSize_; - /** - * - * - *
-     * The maximum number of registries to return in the response. If this value
-     * is zero, the service will select a default size. A call may return fewer
-     * objects than requested. A non-empty `next_page_token` in the response
-     * indicates that more data is available.
-     * 
- * - * int32 page_size = 2; - * - * @return The pageSize. - */ - @java.lang.Override - public int getPageSize() { - return pageSize_; - } - /** - * - * - *
-     * The maximum number of registries to return in the response. If this value
-     * is zero, the service will select a default size. A call may return fewer
-     * objects than requested. A non-empty `next_page_token` in the response
-     * indicates that more data is available.
-     * 
- * - * int32 page_size = 2; - * - * @param value The pageSize to set. - * @return This builder for chaining. - */ - public Builder setPageSize(int value) { - - pageSize_ = value; - onChanged(); - return this; - } - /** - * - * - *
-     * The maximum number of registries to return in the response. If this value
-     * is zero, the service will select a default size. A call may return fewer
-     * objects than requested. A non-empty `next_page_token` in the response
-     * indicates that more data is available.
-     * 
- * - * int32 page_size = 2; - * - * @return This builder for chaining. - */ - public Builder clearPageSize() { - - pageSize_ = 0; - onChanged(); - return this; - } - - private java.lang.Object pageToken_ = ""; - /** - * - * - *
-     * The value returned by the last `ListDeviceRegistriesResponse`; indicates
-     * that this is a continuation of a prior `ListDeviceRegistries` call and
-     * the system should return the next page of data.
-     * 
- * - * string page_token = 3; - * - * @return The pageToken. - */ - public java.lang.String getPageToken() { - java.lang.Object ref = pageToken_; - if (!(ref instanceof java.lang.String)) { - com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; - java.lang.String s = bs.toStringUtf8(); - pageToken_ = s; - return s; - } else { - return (java.lang.String) ref; - } - } - /** - * - * - *
-     * The value returned by the last `ListDeviceRegistriesResponse`; indicates
-     * that this is a continuation of a prior `ListDeviceRegistries` call and
-     * the system should return the next page of data.
-     * 
- * - * string page_token = 3; - * - * @return The bytes for pageToken. - */ - public com.google.protobuf.ByteString getPageTokenBytes() { - java.lang.Object ref = pageToken_; - if (ref instanceof String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); - pageToken_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - /** - * - * - *
-     * The value returned by the last `ListDeviceRegistriesResponse`; indicates
-     * that this is a continuation of a prior `ListDeviceRegistries` call and
-     * the system should return the next page of data.
-     * 
- * - * string page_token = 3; - * - * @param value The pageToken to set. - * @return This builder for chaining. - */ - public Builder setPageToken(java.lang.String value) { - if (value == null) { - throw new NullPointerException(); - } - - pageToken_ = value; - onChanged(); - return this; - } - /** - * - * - *
-     * The value returned by the last `ListDeviceRegistriesResponse`; indicates
-     * that this is a continuation of a prior `ListDeviceRegistries` call and
-     * the system should return the next page of data.
-     * 
- * - * string page_token = 3; - * - * @return This builder for chaining. - */ - public Builder clearPageToken() { - - pageToken_ = getDefaultInstance().getPageToken(); - onChanged(); - return this; - } - /** - * - * - *
-     * The value returned by the last `ListDeviceRegistriesResponse`; indicates
-     * that this is a continuation of a prior `ListDeviceRegistries` call and
-     * the system should return the next page of data.
-     * 
- * - * string page_token = 3; - * - * @param value The bytes for pageToken to set. - * @return This builder for chaining. - */ - public Builder setPageTokenBytes(com.google.protobuf.ByteString value) { - if (value == null) { - throw new NullPointerException(); - } - checkByteStringIsUtf8(value); - - pageToken_ = value; - onChanged(); - return this; - } - - @java.lang.Override - public final Builder setUnknownFields(final com.google.protobuf.UnknownFieldSet unknownFields) { - return super.setUnknownFields(unknownFields); - } - - @java.lang.Override - public final Builder mergeUnknownFields( - final com.google.protobuf.UnknownFieldSet unknownFields) { - return super.mergeUnknownFields(unknownFields); - } - - // @@protoc_insertion_point(builder_scope:google.cloud.iot.v1.ListDeviceRegistriesRequest) - } - - // @@protoc_insertion_point(class_scope:google.cloud.iot.v1.ListDeviceRegistriesRequest) - private static final com.google.cloud.iot.v1.ListDeviceRegistriesRequest DEFAULT_INSTANCE; - - static { - DEFAULT_INSTANCE = new com.google.cloud.iot.v1.ListDeviceRegistriesRequest(); - } - - public static com.google.cloud.iot.v1.ListDeviceRegistriesRequest getDefaultInstance() { - return DEFAULT_INSTANCE; - } - - private static final com.google.protobuf.Parser PARSER = - new com.google.protobuf.AbstractParser() { - @java.lang.Override - public ListDeviceRegistriesRequest parsePartialFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - Builder builder = newBuilder(); - try { - builder.mergeFrom(input, extensionRegistry); - } catch (com.google.protobuf.InvalidProtocolBufferException e) { - throw e.setUnfinishedMessage(builder.buildPartial()); - } catch (com.google.protobuf.UninitializedMessageException e) { - throw e.asInvalidProtocolBufferException().setUnfinishedMessage(builder.buildPartial()); - } catch (java.io.IOException e) { - throw new com.google.protobuf.InvalidProtocolBufferException(e) - .setUnfinishedMessage(builder.buildPartial()); - } - return builder.buildPartial(); - } - }; - - public static com.google.protobuf.Parser parser() { - return PARSER; - } - - @java.lang.Override - public com.google.protobuf.Parser getParserForType() { - return PARSER; - } - - @java.lang.Override - public com.google.cloud.iot.v1.ListDeviceRegistriesRequest getDefaultInstanceForType() { - return DEFAULT_INSTANCE; - } -} diff --git a/proto-google-cloud-iot-v1/src/main/java/com/google/cloud/iot/v1/ListDeviceRegistriesRequestOrBuilder.java b/proto-google-cloud-iot-v1/src/main/java/com/google/cloud/iot/v1/ListDeviceRegistriesRequestOrBuilder.java deleted file mode 100644 index df99ea40..00000000 --- a/proto-google-cloud-iot-v1/src/main/java/com/google/cloud/iot/v1/ListDeviceRegistriesRequestOrBuilder.java +++ /dev/null @@ -1,101 +0,0 @@ -/* - * Copyright 2020 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. - */ -// Generated by the protocol buffer compiler. DO NOT EDIT! -// source: google/cloud/iot/v1/device_manager.proto - -package com.google.cloud.iot.v1; - -public interface ListDeviceRegistriesRequestOrBuilder - extends - // @@protoc_insertion_point(interface_extends:google.cloud.iot.v1.ListDeviceRegistriesRequest) - com.google.protobuf.MessageOrBuilder { - - /** - * - * - *
-   * Required. The project and cloud region path. For example,
-   * `projects/example-project/locations/us-central1`.
-   * 
- * - * - * string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } - * - * - * @return The parent. - */ - java.lang.String getParent(); - /** - * - * - *
-   * Required. The project and cloud region path. For example,
-   * `projects/example-project/locations/us-central1`.
-   * 
- * - * - * string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } - * - * - * @return The bytes for parent. - */ - com.google.protobuf.ByteString getParentBytes(); - - /** - * - * - *
-   * The maximum number of registries to return in the response. If this value
-   * is zero, the service will select a default size. A call may return fewer
-   * objects than requested. A non-empty `next_page_token` in the response
-   * indicates that more data is available.
-   * 
- * - * int32 page_size = 2; - * - * @return The pageSize. - */ - int getPageSize(); - - /** - * - * - *
-   * The value returned by the last `ListDeviceRegistriesResponse`; indicates
-   * that this is a continuation of a prior `ListDeviceRegistries` call and
-   * the system should return the next page of data.
-   * 
- * - * string page_token = 3; - * - * @return The pageToken. - */ - java.lang.String getPageToken(); - /** - * - * - *
-   * The value returned by the last `ListDeviceRegistriesResponse`; indicates
-   * that this is a continuation of a prior `ListDeviceRegistries` call and
-   * the system should return the next page of data.
-   * 
- * - * string page_token = 3; - * - * @return The bytes for pageToken. - */ - com.google.protobuf.ByteString getPageTokenBytes(); -} diff --git a/proto-google-cloud-iot-v1/src/main/java/com/google/cloud/iot/v1/ListDeviceRegistriesResponse.java b/proto-google-cloud-iot-v1/src/main/java/com/google/cloud/iot/v1/ListDeviceRegistriesResponse.java deleted file mode 100644 index 92235673..00000000 --- a/proto-google-cloud-iot-v1/src/main/java/com/google/cloud/iot/v1/ListDeviceRegistriesResponse.java +++ /dev/null @@ -1,1123 +0,0 @@ -/* - * Copyright 2020 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. - */ -// Generated by the protocol buffer compiler. DO NOT EDIT! -// source: google/cloud/iot/v1/device_manager.proto - -package com.google.cloud.iot.v1; - -/** - * - * - *
- * Response for `ListDeviceRegistries`.
- * 
- * - * Protobuf type {@code google.cloud.iot.v1.ListDeviceRegistriesResponse} - */ -public final class ListDeviceRegistriesResponse extends com.google.protobuf.GeneratedMessageV3 - implements - // @@protoc_insertion_point(message_implements:google.cloud.iot.v1.ListDeviceRegistriesResponse) - ListDeviceRegistriesResponseOrBuilder { - private static final long serialVersionUID = 0L; - // Use ListDeviceRegistriesResponse.newBuilder() to construct. - private ListDeviceRegistriesResponse(com.google.protobuf.GeneratedMessageV3.Builder builder) { - super(builder); - } - - private ListDeviceRegistriesResponse() { - deviceRegistries_ = java.util.Collections.emptyList(); - nextPageToken_ = ""; - } - - @java.lang.Override - @SuppressWarnings({"unused"}) - protected java.lang.Object newInstance(UnusedPrivateParameter unused) { - return new ListDeviceRegistriesResponse(); - } - - @java.lang.Override - public final com.google.protobuf.UnknownFieldSet getUnknownFields() { - return this.unknownFields; - } - - public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { - return com.google.cloud.iot.v1.DeviceManagerProto - .internal_static_google_cloud_iot_v1_ListDeviceRegistriesResponse_descriptor; - } - - @java.lang.Override - protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable - internalGetFieldAccessorTable() { - return com.google.cloud.iot.v1.DeviceManagerProto - .internal_static_google_cloud_iot_v1_ListDeviceRegistriesResponse_fieldAccessorTable - .ensureFieldAccessorsInitialized( - com.google.cloud.iot.v1.ListDeviceRegistriesResponse.class, - com.google.cloud.iot.v1.ListDeviceRegistriesResponse.Builder.class); - } - - public static final int DEVICE_REGISTRIES_FIELD_NUMBER = 1; - private java.util.List deviceRegistries_; - /** - * - * - *
-   * The registries that matched the query.
-   * 
- * - * repeated .google.cloud.iot.v1.DeviceRegistry device_registries = 1; - */ - @java.lang.Override - public java.util.List getDeviceRegistriesList() { - return deviceRegistries_; - } - /** - * - * - *
-   * The registries that matched the query.
-   * 
- * - * repeated .google.cloud.iot.v1.DeviceRegistry device_registries = 1; - */ - @java.lang.Override - public java.util.List - getDeviceRegistriesOrBuilderList() { - return deviceRegistries_; - } - /** - * - * - *
-   * The registries that matched the query.
-   * 
- * - * repeated .google.cloud.iot.v1.DeviceRegistry device_registries = 1; - */ - @java.lang.Override - public int getDeviceRegistriesCount() { - return deviceRegistries_.size(); - } - /** - * - * - *
-   * The registries that matched the query.
-   * 
- * - * repeated .google.cloud.iot.v1.DeviceRegistry device_registries = 1; - */ - @java.lang.Override - public com.google.cloud.iot.v1.DeviceRegistry getDeviceRegistries(int index) { - return deviceRegistries_.get(index); - } - /** - * - * - *
-   * The registries that matched the query.
-   * 
- * - * repeated .google.cloud.iot.v1.DeviceRegistry device_registries = 1; - */ - @java.lang.Override - public com.google.cloud.iot.v1.DeviceRegistryOrBuilder getDeviceRegistriesOrBuilder(int index) { - return deviceRegistries_.get(index); - } - - public static final int NEXT_PAGE_TOKEN_FIELD_NUMBER = 2; - private volatile java.lang.Object nextPageToken_; - /** - * - * - *
-   * If not empty, indicates that there may be more registries that match the
-   * request; this value should be passed in a new
-   * `ListDeviceRegistriesRequest`.
-   * 
- * - * string next_page_token = 2; - * - * @return The nextPageToken. - */ - @java.lang.Override - public java.lang.String getNextPageToken() { - java.lang.Object ref = nextPageToken_; - if (ref instanceof java.lang.String) { - return (java.lang.String) ref; - } else { - com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; - java.lang.String s = bs.toStringUtf8(); - nextPageToken_ = s; - return s; - } - } - /** - * - * - *
-   * If not empty, indicates that there may be more registries that match the
-   * request; this value should be passed in a new
-   * `ListDeviceRegistriesRequest`.
-   * 
- * - * string next_page_token = 2; - * - * @return The bytes for nextPageToken. - */ - @java.lang.Override - public com.google.protobuf.ByteString getNextPageTokenBytes() { - java.lang.Object ref = nextPageToken_; - if (ref instanceof java.lang.String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); - nextPageToken_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - - private byte memoizedIsInitialized = -1; - - @java.lang.Override - public final boolean isInitialized() { - byte isInitialized = memoizedIsInitialized; - if (isInitialized == 1) return true; - if (isInitialized == 0) return false; - - memoizedIsInitialized = 1; - return true; - } - - @java.lang.Override - public void writeTo(com.google.protobuf.CodedOutputStream output) throws java.io.IOException { - for (int i = 0; i < deviceRegistries_.size(); i++) { - output.writeMessage(1, deviceRegistries_.get(i)); - } - if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(nextPageToken_)) { - com.google.protobuf.GeneratedMessageV3.writeString(output, 2, nextPageToken_); - } - getUnknownFields().writeTo(output); - } - - @java.lang.Override - public int getSerializedSize() { - int size = memoizedSize; - if (size != -1) return size; - - size = 0; - for (int i = 0; i < deviceRegistries_.size(); i++) { - size += com.google.protobuf.CodedOutputStream.computeMessageSize(1, deviceRegistries_.get(i)); - } - if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(nextPageToken_)) { - size += com.google.protobuf.GeneratedMessageV3.computeStringSize(2, nextPageToken_); - } - size += getUnknownFields().getSerializedSize(); - memoizedSize = size; - return size; - } - - @java.lang.Override - public boolean equals(final java.lang.Object obj) { - if (obj == this) { - return true; - } - if (!(obj instanceof com.google.cloud.iot.v1.ListDeviceRegistriesResponse)) { - return super.equals(obj); - } - com.google.cloud.iot.v1.ListDeviceRegistriesResponse other = - (com.google.cloud.iot.v1.ListDeviceRegistriesResponse) obj; - - if (!getDeviceRegistriesList().equals(other.getDeviceRegistriesList())) return false; - if (!getNextPageToken().equals(other.getNextPageToken())) return false; - if (!getUnknownFields().equals(other.getUnknownFields())) return false; - return true; - } - - @java.lang.Override - public int hashCode() { - if (memoizedHashCode != 0) { - return memoizedHashCode; - } - int hash = 41; - hash = (19 * hash) + getDescriptor().hashCode(); - if (getDeviceRegistriesCount() > 0) { - hash = (37 * hash) + DEVICE_REGISTRIES_FIELD_NUMBER; - hash = (53 * hash) + getDeviceRegistriesList().hashCode(); - } - hash = (37 * hash) + NEXT_PAGE_TOKEN_FIELD_NUMBER; - hash = (53 * hash) + getNextPageToken().hashCode(); - hash = (29 * hash) + getUnknownFields().hashCode(); - memoizedHashCode = hash; - return hash; - } - - public static com.google.cloud.iot.v1.ListDeviceRegistriesResponse parseFrom( - java.nio.ByteBuffer data) throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); - } - - public static com.google.cloud.iot.v1.ListDeviceRegistriesResponse parseFrom( - java.nio.ByteBuffer data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); - } - - public static com.google.cloud.iot.v1.ListDeviceRegistriesResponse parseFrom( - com.google.protobuf.ByteString data) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); - } - - public static com.google.cloud.iot.v1.ListDeviceRegistriesResponse parseFrom( - com.google.protobuf.ByteString data, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); - } - - public static com.google.cloud.iot.v1.ListDeviceRegistriesResponse parseFrom(byte[] data) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); - } - - public static com.google.cloud.iot.v1.ListDeviceRegistriesResponse parseFrom( - byte[] data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); - } - - public static com.google.cloud.iot.v1.ListDeviceRegistriesResponse parseFrom( - java.io.InputStream input) throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input); - } - - public static com.google.cloud.iot.v1.ListDeviceRegistriesResponse parseFrom( - java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3.parseWithIOException( - PARSER, input, extensionRegistry); - } - - public static com.google.cloud.iot.v1.ListDeviceRegistriesResponse parseDelimitedFrom( - java.io.InputStream input) throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3.parseDelimitedWithIOException(PARSER, input); - } - - public static com.google.cloud.iot.v1.ListDeviceRegistriesResponse parseDelimitedFrom( - java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3.parseDelimitedWithIOException( - PARSER, input, extensionRegistry); - } - - public static com.google.cloud.iot.v1.ListDeviceRegistriesResponse parseFrom( - com.google.protobuf.CodedInputStream input) throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input); - } - - public static com.google.cloud.iot.v1.ListDeviceRegistriesResponse parseFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3.parseWithIOException( - PARSER, input, extensionRegistry); - } - - @java.lang.Override - public Builder newBuilderForType() { - return newBuilder(); - } - - public static Builder newBuilder() { - return DEFAULT_INSTANCE.toBuilder(); - } - - public static Builder newBuilder(com.google.cloud.iot.v1.ListDeviceRegistriesResponse prototype) { - return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); - } - - @java.lang.Override - public Builder toBuilder() { - return this == DEFAULT_INSTANCE ? new Builder() : new Builder().mergeFrom(this); - } - - @java.lang.Override - protected Builder newBuilderForType(com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { - Builder builder = new Builder(parent); - return builder; - } - /** - * - * - *
-   * Response for `ListDeviceRegistries`.
-   * 
- * - * Protobuf type {@code google.cloud.iot.v1.ListDeviceRegistriesResponse} - */ - public static final class Builder extends com.google.protobuf.GeneratedMessageV3.Builder - implements - // @@protoc_insertion_point(builder_implements:google.cloud.iot.v1.ListDeviceRegistriesResponse) - com.google.cloud.iot.v1.ListDeviceRegistriesResponseOrBuilder { - public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { - return com.google.cloud.iot.v1.DeviceManagerProto - .internal_static_google_cloud_iot_v1_ListDeviceRegistriesResponse_descriptor; - } - - @java.lang.Override - protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable - internalGetFieldAccessorTable() { - return com.google.cloud.iot.v1.DeviceManagerProto - .internal_static_google_cloud_iot_v1_ListDeviceRegistriesResponse_fieldAccessorTable - .ensureFieldAccessorsInitialized( - com.google.cloud.iot.v1.ListDeviceRegistriesResponse.class, - com.google.cloud.iot.v1.ListDeviceRegistriesResponse.Builder.class); - } - - // Construct using com.google.cloud.iot.v1.ListDeviceRegistriesResponse.newBuilder() - private Builder() {} - - private Builder(com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { - super(parent); - } - - @java.lang.Override - public Builder clear() { - super.clear(); - if (deviceRegistriesBuilder_ == null) { - deviceRegistries_ = java.util.Collections.emptyList(); - } else { - deviceRegistries_ = null; - deviceRegistriesBuilder_.clear(); - } - bitField0_ = (bitField0_ & ~0x00000001); - nextPageToken_ = ""; - - return this; - } - - @java.lang.Override - public com.google.protobuf.Descriptors.Descriptor getDescriptorForType() { - return com.google.cloud.iot.v1.DeviceManagerProto - .internal_static_google_cloud_iot_v1_ListDeviceRegistriesResponse_descriptor; - } - - @java.lang.Override - public com.google.cloud.iot.v1.ListDeviceRegistriesResponse getDefaultInstanceForType() { - return com.google.cloud.iot.v1.ListDeviceRegistriesResponse.getDefaultInstance(); - } - - @java.lang.Override - public com.google.cloud.iot.v1.ListDeviceRegistriesResponse build() { - com.google.cloud.iot.v1.ListDeviceRegistriesResponse result = buildPartial(); - if (!result.isInitialized()) { - throw newUninitializedMessageException(result); - } - return result; - } - - @java.lang.Override - public com.google.cloud.iot.v1.ListDeviceRegistriesResponse buildPartial() { - com.google.cloud.iot.v1.ListDeviceRegistriesResponse result = - new com.google.cloud.iot.v1.ListDeviceRegistriesResponse(this); - int from_bitField0_ = bitField0_; - if (deviceRegistriesBuilder_ == null) { - if (((bitField0_ & 0x00000001) != 0)) { - deviceRegistries_ = java.util.Collections.unmodifiableList(deviceRegistries_); - bitField0_ = (bitField0_ & ~0x00000001); - } - result.deviceRegistries_ = deviceRegistries_; - } else { - result.deviceRegistries_ = deviceRegistriesBuilder_.build(); - } - result.nextPageToken_ = nextPageToken_; - onBuilt(); - return result; - } - - @java.lang.Override - public Builder clone() { - return super.clone(); - } - - @java.lang.Override - public Builder setField( - com.google.protobuf.Descriptors.FieldDescriptor field, java.lang.Object value) { - return super.setField(field, value); - } - - @java.lang.Override - public Builder clearField(com.google.protobuf.Descriptors.FieldDescriptor field) { - return super.clearField(field); - } - - @java.lang.Override - public Builder clearOneof(com.google.protobuf.Descriptors.OneofDescriptor oneof) { - return super.clearOneof(oneof); - } - - @java.lang.Override - public Builder setRepeatedField( - com.google.protobuf.Descriptors.FieldDescriptor field, int index, java.lang.Object value) { - return super.setRepeatedField(field, index, value); - } - - @java.lang.Override - public Builder addRepeatedField( - com.google.protobuf.Descriptors.FieldDescriptor field, java.lang.Object value) { - return super.addRepeatedField(field, value); - } - - @java.lang.Override - public Builder mergeFrom(com.google.protobuf.Message other) { - if (other instanceof com.google.cloud.iot.v1.ListDeviceRegistriesResponse) { - return mergeFrom((com.google.cloud.iot.v1.ListDeviceRegistriesResponse) other); - } else { - super.mergeFrom(other); - return this; - } - } - - public Builder mergeFrom(com.google.cloud.iot.v1.ListDeviceRegistriesResponse other) { - if (other == com.google.cloud.iot.v1.ListDeviceRegistriesResponse.getDefaultInstance()) - return this; - if (deviceRegistriesBuilder_ == null) { - if (!other.deviceRegistries_.isEmpty()) { - if (deviceRegistries_.isEmpty()) { - deviceRegistries_ = other.deviceRegistries_; - bitField0_ = (bitField0_ & ~0x00000001); - } else { - ensureDeviceRegistriesIsMutable(); - deviceRegistries_.addAll(other.deviceRegistries_); - } - onChanged(); - } - } else { - if (!other.deviceRegistries_.isEmpty()) { - if (deviceRegistriesBuilder_.isEmpty()) { - deviceRegistriesBuilder_.dispose(); - deviceRegistriesBuilder_ = null; - deviceRegistries_ = other.deviceRegistries_; - bitField0_ = (bitField0_ & ~0x00000001); - deviceRegistriesBuilder_ = - com.google.protobuf.GeneratedMessageV3.alwaysUseFieldBuilders - ? getDeviceRegistriesFieldBuilder() - : null; - } else { - deviceRegistriesBuilder_.addAllMessages(other.deviceRegistries_); - } - } - } - if (!other.getNextPageToken().isEmpty()) { - nextPageToken_ = other.nextPageToken_; - onChanged(); - } - this.mergeUnknownFields(other.getUnknownFields()); - onChanged(); - return this; - } - - @java.lang.Override - public final boolean isInitialized() { - return true; - } - - @java.lang.Override - public Builder mergeFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - if (extensionRegistry == null) { - throw new java.lang.NullPointerException(); - } - try { - boolean done = false; - while (!done) { - int tag = input.readTag(); - switch (tag) { - case 0: - done = true; - break; - case 10: - { - com.google.cloud.iot.v1.DeviceRegistry m = - input.readMessage( - com.google.cloud.iot.v1.DeviceRegistry.parser(), extensionRegistry); - if (deviceRegistriesBuilder_ == null) { - ensureDeviceRegistriesIsMutable(); - deviceRegistries_.add(m); - } else { - deviceRegistriesBuilder_.addMessage(m); - } - break; - } // case 10 - case 18: - { - nextPageToken_ = input.readStringRequireUtf8(); - - break; - } // case 18 - default: - { - if (!super.parseUnknownField(input, extensionRegistry, tag)) { - done = true; // was an endgroup tag - } - break; - } // default: - } // switch (tag) - } // while (!done) - } catch (com.google.protobuf.InvalidProtocolBufferException e) { - throw e.unwrapIOException(); - } finally { - onChanged(); - } // finally - return this; - } - - private int bitField0_; - - private java.util.List deviceRegistries_ = - java.util.Collections.emptyList(); - - private void ensureDeviceRegistriesIsMutable() { - if (!((bitField0_ & 0x00000001) != 0)) { - deviceRegistries_ = - new java.util.ArrayList(deviceRegistries_); - bitField0_ |= 0x00000001; - } - } - - private com.google.protobuf.RepeatedFieldBuilderV3< - com.google.cloud.iot.v1.DeviceRegistry, - com.google.cloud.iot.v1.DeviceRegistry.Builder, - com.google.cloud.iot.v1.DeviceRegistryOrBuilder> - deviceRegistriesBuilder_; - - /** - * - * - *
-     * The registries that matched the query.
-     * 
- * - * repeated .google.cloud.iot.v1.DeviceRegistry device_registries = 1; - */ - public java.util.List getDeviceRegistriesList() { - if (deviceRegistriesBuilder_ == null) { - return java.util.Collections.unmodifiableList(deviceRegistries_); - } else { - return deviceRegistriesBuilder_.getMessageList(); - } - } - /** - * - * - *
-     * The registries that matched the query.
-     * 
- * - * repeated .google.cloud.iot.v1.DeviceRegistry device_registries = 1; - */ - public int getDeviceRegistriesCount() { - if (deviceRegistriesBuilder_ == null) { - return deviceRegistries_.size(); - } else { - return deviceRegistriesBuilder_.getCount(); - } - } - /** - * - * - *
-     * The registries that matched the query.
-     * 
- * - * repeated .google.cloud.iot.v1.DeviceRegistry device_registries = 1; - */ - public com.google.cloud.iot.v1.DeviceRegistry getDeviceRegistries(int index) { - if (deviceRegistriesBuilder_ == null) { - return deviceRegistries_.get(index); - } else { - return deviceRegistriesBuilder_.getMessage(index); - } - } - /** - * - * - *
-     * The registries that matched the query.
-     * 
- * - * repeated .google.cloud.iot.v1.DeviceRegistry device_registries = 1; - */ - public Builder setDeviceRegistries(int index, com.google.cloud.iot.v1.DeviceRegistry value) { - if (deviceRegistriesBuilder_ == null) { - if (value == null) { - throw new NullPointerException(); - } - ensureDeviceRegistriesIsMutable(); - deviceRegistries_.set(index, value); - onChanged(); - } else { - deviceRegistriesBuilder_.setMessage(index, value); - } - return this; - } - /** - * - * - *
-     * The registries that matched the query.
-     * 
- * - * repeated .google.cloud.iot.v1.DeviceRegistry device_registries = 1; - */ - public Builder setDeviceRegistries( - int index, com.google.cloud.iot.v1.DeviceRegistry.Builder builderForValue) { - if (deviceRegistriesBuilder_ == null) { - ensureDeviceRegistriesIsMutable(); - deviceRegistries_.set(index, builderForValue.build()); - onChanged(); - } else { - deviceRegistriesBuilder_.setMessage(index, builderForValue.build()); - } - return this; - } - /** - * - * - *
-     * The registries that matched the query.
-     * 
- * - * repeated .google.cloud.iot.v1.DeviceRegistry device_registries = 1; - */ - public Builder addDeviceRegistries(com.google.cloud.iot.v1.DeviceRegistry value) { - if (deviceRegistriesBuilder_ == null) { - if (value == null) { - throw new NullPointerException(); - } - ensureDeviceRegistriesIsMutable(); - deviceRegistries_.add(value); - onChanged(); - } else { - deviceRegistriesBuilder_.addMessage(value); - } - return this; - } - /** - * - * - *
-     * The registries that matched the query.
-     * 
- * - * repeated .google.cloud.iot.v1.DeviceRegistry device_registries = 1; - */ - public Builder addDeviceRegistries(int index, com.google.cloud.iot.v1.DeviceRegistry value) { - if (deviceRegistriesBuilder_ == null) { - if (value == null) { - throw new NullPointerException(); - } - ensureDeviceRegistriesIsMutable(); - deviceRegistries_.add(index, value); - onChanged(); - } else { - deviceRegistriesBuilder_.addMessage(index, value); - } - return this; - } - /** - * - * - *
-     * The registries that matched the query.
-     * 
- * - * repeated .google.cloud.iot.v1.DeviceRegistry device_registries = 1; - */ - public Builder addDeviceRegistries( - com.google.cloud.iot.v1.DeviceRegistry.Builder builderForValue) { - if (deviceRegistriesBuilder_ == null) { - ensureDeviceRegistriesIsMutable(); - deviceRegistries_.add(builderForValue.build()); - onChanged(); - } else { - deviceRegistriesBuilder_.addMessage(builderForValue.build()); - } - return this; - } - /** - * - * - *
-     * The registries that matched the query.
-     * 
- * - * repeated .google.cloud.iot.v1.DeviceRegistry device_registries = 1; - */ - public Builder addDeviceRegistries( - int index, com.google.cloud.iot.v1.DeviceRegistry.Builder builderForValue) { - if (deviceRegistriesBuilder_ == null) { - ensureDeviceRegistriesIsMutable(); - deviceRegistries_.add(index, builderForValue.build()); - onChanged(); - } else { - deviceRegistriesBuilder_.addMessage(index, builderForValue.build()); - } - return this; - } - /** - * - * - *
-     * The registries that matched the query.
-     * 
- * - * repeated .google.cloud.iot.v1.DeviceRegistry device_registries = 1; - */ - public Builder addAllDeviceRegistries( - java.lang.Iterable values) { - if (deviceRegistriesBuilder_ == null) { - ensureDeviceRegistriesIsMutable(); - com.google.protobuf.AbstractMessageLite.Builder.addAll(values, deviceRegistries_); - onChanged(); - } else { - deviceRegistriesBuilder_.addAllMessages(values); - } - return this; - } - /** - * - * - *
-     * The registries that matched the query.
-     * 
- * - * repeated .google.cloud.iot.v1.DeviceRegistry device_registries = 1; - */ - public Builder clearDeviceRegistries() { - if (deviceRegistriesBuilder_ == null) { - deviceRegistries_ = java.util.Collections.emptyList(); - bitField0_ = (bitField0_ & ~0x00000001); - onChanged(); - } else { - deviceRegistriesBuilder_.clear(); - } - return this; - } - /** - * - * - *
-     * The registries that matched the query.
-     * 
- * - * repeated .google.cloud.iot.v1.DeviceRegistry device_registries = 1; - */ - public Builder removeDeviceRegistries(int index) { - if (deviceRegistriesBuilder_ == null) { - ensureDeviceRegistriesIsMutable(); - deviceRegistries_.remove(index); - onChanged(); - } else { - deviceRegistriesBuilder_.remove(index); - } - return this; - } - /** - * - * - *
-     * The registries that matched the query.
-     * 
- * - * repeated .google.cloud.iot.v1.DeviceRegistry device_registries = 1; - */ - public com.google.cloud.iot.v1.DeviceRegistry.Builder getDeviceRegistriesBuilder(int index) { - return getDeviceRegistriesFieldBuilder().getBuilder(index); - } - /** - * - * - *
-     * The registries that matched the query.
-     * 
- * - * repeated .google.cloud.iot.v1.DeviceRegistry device_registries = 1; - */ - public com.google.cloud.iot.v1.DeviceRegistryOrBuilder getDeviceRegistriesOrBuilder(int index) { - if (deviceRegistriesBuilder_ == null) { - return deviceRegistries_.get(index); - } else { - return deviceRegistriesBuilder_.getMessageOrBuilder(index); - } - } - /** - * - * - *
-     * The registries that matched the query.
-     * 
- * - * repeated .google.cloud.iot.v1.DeviceRegistry device_registries = 1; - */ - public java.util.List - getDeviceRegistriesOrBuilderList() { - if (deviceRegistriesBuilder_ != null) { - return deviceRegistriesBuilder_.getMessageOrBuilderList(); - } else { - return java.util.Collections.unmodifiableList(deviceRegistries_); - } - } - /** - * - * - *
-     * The registries that matched the query.
-     * 
- * - * repeated .google.cloud.iot.v1.DeviceRegistry device_registries = 1; - */ - public com.google.cloud.iot.v1.DeviceRegistry.Builder addDeviceRegistriesBuilder() { - return getDeviceRegistriesFieldBuilder() - .addBuilder(com.google.cloud.iot.v1.DeviceRegistry.getDefaultInstance()); - } - /** - * - * - *
-     * The registries that matched the query.
-     * 
- * - * repeated .google.cloud.iot.v1.DeviceRegistry device_registries = 1; - */ - public com.google.cloud.iot.v1.DeviceRegistry.Builder addDeviceRegistriesBuilder(int index) { - return getDeviceRegistriesFieldBuilder() - .addBuilder(index, com.google.cloud.iot.v1.DeviceRegistry.getDefaultInstance()); - } - /** - * - * - *
-     * The registries that matched the query.
-     * 
- * - * repeated .google.cloud.iot.v1.DeviceRegistry device_registries = 1; - */ - public java.util.List - getDeviceRegistriesBuilderList() { - return getDeviceRegistriesFieldBuilder().getBuilderList(); - } - - private com.google.protobuf.RepeatedFieldBuilderV3< - com.google.cloud.iot.v1.DeviceRegistry, - com.google.cloud.iot.v1.DeviceRegistry.Builder, - com.google.cloud.iot.v1.DeviceRegistryOrBuilder> - getDeviceRegistriesFieldBuilder() { - if (deviceRegistriesBuilder_ == null) { - deviceRegistriesBuilder_ = - new com.google.protobuf.RepeatedFieldBuilderV3< - com.google.cloud.iot.v1.DeviceRegistry, - com.google.cloud.iot.v1.DeviceRegistry.Builder, - com.google.cloud.iot.v1.DeviceRegistryOrBuilder>( - deviceRegistries_, - ((bitField0_ & 0x00000001) != 0), - getParentForChildren(), - isClean()); - deviceRegistries_ = null; - } - return deviceRegistriesBuilder_; - } - - private java.lang.Object nextPageToken_ = ""; - /** - * - * - *
-     * If not empty, indicates that there may be more registries that match the
-     * request; this value should be passed in a new
-     * `ListDeviceRegistriesRequest`.
-     * 
- * - * string next_page_token = 2; - * - * @return The nextPageToken. - */ - public java.lang.String getNextPageToken() { - java.lang.Object ref = nextPageToken_; - if (!(ref instanceof java.lang.String)) { - com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; - java.lang.String s = bs.toStringUtf8(); - nextPageToken_ = s; - return s; - } else { - return (java.lang.String) ref; - } - } - /** - * - * - *
-     * If not empty, indicates that there may be more registries that match the
-     * request; this value should be passed in a new
-     * `ListDeviceRegistriesRequest`.
-     * 
- * - * string next_page_token = 2; - * - * @return The bytes for nextPageToken. - */ - public com.google.protobuf.ByteString getNextPageTokenBytes() { - java.lang.Object ref = nextPageToken_; - if (ref instanceof String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); - nextPageToken_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - /** - * - * - *
-     * If not empty, indicates that there may be more registries that match the
-     * request; this value should be passed in a new
-     * `ListDeviceRegistriesRequest`.
-     * 
- * - * string next_page_token = 2; - * - * @param value The nextPageToken to set. - * @return This builder for chaining. - */ - public Builder setNextPageToken(java.lang.String value) { - if (value == null) { - throw new NullPointerException(); - } - - nextPageToken_ = value; - onChanged(); - return this; - } - /** - * - * - *
-     * If not empty, indicates that there may be more registries that match the
-     * request; this value should be passed in a new
-     * `ListDeviceRegistriesRequest`.
-     * 
- * - * string next_page_token = 2; - * - * @return This builder for chaining. - */ - public Builder clearNextPageToken() { - - nextPageToken_ = getDefaultInstance().getNextPageToken(); - onChanged(); - return this; - } - /** - * - * - *
-     * If not empty, indicates that there may be more registries that match the
-     * request; this value should be passed in a new
-     * `ListDeviceRegistriesRequest`.
-     * 
- * - * string next_page_token = 2; - * - * @param value The bytes for nextPageToken to set. - * @return This builder for chaining. - */ - public Builder setNextPageTokenBytes(com.google.protobuf.ByteString value) { - if (value == null) { - throw new NullPointerException(); - } - checkByteStringIsUtf8(value); - - nextPageToken_ = value; - onChanged(); - return this; - } - - @java.lang.Override - public final Builder setUnknownFields(final com.google.protobuf.UnknownFieldSet unknownFields) { - return super.setUnknownFields(unknownFields); - } - - @java.lang.Override - public final Builder mergeUnknownFields( - final com.google.protobuf.UnknownFieldSet unknownFields) { - return super.mergeUnknownFields(unknownFields); - } - - // @@protoc_insertion_point(builder_scope:google.cloud.iot.v1.ListDeviceRegistriesResponse) - } - - // @@protoc_insertion_point(class_scope:google.cloud.iot.v1.ListDeviceRegistriesResponse) - private static final com.google.cloud.iot.v1.ListDeviceRegistriesResponse DEFAULT_INSTANCE; - - static { - DEFAULT_INSTANCE = new com.google.cloud.iot.v1.ListDeviceRegistriesResponse(); - } - - public static com.google.cloud.iot.v1.ListDeviceRegistriesResponse getDefaultInstance() { - return DEFAULT_INSTANCE; - } - - private static final com.google.protobuf.Parser PARSER = - new com.google.protobuf.AbstractParser() { - @java.lang.Override - public ListDeviceRegistriesResponse parsePartialFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - Builder builder = newBuilder(); - try { - builder.mergeFrom(input, extensionRegistry); - } catch (com.google.protobuf.InvalidProtocolBufferException e) { - throw e.setUnfinishedMessage(builder.buildPartial()); - } catch (com.google.protobuf.UninitializedMessageException e) { - throw e.asInvalidProtocolBufferException().setUnfinishedMessage(builder.buildPartial()); - } catch (java.io.IOException e) { - throw new com.google.protobuf.InvalidProtocolBufferException(e) - .setUnfinishedMessage(builder.buildPartial()); - } - return builder.buildPartial(); - } - }; - - public static com.google.protobuf.Parser parser() { - return PARSER; - } - - @java.lang.Override - public com.google.protobuf.Parser getParserForType() { - return PARSER; - } - - @java.lang.Override - public com.google.cloud.iot.v1.ListDeviceRegistriesResponse getDefaultInstanceForType() { - return DEFAULT_INSTANCE; - } -} diff --git a/proto-google-cloud-iot-v1/src/main/java/com/google/cloud/iot/v1/ListDeviceRegistriesResponseOrBuilder.java b/proto-google-cloud-iot-v1/src/main/java/com/google/cloud/iot/v1/ListDeviceRegistriesResponseOrBuilder.java deleted file mode 100644 index 769fcc29..00000000 --- a/proto-google-cloud-iot-v1/src/main/java/com/google/cloud/iot/v1/ListDeviceRegistriesResponseOrBuilder.java +++ /dev/null @@ -1,106 +0,0 @@ -/* - * Copyright 2020 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. - */ -// Generated by the protocol buffer compiler. DO NOT EDIT! -// source: google/cloud/iot/v1/device_manager.proto - -package com.google.cloud.iot.v1; - -public interface ListDeviceRegistriesResponseOrBuilder - extends - // @@protoc_insertion_point(interface_extends:google.cloud.iot.v1.ListDeviceRegistriesResponse) - com.google.protobuf.MessageOrBuilder { - - /** - * - * - *
-   * The registries that matched the query.
-   * 
- * - * repeated .google.cloud.iot.v1.DeviceRegistry device_registries = 1; - */ - java.util.List getDeviceRegistriesList(); - /** - * - * - *
-   * The registries that matched the query.
-   * 
- * - * repeated .google.cloud.iot.v1.DeviceRegistry device_registries = 1; - */ - com.google.cloud.iot.v1.DeviceRegistry getDeviceRegistries(int index); - /** - * - * - *
-   * The registries that matched the query.
-   * 
- * - * repeated .google.cloud.iot.v1.DeviceRegistry device_registries = 1; - */ - int getDeviceRegistriesCount(); - /** - * - * - *
-   * The registries that matched the query.
-   * 
- * - * repeated .google.cloud.iot.v1.DeviceRegistry device_registries = 1; - */ - java.util.List - getDeviceRegistriesOrBuilderList(); - /** - * - * - *
-   * The registries that matched the query.
-   * 
- * - * repeated .google.cloud.iot.v1.DeviceRegistry device_registries = 1; - */ - com.google.cloud.iot.v1.DeviceRegistryOrBuilder getDeviceRegistriesOrBuilder(int index); - - /** - * - * - *
-   * If not empty, indicates that there may be more registries that match the
-   * request; this value should be passed in a new
-   * `ListDeviceRegistriesRequest`.
-   * 
- * - * string next_page_token = 2; - * - * @return The nextPageToken. - */ - java.lang.String getNextPageToken(); - /** - * - * - *
-   * If not empty, indicates that there may be more registries that match the
-   * request; this value should be passed in a new
-   * `ListDeviceRegistriesRequest`.
-   * 
- * - * string next_page_token = 2; - * - * @return The bytes for nextPageToken. - */ - com.google.protobuf.ByteString getNextPageTokenBytes(); -} diff --git a/proto-google-cloud-iot-v1/src/main/java/com/google/cloud/iot/v1/ListDeviceStatesRequest.java b/proto-google-cloud-iot-v1/src/main/java/com/google/cloud/iot/v1/ListDeviceStatesRequest.java deleted file mode 100644 index 99c59c1d..00000000 --- a/proto-google-cloud-iot-v1/src/main/java/com/google/cloud/iot/v1/ListDeviceStatesRequest.java +++ /dev/null @@ -1,742 +0,0 @@ -/* - * Copyright 2020 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. - */ -// Generated by the protocol buffer compiler. DO NOT EDIT! -// source: google/cloud/iot/v1/device_manager.proto - -package com.google.cloud.iot.v1; - -/** - * - * - *
- * Request for `ListDeviceStates`.
- * 
- * - * Protobuf type {@code google.cloud.iot.v1.ListDeviceStatesRequest} - */ -public final class ListDeviceStatesRequest extends com.google.protobuf.GeneratedMessageV3 - implements - // @@protoc_insertion_point(message_implements:google.cloud.iot.v1.ListDeviceStatesRequest) - ListDeviceStatesRequestOrBuilder { - private static final long serialVersionUID = 0L; - // Use ListDeviceStatesRequest.newBuilder() to construct. - private ListDeviceStatesRequest(com.google.protobuf.GeneratedMessageV3.Builder builder) { - super(builder); - } - - private ListDeviceStatesRequest() { - name_ = ""; - } - - @java.lang.Override - @SuppressWarnings({"unused"}) - protected java.lang.Object newInstance(UnusedPrivateParameter unused) { - return new ListDeviceStatesRequest(); - } - - @java.lang.Override - public final com.google.protobuf.UnknownFieldSet getUnknownFields() { - return this.unknownFields; - } - - public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { - return com.google.cloud.iot.v1.DeviceManagerProto - .internal_static_google_cloud_iot_v1_ListDeviceStatesRequest_descriptor; - } - - @java.lang.Override - protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable - internalGetFieldAccessorTable() { - return com.google.cloud.iot.v1.DeviceManagerProto - .internal_static_google_cloud_iot_v1_ListDeviceStatesRequest_fieldAccessorTable - .ensureFieldAccessorsInitialized( - com.google.cloud.iot.v1.ListDeviceStatesRequest.class, - com.google.cloud.iot.v1.ListDeviceStatesRequest.Builder.class); - } - - public static final int NAME_FIELD_NUMBER = 1; - private volatile java.lang.Object name_; - /** - * - * - *
-   * Required. The name of the device. For example,
-   * `projects/p0/locations/us-central1/registries/registry0/devices/device0` or
-   * `projects/p0/locations/us-central1/registries/registry0/devices/{num_id}`.
-   * 
- * - * - * string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } - * - * - * @return The name. - */ - @java.lang.Override - public java.lang.String getName() { - java.lang.Object ref = name_; - if (ref instanceof java.lang.String) { - return (java.lang.String) ref; - } else { - com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; - java.lang.String s = bs.toStringUtf8(); - name_ = s; - return s; - } - } - /** - * - * - *
-   * Required. The name of the device. For example,
-   * `projects/p0/locations/us-central1/registries/registry0/devices/device0` or
-   * `projects/p0/locations/us-central1/registries/registry0/devices/{num_id}`.
-   * 
- * - * - * string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } - * - * - * @return The bytes for name. - */ - @java.lang.Override - public com.google.protobuf.ByteString getNameBytes() { - java.lang.Object ref = name_; - if (ref instanceof java.lang.String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); - name_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - - public static final int NUM_STATES_FIELD_NUMBER = 2; - private int numStates_; - /** - * - * - *
-   * The number of states to list. States are listed in descending order of
-   * update time. The maximum number of states retained is 10. If this
-   * value is zero, it will return all the states available.
-   * 
- * - * int32 num_states = 2; - * - * @return The numStates. - */ - @java.lang.Override - public int getNumStates() { - return numStates_; - } - - private byte memoizedIsInitialized = -1; - - @java.lang.Override - public final boolean isInitialized() { - byte isInitialized = memoizedIsInitialized; - if (isInitialized == 1) return true; - if (isInitialized == 0) return false; - - memoizedIsInitialized = 1; - return true; - } - - @java.lang.Override - public void writeTo(com.google.protobuf.CodedOutputStream output) throws java.io.IOException { - if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(name_)) { - com.google.protobuf.GeneratedMessageV3.writeString(output, 1, name_); - } - if (numStates_ != 0) { - output.writeInt32(2, numStates_); - } - getUnknownFields().writeTo(output); - } - - @java.lang.Override - public int getSerializedSize() { - int size = memoizedSize; - if (size != -1) return size; - - size = 0; - if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(name_)) { - size += com.google.protobuf.GeneratedMessageV3.computeStringSize(1, name_); - } - if (numStates_ != 0) { - size += com.google.protobuf.CodedOutputStream.computeInt32Size(2, numStates_); - } - size += getUnknownFields().getSerializedSize(); - memoizedSize = size; - return size; - } - - @java.lang.Override - public boolean equals(final java.lang.Object obj) { - if (obj == this) { - return true; - } - if (!(obj instanceof com.google.cloud.iot.v1.ListDeviceStatesRequest)) { - return super.equals(obj); - } - com.google.cloud.iot.v1.ListDeviceStatesRequest other = - (com.google.cloud.iot.v1.ListDeviceStatesRequest) obj; - - if (!getName().equals(other.getName())) return false; - if (getNumStates() != other.getNumStates()) return false; - if (!getUnknownFields().equals(other.getUnknownFields())) return false; - return true; - } - - @java.lang.Override - public int hashCode() { - if (memoizedHashCode != 0) { - return memoizedHashCode; - } - int hash = 41; - hash = (19 * hash) + getDescriptor().hashCode(); - hash = (37 * hash) + NAME_FIELD_NUMBER; - hash = (53 * hash) + getName().hashCode(); - hash = (37 * hash) + NUM_STATES_FIELD_NUMBER; - hash = (53 * hash) + getNumStates(); - hash = (29 * hash) + getUnknownFields().hashCode(); - memoizedHashCode = hash; - return hash; - } - - public static com.google.cloud.iot.v1.ListDeviceStatesRequest parseFrom(java.nio.ByteBuffer data) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); - } - - public static com.google.cloud.iot.v1.ListDeviceStatesRequest parseFrom( - java.nio.ByteBuffer data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); - } - - public static com.google.cloud.iot.v1.ListDeviceStatesRequest parseFrom( - com.google.protobuf.ByteString data) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); - } - - public static com.google.cloud.iot.v1.ListDeviceStatesRequest parseFrom( - com.google.protobuf.ByteString data, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); - } - - public static com.google.cloud.iot.v1.ListDeviceStatesRequest parseFrom(byte[] data) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); - } - - public static com.google.cloud.iot.v1.ListDeviceStatesRequest parseFrom( - byte[] data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); - } - - public static com.google.cloud.iot.v1.ListDeviceStatesRequest parseFrom(java.io.InputStream input) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input); - } - - public static com.google.cloud.iot.v1.ListDeviceStatesRequest parseFrom( - java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3.parseWithIOException( - PARSER, input, extensionRegistry); - } - - public static com.google.cloud.iot.v1.ListDeviceStatesRequest parseDelimitedFrom( - java.io.InputStream input) throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3.parseDelimitedWithIOException(PARSER, input); - } - - public static com.google.cloud.iot.v1.ListDeviceStatesRequest parseDelimitedFrom( - java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3.parseDelimitedWithIOException( - PARSER, input, extensionRegistry); - } - - public static com.google.cloud.iot.v1.ListDeviceStatesRequest parseFrom( - com.google.protobuf.CodedInputStream input) throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input); - } - - public static com.google.cloud.iot.v1.ListDeviceStatesRequest parseFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3.parseWithIOException( - PARSER, input, extensionRegistry); - } - - @java.lang.Override - public Builder newBuilderForType() { - return newBuilder(); - } - - public static Builder newBuilder() { - return DEFAULT_INSTANCE.toBuilder(); - } - - public static Builder newBuilder(com.google.cloud.iot.v1.ListDeviceStatesRequest prototype) { - return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); - } - - @java.lang.Override - public Builder toBuilder() { - return this == DEFAULT_INSTANCE ? new Builder() : new Builder().mergeFrom(this); - } - - @java.lang.Override - protected Builder newBuilderForType(com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { - Builder builder = new Builder(parent); - return builder; - } - /** - * - * - *
-   * Request for `ListDeviceStates`.
-   * 
- * - * Protobuf type {@code google.cloud.iot.v1.ListDeviceStatesRequest} - */ - public static final class Builder extends com.google.protobuf.GeneratedMessageV3.Builder - implements - // @@protoc_insertion_point(builder_implements:google.cloud.iot.v1.ListDeviceStatesRequest) - com.google.cloud.iot.v1.ListDeviceStatesRequestOrBuilder { - public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { - return com.google.cloud.iot.v1.DeviceManagerProto - .internal_static_google_cloud_iot_v1_ListDeviceStatesRequest_descriptor; - } - - @java.lang.Override - protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable - internalGetFieldAccessorTable() { - return com.google.cloud.iot.v1.DeviceManagerProto - .internal_static_google_cloud_iot_v1_ListDeviceStatesRequest_fieldAccessorTable - .ensureFieldAccessorsInitialized( - com.google.cloud.iot.v1.ListDeviceStatesRequest.class, - com.google.cloud.iot.v1.ListDeviceStatesRequest.Builder.class); - } - - // Construct using com.google.cloud.iot.v1.ListDeviceStatesRequest.newBuilder() - private Builder() {} - - private Builder(com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { - super(parent); - } - - @java.lang.Override - public Builder clear() { - super.clear(); - name_ = ""; - - numStates_ = 0; - - return this; - } - - @java.lang.Override - public com.google.protobuf.Descriptors.Descriptor getDescriptorForType() { - return com.google.cloud.iot.v1.DeviceManagerProto - .internal_static_google_cloud_iot_v1_ListDeviceStatesRequest_descriptor; - } - - @java.lang.Override - public com.google.cloud.iot.v1.ListDeviceStatesRequest getDefaultInstanceForType() { - return com.google.cloud.iot.v1.ListDeviceStatesRequest.getDefaultInstance(); - } - - @java.lang.Override - public com.google.cloud.iot.v1.ListDeviceStatesRequest build() { - com.google.cloud.iot.v1.ListDeviceStatesRequest result = buildPartial(); - if (!result.isInitialized()) { - throw newUninitializedMessageException(result); - } - return result; - } - - @java.lang.Override - public com.google.cloud.iot.v1.ListDeviceStatesRequest buildPartial() { - com.google.cloud.iot.v1.ListDeviceStatesRequest result = - new com.google.cloud.iot.v1.ListDeviceStatesRequest(this); - result.name_ = name_; - result.numStates_ = numStates_; - onBuilt(); - return result; - } - - @java.lang.Override - public Builder clone() { - return super.clone(); - } - - @java.lang.Override - public Builder setField( - com.google.protobuf.Descriptors.FieldDescriptor field, java.lang.Object value) { - return super.setField(field, value); - } - - @java.lang.Override - public Builder clearField(com.google.protobuf.Descriptors.FieldDescriptor field) { - return super.clearField(field); - } - - @java.lang.Override - public Builder clearOneof(com.google.protobuf.Descriptors.OneofDescriptor oneof) { - return super.clearOneof(oneof); - } - - @java.lang.Override - public Builder setRepeatedField( - com.google.protobuf.Descriptors.FieldDescriptor field, int index, java.lang.Object value) { - return super.setRepeatedField(field, index, value); - } - - @java.lang.Override - public Builder addRepeatedField( - com.google.protobuf.Descriptors.FieldDescriptor field, java.lang.Object value) { - return super.addRepeatedField(field, value); - } - - @java.lang.Override - public Builder mergeFrom(com.google.protobuf.Message other) { - if (other instanceof com.google.cloud.iot.v1.ListDeviceStatesRequest) { - return mergeFrom((com.google.cloud.iot.v1.ListDeviceStatesRequest) other); - } else { - super.mergeFrom(other); - return this; - } - } - - public Builder mergeFrom(com.google.cloud.iot.v1.ListDeviceStatesRequest other) { - if (other == com.google.cloud.iot.v1.ListDeviceStatesRequest.getDefaultInstance()) - return this; - if (!other.getName().isEmpty()) { - name_ = other.name_; - onChanged(); - } - if (other.getNumStates() != 0) { - setNumStates(other.getNumStates()); - } - this.mergeUnknownFields(other.getUnknownFields()); - onChanged(); - return this; - } - - @java.lang.Override - public final boolean isInitialized() { - return true; - } - - @java.lang.Override - public Builder mergeFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - if (extensionRegistry == null) { - throw new java.lang.NullPointerException(); - } - try { - boolean done = false; - while (!done) { - int tag = input.readTag(); - switch (tag) { - case 0: - done = true; - break; - case 10: - { - name_ = input.readStringRequireUtf8(); - - break; - } // case 10 - case 16: - { - numStates_ = input.readInt32(); - - break; - } // case 16 - default: - { - if (!super.parseUnknownField(input, extensionRegistry, tag)) { - done = true; // was an endgroup tag - } - break; - } // default: - } // switch (tag) - } // while (!done) - } catch (com.google.protobuf.InvalidProtocolBufferException e) { - throw e.unwrapIOException(); - } finally { - onChanged(); - } // finally - return this; - } - - private java.lang.Object name_ = ""; - /** - * - * - *
-     * Required. The name of the device. For example,
-     * `projects/p0/locations/us-central1/registries/registry0/devices/device0` or
-     * `projects/p0/locations/us-central1/registries/registry0/devices/{num_id}`.
-     * 
- * - * - * string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } - * - * - * @return The name. - */ - public java.lang.String getName() { - java.lang.Object ref = name_; - if (!(ref instanceof java.lang.String)) { - com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; - java.lang.String s = bs.toStringUtf8(); - name_ = s; - return s; - } else { - return (java.lang.String) ref; - } - } - /** - * - * - *
-     * Required. The name of the device. For example,
-     * `projects/p0/locations/us-central1/registries/registry0/devices/device0` or
-     * `projects/p0/locations/us-central1/registries/registry0/devices/{num_id}`.
-     * 
- * - * - * string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } - * - * - * @return The bytes for name. - */ - public com.google.protobuf.ByteString getNameBytes() { - java.lang.Object ref = name_; - if (ref instanceof String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); - name_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - /** - * - * - *
-     * Required. The name of the device. For example,
-     * `projects/p0/locations/us-central1/registries/registry0/devices/device0` or
-     * `projects/p0/locations/us-central1/registries/registry0/devices/{num_id}`.
-     * 
- * - * - * string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } - * - * - * @param value The name to set. - * @return This builder for chaining. - */ - public Builder setName(java.lang.String value) { - if (value == null) { - throw new NullPointerException(); - } - - name_ = value; - onChanged(); - return this; - } - /** - * - * - *
-     * Required. The name of the device. For example,
-     * `projects/p0/locations/us-central1/registries/registry0/devices/device0` or
-     * `projects/p0/locations/us-central1/registries/registry0/devices/{num_id}`.
-     * 
- * - * - * string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } - * - * - * @return This builder for chaining. - */ - public Builder clearName() { - - name_ = getDefaultInstance().getName(); - onChanged(); - return this; - } - /** - * - * - *
-     * Required. The name of the device. For example,
-     * `projects/p0/locations/us-central1/registries/registry0/devices/device0` or
-     * `projects/p0/locations/us-central1/registries/registry0/devices/{num_id}`.
-     * 
- * - * - * string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } - * - * - * @param value The bytes for name to set. - * @return This builder for chaining. - */ - public Builder setNameBytes(com.google.protobuf.ByteString value) { - if (value == null) { - throw new NullPointerException(); - } - checkByteStringIsUtf8(value); - - name_ = value; - onChanged(); - return this; - } - - private int numStates_; - /** - * - * - *
-     * The number of states to list. States are listed in descending order of
-     * update time. The maximum number of states retained is 10. If this
-     * value is zero, it will return all the states available.
-     * 
- * - * int32 num_states = 2; - * - * @return The numStates. - */ - @java.lang.Override - public int getNumStates() { - return numStates_; - } - /** - * - * - *
-     * The number of states to list. States are listed in descending order of
-     * update time. The maximum number of states retained is 10. If this
-     * value is zero, it will return all the states available.
-     * 
- * - * int32 num_states = 2; - * - * @param value The numStates to set. - * @return This builder for chaining. - */ - public Builder setNumStates(int value) { - - numStates_ = value; - onChanged(); - return this; - } - /** - * - * - *
-     * The number of states to list. States are listed in descending order of
-     * update time. The maximum number of states retained is 10. If this
-     * value is zero, it will return all the states available.
-     * 
- * - * int32 num_states = 2; - * - * @return This builder for chaining. - */ - public Builder clearNumStates() { - - numStates_ = 0; - onChanged(); - return this; - } - - @java.lang.Override - public final Builder setUnknownFields(final com.google.protobuf.UnknownFieldSet unknownFields) { - return super.setUnknownFields(unknownFields); - } - - @java.lang.Override - public final Builder mergeUnknownFields( - final com.google.protobuf.UnknownFieldSet unknownFields) { - return super.mergeUnknownFields(unknownFields); - } - - // @@protoc_insertion_point(builder_scope:google.cloud.iot.v1.ListDeviceStatesRequest) - } - - // @@protoc_insertion_point(class_scope:google.cloud.iot.v1.ListDeviceStatesRequest) - private static final com.google.cloud.iot.v1.ListDeviceStatesRequest DEFAULT_INSTANCE; - - static { - DEFAULT_INSTANCE = new com.google.cloud.iot.v1.ListDeviceStatesRequest(); - } - - public static com.google.cloud.iot.v1.ListDeviceStatesRequest getDefaultInstance() { - return DEFAULT_INSTANCE; - } - - private static final com.google.protobuf.Parser PARSER = - new com.google.protobuf.AbstractParser() { - @java.lang.Override - public ListDeviceStatesRequest parsePartialFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - Builder builder = newBuilder(); - try { - builder.mergeFrom(input, extensionRegistry); - } catch (com.google.protobuf.InvalidProtocolBufferException e) { - throw e.setUnfinishedMessage(builder.buildPartial()); - } catch (com.google.protobuf.UninitializedMessageException e) { - throw e.asInvalidProtocolBufferException().setUnfinishedMessage(builder.buildPartial()); - } catch (java.io.IOException e) { - throw new com.google.protobuf.InvalidProtocolBufferException(e) - .setUnfinishedMessage(builder.buildPartial()); - } - return builder.buildPartial(); - } - }; - - public static com.google.protobuf.Parser parser() { - return PARSER; - } - - @java.lang.Override - public com.google.protobuf.Parser getParserForType() { - return PARSER; - } - - @java.lang.Override - public com.google.cloud.iot.v1.ListDeviceStatesRequest getDefaultInstanceForType() { - return DEFAULT_INSTANCE; - } -} diff --git a/proto-google-cloud-iot-v1/src/main/java/com/google/cloud/iot/v1/ListDeviceStatesRequestOrBuilder.java b/proto-google-cloud-iot-v1/src/main/java/com/google/cloud/iot/v1/ListDeviceStatesRequestOrBuilder.java deleted file mode 100644 index dd4137a8..00000000 --- a/proto-google-cloud-iot-v1/src/main/java/com/google/cloud/iot/v1/ListDeviceStatesRequestOrBuilder.java +++ /dev/null @@ -1,73 +0,0 @@ -/* - * Copyright 2020 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. - */ -// Generated by the protocol buffer compiler. DO NOT EDIT! -// source: google/cloud/iot/v1/device_manager.proto - -package com.google.cloud.iot.v1; - -public interface ListDeviceStatesRequestOrBuilder - extends - // @@protoc_insertion_point(interface_extends:google.cloud.iot.v1.ListDeviceStatesRequest) - com.google.protobuf.MessageOrBuilder { - - /** - * - * - *
-   * Required. The name of the device. For example,
-   * `projects/p0/locations/us-central1/registries/registry0/devices/device0` or
-   * `projects/p0/locations/us-central1/registries/registry0/devices/{num_id}`.
-   * 
- * - * - * string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } - * - * - * @return The name. - */ - java.lang.String getName(); - /** - * - * - *
-   * Required. The name of the device. For example,
-   * `projects/p0/locations/us-central1/registries/registry0/devices/device0` or
-   * `projects/p0/locations/us-central1/registries/registry0/devices/{num_id}`.
-   * 
- * - * - * string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } - * - * - * @return The bytes for name. - */ - com.google.protobuf.ByteString getNameBytes(); - - /** - * - * - *
-   * The number of states to list. States are listed in descending order of
-   * update time. The maximum number of states retained is 10. If this
-   * value is zero, it will return all the states available.
-   * 
- * - * int32 num_states = 2; - * - * @return The numStates. - */ - int getNumStates(); -} diff --git a/proto-google-cloud-iot-v1/src/main/java/com/google/cloud/iot/v1/ListDeviceStatesResponse.java b/proto-google-cloud-iot-v1/src/main/java/com/google/cloud/iot/v1/ListDeviceStatesResponse.java deleted file mode 100644 index 522b6fe5..00000000 --- a/proto-google-cloud-iot-v1/src/main/java/com/google/cloud/iot/v1/ListDeviceStatesResponse.java +++ /dev/null @@ -1,949 +0,0 @@ -/* - * Copyright 2020 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. - */ -// Generated by the protocol buffer compiler. DO NOT EDIT! -// source: google/cloud/iot/v1/device_manager.proto - -package com.google.cloud.iot.v1; - -/** - * - * - *
- * Response for `ListDeviceStates`.
- * 
- * - * Protobuf type {@code google.cloud.iot.v1.ListDeviceStatesResponse} - */ -public final class ListDeviceStatesResponse extends com.google.protobuf.GeneratedMessageV3 - implements - // @@protoc_insertion_point(message_implements:google.cloud.iot.v1.ListDeviceStatesResponse) - ListDeviceStatesResponseOrBuilder { - private static final long serialVersionUID = 0L; - // Use ListDeviceStatesResponse.newBuilder() to construct. - private ListDeviceStatesResponse(com.google.protobuf.GeneratedMessageV3.Builder builder) { - super(builder); - } - - private ListDeviceStatesResponse() { - deviceStates_ = java.util.Collections.emptyList(); - } - - @java.lang.Override - @SuppressWarnings({"unused"}) - protected java.lang.Object newInstance(UnusedPrivateParameter unused) { - return new ListDeviceStatesResponse(); - } - - @java.lang.Override - public final com.google.protobuf.UnknownFieldSet getUnknownFields() { - return this.unknownFields; - } - - public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { - return com.google.cloud.iot.v1.DeviceManagerProto - .internal_static_google_cloud_iot_v1_ListDeviceStatesResponse_descriptor; - } - - @java.lang.Override - protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable - internalGetFieldAccessorTable() { - return com.google.cloud.iot.v1.DeviceManagerProto - .internal_static_google_cloud_iot_v1_ListDeviceStatesResponse_fieldAccessorTable - .ensureFieldAccessorsInitialized( - com.google.cloud.iot.v1.ListDeviceStatesResponse.class, - com.google.cloud.iot.v1.ListDeviceStatesResponse.Builder.class); - } - - public static final int DEVICE_STATES_FIELD_NUMBER = 1; - private java.util.List deviceStates_; - /** - * - * - *
-   * The last few device states. States are listed in descending order of server
-   * update time, starting from the most recent one.
-   * 
- * - * repeated .google.cloud.iot.v1.DeviceState device_states = 1; - */ - @java.lang.Override - public java.util.List getDeviceStatesList() { - return deviceStates_; - } - /** - * - * - *
-   * The last few device states. States are listed in descending order of server
-   * update time, starting from the most recent one.
-   * 
- * - * repeated .google.cloud.iot.v1.DeviceState device_states = 1; - */ - @java.lang.Override - public java.util.List - getDeviceStatesOrBuilderList() { - return deviceStates_; - } - /** - * - * - *
-   * The last few device states. States are listed in descending order of server
-   * update time, starting from the most recent one.
-   * 
- * - * repeated .google.cloud.iot.v1.DeviceState device_states = 1; - */ - @java.lang.Override - public int getDeviceStatesCount() { - return deviceStates_.size(); - } - /** - * - * - *
-   * The last few device states. States are listed in descending order of server
-   * update time, starting from the most recent one.
-   * 
- * - * repeated .google.cloud.iot.v1.DeviceState device_states = 1; - */ - @java.lang.Override - public com.google.cloud.iot.v1.DeviceState getDeviceStates(int index) { - return deviceStates_.get(index); - } - /** - * - * - *
-   * The last few device states. States are listed in descending order of server
-   * update time, starting from the most recent one.
-   * 
- * - * repeated .google.cloud.iot.v1.DeviceState device_states = 1; - */ - @java.lang.Override - public com.google.cloud.iot.v1.DeviceStateOrBuilder getDeviceStatesOrBuilder(int index) { - return deviceStates_.get(index); - } - - private byte memoizedIsInitialized = -1; - - @java.lang.Override - public final boolean isInitialized() { - byte isInitialized = memoizedIsInitialized; - if (isInitialized == 1) return true; - if (isInitialized == 0) return false; - - memoizedIsInitialized = 1; - return true; - } - - @java.lang.Override - public void writeTo(com.google.protobuf.CodedOutputStream output) throws java.io.IOException { - for (int i = 0; i < deviceStates_.size(); i++) { - output.writeMessage(1, deviceStates_.get(i)); - } - getUnknownFields().writeTo(output); - } - - @java.lang.Override - public int getSerializedSize() { - int size = memoizedSize; - if (size != -1) return size; - - size = 0; - for (int i = 0; i < deviceStates_.size(); i++) { - size += com.google.protobuf.CodedOutputStream.computeMessageSize(1, deviceStates_.get(i)); - } - size += getUnknownFields().getSerializedSize(); - memoizedSize = size; - return size; - } - - @java.lang.Override - public boolean equals(final java.lang.Object obj) { - if (obj == this) { - return true; - } - if (!(obj instanceof com.google.cloud.iot.v1.ListDeviceStatesResponse)) { - return super.equals(obj); - } - com.google.cloud.iot.v1.ListDeviceStatesResponse other = - (com.google.cloud.iot.v1.ListDeviceStatesResponse) obj; - - if (!getDeviceStatesList().equals(other.getDeviceStatesList())) return false; - if (!getUnknownFields().equals(other.getUnknownFields())) return false; - return true; - } - - @java.lang.Override - public int hashCode() { - if (memoizedHashCode != 0) { - return memoizedHashCode; - } - int hash = 41; - hash = (19 * hash) + getDescriptor().hashCode(); - if (getDeviceStatesCount() > 0) { - hash = (37 * hash) + DEVICE_STATES_FIELD_NUMBER; - hash = (53 * hash) + getDeviceStatesList().hashCode(); - } - hash = (29 * hash) + getUnknownFields().hashCode(); - memoizedHashCode = hash; - return hash; - } - - public static com.google.cloud.iot.v1.ListDeviceStatesResponse parseFrom(java.nio.ByteBuffer data) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); - } - - public static com.google.cloud.iot.v1.ListDeviceStatesResponse parseFrom( - java.nio.ByteBuffer data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); - } - - public static com.google.cloud.iot.v1.ListDeviceStatesResponse parseFrom( - com.google.protobuf.ByteString data) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); - } - - public static com.google.cloud.iot.v1.ListDeviceStatesResponse parseFrom( - com.google.protobuf.ByteString data, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); - } - - public static com.google.cloud.iot.v1.ListDeviceStatesResponse parseFrom(byte[] data) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); - } - - public static com.google.cloud.iot.v1.ListDeviceStatesResponse parseFrom( - byte[] data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); - } - - public static com.google.cloud.iot.v1.ListDeviceStatesResponse parseFrom( - java.io.InputStream input) throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input); - } - - public static com.google.cloud.iot.v1.ListDeviceStatesResponse parseFrom( - java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3.parseWithIOException( - PARSER, input, extensionRegistry); - } - - public static com.google.cloud.iot.v1.ListDeviceStatesResponse parseDelimitedFrom( - java.io.InputStream input) throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3.parseDelimitedWithIOException(PARSER, input); - } - - public static com.google.cloud.iot.v1.ListDeviceStatesResponse parseDelimitedFrom( - java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3.parseDelimitedWithIOException( - PARSER, input, extensionRegistry); - } - - public static com.google.cloud.iot.v1.ListDeviceStatesResponse parseFrom( - com.google.protobuf.CodedInputStream input) throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input); - } - - public static com.google.cloud.iot.v1.ListDeviceStatesResponse parseFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3.parseWithIOException( - PARSER, input, extensionRegistry); - } - - @java.lang.Override - public Builder newBuilderForType() { - return newBuilder(); - } - - public static Builder newBuilder() { - return DEFAULT_INSTANCE.toBuilder(); - } - - public static Builder newBuilder(com.google.cloud.iot.v1.ListDeviceStatesResponse prototype) { - return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); - } - - @java.lang.Override - public Builder toBuilder() { - return this == DEFAULT_INSTANCE ? new Builder() : new Builder().mergeFrom(this); - } - - @java.lang.Override - protected Builder newBuilderForType(com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { - Builder builder = new Builder(parent); - return builder; - } - /** - * - * - *
-   * Response for `ListDeviceStates`.
-   * 
- * - * Protobuf type {@code google.cloud.iot.v1.ListDeviceStatesResponse} - */ - public static final class Builder extends com.google.protobuf.GeneratedMessageV3.Builder - implements - // @@protoc_insertion_point(builder_implements:google.cloud.iot.v1.ListDeviceStatesResponse) - com.google.cloud.iot.v1.ListDeviceStatesResponseOrBuilder { - public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { - return com.google.cloud.iot.v1.DeviceManagerProto - .internal_static_google_cloud_iot_v1_ListDeviceStatesResponse_descriptor; - } - - @java.lang.Override - protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable - internalGetFieldAccessorTable() { - return com.google.cloud.iot.v1.DeviceManagerProto - .internal_static_google_cloud_iot_v1_ListDeviceStatesResponse_fieldAccessorTable - .ensureFieldAccessorsInitialized( - com.google.cloud.iot.v1.ListDeviceStatesResponse.class, - com.google.cloud.iot.v1.ListDeviceStatesResponse.Builder.class); - } - - // Construct using com.google.cloud.iot.v1.ListDeviceStatesResponse.newBuilder() - private Builder() {} - - private Builder(com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { - super(parent); - } - - @java.lang.Override - public Builder clear() { - super.clear(); - if (deviceStatesBuilder_ == null) { - deviceStates_ = java.util.Collections.emptyList(); - } else { - deviceStates_ = null; - deviceStatesBuilder_.clear(); - } - bitField0_ = (bitField0_ & ~0x00000001); - return this; - } - - @java.lang.Override - public com.google.protobuf.Descriptors.Descriptor getDescriptorForType() { - return com.google.cloud.iot.v1.DeviceManagerProto - .internal_static_google_cloud_iot_v1_ListDeviceStatesResponse_descriptor; - } - - @java.lang.Override - public com.google.cloud.iot.v1.ListDeviceStatesResponse getDefaultInstanceForType() { - return com.google.cloud.iot.v1.ListDeviceStatesResponse.getDefaultInstance(); - } - - @java.lang.Override - public com.google.cloud.iot.v1.ListDeviceStatesResponse build() { - com.google.cloud.iot.v1.ListDeviceStatesResponse result = buildPartial(); - if (!result.isInitialized()) { - throw newUninitializedMessageException(result); - } - return result; - } - - @java.lang.Override - public com.google.cloud.iot.v1.ListDeviceStatesResponse buildPartial() { - com.google.cloud.iot.v1.ListDeviceStatesResponse result = - new com.google.cloud.iot.v1.ListDeviceStatesResponse(this); - int from_bitField0_ = bitField0_; - if (deviceStatesBuilder_ == null) { - if (((bitField0_ & 0x00000001) != 0)) { - deviceStates_ = java.util.Collections.unmodifiableList(deviceStates_); - bitField0_ = (bitField0_ & ~0x00000001); - } - result.deviceStates_ = deviceStates_; - } else { - result.deviceStates_ = deviceStatesBuilder_.build(); - } - onBuilt(); - return result; - } - - @java.lang.Override - public Builder clone() { - return super.clone(); - } - - @java.lang.Override - public Builder setField( - com.google.protobuf.Descriptors.FieldDescriptor field, java.lang.Object value) { - return super.setField(field, value); - } - - @java.lang.Override - public Builder clearField(com.google.protobuf.Descriptors.FieldDescriptor field) { - return super.clearField(field); - } - - @java.lang.Override - public Builder clearOneof(com.google.protobuf.Descriptors.OneofDescriptor oneof) { - return super.clearOneof(oneof); - } - - @java.lang.Override - public Builder setRepeatedField( - com.google.protobuf.Descriptors.FieldDescriptor field, int index, java.lang.Object value) { - return super.setRepeatedField(field, index, value); - } - - @java.lang.Override - public Builder addRepeatedField( - com.google.protobuf.Descriptors.FieldDescriptor field, java.lang.Object value) { - return super.addRepeatedField(field, value); - } - - @java.lang.Override - public Builder mergeFrom(com.google.protobuf.Message other) { - if (other instanceof com.google.cloud.iot.v1.ListDeviceStatesResponse) { - return mergeFrom((com.google.cloud.iot.v1.ListDeviceStatesResponse) other); - } else { - super.mergeFrom(other); - return this; - } - } - - public Builder mergeFrom(com.google.cloud.iot.v1.ListDeviceStatesResponse other) { - if (other == com.google.cloud.iot.v1.ListDeviceStatesResponse.getDefaultInstance()) - return this; - if (deviceStatesBuilder_ == null) { - if (!other.deviceStates_.isEmpty()) { - if (deviceStates_.isEmpty()) { - deviceStates_ = other.deviceStates_; - bitField0_ = (bitField0_ & ~0x00000001); - } else { - ensureDeviceStatesIsMutable(); - deviceStates_.addAll(other.deviceStates_); - } - onChanged(); - } - } else { - if (!other.deviceStates_.isEmpty()) { - if (deviceStatesBuilder_.isEmpty()) { - deviceStatesBuilder_.dispose(); - deviceStatesBuilder_ = null; - deviceStates_ = other.deviceStates_; - bitField0_ = (bitField0_ & ~0x00000001); - deviceStatesBuilder_ = - com.google.protobuf.GeneratedMessageV3.alwaysUseFieldBuilders - ? getDeviceStatesFieldBuilder() - : null; - } else { - deviceStatesBuilder_.addAllMessages(other.deviceStates_); - } - } - } - this.mergeUnknownFields(other.getUnknownFields()); - onChanged(); - return this; - } - - @java.lang.Override - public final boolean isInitialized() { - return true; - } - - @java.lang.Override - public Builder mergeFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - if (extensionRegistry == null) { - throw new java.lang.NullPointerException(); - } - try { - boolean done = false; - while (!done) { - int tag = input.readTag(); - switch (tag) { - case 0: - done = true; - break; - case 10: - { - com.google.cloud.iot.v1.DeviceState m = - input.readMessage( - com.google.cloud.iot.v1.DeviceState.parser(), extensionRegistry); - if (deviceStatesBuilder_ == null) { - ensureDeviceStatesIsMutable(); - deviceStates_.add(m); - } else { - deviceStatesBuilder_.addMessage(m); - } - break; - } // case 10 - default: - { - if (!super.parseUnknownField(input, extensionRegistry, tag)) { - done = true; // was an endgroup tag - } - break; - } // default: - } // switch (tag) - } // while (!done) - } catch (com.google.protobuf.InvalidProtocolBufferException e) { - throw e.unwrapIOException(); - } finally { - onChanged(); - } // finally - return this; - } - - private int bitField0_; - - private java.util.List deviceStates_ = - java.util.Collections.emptyList(); - - private void ensureDeviceStatesIsMutable() { - if (!((bitField0_ & 0x00000001) != 0)) { - deviceStates_ = new java.util.ArrayList(deviceStates_); - bitField0_ |= 0x00000001; - } - } - - private com.google.protobuf.RepeatedFieldBuilderV3< - com.google.cloud.iot.v1.DeviceState, - com.google.cloud.iot.v1.DeviceState.Builder, - com.google.cloud.iot.v1.DeviceStateOrBuilder> - deviceStatesBuilder_; - - /** - * - * - *
-     * The last few device states. States are listed in descending order of server
-     * update time, starting from the most recent one.
-     * 
- * - * repeated .google.cloud.iot.v1.DeviceState device_states = 1; - */ - public java.util.List getDeviceStatesList() { - if (deviceStatesBuilder_ == null) { - return java.util.Collections.unmodifiableList(deviceStates_); - } else { - return deviceStatesBuilder_.getMessageList(); - } - } - /** - * - * - *
-     * The last few device states. States are listed in descending order of server
-     * update time, starting from the most recent one.
-     * 
- * - * repeated .google.cloud.iot.v1.DeviceState device_states = 1; - */ - public int getDeviceStatesCount() { - if (deviceStatesBuilder_ == null) { - return deviceStates_.size(); - } else { - return deviceStatesBuilder_.getCount(); - } - } - /** - * - * - *
-     * The last few device states. States are listed in descending order of server
-     * update time, starting from the most recent one.
-     * 
- * - * repeated .google.cloud.iot.v1.DeviceState device_states = 1; - */ - public com.google.cloud.iot.v1.DeviceState getDeviceStates(int index) { - if (deviceStatesBuilder_ == null) { - return deviceStates_.get(index); - } else { - return deviceStatesBuilder_.getMessage(index); - } - } - /** - * - * - *
-     * The last few device states. States are listed in descending order of server
-     * update time, starting from the most recent one.
-     * 
- * - * repeated .google.cloud.iot.v1.DeviceState device_states = 1; - */ - public Builder setDeviceStates(int index, com.google.cloud.iot.v1.DeviceState value) { - if (deviceStatesBuilder_ == null) { - if (value == null) { - throw new NullPointerException(); - } - ensureDeviceStatesIsMutable(); - deviceStates_.set(index, value); - onChanged(); - } else { - deviceStatesBuilder_.setMessage(index, value); - } - return this; - } - /** - * - * - *
-     * The last few device states. States are listed in descending order of server
-     * update time, starting from the most recent one.
-     * 
- * - * repeated .google.cloud.iot.v1.DeviceState device_states = 1; - */ - public Builder setDeviceStates( - int index, com.google.cloud.iot.v1.DeviceState.Builder builderForValue) { - if (deviceStatesBuilder_ == null) { - ensureDeviceStatesIsMutable(); - deviceStates_.set(index, builderForValue.build()); - onChanged(); - } else { - deviceStatesBuilder_.setMessage(index, builderForValue.build()); - } - return this; - } - /** - * - * - *
-     * The last few device states. States are listed in descending order of server
-     * update time, starting from the most recent one.
-     * 
- * - * repeated .google.cloud.iot.v1.DeviceState device_states = 1; - */ - public Builder addDeviceStates(com.google.cloud.iot.v1.DeviceState value) { - if (deviceStatesBuilder_ == null) { - if (value == null) { - throw new NullPointerException(); - } - ensureDeviceStatesIsMutable(); - deviceStates_.add(value); - onChanged(); - } else { - deviceStatesBuilder_.addMessage(value); - } - return this; - } - /** - * - * - *
-     * The last few device states. States are listed in descending order of server
-     * update time, starting from the most recent one.
-     * 
- * - * repeated .google.cloud.iot.v1.DeviceState device_states = 1; - */ - public Builder addDeviceStates(int index, com.google.cloud.iot.v1.DeviceState value) { - if (deviceStatesBuilder_ == null) { - if (value == null) { - throw new NullPointerException(); - } - ensureDeviceStatesIsMutable(); - deviceStates_.add(index, value); - onChanged(); - } else { - deviceStatesBuilder_.addMessage(index, value); - } - return this; - } - /** - * - * - *
-     * The last few device states. States are listed in descending order of server
-     * update time, starting from the most recent one.
-     * 
- * - * repeated .google.cloud.iot.v1.DeviceState device_states = 1; - */ - public Builder addDeviceStates(com.google.cloud.iot.v1.DeviceState.Builder builderForValue) { - if (deviceStatesBuilder_ == null) { - ensureDeviceStatesIsMutable(); - deviceStates_.add(builderForValue.build()); - onChanged(); - } else { - deviceStatesBuilder_.addMessage(builderForValue.build()); - } - return this; - } - /** - * - * - *
-     * The last few device states. States are listed in descending order of server
-     * update time, starting from the most recent one.
-     * 
- * - * repeated .google.cloud.iot.v1.DeviceState device_states = 1; - */ - public Builder addDeviceStates( - int index, com.google.cloud.iot.v1.DeviceState.Builder builderForValue) { - if (deviceStatesBuilder_ == null) { - ensureDeviceStatesIsMutable(); - deviceStates_.add(index, builderForValue.build()); - onChanged(); - } else { - deviceStatesBuilder_.addMessage(index, builderForValue.build()); - } - return this; - } - /** - * - * - *
-     * The last few device states. States are listed in descending order of server
-     * update time, starting from the most recent one.
-     * 
- * - * repeated .google.cloud.iot.v1.DeviceState device_states = 1; - */ - public Builder addAllDeviceStates( - java.lang.Iterable values) { - if (deviceStatesBuilder_ == null) { - ensureDeviceStatesIsMutable(); - com.google.protobuf.AbstractMessageLite.Builder.addAll(values, deviceStates_); - onChanged(); - } else { - deviceStatesBuilder_.addAllMessages(values); - } - return this; - } - /** - * - * - *
-     * The last few device states. States are listed in descending order of server
-     * update time, starting from the most recent one.
-     * 
- * - * repeated .google.cloud.iot.v1.DeviceState device_states = 1; - */ - public Builder clearDeviceStates() { - if (deviceStatesBuilder_ == null) { - deviceStates_ = java.util.Collections.emptyList(); - bitField0_ = (bitField0_ & ~0x00000001); - onChanged(); - } else { - deviceStatesBuilder_.clear(); - } - return this; - } - /** - * - * - *
-     * The last few device states. States are listed in descending order of server
-     * update time, starting from the most recent one.
-     * 
- * - * repeated .google.cloud.iot.v1.DeviceState device_states = 1; - */ - public Builder removeDeviceStates(int index) { - if (deviceStatesBuilder_ == null) { - ensureDeviceStatesIsMutable(); - deviceStates_.remove(index); - onChanged(); - } else { - deviceStatesBuilder_.remove(index); - } - return this; - } - /** - * - * - *
-     * The last few device states. States are listed in descending order of server
-     * update time, starting from the most recent one.
-     * 
- * - * repeated .google.cloud.iot.v1.DeviceState device_states = 1; - */ - public com.google.cloud.iot.v1.DeviceState.Builder getDeviceStatesBuilder(int index) { - return getDeviceStatesFieldBuilder().getBuilder(index); - } - /** - * - * - *
-     * The last few device states. States are listed in descending order of server
-     * update time, starting from the most recent one.
-     * 
- * - * repeated .google.cloud.iot.v1.DeviceState device_states = 1; - */ - public com.google.cloud.iot.v1.DeviceStateOrBuilder getDeviceStatesOrBuilder(int index) { - if (deviceStatesBuilder_ == null) { - return deviceStates_.get(index); - } else { - return deviceStatesBuilder_.getMessageOrBuilder(index); - } - } - /** - * - * - *
-     * The last few device states. States are listed in descending order of server
-     * update time, starting from the most recent one.
-     * 
- * - * repeated .google.cloud.iot.v1.DeviceState device_states = 1; - */ - public java.util.List - getDeviceStatesOrBuilderList() { - if (deviceStatesBuilder_ != null) { - return deviceStatesBuilder_.getMessageOrBuilderList(); - } else { - return java.util.Collections.unmodifiableList(deviceStates_); - } - } - /** - * - * - *
-     * The last few device states. States are listed in descending order of server
-     * update time, starting from the most recent one.
-     * 
- * - * repeated .google.cloud.iot.v1.DeviceState device_states = 1; - */ - public com.google.cloud.iot.v1.DeviceState.Builder addDeviceStatesBuilder() { - return getDeviceStatesFieldBuilder() - .addBuilder(com.google.cloud.iot.v1.DeviceState.getDefaultInstance()); - } - /** - * - * - *
-     * The last few device states. States are listed in descending order of server
-     * update time, starting from the most recent one.
-     * 
- * - * repeated .google.cloud.iot.v1.DeviceState device_states = 1; - */ - public com.google.cloud.iot.v1.DeviceState.Builder addDeviceStatesBuilder(int index) { - return getDeviceStatesFieldBuilder() - .addBuilder(index, com.google.cloud.iot.v1.DeviceState.getDefaultInstance()); - } - /** - * - * - *
-     * The last few device states. States are listed in descending order of server
-     * update time, starting from the most recent one.
-     * 
- * - * repeated .google.cloud.iot.v1.DeviceState device_states = 1; - */ - public java.util.List - getDeviceStatesBuilderList() { - return getDeviceStatesFieldBuilder().getBuilderList(); - } - - private com.google.protobuf.RepeatedFieldBuilderV3< - com.google.cloud.iot.v1.DeviceState, - com.google.cloud.iot.v1.DeviceState.Builder, - com.google.cloud.iot.v1.DeviceStateOrBuilder> - getDeviceStatesFieldBuilder() { - if (deviceStatesBuilder_ == null) { - deviceStatesBuilder_ = - new com.google.protobuf.RepeatedFieldBuilderV3< - com.google.cloud.iot.v1.DeviceState, - com.google.cloud.iot.v1.DeviceState.Builder, - com.google.cloud.iot.v1.DeviceStateOrBuilder>( - deviceStates_, ((bitField0_ & 0x00000001) != 0), getParentForChildren(), isClean()); - deviceStates_ = null; - } - return deviceStatesBuilder_; - } - - @java.lang.Override - public final Builder setUnknownFields(final com.google.protobuf.UnknownFieldSet unknownFields) { - return super.setUnknownFields(unknownFields); - } - - @java.lang.Override - public final Builder mergeUnknownFields( - final com.google.protobuf.UnknownFieldSet unknownFields) { - return super.mergeUnknownFields(unknownFields); - } - - // @@protoc_insertion_point(builder_scope:google.cloud.iot.v1.ListDeviceStatesResponse) - } - - // @@protoc_insertion_point(class_scope:google.cloud.iot.v1.ListDeviceStatesResponse) - private static final com.google.cloud.iot.v1.ListDeviceStatesResponse DEFAULT_INSTANCE; - - static { - DEFAULT_INSTANCE = new com.google.cloud.iot.v1.ListDeviceStatesResponse(); - } - - public static com.google.cloud.iot.v1.ListDeviceStatesResponse getDefaultInstance() { - return DEFAULT_INSTANCE; - } - - private static final com.google.protobuf.Parser PARSER = - new com.google.protobuf.AbstractParser() { - @java.lang.Override - public ListDeviceStatesResponse parsePartialFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - Builder builder = newBuilder(); - try { - builder.mergeFrom(input, extensionRegistry); - } catch (com.google.protobuf.InvalidProtocolBufferException e) { - throw e.setUnfinishedMessage(builder.buildPartial()); - } catch (com.google.protobuf.UninitializedMessageException e) { - throw e.asInvalidProtocolBufferException().setUnfinishedMessage(builder.buildPartial()); - } catch (java.io.IOException e) { - throw new com.google.protobuf.InvalidProtocolBufferException(e) - .setUnfinishedMessage(builder.buildPartial()); - } - return builder.buildPartial(); - } - }; - - public static com.google.protobuf.Parser parser() { - return PARSER; - } - - @java.lang.Override - public com.google.protobuf.Parser getParserForType() { - return PARSER; - } - - @java.lang.Override - public com.google.cloud.iot.v1.ListDeviceStatesResponse getDefaultInstanceForType() { - return DEFAULT_INSTANCE; - } -} diff --git a/proto-google-cloud-iot-v1/src/main/java/com/google/cloud/iot/v1/ListDeviceStatesResponseOrBuilder.java b/proto-google-cloud-iot-v1/src/main/java/com/google/cloud/iot/v1/ListDeviceStatesResponseOrBuilder.java deleted file mode 100644 index 90f12b2f..00000000 --- a/proto-google-cloud-iot-v1/src/main/java/com/google/cloud/iot/v1/ListDeviceStatesResponseOrBuilder.java +++ /dev/null @@ -1,82 +0,0 @@ -/* - * Copyright 2020 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. - */ -// Generated by the protocol buffer compiler. DO NOT EDIT! -// source: google/cloud/iot/v1/device_manager.proto - -package com.google.cloud.iot.v1; - -public interface ListDeviceStatesResponseOrBuilder - extends - // @@protoc_insertion_point(interface_extends:google.cloud.iot.v1.ListDeviceStatesResponse) - com.google.protobuf.MessageOrBuilder { - - /** - * - * - *
-   * The last few device states. States are listed in descending order of server
-   * update time, starting from the most recent one.
-   * 
- * - * repeated .google.cloud.iot.v1.DeviceState device_states = 1; - */ - java.util.List getDeviceStatesList(); - /** - * - * - *
-   * The last few device states. States are listed in descending order of server
-   * update time, starting from the most recent one.
-   * 
- * - * repeated .google.cloud.iot.v1.DeviceState device_states = 1; - */ - com.google.cloud.iot.v1.DeviceState getDeviceStates(int index); - /** - * - * - *
-   * The last few device states. States are listed in descending order of server
-   * update time, starting from the most recent one.
-   * 
- * - * repeated .google.cloud.iot.v1.DeviceState device_states = 1; - */ - int getDeviceStatesCount(); - /** - * - * - *
-   * The last few device states. States are listed in descending order of server
-   * update time, starting from the most recent one.
-   * 
- * - * repeated .google.cloud.iot.v1.DeviceState device_states = 1; - */ - java.util.List - getDeviceStatesOrBuilderList(); - /** - * - * - *
-   * The last few device states. States are listed in descending order of server
-   * update time, starting from the most recent one.
-   * 
- * - * repeated .google.cloud.iot.v1.DeviceState device_states = 1; - */ - com.google.cloud.iot.v1.DeviceStateOrBuilder getDeviceStatesOrBuilder(int index); -} diff --git a/proto-google-cloud-iot-v1/src/main/java/com/google/cloud/iot/v1/ListDevicesRequest.java b/proto-google-cloud-iot-v1/src/main/java/com/google/cloud/iot/v1/ListDevicesRequest.java deleted file mode 100644 index 15030a4f..00000000 --- a/proto-google-cloud-iot-v1/src/main/java/com/google/cloud/iot/v1/ListDevicesRequest.java +++ /dev/null @@ -1,2027 +0,0 @@ -/* - * Copyright 2020 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. - */ -// Generated by the protocol buffer compiler. DO NOT EDIT! -// source: google/cloud/iot/v1/device_manager.proto - -package com.google.cloud.iot.v1; - -/** - * - * - *
- * Request for `ListDevices`.
- * 
- * - * Protobuf type {@code google.cloud.iot.v1.ListDevicesRequest} - */ -public final class ListDevicesRequest extends com.google.protobuf.GeneratedMessageV3 - implements - // @@protoc_insertion_point(message_implements:google.cloud.iot.v1.ListDevicesRequest) - ListDevicesRequestOrBuilder { - private static final long serialVersionUID = 0L; - // Use ListDevicesRequest.newBuilder() to construct. - private ListDevicesRequest(com.google.protobuf.GeneratedMessageV3.Builder builder) { - super(builder); - } - - private ListDevicesRequest() { - parent_ = ""; - deviceNumIds_ = emptyLongList(); - deviceIds_ = com.google.protobuf.LazyStringArrayList.EMPTY; - pageToken_ = ""; - } - - @java.lang.Override - @SuppressWarnings({"unused"}) - protected java.lang.Object newInstance(UnusedPrivateParameter unused) { - return new ListDevicesRequest(); - } - - @java.lang.Override - public final com.google.protobuf.UnknownFieldSet getUnknownFields() { - return this.unknownFields; - } - - public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { - return com.google.cloud.iot.v1.DeviceManagerProto - .internal_static_google_cloud_iot_v1_ListDevicesRequest_descriptor; - } - - @java.lang.Override - protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable - internalGetFieldAccessorTable() { - return com.google.cloud.iot.v1.DeviceManagerProto - .internal_static_google_cloud_iot_v1_ListDevicesRequest_fieldAccessorTable - .ensureFieldAccessorsInitialized( - com.google.cloud.iot.v1.ListDevicesRequest.class, - com.google.cloud.iot.v1.ListDevicesRequest.Builder.class); - } - - public static final int PARENT_FIELD_NUMBER = 1; - private volatile java.lang.Object parent_; - /** - * - * - *
-   * Required. The device registry path. Required. For example,
-   * `projects/my-project/locations/us-central1/registries/my-registry`.
-   * 
- * - * - * string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } - * - * - * @return The parent. - */ - @java.lang.Override - public java.lang.String getParent() { - java.lang.Object ref = parent_; - if (ref instanceof java.lang.String) { - return (java.lang.String) ref; - } else { - com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; - java.lang.String s = bs.toStringUtf8(); - parent_ = s; - return s; - } - } - /** - * - * - *
-   * Required. The device registry path. Required. For example,
-   * `projects/my-project/locations/us-central1/registries/my-registry`.
-   * 
- * - * - * string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } - * - * - * @return The bytes for parent. - */ - @java.lang.Override - public com.google.protobuf.ByteString getParentBytes() { - java.lang.Object ref = parent_; - if (ref instanceof java.lang.String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); - parent_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - - public static final int DEVICE_NUM_IDS_FIELD_NUMBER = 2; - private com.google.protobuf.Internal.LongList deviceNumIds_; - /** - * - * - *
-   * A list of device numeric IDs. If empty, this field is ignored. Maximum
-   * IDs: 10,000.
-   * 
- * - * repeated uint64 device_num_ids = 2; - * - * @return A list containing the deviceNumIds. - */ - @java.lang.Override - public java.util.List getDeviceNumIdsList() { - return deviceNumIds_; - } - /** - * - * - *
-   * A list of device numeric IDs. If empty, this field is ignored. Maximum
-   * IDs: 10,000.
-   * 
- * - * repeated uint64 device_num_ids = 2; - * - * @return The count of deviceNumIds. - */ - public int getDeviceNumIdsCount() { - return deviceNumIds_.size(); - } - /** - * - * - *
-   * A list of device numeric IDs. If empty, this field is ignored. Maximum
-   * IDs: 10,000.
-   * 
- * - * repeated uint64 device_num_ids = 2; - * - * @param index The index of the element to return. - * @return The deviceNumIds at the given index. - */ - public long getDeviceNumIds(int index) { - return deviceNumIds_.getLong(index); - } - - private int deviceNumIdsMemoizedSerializedSize = -1; - - public static final int DEVICE_IDS_FIELD_NUMBER = 3; - private com.google.protobuf.LazyStringList deviceIds_; - /** - * - * - *
-   * A list of device string IDs. For example, `['device0', 'device12']`.
-   * If empty, this field is ignored. Maximum IDs: 10,000
-   * 
- * - * repeated string device_ids = 3; - * - * @return A list containing the deviceIds. - */ - public com.google.protobuf.ProtocolStringList getDeviceIdsList() { - return deviceIds_; - } - /** - * - * - *
-   * A list of device string IDs. For example, `['device0', 'device12']`.
-   * If empty, this field is ignored. Maximum IDs: 10,000
-   * 
- * - * repeated string device_ids = 3; - * - * @return The count of deviceIds. - */ - public int getDeviceIdsCount() { - return deviceIds_.size(); - } - /** - * - * - *
-   * A list of device string IDs. For example, `['device0', 'device12']`.
-   * If empty, this field is ignored. Maximum IDs: 10,000
-   * 
- * - * repeated string device_ids = 3; - * - * @param index The index of the element to return. - * @return The deviceIds at the given index. - */ - public java.lang.String getDeviceIds(int index) { - return deviceIds_.get(index); - } - /** - * - * - *
-   * A list of device string IDs. For example, `['device0', 'device12']`.
-   * If empty, this field is ignored. Maximum IDs: 10,000
-   * 
- * - * repeated string device_ids = 3; - * - * @param index The index of the value to return. - * @return The bytes of the deviceIds at the given index. - */ - public com.google.protobuf.ByteString getDeviceIdsBytes(int index) { - return deviceIds_.getByteString(index); - } - - public static final int FIELD_MASK_FIELD_NUMBER = 4; - private com.google.protobuf.FieldMask fieldMask_; - /** - * - * - *
-   * The fields of the `Device` resource to be returned in the response. The
-   * fields `id` and `num_id` are always returned, along with any
-   * other fields specified in snake_case format, for example:
-   * `last_heartbeat_time`.
-   * 
- * - * .google.protobuf.FieldMask field_mask = 4; - * - * @return Whether the fieldMask field is set. - */ - @java.lang.Override - public boolean hasFieldMask() { - return fieldMask_ != null; - } - /** - * - * - *
-   * The fields of the `Device` resource to be returned in the response. The
-   * fields `id` and `num_id` are always returned, along with any
-   * other fields specified in snake_case format, for example:
-   * `last_heartbeat_time`.
-   * 
- * - * .google.protobuf.FieldMask field_mask = 4; - * - * @return The fieldMask. - */ - @java.lang.Override - public com.google.protobuf.FieldMask getFieldMask() { - return fieldMask_ == null ? com.google.protobuf.FieldMask.getDefaultInstance() : fieldMask_; - } - /** - * - * - *
-   * The fields of the `Device` resource to be returned in the response. The
-   * fields `id` and `num_id` are always returned, along with any
-   * other fields specified in snake_case format, for example:
-   * `last_heartbeat_time`.
-   * 
- * - * .google.protobuf.FieldMask field_mask = 4; - */ - @java.lang.Override - public com.google.protobuf.FieldMaskOrBuilder getFieldMaskOrBuilder() { - return getFieldMask(); - } - - public static final int GATEWAY_LIST_OPTIONS_FIELD_NUMBER = 6; - private com.google.cloud.iot.v1.GatewayListOptions gatewayListOptions_; - /** - * - * - *
-   * Options related to gateways.
-   * 
- * - * .google.cloud.iot.v1.GatewayListOptions gateway_list_options = 6; - * - * @return Whether the gatewayListOptions field is set. - */ - @java.lang.Override - public boolean hasGatewayListOptions() { - return gatewayListOptions_ != null; - } - /** - * - * - *
-   * Options related to gateways.
-   * 
- * - * .google.cloud.iot.v1.GatewayListOptions gateway_list_options = 6; - * - * @return The gatewayListOptions. - */ - @java.lang.Override - public com.google.cloud.iot.v1.GatewayListOptions getGatewayListOptions() { - return gatewayListOptions_ == null - ? com.google.cloud.iot.v1.GatewayListOptions.getDefaultInstance() - : gatewayListOptions_; - } - /** - * - * - *
-   * Options related to gateways.
-   * 
- * - * .google.cloud.iot.v1.GatewayListOptions gateway_list_options = 6; - */ - @java.lang.Override - public com.google.cloud.iot.v1.GatewayListOptionsOrBuilder getGatewayListOptionsOrBuilder() { - return getGatewayListOptions(); - } - - public static final int PAGE_SIZE_FIELD_NUMBER = 100; - private int pageSize_; - /** - * - * - *
-   * The maximum number of devices to return in the response. If this value
-   * is zero, the service will select a default size. A call may return fewer
-   * objects than requested. A non-empty `next_page_token` in the response
-   * indicates that more data is available.
-   * 
- * - * int32 page_size = 100; - * - * @return The pageSize. - */ - @java.lang.Override - public int getPageSize() { - return pageSize_; - } - - public static final int PAGE_TOKEN_FIELD_NUMBER = 101; - private volatile java.lang.Object pageToken_; - /** - * - * - *
-   * The value returned by the last `ListDevicesResponse`; indicates
-   * that this is a continuation of a prior `ListDevices` call and
-   * the system should return the next page of data.
-   * 
- * - * string page_token = 101; - * - * @return The pageToken. - */ - @java.lang.Override - public java.lang.String getPageToken() { - java.lang.Object ref = pageToken_; - if (ref instanceof java.lang.String) { - return (java.lang.String) ref; - } else { - com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; - java.lang.String s = bs.toStringUtf8(); - pageToken_ = s; - return s; - } - } - /** - * - * - *
-   * The value returned by the last `ListDevicesResponse`; indicates
-   * that this is a continuation of a prior `ListDevices` call and
-   * the system should return the next page of data.
-   * 
- * - * string page_token = 101; - * - * @return The bytes for pageToken. - */ - @java.lang.Override - public com.google.protobuf.ByteString getPageTokenBytes() { - java.lang.Object ref = pageToken_; - if (ref instanceof java.lang.String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); - pageToken_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - - private byte memoizedIsInitialized = -1; - - @java.lang.Override - public final boolean isInitialized() { - byte isInitialized = memoizedIsInitialized; - if (isInitialized == 1) return true; - if (isInitialized == 0) return false; - - memoizedIsInitialized = 1; - return true; - } - - @java.lang.Override - public void writeTo(com.google.protobuf.CodedOutputStream output) throws java.io.IOException { - getSerializedSize(); - if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(parent_)) { - com.google.protobuf.GeneratedMessageV3.writeString(output, 1, parent_); - } - if (getDeviceNumIdsList().size() > 0) { - output.writeUInt32NoTag(18); - output.writeUInt32NoTag(deviceNumIdsMemoizedSerializedSize); - } - for (int i = 0; i < deviceNumIds_.size(); i++) { - output.writeUInt64NoTag(deviceNumIds_.getLong(i)); - } - for (int i = 0; i < deviceIds_.size(); i++) { - com.google.protobuf.GeneratedMessageV3.writeString(output, 3, deviceIds_.getRaw(i)); - } - if (fieldMask_ != null) { - output.writeMessage(4, getFieldMask()); - } - if (gatewayListOptions_ != null) { - output.writeMessage(6, getGatewayListOptions()); - } - if (pageSize_ != 0) { - output.writeInt32(100, pageSize_); - } - if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(pageToken_)) { - com.google.protobuf.GeneratedMessageV3.writeString(output, 101, pageToken_); - } - getUnknownFields().writeTo(output); - } - - @java.lang.Override - public int getSerializedSize() { - int size = memoizedSize; - if (size != -1) return size; - - size = 0; - if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(parent_)) { - size += com.google.protobuf.GeneratedMessageV3.computeStringSize(1, parent_); - } - { - int dataSize = 0; - for (int i = 0; i < deviceNumIds_.size(); i++) { - dataSize += - com.google.protobuf.CodedOutputStream.computeUInt64SizeNoTag(deviceNumIds_.getLong(i)); - } - size += dataSize; - if (!getDeviceNumIdsList().isEmpty()) { - size += 1; - size += com.google.protobuf.CodedOutputStream.computeInt32SizeNoTag(dataSize); - } - deviceNumIdsMemoizedSerializedSize = dataSize; - } - { - int dataSize = 0; - for (int i = 0; i < deviceIds_.size(); i++) { - dataSize += computeStringSizeNoTag(deviceIds_.getRaw(i)); - } - size += dataSize; - size += 1 * getDeviceIdsList().size(); - } - if (fieldMask_ != null) { - size += com.google.protobuf.CodedOutputStream.computeMessageSize(4, getFieldMask()); - } - if (gatewayListOptions_ != null) { - size += com.google.protobuf.CodedOutputStream.computeMessageSize(6, getGatewayListOptions()); - } - if (pageSize_ != 0) { - size += com.google.protobuf.CodedOutputStream.computeInt32Size(100, pageSize_); - } - if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(pageToken_)) { - size += com.google.protobuf.GeneratedMessageV3.computeStringSize(101, pageToken_); - } - size += getUnknownFields().getSerializedSize(); - memoizedSize = size; - return size; - } - - @java.lang.Override - public boolean equals(final java.lang.Object obj) { - if (obj == this) { - return true; - } - if (!(obj instanceof com.google.cloud.iot.v1.ListDevicesRequest)) { - return super.equals(obj); - } - com.google.cloud.iot.v1.ListDevicesRequest other = - (com.google.cloud.iot.v1.ListDevicesRequest) obj; - - if (!getParent().equals(other.getParent())) return false; - if (!getDeviceNumIdsList().equals(other.getDeviceNumIdsList())) return false; - if (!getDeviceIdsList().equals(other.getDeviceIdsList())) return false; - if (hasFieldMask() != other.hasFieldMask()) return false; - if (hasFieldMask()) { - if (!getFieldMask().equals(other.getFieldMask())) return false; - } - if (hasGatewayListOptions() != other.hasGatewayListOptions()) return false; - if (hasGatewayListOptions()) { - if (!getGatewayListOptions().equals(other.getGatewayListOptions())) return false; - } - if (getPageSize() != other.getPageSize()) return false; - if (!getPageToken().equals(other.getPageToken())) return false; - if (!getUnknownFields().equals(other.getUnknownFields())) return false; - return true; - } - - @java.lang.Override - public int hashCode() { - if (memoizedHashCode != 0) { - return memoizedHashCode; - } - int hash = 41; - hash = (19 * hash) + getDescriptor().hashCode(); - hash = (37 * hash) + PARENT_FIELD_NUMBER; - hash = (53 * hash) + getParent().hashCode(); - if (getDeviceNumIdsCount() > 0) { - hash = (37 * hash) + DEVICE_NUM_IDS_FIELD_NUMBER; - hash = (53 * hash) + getDeviceNumIdsList().hashCode(); - } - if (getDeviceIdsCount() > 0) { - hash = (37 * hash) + DEVICE_IDS_FIELD_NUMBER; - hash = (53 * hash) + getDeviceIdsList().hashCode(); - } - if (hasFieldMask()) { - hash = (37 * hash) + FIELD_MASK_FIELD_NUMBER; - hash = (53 * hash) + getFieldMask().hashCode(); - } - if (hasGatewayListOptions()) { - hash = (37 * hash) + GATEWAY_LIST_OPTIONS_FIELD_NUMBER; - hash = (53 * hash) + getGatewayListOptions().hashCode(); - } - hash = (37 * hash) + PAGE_SIZE_FIELD_NUMBER; - hash = (53 * hash) + getPageSize(); - hash = (37 * hash) + PAGE_TOKEN_FIELD_NUMBER; - hash = (53 * hash) + getPageToken().hashCode(); - hash = (29 * hash) + getUnknownFields().hashCode(); - memoizedHashCode = hash; - return hash; - } - - public static com.google.cloud.iot.v1.ListDevicesRequest parseFrom(java.nio.ByteBuffer data) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); - } - - public static com.google.cloud.iot.v1.ListDevicesRequest parseFrom( - java.nio.ByteBuffer data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); - } - - public static com.google.cloud.iot.v1.ListDevicesRequest parseFrom( - com.google.protobuf.ByteString data) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); - } - - public static com.google.cloud.iot.v1.ListDevicesRequest parseFrom( - com.google.protobuf.ByteString data, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); - } - - public static com.google.cloud.iot.v1.ListDevicesRequest parseFrom(byte[] data) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); - } - - public static com.google.cloud.iot.v1.ListDevicesRequest parseFrom( - byte[] data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); - } - - public static com.google.cloud.iot.v1.ListDevicesRequest parseFrom(java.io.InputStream input) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input); - } - - public static com.google.cloud.iot.v1.ListDevicesRequest parseFrom( - java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3.parseWithIOException( - PARSER, input, extensionRegistry); - } - - public static com.google.cloud.iot.v1.ListDevicesRequest parseDelimitedFrom( - java.io.InputStream input) throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3.parseDelimitedWithIOException(PARSER, input); - } - - public static com.google.cloud.iot.v1.ListDevicesRequest parseDelimitedFrom( - java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3.parseDelimitedWithIOException( - PARSER, input, extensionRegistry); - } - - public static com.google.cloud.iot.v1.ListDevicesRequest parseFrom( - com.google.protobuf.CodedInputStream input) throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input); - } - - public static com.google.cloud.iot.v1.ListDevicesRequest parseFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3.parseWithIOException( - PARSER, input, extensionRegistry); - } - - @java.lang.Override - public Builder newBuilderForType() { - return newBuilder(); - } - - public static Builder newBuilder() { - return DEFAULT_INSTANCE.toBuilder(); - } - - public static Builder newBuilder(com.google.cloud.iot.v1.ListDevicesRequest prototype) { - return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); - } - - @java.lang.Override - public Builder toBuilder() { - return this == DEFAULT_INSTANCE ? new Builder() : new Builder().mergeFrom(this); - } - - @java.lang.Override - protected Builder newBuilderForType(com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { - Builder builder = new Builder(parent); - return builder; - } - /** - * - * - *
-   * Request for `ListDevices`.
-   * 
- * - * Protobuf type {@code google.cloud.iot.v1.ListDevicesRequest} - */ - public static final class Builder extends com.google.protobuf.GeneratedMessageV3.Builder - implements - // @@protoc_insertion_point(builder_implements:google.cloud.iot.v1.ListDevicesRequest) - com.google.cloud.iot.v1.ListDevicesRequestOrBuilder { - public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { - return com.google.cloud.iot.v1.DeviceManagerProto - .internal_static_google_cloud_iot_v1_ListDevicesRequest_descriptor; - } - - @java.lang.Override - protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable - internalGetFieldAccessorTable() { - return com.google.cloud.iot.v1.DeviceManagerProto - .internal_static_google_cloud_iot_v1_ListDevicesRequest_fieldAccessorTable - .ensureFieldAccessorsInitialized( - com.google.cloud.iot.v1.ListDevicesRequest.class, - com.google.cloud.iot.v1.ListDevicesRequest.Builder.class); - } - - // Construct using com.google.cloud.iot.v1.ListDevicesRequest.newBuilder() - private Builder() {} - - private Builder(com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { - super(parent); - } - - @java.lang.Override - public Builder clear() { - super.clear(); - parent_ = ""; - - deviceNumIds_ = emptyLongList(); - bitField0_ = (bitField0_ & ~0x00000001); - deviceIds_ = com.google.protobuf.LazyStringArrayList.EMPTY; - bitField0_ = (bitField0_ & ~0x00000002); - if (fieldMaskBuilder_ == null) { - fieldMask_ = null; - } else { - fieldMask_ = null; - fieldMaskBuilder_ = null; - } - if (gatewayListOptionsBuilder_ == null) { - gatewayListOptions_ = null; - } else { - gatewayListOptions_ = null; - gatewayListOptionsBuilder_ = null; - } - pageSize_ = 0; - - pageToken_ = ""; - - return this; - } - - @java.lang.Override - public com.google.protobuf.Descriptors.Descriptor getDescriptorForType() { - return com.google.cloud.iot.v1.DeviceManagerProto - .internal_static_google_cloud_iot_v1_ListDevicesRequest_descriptor; - } - - @java.lang.Override - public com.google.cloud.iot.v1.ListDevicesRequest getDefaultInstanceForType() { - return com.google.cloud.iot.v1.ListDevicesRequest.getDefaultInstance(); - } - - @java.lang.Override - public com.google.cloud.iot.v1.ListDevicesRequest build() { - com.google.cloud.iot.v1.ListDevicesRequest result = buildPartial(); - if (!result.isInitialized()) { - throw newUninitializedMessageException(result); - } - return result; - } - - @java.lang.Override - public com.google.cloud.iot.v1.ListDevicesRequest buildPartial() { - com.google.cloud.iot.v1.ListDevicesRequest result = - new com.google.cloud.iot.v1.ListDevicesRequest(this); - int from_bitField0_ = bitField0_; - result.parent_ = parent_; - if (((bitField0_ & 0x00000001) != 0)) { - deviceNumIds_.makeImmutable(); - bitField0_ = (bitField0_ & ~0x00000001); - } - result.deviceNumIds_ = deviceNumIds_; - if (((bitField0_ & 0x00000002) != 0)) { - deviceIds_ = deviceIds_.getUnmodifiableView(); - bitField0_ = (bitField0_ & ~0x00000002); - } - result.deviceIds_ = deviceIds_; - if (fieldMaskBuilder_ == null) { - result.fieldMask_ = fieldMask_; - } else { - result.fieldMask_ = fieldMaskBuilder_.build(); - } - if (gatewayListOptionsBuilder_ == null) { - result.gatewayListOptions_ = gatewayListOptions_; - } else { - result.gatewayListOptions_ = gatewayListOptionsBuilder_.build(); - } - result.pageSize_ = pageSize_; - result.pageToken_ = pageToken_; - onBuilt(); - return result; - } - - @java.lang.Override - public Builder clone() { - return super.clone(); - } - - @java.lang.Override - public Builder setField( - com.google.protobuf.Descriptors.FieldDescriptor field, java.lang.Object value) { - return super.setField(field, value); - } - - @java.lang.Override - public Builder clearField(com.google.protobuf.Descriptors.FieldDescriptor field) { - return super.clearField(field); - } - - @java.lang.Override - public Builder clearOneof(com.google.protobuf.Descriptors.OneofDescriptor oneof) { - return super.clearOneof(oneof); - } - - @java.lang.Override - public Builder setRepeatedField( - com.google.protobuf.Descriptors.FieldDescriptor field, int index, java.lang.Object value) { - return super.setRepeatedField(field, index, value); - } - - @java.lang.Override - public Builder addRepeatedField( - com.google.protobuf.Descriptors.FieldDescriptor field, java.lang.Object value) { - return super.addRepeatedField(field, value); - } - - @java.lang.Override - public Builder mergeFrom(com.google.protobuf.Message other) { - if (other instanceof com.google.cloud.iot.v1.ListDevicesRequest) { - return mergeFrom((com.google.cloud.iot.v1.ListDevicesRequest) other); - } else { - super.mergeFrom(other); - return this; - } - } - - public Builder mergeFrom(com.google.cloud.iot.v1.ListDevicesRequest other) { - if (other == com.google.cloud.iot.v1.ListDevicesRequest.getDefaultInstance()) return this; - if (!other.getParent().isEmpty()) { - parent_ = other.parent_; - onChanged(); - } - if (!other.deviceNumIds_.isEmpty()) { - if (deviceNumIds_.isEmpty()) { - deviceNumIds_ = other.deviceNumIds_; - bitField0_ = (bitField0_ & ~0x00000001); - } else { - ensureDeviceNumIdsIsMutable(); - deviceNumIds_.addAll(other.deviceNumIds_); - } - onChanged(); - } - if (!other.deviceIds_.isEmpty()) { - if (deviceIds_.isEmpty()) { - deviceIds_ = other.deviceIds_; - bitField0_ = (bitField0_ & ~0x00000002); - } else { - ensureDeviceIdsIsMutable(); - deviceIds_.addAll(other.deviceIds_); - } - onChanged(); - } - if (other.hasFieldMask()) { - mergeFieldMask(other.getFieldMask()); - } - if (other.hasGatewayListOptions()) { - mergeGatewayListOptions(other.getGatewayListOptions()); - } - if (other.getPageSize() != 0) { - setPageSize(other.getPageSize()); - } - if (!other.getPageToken().isEmpty()) { - pageToken_ = other.pageToken_; - onChanged(); - } - this.mergeUnknownFields(other.getUnknownFields()); - onChanged(); - return this; - } - - @java.lang.Override - public final boolean isInitialized() { - return true; - } - - @java.lang.Override - public Builder mergeFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - if (extensionRegistry == null) { - throw new java.lang.NullPointerException(); - } - try { - boolean done = false; - while (!done) { - int tag = input.readTag(); - switch (tag) { - case 0: - done = true; - break; - case 10: - { - parent_ = input.readStringRequireUtf8(); - - break; - } // case 10 - case 16: - { - long v = input.readUInt64(); - ensureDeviceNumIdsIsMutable(); - deviceNumIds_.addLong(v); - break; - } // case 16 - case 18: - { - int length = input.readRawVarint32(); - int limit = input.pushLimit(length); - ensureDeviceNumIdsIsMutable(); - while (input.getBytesUntilLimit() > 0) { - deviceNumIds_.addLong(input.readUInt64()); - } - input.popLimit(limit); - break; - } // case 18 - case 26: - { - java.lang.String s = input.readStringRequireUtf8(); - ensureDeviceIdsIsMutable(); - deviceIds_.add(s); - break; - } // case 26 - case 34: - { - input.readMessage(getFieldMaskFieldBuilder().getBuilder(), extensionRegistry); - - break; - } // case 34 - case 50: - { - input.readMessage( - getGatewayListOptionsFieldBuilder().getBuilder(), extensionRegistry); - - break; - } // case 50 - case 800: - { - pageSize_ = input.readInt32(); - - break; - } // case 800 - case 810: - { - pageToken_ = input.readStringRequireUtf8(); - - break; - } // case 810 - default: - { - if (!super.parseUnknownField(input, extensionRegistry, tag)) { - done = true; // was an endgroup tag - } - break; - } // default: - } // switch (tag) - } // while (!done) - } catch (com.google.protobuf.InvalidProtocolBufferException e) { - throw e.unwrapIOException(); - } finally { - onChanged(); - } // finally - return this; - } - - private int bitField0_; - - private java.lang.Object parent_ = ""; - /** - * - * - *
-     * Required. The device registry path. Required. For example,
-     * `projects/my-project/locations/us-central1/registries/my-registry`.
-     * 
- * - * - * string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } - * - * - * @return The parent. - */ - public java.lang.String getParent() { - java.lang.Object ref = parent_; - if (!(ref instanceof java.lang.String)) { - com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; - java.lang.String s = bs.toStringUtf8(); - parent_ = s; - return s; - } else { - return (java.lang.String) ref; - } - } - /** - * - * - *
-     * Required. The device registry path. Required. For example,
-     * `projects/my-project/locations/us-central1/registries/my-registry`.
-     * 
- * - * - * string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } - * - * - * @return The bytes for parent. - */ - public com.google.protobuf.ByteString getParentBytes() { - java.lang.Object ref = parent_; - if (ref instanceof String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); - parent_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - /** - * - * - *
-     * Required. The device registry path. Required. For example,
-     * `projects/my-project/locations/us-central1/registries/my-registry`.
-     * 
- * - * - * string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } - * - * - * @param value The parent to set. - * @return This builder for chaining. - */ - public Builder setParent(java.lang.String value) { - if (value == null) { - throw new NullPointerException(); - } - - parent_ = value; - onChanged(); - return this; - } - /** - * - * - *
-     * Required. The device registry path. Required. For example,
-     * `projects/my-project/locations/us-central1/registries/my-registry`.
-     * 
- * - * - * string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } - * - * - * @return This builder for chaining. - */ - public Builder clearParent() { - - parent_ = getDefaultInstance().getParent(); - onChanged(); - return this; - } - /** - * - * - *
-     * Required. The device registry path. Required. For example,
-     * `projects/my-project/locations/us-central1/registries/my-registry`.
-     * 
- * - * - * string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } - * - * - * @param value The bytes for parent to set. - * @return This builder for chaining. - */ - public Builder setParentBytes(com.google.protobuf.ByteString value) { - if (value == null) { - throw new NullPointerException(); - } - checkByteStringIsUtf8(value); - - parent_ = value; - onChanged(); - return this; - } - - private com.google.protobuf.Internal.LongList deviceNumIds_ = emptyLongList(); - - private void ensureDeviceNumIdsIsMutable() { - if (!((bitField0_ & 0x00000001) != 0)) { - deviceNumIds_ = mutableCopy(deviceNumIds_); - bitField0_ |= 0x00000001; - } - } - /** - * - * - *
-     * A list of device numeric IDs. If empty, this field is ignored. Maximum
-     * IDs: 10,000.
-     * 
- * - * repeated uint64 device_num_ids = 2; - * - * @return A list containing the deviceNumIds. - */ - public java.util.List getDeviceNumIdsList() { - return ((bitField0_ & 0x00000001) != 0) - ? java.util.Collections.unmodifiableList(deviceNumIds_) - : deviceNumIds_; - } - /** - * - * - *
-     * A list of device numeric IDs. If empty, this field is ignored. Maximum
-     * IDs: 10,000.
-     * 
- * - * repeated uint64 device_num_ids = 2; - * - * @return The count of deviceNumIds. - */ - public int getDeviceNumIdsCount() { - return deviceNumIds_.size(); - } - /** - * - * - *
-     * A list of device numeric IDs. If empty, this field is ignored. Maximum
-     * IDs: 10,000.
-     * 
- * - * repeated uint64 device_num_ids = 2; - * - * @param index The index of the element to return. - * @return The deviceNumIds at the given index. - */ - public long getDeviceNumIds(int index) { - return deviceNumIds_.getLong(index); - } - /** - * - * - *
-     * A list of device numeric IDs. If empty, this field is ignored. Maximum
-     * IDs: 10,000.
-     * 
- * - * repeated uint64 device_num_ids = 2; - * - * @param index The index to set the value at. - * @param value The deviceNumIds to set. - * @return This builder for chaining. - */ - public Builder setDeviceNumIds(int index, long value) { - ensureDeviceNumIdsIsMutable(); - deviceNumIds_.setLong(index, value); - onChanged(); - return this; - } - /** - * - * - *
-     * A list of device numeric IDs. If empty, this field is ignored. Maximum
-     * IDs: 10,000.
-     * 
- * - * repeated uint64 device_num_ids = 2; - * - * @param value The deviceNumIds to add. - * @return This builder for chaining. - */ - public Builder addDeviceNumIds(long value) { - ensureDeviceNumIdsIsMutable(); - deviceNumIds_.addLong(value); - onChanged(); - return this; - } - /** - * - * - *
-     * A list of device numeric IDs. If empty, this field is ignored. Maximum
-     * IDs: 10,000.
-     * 
- * - * repeated uint64 device_num_ids = 2; - * - * @param values The deviceNumIds to add. - * @return This builder for chaining. - */ - public Builder addAllDeviceNumIds(java.lang.Iterable values) { - ensureDeviceNumIdsIsMutable(); - com.google.protobuf.AbstractMessageLite.Builder.addAll(values, deviceNumIds_); - onChanged(); - return this; - } - /** - * - * - *
-     * A list of device numeric IDs. If empty, this field is ignored. Maximum
-     * IDs: 10,000.
-     * 
- * - * repeated uint64 device_num_ids = 2; - * - * @return This builder for chaining. - */ - public Builder clearDeviceNumIds() { - deviceNumIds_ = emptyLongList(); - bitField0_ = (bitField0_ & ~0x00000001); - onChanged(); - return this; - } - - private com.google.protobuf.LazyStringList deviceIds_ = - com.google.protobuf.LazyStringArrayList.EMPTY; - - private void ensureDeviceIdsIsMutable() { - if (!((bitField0_ & 0x00000002) != 0)) { - deviceIds_ = new com.google.protobuf.LazyStringArrayList(deviceIds_); - bitField0_ |= 0x00000002; - } - } - /** - * - * - *
-     * A list of device string IDs. For example, `['device0', 'device12']`.
-     * If empty, this field is ignored. Maximum IDs: 10,000
-     * 
- * - * repeated string device_ids = 3; - * - * @return A list containing the deviceIds. - */ - public com.google.protobuf.ProtocolStringList getDeviceIdsList() { - return deviceIds_.getUnmodifiableView(); - } - /** - * - * - *
-     * A list of device string IDs. For example, `['device0', 'device12']`.
-     * If empty, this field is ignored. Maximum IDs: 10,000
-     * 
- * - * repeated string device_ids = 3; - * - * @return The count of deviceIds. - */ - public int getDeviceIdsCount() { - return deviceIds_.size(); - } - /** - * - * - *
-     * A list of device string IDs. For example, `['device0', 'device12']`.
-     * If empty, this field is ignored. Maximum IDs: 10,000
-     * 
- * - * repeated string device_ids = 3; - * - * @param index The index of the element to return. - * @return The deviceIds at the given index. - */ - public java.lang.String getDeviceIds(int index) { - return deviceIds_.get(index); - } - /** - * - * - *
-     * A list of device string IDs. For example, `['device0', 'device12']`.
-     * If empty, this field is ignored. Maximum IDs: 10,000
-     * 
- * - * repeated string device_ids = 3; - * - * @param index The index of the value to return. - * @return The bytes of the deviceIds at the given index. - */ - public com.google.protobuf.ByteString getDeviceIdsBytes(int index) { - return deviceIds_.getByteString(index); - } - /** - * - * - *
-     * A list of device string IDs. For example, `['device0', 'device12']`.
-     * If empty, this field is ignored. Maximum IDs: 10,000
-     * 
- * - * repeated string device_ids = 3; - * - * @param index The index to set the value at. - * @param value The deviceIds to set. - * @return This builder for chaining. - */ - public Builder setDeviceIds(int index, java.lang.String value) { - if (value == null) { - throw new NullPointerException(); - } - ensureDeviceIdsIsMutable(); - deviceIds_.set(index, value); - onChanged(); - return this; - } - /** - * - * - *
-     * A list of device string IDs. For example, `['device0', 'device12']`.
-     * If empty, this field is ignored. Maximum IDs: 10,000
-     * 
- * - * repeated string device_ids = 3; - * - * @param value The deviceIds to add. - * @return This builder for chaining. - */ - public Builder addDeviceIds(java.lang.String value) { - if (value == null) { - throw new NullPointerException(); - } - ensureDeviceIdsIsMutable(); - deviceIds_.add(value); - onChanged(); - return this; - } - /** - * - * - *
-     * A list of device string IDs. For example, `['device0', 'device12']`.
-     * If empty, this field is ignored. Maximum IDs: 10,000
-     * 
- * - * repeated string device_ids = 3; - * - * @param values The deviceIds to add. - * @return This builder for chaining. - */ - public Builder addAllDeviceIds(java.lang.Iterable values) { - ensureDeviceIdsIsMutable(); - com.google.protobuf.AbstractMessageLite.Builder.addAll(values, deviceIds_); - onChanged(); - return this; - } - /** - * - * - *
-     * A list of device string IDs. For example, `['device0', 'device12']`.
-     * If empty, this field is ignored. Maximum IDs: 10,000
-     * 
- * - * repeated string device_ids = 3; - * - * @return This builder for chaining. - */ - public Builder clearDeviceIds() { - deviceIds_ = com.google.protobuf.LazyStringArrayList.EMPTY; - bitField0_ = (bitField0_ & ~0x00000002); - onChanged(); - return this; - } - /** - * - * - *
-     * A list of device string IDs. For example, `['device0', 'device12']`.
-     * If empty, this field is ignored. Maximum IDs: 10,000
-     * 
- * - * repeated string device_ids = 3; - * - * @param value The bytes of the deviceIds to add. - * @return This builder for chaining. - */ - public Builder addDeviceIdsBytes(com.google.protobuf.ByteString value) { - if (value == null) { - throw new NullPointerException(); - } - checkByteStringIsUtf8(value); - ensureDeviceIdsIsMutable(); - deviceIds_.add(value); - onChanged(); - return this; - } - - private com.google.protobuf.FieldMask fieldMask_; - private com.google.protobuf.SingleFieldBuilderV3< - com.google.protobuf.FieldMask, - com.google.protobuf.FieldMask.Builder, - com.google.protobuf.FieldMaskOrBuilder> - fieldMaskBuilder_; - /** - * - * - *
-     * The fields of the `Device` resource to be returned in the response. The
-     * fields `id` and `num_id` are always returned, along with any
-     * other fields specified in snake_case format, for example:
-     * `last_heartbeat_time`.
-     * 
- * - * .google.protobuf.FieldMask field_mask = 4; - * - * @return Whether the fieldMask field is set. - */ - public boolean hasFieldMask() { - return fieldMaskBuilder_ != null || fieldMask_ != null; - } - /** - * - * - *
-     * The fields of the `Device` resource to be returned in the response. The
-     * fields `id` and `num_id` are always returned, along with any
-     * other fields specified in snake_case format, for example:
-     * `last_heartbeat_time`.
-     * 
- * - * .google.protobuf.FieldMask field_mask = 4; - * - * @return The fieldMask. - */ - public com.google.protobuf.FieldMask getFieldMask() { - if (fieldMaskBuilder_ == null) { - return fieldMask_ == null ? com.google.protobuf.FieldMask.getDefaultInstance() : fieldMask_; - } else { - return fieldMaskBuilder_.getMessage(); - } - } - /** - * - * - *
-     * The fields of the `Device` resource to be returned in the response. The
-     * fields `id` and `num_id` are always returned, along with any
-     * other fields specified in snake_case format, for example:
-     * `last_heartbeat_time`.
-     * 
- * - * .google.protobuf.FieldMask field_mask = 4; - */ - public Builder setFieldMask(com.google.protobuf.FieldMask value) { - if (fieldMaskBuilder_ == null) { - if (value == null) { - throw new NullPointerException(); - } - fieldMask_ = value; - onChanged(); - } else { - fieldMaskBuilder_.setMessage(value); - } - - return this; - } - /** - * - * - *
-     * The fields of the `Device` resource to be returned in the response. The
-     * fields `id` and `num_id` are always returned, along with any
-     * other fields specified in snake_case format, for example:
-     * `last_heartbeat_time`.
-     * 
- * - * .google.protobuf.FieldMask field_mask = 4; - */ - public Builder setFieldMask(com.google.protobuf.FieldMask.Builder builderForValue) { - if (fieldMaskBuilder_ == null) { - fieldMask_ = builderForValue.build(); - onChanged(); - } else { - fieldMaskBuilder_.setMessage(builderForValue.build()); - } - - return this; - } - /** - * - * - *
-     * The fields of the `Device` resource to be returned in the response. The
-     * fields `id` and `num_id` are always returned, along with any
-     * other fields specified in snake_case format, for example:
-     * `last_heartbeat_time`.
-     * 
- * - * .google.protobuf.FieldMask field_mask = 4; - */ - public Builder mergeFieldMask(com.google.protobuf.FieldMask value) { - if (fieldMaskBuilder_ == null) { - if (fieldMask_ != null) { - fieldMask_ = - com.google.protobuf.FieldMask.newBuilder(fieldMask_).mergeFrom(value).buildPartial(); - } else { - fieldMask_ = value; - } - onChanged(); - } else { - fieldMaskBuilder_.mergeFrom(value); - } - - return this; - } - /** - * - * - *
-     * The fields of the `Device` resource to be returned in the response. The
-     * fields `id` and `num_id` are always returned, along with any
-     * other fields specified in snake_case format, for example:
-     * `last_heartbeat_time`.
-     * 
- * - * .google.protobuf.FieldMask field_mask = 4; - */ - public Builder clearFieldMask() { - if (fieldMaskBuilder_ == null) { - fieldMask_ = null; - onChanged(); - } else { - fieldMask_ = null; - fieldMaskBuilder_ = null; - } - - return this; - } - /** - * - * - *
-     * The fields of the `Device` resource to be returned in the response. The
-     * fields `id` and `num_id` are always returned, along with any
-     * other fields specified in snake_case format, for example:
-     * `last_heartbeat_time`.
-     * 
- * - * .google.protobuf.FieldMask field_mask = 4; - */ - public com.google.protobuf.FieldMask.Builder getFieldMaskBuilder() { - - onChanged(); - return getFieldMaskFieldBuilder().getBuilder(); - } - /** - * - * - *
-     * The fields of the `Device` resource to be returned in the response. The
-     * fields `id` and `num_id` are always returned, along with any
-     * other fields specified in snake_case format, for example:
-     * `last_heartbeat_time`.
-     * 
- * - * .google.protobuf.FieldMask field_mask = 4; - */ - public com.google.protobuf.FieldMaskOrBuilder getFieldMaskOrBuilder() { - if (fieldMaskBuilder_ != null) { - return fieldMaskBuilder_.getMessageOrBuilder(); - } else { - return fieldMask_ == null ? com.google.protobuf.FieldMask.getDefaultInstance() : fieldMask_; - } - } - /** - * - * - *
-     * The fields of the `Device` resource to be returned in the response. The
-     * fields `id` and `num_id` are always returned, along with any
-     * other fields specified in snake_case format, for example:
-     * `last_heartbeat_time`.
-     * 
- * - * .google.protobuf.FieldMask field_mask = 4; - */ - private com.google.protobuf.SingleFieldBuilderV3< - com.google.protobuf.FieldMask, - com.google.protobuf.FieldMask.Builder, - com.google.protobuf.FieldMaskOrBuilder> - getFieldMaskFieldBuilder() { - if (fieldMaskBuilder_ == null) { - fieldMaskBuilder_ = - new com.google.protobuf.SingleFieldBuilderV3< - com.google.protobuf.FieldMask, - com.google.protobuf.FieldMask.Builder, - com.google.protobuf.FieldMaskOrBuilder>( - getFieldMask(), getParentForChildren(), isClean()); - fieldMask_ = null; - } - return fieldMaskBuilder_; - } - - private com.google.cloud.iot.v1.GatewayListOptions gatewayListOptions_; - private com.google.protobuf.SingleFieldBuilderV3< - com.google.cloud.iot.v1.GatewayListOptions, - com.google.cloud.iot.v1.GatewayListOptions.Builder, - com.google.cloud.iot.v1.GatewayListOptionsOrBuilder> - gatewayListOptionsBuilder_; - /** - * - * - *
-     * Options related to gateways.
-     * 
- * - * .google.cloud.iot.v1.GatewayListOptions gateway_list_options = 6; - * - * @return Whether the gatewayListOptions field is set. - */ - public boolean hasGatewayListOptions() { - return gatewayListOptionsBuilder_ != null || gatewayListOptions_ != null; - } - /** - * - * - *
-     * Options related to gateways.
-     * 
- * - * .google.cloud.iot.v1.GatewayListOptions gateway_list_options = 6; - * - * @return The gatewayListOptions. - */ - public com.google.cloud.iot.v1.GatewayListOptions getGatewayListOptions() { - if (gatewayListOptionsBuilder_ == null) { - return gatewayListOptions_ == null - ? com.google.cloud.iot.v1.GatewayListOptions.getDefaultInstance() - : gatewayListOptions_; - } else { - return gatewayListOptionsBuilder_.getMessage(); - } - } - /** - * - * - *
-     * Options related to gateways.
-     * 
- * - * .google.cloud.iot.v1.GatewayListOptions gateway_list_options = 6; - */ - public Builder setGatewayListOptions(com.google.cloud.iot.v1.GatewayListOptions value) { - if (gatewayListOptionsBuilder_ == null) { - if (value == null) { - throw new NullPointerException(); - } - gatewayListOptions_ = value; - onChanged(); - } else { - gatewayListOptionsBuilder_.setMessage(value); - } - - return this; - } - /** - * - * - *
-     * Options related to gateways.
-     * 
- * - * .google.cloud.iot.v1.GatewayListOptions gateway_list_options = 6; - */ - public Builder setGatewayListOptions( - com.google.cloud.iot.v1.GatewayListOptions.Builder builderForValue) { - if (gatewayListOptionsBuilder_ == null) { - gatewayListOptions_ = builderForValue.build(); - onChanged(); - } else { - gatewayListOptionsBuilder_.setMessage(builderForValue.build()); - } - - return this; - } - /** - * - * - *
-     * Options related to gateways.
-     * 
- * - * .google.cloud.iot.v1.GatewayListOptions gateway_list_options = 6; - */ - public Builder mergeGatewayListOptions(com.google.cloud.iot.v1.GatewayListOptions value) { - if (gatewayListOptionsBuilder_ == null) { - if (gatewayListOptions_ != null) { - gatewayListOptions_ = - com.google.cloud.iot.v1.GatewayListOptions.newBuilder(gatewayListOptions_) - .mergeFrom(value) - .buildPartial(); - } else { - gatewayListOptions_ = value; - } - onChanged(); - } else { - gatewayListOptionsBuilder_.mergeFrom(value); - } - - return this; - } - /** - * - * - *
-     * Options related to gateways.
-     * 
- * - * .google.cloud.iot.v1.GatewayListOptions gateway_list_options = 6; - */ - public Builder clearGatewayListOptions() { - if (gatewayListOptionsBuilder_ == null) { - gatewayListOptions_ = null; - onChanged(); - } else { - gatewayListOptions_ = null; - gatewayListOptionsBuilder_ = null; - } - - return this; - } - /** - * - * - *
-     * Options related to gateways.
-     * 
- * - * .google.cloud.iot.v1.GatewayListOptions gateway_list_options = 6; - */ - public com.google.cloud.iot.v1.GatewayListOptions.Builder getGatewayListOptionsBuilder() { - - onChanged(); - return getGatewayListOptionsFieldBuilder().getBuilder(); - } - /** - * - * - *
-     * Options related to gateways.
-     * 
- * - * .google.cloud.iot.v1.GatewayListOptions gateway_list_options = 6; - */ - public com.google.cloud.iot.v1.GatewayListOptionsOrBuilder getGatewayListOptionsOrBuilder() { - if (gatewayListOptionsBuilder_ != null) { - return gatewayListOptionsBuilder_.getMessageOrBuilder(); - } else { - return gatewayListOptions_ == null - ? com.google.cloud.iot.v1.GatewayListOptions.getDefaultInstance() - : gatewayListOptions_; - } - } - /** - * - * - *
-     * Options related to gateways.
-     * 
- * - * .google.cloud.iot.v1.GatewayListOptions gateway_list_options = 6; - */ - private com.google.protobuf.SingleFieldBuilderV3< - com.google.cloud.iot.v1.GatewayListOptions, - com.google.cloud.iot.v1.GatewayListOptions.Builder, - com.google.cloud.iot.v1.GatewayListOptionsOrBuilder> - getGatewayListOptionsFieldBuilder() { - if (gatewayListOptionsBuilder_ == null) { - gatewayListOptionsBuilder_ = - new com.google.protobuf.SingleFieldBuilderV3< - com.google.cloud.iot.v1.GatewayListOptions, - com.google.cloud.iot.v1.GatewayListOptions.Builder, - com.google.cloud.iot.v1.GatewayListOptionsOrBuilder>( - getGatewayListOptions(), getParentForChildren(), isClean()); - gatewayListOptions_ = null; - } - return gatewayListOptionsBuilder_; - } - - private int pageSize_; - /** - * - * - *
-     * The maximum number of devices to return in the response. If this value
-     * is zero, the service will select a default size. A call may return fewer
-     * objects than requested. A non-empty `next_page_token` in the response
-     * indicates that more data is available.
-     * 
- * - * int32 page_size = 100; - * - * @return The pageSize. - */ - @java.lang.Override - public int getPageSize() { - return pageSize_; - } - /** - * - * - *
-     * The maximum number of devices to return in the response. If this value
-     * is zero, the service will select a default size. A call may return fewer
-     * objects than requested. A non-empty `next_page_token` in the response
-     * indicates that more data is available.
-     * 
- * - * int32 page_size = 100; - * - * @param value The pageSize to set. - * @return This builder for chaining. - */ - public Builder setPageSize(int value) { - - pageSize_ = value; - onChanged(); - return this; - } - /** - * - * - *
-     * The maximum number of devices to return in the response. If this value
-     * is zero, the service will select a default size. A call may return fewer
-     * objects than requested. A non-empty `next_page_token` in the response
-     * indicates that more data is available.
-     * 
- * - * int32 page_size = 100; - * - * @return This builder for chaining. - */ - public Builder clearPageSize() { - - pageSize_ = 0; - onChanged(); - return this; - } - - private java.lang.Object pageToken_ = ""; - /** - * - * - *
-     * The value returned by the last `ListDevicesResponse`; indicates
-     * that this is a continuation of a prior `ListDevices` call and
-     * the system should return the next page of data.
-     * 
- * - * string page_token = 101; - * - * @return The pageToken. - */ - public java.lang.String getPageToken() { - java.lang.Object ref = pageToken_; - if (!(ref instanceof java.lang.String)) { - com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; - java.lang.String s = bs.toStringUtf8(); - pageToken_ = s; - return s; - } else { - return (java.lang.String) ref; - } - } - /** - * - * - *
-     * The value returned by the last `ListDevicesResponse`; indicates
-     * that this is a continuation of a prior `ListDevices` call and
-     * the system should return the next page of data.
-     * 
- * - * string page_token = 101; - * - * @return The bytes for pageToken. - */ - public com.google.protobuf.ByteString getPageTokenBytes() { - java.lang.Object ref = pageToken_; - if (ref instanceof String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); - pageToken_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - /** - * - * - *
-     * The value returned by the last `ListDevicesResponse`; indicates
-     * that this is a continuation of a prior `ListDevices` call and
-     * the system should return the next page of data.
-     * 
- * - * string page_token = 101; - * - * @param value The pageToken to set. - * @return This builder for chaining. - */ - public Builder setPageToken(java.lang.String value) { - if (value == null) { - throw new NullPointerException(); - } - - pageToken_ = value; - onChanged(); - return this; - } - /** - * - * - *
-     * The value returned by the last `ListDevicesResponse`; indicates
-     * that this is a continuation of a prior `ListDevices` call and
-     * the system should return the next page of data.
-     * 
- * - * string page_token = 101; - * - * @return This builder for chaining. - */ - public Builder clearPageToken() { - - pageToken_ = getDefaultInstance().getPageToken(); - onChanged(); - return this; - } - /** - * - * - *
-     * The value returned by the last `ListDevicesResponse`; indicates
-     * that this is a continuation of a prior `ListDevices` call and
-     * the system should return the next page of data.
-     * 
- * - * string page_token = 101; - * - * @param value The bytes for pageToken to set. - * @return This builder for chaining. - */ - public Builder setPageTokenBytes(com.google.protobuf.ByteString value) { - if (value == null) { - throw new NullPointerException(); - } - checkByteStringIsUtf8(value); - - pageToken_ = value; - onChanged(); - return this; - } - - @java.lang.Override - public final Builder setUnknownFields(final com.google.protobuf.UnknownFieldSet unknownFields) { - return super.setUnknownFields(unknownFields); - } - - @java.lang.Override - public final Builder mergeUnknownFields( - final com.google.protobuf.UnknownFieldSet unknownFields) { - return super.mergeUnknownFields(unknownFields); - } - - // @@protoc_insertion_point(builder_scope:google.cloud.iot.v1.ListDevicesRequest) - } - - // @@protoc_insertion_point(class_scope:google.cloud.iot.v1.ListDevicesRequest) - private static final com.google.cloud.iot.v1.ListDevicesRequest DEFAULT_INSTANCE; - - static { - DEFAULT_INSTANCE = new com.google.cloud.iot.v1.ListDevicesRequest(); - } - - public static com.google.cloud.iot.v1.ListDevicesRequest getDefaultInstance() { - return DEFAULT_INSTANCE; - } - - private static final com.google.protobuf.Parser PARSER = - new com.google.protobuf.AbstractParser() { - @java.lang.Override - public ListDevicesRequest parsePartialFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - Builder builder = newBuilder(); - try { - builder.mergeFrom(input, extensionRegistry); - } catch (com.google.protobuf.InvalidProtocolBufferException e) { - throw e.setUnfinishedMessage(builder.buildPartial()); - } catch (com.google.protobuf.UninitializedMessageException e) { - throw e.asInvalidProtocolBufferException().setUnfinishedMessage(builder.buildPartial()); - } catch (java.io.IOException e) { - throw new com.google.protobuf.InvalidProtocolBufferException(e) - .setUnfinishedMessage(builder.buildPartial()); - } - return builder.buildPartial(); - } - }; - - public static com.google.protobuf.Parser parser() { - return PARSER; - } - - @java.lang.Override - public com.google.protobuf.Parser getParserForType() { - return PARSER; - } - - @java.lang.Override - public com.google.cloud.iot.v1.ListDevicesRequest getDefaultInstanceForType() { - return DEFAULT_INSTANCE; - } -} diff --git a/proto-google-cloud-iot-v1/src/main/java/com/google/cloud/iot/v1/ListDevicesRequestOrBuilder.java b/proto-google-cloud-iot-v1/src/main/java/com/google/cloud/iot/v1/ListDevicesRequestOrBuilder.java deleted file mode 100644 index 501c3586..00000000 --- a/proto-google-cloud-iot-v1/src/main/java/com/google/cloud/iot/v1/ListDevicesRequestOrBuilder.java +++ /dev/null @@ -1,276 +0,0 @@ -/* - * Copyright 2020 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. - */ -// Generated by the protocol buffer compiler. DO NOT EDIT! -// source: google/cloud/iot/v1/device_manager.proto - -package com.google.cloud.iot.v1; - -public interface ListDevicesRequestOrBuilder - extends - // @@protoc_insertion_point(interface_extends:google.cloud.iot.v1.ListDevicesRequest) - com.google.protobuf.MessageOrBuilder { - - /** - * - * - *
-   * Required. The device registry path. Required. For example,
-   * `projects/my-project/locations/us-central1/registries/my-registry`.
-   * 
- * - * - * string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } - * - * - * @return The parent. - */ - java.lang.String getParent(); - /** - * - * - *
-   * Required. The device registry path. Required. For example,
-   * `projects/my-project/locations/us-central1/registries/my-registry`.
-   * 
- * - * - * string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } - * - * - * @return The bytes for parent. - */ - com.google.protobuf.ByteString getParentBytes(); - - /** - * - * - *
-   * A list of device numeric IDs. If empty, this field is ignored. Maximum
-   * IDs: 10,000.
-   * 
- * - * repeated uint64 device_num_ids = 2; - * - * @return A list containing the deviceNumIds. - */ - java.util.List getDeviceNumIdsList(); - /** - * - * - *
-   * A list of device numeric IDs. If empty, this field is ignored. Maximum
-   * IDs: 10,000.
-   * 
- * - * repeated uint64 device_num_ids = 2; - * - * @return The count of deviceNumIds. - */ - int getDeviceNumIdsCount(); - /** - * - * - *
-   * A list of device numeric IDs. If empty, this field is ignored. Maximum
-   * IDs: 10,000.
-   * 
- * - * repeated uint64 device_num_ids = 2; - * - * @param index The index of the element to return. - * @return The deviceNumIds at the given index. - */ - long getDeviceNumIds(int index); - - /** - * - * - *
-   * A list of device string IDs. For example, `['device0', 'device12']`.
-   * If empty, this field is ignored. Maximum IDs: 10,000
-   * 
- * - * repeated string device_ids = 3; - * - * @return A list containing the deviceIds. - */ - java.util.List getDeviceIdsList(); - /** - * - * - *
-   * A list of device string IDs. For example, `['device0', 'device12']`.
-   * If empty, this field is ignored. Maximum IDs: 10,000
-   * 
- * - * repeated string device_ids = 3; - * - * @return The count of deviceIds. - */ - int getDeviceIdsCount(); - /** - * - * - *
-   * A list of device string IDs. For example, `['device0', 'device12']`.
-   * If empty, this field is ignored. Maximum IDs: 10,000
-   * 
- * - * repeated string device_ids = 3; - * - * @param index The index of the element to return. - * @return The deviceIds at the given index. - */ - java.lang.String getDeviceIds(int index); - /** - * - * - *
-   * A list of device string IDs. For example, `['device0', 'device12']`.
-   * If empty, this field is ignored. Maximum IDs: 10,000
-   * 
- * - * repeated string device_ids = 3; - * - * @param index The index of the value to return. - * @return The bytes of the deviceIds at the given index. - */ - com.google.protobuf.ByteString getDeviceIdsBytes(int index); - - /** - * - * - *
-   * The fields of the `Device` resource to be returned in the response. The
-   * fields `id` and `num_id` are always returned, along with any
-   * other fields specified in snake_case format, for example:
-   * `last_heartbeat_time`.
-   * 
- * - * .google.protobuf.FieldMask field_mask = 4; - * - * @return Whether the fieldMask field is set. - */ - boolean hasFieldMask(); - /** - * - * - *
-   * The fields of the `Device` resource to be returned in the response. The
-   * fields `id` and `num_id` are always returned, along with any
-   * other fields specified in snake_case format, for example:
-   * `last_heartbeat_time`.
-   * 
- * - * .google.protobuf.FieldMask field_mask = 4; - * - * @return The fieldMask. - */ - com.google.protobuf.FieldMask getFieldMask(); - /** - * - * - *
-   * The fields of the `Device` resource to be returned in the response. The
-   * fields `id` and `num_id` are always returned, along with any
-   * other fields specified in snake_case format, for example:
-   * `last_heartbeat_time`.
-   * 
- * - * .google.protobuf.FieldMask field_mask = 4; - */ - com.google.protobuf.FieldMaskOrBuilder getFieldMaskOrBuilder(); - - /** - * - * - *
-   * Options related to gateways.
-   * 
- * - * .google.cloud.iot.v1.GatewayListOptions gateway_list_options = 6; - * - * @return Whether the gatewayListOptions field is set. - */ - boolean hasGatewayListOptions(); - /** - * - * - *
-   * Options related to gateways.
-   * 
- * - * .google.cloud.iot.v1.GatewayListOptions gateway_list_options = 6; - * - * @return The gatewayListOptions. - */ - com.google.cloud.iot.v1.GatewayListOptions getGatewayListOptions(); - /** - * - * - *
-   * Options related to gateways.
-   * 
- * - * .google.cloud.iot.v1.GatewayListOptions gateway_list_options = 6; - */ - com.google.cloud.iot.v1.GatewayListOptionsOrBuilder getGatewayListOptionsOrBuilder(); - - /** - * - * - *
-   * The maximum number of devices to return in the response. If this value
-   * is zero, the service will select a default size. A call may return fewer
-   * objects than requested. A non-empty `next_page_token` in the response
-   * indicates that more data is available.
-   * 
- * - * int32 page_size = 100; - * - * @return The pageSize. - */ - int getPageSize(); - - /** - * - * - *
-   * The value returned by the last `ListDevicesResponse`; indicates
-   * that this is a continuation of a prior `ListDevices` call and
-   * the system should return the next page of data.
-   * 
- * - * string page_token = 101; - * - * @return The pageToken. - */ - java.lang.String getPageToken(); - /** - * - * - *
-   * The value returned by the last `ListDevicesResponse`; indicates
-   * that this is a continuation of a prior `ListDevices` call and
-   * the system should return the next page of data.
-   * 
- * - * string page_token = 101; - * - * @return The bytes for pageToken. - */ - com.google.protobuf.ByteString getPageTokenBytes(); -} diff --git a/proto-google-cloud-iot-v1/src/main/java/com/google/cloud/iot/v1/ListDevicesResponse.java b/proto-google-cloud-iot-v1/src/main/java/com/google/cloud/iot/v1/ListDevicesResponse.java deleted file mode 100644 index 89b41beb..00000000 --- a/proto-google-cloud-iot-v1/src/main/java/com/google/cloud/iot/v1/ListDevicesResponse.java +++ /dev/null @@ -1,1106 +0,0 @@ -/* - * Copyright 2020 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. - */ -// Generated by the protocol buffer compiler. DO NOT EDIT! -// source: google/cloud/iot/v1/device_manager.proto - -package com.google.cloud.iot.v1; - -/** - * - * - *
- * Response for `ListDevices`.
- * 
- * - * Protobuf type {@code google.cloud.iot.v1.ListDevicesResponse} - */ -public final class ListDevicesResponse extends com.google.protobuf.GeneratedMessageV3 - implements - // @@protoc_insertion_point(message_implements:google.cloud.iot.v1.ListDevicesResponse) - ListDevicesResponseOrBuilder { - private static final long serialVersionUID = 0L; - // Use ListDevicesResponse.newBuilder() to construct. - private ListDevicesResponse(com.google.protobuf.GeneratedMessageV3.Builder builder) { - super(builder); - } - - private ListDevicesResponse() { - devices_ = java.util.Collections.emptyList(); - nextPageToken_ = ""; - } - - @java.lang.Override - @SuppressWarnings({"unused"}) - protected java.lang.Object newInstance(UnusedPrivateParameter unused) { - return new ListDevicesResponse(); - } - - @java.lang.Override - public final com.google.protobuf.UnknownFieldSet getUnknownFields() { - return this.unknownFields; - } - - public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { - return com.google.cloud.iot.v1.DeviceManagerProto - .internal_static_google_cloud_iot_v1_ListDevicesResponse_descriptor; - } - - @java.lang.Override - protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable - internalGetFieldAccessorTable() { - return com.google.cloud.iot.v1.DeviceManagerProto - .internal_static_google_cloud_iot_v1_ListDevicesResponse_fieldAccessorTable - .ensureFieldAccessorsInitialized( - com.google.cloud.iot.v1.ListDevicesResponse.class, - com.google.cloud.iot.v1.ListDevicesResponse.Builder.class); - } - - public static final int DEVICES_FIELD_NUMBER = 1; - private java.util.List devices_; - /** - * - * - *
-   * The devices that match the request.
-   * 
- * - * repeated .google.cloud.iot.v1.Device devices = 1; - */ - @java.lang.Override - public java.util.List getDevicesList() { - return devices_; - } - /** - * - * - *
-   * The devices that match the request.
-   * 
- * - * repeated .google.cloud.iot.v1.Device devices = 1; - */ - @java.lang.Override - public java.util.List - getDevicesOrBuilderList() { - return devices_; - } - /** - * - * - *
-   * The devices that match the request.
-   * 
- * - * repeated .google.cloud.iot.v1.Device devices = 1; - */ - @java.lang.Override - public int getDevicesCount() { - return devices_.size(); - } - /** - * - * - *
-   * The devices that match the request.
-   * 
- * - * repeated .google.cloud.iot.v1.Device devices = 1; - */ - @java.lang.Override - public com.google.cloud.iot.v1.Device getDevices(int index) { - return devices_.get(index); - } - /** - * - * - *
-   * The devices that match the request.
-   * 
- * - * repeated .google.cloud.iot.v1.Device devices = 1; - */ - @java.lang.Override - public com.google.cloud.iot.v1.DeviceOrBuilder getDevicesOrBuilder(int index) { - return devices_.get(index); - } - - public static final int NEXT_PAGE_TOKEN_FIELD_NUMBER = 2; - private volatile java.lang.Object nextPageToken_; - /** - * - * - *
-   * If not empty, indicates that there may be more devices that match the
-   * request; this value should be passed in a new `ListDevicesRequest`.
-   * 
- * - * string next_page_token = 2; - * - * @return The nextPageToken. - */ - @java.lang.Override - public java.lang.String getNextPageToken() { - java.lang.Object ref = nextPageToken_; - if (ref instanceof java.lang.String) { - return (java.lang.String) ref; - } else { - com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; - java.lang.String s = bs.toStringUtf8(); - nextPageToken_ = s; - return s; - } - } - /** - * - * - *
-   * If not empty, indicates that there may be more devices that match the
-   * request; this value should be passed in a new `ListDevicesRequest`.
-   * 
- * - * string next_page_token = 2; - * - * @return The bytes for nextPageToken. - */ - @java.lang.Override - public com.google.protobuf.ByteString getNextPageTokenBytes() { - java.lang.Object ref = nextPageToken_; - if (ref instanceof java.lang.String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); - nextPageToken_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - - private byte memoizedIsInitialized = -1; - - @java.lang.Override - public final boolean isInitialized() { - byte isInitialized = memoizedIsInitialized; - if (isInitialized == 1) return true; - if (isInitialized == 0) return false; - - memoizedIsInitialized = 1; - return true; - } - - @java.lang.Override - public void writeTo(com.google.protobuf.CodedOutputStream output) throws java.io.IOException { - for (int i = 0; i < devices_.size(); i++) { - output.writeMessage(1, devices_.get(i)); - } - if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(nextPageToken_)) { - com.google.protobuf.GeneratedMessageV3.writeString(output, 2, nextPageToken_); - } - getUnknownFields().writeTo(output); - } - - @java.lang.Override - public int getSerializedSize() { - int size = memoizedSize; - if (size != -1) return size; - - size = 0; - for (int i = 0; i < devices_.size(); i++) { - size += com.google.protobuf.CodedOutputStream.computeMessageSize(1, devices_.get(i)); - } - if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(nextPageToken_)) { - size += com.google.protobuf.GeneratedMessageV3.computeStringSize(2, nextPageToken_); - } - size += getUnknownFields().getSerializedSize(); - memoizedSize = size; - return size; - } - - @java.lang.Override - public boolean equals(final java.lang.Object obj) { - if (obj == this) { - return true; - } - if (!(obj instanceof com.google.cloud.iot.v1.ListDevicesResponse)) { - return super.equals(obj); - } - com.google.cloud.iot.v1.ListDevicesResponse other = - (com.google.cloud.iot.v1.ListDevicesResponse) obj; - - if (!getDevicesList().equals(other.getDevicesList())) return false; - if (!getNextPageToken().equals(other.getNextPageToken())) return false; - if (!getUnknownFields().equals(other.getUnknownFields())) return false; - return true; - } - - @java.lang.Override - public int hashCode() { - if (memoizedHashCode != 0) { - return memoizedHashCode; - } - int hash = 41; - hash = (19 * hash) + getDescriptor().hashCode(); - if (getDevicesCount() > 0) { - hash = (37 * hash) + DEVICES_FIELD_NUMBER; - hash = (53 * hash) + getDevicesList().hashCode(); - } - hash = (37 * hash) + NEXT_PAGE_TOKEN_FIELD_NUMBER; - hash = (53 * hash) + getNextPageToken().hashCode(); - hash = (29 * hash) + getUnknownFields().hashCode(); - memoizedHashCode = hash; - return hash; - } - - public static com.google.cloud.iot.v1.ListDevicesResponse parseFrom(java.nio.ByteBuffer data) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); - } - - public static com.google.cloud.iot.v1.ListDevicesResponse parseFrom( - java.nio.ByteBuffer data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); - } - - public static com.google.cloud.iot.v1.ListDevicesResponse parseFrom( - com.google.protobuf.ByteString data) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); - } - - public static com.google.cloud.iot.v1.ListDevicesResponse parseFrom( - com.google.protobuf.ByteString data, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); - } - - public static com.google.cloud.iot.v1.ListDevicesResponse parseFrom(byte[] data) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); - } - - public static com.google.cloud.iot.v1.ListDevicesResponse parseFrom( - byte[] data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); - } - - public static com.google.cloud.iot.v1.ListDevicesResponse parseFrom(java.io.InputStream input) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input); - } - - public static com.google.cloud.iot.v1.ListDevicesResponse parseFrom( - java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3.parseWithIOException( - PARSER, input, extensionRegistry); - } - - public static com.google.cloud.iot.v1.ListDevicesResponse parseDelimitedFrom( - java.io.InputStream input) throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3.parseDelimitedWithIOException(PARSER, input); - } - - public static com.google.cloud.iot.v1.ListDevicesResponse parseDelimitedFrom( - java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3.parseDelimitedWithIOException( - PARSER, input, extensionRegistry); - } - - public static com.google.cloud.iot.v1.ListDevicesResponse parseFrom( - com.google.protobuf.CodedInputStream input) throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input); - } - - public static com.google.cloud.iot.v1.ListDevicesResponse parseFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3.parseWithIOException( - PARSER, input, extensionRegistry); - } - - @java.lang.Override - public Builder newBuilderForType() { - return newBuilder(); - } - - public static Builder newBuilder() { - return DEFAULT_INSTANCE.toBuilder(); - } - - public static Builder newBuilder(com.google.cloud.iot.v1.ListDevicesResponse prototype) { - return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); - } - - @java.lang.Override - public Builder toBuilder() { - return this == DEFAULT_INSTANCE ? new Builder() : new Builder().mergeFrom(this); - } - - @java.lang.Override - protected Builder newBuilderForType(com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { - Builder builder = new Builder(parent); - return builder; - } - /** - * - * - *
-   * Response for `ListDevices`.
-   * 
- * - * Protobuf type {@code google.cloud.iot.v1.ListDevicesResponse} - */ - public static final class Builder extends com.google.protobuf.GeneratedMessageV3.Builder - implements - // @@protoc_insertion_point(builder_implements:google.cloud.iot.v1.ListDevicesResponse) - com.google.cloud.iot.v1.ListDevicesResponseOrBuilder { - public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { - return com.google.cloud.iot.v1.DeviceManagerProto - .internal_static_google_cloud_iot_v1_ListDevicesResponse_descriptor; - } - - @java.lang.Override - protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable - internalGetFieldAccessorTable() { - return com.google.cloud.iot.v1.DeviceManagerProto - .internal_static_google_cloud_iot_v1_ListDevicesResponse_fieldAccessorTable - .ensureFieldAccessorsInitialized( - com.google.cloud.iot.v1.ListDevicesResponse.class, - com.google.cloud.iot.v1.ListDevicesResponse.Builder.class); - } - - // Construct using com.google.cloud.iot.v1.ListDevicesResponse.newBuilder() - private Builder() {} - - private Builder(com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { - super(parent); - } - - @java.lang.Override - public Builder clear() { - super.clear(); - if (devicesBuilder_ == null) { - devices_ = java.util.Collections.emptyList(); - } else { - devices_ = null; - devicesBuilder_.clear(); - } - bitField0_ = (bitField0_ & ~0x00000001); - nextPageToken_ = ""; - - return this; - } - - @java.lang.Override - public com.google.protobuf.Descriptors.Descriptor getDescriptorForType() { - return com.google.cloud.iot.v1.DeviceManagerProto - .internal_static_google_cloud_iot_v1_ListDevicesResponse_descriptor; - } - - @java.lang.Override - public com.google.cloud.iot.v1.ListDevicesResponse getDefaultInstanceForType() { - return com.google.cloud.iot.v1.ListDevicesResponse.getDefaultInstance(); - } - - @java.lang.Override - public com.google.cloud.iot.v1.ListDevicesResponse build() { - com.google.cloud.iot.v1.ListDevicesResponse result = buildPartial(); - if (!result.isInitialized()) { - throw newUninitializedMessageException(result); - } - return result; - } - - @java.lang.Override - public com.google.cloud.iot.v1.ListDevicesResponse buildPartial() { - com.google.cloud.iot.v1.ListDevicesResponse result = - new com.google.cloud.iot.v1.ListDevicesResponse(this); - int from_bitField0_ = bitField0_; - if (devicesBuilder_ == null) { - if (((bitField0_ & 0x00000001) != 0)) { - devices_ = java.util.Collections.unmodifiableList(devices_); - bitField0_ = (bitField0_ & ~0x00000001); - } - result.devices_ = devices_; - } else { - result.devices_ = devicesBuilder_.build(); - } - result.nextPageToken_ = nextPageToken_; - onBuilt(); - return result; - } - - @java.lang.Override - public Builder clone() { - return super.clone(); - } - - @java.lang.Override - public Builder setField( - com.google.protobuf.Descriptors.FieldDescriptor field, java.lang.Object value) { - return super.setField(field, value); - } - - @java.lang.Override - public Builder clearField(com.google.protobuf.Descriptors.FieldDescriptor field) { - return super.clearField(field); - } - - @java.lang.Override - public Builder clearOneof(com.google.protobuf.Descriptors.OneofDescriptor oneof) { - return super.clearOneof(oneof); - } - - @java.lang.Override - public Builder setRepeatedField( - com.google.protobuf.Descriptors.FieldDescriptor field, int index, java.lang.Object value) { - return super.setRepeatedField(field, index, value); - } - - @java.lang.Override - public Builder addRepeatedField( - com.google.protobuf.Descriptors.FieldDescriptor field, java.lang.Object value) { - return super.addRepeatedField(field, value); - } - - @java.lang.Override - public Builder mergeFrom(com.google.protobuf.Message other) { - if (other instanceof com.google.cloud.iot.v1.ListDevicesResponse) { - return mergeFrom((com.google.cloud.iot.v1.ListDevicesResponse) other); - } else { - super.mergeFrom(other); - return this; - } - } - - public Builder mergeFrom(com.google.cloud.iot.v1.ListDevicesResponse other) { - if (other == com.google.cloud.iot.v1.ListDevicesResponse.getDefaultInstance()) return this; - if (devicesBuilder_ == null) { - if (!other.devices_.isEmpty()) { - if (devices_.isEmpty()) { - devices_ = other.devices_; - bitField0_ = (bitField0_ & ~0x00000001); - } else { - ensureDevicesIsMutable(); - devices_.addAll(other.devices_); - } - onChanged(); - } - } else { - if (!other.devices_.isEmpty()) { - if (devicesBuilder_.isEmpty()) { - devicesBuilder_.dispose(); - devicesBuilder_ = null; - devices_ = other.devices_; - bitField0_ = (bitField0_ & ~0x00000001); - devicesBuilder_ = - com.google.protobuf.GeneratedMessageV3.alwaysUseFieldBuilders - ? getDevicesFieldBuilder() - : null; - } else { - devicesBuilder_.addAllMessages(other.devices_); - } - } - } - if (!other.getNextPageToken().isEmpty()) { - nextPageToken_ = other.nextPageToken_; - onChanged(); - } - this.mergeUnknownFields(other.getUnknownFields()); - onChanged(); - return this; - } - - @java.lang.Override - public final boolean isInitialized() { - return true; - } - - @java.lang.Override - public Builder mergeFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - if (extensionRegistry == null) { - throw new java.lang.NullPointerException(); - } - try { - boolean done = false; - while (!done) { - int tag = input.readTag(); - switch (tag) { - case 0: - done = true; - break; - case 10: - { - com.google.cloud.iot.v1.Device m = - input.readMessage(com.google.cloud.iot.v1.Device.parser(), extensionRegistry); - if (devicesBuilder_ == null) { - ensureDevicesIsMutable(); - devices_.add(m); - } else { - devicesBuilder_.addMessage(m); - } - break; - } // case 10 - case 18: - { - nextPageToken_ = input.readStringRequireUtf8(); - - break; - } // case 18 - default: - { - if (!super.parseUnknownField(input, extensionRegistry, tag)) { - done = true; // was an endgroup tag - } - break; - } // default: - } // switch (tag) - } // while (!done) - } catch (com.google.protobuf.InvalidProtocolBufferException e) { - throw e.unwrapIOException(); - } finally { - onChanged(); - } // finally - return this; - } - - private int bitField0_; - - private java.util.List devices_ = - java.util.Collections.emptyList(); - - private void ensureDevicesIsMutable() { - if (!((bitField0_ & 0x00000001) != 0)) { - devices_ = new java.util.ArrayList(devices_); - bitField0_ |= 0x00000001; - } - } - - private com.google.protobuf.RepeatedFieldBuilderV3< - com.google.cloud.iot.v1.Device, - com.google.cloud.iot.v1.Device.Builder, - com.google.cloud.iot.v1.DeviceOrBuilder> - devicesBuilder_; - - /** - * - * - *
-     * The devices that match the request.
-     * 
- * - * repeated .google.cloud.iot.v1.Device devices = 1; - */ - public java.util.List getDevicesList() { - if (devicesBuilder_ == null) { - return java.util.Collections.unmodifiableList(devices_); - } else { - return devicesBuilder_.getMessageList(); - } - } - /** - * - * - *
-     * The devices that match the request.
-     * 
- * - * repeated .google.cloud.iot.v1.Device devices = 1; - */ - public int getDevicesCount() { - if (devicesBuilder_ == null) { - return devices_.size(); - } else { - return devicesBuilder_.getCount(); - } - } - /** - * - * - *
-     * The devices that match the request.
-     * 
- * - * repeated .google.cloud.iot.v1.Device devices = 1; - */ - public com.google.cloud.iot.v1.Device getDevices(int index) { - if (devicesBuilder_ == null) { - return devices_.get(index); - } else { - return devicesBuilder_.getMessage(index); - } - } - /** - * - * - *
-     * The devices that match the request.
-     * 
- * - * repeated .google.cloud.iot.v1.Device devices = 1; - */ - public Builder setDevices(int index, com.google.cloud.iot.v1.Device value) { - if (devicesBuilder_ == null) { - if (value == null) { - throw new NullPointerException(); - } - ensureDevicesIsMutable(); - devices_.set(index, value); - onChanged(); - } else { - devicesBuilder_.setMessage(index, value); - } - return this; - } - /** - * - * - *
-     * The devices that match the request.
-     * 
- * - * repeated .google.cloud.iot.v1.Device devices = 1; - */ - public Builder setDevices(int index, com.google.cloud.iot.v1.Device.Builder builderForValue) { - if (devicesBuilder_ == null) { - ensureDevicesIsMutable(); - devices_.set(index, builderForValue.build()); - onChanged(); - } else { - devicesBuilder_.setMessage(index, builderForValue.build()); - } - return this; - } - /** - * - * - *
-     * The devices that match the request.
-     * 
- * - * repeated .google.cloud.iot.v1.Device devices = 1; - */ - public Builder addDevices(com.google.cloud.iot.v1.Device value) { - if (devicesBuilder_ == null) { - if (value == null) { - throw new NullPointerException(); - } - ensureDevicesIsMutable(); - devices_.add(value); - onChanged(); - } else { - devicesBuilder_.addMessage(value); - } - return this; - } - /** - * - * - *
-     * The devices that match the request.
-     * 
- * - * repeated .google.cloud.iot.v1.Device devices = 1; - */ - public Builder addDevices(int index, com.google.cloud.iot.v1.Device value) { - if (devicesBuilder_ == null) { - if (value == null) { - throw new NullPointerException(); - } - ensureDevicesIsMutable(); - devices_.add(index, value); - onChanged(); - } else { - devicesBuilder_.addMessage(index, value); - } - return this; - } - /** - * - * - *
-     * The devices that match the request.
-     * 
- * - * repeated .google.cloud.iot.v1.Device devices = 1; - */ - public Builder addDevices(com.google.cloud.iot.v1.Device.Builder builderForValue) { - if (devicesBuilder_ == null) { - ensureDevicesIsMutable(); - devices_.add(builderForValue.build()); - onChanged(); - } else { - devicesBuilder_.addMessage(builderForValue.build()); - } - return this; - } - /** - * - * - *
-     * The devices that match the request.
-     * 
- * - * repeated .google.cloud.iot.v1.Device devices = 1; - */ - public Builder addDevices(int index, com.google.cloud.iot.v1.Device.Builder builderForValue) { - if (devicesBuilder_ == null) { - ensureDevicesIsMutable(); - devices_.add(index, builderForValue.build()); - onChanged(); - } else { - devicesBuilder_.addMessage(index, builderForValue.build()); - } - return this; - } - /** - * - * - *
-     * The devices that match the request.
-     * 
- * - * repeated .google.cloud.iot.v1.Device devices = 1; - */ - public Builder addAllDevices( - java.lang.Iterable values) { - if (devicesBuilder_ == null) { - ensureDevicesIsMutable(); - com.google.protobuf.AbstractMessageLite.Builder.addAll(values, devices_); - onChanged(); - } else { - devicesBuilder_.addAllMessages(values); - } - return this; - } - /** - * - * - *
-     * The devices that match the request.
-     * 
- * - * repeated .google.cloud.iot.v1.Device devices = 1; - */ - public Builder clearDevices() { - if (devicesBuilder_ == null) { - devices_ = java.util.Collections.emptyList(); - bitField0_ = (bitField0_ & ~0x00000001); - onChanged(); - } else { - devicesBuilder_.clear(); - } - return this; - } - /** - * - * - *
-     * The devices that match the request.
-     * 
- * - * repeated .google.cloud.iot.v1.Device devices = 1; - */ - public Builder removeDevices(int index) { - if (devicesBuilder_ == null) { - ensureDevicesIsMutable(); - devices_.remove(index); - onChanged(); - } else { - devicesBuilder_.remove(index); - } - return this; - } - /** - * - * - *
-     * The devices that match the request.
-     * 
- * - * repeated .google.cloud.iot.v1.Device devices = 1; - */ - public com.google.cloud.iot.v1.Device.Builder getDevicesBuilder(int index) { - return getDevicesFieldBuilder().getBuilder(index); - } - /** - * - * - *
-     * The devices that match the request.
-     * 
- * - * repeated .google.cloud.iot.v1.Device devices = 1; - */ - public com.google.cloud.iot.v1.DeviceOrBuilder getDevicesOrBuilder(int index) { - if (devicesBuilder_ == null) { - return devices_.get(index); - } else { - return devicesBuilder_.getMessageOrBuilder(index); - } - } - /** - * - * - *
-     * The devices that match the request.
-     * 
- * - * repeated .google.cloud.iot.v1.Device devices = 1; - */ - public java.util.List - getDevicesOrBuilderList() { - if (devicesBuilder_ != null) { - return devicesBuilder_.getMessageOrBuilderList(); - } else { - return java.util.Collections.unmodifiableList(devices_); - } - } - /** - * - * - *
-     * The devices that match the request.
-     * 
- * - * repeated .google.cloud.iot.v1.Device devices = 1; - */ - public com.google.cloud.iot.v1.Device.Builder addDevicesBuilder() { - return getDevicesFieldBuilder() - .addBuilder(com.google.cloud.iot.v1.Device.getDefaultInstance()); - } - /** - * - * - *
-     * The devices that match the request.
-     * 
- * - * repeated .google.cloud.iot.v1.Device devices = 1; - */ - public com.google.cloud.iot.v1.Device.Builder addDevicesBuilder(int index) { - return getDevicesFieldBuilder() - .addBuilder(index, com.google.cloud.iot.v1.Device.getDefaultInstance()); - } - /** - * - * - *
-     * The devices that match the request.
-     * 
- * - * repeated .google.cloud.iot.v1.Device devices = 1; - */ - public java.util.List getDevicesBuilderList() { - return getDevicesFieldBuilder().getBuilderList(); - } - - private com.google.protobuf.RepeatedFieldBuilderV3< - com.google.cloud.iot.v1.Device, - com.google.cloud.iot.v1.Device.Builder, - com.google.cloud.iot.v1.DeviceOrBuilder> - getDevicesFieldBuilder() { - if (devicesBuilder_ == null) { - devicesBuilder_ = - new com.google.protobuf.RepeatedFieldBuilderV3< - com.google.cloud.iot.v1.Device, - com.google.cloud.iot.v1.Device.Builder, - com.google.cloud.iot.v1.DeviceOrBuilder>( - devices_, ((bitField0_ & 0x00000001) != 0), getParentForChildren(), isClean()); - devices_ = null; - } - return devicesBuilder_; - } - - private java.lang.Object nextPageToken_ = ""; - /** - * - * - *
-     * If not empty, indicates that there may be more devices that match the
-     * request; this value should be passed in a new `ListDevicesRequest`.
-     * 
- * - * string next_page_token = 2; - * - * @return The nextPageToken. - */ - public java.lang.String getNextPageToken() { - java.lang.Object ref = nextPageToken_; - if (!(ref instanceof java.lang.String)) { - com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; - java.lang.String s = bs.toStringUtf8(); - nextPageToken_ = s; - return s; - } else { - return (java.lang.String) ref; - } - } - /** - * - * - *
-     * If not empty, indicates that there may be more devices that match the
-     * request; this value should be passed in a new `ListDevicesRequest`.
-     * 
- * - * string next_page_token = 2; - * - * @return The bytes for nextPageToken. - */ - public com.google.protobuf.ByteString getNextPageTokenBytes() { - java.lang.Object ref = nextPageToken_; - if (ref instanceof String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); - nextPageToken_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - /** - * - * - *
-     * If not empty, indicates that there may be more devices that match the
-     * request; this value should be passed in a new `ListDevicesRequest`.
-     * 
- * - * string next_page_token = 2; - * - * @param value The nextPageToken to set. - * @return This builder for chaining. - */ - public Builder setNextPageToken(java.lang.String value) { - if (value == null) { - throw new NullPointerException(); - } - - nextPageToken_ = value; - onChanged(); - return this; - } - /** - * - * - *
-     * If not empty, indicates that there may be more devices that match the
-     * request; this value should be passed in a new `ListDevicesRequest`.
-     * 
- * - * string next_page_token = 2; - * - * @return This builder for chaining. - */ - public Builder clearNextPageToken() { - - nextPageToken_ = getDefaultInstance().getNextPageToken(); - onChanged(); - return this; - } - /** - * - * - *
-     * If not empty, indicates that there may be more devices that match the
-     * request; this value should be passed in a new `ListDevicesRequest`.
-     * 
- * - * string next_page_token = 2; - * - * @param value The bytes for nextPageToken to set. - * @return This builder for chaining. - */ - public Builder setNextPageTokenBytes(com.google.protobuf.ByteString value) { - if (value == null) { - throw new NullPointerException(); - } - checkByteStringIsUtf8(value); - - nextPageToken_ = value; - onChanged(); - return this; - } - - @java.lang.Override - public final Builder setUnknownFields(final com.google.protobuf.UnknownFieldSet unknownFields) { - return super.setUnknownFields(unknownFields); - } - - @java.lang.Override - public final Builder mergeUnknownFields( - final com.google.protobuf.UnknownFieldSet unknownFields) { - return super.mergeUnknownFields(unknownFields); - } - - // @@protoc_insertion_point(builder_scope:google.cloud.iot.v1.ListDevicesResponse) - } - - // @@protoc_insertion_point(class_scope:google.cloud.iot.v1.ListDevicesResponse) - private static final com.google.cloud.iot.v1.ListDevicesResponse DEFAULT_INSTANCE; - - static { - DEFAULT_INSTANCE = new com.google.cloud.iot.v1.ListDevicesResponse(); - } - - public static com.google.cloud.iot.v1.ListDevicesResponse getDefaultInstance() { - return DEFAULT_INSTANCE; - } - - private static final com.google.protobuf.Parser PARSER = - new com.google.protobuf.AbstractParser() { - @java.lang.Override - public ListDevicesResponse parsePartialFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - Builder builder = newBuilder(); - try { - builder.mergeFrom(input, extensionRegistry); - } catch (com.google.protobuf.InvalidProtocolBufferException e) { - throw e.setUnfinishedMessage(builder.buildPartial()); - } catch (com.google.protobuf.UninitializedMessageException e) { - throw e.asInvalidProtocolBufferException().setUnfinishedMessage(builder.buildPartial()); - } catch (java.io.IOException e) { - throw new com.google.protobuf.InvalidProtocolBufferException(e) - .setUnfinishedMessage(builder.buildPartial()); - } - return builder.buildPartial(); - } - }; - - public static com.google.protobuf.Parser parser() { - return PARSER; - } - - @java.lang.Override - public com.google.protobuf.Parser getParserForType() { - return PARSER; - } - - @java.lang.Override - public com.google.cloud.iot.v1.ListDevicesResponse getDefaultInstanceForType() { - return DEFAULT_INSTANCE; - } -} diff --git a/proto-google-cloud-iot-v1/src/main/java/com/google/cloud/iot/v1/ListDevicesResponseOrBuilder.java b/proto-google-cloud-iot-v1/src/main/java/com/google/cloud/iot/v1/ListDevicesResponseOrBuilder.java deleted file mode 100644 index 4aaf0e36..00000000 --- a/proto-google-cloud-iot-v1/src/main/java/com/google/cloud/iot/v1/ListDevicesResponseOrBuilder.java +++ /dev/null @@ -1,103 +0,0 @@ -/* - * Copyright 2020 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. - */ -// Generated by the protocol buffer compiler. DO NOT EDIT! -// source: google/cloud/iot/v1/device_manager.proto - -package com.google.cloud.iot.v1; - -public interface ListDevicesResponseOrBuilder - extends - // @@protoc_insertion_point(interface_extends:google.cloud.iot.v1.ListDevicesResponse) - com.google.protobuf.MessageOrBuilder { - - /** - * - * - *
-   * The devices that match the request.
-   * 
- * - * repeated .google.cloud.iot.v1.Device devices = 1; - */ - java.util.List getDevicesList(); - /** - * - * - *
-   * The devices that match the request.
-   * 
- * - * repeated .google.cloud.iot.v1.Device devices = 1; - */ - com.google.cloud.iot.v1.Device getDevices(int index); - /** - * - * - *
-   * The devices that match the request.
-   * 
- * - * repeated .google.cloud.iot.v1.Device devices = 1; - */ - int getDevicesCount(); - /** - * - * - *
-   * The devices that match the request.
-   * 
- * - * repeated .google.cloud.iot.v1.Device devices = 1; - */ - java.util.List getDevicesOrBuilderList(); - /** - * - * - *
-   * The devices that match the request.
-   * 
- * - * repeated .google.cloud.iot.v1.Device devices = 1; - */ - com.google.cloud.iot.v1.DeviceOrBuilder getDevicesOrBuilder(int index); - - /** - * - * - *
-   * If not empty, indicates that there may be more devices that match the
-   * request; this value should be passed in a new `ListDevicesRequest`.
-   * 
- * - * string next_page_token = 2; - * - * @return The nextPageToken. - */ - java.lang.String getNextPageToken(); - /** - * - * - *
-   * If not empty, indicates that there may be more devices that match the
-   * request; this value should be passed in a new `ListDevicesRequest`.
-   * 
- * - * string next_page_token = 2; - * - * @return The bytes for nextPageToken. - */ - com.google.protobuf.ByteString getNextPageTokenBytes(); -} diff --git a/proto-google-cloud-iot-v1/src/main/java/com/google/cloud/iot/v1/LocationName.java b/proto-google-cloud-iot-v1/src/main/java/com/google/cloud/iot/v1/LocationName.java deleted file mode 100644 index 344bc18d..00000000 --- a/proto-google-cloud-iot-v1/src/main/java/com/google/cloud/iot/v1/LocationName.java +++ /dev/null @@ -1,192 +0,0 @@ -/* - * 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 com.google.api.pathtemplate.PathTemplate; -import com.google.api.resourcenames.ResourceName; -import com.google.common.base.Preconditions; -import com.google.common.collect.ImmutableMap; -import java.util.ArrayList; -import java.util.List; -import java.util.Map; -import java.util.Objects; -import javax.annotation.Generated; - -// AUTO-GENERATED DOCUMENTATION AND CLASS. -@Generated("by gapic-generator-java") -public class LocationName implements ResourceName { - private static final PathTemplate PROJECT_LOCATION = - PathTemplate.createWithoutUrlEncoding("projects/{project}/locations/{location}"); - private volatile Map fieldValuesMap; - private final String project; - private final String location; - - @Deprecated - protected LocationName() { - project = null; - location = null; - } - - private LocationName(Builder builder) { - project = Preconditions.checkNotNull(builder.getProject()); - location = Preconditions.checkNotNull(builder.getLocation()); - } - - public String getProject() { - return project; - } - - public String getLocation() { - return location; - } - - public static Builder newBuilder() { - return new Builder(); - } - - public Builder toBuilder() { - return new Builder(this); - } - - public static LocationName of(String project, String location) { - return newBuilder().setProject(project).setLocation(location).build(); - } - - public static String format(String project, String location) { - return newBuilder().setProject(project).setLocation(location).build().toString(); - } - - public static LocationName parse(String formattedString) { - if (formattedString.isEmpty()) { - return null; - } - Map matchMap = - PROJECT_LOCATION.validatedMatch( - formattedString, "LocationName.parse: formattedString not in valid format"); - return of(matchMap.get("project"), matchMap.get("location")); - } - - public static List parseList(List formattedStrings) { - List list = new ArrayList<>(formattedStrings.size()); - for (String formattedString : formattedStrings) { - list.add(parse(formattedString)); - } - return list; - } - - public static List toStringList(List values) { - List list = new ArrayList<>(values.size()); - for (LocationName value : values) { - if (value == null) { - list.add(""); - } else { - list.add(value.toString()); - } - } - return list; - } - - public static boolean isParsableFrom(String formattedString) { - return PROJECT_LOCATION.matches(formattedString); - } - - @Override - public Map getFieldValuesMap() { - if (fieldValuesMap == null) { - synchronized (this) { - if (fieldValuesMap == null) { - ImmutableMap.Builder fieldMapBuilder = ImmutableMap.builder(); - if (project != null) { - fieldMapBuilder.put("project", project); - } - if (location != null) { - fieldMapBuilder.put("location", location); - } - fieldValuesMap = fieldMapBuilder.build(); - } - } - } - return fieldValuesMap; - } - - public String getFieldValue(String fieldName) { - return getFieldValuesMap().get(fieldName); - } - - @Override - public String toString() { - return PROJECT_LOCATION.instantiate("project", project, "location", location); - } - - @Override - public boolean equals(Object o) { - if (o == this) { - return true; - } - if (o != null || getClass() == o.getClass()) { - LocationName that = ((LocationName) o); - return Objects.equals(this.project, that.project) - && Objects.equals(this.location, that.location); - } - return false; - } - - @Override - public int hashCode() { - int h = 1; - h *= 1000003; - h ^= Objects.hashCode(project); - h *= 1000003; - h ^= Objects.hashCode(location); - return h; - } - - /** Builder for projects/{project}/locations/{location}. */ - public static class Builder { - private String project; - private String location; - - protected Builder() {} - - public String getProject() { - return project; - } - - public String getLocation() { - return location; - } - - public Builder setProject(String project) { - this.project = project; - return this; - } - - public Builder setLocation(String location) { - this.location = location; - return this; - } - - private Builder(LocationName locationName) { - this.project = locationName.project; - this.location = locationName.location; - } - - public LocationName build() { - return new LocationName(this); - } - } -} diff --git a/proto-google-cloud-iot-v1/src/main/java/com/google/cloud/iot/v1/LogLevel.java b/proto-google-cloud-iot-v1/src/main/java/com/google/cloud/iot/v1/LogLevel.java deleted file mode 100644 index 4e73594c..00000000 --- a/proto-google-cloud-iot-v1/src/main/java/com/google/cloud/iot/v1/LogLevel.java +++ /dev/null @@ -1,226 +0,0 @@ -/* - * Copyright 2020 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. - */ -// Generated by the protocol buffer compiler. DO NOT EDIT! -// source: google/cloud/iot/v1/resources.proto - -package com.google.cloud.iot.v1; - -/** - * - * - *
- * **Beta Feature**
- * The logging verbosity for device activity. Specifies which events should be
- * written to logs. For example, if the LogLevel is ERROR, only events that
- * terminate in errors will be logged. LogLevel is inclusive; enabling INFO
- * logging will also enable ERROR logging.
- * 
- * - * Protobuf enum {@code google.cloud.iot.v1.LogLevel} - */ -public enum LogLevel implements com.google.protobuf.ProtocolMessageEnum { - /** - * - * - *
-   * No logging specified. If not specified, logging will be disabled.
-   * 
- * - * LOG_LEVEL_UNSPECIFIED = 0; - */ - LOG_LEVEL_UNSPECIFIED(0), - /** - * - * - *
-   * Disables logging.
-   * 
- * - * NONE = 10; - */ - NONE(10), - /** - * - * - *
-   * Error events will be logged.
-   * 
- * - * ERROR = 20; - */ - ERROR(20), - /** - * - * - *
-   * Informational events will be logged, such as connections and
-   * disconnections.
-   * 
- * - * INFO = 30; - */ - INFO(30), - /** - * - * - *
-   * All events will be logged.
-   * 
- * - * DEBUG = 40; - */ - DEBUG(40), - UNRECOGNIZED(-1), - ; - - /** - * - * - *
-   * No logging specified. If not specified, logging will be disabled.
-   * 
- * - * LOG_LEVEL_UNSPECIFIED = 0; - */ - public static final int LOG_LEVEL_UNSPECIFIED_VALUE = 0; - /** - * - * - *
-   * Disables logging.
-   * 
- * - * NONE = 10; - */ - public static final int NONE_VALUE = 10; - /** - * - * - *
-   * Error events will be logged.
-   * 
- * - * ERROR = 20; - */ - public static final int ERROR_VALUE = 20; - /** - * - * - *
-   * Informational events will be logged, such as connections and
-   * disconnections.
-   * 
- * - * INFO = 30; - */ - public static final int INFO_VALUE = 30; - /** - * - * - *
-   * All events will be logged.
-   * 
- * - * DEBUG = 40; - */ - public static final int DEBUG_VALUE = 40; - - public final int getNumber() { - if (this == UNRECOGNIZED) { - throw new java.lang.IllegalArgumentException( - "Can't get the number of an unknown enum value."); - } - return value; - } - - /** - * @param value The numeric wire value of the corresponding enum entry. - * @return The enum associated with the given numeric wire value. - * @deprecated Use {@link #forNumber(int)} instead. - */ - @java.lang.Deprecated - public static LogLevel valueOf(int value) { - return forNumber(value); - } - - /** - * @param value The numeric wire value of the corresponding enum entry. - * @return The enum associated with the given numeric wire value. - */ - public static LogLevel forNumber(int value) { - switch (value) { - case 0: - return LOG_LEVEL_UNSPECIFIED; - case 10: - return NONE; - case 20: - return ERROR; - case 30: - return INFO; - case 40: - return DEBUG; - default: - return null; - } - } - - public static com.google.protobuf.Internal.EnumLiteMap internalGetValueMap() { - return internalValueMap; - } - - private static final com.google.protobuf.Internal.EnumLiteMap internalValueMap = - new com.google.protobuf.Internal.EnumLiteMap() { - public LogLevel findValueByNumber(int number) { - return LogLevel.forNumber(number); - } - }; - - public final com.google.protobuf.Descriptors.EnumValueDescriptor getValueDescriptor() { - if (this == UNRECOGNIZED) { - throw new java.lang.IllegalStateException( - "Can't get the descriptor of an unrecognized enum value."); - } - return getDescriptor().getValues().get(ordinal()); - } - - public final com.google.protobuf.Descriptors.EnumDescriptor getDescriptorForType() { - return getDescriptor(); - } - - public static final com.google.protobuf.Descriptors.EnumDescriptor getDescriptor() { - return com.google.cloud.iot.v1.ResourcesProto.getDescriptor().getEnumTypes().get(2); - } - - private static final LogLevel[] VALUES = values(); - - public static LogLevel valueOf(com.google.protobuf.Descriptors.EnumValueDescriptor desc) { - if (desc.getType() != getDescriptor()) { - throw new java.lang.IllegalArgumentException("EnumValueDescriptor is not for this type."); - } - if (desc.getIndex() == -1) { - return UNRECOGNIZED; - } - return VALUES[desc.getIndex()]; - } - - private final int value; - - private LogLevel(int value) { - this.value = value; - } - - // @@protoc_insertion_point(enum_scope:google.cloud.iot.v1.LogLevel) -} diff --git a/proto-google-cloud-iot-v1/src/main/java/com/google/cloud/iot/v1/ModifyCloudToDeviceConfigRequest.java b/proto-google-cloud-iot-v1/src/main/java/com/google/cloud/iot/v1/ModifyCloudToDeviceConfigRequest.java deleted file mode 100644 index 80fa2131..00000000 --- a/proto-google-cloud-iot-v1/src/main/java/com/google/cloud/iot/v1/ModifyCloudToDeviceConfigRequest.java +++ /dev/null @@ -1,847 +0,0 @@ -/* - * Copyright 2020 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. - */ -// Generated by the protocol buffer compiler. DO NOT EDIT! -// source: google/cloud/iot/v1/device_manager.proto - -package com.google.cloud.iot.v1; - -/** - * - * - *
- * Request for `ModifyCloudToDeviceConfig`.
- * 
- * - * Protobuf type {@code google.cloud.iot.v1.ModifyCloudToDeviceConfigRequest} - */ -public final class ModifyCloudToDeviceConfigRequest extends com.google.protobuf.GeneratedMessageV3 - implements - // @@protoc_insertion_point(message_implements:google.cloud.iot.v1.ModifyCloudToDeviceConfigRequest) - ModifyCloudToDeviceConfigRequestOrBuilder { - private static final long serialVersionUID = 0L; - // Use ModifyCloudToDeviceConfigRequest.newBuilder() to construct. - private ModifyCloudToDeviceConfigRequest( - com.google.protobuf.GeneratedMessageV3.Builder builder) { - super(builder); - } - - private ModifyCloudToDeviceConfigRequest() { - name_ = ""; - binaryData_ = com.google.protobuf.ByteString.EMPTY; - } - - @java.lang.Override - @SuppressWarnings({"unused"}) - protected java.lang.Object newInstance(UnusedPrivateParameter unused) { - return new ModifyCloudToDeviceConfigRequest(); - } - - @java.lang.Override - public final com.google.protobuf.UnknownFieldSet getUnknownFields() { - return this.unknownFields; - } - - public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { - return com.google.cloud.iot.v1.DeviceManagerProto - .internal_static_google_cloud_iot_v1_ModifyCloudToDeviceConfigRequest_descriptor; - } - - @java.lang.Override - protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable - internalGetFieldAccessorTable() { - return com.google.cloud.iot.v1.DeviceManagerProto - .internal_static_google_cloud_iot_v1_ModifyCloudToDeviceConfigRequest_fieldAccessorTable - .ensureFieldAccessorsInitialized( - com.google.cloud.iot.v1.ModifyCloudToDeviceConfigRequest.class, - com.google.cloud.iot.v1.ModifyCloudToDeviceConfigRequest.Builder.class); - } - - public static final int NAME_FIELD_NUMBER = 1; - private volatile java.lang.Object name_; - /** - * - * - *
-   * Required. The name of the device. For example,
-   * `projects/p0/locations/us-central1/registries/registry0/devices/device0` or
-   * `projects/p0/locations/us-central1/registries/registry0/devices/{num_id}`.
-   * 
- * - * - * string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } - * - * - * @return The name. - */ - @java.lang.Override - public java.lang.String getName() { - java.lang.Object ref = name_; - if (ref instanceof java.lang.String) { - return (java.lang.String) ref; - } else { - com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; - java.lang.String s = bs.toStringUtf8(); - name_ = s; - return s; - } - } - /** - * - * - *
-   * Required. The name of the device. For example,
-   * `projects/p0/locations/us-central1/registries/registry0/devices/device0` or
-   * `projects/p0/locations/us-central1/registries/registry0/devices/{num_id}`.
-   * 
- * - * - * string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } - * - * - * @return The bytes for name. - */ - @java.lang.Override - public com.google.protobuf.ByteString getNameBytes() { - java.lang.Object ref = name_; - if (ref instanceof java.lang.String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); - name_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - - public static final int VERSION_TO_UPDATE_FIELD_NUMBER = 2; - private long versionToUpdate_; - /** - * - * - *
-   * The version number to update. If this value is zero, it will not check the
-   * version number of the server and will always update the current version;
-   * otherwise, this update will fail if the version number found on the server
-   * does not match this version number. This is used to support multiple
-   * simultaneous updates without losing data.
-   * 
- * - * int64 version_to_update = 2; - * - * @return The versionToUpdate. - */ - @java.lang.Override - public long getVersionToUpdate() { - return versionToUpdate_; - } - - public static final int BINARY_DATA_FIELD_NUMBER = 3; - private com.google.protobuf.ByteString binaryData_; - /** - * - * - *
-   * Required. The configuration data for the device.
-   * 
- * - * bytes binary_data = 3 [(.google.api.field_behavior) = REQUIRED]; - * - * @return The binaryData. - */ - @java.lang.Override - public com.google.protobuf.ByteString getBinaryData() { - return binaryData_; - } - - private byte memoizedIsInitialized = -1; - - @java.lang.Override - public final boolean isInitialized() { - byte isInitialized = memoizedIsInitialized; - if (isInitialized == 1) return true; - if (isInitialized == 0) return false; - - memoizedIsInitialized = 1; - return true; - } - - @java.lang.Override - public void writeTo(com.google.protobuf.CodedOutputStream output) throws java.io.IOException { - if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(name_)) { - com.google.protobuf.GeneratedMessageV3.writeString(output, 1, name_); - } - if (versionToUpdate_ != 0L) { - output.writeInt64(2, versionToUpdate_); - } - if (!binaryData_.isEmpty()) { - output.writeBytes(3, binaryData_); - } - getUnknownFields().writeTo(output); - } - - @java.lang.Override - public int getSerializedSize() { - int size = memoizedSize; - if (size != -1) return size; - - size = 0; - if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(name_)) { - size += com.google.protobuf.GeneratedMessageV3.computeStringSize(1, name_); - } - if (versionToUpdate_ != 0L) { - size += com.google.protobuf.CodedOutputStream.computeInt64Size(2, versionToUpdate_); - } - if (!binaryData_.isEmpty()) { - size += com.google.protobuf.CodedOutputStream.computeBytesSize(3, binaryData_); - } - size += getUnknownFields().getSerializedSize(); - memoizedSize = size; - return size; - } - - @java.lang.Override - public boolean equals(final java.lang.Object obj) { - if (obj == this) { - return true; - } - if (!(obj instanceof com.google.cloud.iot.v1.ModifyCloudToDeviceConfigRequest)) { - return super.equals(obj); - } - com.google.cloud.iot.v1.ModifyCloudToDeviceConfigRequest other = - (com.google.cloud.iot.v1.ModifyCloudToDeviceConfigRequest) obj; - - if (!getName().equals(other.getName())) return false; - if (getVersionToUpdate() != other.getVersionToUpdate()) return false; - if (!getBinaryData().equals(other.getBinaryData())) return false; - if (!getUnknownFields().equals(other.getUnknownFields())) return false; - return true; - } - - @java.lang.Override - public int hashCode() { - if (memoizedHashCode != 0) { - return memoizedHashCode; - } - int hash = 41; - hash = (19 * hash) + getDescriptor().hashCode(); - hash = (37 * hash) + NAME_FIELD_NUMBER; - hash = (53 * hash) + getName().hashCode(); - hash = (37 * hash) + VERSION_TO_UPDATE_FIELD_NUMBER; - hash = (53 * hash) + com.google.protobuf.Internal.hashLong(getVersionToUpdate()); - hash = (37 * hash) + BINARY_DATA_FIELD_NUMBER; - hash = (53 * hash) + getBinaryData().hashCode(); - hash = (29 * hash) + getUnknownFields().hashCode(); - memoizedHashCode = hash; - return hash; - } - - public static com.google.cloud.iot.v1.ModifyCloudToDeviceConfigRequest parseFrom( - java.nio.ByteBuffer data) throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); - } - - public static com.google.cloud.iot.v1.ModifyCloudToDeviceConfigRequest parseFrom( - java.nio.ByteBuffer data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); - } - - public static com.google.cloud.iot.v1.ModifyCloudToDeviceConfigRequest parseFrom( - com.google.protobuf.ByteString data) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); - } - - public static com.google.cloud.iot.v1.ModifyCloudToDeviceConfigRequest parseFrom( - com.google.protobuf.ByteString data, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); - } - - public static com.google.cloud.iot.v1.ModifyCloudToDeviceConfigRequest parseFrom(byte[] data) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); - } - - public static com.google.cloud.iot.v1.ModifyCloudToDeviceConfigRequest parseFrom( - byte[] data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); - } - - public static com.google.cloud.iot.v1.ModifyCloudToDeviceConfigRequest parseFrom( - java.io.InputStream input) throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input); - } - - public static com.google.cloud.iot.v1.ModifyCloudToDeviceConfigRequest parseFrom( - java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3.parseWithIOException( - PARSER, input, extensionRegistry); - } - - public static com.google.cloud.iot.v1.ModifyCloudToDeviceConfigRequest parseDelimitedFrom( - java.io.InputStream input) throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3.parseDelimitedWithIOException(PARSER, input); - } - - public static com.google.cloud.iot.v1.ModifyCloudToDeviceConfigRequest parseDelimitedFrom( - java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3.parseDelimitedWithIOException( - PARSER, input, extensionRegistry); - } - - public static com.google.cloud.iot.v1.ModifyCloudToDeviceConfigRequest parseFrom( - com.google.protobuf.CodedInputStream input) throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input); - } - - public static com.google.cloud.iot.v1.ModifyCloudToDeviceConfigRequest parseFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3.parseWithIOException( - PARSER, input, extensionRegistry); - } - - @java.lang.Override - public Builder newBuilderForType() { - return newBuilder(); - } - - public static Builder newBuilder() { - return DEFAULT_INSTANCE.toBuilder(); - } - - public static Builder newBuilder( - com.google.cloud.iot.v1.ModifyCloudToDeviceConfigRequest prototype) { - return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); - } - - @java.lang.Override - public Builder toBuilder() { - return this == DEFAULT_INSTANCE ? new Builder() : new Builder().mergeFrom(this); - } - - @java.lang.Override - protected Builder newBuilderForType(com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { - Builder builder = new Builder(parent); - return builder; - } - /** - * - * - *
-   * Request for `ModifyCloudToDeviceConfig`.
-   * 
- * - * Protobuf type {@code google.cloud.iot.v1.ModifyCloudToDeviceConfigRequest} - */ - public static final class Builder extends com.google.protobuf.GeneratedMessageV3.Builder - implements - // @@protoc_insertion_point(builder_implements:google.cloud.iot.v1.ModifyCloudToDeviceConfigRequest) - com.google.cloud.iot.v1.ModifyCloudToDeviceConfigRequestOrBuilder { - public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { - return com.google.cloud.iot.v1.DeviceManagerProto - .internal_static_google_cloud_iot_v1_ModifyCloudToDeviceConfigRequest_descriptor; - } - - @java.lang.Override - protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable - internalGetFieldAccessorTable() { - return com.google.cloud.iot.v1.DeviceManagerProto - .internal_static_google_cloud_iot_v1_ModifyCloudToDeviceConfigRequest_fieldAccessorTable - .ensureFieldAccessorsInitialized( - com.google.cloud.iot.v1.ModifyCloudToDeviceConfigRequest.class, - com.google.cloud.iot.v1.ModifyCloudToDeviceConfigRequest.Builder.class); - } - - // Construct using com.google.cloud.iot.v1.ModifyCloudToDeviceConfigRequest.newBuilder() - private Builder() {} - - private Builder(com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { - super(parent); - } - - @java.lang.Override - public Builder clear() { - super.clear(); - name_ = ""; - - versionToUpdate_ = 0L; - - binaryData_ = com.google.protobuf.ByteString.EMPTY; - - return this; - } - - @java.lang.Override - public com.google.protobuf.Descriptors.Descriptor getDescriptorForType() { - return com.google.cloud.iot.v1.DeviceManagerProto - .internal_static_google_cloud_iot_v1_ModifyCloudToDeviceConfigRequest_descriptor; - } - - @java.lang.Override - public com.google.cloud.iot.v1.ModifyCloudToDeviceConfigRequest getDefaultInstanceForType() { - return com.google.cloud.iot.v1.ModifyCloudToDeviceConfigRequest.getDefaultInstance(); - } - - @java.lang.Override - public com.google.cloud.iot.v1.ModifyCloudToDeviceConfigRequest build() { - com.google.cloud.iot.v1.ModifyCloudToDeviceConfigRequest result = buildPartial(); - if (!result.isInitialized()) { - throw newUninitializedMessageException(result); - } - return result; - } - - @java.lang.Override - public com.google.cloud.iot.v1.ModifyCloudToDeviceConfigRequest buildPartial() { - com.google.cloud.iot.v1.ModifyCloudToDeviceConfigRequest result = - new com.google.cloud.iot.v1.ModifyCloudToDeviceConfigRequest(this); - result.name_ = name_; - result.versionToUpdate_ = versionToUpdate_; - result.binaryData_ = binaryData_; - onBuilt(); - return result; - } - - @java.lang.Override - public Builder clone() { - return super.clone(); - } - - @java.lang.Override - public Builder setField( - com.google.protobuf.Descriptors.FieldDescriptor field, java.lang.Object value) { - return super.setField(field, value); - } - - @java.lang.Override - public Builder clearField(com.google.protobuf.Descriptors.FieldDescriptor field) { - return super.clearField(field); - } - - @java.lang.Override - public Builder clearOneof(com.google.protobuf.Descriptors.OneofDescriptor oneof) { - return super.clearOneof(oneof); - } - - @java.lang.Override - public Builder setRepeatedField( - com.google.protobuf.Descriptors.FieldDescriptor field, int index, java.lang.Object value) { - return super.setRepeatedField(field, index, value); - } - - @java.lang.Override - public Builder addRepeatedField( - com.google.protobuf.Descriptors.FieldDescriptor field, java.lang.Object value) { - return super.addRepeatedField(field, value); - } - - @java.lang.Override - public Builder mergeFrom(com.google.protobuf.Message other) { - if (other instanceof com.google.cloud.iot.v1.ModifyCloudToDeviceConfigRequest) { - return mergeFrom((com.google.cloud.iot.v1.ModifyCloudToDeviceConfigRequest) other); - } else { - super.mergeFrom(other); - return this; - } - } - - public Builder mergeFrom(com.google.cloud.iot.v1.ModifyCloudToDeviceConfigRequest other) { - if (other == com.google.cloud.iot.v1.ModifyCloudToDeviceConfigRequest.getDefaultInstance()) - return this; - if (!other.getName().isEmpty()) { - name_ = other.name_; - onChanged(); - } - if (other.getVersionToUpdate() != 0L) { - setVersionToUpdate(other.getVersionToUpdate()); - } - if (other.getBinaryData() != com.google.protobuf.ByteString.EMPTY) { - setBinaryData(other.getBinaryData()); - } - this.mergeUnknownFields(other.getUnknownFields()); - onChanged(); - return this; - } - - @java.lang.Override - public final boolean isInitialized() { - return true; - } - - @java.lang.Override - public Builder mergeFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - if (extensionRegistry == null) { - throw new java.lang.NullPointerException(); - } - try { - boolean done = false; - while (!done) { - int tag = input.readTag(); - switch (tag) { - case 0: - done = true; - break; - case 10: - { - name_ = input.readStringRequireUtf8(); - - break; - } // case 10 - case 16: - { - versionToUpdate_ = input.readInt64(); - - break; - } // case 16 - case 26: - { - binaryData_ = input.readBytes(); - - break; - } // case 26 - default: - { - if (!super.parseUnknownField(input, extensionRegistry, tag)) { - done = true; // was an endgroup tag - } - break; - } // default: - } // switch (tag) - } // while (!done) - } catch (com.google.protobuf.InvalidProtocolBufferException e) { - throw e.unwrapIOException(); - } finally { - onChanged(); - } // finally - return this; - } - - private java.lang.Object name_ = ""; - /** - * - * - *
-     * Required. The name of the device. For example,
-     * `projects/p0/locations/us-central1/registries/registry0/devices/device0` or
-     * `projects/p0/locations/us-central1/registries/registry0/devices/{num_id}`.
-     * 
- * - * - * string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } - * - * - * @return The name. - */ - public java.lang.String getName() { - java.lang.Object ref = name_; - if (!(ref instanceof java.lang.String)) { - com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; - java.lang.String s = bs.toStringUtf8(); - name_ = s; - return s; - } else { - return (java.lang.String) ref; - } - } - /** - * - * - *
-     * Required. The name of the device. For example,
-     * `projects/p0/locations/us-central1/registries/registry0/devices/device0` or
-     * `projects/p0/locations/us-central1/registries/registry0/devices/{num_id}`.
-     * 
- * - * - * string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } - * - * - * @return The bytes for name. - */ - public com.google.protobuf.ByteString getNameBytes() { - java.lang.Object ref = name_; - if (ref instanceof String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); - name_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - /** - * - * - *
-     * Required. The name of the device. For example,
-     * `projects/p0/locations/us-central1/registries/registry0/devices/device0` or
-     * `projects/p0/locations/us-central1/registries/registry0/devices/{num_id}`.
-     * 
- * - * - * string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } - * - * - * @param value The name to set. - * @return This builder for chaining. - */ - public Builder setName(java.lang.String value) { - if (value == null) { - throw new NullPointerException(); - } - - name_ = value; - onChanged(); - return this; - } - /** - * - * - *
-     * Required. The name of the device. For example,
-     * `projects/p0/locations/us-central1/registries/registry0/devices/device0` or
-     * `projects/p0/locations/us-central1/registries/registry0/devices/{num_id}`.
-     * 
- * - * - * string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } - * - * - * @return This builder for chaining. - */ - public Builder clearName() { - - name_ = getDefaultInstance().getName(); - onChanged(); - return this; - } - /** - * - * - *
-     * Required. The name of the device. For example,
-     * `projects/p0/locations/us-central1/registries/registry0/devices/device0` or
-     * `projects/p0/locations/us-central1/registries/registry0/devices/{num_id}`.
-     * 
- * - * - * string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } - * - * - * @param value The bytes for name to set. - * @return This builder for chaining. - */ - public Builder setNameBytes(com.google.protobuf.ByteString value) { - if (value == null) { - throw new NullPointerException(); - } - checkByteStringIsUtf8(value); - - name_ = value; - onChanged(); - return this; - } - - private long versionToUpdate_; - /** - * - * - *
-     * The version number to update. If this value is zero, it will not check the
-     * version number of the server and will always update the current version;
-     * otherwise, this update will fail if the version number found on the server
-     * does not match this version number. This is used to support multiple
-     * simultaneous updates without losing data.
-     * 
- * - * int64 version_to_update = 2; - * - * @return The versionToUpdate. - */ - @java.lang.Override - public long getVersionToUpdate() { - return versionToUpdate_; - } - /** - * - * - *
-     * The version number to update. If this value is zero, it will not check the
-     * version number of the server and will always update the current version;
-     * otherwise, this update will fail if the version number found on the server
-     * does not match this version number. This is used to support multiple
-     * simultaneous updates without losing data.
-     * 
- * - * int64 version_to_update = 2; - * - * @param value The versionToUpdate to set. - * @return This builder for chaining. - */ - public Builder setVersionToUpdate(long value) { - - versionToUpdate_ = value; - onChanged(); - return this; - } - /** - * - * - *
-     * The version number to update. If this value is zero, it will not check the
-     * version number of the server and will always update the current version;
-     * otherwise, this update will fail if the version number found on the server
-     * does not match this version number. This is used to support multiple
-     * simultaneous updates without losing data.
-     * 
- * - * int64 version_to_update = 2; - * - * @return This builder for chaining. - */ - public Builder clearVersionToUpdate() { - - versionToUpdate_ = 0L; - onChanged(); - return this; - } - - private com.google.protobuf.ByteString binaryData_ = com.google.protobuf.ByteString.EMPTY; - /** - * - * - *
-     * Required. The configuration data for the device.
-     * 
- * - * bytes binary_data = 3 [(.google.api.field_behavior) = REQUIRED]; - * - * @return The binaryData. - */ - @java.lang.Override - public com.google.protobuf.ByteString getBinaryData() { - return binaryData_; - } - /** - * - * - *
-     * Required. The configuration data for the device.
-     * 
- * - * bytes binary_data = 3 [(.google.api.field_behavior) = REQUIRED]; - * - * @param value The binaryData to set. - * @return This builder for chaining. - */ - public Builder setBinaryData(com.google.protobuf.ByteString value) { - if (value == null) { - throw new NullPointerException(); - } - - binaryData_ = value; - onChanged(); - return this; - } - /** - * - * - *
-     * Required. The configuration data for the device.
-     * 
- * - * bytes binary_data = 3 [(.google.api.field_behavior) = REQUIRED]; - * - * @return This builder for chaining. - */ - public Builder clearBinaryData() { - - binaryData_ = getDefaultInstance().getBinaryData(); - onChanged(); - return this; - } - - @java.lang.Override - public final Builder setUnknownFields(final com.google.protobuf.UnknownFieldSet unknownFields) { - return super.setUnknownFields(unknownFields); - } - - @java.lang.Override - public final Builder mergeUnknownFields( - final com.google.protobuf.UnknownFieldSet unknownFields) { - return super.mergeUnknownFields(unknownFields); - } - - // @@protoc_insertion_point(builder_scope:google.cloud.iot.v1.ModifyCloudToDeviceConfigRequest) - } - - // @@protoc_insertion_point(class_scope:google.cloud.iot.v1.ModifyCloudToDeviceConfigRequest) - private static final com.google.cloud.iot.v1.ModifyCloudToDeviceConfigRequest DEFAULT_INSTANCE; - - static { - DEFAULT_INSTANCE = new com.google.cloud.iot.v1.ModifyCloudToDeviceConfigRequest(); - } - - public static com.google.cloud.iot.v1.ModifyCloudToDeviceConfigRequest getDefaultInstance() { - return DEFAULT_INSTANCE; - } - - private static final com.google.protobuf.Parser PARSER = - new com.google.protobuf.AbstractParser() { - @java.lang.Override - public ModifyCloudToDeviceConfigRequest parsePartialFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - Builder builder = newBuilder(); - try { - builder.mergeFrom(input, extensionRegistry); - } catch (com.google.protobuf.InvalidProtocolBufferException e) { - throw e.setUnfinishedMessage(builder.buildPartial()); - } catch (com.google.protobuf.UninitializedMessageException e) { - throw e.asInvalidProtocolBufferException().setUnfinishedMessage(builder.buildPartial()); - } catch (java.io.IOException e) { - throw new com.google.protobuf.InvalidProtocolBufferException(e) - .setUnfinishedMessage(builder.buildPartial()); - } - return builder.buildPartial(); - } - }; - - public static com.google.protobuf.Parser parser() { - return PARSER; - } - - @java.lang.Override - public com.google.protobuf.Parser getParserForType() { - return PARSER; - } - - @java.lang.Override - public com.google.cloud.iot.v1.ModifyCloudToDeviceConfigRequest getDefaultInstanceForType() { - return DEFAULT_INSTANCE; - } -} diff --git a/proto-google-cloud-iot-v1/src/main/java/com/google/cloud/iot/v1/ModifyCloudToDeviceConfigRequestOrBuilder.java b/proto-google-cloud-iot-v1/src/main/java/com/google/cloud/iot/v1/ModifyCloudToDeviceConfigRequestOrBuilder.java deleted file mode 100644 index ee851ed3..00000000 --- a/proto-google-cloud-iot-v1/src/main/java/com/google/cloud/iot/v1/ModifyCloudToDeviceConfigRequestOrBuilder.java +++ /dev/null @@ -1,88 +0,0 @@ -/* - * Copyright 2020 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. - */ -// Generated by the protocol buffer compiler. DO NOT EDIT! -// source: google/cloud/iot/v1/device_manager.proto - -package com.google.cloud.iot.v1; - -public interface ModifyCloudToDeviceConfigRequestOrBuilder - extends - // @@protoc_insertion_point(interface_extends:google.cloud.iot.v1.ModifyCloudToDeviceConfigRequest) - com.google.protobuf.MessageOrBuilder { - - /** - * - * - *
-   * Required. The name of the device. For example,
-   * `projects/p0/locations/us-central1/registries/registry0/devices/device0` or
-   * `projects/p0/locations/us-central1/registries/registry0/devices/{num_id}`.
-   * 
- * - * - * string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } - * - * - * @return The name. - */ - java.lang.String getName(); - /** - * - * - *
-   * Required. The name of the device. For example,
-   * `projects/p0/locations/us-central1/registries/registry0/devices/device0` or
-   * `projects/p0/locations/us-central1/registries/registry0/devices/{num_id}`.
-   * 
- * - * - * string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } - * - * - * @return The bytes for name. - */ - com.google.protobuf.ByteString getNameBytes(); - - /** - * - * - *
-   * The version number to update. If this value is zero, it will not check the
-   * version number of the server and will always update the current version;
-   * otherwise, this update will fail if the version number found on the server
-   * does not match this version number. This is used to support multiple
-   * simultaneous updates without losing data.
-   * 
- * - * int64 version_to_update = 2; - * - * @return The versionToUpdate. - */ - long getVersionToUpdate(); - - /** - * - * - *
-   * Required. The configuration data for the device.
-   * 
- * - * bytes binary_data = 3 [(.google.api.field_behavior) = REQUIRED]; - * - * @return The binaryData. - */ - com.google.protobuf.ByteString getBinaryData(); -} diff --git a/proto-google-cloud-iot-v1/src/main/java/com/google/cloud/iot/v1/MqttConfig.java b/proto-google-cloud-iot-v1/src/main/java/com/google/cloud/iot/v1/MqttConfig.java deleted file mode 100644 index 5a8cac34..00000000 --- a/proto-google-cloud-iot-v1/src/main/java/com/google/cloud/iot/v1/MqttConfig.java +++ /dev/null @@ -1,589 +0,0 @@ -/* - * Copyright 2020 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. - */ -// Generated by the protocol buffer compiler. DO NOT EDIT! -// source: google/cloud/iot/v1/resources.proto - -package com.google.cloud.iot.v1; - -/** - * - * - *
- * The configuration of MQTT for a device registry.
- * 
- * - * Protobuf type {@code google.cloud.iot.v1.MqttConfig} - */ -public final class MqttConfig extends com.google.protobuf.GeneratedMessageV3 - implements - // @@protoc_insertion_point(message_implements:google.cloud.iot.v1.MqttConfig) - MqttConfigOrBuilder { - private static final long serialVersionUID = 0L; - // Use MqttConfig.newBuilder() to construct. - private MqttConfig(com.google.protobuf.GeneratedMessageV3.Builder builder) { - super(builder); - } - - private MqttConfig() { - mqttEnabledState_ = 0; - } - - @java.lang.Override - @SuppressWarnings({"unused"}) - protected java.lang.Object newInstance(UnusedPrivateParameter unused) { - return new MqttConfig(); - } - - @java.lang.Override - public final com.google.protobuf.UnknownFieldSet getUnknownFields() { - return this.unknownFields; - } - - public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { - return com.google.cloud.iot.v1.ResourcesProto - .internal_static_google_cloud_iot_v1_MqttConfig_descriptor; - } - - @java.lang.Override - protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable - internalGetFieldAccessorTable() { - return com.google.cloud.iot.v1.ResourcesProto - .internal_static_google_cloud_iot_v1_MqttConfig_fieldAccessorTable - .ensureFieldAccessorsInitialized( - com.google.cloud.iot.v1.MqttConfig.class, - com.google.cloud.iot.v1.MqttConfig.Builder.class); - } - - public static final int MQTT_ENABLED_STATE_FIELD_NUMBER = 1; - private int mqttEnabledState_; - /** - * - * - *
-   * If enabled, allows connections using the MQTT protocol. Otherwise, MQTT
-   * connections to this registry will fail.
-   * 
- * - * .google.cloud.iot.v1.MqttState mqtt_enabled_state = 1; - * - * @return The enum numeric value on the wire for mqttEnabledState. - */ - @java.lang.Override - public int getMqttEnabledStateValue() { - return mqttEnabledState_; - } - /** - * - * - *
-   * If enabled, allows connections using the MQTT protocol. Otherwise, MQTT
-   * connections to this registry will fail.
-   * 
- * - * .google.cloud.iot.v1.MqttState mqtt_enabled_state = 1; - * - * @return The mqttEnabledState. - */ - @java.lang.Override - public com.google.cloud.iot.v1.MqttState getMqttEnabledState() { - @SuppressWarnings("deprecation") - com.google.cloud.iot.v1.MqttState result = - com.google.cloud.iot.v1.MqttState.valueOf(mqttEnabledState_); - return result == null ? com.google.cloud.iot.v1.MqttState.UNRECOGNIZED : result; - } - - private byte memoizedIsInitialized = -1; - - @java.lang.Override - public final boolean isInitialized() { - byte isInitialized = memoizedIsInitialized; - if (isInitialized == 1) return true; - if (isInitialized == 0) return false; - - memoizedIsInitialized = 1; - return true; - } - - @java.lang.Override - public void writeTo(com.google.protobuf.CodedOutputStream output) throws java.io.IOException { - if (mqttEnabledState_ != com.google.cloud.iot.v1.MqttState.MQTT_STATE_UNSPECIFIED.getNumber()) { - output.writeEnum(1, mqttEnabledState_); - } - getUnknownFields().writeTo(output); - } - - @java.lang.Override - public int getSerializedSize() { - int size = memoizedSize; - if (size != -1) return size; - - size = 0; - if (mqttEnabledState_ != com.google.cloud.iot.v1.MqttState.MQTT_STATE_UNSPECIFIED.getNumber()) { - size += com.google.protobuf.CodedOutputStream.computeEnumSize(1, mqttEnabledState_); - } - size += getUnknownFields().getSerializedSize(); - memoizedSize = size; - return size; - } - - @java.lang.Override - public boolean equals(final java.lang.Object obj) { - if (obj == this) { - return true; - } - if (!(obj instanceof com.google.cloud.iot.v1.MqttConfig)) { - return super.equals(obj); - } - com.google.cloud.iot.v1.MqttConfig other = (com.google.cloud.iot.v1.MqttConfig) obj; - - if (mqttEnabledState_ != other.mqttEnabledState_) return false; - if (!getUnknownFields().equals(other.getUnknownFields())) return false; - return true; - } - - @java.lang.Override - public int hashCode() { - if (memoizedHashCode != 0) { - return memoizedHashCode; - } - int hash = 41; - hash = (19 * hash) + getDescriptor().hashCode(); - hash = (37 * hash) + MQTT_ENABLED_STATE_FIELD_NUMBER; - hash = (53 * hash) + mqttEnabledState_; - hash = (29 * hash) + getUnknownFields().hashCode(); - memoizedHashCode = hash; - return hash; - } - - public static com.google.cloud.iot.v1.MqttConfig parseFrom(java.nio.ByteBuffer data) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); - } - - public static com.google.cloud.iot.v1.MqttConfig parseFrom( - java.nio.ByteBuffer data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); - } - - public static com.google.cloud.iot.v1.MqttConfig parseFrom(com.google.protobuf.ByteString data) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); - } - - public static com.google.cloud.iot.v1.MqttConfig parseFrom( - com.google.protobuf.ByteString data, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); - } - - public static com.google.cloud.iot.v1.MqttConfig parseFrom(byte[] data) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); - } - - public static com.google.cloud.iot.v1.MqttConfig parseFrom( - byte[] data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); - } - - public static com.google.cloud.iot.v1.MqttConfig parseFrom(java.io.InputStream input) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input); - } - - public static com.google.cloud.iot.v1.MqttConfig parseFrom( - java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3.parseWithIOException( - PARSER, input, extensionRegistry); - } - - public static com.google.cloud.iot.v1.MqttConfig parseDelimitedFrom(java.io.InputStream input) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3.parseDelimitedWithIOException(PARSER, input); - } - - public static com.google.cloud.iot.v1.MqttConfig parseDelimitedFrom( - java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3.parseDelimitedWithIOException( - PARSER, input, extensionRegistry); - } - - public static com.google.cloud.iot.v1.MqttConfig parseFrom( - com.google.protobuf.CodedInputStream input) throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input); - } - - public static com.google.cloud.iot.v1.MqttConfig parseFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3.parseWithIOException( - PARSER, input, extensionRegistry); - } - - @java.lang.Override - public Builder newBuilderForType() { - return newBuilder(); - } - - public static Builder newBuilder() { - return DEFAULT_INSTANCE.toBuilder(); - } - - public static Builder newBuilder(com.google.cloud.iot.v1.MqttConfig prototype) { - return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); - } - - @java.lang.Override - public Builder toBuilder() { - return this == DEFAULT_INSTANCE ? new Builder() : new Builder().mergeFrom(this); - } - - @java.lang.Override - protected Builder newBuilderForType(com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { - Builder builder = new Builder(parent); - return builder; - } - /** - * - * - *
-   * The configuration of MQTT for a device registry.
-   * 
- * - * Protobuf type {@code google.cloud.iot.v1.MqttConfig} - */ - public static final class Builder extends com.google.protobuf.GeneratedMessageV3.Builder - implements - // @@protoc_insertion_point(builder_implements:google.cloud.iot.v1.MqttConfig) - com.google.cloud.iot.v1.MqttConfigOrBuilder { - public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { - return com.google.cloud.iot.v1.ResourcesProto - .internal_static_google_cloud_iot_v1_MqttConfig_descriptor; - } - - @java.lang.Override - protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable - internalGetFieldAccessorTable() { - return com.google.cloud.iot.v1.ResourcesProto - .internal_static_google_cloud_iot_v1_MqttConfig_fieldAccessorTable - .ensureFieldAccessorsInitialized( - com.google.cloud.iot.v1.MqttConfig.class, - com.google.cloud.iot.v1.MqttConfig.Builder.class); - } - - // Construct using com.google.cloud.iot.v1.MqttConfig.newBuilder() - private Builder() {} - - private Builder(com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { - super(parent); - } - - @java.lang.Override - public Builder clear() { - super.clear(); - mqttEnabledState_ = 0; - - return this; - } - - @java.lang.Override - public com.google.protobuf.Descriptors.Descriptor getDescriptorForType() { - return com.google.cloud.iot.v1.ResourcesProto - .internal_static_google_cloud_iot_v1_MqttConfig_descriptor; - } - - @java.lang.Override - public com.google.cloud.iot.v1.MqttConfig getDefaultInstanceForType() { - return com.google.cloud.iot.v1.MqttConfig.getDefaultInstance(); - } - - @java.lang.Override - public com.google.cloud.iot.v1.MqttConfig build() { - com.google.cloud.iot.v1.MqttConfig result = buildPartial(); - if (!result.isInitialized()) { - throw newUninitializedMessageException(result); - } - return result; - } - - @java.lang.Override - public com.google.cloud.iot.v1.MqttConfig buildPartial() { - com.google.cloud.iot.v1.MqttConfig result = new com.google.cloud.iot.v1.MqttConfig(this); - result.mqttEnabledState_ = mqttEnabledState_; - onBuilt(); - return result; - } - - @java.lang.Override - public Builder clone() { - return super.clone(); - } - - @java.lang.Override - public Builder setField( - com.google.protobuf.Descriptors.FieldDescriptor field, java.lang.Object value) { - return super.setField(field, value); - } - - @java.lang.Override - public Builder clearField(com.google.protobuf.Descriptors.FieldDescriptor field) { - return super.clearField(field); - } - - @java.lang.Override - public Builder clearOneof(com.google.protobuf.Descriptors.OneofDescriptor oneof) { - return super.clearOneof(oneof); - } - - @java.lang.Override - public Builder setRepeatedField( - com.google.protobuf.Descriptors.FieldDescriptor field, int index, java.lang.Object value) { - return super.setRepeatedField(field, index, value); - } - - @java.lang.Override - public Builder addRepeatedField( - com.google.protobuf.Descriptors.FieldDescriptor field, java.lang.Object value) { - return super.addRepeatedField(field, value); - } - - @java.lang.Override - public Builder mergeFrom(com.google.protobuf.Message other) { - if (other instanceof com.google.cloud.iot.v1.MqttConfig) { - return mergeFrom((com.google.cloud.iot.v1.MqttConfig) other); - } else { - super.mergeFrom(other); - return this; - } - } - - public Builder mergeFrom(com.google.cloud.iot.v1.MqttConfig other) { - if (other == com.google.cloud.iot.v1.MqttConfig.getDefaultInstance()) return this; - if (other.mqttEnabledState_ != 0) { - setMqttEnabledStateValue(other.getMqttEnabledStateValue()); - } - this.mergeUnknownFields(other.getUnknownFields()); - onChanged(); - return this; - } - - @java.lang.Override - public final boolean isInitialized() { - return true; - } - - @java.lang.Override - public Builder mergeFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - if (extensionRegistry == null) { - throw new java.lang.NullPointerException(); - } - try { - boolean done = false; - while (!done) { - int tag = input.readTag(); - switch (tag) { - case 0: - done = true; - break; - case 8: - { - mqttEnabledState_ = input.readEnum(); - - break; - } // case 8 - default: - { - if (!super.parseUnknownField(input, extensionRegistry, tag)) { - done = true; // was an endgroup tag - } - break; - } // default: - } // switch (tag) - } // while (!done) - } catch (com.google.protobuf.InvalidProtocolBufferException e) { - throw e.unwrapIOException(); - } finally { - onChanged(); - } // finally - return this; - } - - private int mqttEnabledState_ = 0; - /** - * - * - *
-     * If enabled, allows connections using the MQTT protocol. Otherwise, MQTT
-     * connections to this registry will fail.
-     * 
- * - * .google.cloud.iot.v1.MqttState mqtt_enabled_state = 1; - * - * @return The enum numeric value on the wire for mqttEnabledState. - */ - @java.lang.Override - public int getMqttEnabledStateValue() { - return mqttEnabledState_; - } - /** - * - * - *
-     * If enabled, allows connections using the MQTT protocol. Otherwise, MQTT
-     * connections to this registry will fail.
-     * 
- * - * .google.cloud.iot.v1.MqttState mqtt_enabled_state = 1; - * - * @param value The enum numeric value on the wire for mqttEnabledState to set. - * @return This builder for chaining. - */ - public Builder setMqttEnabledStateValue(int value) { - - mqttEnabledState_ = value; - onChanged(); - return this; - } - /** - * - * - *
-     * If enabled, allows connections using the MQTT protocol. Otherwise, MQTT
-     * connections to this registry will fail.
-     * 
- * - * .google.cloud.iot.v1.MqttState mqtt_enabled_state = 1; - * - * @return The mqttEnabledState. - */ - @java.lang.Override - public com.google.cloud.iot.v1.MqttState getMqttEnabledState() { - @SuppressWarnings("deprecation") - com.google.cloud.iot.v1.MqttState result = - com.google.cloud.iot.v1.MqttState.valueOf(mqttEnabledState_); - return result == null ? com.google.cloud.iot.v1.MqttState.UNRECOGNIZED : result; - } - /** - * - * - *
-     * If enabled, allows connections using the MQTT protocol. Otherwise, MQTT
-     * connections to this registry will fail.
-     * 
- * - * .google.cloud.iot.v1.MqttState mqtt_enabled_state = 1; - * - * @param value The mqttEnabledState to set. - * @return This builder for chaining. - */ - public Builder setMqttEnabledState(com.google.cloud.iot.v1.MqttState value) { - if (value == null) { - throw new NullPointerException(); - } - - mqttEnabledState_ = value.getNumber(); - onChanged(); - return this; - } - /** - * - * - *
-     * If enabled, allows connections using the MQTT protocol. Otherwise, MQTT
-     * connections to this registry will fail.
-     * 
- * - * .google.cloud.iot.v1.MqttState mqtt_enabled_state = 1; - * - * @return This builder for chaining. - */ - public Builder clearMqttEnabledState() { - - mqttEnabledState_ = 0; - onChanged(); - return this; - } - - @java.lang.Override - public final Builder setUnknownFields(final com.google.protobuf.UnknownFieldSet unknownFields) { - return super.setUnknownFields(unknownFields); - } - - @java.lang.Override - public final Builder mergeUnknownFields( - final com.google.protobuf.UnknownFieldSet unknownFields) { - return super.mergeUnknownFields(unknownFields); - } - - // @@protoc_insertion_point(builder_scope:google.cloud.iot.v1.MqttConfig) - } - - // @@protoc_insertion_point(class_scope:google.cloud.iot.v1.MqttConfig) - private static final com.google.cloud.iot.v1.MqttConfig DEFAULT_INSTANCE; - - static { - DEFAULT_INSTANCE = new com.google.cloud.iot.v1.MqttConfig(); - } - - public static com.google.cloud.iot.v1.MqttConfig getDefaultInstance() { - return DEFAULT_INSTANCE; - } - - private static final com.google.protobuf.Parser PARSER = - new com.google.protobuf.AbstractParser() { - @java.lang.Override - public MqttConfig parsePartialFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - Builder builder = newBuilder(); - try { - builder.mergeFrom(input, extensionRegistry); - } catch (com.google.protobuf.InvalidProtocolBufferException e) { - throw e.setUnfinishedMessage(builder.buildPartial()); - } catch (com.google.protobuf.UninitializedMessageException e) { - throw e.asInvalidProtocolBufferException().setUnfinishedMessage(builder.buildPartial()); - } catch (java.io.IOException e) { - throw new com.google.protobuf.InvalidProtocolBufferException(e) - .setUnfinishedMessage(builder.buildPartial()); - } - return builder.buildPartial(); - } - }; - - public static com.google.protobuf.Parser parser() { - return PARSER; - } - - @java.lang.Override - public com.google.protobuf.Parser getParserForType() { - return PARSER; - } - - @java.lang.Override - public com.google.cloud.iot.v1.MqttConfig getDefaultInstanceForType() { - return DEFAULT_INSTANCE; - } -} diff --git a/proto-google-cloud-iot-v1/src/main/java/com/google/cloud/iot/v1/MqttConfigOrBuilder.java b/proto-google-cloud-iot-v1/src/main/java/com/google/cloud/iot/v1/MqttConfigOrBuilder.java deleted file mode 100644 index 897b7f5e..00000000 --- a/proto-google-cloud-iot-v1/src/main/java/com/google/cloud/iot/v1/MqttConfigOrBuilder.java +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Copyright 2020 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. - */ -// Generated by the protocol buffer compiler. DO NOT EDIT! -// source: google/cloud/iot/v1/resources.proto - -package com.google.cloud.iot.v1; - -public interface MqttConfigOrBuilder - extends - // @@protoc_insertion_point(interface_extends:google.cloud.iot.v1.MqttConfig) - com.google.protobuf.MessageOrBuilder { - - /** - * - * - *
-   * If enabled, allows connections using the MQTT protocol. Otherwise, MQTT
-   * connections to this registry will fail.
-   * 
- * - * .google.cloud.iot.v1.MqttState mqtt_enabled_state = 1; - * - * @return The enum numeric value on the wire for mqttEnabledState. - */ - int getMqttEnabledStateValue(); - /** - * - * - *
-   * If enabled, allows connections using the MQTT protocol. Otherwise, MQTT
-   * connections to this registry will fail.
-   * 
- * - * .google.cloud.iot.v1.MqttState mqtt_enabled_state = 1; - * - * @return The mqttEnabledState. - */ - com.google.cloud.iot.v1.MqttState getMqttEnabledState(); -} diff --git a/proto-google-cloud-iot-v1/src/main/java/com/google/cloud/iot/v1/MqttState.java b/proto-google-cloud-iot-v1/src/main/java/com/google/cloud/iot/v1/MqttState.java deleted file mode 100644 index b0de10ee..00000000 --- a/proto-google-cloud-iot-v1/src/main/java/com/google/cloud/iot/v1/MqttState.java +++ /dev/null @@ -1,177 +0,0 @@ -/* - * Copyright 2020 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. - */ -// Generated by the protocol buffer compiler. DO NOT EDIT! -// source: google/cloud/iot/v1/resources.proto - -package com.google.cloud.iot.v1; - -/** - * - * - *
- * Indicates whether an MQTT connection is enabled or disabled. See the field
- * description for details.
- * 
- * - * Protobuf enum {@code google.cloud.iot.v1.MqttState} - */ -public enum MqttState implements com.google.protobuf.ProtocolMessageEnum { - /** - * - * - *
-   * No MQTT state specified. If not specified, MQTT will be enabled by default.
-   * 
- * - * MQTT_STATE_UNSPECIFIED = 0; - */ - MQTT_STATE_UNSPECIFIED(0), - /** - * - * - *
-   * Enables a MQTT connection.
-   * 
- * - * MQTT_ENABLED = 1; - */ - MQTT_ENABLED(1), - /** - * - * - *
-   * Disables a MQTT connection.
-   * 
- * - * MQTT_DISABLED = 2; - */ - MQTT_DISABLED(2), - UNRECOGNIZED(-1), - ; - - /** - * - * - *
-   * No MQTT state specified. If not specified, MQTT will be enabled by default.
-   * 
- * - * MQTT_STATE_UNSPECIFIED = 0; - */ - public static final int MQTT_STATE_UNSPECIFIED_VALUE = 0; - /** - * - * - *
-   * Enables a MQTT connection.
-   * 
- * - * MQTT_ENABLED = 1; - */ - public static final int MQTT_ENABLED_VALUE = 1; - /** - * - * - *
-   * Disables a MQTT connection.
-   * 
- * - * MQTT_DISABLED = 2; - */ - public static final int MQTT_DISABLED_VALUE = 2; - - public final int getNumber() { - if (this == UNRECOGNIZED) { - throw new java.lang.IllegalArgumentException( - "Can't get the number of an unknown enum value."); - } - return value; - } - - /** - * @param value The numeric wire value of the corresponding enum entry. - * @return The enum associated with the given numeric wire value. - * @deprecated Use {@link #forNumber(int)} instead. - */ - @java.lang.Deprecated - public static MqttState valueOf(int value) { - return forNumber(value); - } - - /** - * @param value The numeric wire value of the corresponding enum entry. - * @return The enum associated with the given numeric wire value. - */ - public static MqttState forNumber(int value) { - switch (value) { - case 0: - return MQTT_STATE_UNSPECIFIED; - case 1: - return MQTT_ENABLED; - case 2: - return MQTT_DISABLED; - default: - return null; - } - } - - public static com.google.protobuf.Internal.EnumLiteMap internalGetValueMap() { - return internalValueMap; - } - - private static final com.google.protobuf.Internal.EnumLiteMap internalValueMap = - new com.google.protobuf.Internal.EnumLiteMap() { - public MqttState findValueByNumber(int number) { - return MqttState.forNumber(number); - } - }; - - public final com.google.protobuf.Descriptors.EnumValueDescriptor getValueDescriptor() { - if (this == UNRECOGNIZED) { - throw new java.lang.IllegalStateException( - "Can't get the descriptor of an unrecognized enum value."); - } - return getDescriptor().getValues().get(ordinal()); - } - - public final com.google.protobuf.Descriptors.EnumDescriptor getDescriptorForType() { - return getDescriptor(); - } - - public static final com.google.protobuf.Descriptors.EnumDescriptor getDescriptor() { - return com.google.cloud.iot.v1.ResourcesProto.getDescriptor().getEnumTypes().get(0); - } - - private static final MqttState[] VALUES = values(); - - public static MqttState valueOf(com.google.protobuf.Descriptors.EnumValueDescriptor desc) { - if (desc.getType() != getDescriptor()) { - throw new java.lang.IllegalArgumentException("EnumValueDescriptor is not for this type."); - } - if (desc.getIndex() == -1) { - return UNRECOGNIZED; - } - return VALUES[desc.getIndex()]; - } - - private final int value; - - private MqttState(int value) { - this.value = value; - } - - // @@protoc_insertion_point(enum_scope:google.cloud.iot.v1.MqttState) -} diff --git a/proto-google-cloud-iot-v1/src/main/java/com/google/cloud/iot/v1/PublicKeyCertificate.java b/proto-google-cloud-iot-v1/src/main/java/com/google/cloud/iot/v1/PublicKeyCertificate.java deleted file mode 100644 index bb750045..00000000 --- a/proto-google-cloud-iot-v1/src/main/java/com/google/cloud/iot/v1/PublicKeyCertificate.java +++ /dev/null @@ -1,1041 +0,0 @@ -/* - * Copyright 2020 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. - */ -// Generated by the protocol buffer compiler. DO NOT EDIT! -// source: google/cloud/iot/v1/resources.proto - -package com.google.cloud.iot.v1; - -/** - * - * - *
- * A public key certificate format and data.
- * 
- * - * Protobuf type {@code google.cloud.iot.v1.PublicKeyCertificate} - */ -public final class PublicKeyCertificate extends com.google.protobuf.GeneratedMessageV3 - implements - // @@protoc_insertion_point(message_implements:google.cloud.iot.v1.PublicKeyCertificate) - PublicKeyCertificateOrBuilder { - private static final long serialVersionUID = 0L; - // Use PublicKeyCertificate.newBuilder() to construct. - private PublicKeyCertificate(com.google.protobuf.GeneratedMessageV3.Builder builder) { - super(builder); - } - - private PublicKeyCertificate() { - format_ = 0; - certificate_ = ""; - } - - @java.lang.Override - @SuppressWarnings({"unused"}) - protected java.lang.Object newInstance(UnusedPrivateParameter unused) { - return new PublicKeyCertificate(); - } - - @java.lang.Override - public final com.google.protobuf.UnknownFieldSet getUnknownFields() { - return this.unknownFields; - } - - public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { - return com.google.cloud.iot.v1.ResourcesProto - .internal_static_google_cloud_iot_v1_PublicKeyCertificate_descriptor; - } - - @java.lang.Override - protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable - internalGetFieldAccessorTable() { - return com.google.cloud.iot.v1.ResourcesProto - .internal_static_google_cloud_iot_v1_PublicKeyCertificate_fieldAccessorTable - .ensureFieldAccessorsInitialized( - com.google.cloud.iot.v1.PublicKeyCertificate.class, - com.google.cloud.iot.v1.PublicKeyCertificate.Builder.class); - } - - public static final int FORMAT_FIELD_NUMBER = 1; - private int format_; - /** - * - * - *
-   * The certificate format.
-   * 
- * - * .google.cloud.iot.v1.PublicKeyCertificateFormat format = 1; - * - * @return The enum numeric value on the wire for format. - */ - @java.lang.Override - public int getFormatValue() { - return format_; - } - /** - * - * - *
-   * The certificate format.
-   * 
- * - * .google.cloud.iot.v1.PublicKeyCertificateFormat format = 1; - * - * @return The format. - */ - @java.lang.Override - public com.google.cloud.iot.v1.PublicKeyCertificateFormat getFormat() { - @SuppressWarnings("deprecation") - com.google.cloud.iot.v1.PublicKeyCertificateFormat result = - com.google.cloud.iot.v1.PublicKeyCertificateFormat.valueOf(format_); - return result == null - ? com.google.cloud.iot.v1.PublicKeyCertificateFormat.UNRECOGNIZED - : result; - } - - public static final int CERTIFICATE_FIELD_NUMBER = 2; - private volatile java.lang.Object certificate_; - /** - * - * - *
-   * The certificate data.
-   * 
- * - * string certificate = 2; - * - * @return The certificate. - */ - @java.lang.Override - public java.lang.String getCertificate() { - java.lang.Object ref = certificate_; - if (ref instanceof java.lang.String) { - return (java.lang.String) ref; - } else { - com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; - java.lang.String s = bs.toStringUtf8(); - certificate_ = s; - return s; - } - } - /** - * - * - *
-   * The certificate data.
-   * 
- * - * string certificate = 2; - * - * @return The bytes for certificate. - */ - @java.lang.Override - public com.google.protobuf.ByteString getCertificateBytes() { - java.lang.Object ref = certificate_; - if (ref instanceof java.lang.String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); - certificate_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - - public static final int X509_DETAILS_FIELD_NUMBER = 3; - private com.google.cloud.iot.v1.X509CertificateDetails x509Details_; - /** - * - * - *
-   * [Output only] The certificate details. Used only for X.509 certificates.
-   * 
- * - * .google.cloud.iot.v1.X509CertificateDetails x509_details = 3; - * - * @return Whether the x509Details field is set. - */ - @java.lang.Override - public boolean hasX509Details() { - return x509Details_ != null; - } - /** - * - * - *
-   * [Output only] The certificate details. Used only for X.509 certificates.
-   * 
- * - * .google.cloud.iot.v1.X509CertificateDetails x509_details = 3; - * - * @return The x509Details. - */ - @java.lang.Override - public com.google.cloud.iot.v1.X509CertificateDetails getX509Details() { - return x509Details_ == null - ? com.google.cloud.iot.v1.X509CertificateDetails.getDefaultInstance() - : x509Details_; - } - /** - * - * - *
-   * [Output only] The certificate details. Used only for X.509 certificates.
-   * 
- * - * .google.cloud.iot.v1.X509CertificateDetails x509_details = 3; - */ - @java.lang.Override - public com.google.cloud.iot.v1.X509CertificateDetailsOrBuilder getX509DetailsOrBuilder() { - return getX509Details(); - } - - private byte memoizedIsInitialized = -1; - - @java.lang.Override - public final boolean isInitialized() { - byte isInitialized = memoizedIsInitialized; - if (isInitialized == 1) return true; - if (isInitialized == 0) return false; - - memoizedIsInitialized = 1; - return true; - } - - @java.lang.Override - public void writeTo(com.google.protobuf.CodedOutputStream output) throws java.io.IOException { - if (format_ - != com.google.cloud.iot.v1.PublicKeyCertificateFormat - .UNSPECIFIED_PUBLIC_KEY_CERTIFICATE_FORMAT - .getNumber()) { - output.writeEnum(1, format_); - } - if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(certificate_)) { - com.google.protobuf.GeneratedMessageV3.writeString(output, 2, certificate_); - } - if (x509Details_ != null) { - output.writeMessage(3, getX509Details()); - } - getUnknownFields().writeTo(output); - } - - @java.lang.Override - public int getSerializedSize() { - int size = memoizedSize; - if (size != -1) return size; - - size = 0; - if (format_ - != com.google.cloud.iot.v1.PublicKeyCertificateFormat - .UNSPECIFIED_PUBLIC_KEY_CERTIFICATE_FORMAT - .getNumber()) { - size += com.google.protobuf.CodedOutputStream.computeEnumSize(1, format_); - } - if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(certificate_)) { - size += com.google.protobuf.GeneratedMessageV3.computeStringSize(2, certificate_); - } - if (x509Details_ != null) { - size += com.google.protobuf.CodedOutputStream.computeMessageSize(3, getX509Details()); - } - size += getUnknownFields().getSerializedSize(); - memoizedSize = size; - return size; - } - - @java.lang.Override - public boolean equals(final java.lang.Object obj) { - if (obj == this) { - return true; - } - if (!(obj instanceof com.google.cloud.iot.v1.PublicKeyCertificate)) { - return super.equals(obj); - } - com.google.cloud.iot.v1.PublicKeyCertificate other = - (com.google.cloud.iot.v1.PublicKeyCertificate) obj; - - if (format_ != other.format_) return false; - if (!getCertificate().equals(other.getCertificate())) return false; - if (hasX509Details() != other.hasX509Details()) return false; - if (hasX509Details()) { - if (!getX509Details().equals(other.getX509Details())) return false; - } - if (!getUnknownFields().equals(other.getUnknownFields())) return false; - return true; - } - - @java.lang.Override - public int hashCode() { - if (memoizedHashCode != 0) { - return memoizedHashCode; - } - int hash = 41; - hash = (19 * hash) + getDescriptor().hashCode(); - hash = (37 * hash) + FORMAT_FIELD_NUMBER; - hash = (53 * hash) + format_; - hash = (37 * hash) + CERTIFICATE_FIELD_NUMBER; - hash = (53 * hash) + getCertificate().hashCode(); - if (hasX509Details()) { - hash = (37 * hash) + X509_DETAILS_FIELD_NUMBER; - hash = (53 * hash) + getX509Details().hashCode(); - } - hash = (29 * hash) + getUnknownFields().hashCode(); - memoizedHashCode = hash; - return hash; - } - - public static com.google.cloud.iot.v1.PublicKeyCertificate parseFrom(java.nio.ByteBuffer data) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); - } - - public static com.google.cloud.iot.v1.PublicKeyCertificate parseFrom( - java.nio.ByteBuffer data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); - } - - public static com.google.cloud.iot.v1.PublicKeyCertificate parseFrom( - com.google.protobuf.ByteString data) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); - } - - public static com.google.cloud.iot.v1.PublicKeyCertificate parseFrom( - com.google.protobuf.ByteString data, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); - } - - public static com.google.cloud.iot.v1.PublicKeyCertificate parseFrom(byte[] data) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); - } - - public static com.google.cloud.iot.v1.PublicKeyCertificate parseFrom( - byte[] data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); - } - - public static com.google.cloud.iot.v1.PublicKeyCertificate parseFrom(java.io.InputStream input) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input); - } - - public static com.google.cloud.iot.v1.PublicKeyCertificate parseFrom( - java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3.parseWithIOException( - PARSER, input, extensionRegistry); - } - - public static com.google.cloud.iot.v1.PublicKeyCertificate parseDelimitedFrom( - java.io.InputStream input) throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3.parseDelimitedWithIOException(PARSER, input); - } - - public static com.google.cloud.iot.v1.PublicKeyCertificate parseDelimitedFrom( - java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3.parseDelimitedWithIOException( - PARSER, input, extensionRegistry); - } - - public static com.google.cloud.iot.v1.PublicKeyCertificate parseFrom( - com.google.protobuf.CodedInputStream input) throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input); - } - - public static com.google.cloud.iot.v1.PublicKeyCertificate parseFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3.parseWithIOException( - PARSER, input, extensionRegistry); - } - - @java.lang.Override - public Builder newBuilderForType() { - return newBuilder(); - } - - public static Builder newBuilder() { - return DEFAULT_INSTANCE.toBuilder(); - } - - public static Builder newBuilder(com.google.cloud.iot.v1.PublicKeyCertificate prototype) { - return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); - } - - @java.lang.Override - public Builder toBuilder() { - return this == DEFAULT_INSTANCE ? new Builder() : new Builder().mergeFrom(this); - } - - @java.lang.Override - protected Builder newBuilderForType(com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { - Builder builder = new Builder(parent); - return builder; - } - /** - * - * - *
-   * A public key certificate format and data.
-   * 
- * - * Protobuf type {@code google.cloud.iot.v1.PublicKeyCertificate} - */ - public static final class Builder extends com.google.protobuf.GeneratedMessageV3.Builder - implements - // @@protoc_insertion_point(builder_implements:google.cloud.iot.v1.PublicKeyCertificate) - com.google.cloud.iot.v1.PublicKeyCertificateOrBuilder { - public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { - return com.google.cloud.iot.v1.ResourcesProto - .internal_static_google_cloud_iot_v1_PublicKeyCertificate_descriptor; - } - - @java.lang.Override - protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable - internalGetFieldAccessorTable() { - return com.google.cloud.iot.v1.ResourcesProto - .internal_static_google_cloud_iot_v1_PublicKeyCertificate_fieldAccessorTable - .ensureFieldAccessorsInitialized( - com.google.cloud.iot.v1.PublicKeyCertificate.class, - com.google.cloud.iot.v1.PublicKeyCertificate.Builder.class); - } - - // Construct using com.google.cloud.iot.v1.PublicKeyCertificate.newBuilder() - private Builder() {} - - private Builder(com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { - super(parent); - } - - @java.lang.Override - public Builder clear() { - super.clear(); - format_ = 0; - - certificate_ = ""; - - if (x509DetailsBuilder_ == null) { - x509Details_ = null; - } else { - x509Details_ = null; - x509DetailsBuilder_ = null; - } - return this; - } - - @java.lang.Override - public com.google.protobuf.Descriptors.Descriptor getDescriptorForType() { - return com.google.cloud.iot.v1.ResourcesProto - .internal_static_google_cloud_iot_v1_PublicKeyCertificate_descriptor; - } - - @java.lang.Override - public com.google.cloud.iot.v1.PublicKeyCertificate getDefaultInstanceForType() { - return com.google.cloud.iot.v1.PublicKeyCertificate.getDefaultInstance(); - } - - @java.lang.Override - public com.google.cloud.iot.v1.PublicKeyCertificate build() { - com.google.cloud.iot.v1.PublicKeyCertificate result = buildPartial(); - if (!result.isInitialized()) { - throw newUninitializedMessageException(result); - } - return result; - } - - @java.lang.Override - public com.google.cloud.iot.v1.PublicKeyCertificate buildPartial() { - com.google.cloud.iot.v1.PublicKeyCertificate result = - new com.google.cloud.iot.v1.PublicKeyCertificate(this); - result.format_ = format_; - result.certificate_ = certificate_; - if (x509DetailsBuilder_ == null) { - result.x509Details_ = x509Details_; - } else { - result.x509Details_ = x509DetailsBuilder_.build(); - } - onBuilt(); - return result; - } - - @java.lang.Override - public Builder clone() { - return super.clone(); - } - - @java.lang.Override - public Builder setField( - com.google.protobuf.Descriptors.FieldDescriptor field, java.lang.Object value) { - return super.setField(field, value); - } - - @java.lang.Override - public Builder clearField(com.google.protobuf.Descriptors.FieldDescriptor field) { - return super.clearField(field); - } - - @java.lang.Override - public Builder clearOneof(com.google.protobuf.Descriptors.OneofDescriptor oneof) { - return super.clearOneof(oneof); - } - - @java.lang.Override - public Builder setRepeatedField( - com.google.protobuf.Descriptors.FieldDescriptor field, int index, java.lang.Object value) { - return super.setRepeatedField(field, index, value); - } - - @java.lang.Override - public Builder addRepeatedField( - com.google.protobuf.Descriptors.FieldDescriptor field, java.lang.Object value) { - return super.addRepeatedField(field, value); - } - - @java.lang.Override - public Builder mergeFrom(com.google.protobuf.Message other) { - if (other instanceof com.google.cloud.iot.v1.PublicKeyCertificate) { - return mergeFrom((com.google.cloud.iot.v1.PublicKeyCertificate) other); - } else { - super.mergeFrom(other); - return this; - } - } - - public Builder mergeFrom(com.google.cloud.iot.v1.PublicKeyCertificate other) { - if (other == com.google.cloud.iot.v1.PublicKeyCertificate.getDefaultInstance()) return this; - if (other.format_ != 0) { - setFormatValue(other.getFormatValue()); - } - if (!other.getCertificate().isEmpty()) { - certificate_ = other.certificate_; - onChanged(); - } - if (other.hasX509Details()) { - mergeX509Details(other.getX509Details()); - } - this.mergeUnknownFields(other.getUnknownFields()); - onChanged(); - return this; - } - - @java.lang.Override - public final boolean isInitialized() { - return true; - } - - @java.lang.Override - public Builder mergeFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - if (extensionRegistry == null) { - throw new java.lang.NullPointerException(); - } - try { - boolean done = false; - while (!done) { - int tag = input.readTag(); - switch (tag) { - case 0: - done = true; - break; - case 8: - { - format_ = input.readEnum(); - - break; - } // case 8 - case 18: - { - certificate_ = input.readStringRequireUtf8(); - - break; - } // case 18 - case 26: - { - input.readMessage(getX509DetailsFieldBuilder().getBuilder(), extensionRegistry); - - break; - } // case 26 - default: - { - if (!super.parseUnknownField(input, extensionRegistry, tag)) { - done = true; // was an endgroup tag - } - break; - } // default: - } // switch (tag) - } // while (!done) - } catch (com.google.protobuf.InvalidProtocolBufferException e) { - throw e.unwrapIOException(); - } finally { - onChanged(); - } // finally - return this; - } - - private int format_ = 0; - /** - * - * - *
-     * The certificate format.
-     * 
- * - * .google.cloud.iot.v1.PublicKeyCertificateFormat format = 1; - * - * @return The enum numeric value on the wire for format. - */ - @java.lang.Override - public int getFormatValue() { - return format_; - } - /** - * - * - *
-     * The certificate format.
-     * 
- * - * .google.cloud.iot.v1.PublicKeyCertificateFormat format = 1; - * - * @param value The enum numeric value on the wire for format to set. - * @return This builder for chaining. - */ - public Builder setFormatValue(int value) { - - format_ = value; - onChanged(); - return this; - } - /** - * - * - *
-     * The certificate format.
-     * 
- * - * .google.cloud.iot.v1.PublicKeyCertificateFormat format = 1; - * - * @return The format. - */ - @java.lang.Override - public com.google.cloud.iot.v1.PublicKeyCertificateFormat getFormat() { - @SuppressWarnings("deprecation") - com.google.cloud.iot.v1.PublicKeyCertificateFormat result = - com.google.cloud.iot.v1.PublicKeyCertificateFormat.valueOf(format_); - return result == null - ? com.google.cloud.iot.v1.PublicKeyCertificateFormat.UNRECOGNIZED - : result; - } - /** - * - * - *
-     * The certificate format.
-     * 
- * - * .google.cloud.iot.v1.PublicKeyCertificateFormat format = 1; - * - * @param value The format to set. - * @return This builder for chaining. - */ - public Builder setFormat(com.google.cloud.iot.v1.PublicKeyCertificateFormat value) { - if (value == null) { - throw new NullPointerException(); - } - - format_ = value.getNumber(); - onChanged(); - return this; - } - /** - * - * - *
-     * The certificate format.
-     * 
- * - * .google.cloud.iot.v1.PublicKeyCertificateFormat format = 1; - * - * @return This builder for chaining. - */ - public Builder clearFormat() { - - format_ = 0; - onChanged(); - return this; - } - - private java.lang.Object certificate_ = ""; - /** - * - * - *
-     * The certificate data.
-     * 
- * - * string certificate = 2; - * - * @return The certificate. - */ - public java.lang.String getCertificate() { - java.lang.Object ref = certificate_; - if (!(ref instanceof java.lang.String)) { - com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; - java.lang.String s = bs.toStringUtf8(); - certificate_ = s; - return s; - } else { - return (java.lang.String) ref; - } - } - /** - * - * - *
-     * The certificate data.
-     * 
- * - * string certificate = 2; - * - * @return The bytes for certificate. - */ - public com.google.protobuf.ByteString getCertificateBytes() { - java.lang.Object ref = certificate_; - if (ref instanceof String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); - certificate_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - /** - * - * - *
-     * The certificate data.
-     * 
- * - * string certificate = 2; - * - * @param value The certificate to set. - * @return This builder for chaining. - */ - public Builder setCertificate(java.lang.String value) { - if (value == null) { - throw new NullPointerException(); - } - - certificate_ = value; - onChanged(); - return this; - } - /** - * - * - *
-     * The certificate data.
-     * 
- * - * string certificate = 2; - * - * @return This builder for chaining. - */ - public Builder clearCertificate() { - - certificate_ = getDefaultInstance().getCertificate(); - onChanged(); - return this; - } - /** - * - * - *
-     * The certificate data.
-     * 
- * - * string certificate = 2; - * - * @param value The bytes for certificate to set. - * @return This builder for chaining. - */ - public Builder setCertificateBytes(com.google.protobuf.ByteString value) { - if (value == null) { - throw new NullPointerException(); - } - checkByteStringIsUtf8(value); - - certificate_ = value; - onChanged(); - return this; - } - - private com.google.cloud.iot.v1.X509CertificateDetails x509Details_; - private com.google.protobuf.SingleFieldBuilderV3< - com.google.cloud.iot.v1.X509CertificateDetails, - com.google.cloud.iot.v1.X509CertificateDetails.Builder, - com.google.cloud.iot.v1.X509CertificateDetailsOrBuilder> - x509DetailsBuilder_; - /** - * - * - *
-     * [Output only] The certificate details. Used only for X.509 certificates.
-     * 
- * - * .google.cloud.iot.v1.X509CertificateDetails x509_details = 3; - * - * @return Whether the x509Details field is set. - */ - public boolean hasX509Details() { - return x509DetailsBuilder_ != null || x509Details_ != null; - } - /** - * - * - *
-     * [Output only] The certificate details. Used only for X.509 certificates.
-     * 
- * - * .google.cloud.iot.v1.X509CertificateDetails x509_details = 3; - * - * @return The x509Details. - */ - public com.google.cloud.iot.v1.X509CertificateDetails getX509Details() { - if (x509DetailsBuilder_ == null) { - return x509Details_ == null - ? com.google.cloud.iot.v1.X509CertificateDetails.getDefaultInstance() - : x509Details_; - } else { - return x509DetailsBuilder_.getMessage(); - } - } - /** - * - * - *
-     * [Output only] The certificate details. Used only for X.509 certificates.
-     * 
- * - * .google.cloud.iot.v1.X509CertificateDetails x509_details = 3; - */ - public Builder setX509Details(com.google.cloud.iot.v1.X509CertificateDetails value) { - if (x509DetailsBuilder_ == null) { - if (value == null) { - throw new NullPointerException(); - } - x509Details_ = value; - onChanged(); - } else { - x509DetailsBuilder_.setMessage(value); - } - - return this; - } - /** - * - * - *
-     * [Output only] The certificate details. Used only for X.509 certificates.
-     * 
- * - * .google.cloud.iot.v1.X509CertificateDetails x509_details = 3; - */ - public Builder setX509Details( - com.google.cloud.iot.v1.X509CertificateDetails.Builder builderForValue) { - if (x509DetailsBuilder_ == null) { - x509Details_ = builderForValue.build(); - onChanged(); - } else { - x509DetailsBuilder_.setMessage(builderForValue.build()); - } - - return this; - } - /** - * - * - *
-     * [Output only] The certificate details. Used only for X.509 certificates.
-     * 
- * - * .google.cloud.iot.v1.X509CertificateDetails x509_details = 3; - */ - public Builder mergeX509Details(com.google.cloud.iot.v1.X509CertificateDetails value) { - if (x509DetailsBuilder_ == null) { - if (x509Details_ != null) { - x509Details_ = - com.google.cloud.iot.v1.X509CertificateDetails.newBuilder(x509Details_) - .mergeFrom(value) - .buildPartial(); - } else { - x509Details_ = value; - } - onChanged(); - } else { - x509DetailsBuilder_.mergeFrom(value); - } - - return this; - } - /** - * - * - *
-     * [Output only] The certificate details. Used only for X.509 certificates.
-     * 
- * - * .google.cloud.iot.v1.X509CertificateDetails x509_details = 3; - */ - public Builder clearX509Details() { - if (x509DetailsBuilder_ == null) { - x509Details_ = null; - onChanged(); - } else { - x509Details_ = null; - x509DetailsBuilder_ = null; - } - - return this; - } - /** - * - * - *
-     * [Output only] The certificate details. Used only for X.509 certificates.
-     * 
- * - * .google.cloud.iot.v1.X509CertificateDetails x509_details = 3; - */ - public com.google.cloud.iot.v1.X509CertificateDetails.Builder getX509DetailsBuilder() { - - onChanged(); - return getX509DetailsFieldBuilder().getBuilder(); - } - /** - * - * - *
-     * [Output only] The certificate details. Used only for X.509 certificates.
-     * 
- * - * .google.cloud.iot.v1.X509CertificateDetails x509_details = 3; - */ - public com.google.cloud.iot.v1.X509CertificateDetailsOrBuilder getX509DetailsOrBuilder() { - if (x509DetailsBuilder_ != null) { - return x509DetailsBuilder_.getMessageOrBuilder(); - } else { - return x509Details_ == null - ? com.google.cloud.iot.v1.X509CertificateDetails.getDefaultInstance() - : x509Details_; - } - } - /** - * - * - *
-     * [Output only] The certificate details. Used only for X.509 certificates.
-     * 
- * - * .google.cloud.iot.v1.X509CertificateDetails x509_details = 3; - */ - private com.google.protobuf.SingleFieldBuilderV3< - com.google.cloud.iot.v1.X509CertificateDetails, - com.google.cloud.iot.v1.X509CertificateDetails.Builder, - com.google.cloud.iot.v1.X509CertificateDetailsOrBuilder> - getX509DetailsFieldBuilder() { - if (x509DetailsBuilder_ == null) { - x509DetailsBuilder_ = - new com.google.protobuf.SingleFieldBuilderV3< - com.google.cloud.iot.v1.X509CertificateDetails, - com.google.cloud.iot.v1.X509CertificateDetails.Builder, - com.google.cloud.iot.v1.X509CertificateDetailsOrBuilder>( - getX509Details(), getParentForChildren(), isClean()); - x509Details_ = null; - } - return x509DetailsBuilder_; - } - - @java.lang.Override - public final Builder setUnknownFields(final com.google.protobuf.UnknownFieldSet unknownFields) { - return super.setUnknownFields(unknownFields); - } - - @java.lang.Override - public final Builder mergeUnknownFields( - final com.google.protobuf.UnknownFieldSet unknownFields) { - return super.mergeUnknownFields(unknownFields); - } - - // @@protoc_insertion_point(builder_scope:google.cloud.iot.v1.PublicKeyCertificate) - } - - // @@protoc_insertion_point(class_scope:google.cloud.iot.v1.PublicKeyCertificate) - private static final com.google.cloud.iot.v1.PublicKeyCertificate DEFAULT_INSTANCE; - - static { - DEFAULT_INSTANCE = new com.google.cloud.iot.v1.PublicKeyCertificate(); - } - - public static com.google.cloud.iot.v1.PublicKeyCertificate getDefaultInstance() { - return DEFAULT_INSTANCE; - } - - private static final com.google.protobuf.Parser PARSER = - new com.google.protobuf.AbstractParser() { - @java.lang.Override - public PublicKeyCertificate parsePartialFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - Builder builder = newBuilder(); - try { - builder.mergeFrom(input, extensionRegistry); - } catch (com.google.protobuf.InvalidProtocolBufferException e) { - throw e.setUnfinishedMessage(builder.buildPartial()); - } catch (com.google.protobuf.UninitializedMessageException e) { - throw e.asInvalidProtocolBufferException().setUnfinishedMessage(builder.buildPartial()); - } catch (java.io.IOException e) { - throw new com.google.protobuf.InvalidProtocolBufferException(e) - .setUnfinishedMessage(builder.buildPartial()); - } - return builder.buildPartial(); - } - }; - - public static com.google.protobuf.Parser parser() { - return PARSER; - } - - @java.lang.Override - public com.google.protobuf.Parser getParserForType() { - return PARSER; - } - - @java.lang.Override - public com.google.cloud.iot.v1.PublicKeyCertificate getDefaultInstanceForType() { - return DEFAULT_INSTANCE; - } -} diff --git a/proto-google-cloud-iot-v1/src/main/java/com/google/cloud/iot/v1/PublicKeyCertificateFormat.java b/proto-google-cloud-iot-v1/src/main/java/com/google/cloud/iot/v1/PublicKeyCertificateFormat.java deleted file mode 100644 index 2babfa94..00000000 --- a/proto-google-cloud-iot-v1/src/main/java/com/google/cloud/iot/v1/PublicKeyCertificateFormat.java +++ /dev/null @@ -1,163 +0,0 @@ -/* - * Copyright 2020 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. - */ -// Generated by the protocol buffer compiler. DO NOT EDIT! -// source: google/cloud/iot/v1/resources.proto - -package com.google.cloud.iot.v1; - -/** - * - * - *
- * The supported formats for the public key.
- * 
- * - * Protobuf enum {@code google.cloud.iot.v1.PublicKeyCertificateFormat} - */ -public enum PublicKeyCertificateFormat implements com.google.protobuf.ProtocolMessageEnum { - /** - * - * - *
-   * The format has not been specified. This is an invalid default value and
-   * must not be used.
-   * 
- * - * UNSPECIFIED_PUBLIC_KEY_CERTIFICATE_FORMAT = 0; - */ - UNSPECIFIED_PUBLIC_KEY_CERTIFICATE_FORMAT(0), - /** - * - * - *
-   * An X.509v3 certificate ([RFC5280](https://www.ietf.org/rfc/rfc5280.txt)),
-   * encoded in base64, and wrapped by `-----BEGIN CERTIFICATE-----` and
-   * `-----END CERTIFICATE-----`.
-   * 
- * - * X509_CERTIFICATE_PEM = 1; - */ - X509_CERTIFICATE_PEM(1), - UNRECOGNIZED(-1), - ; - - /** - * - * - *
-   * The format has not been specified. This is an invalid default value and
-   * must not be used.
-   * 
- * - * UNSPECIFIED_PUBLIC_KEY_CERTIFICATE_FORMAT = 0; - */ - public static final int UNSPECIFIED_PUBLIC_KEY_CERTIFICATE_FORMAT_VALUE = 0; - /** - * - * - *
-   * An X.509v3 certificate ([RFC5280](https://www.ietf.org/rfc/rfc5280.txt)),
-   * encoded in base64, and wrapped by `-----BEGIN CERTIFICATE-----` and
-   * `-----END CERTIFICATE-----`.
-   * 
- * - * X509_CERTIFICATE_PEM = 1; - */ - public static final int X509_CERTIFICATE_PEM_VALUE = 1; - - public final int getNumber() { - if (this == UNRECOGNIZED) { - throw new java.lang.IllegalArgumentException( - "Can't get the number of an unknown enum value."); - } - return value; - } - - /** - * @param value The numeric wire value of the corresponding enum entry. - * @return The enum associated with the given numeric wire value. - * @deprecated Use {@link #forNumber(int)} instead. - */ - @java.lang.Deprecated - public static PublicKeyCertificateFormat valueOf(int value) { - return forNumber(value); - } - - /** - * @param value The numeric wire value of the corresponding enum entry. - * @return The enum associated with the given numeric wire value. - */ - public static PublicKeyCertificateFormat forNumber(int value) { - switch (value) { - case 0: - return UNSPECIFIED_PUBLIC_KEY_CERTIFICATE_FORMAT; - case 1: - return X509_CERTIFICATE_PEM; - default: - return null; - } - } - - public static com.google.protobuf.Internal.EnumLiteMap - internalGetValueMap() { - return internalValueMap; - } - - private static final com.google.protobuf.Internal.EnumLiteMap - internalValueMap = - new com.google.protobuf.Internal.EnumLiteMap() { - public PublicKeyCertificateFormat findValueByNumber(int number) { - return PublicKeyCertificateFormat.forNumber(number); - } - }; - - public final com.google.protobuf.Descriptors.EnumValueDescriptor getValueDescriptor() { - if (this == UNRECOGNIZED) { - throw new java.lang.IllegalStateException( - "Can't get the descriptor of an unrecognized enum value."); - } - return getDescriptor().getValues().get(ordinal()); - } - - public final com.google.protobuf.Descriptors.EnumDescriptor getDescriptorForType() { - return getDescriptor(); - } - - public static final com.google.protobuf.Descriptors.EnumDescriptor getDescriptor() { - return com.google.cloud.iot.v1.ResourcesProto.getDescriptor().getEnumTypes().get(5); - } - - private static final PublicKeyCertificateFormat[] VALUES = values(); - - public static PublicKeyCertificateFormat valueOf( - com.google.protobuf.Descriptors.EnumValueDescriptor desc) { - if (desc.getType() != getDescriptor()) { - throw new java.lang.IllegalArgumentException("EnumValueDescriptor is not for this type."); - } - if (desc.getIndex() == -1) { - return UNRECOGNIZED; - } - return VALUES[desc.getIndex()]; - } - - private final int value; - - private PublicKeyCertificateFormat(int value) { - this.value = value; - } - - // @@protoc_insertion_point(enum_scope:google.cloud.iot.v1.PublicKeyCertificateFormat) -} diff --git a/proto-google-cloud-iot-v1/src/main/java/com/google/cloud/iot/v1/PublicKeyCertificateOrBuilder.java b/proto-google-cloud-iot-v1/src/main/java/com/google/cloud/iot/v1/PublicKeyCertificateOrBuilder.java deleted file mode 100644 index 4f0ea283..00000000 --- a/proto-google-cloud-iot-v1/src/main/java/com/google/cloud/iot/v1/PublicKeyCertificateOrBuilder.java +++ /dev/null @@ -1,110 +0,0 @@ -/* - * Copyright 2020 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. - */ -// Generated by the protocol buffer compiler. DO NOT EDIT! -// source: google/cloud/iot/v1/resources.proto - -package com.google.cloud.iot.v1; - -public interface PublicKeyCertificateOrBuilder - extends - // @@protoc_insertion_point(interface_extends:google.cloud.iot.v1.PublicKeyCertificate) - com.google.protobuf.MessageOrBuilder { - - /** - * - * - *
-   * The certificate format.
-   * 
- * - * .google.cloud.iot.v1.PublicKeyCertificateFormat format = 1; - * - * @return The enum numeric value on the wire for format. - */ - int getFormatValue(); - /** - * - * - *
-   * The certificate format.
-   * 
- * - * .google.cloud.iot.v1.PublicKeyCertificateFormat format = 1; - * - * @return The format. - */ - com.google.cloud.iot.v1.PublicKeyCertificateFormat getFormat(); - - /** - * - * - *
-   * The certificate data.
-   * 
- * - * string certificate = 2; - * - * @return The certificate. - */ - java.lang.String getCertificate(); - /** - * - * - *
-   * The certificate data.
-   * 
- * - * string certificate = 2; - * - * @return The bytes for certificate. - */ - com.google.protobuf.ByteString getCertificateBytes(); - - /** - * - * - *
-   * [Output only] The certificate details. Used only for X.509 certificates.
-   * 
- * - * .google.cloud.iot.v1.X509CertificateDetails x509_details = 3; - * - * @return Whether the x509Details field is set. - */ - boolean hasX509Details(); - /** - * - * - *
-   * [Output only] The certificate details. Used only for X.509 certificates.
-   * 
- * - * .google.cloud.iot.v1.X509CertificateDetails x509_details = 3; - * - * @return The x509Details. - */ - com.google.cloud.iot.v1.X509CertificateDetails getX509Details(); - /** - * - * - *
-   * [Output only] The certificate details. Used only for X.509 certificates.
-   * 
- * - * .google.cloud.iot.v1.X509CertificateDetails x509_details = 3; - */ - com.google.cloud.iot.v1.X509CertificateDetailsOrBuilder getX509DetailsOrBuilder(); -} diff --git a/proto-google-cloud-iot-v1/src/main/java/com/google/cloud/iot/v1/PublicKeyCredential.java b/proto-google-cloud-iot-v1/src/main/java/com/google/cloud/iot/v1/PublicKeyCredential.java deleted file mode 100644 index 708e4842..00000000 --- a/proto-google-cloud-iot-v1/src/main/java/com/google/cloud/iot/v1/PublicKeyCredential.java +++ /dev/null @@ -1,765 +0,0 @@ -/* - * Copyright 2020 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. - */ -// Generated by the protocol buffer compiler. DO NOT EDIT! -// source: google/cloud/iot/v1/resources.proto - -package com.google.cloud.iot.v1; - -/** - * - * - *
- * A public key format and data.
- * 
- * - * Protobuf type {@code google.cloud.iot.v1.PublicKeyCredential} - */ -public final class PublicKeyCredential extends com.google.protobuf.GeneratedMessageV3 - implements - // @@protoc_insertion_point(message_implements:google.cloud.iot.v1.PublicKeyCredential) - PublicKeyCredentialOrBuilder { - private static final long serialVersionUID = 0L; - // Use PublicKeyCredential.newBuilder() to construct. - private PublicKeyCredential(com.google.protobuf.GeneratedMessageV3.Builder builder) { - super(builder); - } - - private PublicKeyCredential() { - format_ = 0; - key_ = ""; - } - - @java.lang.Override - @SuppressWarnings({"unused"}) - protected java.lang.Object newInstance(UnusedPrivateParameter unused) { - return new PublicKeyCredential(); - } - - @java.lang.Override - public final com.google.protobuf.UnknownFieldSet getUnknownFields() { - return this.unknownFields; - } - - public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { - return com.google.cloud.iot.v1.ResourcesProto - .internal_static_google_cloud_iot_v1_PublicKeyCredential_descriptor; - } - - @java.lang.Override - protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable - internalGetFieldAccessorTable() { - return com.google.cloud.iot.v1.ResourcesProto - .internal_static_google_cloud_iot_v1_PublicKeyCredential_fieldAccessorTable - .ensureFieldAccessorsInitialized( - com.google.cloud.iot.v1.PublicKeyCredential.class, - com.google.cloud.iot.v1.PublicKeyCredential.Builder.class); - } - - public static final int FORMAT_FIELD_NUMBER = 1; - private int format_; - /** - * - * - *
-   * The format of the key.
-   * 
- * - * .google.cloud.iot.v1.PublicKeyFormat format = 1; - * - * @return The enum numeric value on the wire for format. - */ - @java.lang.Override - public int getFormatValue() { - return format_; - } - /** - * - * - *
-   * The format of the key.
-   * 
- * - * .google.cloud.iot.v1.PublicKeyFormat format = 1; - * - * @return The format. - */ - @java.lang.Override - public com.google.cloud.iot.v1.PublicKeyFormat getFormat() { - @SuppressWarnings("deprecation") - com.google.cloud.iot.v1.PublicKeyFormat result = - com.google.cloud.iot.v1.PublicKeyFormat.valueOf(format_); - return result == null ? com.google.cloud.iot.v1.PublicKeyFormat.UNRECOGNIZED : result; - } - - public static final int KEY_FIELD_NUMBER = 2; - private volatile java.lang.Object key_; - /** - * - * - *
-   * The key data.
-   * 
- * - * string key = 2; - * - * @return The key. - */ - @java.lang.Override - public java.lang.String getKey() { - java.lang.Object ref = key_; - if (ref instanceof java.lang.String) { - return (java.lang.String) ref; - } else { - com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; - java.lang.String s = bs.toStringUtf8(); - key_ = s; - return s; - } - } - /** - * - * - *
-   * The key data.
-   * 
- * - * string key = 2; - * - * @return The bytes for key. - */ - @java.lang.Override - public com.google.protobuf.ByteString getKeyBytes() { - java.lang.Object ref = key_; - if (ref instanceof java.lang.String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); - key_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - - private byte memoizedIsInitialized = -1; - - @java.lang.Override - public final boolean isInitialized() { - byte isInitialized = memoizedIsInitialized; - if (isInitialized == 1) return true; - if (isInitialized == 0) return false; - - memoizedIsInitialized = 1; - return true; - } - - @java.lang.Override - public void writeTo(com.google.protobuf.CodedOutputStream output) throws java.io.IOException { - if (format_ - != com.google.cloud.iot.v1.PublicKeyFormat.UNSPECIFIED_PUBLIC_KEY_FORMAT.getNumber()) { - output.writeEnum(1, format_); - } - if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(key_)) { - com.google.protobuf.GeneratedMessageV3.writeString(output, 2, key_); - } - getUnknownFields().writeTo(output); - } - - @java.lang.Override - public int getSerializedSize() { - int size = memoizedSize; - if (size != -1) return size; - - size = 0; - if (format_ - != com.google.cloud.iot.v1.PublicKeyFormat.UNSPECIFIED_PUBLIC_KEY_FORMAT.getNumber()) { - size += com.google.protobuf.CodedOutputStream.computeEnumSize(1, format_); - } - if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(key_)) { - size += com.google.protobuf.GeneratedMessageV3.computeStringSize(2, key_); - } - size += getUnknownFields().getSerializedSize(); - memoizedSize = size; - return size; - } - - @java.lang.Override - public boolean equals(final java.lang.Object obj) { - if (obj == this) { - return true; - } - if (!(obj instanceof com.google.cloud.iot.v1.PublicKeyCredential)) { - return super.equals(obj); - } - com.google.cloud.iot.v1.PublicKeyCredential other = - (com.google.cloud.iot.v1.PublicKeyCredential) obj; - - if (format_ != other.format_) return false; - if (!getKey().equals(other.getKey())) return false; - if (!getUnknownFields().equals(other.getUnknownFields())) return false; - return true; - } - - @java.lang.Override - public int hashCode() { - if (memoizedHashCode != 0) { - return memoizedHashCode; - } - int hash = 41; - hash = (19 * hash) + getDescriptor().hashCode(); - hash = (37 * hash) + FORMAT_FIELD_NUMBER; - hash = (53 * hash) + format_; - hash = (37 * hash) + KEY_FIELD_NUMBER; - hash = (53 * hash) + getKey().hashCode(); - hash = (29 * hash) + getUnknownFields().hashCode(); - memoizedHashCode = hash; - return hash; - } - - public static com.google.cloud.iot.v1.PublicKeyCredential parseFrom(java.nio.ByteBuffer data) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); - } - - public static com.google.cloud.iot.v1.PublicKeyCredential parseFrom( - java.nio.ByteBuffer data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); - } - - public static com.google.cloud.iot.v1.PublicKeyCredential parseFrom( - com.google.protobuf.ByteString data) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); - } - - public static com.google.cloud.iot.v1.PublicKeyCredential parseFrom( - com.google.protobuf.ByteString data, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); - } - - public static com.google.cloud.iot.v1.PublicKeyCredential parseFrom(byte[] data) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); - } - - public static com.google.cloud.iot.v1.PublicKeyCredential parseFrom( - byte[] data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); - } - - public static com.google.cloud.iot.v1.PublicKeyCredential parseFrom(java.io.InputStream input) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input); - } - - public static com.google.cloud.iot.v1.PublicKeyCredential parseFrom( - java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3.parseWithIOException( - PARSER, input, extensionRegistry); - } - - public static com.google.cloud.iot.v1.PublicKeyCredential parseDelimitedFrom( - java.io.InputStream input) throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3.parseDelimitedWithIOException(PARSER, input); - } - - public static com.google.cloud.iot.v1.PublicKeyCredential parseDelimitedFrom( - java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3.parseDelimitedWithIOException( - PARSER, input, extensionRegistry); - } - - public static com.google.cloud.iot.v1.PublicKeyCredential parseFrom( - com.google.protobuf.CodedInputStream input) throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input); - } - - public static com.google.cloud.iot.v1.PublicKeyCredential parseFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3.parseWithIOException( - PARSER, input, extensionRegistry); - } - - @java.lang.Override - public Builder newBuilderForType() { - return newBuilder(); - } - - public static Builder newBuilder() { - return DEFAULT_INSTANCE.toBuilder(); - } - - public static Builder newBuilder(com.google.cloud.iot.v1.PublicKeyCredential prototype) { - return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); - } - - @java.lang.Override - public Builder toBuilder() { - return this == DEFAULT_INSTANCE ? new Builder() : new Builder().mergeFrom(this); - } - - @java.lang.Override - protected Builder newBuilderForType(com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { - Builder builder = new Builder(parent); - return builder; - } - /** - * - * - *
-   * A public key format and data.
-   * 
- * - * Protobuf type {@code google.cloud.iot.v1.PublicKeyCredential} - */ - public static final class Builder extends com.google.protobuf.GeneratedMessageV3.Builder - implements - // @@protoc_insertion_point(builder_implements:google.cloud.iot.v1.PublicKeyCredential) - com.google.cloud.iot.v1.PublicKeyCredentialOrBuilder { - public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { - return com.google.cloud.iot.v1.ResourcesProto - .internal_static_google_cloud_iot_v1_PublicKeyCredential_descriptor; - } - - @java.lang.Override - protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable - internalGetFieldAccessorTable() { - return com.google.cloud.iot.v1.ResourcesProto - .internal_static_google_cloud_iot_v1_PublicKeyCredential_fieldAccessorTable - .ensureFieldAccessorsInitialized( - com.google.cloud.iot.v1.PublicKeyCredential.class, - com.google.cloud.iot.v1.PublicKeyCredential.Builder.class); - } - - // Construct using com.google.cloud.iot.v1.PublicKeyCredential.newBuilder() - private Builder() {} - - private Builder(com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { - super(parent); - } - - @java.lang.Override - public Builder clear() { - super.clear(); - format_ = 0; - - key_ = ""; - - return this; - } - - @java.lang.Override - public com.google.protobuf.Descriptors.Descriptor getDescriptorForType() { - return com.google.cloud.iot.v1.ResourcesProto - .internal_static_google_cloud_iot_v1_PublicKeyCredential_descriptor; - } - - @java.lang.Override - public com.google.cloud.iot.v1.PublicKeyCredential getDefaultInstanceForType() { - return com.google.cloud.iot.v1.PublicKeyCredential.getDefaultInstance(); - } - - @java.lang.Override - public com.google.cloud.iot.v1.PublicKeyCredential build() { - com.google.cloud.iot.v1.PublicKeyCredential result = buildPartial(); - if (!result.isInitialized()) { - throw newUninitializedMessageException(result); - } - return result; - } - - @java.lang.Override - public com.google.cloud.iot.v1.PublicKeyCredential buildPartial() { - com.google.cloud.iot.v1.PublicKeyCredential result = - new com.google.cloud.iot.v1.PublicKeyCredential(this); - result.format_ = format_; - result.key_ = key_; - onBuilt(); - return result; - } - - @java.lang.Override - public Builder clone() { - return super.clone(); - } - - @java.lang.Override - public Builder setField( - com.google.protobuf.Descriptors.FieldDescriptor field, java.lang.Object value) { - return super.setField(field, value); - } - - @java.lang.Override - public Builder clearField(com.google.protobuf.Descriptors.FieldDescriptor field) { - return super.clearField(field); - } - - @java.lang.Override - public Builder clearOneof(com.google.protobuf.Descriptors.OneofDescriptor oneof) { - return super.clearOneof(oneof); - } - - @java.lang.Override - public Builder setRepeatedField( - com.google.protobuf.Descriptors.FieldDescriptor field, int index, java.lang.Object value) { - return super.setRepeatedField(field, index, value); - } - - @java.lang.Override - public Builder addRepeatedField( - com.google.protobuf.Descriptors.FieldDescriptor field, java.lang.Object value) { - return super.addRepeatedField(field, value); - } - - @java.lang.Override - public Builder mergeFrom(com.google.protobuf.Message other) { - if (other instanceof com.google.cloud.iot.v1.PublicKeyCredential) { - return mergeFrom((com.google.cloud.iot.v1.PublicKeyCredential) other); - } else { - super.mergeFrom(other); - return this; - } - } - - public Builder mergeFrom(com.google.cloud.iot.v1.PublicKeyCredential other) { - if (other == com.google.cloud.iot.v1.PublicKeyCredential.getDefaultInstance()) return this; - if (other.format_ != 0) { - setFormatValue(other.getFormatValue()); - } - if (!other.getKey().isEmpty()) { - key_ = other.key_; - onChanged(); - } - this.mergeUnknownFields(other.getUnknownFields()); - onChanged(); - return this; - } - - @java.lang.Override - public final boolean isInitialized() { - return true; - } - - @java.lang.Override - public Builder mergeFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - if (extensionRegistry == null) { - throw new java.lang.NullPointerException(); - } - try { - boolean done = false; - while (!done) { - int tag = input.readTag(); - switch (tag) { - case 0: - done = true; - break; - case 8: - { - format_ = input.readEnum(); - - break; - } // case 8 - case 18: - { - key_ = input.readStringRequireUtf8(); - - break; - } // case 18 - default: - { - if (!super.parseUnknownField(input, extensionRegistry, tag)) { - done = true; // was an endgroup tag - } - break; - } // default: - } // switch (tag) - } // while (!done) - } catch (com.google.protobuf.InvalidProtocolBufferException e) { - throw e.unwrapIOException(); - } finally { - onChanged(); - } // finally - return this; - } - - private int format_ = 0; - /** - * - * - *
-     * The format of the key.
-     * 
- * - * .google.cloud.iot.v1.PublicKeyFormat format = 1; - * - * @return The enum numeric value on the wire for format. - */ - @java.lang.Override - public int getFormatValue() { - return format_; - } - /** - * - * - *
-     * The format of the key.
-     * 
- * - * .google.cloud.iot.v1.PublicKeyFormat format = 1; - * - * @param value The enum numeric value on the wire for format to set. - * @return This builder for chaining. - */ - public Builder setFormatValue(int value) { - - format_ = value; - onChanged(); - return this; - } - /** - * - * - *
-     * The format of the key.
-     * 
- * - * .google.cloud.iot.v1.PublicKeyFormat format = 1; - * - * @return The format. - */ - @java.lang.Override - public com.google.cloud.iot.v1.PublicKeyFormat getFormat() { - @SuppressWarnings("deprecation") - com.google.cloud.iot.v1.PublicKeyFormat result = - com.google.cloud.iot.v1.PublicKeyFormat.valueOf(format_); - return result == null ? com.google.cloud.iot.v1.PublicKeyFormat.UNRECOGNIZED : result; - } - /** - * - * - *
-     * The format of the key.
-     * 
- * - * .google.cloud.iot.v1.PublicKeyFormat format = 1; - * - * @param value The format to set. - * @return This builder for chaining. - */ - public Builder setFormat(com.google.cloud.iot.v1.PublicKeyFormat value) { - if (value == null) { - throw new NullPointerException(); - } - - format_ = value.getNumber(); - onChanged(); - return this; - } - /** - * - * - *
-     * The format of the key.
-     * 
- * - * .google.cloud.iot.v1.PublicKeyFormat format = 1; - * - * @return This builder for chaining. - */ - public Builder clearFormat() { - - format_ = 0; - onChanged(); - return this; - } - - private java.lang.Object key_ = ""; - /** - * - * - *
-     * The key data.
-     * 
- * - * string key = 2; - * - * @return The key. - */ - public java.lang.String getKey() { - java.lang.Object ref = key_; - if (!(ref instanceof java.lang.String)) { - com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; - java.lang.String s = bs.toStringUtf8(); - key_ = s; - return s; - } else { - return (java.lang.String) ref; - } - } - /** - * - * - *
-     * The key data.
-     * 
- * - * string key = 2; - * - * @return The bytes for key. - */ - public com.google.protobuf.ByteString getKeyBytes() { - java.lang.Object ref = key_; - if (ref instanceof String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); - key_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - /** - * - * - *
-     * The key data.
-     * 
- * - * string key = 2; - * - * @param value The key to set. - * @return This builder for chaining. - */ - public Builder setKey(java.lang.String value) { - if (value == null) { - throw new NullPointerException(); - } - - key_ = value; - onChanged(); - return this; - } - /** - * - * - *
-     * The key data.
-     * 
- * - * string key = 2; - * - * @return This builder for chaining. - */ - public Builder clearKey() { - - key_ = getDefaultInstance().getKey(); - onChanged(); - return this; - } - /** - * - * - *
-     * The key data.
-     * 
- * - * string key = 2; - * - * @param value The bytes for key to set. - * @return This builder for chaining. - */ - public Builder setKeyBytes(com.google.protobuf.ByteString value) { - if (value == null) { - throw new NullPointerException(); - } - checkByteStringIsUtf8(value); - - key_ = value; - onChanged(); - return this; - } - - @java.lang.Override - public final Builder setUnknownFields(final com.google.protobuf.UnknownFieldSet unknownFields) { - return super.setUnknownFields(unknownFields); - } - - @java.lang.Override - public final Builder mergeUnknownFields( - final com.google.protobuf.UnknownFieldSet unknownFields) { - return super.mergeUnknownFields(unknownFields); - } - - // @@protoc_insertion_point(builder_scope:google.cloud.iot.v1.PublicKeyCredential) - } - - // @@protoc_insertion_point(class_scope:google.cloud.iot.v1.PublicKeyCredential) - private static final com.google.cloud.iot.v1.PublicKeyCredential DEFAULT_INSTANCE; - - static { - DEFAULT_INSTANCE = new com.google.cloud.iot.v1.PublicKeyCredential(); - } - - public static com.google.cloud.iot.v1.PublicKeyCredential getDefaultInstance() { - return DEFAULT_INSTANCE; - } - - private static final com.google.protobuf.Parser PARSER = - new com.google.protobuf.AbstractParser() { - @java.lang.Override - public PublicKeyCredential parsePartialFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - Builder builder = newBuilder(); - try { - builder.mergeFrom(input, extensionRegistry); - } catch (com.google.protobuf.InvalidProtocolBufferException e) { - throw e.setUnfinishedMessage(builder.buildPartial()); - } catch (com.google.protobuf.UninitializedMessageException e) { - throw e.asInvalidProtocolBufferException().setUnfinishedMessage(builder.buildPartial()); - } catch (java.io.IOException e) { - throw new com.google.protobuf.InvalidProtocolBufferException(e) - .setUnfinishedMessage(builder.buildPartial()); - } - return builder.buildPartial(); - } - }; - - public static com.google.protobuf.Parser parser() { - return PARSER; - } - - @java.lang.Override - public com.google.protobuf.Parser getParserForType() { - return PARSER; - } - - @java.lang.Override - public com.google.cloud.iot.v1.PublicKeyCredential getDefaultInstanceForType() { - return DEFAULT_INSTANCE; - } -} diff --git a/proto-google-cloud-iot-v1/src/main/java/com/google/cloud/iot/v1/PublicKeyCredentialOrBuilder.java b/proto-google-cloud-iot-v1/src/main/java/com/google/cloud/iot/v1/PublicKeyCredentialOrBuilder.java deleted file mode 100644 index 948cd7c7..00000000 --- a/proto-google-cloud-iot-v1/src/main/java/com/google/cloud/iot/v1/PublicKeyCredentialOrBuilder.java +++ /dev/null @@ -1,75 +0,0 @@ -/* - * Copyright 2020 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. - */ -// Generated by the protocol buffer compiler. DO NOT EDIT! -// source: google/cloud/iot/v1/resources.proto - -package com.google.cloud.iot.v1; - -public interface PublicKeyCredentialOrBuilder - extends - // @@protoc_insertion_point(interface_extends:google.cloud.iot.v1.PublicKeyCredential) - com.google.protobuf.MessageOrBuilder { - - /** - * - * - *
-   * The format of the key.
-   * 
- * - * .google.cloud.iot.v1.PublicKeyFormat format = 1; - * - * @return The enum numeric value on the wire for format. - */ - int getFormatValue(); - /** - * - * - *
-   * The format of the key.
-   * 
- * - * .google.cloud.iot.v1.PublicKeyFormat format = 1; - * - * @return The format. - */ - com.google.cloud.iot.v1.PublicKeyFormat getFormat(); - - /** - * - * - *
-   * The key data.
-   * 
- * - * string key = 2; - * - * @return The key. - */ - java.lang.String getKey(); - /** - * - * - *
-   * The key data.
-   * 
- * - * string key = 2; - * - * @return The bytes for key. - */ - com.google.protobuf.ByteString getKeyBytes(); -} diff --git a/proto-google-cloud-iot-v1/src/main/java/com/google/cloud/iot/v1/PublicKeyFormat.java b/proto-google-cloud-iot-v1/src/main/java/com/google/cloud/iot/v1/PublicKeyFormat.java deleted file mode 100644 index 0b7315b6..00000000 --- a/proto-google-cloud-iot-v1/src/main/java/com/google/cloud/iot/v1/PublicKeyFormat.java +++ /dev/null @@ -1,244 +0,0 @@ -/* - * Copyright 2020 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. - */ -// Generated by the protocol buffer compiler. DO NOT EDIT! -// source: google/cloud/iot/v1/resources.proto - -package com.google.cloud.iot.v1; - -/** - * - * - *
- * The supported formats for the public key.
- * 
- * - * Protobuf enum {@code google.cloud.iot.v1.PublicKeyFormat} - */ -public enum PublicKeyFormat implements com.google.protobuf.ProtocolMessageEnum { - /** - * - * - *
-   * The format has not been specified. This is an invalid default value and
-   * must not be used.
-   * 
- * - * UNSPECIFIED_PUBLIC_KEY_FORMAT = 0; - */ - UNSPECIFIED_PUBLIC_KEY_FORMAT(0), - /** - * - * - *
-   * An RSA public key encoded in base64, and wrapped by
-   * `-----BEGIN PUBLIC KEY-----` and `-----END PUBLIC KEY-----`. This can be
-   * used to verify `RS256` signatures in JWT tokens ([RFC7518](
-   * https://www.ietf.org/rfc/rfc7518.txt)).
-   * 
- * - * RSA_PEM = 3; - */ - RSA_PEM(3), - /** - * - * - *
-   * As RSA_PEM, but wrapped in an X.509v3 certificate ([RFC5280](
-   * https://www.ietf.org/rfc/rfc5280.txt)), encoded in base64, and wrapped by
-   * `-----BEGIN CERTIFICATE-----` and `-----END CERTIFICATE-----`.
-   * 
- * - * RSA_X509_PEM = 1; - */ - RSA_X509_PEM(1), - /** - * - * - *
-   * Public key for the ECDSA algorithm using P-256 and SHA-256, encoded in
-   * base64, and wrapped by `-----BEGIN PUBLIC KEY-----` and `-----END
-   * PUBLIC KEY-----`. This can be used to verify JWT tokens with the `ES256`
-   * algorithm ([RFC7518](https://www.ietf.org/rfc/rfc7518.txt)). This curve is
-   * defined in [OpenSSL](https://www.openssl.org/) as the `prime256v1` curve.
-   * 
- * - * ES256_PEM = 2; - */ - ES256_PEM(2), - /** - * - * - *
-   * As ES256_PEM, but wrapped in an X.509v3 certificate ([RFC5280](
-   * https://www.ietf.org/rfc/rfc5280.txt)), encoded in base64, and wrapped by
-   * `-----BEGIN CERTIFICATE-----` and `-----END CERTIFICATE-----`.
-   * 
- * - * ES256_X509_PEM = 4; - */ - ES256_X509_PEM(4), - UNRECOGNIZED(-1), - ; - - /** - * - * - *
-   * The format has not been specified. This is an invalid default value and
-   * must not be used.
-   * 
- * - * UNSPECIFIED_PUBLIC_KEY_FORMAT = 0; - */ - public static final int UNSPECIFIED_PUBLIC_KEY_FORMAT_VALUE = 0; - /** - * - * - *
-   * An RSA public key encoded in base64, and wrapped by
-   * `-----BEGIN PUBLIC KEY-----` and `-----END PUBLIC KEY-----`. This can be
-   * used to verify `RS256` signatures in JWT tokens ([RFC7518](
-   * https://www.ietf.org/rfc/rfc7518.txt)).
-   * 
- * - * RSA_PEM = 3; - */ - public static final int RSA_PEM_VALUE = 3; - /** - * - * - *
-   * As RSA_PEM, but wrapped in an X.509v3 certificate ([RFC5280](
-   * https://www.ietf.org/rfc/rfc5280.txt)), encoded in base64, and wrapped by
-   * `-----BEGIN CERTIFICATE-----` and `-----END CERTIFICATE-----`.
-   * 
- * - * RSA_X509_PEM = 1; - */ - public static final int RSA_X509_PEM_VALUE = 1; - /** - * - * - *
-   * Public key for the ECDSA algorithm using P-256 and SHA-256, encoded in
-   * base64, and wrapped by `-----BEGIN PUBLIC KEY-----` and `-----END
-   * PUBLIC KEY-----`. This can be used to verify JWT tokens with the `ES256`
-   * algorithm ([RFC7518](https://www.ietf.org/rfc/rfc7518.txt)). This curve is
-   * defined in [OpenSSL](https://www.openssl.org/) as the `prime256v1` curve.
-   * 
- * - * ES256_PEM = 2; - */ - public static final int ES256_PEM_VALUE = 2; - /** - * - * - *
-   * As ES256_PEM, but wrapped in an X.509v3 certificate ([RFC5280](
-   * https://www.ietf.org/rfc/rfc5280.txt)), encoded in base64, and wrapped by
-   * `-----BEGIN CERTIFICATE-----` and `-----END CERTIFICATE-----`.
-   * 
- * - * ES256_X509_PEM = 4; - */ - public static final int ES256_X509_PEM_VALUE = 4; - - public final int getNumber() { - if (this == UNRECOGNIZED) { - throw new java.lang.IllegalArgumentException( - "Can't get the number of an unknown enum value."); - } - return value; - } - - /** - * @param value The numeric wire value of the corresponding enum entry. - * @return The enum associated with the given numeric wire value. - * @deprecated Use {@link #forNumber(int)} instead. - */ - @java.lang.Deprecated - public static PublicKeyFormat valueOf(int value) { - return forNumber(value); - } - - /** - * @param value The numeric wire value of the corresponding enum entry. - * @return The enum associated with the given numeric wire value. - */ - public static PublicKeyFormat forNumber(int value) { - switch (value) { - case 0: - return UNSPECIFIED_PUBLIC_KEY_FORMAT; - case 3: - return RSA_PEM; - case 1: - return RSA_X509_PEM; - case 2: - return ES256_PEM; - case 4: - return ES256_X509_PEM; - default: - return null; - } - } - - public static com.google.protobuf.Internal.EnumLiteMap internalGetValueMap() { - return internalValueMap; - } - - private static final com.google.protobuf.Internal.EnumLiteMap internalValueMap = - new com.google.protobuf.Internal.EnumLiteMap() { - public PublicKeyFormat findValueByNumber(int number) { - return PublicKeyFormat.forNumber(number); - } - }; - - public final com.google.protobuf.Descriptors.EnumValueDescriptor getValueDescriptor() { - if (this == UNRECOGNIZED) { - throw new java.lang.IllegalStateException( - "Can't get the descriptor of an unrecognized enum value."); - } - return getDescriptor().getValues().get(ordinal()); - } - - public final com.google.protobuf.Descriptors.EnumDescriptor getDescriptorForType() { - return getDescriptor(); - } - - public static final com.google.protobuf.Descriptors.EnumDescriptor getDescriptor() { - return com.google.cloud.iot.v1.ResourcesProto.getDescriptor().getEnumTypes().get(6); - } - - private static final PublicKeyFormat[] VALUES = values(); - - public static PublicKeyFormat valueOf(com.google.protobuf.Descriptors.EnumValueDescriptor desc) { - if (desc.getType() != getDescriptor()) { - throw new java.lang.IllegalArgumentException("EnumValueDescriptor is not for this type."); - } - if (desc.getIndex() == -1) { - return UNRECOGNIZED; - } - return VALUES[desc.getIndex()]; - } - - private final int value; - - private PublicKeyFormat(int value) { - this.value = value; - } - - // @@protoc_insertion_point(enum_scope:google.cloud.iot.v1.PublicKeyFormat) -} diff --git a/proto-google-cloud-iot-v1/src/main/java/com/google/cloud/iot/v1/RegistryCredential.java b/proto-google-cloud-iot-v1/src/main/java/com/google/cloud/iot/v1/RegistryCredential.java deleted file mode 100644 index bc019c16..00000000 --- a/proto-google-cloud-iot-v1/src/main/java/com/google/cloud/iot/v1/RegistryCredential.java +++ /dev/null @@ -1,810 +0,0 @@ -/* - * Copyright 2020 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. - */ -// Generated by the protocol buffer compiler. DO NOT EDIT! -// source: google/cloud/iot/v1/resources.proto - -package com.google.cloud.iot.v1; - -/** - * - * - *
- * A server-stored registry credential used to validate device credentials.
- * 
- * - * Protobuf type {@code google.cloud.iot.v1.RegistryCredential} - */ -public final class RegistryCredential extends com.google.protobuf.GeneratedMessageV3 - implements - // @@protoc_insertion_point(message_implements:google.cloud.iot.v1.RegistryCredential) - RegistryCredentialOrBuilder { - private static final long serialVersionUID = 0L; - // Use RegistryCredential.newBuilder() to construct. - private RegistryCredential(com.google.protobuf.GeneratedMessageV3.Builder builder) { - super(builder); - } - - private RegistryCredential() {} - - @java.lang.Override - @SuppressWarnings({"unused"}) - protected java.lang.Object newInstance(UnusedPrivateParameter unused) { - return new RegistryCredential(); - } - - @java.lang.Override - public final com.google.protobuf.UnknownFieldSet getUnknownFields() { - return this.unknownFields; - } - - public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { - return com.google.cloud.iot.v1.ResourcesProto - .internal_static_google_cloud_iot_v1_RegistryCredential_descriptor; - } - - @java.lang.Override - protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable - internalGetFieldAccessorTable() { - return com.google.cloud.iot.v1.ResourcesProto - .internal_static_google_cloud_iot_v1_RegistryCredential_fieldAccessorTable - .ensureFieldAccessorsInitialized( - com.google.cloud.iot.v1.RegistryCredential.class, - com.google.cloud.iot.v1.RegistryCredential.Builder.class); - } - - private int credentialCase_ = 0; - private java.lang.Object credential_; - - public enum CredentialCase - implements - com.google.protobuf.Internal.EnumLite, - com.google.protobuf.AbstractMessage.InternalOneOfEnum { - PUBLIC_KEY_CERTIFICATE(1), - CREDENTIAL_NOT_SET(0); - private final int value; - - private CredentialCase(int value) { - this.value = value; - } - /** - * @param value The number of the enum to look for. - * @return The enum associated with the given number. - * @deprecated Use {@link #forNumber(int)} instead. - */ - @java.lang.Deprecated - public static CredentialCase valueOf(int value) { - return forNumber(value); - } - - public static CredentialCase forNumber(int value) { - switch (value) { - case 1: - return PUBLIC_KEY_CERTIFICATE; - case 0: - return CREDENTIAL_NOT_SET; - default: - return null; - } - } - - public int getNumber() { - return this.value; - } - }; - - public CredentialCase getCredentialCase() { - return CredentialCase.forNumber(credentialCase_); - } - - public static final int PUBLIC_KEY_CERTIFICATE_FIELD_NUMBER = 1; - /** - * - * - *
-   * A public key certificate used to verify the device credentials.
-   * 
- * - * .google.cloud.iot.v1.PublicKeyCertificate public_key_certificate = 1; - * - * @return Whether the publicKeyCertificate field is set. - */ - @java.lang.Override - public boolean hasPublicKeyCertificate() { - return credentialCase_ == 1; - } - /** - * - * - *
-   * A public key certificate used to verify the device credentials.
-   * 
- * - * .google.cloud.iot.v1.PublicKeyCertificate public_key_certificate = 1; - * - * @return The publicKeyCertificate. - */ - @java.lang.Override - public com.google.cloud.iot.v1.PublicKeyCertificate getPublicKeyCertificate() { - if (credentialCase_ == 1) { - return (com.google.cloud.iot.v1.PublicKeyCertificate) credential_; - } - return com.google.cloud.iot.v1.PublicKeyCertificate.getDefaultInstance(); - } - /** - * - * - *
-   * A public key certificate used to verify the device credentials.
-   * 
- * - * .google.cloud.iot.v1.PublicKeyCertificate public_key_certificate = 1; - */ - @java.lang.Override - public com.google.cloud.iot.v1.PublicKeyCertificateOrBuilder getPublicKeyCertificateOrBuilder() { - if (credentialCase_ == 1) { - return (com.google.cloud.iot.v1.PublicKeyCertificate) credential_; - } - return com.google.cloud.iot.v1.PublicKeyCertificate.getDefaultInstance(); - } - - private byte memoizedIsInitialized = -1; - - @java.lang.Override - public final boolean isInitialized() { - byte isInitialized = memoizedIsInitialized; - if (isInitialized == 1) return true; - if (isInitialized == 0) return false; - - memoizedIsInitialized = 1; - return true; - } - - @java.lang.Override - public void writeTo(com.google.protobuf.CodedOutputStream output) throws java.io.IOException { - if (credentialCase_ == 1) { - output.writeMessage(1, (com.google.cloud.iot.v1.PublicKeyCertificate) credential_); - } - getUnknownFields().writeTo(output); - } - - @java.lang.Override - public int getSerializedSize() { - int size = memoizedSize; - if (size != -1) return size; - - size = 0; - if (credentialCase_ == 1) { - size += - com.google.protobuf.CodedOutputStream.computeMessageSize( - 1, (com.google.cloud.iot.v1.PublicKeyCertificate) credential_); - } - size += getUnknownFields().getSerializedSize(); - memoizedSize = size; - return size; - } - - @java.lang.Override - public boolean equals(final java.lang.Object obj) { - if (obj == this) { - return true; - } - if (!(obj instanceof com.google.cloud.iot.v1.RegistryCredential)) { - return super.equals(obj); - } - com.google.cloud.iot.v1.RegistryCredential other = - (com.google.cloud.iot.v1.RegistryCredential) obj; - - if (!getCredentialCase().equals(other.getCredentialCase())) return false; - switch (credentialCase_) { - case 1: - if (!getPublicKeyCertificate().equals(other.getPublicKeyCertificate())) return false; - break; - case 0: - default: - } - if (!getUnknownFields().equals(other.getUnknownFields())) return false; - return true; - } - - @java.lang.Override - public int hashCode() { - if (memoizedHashCode != 0) { - return memoizedHashCode; - } - int hash = 41; - hash = (19 * hash) + getDescriptor().hashCode(); - switch (credentialCase_) { - case 1: - hash = (37 * hash) + PUBLIC_KEY_CERTIFICATE_FIELD_NUMBER; - hash = (53 * hash) + getPublicKeyCertificate().hashCode(); - break; - case 0: - default: - } - hash = (29 * hash) + getUnknownFields().hashCode(); - memoizedHashCode = hash; - return hash; - } - - public static com.google.cloud.iot.v1.RegistryCredential parseFrom(java.nio.ByteBuffer data) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); - } - - public static com.google.cloud.iot.v1.RegistryCredential parseFrom( - java.nio.ByteBuffer data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); - } - - public static com.google.cloud.iot.v1.RegistryCredential parseFrom( - com.google.protobuf.ByteString data) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); - } - - public static com.google.cloud.iot.v1.RegistryCredential parseFrom( - com.google.protobuf.ByteString data, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); - } - - public static com.google.cloud.iot.v1.RegistryCredential parseFrom(byte[] data) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); - } - - public static com.google.cloud.iot.v1.RegistryCredential parseFrom( - byte[] data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); - } - - public static com.google.cloud.iot.v1.RegistryCredential parseFrom(java.io.InputStream input) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input); - } - - public static com.google.cloud.iot.v1.RegistryCredential parseFrom( - java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3.parseWithIOException( - PARSER, input, extensionRegistry); - } - - public static com.google.cloud.iot.v1.RegistryCredential parseDelimitedFrom( - java.io.InputStream input) throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3.parseDelimitedWithIOException(PARSER, input); - } - - public static com.google.cloud.iot.v1.RegistryCredential parseDelimitedFrom( - java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3.parseDelimitedWithIOException( - PARSER, input, extensionRegistry); - } - - public static com.google.cloud.iot.v1.RegistryCredential parseFrom( - com.google.protobuf.CodedInputStream input) throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input); - } - - public static com.google.cloud.iot.v1.RegistryCredential parseFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3.parseWithIOException( - PARSER, input, extensionRegistry); - } - - @java.lang.Override - public Builder newBuilderForType() { - return newBuilder(); - } - - public static Builder newBuilder() { - return DEFAULT_INSTANCE.toBuilder(); - } - - public static Builder newBuilder(com.google.cloud.iot.v1.RegistryCredential prototype) { - return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); - } - - @java.lang.Override - public Builder toBuilder() { - return this == DEFAULT_INSTANCE ? new Builder() : new Builder().mergeFrom(this); - } - - @java.lang.Override - protected Builder newBuilderForType(com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { - Builder builder = new Builder(parent); - return builder; - } - /** - * - * - *
-   * A server-stored registry credential used to validate device credentials.
-   * 
- * - * Protobuf type {@code google.cloud.iot.v1.RegistryCredential} - */ - public static final class Builder extends com.google.protobuf.GeneratedMessageV3.Builder - implements - // @@protoc_insertion_point(builder_implements:google.cloud.iot.v1.RegistryCredential) - com.google.cloud.iot.v1.RegistryCredentialOrBuilder { - public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { - return com.google.cloud.iot.v1.ResourcesProto - .internal_static_google_cloud_iot_v1_RegistryCredential_descriptor; - } - - @java.lang.Override - protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable - internalGetFieldAccessorTable() { - return com.google.cloud.iot.v1.ResourcesProto - .internal_static_google_cloud_iot_v1_RegistryCredential_fieldAccessorTable - .ensureFieldAccessorsInitialized( - com.google.cloud.iot.v1.RegistryCredential.class, - com.google.cloud.iot.v1.RegistryCredential.Builder.class); - } - - // Construct using com.google.cloud.iot.v1.RegistryCredential.newBuilder() - private Builder() {} - - private Builder(com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { - super(parent); - } - - @java.lang.Override - public Builder clear() { - super.clear(); - if (publicKeyCertificateBuilder_ != null) { - publicKeyCertificateBuilder_.clear(); - } - credentialCase_ = 0; - credential_ = null; - return this; - } - - @java.lang.Override - public com.google.protobuf.Descriptors.Descriptor getDescriptorForType() { - return com.google.cloud.iot.v1.ResourcesProto - .internal_static_google_cloud_iot_v1_RegistryCredential_descriptor; - } - - @java.lang.Override - public com.google.cloud.iot.v1.RegistryCredential getDefaultInstanceForType() { - return com.google.cloud.iot.v1.RegistryCredential.getDefaultInstance(); - } - - @java.lang.Override - public com.google.cloud.iot.v1.RegistryCredential build() { - com.google.cloud.iot.v1.RegistryCredential result = buildPartial(); - if (!result.isInitialized()) { - throw newUninitializedMessageException(result); - } - return result; - } - - @java.lang.Override - public com.google.cloud.iot.v1.RegistryCredential buildPartial() { - com.google.cloud.iot.v1.RegistryCredential result = - new com.google.cloud.iot.v1.RegistryCredential(this); - if (credentialCase_ == 1) { - if (publicKeyCertificateBuilder_ == null) { - result.credential_ = credential_; - } else { - result.credential_ = publicKeyCertificateBuilder_.build(); - } - } - result.credentialCase_ = credentialCase_; - onBuilt(); - return result; - } - - @java.lang.Override - public Builder clone() { - return super.clone(); - } - - @java.lang.Override - public Builder setField( - com.google.protobuf.Descriptors.FieldDescriptor field, java.lang.Object value) { - return super.setField(field, value); - } - - @java.lang.Override - public Builder clearField(com.google.protobuf.Descriptors.FieldDescriptor field) { - return super.clearField(field); - } - - @java.lang.Override - public Builder clearOneof(com.google.protobuf.Descriptors.OneofDescriptor oneof) { - return super.clearOneof(oneof); - } - - @java.lang.Override - public Builder setRepeatedField( - com.google.protobuf.Descriptors.FieldDescriptor field, int index, java.lang.Object value) { - return super.setRepeatedField(field, index, value); - } - - @java.lang.Override - public Builder addRepeatedField( - com.google.protobuf.Descriptors.FieldDescriptor field, java.lang.Object value) { - return super.addRepeatedField(field, value); - } - - @java.lang.Override - public Builder mergeFrom(com.google.protobuf.Message other) { - if (other instanceof com.google.cloud.iot.v1.RegistryCredential) { - return mergeFrom((com.google.cloud.iot.v1.RegistryCredential) other); - } else { - super.mergeFrom(other); - return this; - } - } - - public Builder mergeFrom(com.google.cloud.iot.v1.RegistryCredential other) { - if (other == com.google.cloud.iot.v1.RegistryCredential.getDefaultInstance()) return this; - switch (other.getCredentialCase()) { - case PUBLIC_KEY_CERTIFICATE: - { - mergePublicKeyCertificate(other.getPublicKeyCertificate()); - break; - } - case CREDENTIAL_NOT_SET: - { - break; - } - } - this.mergeUnknownFields(other.getUnknownFields()); - onChanged(); - return this; - } - - @java.lang.Override - public final boolean isInitialized() { - return true; - } - - @java.lang.Override - public Builder mergeFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - if (extensionRegistry == null) { - throw new java.lang.NullPointerException(); - } - try { - boolean done = false; - while (!done) { - int tag = input.readTag(); - switch (tag) { - case 0: - done = true; - break; - case 10: - { - input.readMessage( - getPublicKeyCertificateFieldBuilder().getBuilder(), extensionRegistry); - credentialCase_ = 1; - break; - } // case 10 - default: - { - if (!super.parseUnknownField(input, extensionRegistry, tag)) { - done = true; // was an endgroup tag - } - break; - } // default: - } // switch (tag) - } // while (!done) - } catch (com.google.protobuf.InvalidProtocolBufferException e) { - throw e.unwrapIOException(); - } finally { - onChanged(); - } // finally - return this; - } - - private int credentialCase_ = 0; - private java.lang.Object credential_; - - public CredentialCase getCredentialCase() { - return CredentialCase.forNumber(credentialCase_); - } - - public Builder clearCredential() { - credentialCase_ = 0; - credential_ = null; - onChanged(); - return this; - } - - private com.google.protobuf.SingleFieldBuilderV3< - com.google.cloud.iot.v1.PublicKeyCertificate, - com.google.cloud.iot.v1.PublicKeyCertificate.Builder, - com.google.cloud.iot.v1.PublicKeyCertificateOrBuilder> - publicKeyCertificateBuilder_; - /** - * - * - *
-     * A public key certificate used to verify the device credentials.
-     * 
- * - * .google.cloud.iot.v1.PublicKeyCertificate public_key_certificate = 1; - * - * @return Whether the publicKeyCertificate field is set. - */ - @java.lang.Override - public boolean hasPublicKeyCertificate() { - return credentialCase_ == 1; - } - /** - * - * - *
-     * A public key certificate used to verify the device credentials.
-     * 
- * - * .google.cloud.iot.v1.PublicKeyCertificate public_key_certificate = 1; - * - * @return The publicKeyCertificate. - */ - @java.lang.Override - public com.google.cloud.iot.v1.PublicKeyCertificate getPublicKeyCertificate() { - if (publicKeyCertificateBuilder_ == null) { - if (credentialCase_ == 1) { - return (com.google.cloud.iot.v1.PublicKeyCertificate) credential_; - } - return com.google.cloud.iot.v1.PublicKeyCertificate.getDefaultInstance(); - } else { - if (credentialCase_ == 1) { - return publicKeyCertificateBuilder_.getMessage(); - } - return com.google.cloud.iot.v1.PublicKeyCertificate.getDefaultInstance(); - } - } - /** - * - * - *
-     * A public key certificate used to verify the device credentials.
-     * 
- * - * .google.cloud.iot.v1.PublicKeyCertificate public_key_certificate = 1; - */ - public Builder setPublicKeyCertificate(com.google.cloud.iot.v1.PublicKeyCertificate value) { - if (publicKeyCertificateBuilder_ == null) { - if (value == null) { - throw new NullPointerException(); - } - credential_ = value; - onChanged(); - } else { - publicKeyCertificateBuilder_.setMessage(value); - } - credentialCase_ = 1; - return this; - } - /** - * - * - *
-     * A public key certificate used to verify the device credentials.
-     * 
- * - * .google.cloud.iot.v1.PublicKeyCertificate public_key_certificate = 1; - */ - public Builder setPublicKeyCertificate( - com.google.cloud.iot.v1.PublicKeyCertificate.Builder builderForValue) { - if (publicKeyCertificateBuilder_ == null) { - credential_ = builderForValue.build(); - onChanged(); - } else { - publicKeyCertificateBuilder_.setMessage(builderForValue.build()); - } - credentialCase_ = 1; - return this; - } - /** - * - * - *
-     * A public key certificate used to verify the device credentials.
-     * 
- * - * .google.cloud.iot.v1.PublicKeyCertificate public_key_certificate = 1; - */ - public Builder mergePublicKeyCertificate(com.google.cloud.iot.v1.PublicKeyCertificate value) { - if (publicKeyCertificateBuilder_ == null) { - if (credentialCase_ == 1 - && credential_ != com.google.cloud.iot.v1.PublicKeyCertificate.getDefaultInstance()) { - credential_ = - com.google.cloud.iot.v1.PublicKeyCertificate.newBuilder( - (com.google.cloud.iot.v1.PublicKeyCertificate) credential_) - .mergeFrom(value) - .buildPartial(); - } else { - credential_ = value; - } - onChanged(); - } else { - if (credentialCase_ == 1) { - publicKeyCertificateBuilder_.mergeFrom(value); - } else { - publicKeyCertificateBuilder_.setMessage(value); - } - } - credentialCase_ = 1; - return this; - } - /** - * - * - *
-     * A public key certificate used to verify the device credentials.
-     * 
- * - * .google.cloud.iot.v1.PublicKeyCertificate public_key_certificate = 1; - */ - public Builder clearPublicKeyCertificate() { - if (publicKeyCertificateBuilder_ == null) { - if (credentialCase_ == 1) { - credentialCase_ = 0; - credential_ = null; - onChanged(); - } - } else { - if (credentialCase_ == 1) { - credentialCase_ = 0; - credential_ = null; - } - publicKeyCertificateBuilder_.clear(); - } - return this; - } - /** - * - * - *
-     * A public key certificate used to verify the device credentials.
-     * 
- * - * .google.cloud.iot.v1.PublicKeyCertificate public_key_certificate = 1; - */ - public com.google.cloud.iot.v1.PublicKeyCertificate.Builder getPublicKeyCertificateBuilder() { - return getPublicKeyCertificateFieldBuilder().getBuilder(); - } - /** - * - * - *
-     * A public key certificate used to verify the device credentials.
-     * 
- * - * .google.cloud.iot.v1.PublicKeyCertificate public_key_certificate = 1; - */ - @java.lang.Override - public com.google.cloud.iot.v1.PublicKeyCertificateOrBuilder - getPublicKeyCertificateOrBuilder() { - if ((credentialCase_ == 1) && (publicKeyCertificateBuilder_ != null)) { - return publicKeyCertificateBuilder_.getMessageOrBuilder(); - } else { - if (credentialCase_ == 1) { - return (com.google.cloud.iot.v1.PublicKeyCertificate) credential_; - } - return com.google.cloud.iot.v1.PublicKeyCertificate.getDefaultInstance(); - } - } - /** - * - * - *
-     * A public key certificate used to verify the device credentials.
-     * 
- * - * .google.cloud.iot.v1.PublicKeyCertificate public_key_certificate = 1; - */ - private com.google.protobuf.SingleFieldBuilderV3< - com.google.cloud.iot.v1.PublicKeyCertificate, - com.google.cloud.iot.v1.PublicKeyCertificate.Builder, - com.google.cloud.iot.v1.PublicKeyCertificateOrBuilder> - getPublicKeyCertificateFieldBuilder() { - if (publicKeyCertificateBuilder_ == null) { - if (!(credentialCase_ == 1)) { - credential_ = com.google.cloud.iot.v1.PublicKeyCertificate.getDefaultInstance(); - } - publicKeyCertificateBuilder_ = - new com.google.protobuf.SingleFieldBuilderV3< - com.google.cloud.iot.v1.PublicKeyCertificate, - com.google.cloud.iot.v1.PublicKeyCertificate.Builder, - com.google.cloud.iot.v1.PublicKeyCertificateOrBuilder>( - (com.google.cloud.iot.v1.PublicKeyCertificate) credential_, - getParentForChildren(), - isClean()); - credential_ = null; - } - credentialCase_ = 1; - onChanged(); - ; - return publicKeyCertificateBuilder_; - } - - @java.lang.Override - public final Builder setUnknownFields(final com.google.protobuf.UnknownFieldSet unknownFields) { - return super.setUnknownFields(unknownFields); - } - - @java.lang.Override - public final Builder mergeUnknownFields( - final com.google.protobuf.UnknownFieldSet unknownFields) { - return super.mergeUnknownFields(unknownFields); - } - - // @@protoc_insertion_point(builder_scope:google.cloud.iot.v1.RegistryCredential) - } - - // @@protoc_insertion_point(class_scope:google.cloud.iot.v1.RegistryCredential) - private static final com.google.cloud.iot.v1.RegistryCredential DEFAULT_INSTANCE; - - static { - DEFAULT_INSTANCE = new com.google.cloud.iot.v1.RegistryCredential(); - } - - public static com.google.cloud.iot.v1.RegistryCredential getDefaultInstance() { - return DEFAULT_INSTANCE; - } - - private static final com.google.protobuf.Parser PARSER = - new com.google.protobuf.AbstractParser() { - @java.lang.Override - public RegistryCredential parsePartialFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - Builder builder = newBuilder(); - try { - builder.mergeFrom(input, extensionRegistry); - } catch (com.google.protobuf.InvalidProtocolBufferException e) { - throw e.setUnfinishedMessage(builder.buildPartial()); - } catch (com.google.protobuf.UninitializedMessageException e) { - throw e.asInvalidProtocolBufferException().setUnfinishedMessage(builder.buildPartial()); - } catch (java.io.IOException e) { - throw new com.google.protobuf.InvalidProtocolBufferException(e) - .setUnfinishedMessage(builder.buildPartial()); - } - return builder.buildPartial(); - } - }; - - public static com.google.protobuf.Parser parser() { - return PARSER; - } - - @java.lang.Override - public com.google.protobuf.Parser getParserForType() { - return PARSER; - } - - @java.lang.Override - public com.google.cloud.iot.v1.RegistryCredential getDefaultInstanceForType() { - return DEFAULT_INSTANCE; - } -} diff --git a/proto-google-cloud-iot-v1/src/main/java/com/google/cloud/iot/v1/RegistryCredentialOrBuilder.java b/proto-google-cloud-iot-v1/src/main/java/com/google/cloud/iot/v1/RegistryCredentialOrBuilder.java deleted file mode 100644 index 4a8cac1e..00000000 --- a/proto-google-cloud-iot-v1/src/main/java/com/google/cloud/iot/v1/RegistryCredentialOrBuilder.java +++ /dev/null @@ -1,62 +0,0 @@ -/* - * Copyright 2020 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. - */ -// Generated by the protocol buffer compiler. DO NOT EDIT! -// source: google/cloud/iot/v1/resources.proto - -package com.google.cloud.iot.v1; - -public interface RegistryCredentialOrBuilder - extends - // @@protoc_insertion_point(interface_extends:google.cloud.iot.v1.RegistryCredential) - com.google.protobuf.MessageOrBuilder { - - /** - * - * - *
-   * A public key certificate used to verify the device credentials.
-   * 
- * - * .google.cloud.iot.v1.PublicKeyCertificate public_key_certificate = 1; - * - * @return Whether the publicKeyCertificate field is set. - */ - boolean hasPublicKeyCertificate(); - /** - * - * - *
-   * A public key certificate used to verify the device credentials.
-   * 
- * - * .google.cloud.iot.v1.PublicKeyCertificate public_key_certificate = 1; - * - * @return The publicKeyCertificate. - */ - com.google.cloud.iot.v1.PublicKeyCertificate getPublicKeyCertificate(); - /** - * - * - *
-   * A public key certificate used to verify the device credentials.
-   * 
- * - * .google.cloud.iot.v1.PublicKeyCertificate public_key_certificate = 1; - */ - com.google.cloud.iot.v1.PublicKeyCertificateOrBuilder getPublicKeyCertificateOrBuilder(); - - public com.google.cloud.iot.v1.RegistryCredential.CredentialCase getCredentialCase(); -} diff --git a/proto-google-cloud-iot-v1/src/main/java/com/google/cloud/iot/v1/RegistryName.java b/proto-google-cloud-iot-v1/src/main/java/com/google/cloud/iot/v1/RegistryName.java deleted file mode 100644 index 11dc867d..00000000 --- a/proto-google-cloud-iot-v1/src/main/java/com/google/cloud/iot/v1/RegistryName.java +++ /dev/null @@ -1,223 +0,0 @@ -/* - * 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 com.google.api.pathtemplate.PathTemplate; -import com.google.api.resourcenames.ResourceName; -import com.google.common.base.Preconditions; -import com.google.common.collect.ImmutableMap; -import java.util.ArrayList; -import java.util.List; -import java.util.Map; -import java.util.Objects; -import javax.annotation.Generated; - -// AUTO-GENERATED DOCUMENTATION AND CLASS. -@Generated("by gapic-generator-java") -public class RegistryName implements ResourceName { - private static final PathTemplate PROJECT_LOCATION_REGISTRY = - PathTemplate.createWithoutUrlEncoding( - "projects/{project}/locations/{location}/registries/{registry}"); - private volatile Map fieldValuesMap; - private final String project; - private final String location; - private final String registry; - - @Deprecated - protected RegistryName() { - project = null; - location = null; - registry = null; - } - - private RegistryName(Builder builder) { - project = Preconditions.checkNotNull(builder.getProject()); - location = Preconditions.checkNotNull(builder.getLocation()); - registry = Preconditions.checkNotNull(builder.getRegistry()); - } - - public String getProject() { - return project; - } - - public String getLocation() { - return location; - } - - public String getRegistry() { - return registry; - } - - public static Builder newBuilder() { - return new Builder(); - } - - public Builder toBuilder() { - return new Builder(this); - } - - public static RegistryName of(String project, String location, String registry) { - return newBuilder().setProject(project).setLocation(location).setRegistry(registry).build(); - } - - public static String format(String project, String location, String registry) { - return newBuilder() - .setProject(project) - .setLocation(location) - .setRegistry(registry) - .build() - .toString(); - } - - public static RegistryName parse(String formattedString) { - if (formattedString.isEmpty()) { - return null; - } - Map matchMap = - PROJECT_LOCATION_REGISTRY.validatedMatch( - formattedString, "RegistryName.parse: formattedString not in valid format"); - return of(matchMap.get("project"), matchMap.get("location"), matchMap.get("registry")); - } - - public static List parseList(List formattedStrings) { - List list = new ArrayList<>(formattedStrings.size()); - for (String formattedString : formattedStrings) { - list.add(parse(formattedString)); - } - return list; - } - - public static List toStringList(List values) { - List list = new ArrayList<>(values.size()); - for (RegistryName value : values) { - if (value == null) { - list.add(""); - } else { - list.add(value.toString()); - } - } - return list; - } - - public static boolean isParsableFrom(String formattedString) { - return PROJECT_LOCATION_REGISTRY.matches(formattedString); - } - - @Override - public Map getFieldValuesMap() { - if (fieldValuesMap == null) { - synchronized (this) { - if (fieldValuesMap == null) { - ImmutableMap.Builder fieldMapBuilder = ImmutableMap.builder(); - if (project != null) { - fieldMapBuilder.put("project", project); - } - if (location != null) { - fieldMapBuilder.put("location", location); - } - if (registry != null) { - fieldMapBuilder.put("registry", registry); - } - fieldValuesMap = fieldMapBuilder.build(); - } - } - } - return fieldValuesMap; - } - - public String getFieldValue(String fieldName) { - return getFieldValuesMap().get(fieldName); - } - - @Override - public String toString() { - return PROJECT_LOCATION_REGISTRY.instantiate( - "project", project, "location", location, "registry", registry); - } - - @Override - public boolean equals(Object o) { - if (o == this) { - return true; - } - if (o != null || getClass() == o.getClass()) { - RegistryName that = ((RegistryName) o); - return Objects.equals(this.project, that.project) - && Objects.equals(this.location, that.location) - && Objects.equals(this.registry, that.registry); - } - return false; - } - - @Override - public int hashCode() { - int h = 1; - h *= 1000003; - h ^= Objects.hashCode(project); - h *= 1000003; - h ^= Objects.hashCode(location); - h *= 1000003; - h ^= Objects.hashCode(registry); - return h; - } - - /** Builder for projects/{project}/locations/{location}/registries/{registry}. */ - public static class Builder { - private String project; - private String location; - private String registry; - - protected Builder() {} - - public String getProject() { - return project; - } - - public String getLocation() { - return location; - } - - public String getRegistry() { - return registry; - } - - public Builder setProject(String project) { - this.project = project; - return this; - } - - public Builder setLocation(String location) { - this.location = location; - return this; - } - - public Builder setRegistry(String registry) { - this.registry = registry; - return this; - } - - private Builder(RegistryName registryName) { - this.project = registryName.project; - this.location = registryName.location; - this.registry = registryName.registry; - } - - public RegistryName build() { - return new RegistryName(this); - } - } -} diff --git a/proto-google-cloud-iot-v1/src/main/java/com/google/cloud/iot/v1/ResourcesProto.java b/proto-google-cloud-iot-v1/src/main/java/com/google/cloud/iot/v1/ResourcesProto.java deleted file mode 100644 index b8663144..00000000 --- a/proto-google-cloud-iot-v1/src/main/java/com/google/cloud/iot/v1/ResourcesProto.java +++ /dev/null @@ -1,364 +0,0 @@ -/* - * Copyright 2020 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. - */ -// Generated by the protocol buffer compiler. DO NOT EDIT! -// source: google/cloud/iot/v1/resources.proto - -package com.google.cloud.iot.v1; - -public final class ResourcesProto { - private ResourcesProto() {} - - public static void registerAllExtensions(com.google.protobuf.ExtensionRegistryLite registry) {} - - public static void registerAllExtensions(com.google.protobuf.ExtensionRegistry registry) { - registerAllExtensions((com.google.protobuf.ExtensionRegistryLite) registry); - } - - static final com.google.protobuf.Descriptors.Descriptor - internal_static_google_cloud_iot_v1_Device_descriptor; - static final com.google.protobuf.GeneratedMessageV3.FieldAccessorTable - internal_static_google_cloud_iot_v1_Device_fieldAccessorTable; - static final com.google.protobuf.Descriptors.Descriptor - internal_static_google_cloud_iot_v1_Device_MetadataEntry_descriptor; - static final com.google.protobuf.GeneratedMessageV3.FieldAccessorTable - internal_static_google_cloud_iot_v1_Device_MetadataEntry_fieldAccessorTable; - static final com.google.protobuf.Descriptors.Descriptor - internal_static_google_cloud_iot_v1_GatewayConfig_descriptor; - static final com.google.protobuf.GeneratedMessageV3.FieldAccessorTable - internal_static_google_cloud_iot_v1_GatewayConfig_fieldAccessorTable; - static final com.google.protobuf.Descriptors.Descriptor - internal_static_google_cloud_iot_v1_DeviceRegistry_descriptor; - static final com.google.protobuf.GeneratedMessageV3.FieldAccessorTable - internal_static_google_cloud_iot_v1_DeviceRegistry_fieldAccessorTable; - static final com.google.protobuf.Descriptors.Descriptor - internal_static_google_cloud_iot_v1_MqttConfig_descriptor; - static final com.google.protobuf.GeneratedMessageV3.FieldAccessorTable - internal_static_google_cloud_iot_v1_MqttConfig_fieldAccessorTable; - static final com.google.protobuf.Descriptors.Descriptor - internal_static_google_cloud_iot_v1_HttpConfig_descriptor; - static final com.google.protobuf.GeneratedMessageV3.FieldAccessorTable - internal_static_google_cloud_iot_v1_HttpConfig_fieldAccessorTable; - static final com.google.protobuf.Descriptors.Descriptor - internal_static_google_cloud_iot_v1_EventNotificationConfig_descriptor; - static final com.google.protobuf.GeneratedMessageV3.FieldAccessorTable - internal_static_google_cloud_iot_v1_EventNotificationConfig_fieldAccessorTable; - static final com.google.protobuf.Descriptors.Descriptor - internal_static_google_cloud_iot_v1_StateNotificationConfig_descriptor; - static final com.google.protobuf.GeneratedMessageV3.FieldAccessorTable - internal_static_google_cloud_iot_v1_StateNotificationConfig_fieldAccessorTable; - static final com.google.protobuf.Descriptors.Descriptor - internal_static_google_cloud_iot_v1_RegistryCredential_descriptor; - static final com.google.protobuf.GeneratedMessageV3.FieldAccessorTable - internal_static_google_cloud_iot_v1_RegistryCredential_fieldAccessorTable; - static final com.google.protobuf.Descriptors.Descriptor - internal_static_google_cloud_iot_v1_X509CertificateDetails_descriptor; - static final com.google.protobuf.GeneratedMessageV3.FieldAccessorTable - internal_static_google_cloud_iot_v1_X509CertificateDetails_fieldAccessorTable; - static final com.google.protobuf.Descriptors.Descriptor - internal_static_google_cloud_iot_v1_PublicKeyCertificate_descriptor; - static final com.google.protobuf.GeneratedMessageV3.FieldAccessorTable - internal_static_google_cloud_iot_v1_PublicKeyCertificate_fieldAccessorTable; - static final com.google.protobuf.Descriptors.Descriptor - internal_static_google_cloud_iot_v1_DeviceCredential_descriptor; - static final com.google.protobuf.GeneratedMessageV3.FieldAccessorTable - internal_static_google_cloud_iot_v1_DeviceCredential_fieldAccessorTable; - static final com.google.protobuf.Descriptors.Descriptor - internal_static_google_cloud_iot_v1_PublicKeyCredential_descriptor; - static final com.google.protobuf.GeneratedMessageV3.FieldAccessorTable - internal_static_google_cloud_iot_v1_PublicKeyCredential_fieldAccessorTable; - static final com.google.protobuf.Descriptors.Descriptor - internal_static_google_cloud_iot_v1_DeviceConfig_descriptor; - static final com.google.protobuf.GeneratedMessageV3.FieldAccessorTable - internal_static_google_cloud_iot_v1_DeviceConfig_fieldAccessorTable; - static final com.google.protobuf.Descriptors.Descriptor - internal_static_google_cloud_iot_v1_DeviceState_descriptor; - static final com.google.protobuf.GeneratedMessageV3.FieldAccessorTable - internal_static_google_cloud_iot_v1_DeviceState_fieldAccessorTable; - - public static com.google.protobuf.Descriptors.FileDescriptor getDescriptor() { - return descriptor; - } - - private static com.google.protobuf.Descriptors.FileDescriptor descriptor; - - static { - java.lang.String[] descriptorData = { - "\n#google/cloud/iot/v1/resources.proto\022\023g" - + "oogle.cloud.iot.v1\032\031google/api/resource." - + "proto\032\037google/protobuf/timestamp.proto\032\027" - + "google/rpc/status.proto\"\260\007\n\006Device\022\n\n\002id" - + "\030\001 \001(\t\022\014\n\004name\030\002 \001(\t\022\016\n\006num_id\030\003 \001(\004\022:\n\013" - + "credentials\030\014 \003(\0132%.google.cloud.iot.v1." - + "DeviceCredential\0227\n\023last_heartbeat_time\030" - + "\007 \001(\0132\032.google.protobuf.Timestamp\0223\n\017las" - + "t_event_time\030\010 \001(\0132\032.google.protobuf.Tim" - + "estamp\0223\n\017last_state_time\030\024 \001(\0132\032.google" - + ".protobuf.Timestamp\0228\n\024last_config_ack_t" - + "ime\030\016 \001(\0132\032.google.protobuf.Timestamp\0229\n" - + "\025last_config_send_time\030\022 \001(\0132\032.google.pr" - + "otobuf.Timestamp\022\017\n\007blocked\030\023 \001(\010\0223\n\017las" - + "t_error_time\030\n \001(\0132\032.google.protobuf.Tim" - + "estamp\022-\n\021last_error_status\030\013 \001(\0132\022.goog" - + "le.rpc.Status\0221\n\006config\030\r \001(\0132!.google.c" - + "loud.iot.v1.DeviceConfig\022/\n\005state\030\020 \001(\0132" - + " .google.cloud.iot.v1.DeviceState\0220\n\tlog" - + "_level\030\025 \001(\0162\035.google.cloud.iot.v1.LogLe" - + "vel\022;\n\010metadata\030\021 \003(\0132).google.cloud.iot" - + ".v1.Device.MetadataEntry\022:\n\016gateway_conf" - + "ig\030\030 \001(\0132\".google.cloud.iot.v1.GatewayCo" - + "nfig\032/\n\rMetadataEntry\022\013\n\003key\030\001 \001(\t\022\r\n\005va" - + "lue\030\002 \001(\t:\0028\001:s\352Ap\n\036cloudiot.googleapis." - + "com/Device\022Nprojects/{project}/locations" - + "/{location}/registries/{registry}/device" - + "s/{device}\"\356\001\n\rGatewayConfig\0226\n\014gateway_" - + "type\030\001 \001(\0162 .google.cloud.iot.v1.Gateway" - + "Type\022C\n\023gateway_auth_method\030\002 \001(\0162&.goog" - + "le.cloud.iot.v1.GatewayAuthMethod\022 \n\030las" - + "t_accessed_gateway_id\030\003 \001(\t\022>\n\032last_acce" - + "ssed_gateway_time\030\004 \001(\0132\032.google.protobu" - + "f.Timestamp\"\217\004\n\016DeviceRegistry\022\n\n\002id\030\001 \001" - + "(\t\022\014\n\004name\030\002 \001(\t\022P\n\032event_notification_c" - + "onfigs\030\n \003(\0132,.google.cloud.iot.v1.Event" - + "NotificationConfig\022O\n\031state_notification" - + "_config\030\007 \001(\0132,.google.cloud.iot.v1.Stat" - + "eNotificationConfig\0224\n\013mqtt_config\030\004 \001(\013" - + "2\037.google.cloud.iot.v1.MqttConfig\0224\n\013htt" - + "p_config\030\t \001(\0132\037.google.cloud.iot.v1.Htt" - + "pConfig\0220\n\tlog_level\030\013 \001(\0162\035.google.clou" - + "d.iot.v1.LogLevel\022<\n\013credentials\030\010 \003(\0132\'" - + ".google.cloud.iot.v1.RegistryCredential:" - + "d\352Aa\n cloudiot.googleapis.com/Registry\022=" - + "projects/{project}/locations/{location}/" - + "registries/{registry}\"H\n\nMqttConfig\022:\n\022m" - + "qtt_enabled_state\030\001 \001(\0162\036.google.cloud.i" - + "ot.v1.MqttState\"H\n\nHttpConfig\022:\n\022http_en" - + "abled_state\030\001 \001(\0162\036.google.cloud.iot.v1." - + "HttpState\"O\n\027EventNotificationConfig\022\031\n\021" - + "subfolder_matches\030\002 \001(\t\022\031\n\021pubsub_topic_" - + "name\030\001 \001(\t\"4\n\027StateNotificationConfig\022\031\n" - + "\021pubsub_topic_name\030\001 \001(\t\"o\n\022RegistryCred" - + "ential\022K\n\026public_key_certificate\030\001 \001(\0132)" - + ".google.cloud.iot.v1.PublicKeyCertificat" - + "eH\000B\014\n\ncredential\"\320\001\n\026X509CertificateDet" - + "ails\022\016\n\006issuer\030\001 \001(\t\022\017\n\007subject\030\002 \001(\t\022.\n" - + "\nstart_time\030\003 \001(\0132\032.google.protobuf.Time" - + "stamp\022/\n\013expiry_time\030\004 \001(\0132\032.google.prot" - + "obuf.Timestamp\022\033\n\023signature_algorithm\030\005 " - + "\001(\t\022\027\n\017public_key_type\030\006 \001(\t\"\257\001\n\024PublicK" - + "eyCertificate\022?\n\006format\030\001 \001(\0162/.google.c" - + "loud.iot.v1.PublicKeyCertificateFormat\022\023" - + "\n\013certificate\030\002 \001(\t\022A\n\014x509_details\030\003 \001(" - + "\0132+.google.cloud.iot.v1.X509CertificateD" - + "etails\"\225\001\n\020DeviceCredential\022>\n\npublic_ke" - + "y\030\002 \001(\0132(.google.cloud.iot.v1.PublicKeyC" - + "redentialH\000\0223\n\017expiration_time\030\006 \001(\0132\032.g" - + "oogle.protobuf.TimestampB\014\n\ncredential\"X" - + "\n\023PublicKeyCredential\0224\n\006format\030\001 \001(\0162$." - + "google.cloud.iot.v1.PublicKeyFormat\022\013\n\003k" - + "ey\030\002 \001(\t\"\240\001\n\014DeviceConfig\022\017\n\007version\030\001 \001" - + "(\003\0225\n\021cloud_update_time\030\002 \001(\0132\032.google.p" - + "rotobuf.Timestamp\0223\n\017device_ack_time\030\003 \001" - + "(\0132\032.google.protobuf.Timestamp\022\023\n\013binary" - + "_data\030\004 \001(\014\"S\n\013DeviceState\022/\n\013update_tim" - + "e\030\001 \001(\0132\032.google.protobuf.Timestamp\022\023\n\013b" - + "inary_data\030\002 \001(\014*L\n\tMqttState\022\032\n\026MQTT_ST" - + "ATE_UNSPECIFIED\020\000\022\020\n\014MQTT_ENABLED\020\001\022\021\n\rM" - + "QTT_DISABLED\020\002*L\n\tHttpState\022\032\n\026HTTP_STAT" - + "E_UNSPECIFIED\020\000\022\020\n\014HTTP_ENABLED\020\001\022\021\n\rHTT" - + "P_DISABLED\020\002*O\n\010LogLevel\022\031\n\025LOG_LEVEL_UN" - + "SPECIFIED\020\000\022\010\n\004NONE\020\n\022\t\n\005ERROR\020\024\022\010\n\004INFO" - + "\020\036\022\t\n\005DEBUG\020(*I\n\013GatewayType\022\034\n\030GATEWAY_" - + "TYPE_UNSPECIFIED\020\000\022\013\n\007GATEWAY\020\001\022\017\n\013NON_G" - + "ATEWAY\020\002*\221\001\n\021GatewayAuthMethod\022#\n\037GATEWA" - + "Y_AUTH_METHOD_UNSPECIFIED\020\000\022\024\n\020ASSOCIATI" - + "ON_ONLY\020\001\022\032\n\026DEVICE_AUTH_TOKEN_ONLY\020\002\022%\n" - + "!ASSOCIATION_AND_DEVICE_AUTH_TOKEN\020\003*e\n\032" - + "PublicKeyCertificateFormat\022-\n)UNSPECIFIE" - + "D_PUBLIC_KEY_CERTIFICATE_FORMAT\020\000\022\030\n\024X50" - + "9_CERTIFICATE_PEM\020\001*v\n\017PublicKeyFormat\022!" - + "\n\035UNSPECIFIED_PUBLIC_KEY_FORMAT\020\000\022\013\n\007RSA" - + "_PEM\020\003\022\020\n\014RSA_X509_PEM\020\001\022\r\n\tES256_PEM\020\002\022" - + "\022\n\016ES256_X509_PEM\020\004Bf\n\027com.google.cloud." - + "iot.v1B\016ResourcesProtoP\001Z6google.golang." - + "org/genproto/googleapis/cloud/iot/v1;iot" - + "\370\001\001b\006proto3" - }; - descriptor = - com.google.protobuf.Descriptors.FileDescriptor.internalBuildGeneratedFileFrom( - descriptorData, - new com.google.protobuf.Descriptors.FileDescriptor[] { - com.google.api.ResourceProto.getDescriptor(), - com.google.protobuf.TimestampProto.getDescriptor(), - com.google.rpc.StatusProto.getDescriptor(), - }); - internal_static_google_cloud_iot_v1_Device_descriptor = - getDescriptor().getMessageTypes().get(0); - internal_static_google_cloud_iot_v1_Device_fieldAccessorTable = - new com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( - internal_static_google_cloud_iot_v1_Device_descriptor, - new java.lang.String[] { - "Id", - "Name", - "NumId", - "Credentials", - "LastHeartbeatTime", - "LastEventTime", - "LastStateTime", - "LastConfigAckTime", - "LastConfigSendTime", - "Blocked", - "LastErrorTime", - "LastErrorStatus", - "Config", - "State", - "LogLevel", - "Metadata", - "GatewayConfig", - }); - internal_static_google_cloud_iot_v1_Device_MetadataEntry_descriptor = - internal_static_google_cloud_iot_v1_Device_descriptor.getNestedTypes().get(0); - internal_static_google_cloud_iot_v1_Device_MetadataEntry_fieldAccessorTable = - new com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( - internal_static_google_cloud_iot_v1_Device_MetadataEntry_descriptor, - new java.lang.String[] { - "Key", "Value", - }); - internal_static_google_cloud_iot_v1_GatewayConfig_descriptor = - getDescriptor().getMessageTypes().get(1); - internal_static_google_cloud_iot_v1_GatewayConfig_fieldAccessorTable = - new com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( - internal_static_google_cloud_iot_v1_GatewayConfig_descriptor, - new java.lang.String[] { - "GatewayType", - "GatewayAuthMethod", - "LastAccessedGatewayId", - "LastAccessedGatewayTime", - }); - internal_static_google_cloud_iot_v1_DeviceRegistry_descriptor = - getDescriptor().getMessageTypes().get(2); - internal_static_google_cloud_iot_v1_DeviceRegistry_fieldAccessorTable = - new com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( - internal_static_google_cloud_iot_v1_DeviceRegistry_descriptor, - new java.lang.String[] { - "Id", - "Name", - "EventNotificationConfigs", - "StateNotificationConfig", - "MqttConfig", - "HttpConfig", - "LogLevel", - "Credentials", - }); - internal_static_google_cloud_iot_v1_MqttConfig_descriptor = - getDescriptor().getMessageTypes().get(3); - internal_static_google_cloud_iot_v1_MqttConfig_fieldAccessorTable = - new com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( - internal_static_google_cloud_iot_v1_MqttConfig_descriptor, - new java.lang.String[] { - "MqttEnabledState", - }); - internal_static_google_cloud_iot_v1_HttpConfig_descriptor = - getDescriptor().getMessageTypes().get(4); - internal_static_google_cloud_iot_v1_HttpConfig_fieldAccessorTable = - new com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( - internal_static_google_cloud_iot_v1_HttpConfig_descriptor, - new java.lang.String[] { - "HttpEnabledState", - }); - internal_static_google_cloud_iot_v1_EventNotificationConfig_descriptor = - getDescriptor().getMessageTypes().get(5); - internal_static_google_cloud_iot_v1_EventNotificationConfig_fieldAccessorTable = - new com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( - internal_static_google_cloud_iot_v1_EventNotificationConfig_descriptor, - new java.lang.String[] { - "SubfolderMatches", "PubsubTopicName", - }); - internal_static_google_cloud_iot_v1_StateNotificationConfig_descriptor = - getDescriptor().getMessageTypes().get(6); - internal_static_google_cloud_iot_v1_StateNotificationConfig_fieldAccessorTable = - new com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( - internal_static_google_cloud_iot_v1_StateNotificationConfig_descriptor, - new java.lang.String[] { - "PubsubTopicName", - }); - internal_static_google_cloud_iot_v1_RegistryCredential_descriptor = - getDescriptor().getMessageTypes().get(7); - internal_static_google_cloud_iot_v1_RegistryCredential_fieldAccessorTable = - new com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( - internal_static_google_cloud_iot_v1_RegistryCredential_descriptor, - new java.lang.String[] { - "PublicKeyCertificate", "Credential", - }); - internal_static_google_cloud_iot_v1_X509CertificateDetails_descriptor = - getDescriptor().getMessageTypes().get(8); - internal_static_google_cloud_iot_v1_X509CertificateDetails_fieldAccessorTable = - new com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( - internal_static_google_cloud_iot_v1_X509CertificateDetails_descriptor, - new java.lang.String[] { - "Issuer", "Subject", "StartTime", "ExpiryTime", "SignatureAlgorithm", "PublicKeyType", - }); - internal_static_google_cloud_iot_v1_PublicKeyCertificate_descriptor = - getDescriptor().getMessageTypes().get(9); - internal_static_google_cloud_iot_v1_PublicKeyCertificate_fieldAccessorTable = - new com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( - internal_static_google_cloud_iot_v1_PublicKeyCertificate_descriptor, - new java.lang.String[] { - "Format", "Certificate", "X509Details", - }); - internal_static_google_cloud_iot_v1_DeviceCredential_descriptor = - getDescriptor().getMessageTypes().get(10); - internal_static_google_cloud_iot_v1_DeviceCredential_fieldAccessorTable = - new com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( - internal_static_google_cloud_iot_v1_DeviceCredential_descriptor, - new java.lang.String[] { - "PublicKey", "ExpirationTime", "Credential", - }); - internal_static_google_cloud_iot_v1_PublicKeyCredential_descriptor = - getDescriptor().getMessageTypes().get(11); - internal_static_google_cloud_iot_v1_PublicKeyCredential_fieldAccessorTable = - new com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( - internal_static_google_cloud_iot_v1_PublicKeyCredential_descriptor, - new java.lang.String[] { - "Format", "Key", - }); - internal_static_google_cloud_iot_v1_DeviceConfig_descriptor = - getDescriptor().getMessageTypes().get(12); - internal_static_google_cloud_iot_v1_DeviceConfig_fieldAccessorTable = - new com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( - internal_static_google_cloud_iot_v1_DeviceConfig_descriptor, - new java.lang.String[] { - "Version", "CloudUpdateTime", "DeviceAckTime", "BinaryData", - }); - internal_static_google_cloud_iot_v1_DeviceState_descriptor = - getDescriptor().getMessageTypes().get(13); - internal_static_google_cloud_iot_v1_DeviceState_fieldAccessorTable = - new com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( - internal_static_google_cloud_iot_v1_DeviceState_descriptor, - new java.lang.String[] { - "UpdateTime", "BinaryData", - }); - com.google.protobuf.ExtensionRegistry registry = - com.google.protobuf.ExtensionRegistry.newInstance(); - registry.add(com.google.api.ResourceProto.resource); - com.google.protobuf.Descriptors.FileDescriptor.internalUpdateFileDescriptor( - descriptor, registry); - com.google.api.ResourceProto.getDescriptor(); - com.google.protobuf.TimestampProto.getDescriptor(); - com.google.rpc.StatusProto.getDescriptor(); - } - - // @@protoc_insertion_point(outer_class_scope) -} diff --git a/proto-google-cloud-iot-v1/src/main/java/com/google/cloud/iot/v1/SendCommandToDeviceRequest.java b/proto-google-cloud-iot-v1/src/main/java/com/google/cloud/iot/v1/SendCommandToDeviceRequest.java deleted file mode 100644 index 026783f8..00000000 --- a/proto-google-cloud-iot-v1/src/main/java/com/google/cloud/iot/v1/SendCommandToDeviceRequest.java +++ /dev/null @@ -1,944 +0,0 @@ -/* - * Copyright 2020 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. - */ -// Generated by the protocol buffer compiler. DO NOT EDIT! -// source: google/cloud/iot/v1/device_manager.proto - -package com.google.cloud.iot.v1; - -/** - * - * - *
- * Request for `SendCommandToDevice`.
- * 
- * - * Protobuf type {@code google.cloud.iot.v1.SendCommandToDeviceRequest} - */ -public final class SendCommandToDeviceRequest extends com.google.protobuf.GeneratedMessageV3 - implements - // @@protoc_insertion_point(message_implements:google.cloud.iot.v1.SendCommandToDeviceRequest) - SendCommandToDeviceRequestOrBuilder { - private static final long serialVersionUID = 0L; - // Use SendCommandToDeviceRequest.newBuilder() to construct. - private SendCommandToDeviceRequest(com.google.protobuf.GeneratedMessageV3.Builder builder) { - super(builder); - } - - private SendCommandToDeviceRequest() { - name_ = ""; - binaryData_ = com.google.protobuf.ByteString.EMPTY; - subfolder_ = ""; - } - - @java.lang.Override - @SuppressWarnings({"unused"}) - protected java.lang.Object newInstance(UnusedPrivateParameter unused) { - return new SendCommandToDeviceRequest(); - } - - @java.lang.Override - public final com.google.protobuf.UnknownFieldSet getUnknownFields() { - return this.unknownFields; - } - - public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { - return com.google.cloud.iot.v1.DeviceManagerProto - .internal_static_google_cloud_iot_v1_SendCommandToDeviceRequest_descriptor; - } - - @java.lang.Override - protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable - internalGetFieldAccessorTable() { - return com.google.cloud.iot.v1.DeviceManagerProto - .internal_static_google_cloud_iot_v1_SendCommandToDeviceRequest_fieldAccessorTable - .ensureFieldAccessorsInitialized( - com.google.cloud.iot.v1.SendCommandToDeviceRequest.class, - com.google.cloud.iot.v1.SendCommandToDeviceRequest.Builder.class); - } - - public static final int NAME_FIELD_NUMBER = 1; - private volatile java.lang.Object name_; - /** - * - * - *
-   * Required. The name of the device. For example,
-   * `projects/p0/locations/us-central1/registries/registry0/devices/device0` or
-   * `projects/p0/locations/us-central1/registries/registry0/devices/{num_id}`.
-   * 
- * - * - * string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } - * - * - * @return The name. - */ - @java.lang.Override - public java.lang.String getName() { - java.lang.Object ref = name_; - if (ref instanceof java.lang.String) { - return (java.lang.String) ref; - } else { - com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; - java.lang.String s = bs.toStringUtf8(); - name_ = s; - return s; - } - } - /** - * - * - *
-   * Required. The name of the device. For example,
-   * `projects/p0/locations/us-central1/registries/registry0/devices/device0` or
-   * `projects/p0/locations/us-central1/registries/registry0/devices/{num_id}`.
-   * 
- * - * - * string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } - * - * - * @return The bytes for name. - */ - @java.lang.Override - public com.google.protobuf.ByteString getNameBytes() { - java.lang.Object ref = name_; - if (ref instanceof java.lang.String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); - name_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - - public static final int BINARY_DATA_FIELD_NUMBER = 2; - private com.google.protobuf.ByteString binaryData_; - /** - * - * - *
-   * Required. The command data to send to the device.
-   * 
- * - * bytes binary_data = 2 [(.google.api.field_behavior) = REQUIRED]; - * - * @return The binaryData. - */ - @java.lang.Override - public com.google.protobuf.ByteString getBinaryData() { - return binaryData_; - } - - public static final int SUBFOLDER_FIELD_NUMBER = 3; - private volatile java.lang.Object subfolder_; - /** - * - * - *
-   * Optional subfolder for the command. If empty, the command will be delivered
-   * to the /devices/{device-id}/commands topic, otherwise it will be delivered
-   * to the /devices/{device-id}/commands/{subfolder} topic. Multi-level
-   * subfolders are allowed. This field must not have more than 256 characters,
-   * and must not contain any MQTT wildcards ("+" or "#") or null characters.
-   * 
- * - * string subfolder = 3; - * - * @return The subfolder. - */ - @java.lang.Override - public java.lang.String getSubfolder() { - java.lang.Object ref = subfolder_; - if (ref instanceof java.lang.String) { - return (java.lang.String) ref; - } else { - com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; - java.lang.String s = bs.toStringUtf8(); - subfolder_ = s; - return s; - } - } - /** - * - * - *
-   * Optional subfolder for the command. If empty, the command will be delivered
-   * to the /devices/{device-id}/commands topic, otherwise it will be delivered
-   * to the /devices/{device-id}/commands/{subfolder} topic. Multi-level
-   * subfolders are allowed. This field must not have more than 256 characters,
-   * and must not contain any MQTT wildcards ("+" or "#") or null characters.
-   * 
- * - * string subfolder = 3; - * - * @return The bytes for subfolder. - */ - @java.lang.Override - public com.google.protobuf.ByteString getSubfolderBytes() { - java.lang.Object ref = subfolder_; - if (ref instanceof java.lang.String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); - subfolder_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - - private byte memoizedIsInitialized = -1; - - @java.lang.Override - public final boolean isInitialized() { - byte isInitialized = memoizedIsInitialized; - if (isInitialized == 1) return true; - if (isInitialized == 0) return false; - - memoizedIsInitialized = 1; - return true; - } - - @java.lang.Override - public void writeTo(com.google.protobuf.CodedOutputStream output) throws java.io.IOException { - if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(name_)) { - com.google.protobuf.GeneratedMessageV3.writeString(output, 1, name_); - } - if (!binaryData_.isEmpty()) { - output.writeBytes(2, binaryData_); - } - if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(subfolder_)) { - com.google.protobuf.GeneratedMessageV3.writeString(output, 3, subfolder_); - } - getUnknownFields().writeTo(output); - } - - @java.lang.Override - public int getSerializedSize() { - int size = memoizedSize; - if (size != -1) return size; - - size = 0; - if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(name_)) { - size += com.google.protobuf.GeneratedMessageV3.computeStringSize(1, name_); - } - if (!binaryData_.isEmpty()) { - size += com.google.protobuf.CodedOutputStream.computeBytesSize(2, binaryData_); - } - if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(subfolder_)) { - size += com.google.protobuf.GeneratedMessageV3.computeStringSize(3, subfolder_); - } - size += getUnknownFields().getSerializedSize(); - memoizedSize = size; - return size; - } - - @java.lang.Override - public boolean equals(final java.lang.Object obj) { - if (obj == this) { - return true; - } - if (!(obj instanceof com.google.cloud.iot.v1.SendCommandToDeviceRequest)) { - return super.equals(obj); - } - com.google.cloud.iot.v1.SendCommandToDeviceRequest other = - (com.google.cloud.iot.v1.SendCommandToDeviceRequest) obj; - - if (!getName().equals(other.getName())) return false; - if (!getBinaryData().equals(other.getBinaryData())) return false; - if (!getSubfolder().equals(other.getSubfolder())) return false; - if (!getUnknownFields().equals(other.getUnknownFields())) return false; - return true; - } - - @java.lang.Override - public int hashCode() { - if (memoizedHashCode != 0) { - return memoizedHashCode; - } - int hash = 41; - hash = (19 * hash) + getDescriptor().hashCode(); - hash = (37 * hash) + NAME_FIELD_NUMBER; - hash = (53 * hash) + getName().hashCode(); - hash = (37 * hash) + BINARY_DATA_FIELD_NUMBER; - hash = (53 * hash) + getBinaryData().hashCode(); - hash = (37 * hash) + SUBFOLDER_FIELD_NUMBER; - hash = (53 * hash) + getSubfolder().hashCode(); - hash = (29 * hash) + getUnknownFields().hashCode(); - memoizedHashCode = hash; - return hash; - } - - public static com.google.cloud.iot.v1.SendCommandToDeviceRequest parseFrom( - java.nio.ByteBuffer data) throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); - } - - public static com.google.cloud.iot.v1.SendCommandToDeviceRequest parseFrom( - java.nio.ByteBuffer data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); - } - - public static com.google.cloud.iot.v1.SendCommandToDeviceRequest parseFrom( - com.google.protobuf.ByteString data) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); - } - - public static com.google.cloud.iot.v1.SendCommandToDeviceRequest parseFrom( - com.google.protobuf.ByteString data, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); - } - - public static com.google.cloud.iot.v1.SendCommandToDeviceRequest parseFrom(byte[] data) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); - } - - public static com.google.cloud.iot.v1.SendCommandToDeviceRequest parseFrom( - byte[] data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); - } - - public static com.google.cloud.iot.v1.SendCommandToDeviceRequest parseFrom( - java.io.InputStream input) throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input); - } - - public static com.google.cloud.iot.v1.SendCommandToDeviceRequest parseFrom( - java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3.parseWithIOException( - PARSER, input, extensionRegistry); - } - - public static com.google.cloud.iot.v1.SendCommandToDeviceRequest parseDelimitedFrom( - java.io.InputStream input) throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3.parseDelimitedWithIOException(PARSER, input); - } - - public static com.google.cloud.iot.v1.SendCommandToDeviceRequest parseDelimitedFrom( - java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3.parseDelimitedWithIOException( - PARSER, input, extensionRegistry); - } - - public static com.google.cloud.iot.v1.SendCommandToDeviceRequest parseFrom( - com.google.protobuf.CodedInputStream input) throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input); - } - - public static com.google.cloud.iot.v1.SendCommandToDeviceRequest parseFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3.parseWithIOException( - PARSER, input, extensionRegistry); - } - - @java.lang.Override - public Builder newBuilderForType() { - return newBuilder(); - } - - public static Builder newBuilder() { - return DEFAULT_INSTANCE.toBuilder(); - } - - public static Builder newBuilder(com.google.cloud.iot.v1.SendCommandToDeviceRequest prototype) { - return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); - } - - @java.lang.Override - public Builder toBuilder() { - return this == DEFAULT_INSTANCE ? new Builder() : new Builder().mergeFrom(this); - } - - @java.lang.Override - protected Builder newBuilderForType(com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { - Builder builder = new Builder(parent); - return builder; - } - /** - * - * - *
-   * Request for `SendCommandToDevice`.
-   * 
- * - * Protobuf type {@code google.cloud.iot.v1.SendCommandToDeviceRequest} - */ - public static final class Builder extends com.google.protobuf.GeneratedMessageV3.Builder - implements - // @@protoc_insertion_point(builder_implements:google.cloud.iot.v1.SendCommandToDeviceRequest) - com.google.cloud.iot.v1.SendCommandToDeviceRequestOrBuilder { - public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { - return com.google.cloud.iot.v1.DeviceManagerProto - .internal_static_google_cloud_iot_v1_SendCommandToDeviceRequest_descriptor; - } - - @java.lang.Override - protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable - internalGetFieldAccessorTable() { - return com.google.cloud.iot.v1.DeviceManagerProto - .internal_static_google_cloud_iot_v1_SendCommandToDeviceRequest_fieldAccessorTable - .ensureFieldAccessorsInitialized( - com.google.cloud.iot.v1.SendCommandToDeviceRequest.class, - com.google.cloud.iot.v1.SendCommandToDeviceRequest.Builder.class); - } - - // Construct using com.google.cloud.iot.v1.SendCommandToDeviceRequest.newBuilder() - private Builder() {} - - private Builder(com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { - super(parent); - } - - @java.lang.Override - public Builder clear() { - super.clear(); - name_ = ""; - - binaryData_ = com.google.protobuf.ByteString.EMPTY; - - subfolder_ = ""; - - return this; - } - - @java.lang.Override - public com.google.protobuf.Descriptors.Descriptor getDescriptorForType() { - return com.google.cloud.iot.v1.DeviceManagerProto - .internal_static_google_cloud_iot_v1_SendCommandToDeviceRequest_descriptor; - } - - @java.lang.Override - public com.google.cloud.iot.v1.SendCommandToDeviceRequest getDefaultInstanceForType() { - return com.google.cloud.iot.v1.SendCommandToDeviceRequest.getDefaultInstance(); - } - - @java.lang.Override - public com.google.cloud.iot.v1.SendCommandToDeviceRequest build() { - com.google.cloud.iot.v1.SendCommandToDeviceRequest result = buildPartial(); - if (!result.isInitialized()) { - throw newUninitializedMessageException(result); - } - return result; - } - - @java.lang.Override - public com.google.cloud.iot.v1.SendCommandToDeviceRequest buildPartial() { - com.google.cloud.iot.v1.SendCommandToDeviceRequest result = - new com.google.cloud.iot.v1.SendCommandToDeviceRequest(this); - result.name_ = name_; - result.binaryData_ = binaryData_; - result.subfolder_ = subfolder_; - onBuilt(); - return result; - } - - @java.lang.Override - public Builder clone() { - return super.clone(); - } - - @java.lang.Override - public Builder setField( - com.google.protobuf.Descriptors.FieldDescriptor field, java.lang.Object value) { - return super.setField(field, value); - } - - @java.lang.Override - public Builder clearField(com.google.protobuf.Descriptors.FieldDescriptor field) { - return super.clearField(field); - } - - @java.lang.Override - public Builder clearOneof(com.google.protobuf.Descriptors.OneofDescriptor oneof) { - return super.clearOneof(oneof); - } - - @java.lang.Override - public Builder setRepeatedField( - com.google.protobuf.Descriptors.FieldDescriptor field, int index, java.lang.Object value) { - return super.setRepeatedField(field, index, value); - } - - @java.lang.Override - public Builder addRepeatedField( - com.google.protobuf.Descriptors.FieldDescriptor field, java.lang.Object value) { - return super.addRepeatedField(field, value); - } - - @java.lang.Override - public Builder mergeFrom(com.google.protobuf.Message other) { - if (other instanceof com.google.cloud.iot.v1.SendCommandToDeviceRequest) { - return mergeFrom((com.google.cloud.iot.v1.SendCommandToDeviceRequest) other); - } else { - super.mergeFrom(other); - return this; - } - } - - public Builder mergeFrom(com.google.cloud.iot.v1.SendCommandToDeviceRequest other) { - if (other == com.google.cloud.iot.v1.SendCommandToDeviceRequest.getDefaultInstance()) - return this; - if (!other.getName().isEmpty()) { - name_ = other.name_; - onChanged(); - } - if (other.getBinaryData() != com.google.protobuf.ByteString.EMPTY) { - setBinaryData(other.getBinaryData()); - } - if (!other.getSubfolder().isEmpty()) { - subfolder_ = other.subfolder_; - onChanged(); - } - this.mergeUnknownFields(other.getUnknownFields()); - onChanged(); - return this; - } - - @java.lang.Override - public final boolean isInitialized() { - return true; - } - - @java.lang.Override - public Builder mergeFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - if (extensionRegistry == null) { - throw new java.lang.NullPointerException(); - } - try { - boolean done = false; - while (!done) { - int tag = input.readTag(); - switch (tag) { - case 0: - done = true; - break; - case 10: - { - name_ = input.readStringRequireUtf8(); - - break; - } // case 10 - case 18: - { - binaryData_ = input.readBytes(); - - break; - } // case 18 - case 26: - { - subfolder_ = input.readStringRequireUtf8(); - - break; - } // case 26 - default: - { - if (!super.parseUnknownField(input, extensionRegistry, tag)) { - done = true; // was an endgroup tag - } - break; - } // default: - } // switch (tag) - } // while (!done) - } catch (com.google.protobuf.InvalidProtocolBufferException e) { - throw e.unwrapIOException(); - } finally { - onChanged(); - } // finally - return this; - } - - private java.lang.Object name_ = ""; - /** - * - * - *
-     * Required. The name of the device. For example,
-     * `projects/p0/locations/us-central1/registries/registry0/devices/device0` or
-     * `projects/p0/locations/us-central1/registries/registry0/devices/{num_id}`.
-     * 
- * - * - * string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } - * - * - * @return The name. - */ - public java.lang.String getName() { - java.lang.Object ref = name_; - if (!(ref instanceof java.lang.String)) { - com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; - java.lang.String s = bs.toStringUtf8(); - name_ = s; - return s; - } else { - return (java.lang.String) ref; - } - } - /** - * - * - *
-     * Required. The name of the device. For example,
-     * `projects/p0/locations/us-central1/registries/registry0/devices/device0` or
-     * `projects/p0/locations/us-central1/registries/registry0/devices/{num_id}`.
-     * 
- * - * - * string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } - * - * - * @return The bytes for name. - */ - public com.google.protobuf.ByteString getNameBytes() { - java.lang.Object ref = name_; - if (ref instanceof String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); - name_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - /** - * - * - *
-     * Required. The name of the device. For example,
-     * `projects/p0/locations/us-central1/registries/registry0/devices/device0` or
-     * `projects/p0/locations/us-central1/registries/registry0/devices/{num_id}`.
-     * 
- * - * - * string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } - * - * - * @param value The name to set. - * @return This builder for chaining. - */ - public Builder setName(java.lang.String value) { - if (value == null) { - throw new NullPointerException(); - } - - name_ = value; - onChanged(); - return this; - } - /** - * - * - *
-     * Required. The name of the device. For example,
-     * `projects/p0/locations/us-central1/registries/registry0/devices/device0` or
-     * `projects/p0/locations/us-central1/registries/registry0/devices/{num_id}`.
-     * 
- * - * - * string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } - * - * - * @return This builder for chaining. - */ - public Builder clearName() { - - name_ = getDefaultInstance().getName(); - onChanged(); - return this; - } - /** - * - * - *
-     * Required. The name of the device. For example,
-     * `projects/p0/locations/us-central1/registries/registry0/devices/device0` or
-     * `projects/p0/locations/us-central1/registries/registry0/devices/{num_id}`.
-     * 
- * - * - * string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } - * - * - * @param value The bytes for name to set. - * @return This builder for chaining. - */ - public Builder setNameBytes(com.google.protobuf.ByteString value) { - if (value == null) { - throw new NullPointerException(); - } - checkByteStringIsUtf8(value); - - name_ = value; - onChanged(); - return this; - } - - private com.google.protobuf.ByteString binaryData_ = com.google.protobuf.ByteString.EMPTY; - /** - * - * - *
-     * Required. The command data to send to the device.
-     * 
- * - * bytes binary_data = 2 [(.google.api.field_behavior) = REQUIRED]; - * - * @return The binaryData. - */ - @java.lang.Override - public com.google.protobuf.ByteString getBinaryData() { - return binaryData_; - } - /** - * - * - *
-     * Required. The command data to send to the device.
-     * 
- * - * bytes binary_data = 2 [(.google.api.field_behavior) = REQUIRED]; - * - * @param value The binaryData to set. - * @return This builder for chaining. - */ - public Builder setBinaryData(com.google.protobuf.ByteString value) { - if (value == null) { - throw new NullPointerException(); - } - - binaryData_ = value; - onChanged(); - return this; - } - /** - * - * - *
-     * Required. The command data to send to the device.
-     * 
- * - * bytes binary_data = 2 [(.google.api.field_behavior) = REQUIRED]; - * - * @return This builder for chaining. - */ - public Builder clearBinaryData() { - - binaryData_ = getDefaultInstance().getBinaryData(); - onChanged(); - return this; - } - - private java.lang.Object subfolder_ = ""; - /** - * - * - *
-     * Optional subfolder for the command. If empty, the command will be delivered
-     * to the /devices/{device-id}/commands topic, otherwise it will be delivered
-     * to the /devices/{device-id}/commands/{subfolder} topic. Multi-level
-     * subfolders are allowed. This field must not have more than 256 characters,
-     * and must not contain any MQTT wildcards ("+" or "#") or null characters.
-     * 
- * - * string subfolder = 3; - * - * @return The subfolder. - */ - public java.lang.String getSubfolder() { - java.lang.Object ref = subfolder_; - if (!(ref instanceof java.lang.String)) { - com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; - java.lang.String s = bs.toStringUtf8(); - subfolder_ = s; - return s; - } else { - return (java.lang.String) ref; - } - } - /** - * - * - *
-     * Optional subfolder for the command. If empty, the command will be delivered
-     * to the /devices/{device-id}/commands topic, otherwise it will be delivered
-     * to the /devices/{device-id}/commands/{subfolder} topic. Multi-level
-     * subfolders are allowed. This field must not have more than 256 characters,
-     * and must not contain any MQTT wildcards ("+" or "#") or null characters.
-     * 
- * - * string subfolder = 3; - * - * @return The bytes for subfolder. - */ - public com.google.protobuf.ByteString getSubfolderBytes() { - java.lang.Object ref = subfolder_; - if (ref instanceof String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); - subfolder_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - /** - * - * - *
-     * Optional subfolder for the command. If empty, the command will be delivered
-     * to the /devices/{device-id}/commands topic, otherwise it will be delivered
-     * to the /devices/{device-id}/commands/{subfolder} topic. Multi-level
-     * subfolders are allowed. This field must not have more than 256 characters,
-     * and must not contain any MQTT wildcards ("+" or "#") or null characters.
-     * 
- * - * string subfolder = 3; - * - * @param value The subfolder to set. - * @return This builder for chaining. - */ - public Builder setSubfolder(java.lang.String value) { - if (value == null) { - throw new NullPointerException(); - } - - subfolder_ = value; - onChanged(); - return this; - } - /** - * - * - *
-     * Optional subfolder for the command. If empty, the command will be delivered
-     * to the /devices/{device-id}/commands topic, otherwise it will be delivered
-     * to the /devices/{device-id}/commands/{subfolder} topic. Multi-level
-     * subfolders are allowed. This field must not have more than 256 characters,
-     * and must not contain any MQTT wildcards ("+" or "#") or null characters.
-     * 
- * - * string subfolder = 3; - * - * @return This builder for chaining. - */ - public Builder clearSubfolder() { - - subfolder_ = getDefaultInstance().getSubfolder(); - onChanged(); - return this; - } - /** - * - * - *
-     * Optional subfolder for the command. If empty, the command will be delivered
-     * to the /devices/{device-id}/commands topic, otherwise it will be delivered
-     * to the /devices/{device-id}/commands/{subfolder} topic. Multi-level
-     * subfolders are allowed. This field must not have more than 256 characters,
-     * and must not contain any MQTT wildcards ("+" or "#") or null characters.
-     * 
- * - * string subfolder = 3; - * - * @param value The bytes for subfolder to set. - * @return This builder for chaining. - */ - public Builder setSubfolderBytes(com.google.protobuf.ByteString value) { - if (value == null) { - throw new NullPointerException(); - } - checkByteStringIsUtf8(value); - - subfolder_ = value; - onChanged(); - return this; - } - - @java.lang.Override - public final Builder setUnknownFields(final com.google.protobuf.UnknownFieldSet unknownFields) { - return super.setUnknownFields(unknownFields); - } - - @java.lang.Override - public final Builder mergeUnknownFields( - final com.google.protobuf.UnknownFieldSet unknownFields) { - return super.mergeUnknownFields(unknownFields); - } - - // @@protoc_insertion_point(builder_scope:google.cloud.iot.v1.SendCommandToDeviceRequest) - } - - // @@protoc_insertion_point(class_scope:google.cloud.iot.v1.SendCommandToDeviceRequest) - private static final com.google.cloud.iot.v1.SendCommandToDeviceRequest DEFAULT_INSTANCE; - - static { - DEFAULT_INSTANCE = new com.google.cloud.iot.v1.SendCommandToDeviceRequest(); - } - - public static com.google.cloud.iot.v1.SendCommandToDeviceRequest getDefaultInstance() { - return DEFAULT_INSTANCE; - } - - private static final com.google.protobuf.Parser PARSER = - new com.google.protobuf.AbstractParser() { - @java.lang.Override - public SendCommandToDeviceRequest parsePartialFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - Builder builder = newBuilder(); - try { - builder.mergeFrom(input, extensionRegistry); - } catch (com.google.protobuf.InvalidProtocolBufferException e) { - throw e.setUnfinishedMessage(builder.buildPartial()); - } catch (com.google.protobuf.UninitializedMessageException e) { - throw e.asInvalidProtocolBufferException().setUnfinishedMessage(builder.buildPartial()); - } catch (java.io.IOException e) { - throw new com.google.protobuf.InvalidProtocolBufferException(e) - .setUnfinishedMessage(builder.buildPartial()); - } - return builder.buildPartial(); - } - }; - - public static com.google.protobuf.Parser parser() { - return PARSER; - } - - @java.lang.Override - public com.google.protobuf.Parser getParserForType() { - return PARSER; - } - - @java.lang.Override - public com.google.cloud.iot.v1.SendCommandToDeviceRequest getDefaultInstanceForType() { - return DEFAULT_INSTANCE; - } -} diff --git a/proto-google-cloud-iot-v1/src/main/java/com/google/cloud/iot/v1/SendCommandToDeviceRequestOrBuilder.java b/proto-google-cloud-iot-v1/src/main/java/com/google/cloud/iot/v1/SendCommandToDeviceRequestOrBuilder.java deleted file mode 100644 index a801f4f1..00000000 --- a/proto-google-cloud-iot-v1/src/main/java/com/google/cloud/iot/v1/SendCommandToDeviceRequestOrBuilder.java +++ /dev/null @@ -1,104 +0,0 @@ -/* - * Copyright 2020 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. - */ -// Generated by the protocol buffer compiler. DO NOT EDIT! -// source: google/cloud/iot/v1/device_manager.proto - -package com.google.cloud.iot.v1; - -public interface SendCommandToDeviceRequestOrBuilder - extends - // @@protoc_insertion_point(interface_extends:google.cloud.iot.v1.SendCommandToDeviceRequest) - com.google.protobuf.MessageOrBuilder { - - /** - * - * - *
-   * Required. The name of the device. For example,
-   * `projects/p0/locations/us-central1/registries/registry0/devices/device0` or
-   * `projects/p0/locations/us-central1/registries/registry0/devices/{num_id}`.
-   * 
- * - * - * string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } - * - * - * @return The name. - */ - java.lang.String getName(); - /** - * - * - *
-   * Required. The name of the device. For example,
-   * `projects/p0/locations/us-central1/registries/registry0/devices/device0` or
-   * `projects/p0/locations/us-central1/registries/registry0/devices/{num_id}`.
-   * 
- * - * - * string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } - * - * - * @return The bytes for name. - */ - com.google.protobuf.ByteString getNameBytes(); - - /** - * - * - *
-   * Required. The command data to send to the device.
-   * 
- * - * bytes binary_data = 2 [(.google.api.field_behavior) = REQUIRED]; - * - * @return The binaryData. - */ - com.google.protobuf.ByteString getBinaryData(); - - /** - * - * - *
-   * Optional subfolder for the command. If empty, the command will be delivered
-   * to the /devices/{device-id}/commands topic, otherwise it will be delivered
-   * to the /devices/{device-id}/commands/{subfolder} topic. Multi-level
-   * subfolders are allowed. This field must not have more than 256 characters,
-   * and must not contain any MQTT wildcards ("+" or "#") or null characters.
-   * 
- * - * string subfolder = 3; - * - * @return The subfolder. - */ - java.lang.String getSubfolder(); - /** - * - * - *
-   * Optional subfolder for the command. If empty, the command will be delivered
-   * to the /devices/{device-id}/commands topic, otherwise it will be delivered
-   * to the /devices/{device-id}/commands/{subfolder} topic. Multi-level
-   * subfolders are allowed. This field must not have more than 256 characters,
-   * and must not contain any MQTT wildcards ("+" or "#") or null characters.
-   * 
- * - * string subfolder = 3; - * - * @return The bytes for subfolder. - */ - com.google.protobuf.ByteString getSubfolderBytes(); -} diff --git a/proto-google-cloud-iot-v1/src/main/java/com/google/cloud/iot/v1/SendCommandToDeviceResponse.java b/proto-google-cloud-iot-v1/src/main/java/com/google/cloud/iot/v1/SendCommandToDeviceResponse.java deleted file mode 100644 index 9ef82605..00000000 --- a/proto-google-cloud-iot-v1/src/main/java/com/google/cloud/iot/v1/SendCommandToDeviceResponse.java +++ /dev/null @@ -1,436 +0,0 @@ -/* - * Copyright 2020 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. - */ -// Generated by the protocol buffer compiler. DO NOT EDIT! -// source: google/cloud/iot/v1/device_manager.proto - -package com.google.cloud.iot.v1; - -/** - * - * - *
- * Response for `SendCommandToDevice`.
- * 
- * - * Protobuf type {@code google.cloud.iot.v1.SendCommandToDeviceResponse} - */ -public final class SendCommandToDeviceResponse extends com.google.protobuf.GeneratedMessageV3 - implements - // @@protoc_insertion_point(message_implements:google.cloud.iot.v1.SendCommandToDeviceResponse) - SendCommandToDeviceResponseOrBuilder { - private static final long serialVersionUID = 0L; - // Use SendCommandToDeviceResponse.newBuilder() to construct. - private SendCommandToDeviceResponse(com.google.protobuf.GeneratedMessageV3.Builder builder) { - super(builder); - } - - private SendCommandToDeviceResponse() {} - - @java.lang.Override - @SuppressWarnings({"unused"}) - protected java.lang.Object newInstance(UnusedPrivateParameter unused) { - return new SendCommandToDeviceResponse(); - } - - @java.lang.Override - public final com.google.protobuf.UnknownFieldSet getUnknownFields() { - return this.unknownFields; - } - - public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { - return com.google.cloud.iot.v1.DeviceManagerProto - .internal_static_google_cloud_iot_v1_SendCommandToDeviceResponse_descriptor; - } - - @java.lang.Override - protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable - internalGetFieldAccessorTable() { - return com.google.cloud.iot.v1.DeviceManagerProto - .internal_static_google_cloud_iot_v1_SendCommandToDeviceResponse_fieldAccessorTable - .ensureFieldAccessorsInitialized( - com.google.cloud.iot.v1.SendCommandToDeviceResponse.class, - com.google.cloud.iot.v1.SendCommandToDeviceResponse.Builder.class); - } - - private byte memoizedIsInitialized = -1; - - @java.lang.Override - public final boolean isInitialized() { - byte isInitialized = memoizedIsInitialized; - if (isInitialized == 1) return true; - if (isInitialized == 0) return false; - - memoizedIsInitialized = 1; - return true; - } - - @java.lang.Override - public void writeTo(com.google.protobuf.CodedOutputStream output) throws java.io.IOException { - getUnknownFields().writeTo(output); - } - - @java.lang.Override - public int getSerializedSize() { - int size = memoizedSize; - if (size != -1) return size; - - size = 0; - size += getUnknownFields().getSerializedSize(); - memoizedSize = size; - return size; - } - - @java.lang.Override - public boolean equals(final java.lang.Object obj) { - if (obj == this) { - return true; - } - if (!(obj instanceof com.google.cloud.iot.v1.SendCommandToDeviceResponse)) { - return super.equals(obj); - } - com.google.cloud.iot.v1.SendCommandToDeviceResponse other = - (com.google.cloud.iot.v1.SendCommandToDeviceResponse) obj; - - if (!getUnknownFields().equals(other.getUnknownFields())) return false; - return true; - } - - @java.lang.Override - public int hashCode() { - if (memoizedHashCode != 0) { - return memoizedHashCode; - } - int hash = 41; - hash = (19 * hash) + getDescriptor().hashCode(); - hash = (29 * hash) + getUnknownFields().hashCode(); - memoizedHashCode = hash; - return hash; - } - - public static com.google.cloud.iot.v1.SendCommandToDeviceResponse parseFrom( - java.nio.ByteBuffer data) throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); - } - - public static com.google.cloud.iot.v1.SendCommandToDeviceResponse parseFrom( - java.nio.ByteBuffer data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); - } - - public static com.google.cloud.iot.v1.SendCommandToDeviceResponse parseFrom( - com.google.protobuf.ByteString data) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); - } - - public static com.google.cloud.iot.v1.SendCommandToDeviceResponse parseFrom( - com.google.protobuf.ByteString data, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); - } - - public static com.google.cloud.iot.v1.SendCommandToDeviceResponse parseFrom(byte[] data) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); - } - - public static com.google.cloud.iot.v1.SendCommandToDeviceResponse parseFrom( - byte[] data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); - } - - public static com.google.cloud.iot.v1.SendCommandToDeviceResponse parseFrom( - java.io.InputStream input) throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input); - } - - public static com.google.cloud.iot.v1.SendCommandToDeviceResponse parseFrom( - java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3.parseWithIOException( - PARSER, input, extensionRegistry); - } - - public static com.google.cloud.iot.v1.SendCommandToDeviceResponse parseDelimitedFrom( - java.io.InputStream input) throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3.parseDelimitedWithIOException(PARSER, input); - } - - public static com.google.cloud.iot.v1.SendCommandToDeviceResponse parseDelimitedFrom( - java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3.parseDelimitedWithIOException( - PARSER, input, extensionRegistry); - } - - public static com.google.cloud.iot.v1.SendCommandToDeviceResponse parseFrom( - com.google.protobuf.CodedInputStream input) throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input); - } - - public static com.google.cloud.iot.v1.SendCommandToDeviceResponse parseFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3.parseWithIOException( - PARSER, input, extensionRegistry); - } - - @java.lang.Override - public Builder newBuilderForType() { - return newBuilder(); - } - - public static Builder newBuilder() { - return DEFAULT_INSTANCE.toBuilder(); - } - - public static Builder newBuilder(com.google.cloud.iot.v1.SendCommandToDeviceResponse prototype) { - return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); - } - - @java.lang.Override - public Builder toBuilder() { - return this == DEFAULT_INSTANCE ? new Builder() : new Builder().mergeFrom(this); - } - - @java.lang.Override - protected Builder newBuilderForType(com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { - Builder builder = new Builder(parent); - return builder; - } - /** - * - * - *
-   * Response for `SendCommandToDevice`.
-   * 
- * - * Protobuf type {@code google.cloud.iot.v1.SendCommandToDeviceResponse} - */ - public static final class Builder extends com.google.protobuf.GeneratedMessageV3.Builder - implements - // @@protoc_insertion_point(builder_implements:google.cloud.iot.v1.SendCommandToDeviceResponse) - com.google.cloud.iot.v1.SendCommandToDeviceResponseOrBuilder { - public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { - return com.google.cloud.iot.v1.DeviceManagerProto - .internal_static_google_cloud_iot_v1_SendCommandToDeviceResponse_descriptor; - } - - @java.lang.Override - protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable - internalGetFieldAccessorTable() { - return com.google.cloud.iot.v1.DeviceManagerProto - .internal_static_google_cloud_iot_v1_SendCommandToDeviceResponse_fieldAccessorTable - .ensureFieldAccessorsInitialized( - com.google.cloud.iot.v1.SendCommandToDeviceResponse.class, - com.google.cloud.iot.v1.SendCommandToDeviceResponse.Builder.class); - } - - // Construct using com.google.cloud.iot.v1.SendCommandToDeviceResponse.newBuilder() - private Builder() {} - - private Builder(com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { - super(parent); - } - - @java.lang.Override - public Builder clear() { - super.clear(); - return this; - } - - @java.lang.Override - public com.google.protobuf.Descriptors.Descriptor getDescriptorForType() { - return com.google.cloud.iot.v1.DeviceManagerProto - .internal_static_google_cloud_iot_v1_SendCommandToDeviceResponse_descriptor; - } - - @java.lang.Override - public com.google.cloud.iot.v1.SendCommandToDeviceResponse getDefaultInstanceForType() { - return com.google.cloud.iot.v1.SendCommandToDeviceResponse.getDefaultInstance(); - } - - @java.lang.Override - public com.google.cloud.iot.v1.SendCommandToDeviceResponse build() { - com.google.cloud.iot.v1.SendCommandToDeviceResponse result = buildPartial(); - if (!result.isInitialized()) { - throw newUninitializedMessageException(result); - } - return result; - } - - @java.lang.Override - public com.google.cloud.iot.v1.SendCommandToDeviceResponse buildPartial() { - com.google.cloud.iot.v1.SendCommandToDeviceResponse result = - new com.google.cloud.iot.v1.SendCommandToDeviceResponse(this); - onBuilt(); - return result; - } - - @java.lang.Override - public Builder clone() { - return super.clone(); - } - - @java.lang.Override - public Builder setField( - com.google.protobuf.Descriptors.FieldDescriptor field, java.lang.Object value) { - return super.setField(field, value); - } - - @java.lang.Override - public Builder clearField(com.google.protobuf.Descriptors.FieldDescriptor field) { - return super.clearField(field); - } - - @java.lang.Override - public Builder clearOneof(com.google.protobuf.Descriptors.OneofDescriptor oneof) { - return super.clearOneof(oneof); - } - - @java.lang.Override - public Builder setRepeatedField( - com.google.protobuf.Descriptors.FieldDescriptor field, int index, java.lang.Object value) { - return super.setRepeatedField(field, index, value); - } - - @java.lang.Override - public Builder addRepeatedField( - com.google.protobuf.Descriptors.FieldDescriptor field, java.lang.Object value) { - return super.addRepeatedField(field, value); - } - - @java.lang.Override - public Builder mergeFrom(com.google.protobuf.Message other) { - if (other instanceof com.google.cloud.iot.v1.SendCommandToDeviceResponse) { - return mergeFrom((com.google.cloud.iot.v1.SendCommandToDeviceResponse) other); - } else { - super.mergeFrom(other); - return this; - } - } - - public Builder mergeFrom(com.google.cloud.iot.v1.SendCommandToDeviceResponse other) { - if (other == com.google.cloud.iot.v1.SendCommandToDeviceResponse.getDefaultInstance()) - return this; - this.mergeUnknownFields(other.getUnknownFields()); - onChanged(); - return this; - } - - @java.lang.Override - public final boolean isInitialized() { - return true; - } - - @java.lang.Override - public Builder mergeFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - if (extensionRegistry == null) { - throw new java.lang.NullPointerException(); - } - try { - boolean done = false; - while (!done) { - int tag = input.readTag(); - switch (tag) { - case 0: - done = true; - break; - default: - { - if (!super.parseUnknownField(input, extensionRegistry, tag)) { - done = true; // was an endgroup tag - } - break; - } // default: - } // switch (tag) - } // while (!done) - } catch (com.google.protobuf.InvalidProtocolBufferException e) { - throw e.unwrapIOException(); - } finally { - onChanged(); - } // finally - return this; - } - - @java.lang.Override - public final Builder setUnknownFields(final com.google.protobuf.UnknownFieldSet unknownFields) { - return super.setUnknownFields(unknownFields); - } - - @java.lang.Override - public final Builder mergeUnknownFields( - final com.google.protobuf.UnknownFieldSet unknownFields) { - return super.mergeUnknownFields(unknownFields); - } - - // @@protoc_insertion_point(builder_scope:google.cloud.iot.v1.SendCommandToDeviceResponse) - } - - // @@protoc_insertion_point(class_scope:google.cloud.iot.v1.SendCommandToDeviceResponse) - private static final com.google.cloud.iot.v1.SendCommandToDeviceResponse DEFAULT_INSTANCE; - - static { - DEFAULT_INSTANCE = new com.google.cloud.iot.v1.SendCommandToDeviceResponse(); - } - - public static com.google.cloud.iot.v1.SendCommandToDeviceResponse getDefaultInstance() { - return DEFAULT_INSTANCE; - } - - private static final com.google.protobuf.Parser PARSER = - new com.google.protobuf.AbstractParser() { - @java.lang.Override - public SendCommandToDeviceResponse parsePartialFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - Builder builder = newBuilder(); - try { - builder.mergeFrom(input, extensionRegistry); - } catch (com.google.protobuf.InvalidProtocolBufferException e) { - throw e.setUnfinishedMessage(builder.buildPartial()); - } catch (com.google.protobuf.UninitializedMessageException e) { - throw e.asInvalidProtocolBufferException().setUnfinishedMessage(builder.buildPartial()); - } catch (java.io.IOException e) { - throw new com.google.protobuf.InvalidProtocolBufferException(e) - .setUnfinishedMessage(builder.buildPartial()); - } - return builder.buildPartial(); - } - }; - - public static com.google.protobuf.Parser parser() { - return PARSER; - } - - @java.lang.Override - public com.google.protobuf.Parser getParserForType() { - return PARSER; - } - - @java.lang.Override - public com.google.cloud.iot.v1.SendCommandToDeviceResponse getDefaultInstanceForType() { - return DEFAULT_INSTANCE; - } -} diff --git a/proto-google-cloud-iot-v1/src/main/java/com/google/cloud/iot/v1/SendCommandToDeviceResponseOrBuilder.java b/proto-google-cloud-iot-v1/src/main/java/com/google/cloud/iot/v1/SendCommandToDeviceResponseOrBuilder.java deleted file mode 100644 index 2358336d..00000000 --- a/proto-google-cloud-iot-v1/src/main/java/com/google/cloud/iot/v1/SendCommandToDeviceResponseOrBuilder.java +++ /dev/null @@ -1,24 +0,0 @@ -/* - * Copyright 2020 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. - */ -// Generated by the protocol buffer compiler. DO NOT EDIT! -// source: google/cloud/iot/v1/device_manager.proto - -package com.google.cloud.iot.v1; - -public interface SendCommandToDeviceResponseOrBuilder - extends - // @@protoc_insertion_point(interface_extends:google.cloud.iot.v1.SendCommandToDeviceResponse) - com.google.protobuf.MessageOrBuilder {} diff --git a/proto-google-cloud-iot-v1/src/main/java/com/google/cloud/iot/v1/StateNotificationConfig.java b/proto-google-cloud-iot-v1/src/main/java/com/google/cloud/iot/v1/StateNotificationConfig.java deleted file mode 100644 index b18bffae..00000000 --- a/proto-google-cloud-iot-v1/src/main/java/com/google/cloud/iot/v1/StateNotificationConfig.java +++ /dev/null @@ -1,622 +0,0 @@ -/* - * Copyright 2020 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. - */ -// Generated by the protocol buffer compiler. DO NOT EDIT! -// source: google/cloud/iot/v1/resources.proto - -package com.google.cloud.iot.v1; - -/** - * - * - *
- * The configuration for notification of new states received from the device.
- * 
- * - * Protobuf type {@code google.cloud.iot.v1.StateNotificationConfig} - */ -public final class StateNotificationConfig extends com.google.protobuf.GeneratedMessageV3 - implements - // @@protoc_insertion_point(message_implements:google.cloud.iot.v1.StateNotificationConfig) - StateNotificationConfigOrBuilder { - private static final long serialVersionUID = 0L; - // Use StateNotificationConfig.newBuilder() to construct. - private StateNotificationConfig(com.google.protobuf.GeneratedMessageV3.Builder builder) { - super(builder); - } - - private StateNotificationConfig() { - pubsubTopicName_ = ""; - } - - @java.lang.Override - @SuppressWarnings({"unused"}) - protected java.lang.Object newInstance(UnusedPrivateParameter unused) { - return new StateNotificationConfig(); - } - - @java.lang.Override - public final com.google.protobuf.UnknownFieldSet getUnknownFields() { - return this.unknownFields; - } - - public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { - return com.google.cloud.iot.v1.ResourcesProto - .internal_static_google_cloud_iot_v1_StateNotificationConfig_descriptor; - } - - @java.lang.Override - protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable - internalGetFieldAccessorTable() { - return com.google.cloud.iot.v1.ResourcesProto - .internal_static_google_cloud_iot_v1_StateNotificationConfig_fieldAccessorTable - .ensureFieldAccessorsInitialized( - com.google.cloud.iot.v1.StateNotificationConfig.class, - com.google.cloud.iot.v1.StateNotificationConfig.Builder.class); - } - - public static final int PUBSUB_TOPIC_NAME_FIELD_NUMBER = 1; - private volatile java.lang.Object pubsubTopicName_; - /** - * - * - *
-   * A Cloud Pub/Sub topic name. For example,
-   * `projects/myProject/topics/deviceEvents`.
-   * 
- * - * string pubsub_topic_name = 1; - * - * @return The pubsubTopicName. - */ - @java.lang.Override - public java.lang.String getPubsubTopicName() { - java.lang.Object ref = pubsubTopicName_; - if (ref instanceof java.lang.String) { - return (java.lang.String) ref; - } else { - com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; - java.lang.String s = bs.toStringUtf8(); - pubsubTopicName_ = s; - return s; - } - } - /** - * - * - *
-   * A Cloud Pub/Sub topic name. For example,
-   * `projects/myProject/topics/deviceEvents`.
-   * 
- * - * string pubsub_topic_name = 1; - * - * @return The bytes for pubsubTopicName. - */ - @java.lang.Override - public com.google.protobuf.ByteString getPubsubTopicNameBytes() { - java.lang.Object ref = pubsubTopicName_; - if (ref instanceof java.lang.String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); - pubsubTopicName_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - - private byte memoizedIsInitialized = -1; - - @java.lang.Override - public final boolean isInitialized() { - byte isInitialized = memoizedIsInitialized; - if (isInitialized == 1) return true; - if (isInitialized == 0) return false; - - memoizedIsInitialized = 1; - return true; - } - - @java.lang.Override - public void writeTo(com.google.protobuf.CodedOutputStream output) throws java.io.IOException { - if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(pubsubTopicName_)) { - com.google.protobuf.GeneratedMessageV3.writeString(output, 1, pubsubTopicName_); - } - getUnknownFields().writeTo(output); - } - - @java.lang.Override - public int getSerializedSize() { - int size = memoizedSize; - if (size != -1) return size; - - size = 0; - if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(pubsubTopicName_)) { - size += com.google.protobuf.GeneratedMessageV3.computeStringSize(1, pubsubTopicName_); - } - size += getUnknownFields().getSerializedSize(); - memoizedSize = size; - return size; - } - - @java.lang.Override - public boolean equals(final java.lang.Object obj) { - if (obj == this) { - return true; - } - if (!(obj instanceof com.google.cloud.iot.v1.StateNotificationConfig)) { - return super.equals(obj); - } - com.google.cloud.iot.v1.StateNotificationConfig other = - (com.google.cloud.iot.v1.StateNotificationConfig) obj; - - if (!getPubsubTopicName().equals(other.getPubsubTopicName())) return false; - if (!getUnknownFields().equals(other.getUnknownFields())) return false; - return true; - } - - @java.lang.Override - public int hashCode() { - if (memoizedHashCode != 0) { - return memoizedHashCode; - } - int hash = 41; - hash = (19 * hash) + getDescriptor().hashCode(); - hash = (37 * hash) + PUBSUB_TOPIC_NAME_FIELD_NUMBER; - hash = (53 * hash) + getPubsubTopicName().hashCode(); - hash = (29 * hash) + getUnknownFields().hashCode(); - memoizedHashCode = hash; - return hash; - } - - public static com.google.cloud.iot.v1.StateNotificationConfig parseFrom(java.nio.ByteBuffer data) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); - } - - public static com.google.cloud.iot.v1.StateNotificationConfig parseFrom( - java.nio.ByteBuffer data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); - } - - public static com.google.cloud.iot.v1.StateNotificationConfig parseFrom( - com.google.protobuf.ByteString data) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); - } - - public static com.google.cloud.iot.v1.StateNotificationConfig parseFrom( - com.google.protobuf.ByteString data, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); - } - - public static com.google.cloud.iot.v1.StateNotificationConfig parseFrom(byte[] data) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); - } - - public static com.google.cloud.iot.v1.StateNotificationConfig parseFrom( - byte[] data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); - } - - public static com.google.cloud.iot.v1.StateNotificationConfig parseFrom(java.io.InputStream input) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input); - } - - public static com.google.cloud.iot.v1.StateNotificationConfig parseFrom( - java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3.parseWithIOException( - PARSER, input, extensionRegistry); - } - - public static com.google.cloud.iot.v1.StateNotificationConfig parseDelimitedFrom( - java.io.InputStream input) throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3.parseDelimitedWithIOException(PARSER, input); - } - - public static com.google.cloud.iot.v1.StateNotificationConfig parseDelimitedFrom( - java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3.parseDelimitedWithIOException( - PARSER, input, extensionRegistry); - } - - public static com.google.cloud.iot.v1.StateNotificationConfig parseFrom( - com.google.protobuf.CodedInputStream input) throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input); - } - - public static com.google.cloud.iot.v1.StateNotificationConfig parseFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3.parseWithIOException( - PARSER, input, extensionRegistry); - } - - @java.lang.Override - public Builder newBuilderForType() { - return newBuilder(); - } - - public static Builder newBuilder() { - return DEFAULT_INSTANCE.toBuilder(); - } - - public static Builder newBuilder(com.google.cloud.iot.v1.StateNotificationConfig prototype) { - return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); - } - - @java.lang.Override - public Builder toBuilder() { - return this == DEFAULT_INSTANCE ? new Builder() : new Builder().mergeFrom(this); - } - - @java.lang.Override - protected Builder newBuilderForType(com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { - Builder builder = new Builder(parent); - return builder; - } - /** - * - * - *
-   * The configuration for notification of new states received from the device.
-   * 
- * - * Protobuf type {@code google.cloud.iot.v1.StateNotificationConfig} - */ - public static final class Builder extends com.google.protobuf.GeneratedMessageV3.Builder - implements - // @@protoc_insertion_point(builder_implements:google.cloud.iot.v1.StateNotificationConfig) - com.google.cloud.iot.v1.StateNotificationConfigOrBuilder { - public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { - return com.google.cloud.iot.v1.ResourcesProto - .internal_static_google_cloud_iot_v1_StateNotificationConfig_descriptor; - } - - @java.lang.Override - protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable - internalGetFieldAccessorTable() { - return com.google.cloud.iot.v1.ResourcesProto - .internal_static_google_cloud_iot_v1_StateNotificationConfig_fieldAccessorTable - .ensureFieldAccessorsInitialized( - com.google.cloud.iot.v1.StateNotificationConfig.class, - com.google.cloud.iot.v1.StateNotificationConfig.Builder.class); - } - - // Construct using com.google.cloud.iot.v1.StateNotificationConfig.newBuilder() - private Builder() {} - - private Builder(com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { - super(parent); - } - - @java.lang.Override - public Builder clear() { - super.clear(); - pubsubTopicName_ = ""; - - return this; - } - - @java.lang.Override - public com.google.protobuf.Descriptors.Descriptor getDescriptorForType() { - return com.google.cloud.iot.v1.ResourcesProto - .internal_static_google_cloud_iot_v1_StateNotificationConfig_descriptor; - } - - @java.lang.Override - public com.google.cloud.iot.v1.StateNotificationConfig getDefaultInstanceForType() { - return com.google.cloud.iot.v1.StateNotificationConfig.getDefaultInstance(); - } - - @java.lang.Override - public com.google.cloud.iot.v1.StateNotificationConfig build() { - com.google.cloud.iot.v1.StateNotificationConfig result = buildPartial(); - if (!result.isInitialized()) { - throw newUninitializedMessageException(result); - } - return result; - } - - @java.lang.Override - public com.google.cloud.iot.v1.StateNotificationConfig buildPartial() { - com.google.cloud.iot.v1.StateNotificationConfig result = - new com.google.cloud.iot.v1.StateNotificationConfig(this); - result.pubsubTopicName_ = pubsubTopicName_; - onBuilt(); - return result; - } - - @java.lang.Override - public Builder clone() { - return super.clone(); - } - - @java.lang.Override - public Builder setField( - com.google.protobuf.Descriptors.FieldDescriptor field, java.lang.Object value) { - return super.setField(field, value); - } - - @java.lang.Override - public Builder clearField(com.google.protobuf.Descriptors.FieldDescriptor field) { - return super.clearField(field); - } - - @java.lang.Override - public Builder clearOneof(com.google.protobuf.Descriptors.OneofDescriptor oneof) { - return super.clearOneof(oneof); - } - - @java.lang.Override - public Builder setRepeatedField( - com.google.protobuf.Descriptors.FieldDescriptor field, int index, java.lang.Object value) { - return super.setRepeatedField(field, index, value); - } - - @java.lang.Override - public Builder addRepeatedField( - com.google.protobuf.Descriptors.FieldDescriptor field, java.lang.Object value) { - return super.addRepeatedField(field, value); - } - - @java.lang.Override - public Builder mergeFrom(com.google.protobuf.Message other) { - if (other instanceof com.google.cloud.iot.v1.StateNotificationConfig) { - return mergeFrom((com.google.cloud.iot.v1.StateNotificationConfig) other); - } else { - super.mergeFrom(other); - return this; - } - } - - public Builder mergeFrom(com.google.cloud.iot.v1.StateNotificationConfig other) { - if (other == com.google.cloud.iot.v1.StateNotificationConfig.getDefaultInstance()) - return this; - if (!other.getPubsubTopicName().isEmpty()) { - pubsubTopicName_ = other.pubsubTopicName_; - onChanged(); - } - this.mergeUnknownFields(other.getUnknownFields()); - onChanged(); - return this; - } - - @java.lang.Override - public final boolean isInitialized() { - return true; - } - - @java.lang.Override - public Builder mergeFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - if (extensionRegistry == null) { - throw new java.lang.NullPointerException(); - } - try { - boolean done = false; - while (!done) { - int tag = input.readTag(); - switch (tag) { - case 0: - done = true; - break; - case 10: - { - pubsubTopicName_ = input.readStringRequireUtf8(); - - break; - } // case 10 - default: - { - if (!super.parseUnknownField(input, extensionRegistry, tag)) { - done = true; // was an endgroup tag - } - break; - } // default: - } // switch (tag) - } // while (!done) - } catch (com.google.protobuf.InvalidProtocolBufferException e) { - throw e.unwrapIOException(); - } finally { - onChanged(); - } // finally - return this; - } - - private java.lang.Object pubsubTopicName_ = ""; - /** - * - * - *
-     * A Cloud Pub/Sub topic name. For example,
-     * `projects/myProject/topics/deviceEvents`.
-     * 
- * - * string pubsub_topic_name = 1; - * - * @return The pubsubTopicName. - */ - public java.lang.String getPubsubTopicName() { - java.lang.Object ref = pubsubTopicName_; - if (!(ref instanceof java.lang.String)) { - com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; - java.lang.String s = bs.toStringUtf8(); - pubsubTopicName_ = s; - return s; - } else { - return (java.lang.String) ref; - } - } - /** - * - * - *
-     * A Cloud Pub/Sub topic name. For example,
-     * `projects/myProject/topics/deviceEvents`.
-     * 
- * - * string pubsub_topic_name = 1; - * - * @return The bytes for pubsubTopicName. - */ - public com.google.protobuf.ByteString getPubsubTopicNameBytes() { - java.lang.Object ref = pubsubTopicName_; - if (ref instanceof String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); - pubsubTopicName_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - /** - * - * - *
-     * A Cloud Pub/Sub topic name. For example,
-     * `projects/myProject/topics/deviceEvents`.
-     * 
- * - * string pubsub_topic_name = 1; - * - * @param value The pubsubTopicName to set. - * @return This builder for chaining. - */ - public Builder setPubsubTopicName(java.lang.String value) { - if (value == null) { - throw new NullPointerException(); - } - - pubsubTopicName_ = value; - onChanged(); - return this; - } - /** - * - * - *
-     * A Cloud Pub/Sub topic name. For example,
-     * `projects/myProject/topics/deviceEvents`.
-     * 
- * - * string pubsub_topic_name = 1; - * - * @return This builder for chaining. - */ - public Builder clearPubsubTopicName() { - - pubsubTopicName_ = getDefaultInstance().getPubsubTopicName(); - onChanged(); - return this; - } - /** - * - * - *
-     * A Cloud Pub/Sub topic name. For example,
-     * `projects/myProject/topics/deviceEvents`.
-     * 
- * - * string pubsub_topic_name = 1; - * - * @param value The bytes for pubsubTopicName to set. - * @return This builder for chaining. - */ - public Builder setPubsubTopicNameBytes(com.google.protobuf.ByteString value) { - if (value == null) { - throw new NullPointerException(); - } - checkByteStringIsUtf8(value); - - pubsubTopicName_ = value; - onChanged(); - return this; - } - - @java.lang.Override - public final Builder setUnknownFields(final com.google.protobuf.UnknownFieldSet unknownFields) { - return super.setUnknownFields(unknownFields); - } - - @java.lang.Override - public final Builder mergeUnknownFields( - final com.google.protobuf.UnknownFieldSet unknownFields) { - return super.mergeUnknownFields(unknownFields); - } - - // @@protoc_insertion_point(builder_scope:google.cloud.iot.v1.StateNotificationConfig) - } - - // @@protoc_insertion_point(class_scope:google.cloud.iot.v1.StateNotificationConfig) - private static final com.google.cloud.iot.v1.StateNotificationConfig DEFAULT_INSTANCE; - - static { - DEFAULT_INSTANCE = new com.google.cloud.iot.v1.StateNotificationConfig(); - } - - public static com.google.cloud.iot.v1.StateNotificationConfig getDefaultInstance() { - return DEFAULT_INSTANCE; - } - - private static final com.google.protobuf.Parser PARSER = - new com.google.protobuf.AbstractParser() { - @java.lang.Override - public StateNotificationConfig parsePartialFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - Builder builder = newBuilder(); - try { - builder.mergeFrom(input, extensionRegistry); - } catch (com.google.protobuf.InvalidProtocolBufferException e) { - throw e.setUnfinishedMessage(builder.buildPartial()); - } catch (com.google.protobuf.UninitializedMessageException e) { - throw e.asInvalidProtocolBufferException().setUnfinishedMessage(builder.buildPartial()); - } catch (java.io.IOException e) { - throw new com.google.protobuf.InvalidProtocolBufferException(e) - .setUnfinishedMessage(builder.buildPartial()); - } - return builder.buildPartial(); - } - }; - - public static com.google.protobuf.Parser parser() { - return PARSER; - } - - @java.lang.Override - public com.google.protobuf.Parser getParserForType() { - return PARSER; - } - - @java.lang.Override - public com.google.cloud.iot.v1.StateNotificationConfig getDefaultInstanceForType() { - return DEFAULT_INSTANCE; - } -} diff --git a/proto-google-cloud-iot-v1/src/main/java/com/google/cloud/iot/v1/StateNotificationConfigOrBuilder.java b/proto-google-cloud-iot-v1/src/main/java/com/google/cloud/iot/v1/StateNotificationConfigOrBuilder.java deleted file mode 100644 index af4e3e56..00000000 --- a/proto-google-cloud-iot-v1/src/main/java/com/google/cloud/iot/v1/StateNotificationConfigOrBuilder.java +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Copyright 2020 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. - */ -// Generated by the protocol buffer compiler. DO NOT EDIT! -// source: google/cloud/iot/v1/resources.proto - -package com.google.cloud.iot.v1; - -public interface StateNotificationConfigOrBuilder - extends - // @@protoc_insertion_point(interface_extends:google.cloud.iot.v1.StateNotificationConfig) - com.google.protobuf.MessageOrBuilder { - - /** - * - * - *
-   * A Cloud Pub/Sub topic name. For example,
-   * `projects/myProject/topics/deviceEvents`.
-   * 
- * - * string pubsub_topic_name = 1; - * - * @return The pubsubTopicName. - */ - java.lang.String getPubsubTopicName(); - /** - * - * - *
-   * A Cloud Pub/Sub topic name. For example,
-   * `projects/myProject/topics/deviceEvents`.
-   * 
- * - * string pubsub_topic_name = 1; - * - * @return The bytes for pubsubTopicName. - */ - com.google.protobuf.ByteString getPubsubTopicNameBytes(); -} diff --git a/proto-google-cloud-iot-v1/src/main/java/com/google/cloud/iot/v1/UnbindDeviceFromGatewayRequest.java b/proto-google-cloud-iot-v1/src/main/java/com/google/cloud/iot/v1/UnbindDeviceFromGatewayRequest.java deleted file mode 100644 index b79319d0..00000000 --- a/proto-google-cloud-iot-v1/src/main/java/com/google/cloud/iot/v1/UnbindDeviceFromGatewayRequest.java +++ /dev/null @@ -1,1015 +0,0 @@ -/* - * Copyright 2020 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. - */ -// Generated by the protocol buffer compiler. DO NOT EDIT! -// source: google/cloud/iot/v1/device_manager.proto - -package com.google.cloud.iot.v1; - -/** - * - * - *
- * Request for `UnbindDeviceFromGateway`.
- * 
- * - * Protobuf type {@code google.cloud.iot.v1.UnbindDeviceFromGatewayRequest} - */ -public final class UnbindDeviceFromGatewayRequest extends com.google.protobuf.GeneratedMessageV3 - implements - // @@protoc_insertion_point(message_implements:google.cloud.iot.v1.UnbindDeviceFromGatewayRequest) - UnbindDeviceFromGatewayRequestOrBuilder { - private static final long serialVersionUID = 0L; - // Use UnbindDeviceFromGatewayRequest.newBuilder() to construct. - private UnbindDeviceFromGatewayRequest( - com.google.protobuf.GeneratedMessageV3.Builder builder) { - super(builder); - } - - private UnbindDeviceFromGatewayRequest() { - parent_ = ""; - gatewayId_ = ""; - deviceId_ = ""; - } - - @java.lang.Override - @SuppressWarnings({"unused"}) - protected java.lang.Object newInstance(UnusedPrivateParameter unused) { - return new UnbindDeviceFromGatewayRequest(); - } - - @java.lang.Override - public final com.google.protobuf.UnknownFieldSet getUnknownFields() { - return this.unknownFields; - } - - public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { - return com.google.cloud.iot.v1.DeviceManagerProto - .internal_static_google_cloud_iot_v1_UnbindDeviceFromGatewayRequest_descriptor; - } - - @java.lang.Override - protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable - internalGetFieldAccessorTable() { - return com.google.cloud.iot.v1.DeviceManagerProto - .internal_static_google_cloud_iot_v1_UnbindDeviceFromGatewayRequest_fieldAccessorTable - .ensureFieldAccessorsInitialized( - com.google.cloud.iot.v1.UnbindDeviceFromGatewayRequest.class, - com.google.cloud.iot.v1.UnbindDeviceFromGatewayRequest.Builder.class); - } - - public static final int PARENT_FIELD_NUMBER = 1; - private volatile java.lang.Object parent_; - /** - * - * - *
-   * Required. The name of the registry. For example,
-   * `projects/example-project/locations/us-central1/registries/my-registry`.
-   * 
- * - * - * string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } - * - * - * @return The parent. - */ - @java.lang.Override - public java.lang.String getParent() { - java.lang.Object ref = parent_; - if (ref instanceof java.lang.String) { - return (java.lang.String) ref; - } else { - com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; - java.lang.String s = bs.toStringUtf8(); - parent_ = s; - return s; - } - } - /** - * - * - *
-   * Required. The name of the registry. For example,
-   * `projects/example-project/locations/us-central1/registries/my-registry`.
-   * 
- * - * - * string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } - * - * - * @return The bytes for parent. - */ - @java.lang.Override - public com.google.protobuf.ByteString getParentBytes() { - java.lang.Object ref = parent_; - if (ref instanceof java.lang.String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); - parent_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - - public static final int GATEWAY_ID_FIELD_NUMBER = 2; - private volatile java.lang.Object gatewayId_; - /** - * - * - *
-   * Required. The value of `gateway_id` can be either the device numeric ID or the
-   * user-defined device identifier.
-   * 
- * - * string gateway_id = 2 [(.google.api.field_behavior) = REQUIRED]; - * - * @return The gatewayId. - */ - @java.lang.Override - public java.lang.String getGatewayId() { - java.lang.Object ref = gatewayId_; - if (ref instanceof java.lang.String) { - return (java.lang.String) ref; - } else { - com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; - java.lang.String s = bs.toStringUtf8(); - gatewayId_ = s; - return s; - } - } - /** - * - * - *
-   * Required. The value of `gateway_id` can be either the device numeric ID or the
-   * user-defined device identifier.
-   * 
- * - * string gateway_id = 2 [(.google.api.field_behavior) = REQUIRED]; - * - * @return The bytes for gatewayId. - */ - @java.lang.Override - public com.google.protobuf.ByteString getGatewayIdBytes() { - java.lang.Object ref = gatewayId_; - if (ref instanceof java.lang.String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); - gatewayId_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - - public static final int DEVICE_ID_FIELD_NUMBER = 3; - private volatile java.lang.Object deviceId_; - /** - * - * - *
-   * Required. The device to disassociate from the specified gateway. The value of
-   * `device_id` can be either the device numeric ID or the user-defined device
-   * identifier.
-   * 
- * - * string device_id = 3 [(.google.api.field_behavior) = REQUIRED]; - * - * @return The deviceId. - */ - @java.lang.Override - public java.lang.String getDeviceId() { - java.lang.Object ref = deviceId_; - if (ref instanceof java.lang.String) { - return (java.lang.String) ref; - } else { - com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; - java.lang.String s = bs.toStringUtf8(); - deviceId_ = s; - return s; - } - } - /** - * - * - *
-   * Required. The device to disassociate from the specified gateway. The value of
-   * `device_id` can be either the device numeric ID or the user-defined device
-   * identifier.
-   * 
- * - * string device_id = 3 [(.google.api.field_behavior) = REQUIRED]; - * - * @return The bytes for deviceId. - */ - @java.lang.Override - public com.google.protobuf.ByteString getDeviceIdBytes() { - java.lang.Object ref = deviceId_; - if (ref instanceof java.lang.String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); - deviceId_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - - private byte memoizedIsInitialized = -1; - - @java.lang.Override - public final boolean isInitialized() { - byte isInitialized = memoizedIsInitialized; - if (isInitialized == 1) return true; - if (isInitialized == 0) return false; - - memoizedIsInitialized = 1; - return true; - } - - @java.lang.Override - public void writeTo(com.google.protobuf.CodedOutputStream output) throws java.io.IOException { - if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(parent_)) { - com.google.protobuf.GeneratedMessageV3.writeString(output, 1, parent_); - } - if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(gatewayId_)) { - com.google.protobuf.GeneratedMessageV3.writeString(output, 2, gatewayId_); - } - if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(deviceId_)) { - com.google.protobuf.GeneratedMessageV3.writeString(output, 3, deviceId_); - } - getUnknownFields().writeTo(output); - } - - @java.lang.Override - public int getSerializedSize() { - int size = memoizedSize; - if (size != -1) return size; - - size = 0; - if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(parent_)) { - size += com.google.protobuf.GeneratedMessageV3.computeStringSize(1, parent_); - } - if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(gatewayId_)) { - size += com.google.protobuf.GeneratedMessageV3.computeStringSize(2, gatewayId_); - } - if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(deviceId_)) { - size += com.google.protobuf.GeneratedMessageV3.computeStringSize(3, deviceId_); - } - size += getUnknownFields().getSerializedSize(); - memoizedSize = size; - return size; - } - - @java.lang.Override - public boolean equals(final java.lang.Object obj) { - if (obj == this) { - return true; - } - if (!(obj instanceof com.google.cloud.iot.v1.UnbindDeviceFromGatewayRequest)) { - return super.equals(obj); - } - com.google.cloud.iot.v1.UnbindDeviceFromGatewayRequest other = - (com.google.cloud.iot.v1.UnbindDeviceFromGatewayRequest) obj; - - if (!getParent().equals(other.getParent())) return false; - if (!getGatewayId().equals(other.getGatewayId())) return false; - if (!getDeviceId().equals(other.getDeviceId())) return false; - if (!getUnknownFields().equals(other.getUnknownFields())) return false; - return true; - } - - @java.lang.Override - public int hashCode() { - if (memoizedHashCode != 0) { - return memoizedHashCode; - } - int hash = 41; - hash = (19 * hash) + getDescriptor().hashCode(); - hash = (37 * hash) + PARENT_FIELD_NUMBER; - hash = (53 * hash) + getParent().hashCode(); - hash = (37 * hash) + GATEWAY_ID_FIELD_NUMBER; - hash = (53 * hash) + getGatewayId().hashCode(); - hash = (37 * hash) + DEVICE_ID_FIELD_NUMBER; - hash = (53 * hash) + getDeviceId().hashCode(); - hash = (29 * hash) + getUnknownFields().hashCode(); - memoizedHashCode = hash; - return hash; - } - - public static com.google.cloud.iot.v1.UnbindDeviceFromGatewayRequest parseFrom( - java.nio.ByteBuffer data) throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); - } - - public static com.google.cloud.iot.v1.UnbindDeviceFromGatewayRequest parseFrom( - java.nio.ByteBuffer data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); - } - - public static com.google.cloud.iot.v1.UnbindDeviceFromGatewayRequest parseFrom( - com.google.protobuf.ByteString data) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); - } - - public static com.google.cloud.iot.v1.UnbindDeviceFromGatewayRequest parseFrom( - com.google.protobuf.ByteString data, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); - } - - public static com.google.cloud.iot.v1.UnbindDeviceFromGatewayRequest parseFrom(byte[] data) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); - } - - public static com.google.cloud.iot.v1.UnbindDeviceFromGatewayRequest parseFrom( - byte[] data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); - } - - public static com.google.cloud.iot.v1.UnbindDeviceFromGatewayRequest parseFrom( - java.io.InputStream input) throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input); - } - - public static com.google.cloud.iot.v1.UnbindDeviceFromGatewayRequest parseFrom( - java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3.parseWithIOException( - PARSER, input, extensionRegistry); - } - - public static com.google.cloud.iot.v1.UnbindDeviceFromGatewayRequest parseDelimitedFrom( - java.io.InputStream input) throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3.parseDelimitedWithIOException(PARSER, input); - } - - public static com.google.cloud.iot.v1.UnbindDeviceFromGatewayRequest parseDelimitedFrom( - java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3.parseDelimitedWithIOException( - PARSER, input, extensionRegistry); - } - - public static com.google.cloud.iot.v1.UnbindDeviceFromGatewayRequest parseFrom( - com.google.protobuf.CodedInputStream input) throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input); - } - - public static com.google.cloud.iot.v1.UnbindDeviceFromGatewayRequest parseFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3.parseWithIOException( - PARSER, input, extensionRegistry); - } - - @java.lang.Override - public Builder newBuilderForType() { - return newBuilder(); - } - - public static Builder newBuilder() { - return DEFAULT_INSTANCE.toBuilder(); - } - - public static Builder newBuilder( - com.google.cloud.iot.v1.UnbindDeviceFromGatewayRequest prototype) { - return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); - } - - @java.lang.Override - public Builder toBuilder() { - return this == DEFAULT_INSTANCE ? new Builder() : new Builder().mergeFrom(this); - } - - @java.lang.Override - protected Builder newBuilderForType(com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { - Builder builder = new Builder(parent); - return builder; - } - /** - * - * - *
-   * Request for `UnbindDeviceFromGateway`.
-   * 
- * - * Protobuf type {@code google.cloud.iot.v1.UnbindDeviceFromGatewayRequest} - */ - public static final class Builder extends com.google.protobuf.GeneratedMessageV3.Builder - implements - // @@protoc_insertion_point(builder_implements:google.cloud.iot.v1.UnbindDeviceFromGatewayRequest) - com.google.cloud.iot.v1.UnbindDeviceFromGatewayRequestOrBuilder { - public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { - return com.google.cloud.iot.v1.DeviceManagerProto - .internal_static_google_cloud_iot_v1_UnbindDeviceFromGatewayRequest_descriptor; - } - - @java.lang.Override - protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable - internalGetFieldAccessorTable() { - return com.google.cloud.iot.v1.DeviceManagerProto - .internal_static_google_cloud_iot_v1_UnbindDeviceFromGatewayRequest_fieldAccessorTable - .ensureFieldAccessorsInitialized( - com.google.cloud.iot.v1.UnbindDeviceFromGatewayRequest.class, - com.google.cloud.iot.v1.UnbindDeviceFromGatewayRequest.Builder.class); - } - - // Construct using com.google.cloud.iot.v1.UnbindDeviceFromGatewayRequest.newBuilder() - private Builder() {} - - private Builder(com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { - super(parent); - } - - @java.lang.Override - public Builder clear() { - super.clear(); - parent_ = ""; - - gatewayId_ = ""; - - deviceId_ = ""; - - return this; - } - - @java.lang.Override - public com.google.protobuf.Descriptors.Descriptor getDescriptorForType() { - return com.google.cloud.iot.v1.DeviceManagerProto - .internal_static_google_cloud_iot_v1_UnbindDeviceFromGatewayRequest_descriptor; - } - - @java.lang.Override - public com.google.cloud.iot.v1.UnbindDeviceFromGatewayRequest getDefaultInstanceForType() { - return com.google.cloud.iot.v1.UnbindDeviceFromGatewayRequest.getDefaultInstance(); - } - - @java.lang.Override - public com.google.cloud.iot.v1.UnbindDeviceFromGatewayRequest build() { - com.google.cloud.iot.v1.UnbindDeviceFromGatewayRequest result = buildPartial(); - if (!result.isInitialized()) { - throw newUninitializedMessageException(result); - } - return result; - } - - @java.lang.Override - public com.google.cloud.iot.v1.UnbindDeviceFromGatewayRequest buildPartial() { - com.google.cloud.iot.v1.UnbindDeviceFromGatewayRequest result = - new com.google.cloud.iot.v1.UnbindDeviceFromGatewayRequest(this); - result.parent_ = parent_; - result.gatewayId_ = gatewayId_; - result.deviceId_ = deviceId_; - onBuilt(); - return result; - } - - @java.lang.Override - public Builder clone() { - return super.clone(); - } - - @java.lang.Override - public Builder setField( - com.google.protobuf.Descriptors.FieldDescriptor field, java.lang.Object value) { - return super.setField(field, value); - } - - @java.lang.Override - public Builder clearField(com.google.protobuf.Descriptors.FieldDescriptor field) { - return super.clearField(field); - } - - @java.lang.Override - public Builder clearOneof(com.google.protobuf.Descriptors.OneofDescriptor oneof) { - return super.clearOneof(oneof); - } - - @java.lang.Override - public Builder setRepeatedField( - com.google.protobuf.Descriptors.FieldDescriptor field, int index, java.lang.Object value) { - return super.setRepeatedField(field, index, value); - } - - @java.lang.Override - public Builder addRepeatedField( - com.google.protobuf.Descriptors.FieldDescriptor field, java.lang.Object value) { - return super.addRepeatedField(field, value); - } - - @java.lang.Override - public Builder mergeFrom(com.google.protobuf.Message other) { - if (other instanceof com.google.cloud.iot.v1.UnbindDeviceFromGatewayRequest) { - return mergeFrom((com.google.cloud.iot.v1.UnbindDeviceFromGatewayRequest) other); - } else { - super.mergeFrom(other); - return this; - } - } - - public Builder mergeFrom(com.google.cloud.iot.v1.UnbindDeviceFromGatewayRequest other) { - if (other == com.google.cloud.iot.v1.UnbindDeviceFromGatewayRequest.getDefaultInstance()) - return this; - if (!other.getParent().isEmpty()) { - parent_ = other.parent_; - onChanged(); - } - if (!other.getGatewayId().isEmpty()) { - gatewayId_ = other.gatewayId_; - onChanged(); - } - if (!other.getDeviceId().isEmpty()) { - deviceId_ = other.deviceId_; - onChanged(); - } - this.mergeUnknownFields(other.getUnknownFields()); - onChanged(); - return this; - } - - @java.lang.Override - public final boolean isInitialized() { - return true; - } - - @java.lang.Override - public Builder mergeFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - if (extensionRegistry == null) { - throw new java.lang.NullPointerException(); - } - try { - boolean done = false; - while (!done) { - int tag = input.readTag(); - switch (tag) { - case 0: - done = true; - break; - case 10: - { - parent_ = input.readStringRequireUtf8(); - - break; - } // case 10 - case 18: - { - gatewayId_ = input.readStringRequireUtf8(); - - break; - } // case 18 - case 26: - { - deviceId_ = input.readStringRequireUtf8(); - - break; - } // case 26 - default: - { - if (!super.parseUnknownField(input, extensionRegistry, tag)) { - done = true; // was an endgroup tag - } - break; - } // default: - } // switch (tag) - } // while (!done) - } catch (com.google.protobuf.InvalidProtocolBufferException e) { - throw e.unwrapIOException(); - } finally { - onChanged(); - } // finally - return this; - } - - private java.lang.Object parent_ = ""; - /** - * - * - *
-     * Required. The name of the registry. For example,
-     * `projects/example-project/locations/us-central1/registries/my-registry`.
-     * 
- * - * - * string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } - * - * - * @return The parent. - */ - public java.lang.String getParent() { - java.lang.Object ref = parent_; - if (!(ref instanceof java.lang.String)) { - com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; - java.lang.String s = bs.toStringUtf8(); - parent_ = s; - return s; - } else { - return (java.lang.String) ref; - } - } - /** - * - * - *
-     * Required. The name of the registry. For example,
-     * `projects/example-project/locations/us-central1/registries/my-registry`.
-     * 
- * - * - * string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } - * - * - * @return The bytes for parent. - */ - public com.google.protobuf.ByteString getParentBytes() { - java.lang.Object ref = parent_; - if (ref instanceof String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); - parent_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - /** - * - * - *
-     * Required. The name of the registry. For example,
-     * `projects/example-project/locations/us-central1/registries/my-registry`.
-     * 
- * - * - * string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } - * - * - * @param value The parent to set. - * @return This builder for chaining. - */ - public Builder setParent(java.lang.String value) { - if (value == null) { - throw new NullPointerException(); - } - - parent_ = value; - onChanged(); - return this; - } - /** - * - * - *
-     * Required. The name of the registry. For example,
-     * `projects/example-project/locations/us-central1/registries/my-registry`.
-     * 
- * - * - * string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } - * - * - * @return This builder for chaining. - */ - public Builder clearParent() { - - parent_ = getDefaultInstance().getParent(); - onChanged(); - return this; - } - /** - * - * - *
-     * Required. The name of the registry. For example,
-     * `projects/example-project/locations/us-central1/registries/my-registry`.
-     * 
- * - * - * string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } - * - * - * @param value The bytes for parent to set. - * @return This builder for chaining. - */ - public Builder setParentBytes(com.google.protobuf.ByteString value) { - if (value == null) { - throw new NullPointerException(); - } - checkByteStringIsUtf8(value); - - parent_ = value; - onChanged(); - return this; - } - - private java.lang.Object gatewayId_ = ""; - /** - * - * - *
-     * Required. The value of `gateway_id` can be either the device numeric ID or the
-     * user-defined device identifier.
-     * 
- * - * string gateway_id = 2 [(.google.api.field_behavior) = REQUIRED]; - * - * @return The gatewayId. - */ - public java.lang.String getGatewayId() { - java.lang.Object ref = gatewayId_; - if (!(ref instanceof java.lang.String)) { - com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; - java.lang.String s = bs.toStringUtf8(); - gatewayId_ = s; - return s; - } else { - return (java.lang.String) ref; - } - } - /** - * - * - *
-     * Required. The value of `gateway_id` can be either the device numeric ID or the
-     * user-defined device identifier.
-     * 
- * - * string gateway_id = 2 [(.google.api.field_behavior) = REQUIRED]; - * - * @return The bytes for gatewayId. - */ - public com.google.protobuf.ByteString getGatewayIdBytes() { - java.lang.Object ref = gatewayId_; - if (ref instanceof String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); - gatewayId_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - /** - * - * - *
-     * Required. The value of `gateway_id` can be either the device numeric ID or the
-     * user-defined device identifier.
-     * 
- * - * string gateway_id = 2 [(.google.api.field_behavior) = REQUIRED]; - * - * @param value The gatewayId to set. - * @return This builder for chaining. - */ - public Builder setGatewayId(java.lang.String value) { - if (value == null) { - throw new NullPointerException(); - } - - gatewayId_ = value; - onChanged(); - return this; - } - /** - * - * - *
-     * Required. The value of `gateway_id` can be either the device numeric ID or the
-     * user-defined device identifier.
-     * 
- * - * string gateway_id = 2 [(.google.api.field_behavior) = REQUIRED]; - * - * @return This builder for chaining. - */ - public Builder clearGatewayId() { - - gatewayId_ = getDefaultInstance().getGatewayId(); - onChanged(); - return this; - } - /** - * - * - *
-     * Required. The value of `gateway_id` can be either the device numeric ID or the
-     * user-defined device identifier.
-     * 
- * - * string gateway_id = 2 [(.google.api.field_behavior) = REQUIRED]; - * - * @param value The bytes for gatewayId to set. - * @return This builder for chaining. - */ - public Builder setGatewayIdBytes(com.google.protobuf.ByteString value) { - if (value == null) { - throw new NullPointerException(); - } - checkByteStringIsUtf8(value); - - gatewayId_ = value; - onChanged(); - return this; - } - - private java.lang.Object deviceId_ = ""; - /** - * - * - *
-     * Required. The device to disassociate from the specified gateway. The value of
-     * `device_id` can be either the device numeric ID or the user-defined device
-     * identifier.
-     * 
- * - * string device_id = 3 [(.google.api.field_behavior) = REQUIRED]; - * - * @return The deviceId. - */ - public java.lang.String getDeviceId() { - java.lang.Object ref = deviceId_; - if (!(ref instanceof java.lang.String)) { - com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; - java.lang.String s = bs.toStringUtf8(); - deviceId_ = s; - return s; - } else { - return (java.lang.String) ref; - } - } - /** - * - * - *
-     * Required. The device to disassociate from the specified gateway. The value of
-     * `device_id` can be either the device numeric ID or the user-defined device
-     * identifier.
-     * 
- * - * string device_id = 3 [(.google.api.field_behavior) = REQUIRED]; - * - * @return The bytes for deviceId. - */ - public com.google.protobuf.ByteString getDeviceIdBytes() { - java.lang.Object ref = deviceId_; - if (ref instanceof String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); - deviceId_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - /** - * - * - *
-     * Required. The device to disassociate from the specified gateway. The value of
-     * `device_id` can be either the device numeric ID or the user-defined device
-     * identifier.
-     * 
- * - * string device_id = 3 [(.google.api.field_behavior) = REQUIRED]; - * - * @param value The deviceId to set. - * @return This builder for chaining. - */ - public Builder setDeviceId(java.lang.String value) { - if (value == null) { - throw new NullPointerException(); - } - - deviceId_ = value; - onChanged(); - return this; - } - /** - * - * - *
-     * Required. The device to disassociate from the specified gateway. The value of
-     * `device_id` can be either the device numeric ID or the user-defined device
-     * identifier.
-     * 
- * - * string device_id = 3 [(.google.api.field_behavior) = REQUIRED]; - * - * @return This builder for chaining. - */ - public Builder clearDeviceId() { - - deviceId_ = getDefaultInstance().getDeviceId(); - onChanged(); - return this; - } - /** - * - * - *
-     * Required. The device to disassociate from the specified gateway. The value of
-     * `device_id` can be either the device numeric ID or the user-defined device
-     * identifier.
-     * 
- * - * string device_id = 3 [(.google.api.field_behavior) = REQUIRED]; - * - * @param value The bytes for deviceId to set. - * @return This builder for chaining. - */ - public Builder setDeviceIdBytes(com.google.protobuf.ByteString value) { - if (value == null) { - throw new NullPointerException(); - } - checkByteStringIsUtf8(value); - - deviceId_ = value; - onChanged(); - return this; - } - - @java.lang.Override - public final Builder setUnknownFields(final com.google.protobuf.UnknownFieldSet unknownFields) { - return super.setUnknownFields(unknownFields); - } - - @java.lang.Override - public final Builder mergeUnknownFields( - final com.google.protobuf.UnknownFieldSet unknownFields) { - return super.mergeUnknownFields(unknownFields); - } - - // @@protoc_insertion_point(builder_scope:google.cloud.iot.v1.UnbindDeviceFromGatewayRequest) - } - - // @@protoc_insertion_point(class_scope:google.cloud.iot.v1.UnbindDeviceFromGatewayRequest) - private static final com.google.cloud.iot.v1.UnbindDeviceFromGatewayRequest DEFAULT_INSTANCE; - - static { - DEFAULT_INSTANCE = new com.google.cloud.iot.v1.UnbindDeviceFromGatewayRequest(); - } - - public static com.google.cloud.iot.v1.UnbindDeviceFromGatewayRequest getDefaultInstance() { - return DEFAULT_INSTANCE; - } - - private static final com.google.protobuf.Parser PARSER = - new com.google.protobuf.AbstractParser() { - @java.lang.Override - public UnbindDeviceFromGatewayRequest parsePartialFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - Builder builder = newBuilder(); - try { - builder.mergeFrom(input, extensionRegistry); - } catch (com.google.protobuf.InvalidProtocolBufferException e) { - throw e.setUnfinishedMessage(builder.buildPartial()); - } catch (com.google.protobuf.UninitializedMessageException e) { - throw e.asInvalidProtocolBufferException().setUnfinishedMessage(builder.buildPartial()); - } catch (java.io.IOException e) { - throw new com.google.protobuf.InvalidProtocolBufferException(e) - .setUnfinishedMessage(builder.buildPartial()); - } - return builder.buildPartial(); - } - }; - - public static com.google.protobuf.Parser parser() { - return PARSER; - } - - @java.lang.Override - public com.google.protobuf.Parser getParserForType() { - return PARSER; - } - - @java.lang.Override - public com.google.cloud.iot.v1.UnbindDeviceFromGatewayRequest getDefaultInstanceForType() { - return DEFAULT_INSTANCE; - } -} diff --git a/proto-google-cloud-iot-v1/src/main/java/com/google/cloud/iot/v1/UnbindDeviceFromGatewayRequestOrBuilder.java b/proto-google-cloud-iot-v1/src/main/java/com/google/cloud/iot/v1/UnbindDeviceFromGatewayRequestOrBuilder.java deleted file mode 100644 index db01b831..00000000 --- a/proto-google-cloud-iot-v1/src/main/java/com/google/cloud/iot/v1/UnbindDeviceFromGatewayRequestOrBuilder.java +++ /dev/null @@ -1,112 +0,0 @@ -/* - * Copyright 2020 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. - */ -// Generated by the protocol buffer compiler. DO NOT EDIT! -// source: google/cloud/iot/v1/device_manager.proto - -package com.google.cloud.iot.v1; - -public interface UnbindDeviceFromGatewayRequestOrBuilder - extends - // @@protoc_insertion_point(interface_extends:google.cloud.iot.v1.UnbindDeviceFromGatewayRequest) - com.google.protobuf.MessageOrBuilder { - - /** - * - * - *
-   * Required. The name of the registry. For example,
-   * `projects/example-project/locations/us-central1/registries/my-registry`.
-   * 
- * - * - * string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } - * - * - * @return The parent. - */ - java.lang.String getParent(); - /** - * - * - *
-   * Required. The name of the registry. For example,
-   * `projects/example-project/locations/us-central1/registries/my-registry`.
-   * 
- * - * - * string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } - * - * - * @return The bytes for parent. - */ - com.google.protobuf.ByteString getParentBytes(); - - /** - * - * - *
-   * Required. The value of `gateway_id` can be either the device numeric ID or the
-   * user-defined device identifier.
-   * 
- * - * string gateway_id = 2 [(.google.api.field_behavior) = REQUIRED]; - * - * @return The gatewayId. - */ - java.lang.String getGatewayId(); - /** - * - * - *
-   * Required. The value of `gateway_id` can be either the device numeric ID or the
-   * user-defined device identifier.
-   * 
- * - * string gateway_id = 2 [(.google.api.field_behavior) = REQUIRED]; - * - * @return The bytes for gatewayId. - */ - com.google.protobuf.ByteString getGatewayIdBytes(); - - /** - * - * - *
-   * Required. The device to disassociate from the specified gateway. The value of
-   * `device_id` can be either the device numeric ID or the user-defined device
-   * identifier.
-   * 
- * - * string device_id = 3 [(.google.api.field_behavior) = REQUIRED]; - * - * @return The deviceId. - */ - java.lang.String getDeviceId(); - /** - * - * - *
-   * Required. The device to disassociate from the specified gateway. The value of
-   * `device_id` can be either the device numeric ID or the user-defined device
-   * identifier.
-   * 
- * - * string device_id = 3 [(.google.api.field_behavior) = REQUIRED]; - * - * @return The bytes for deviceId. - */ - com.google.protobuf.ByteString getDeviceIdBytes(); -} diff --git a/proto-google-cloud-iot-v1/src/main/java/com/google/cloud/iot/v1/UnbindDeviceFromGatewayResponse.java b/proto-google-cloud-iot-v1/src/main/java/com/google/cloud/iot/v1/UnbindDeviceFromGatewayResponse.java deleted file mode 100644 index 2567e43e..00000000 --- a/proto-google-cloud-iot-v1/src/main/java/com/google/cloud/iot/v1/UnbindDeviceFromGatewayResponse.java +++ /dev/null @@ -1,438 +0,0 @@ -/* - * Copyright 2020 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. - */ -// Generated by the protocol buffer compiler. DO NOT EDIT! -// source: google/cloud/iot/v1/device_manager.proto - -package com.google.cloud.iot.v1; - -/** - * - * - *
- * Response for `UnbindDeviceFromGateway`.
- * 
- * - * Protobuf type {@code google.cloud.iot.v1.UnbindDeviceFromGatewayResponse} - */ -public final class UnbindDeviceFromGatewayResponse extends com.google.protobuf.GeneratedMessageV3 - implements - // @@protoc_insertion_point(message_implements:google.cloud.iot.v1.UnbindDeviceFromGatewayResponse) - UnbindDeviceFromGatewayResponseOrBuilder { - private static final long serialVersionUID = 0L; - // Use UnbindDeviceFromGatewayResponse.newBuilder() to construct. - private UnbindDeviceFromGatewayResponse( - com.google.protobuf.GeneratedMessageV3.Builder builder) { - super(builder); - } - - private UnbindDeviceFromGatewayResponse() {} - - @java.lang.Override - @SuppressWarnings({"unused"}) - protected java.lang.Object newInstance(UnusedPrivateParameter unused) { - return new UnbindDeviceFromGatewayResponse(); - } - - @java.lang.Override - public final com.google.protobuf.UnknownFieldSet getUnknownFields() { - return this.unknownFields; - } - - public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { - return com.google.cloud.iot.v1.DeviceManagerProto - .internal_static_google_cloud_iot_v1_UnbindDeviceFromGatewayResponse_descriptor; - } - - @java.lang.Override - protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable - internalGetFieldAccessorTable() { - return com.google.cloud.iot.v1.DeviceManagerProto - .internal_static_google_cloud_iot_v1_UnbindDeviceFromGatewayResponse_fieldAccessorTable - .ensureFieldAccessorsInitialized( - com.google.cloud.iot.v1.UnbindDeviceFromGatewayResponse.class, - com.google.cloud.iot.v1.UnbindDeviceFromGatewayResponse.Builder.class); - } - - private byte memoizedIsInitialized = -1; - - @java.lang.Override - public final boolean isInitialized() { - byte isInitialized = memoizedIsInitialized; - if (isInitialized == 1) return true; - if (isInitialized == 0) return false; - - memoizedIsInitialized = 1; - return true; - } - - @java.lang.Override - public void writeTo(com.google.protobuf.CodedOutputStream output) throws java.io.IOException { - getUnknownFields().writeTo(output); - } - - @java.lang.Override - public int getSerializedSize() { - int size = memoizedSize; - if (size != -1) return size; - - size = 0; - size += getUnknownFields().getSerializedSize(); - memoizedSize = size; - return size; - } - - @java.lang.Override - public boolean equals(final java.lang.Object obj) { - if (obj == this) { - return true; - } - if (!(obj instanceof com.google.cloud.iot.v1.UnbindDeviceFromGatewayResponse)) { - return super.equals(obj); - } - com.google.cloud.iot.v1.UnbindDeviceFromGatewayResponse other = - (com.google.cloud.iot.v1.UnbindDeviceFromGatewayResponse) obj; - - if (!getUnknownFields().equals(other.getUnknownFields())) return false; - return true; - } - - @java.lang.Override - public int hashCode() { - if (memoizedHashCode != 0) { - return memoizedHashCode; - } - int hash = 41; - hash = (19 * hash) + getDescriptor().hashCode(); - hash = (29 * hash) + getUnknownFields().hashCode(); - memoizedHashCode = hash; - return hash; - } - - public static com.google.cloud.iot.v1.UnbindDeviceFromGatewayResponse parseFrom( - java.nio.ByteBuffer data) throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); - } - - public static com.google.cloud.iot.v1.UnbindDeviceFromGatewayResponse parseFrom( - java.nio.ByteBuffer data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); - } - - public static com.google.cloud.iot.v1.UnbindDeviceFromGatewayResponse parseFrom( - com.google.protobuf.ByteString data) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); - } - - public static com.google.cloud.iot.v1.UnbindDeviceFromGatewayResponse parseFrom( - com.google.protobuf.ByteString data, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); - } - - public static com.google.cloud.iot.v1.UnbindDeviceFromGatewayResponse parseFrom(byte[] data) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); - } - - public static com.google.cloud.iot.v1.UnbindDeviceFromGatewayResponse parseFrom( - byte[] data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); - } - - public static com.google.cloud.iot.v1.UnbindDeviceFromGatewayResponse parseFrom( - java.io.InputStream input) throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input); - } - - public static com.google.cloud.iot.v1.UnbindDeviceFromGatewayResponse parseFrom( - java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3.parseWithIOException( - PARSER, input, extensionRegistry); - } - - public static com.google.cloud.iot.v1.UnbindDeviceFromGatewayResponse parseDelimitedFrom( - java.io.InputStream input) throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3.parseDelimitedWithIOException(PARSER, input); - } - - public static com.google.cloud.iot.v1.UnbindDeviceFromGatewayResponse parseDelimitedFrom( - java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3.parseDelimitedWithIOException( - PARSER, input, extensionRegistry); - } - - public static com.google.cloud.iot.v1.UnbindDeviceFromGatewayResponse parseFrom( - com.google.protobuf.CodedInputStream input) throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input); - } - - public static com.google.cloud.iot.v1.UnbindDeviceFromGatewayResponse parseFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3.parseWithIOException( - PARSER, input, extensionRegistry); - } - - @java.lang.Override - public Builder newBuilderForType() { - return newBuilder(); - } - - public static Builder newBuilder() { - return DEFAULT_INSTANCE.toBuilder(); - } - - public static Builder newBuilder( - com.google.cloud.iot.v1.UnbindDeviceFromGatewayResponse prototype) { - return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); - } - - @java.lang.Override - public Builder toBuilder() { - return this == DEFAULT_INSTANCE ? new Builder() : new Builder().mergeFrom(this); - } - - @java.lang.Override - protected Builder newBuilderForType(com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { - Builder builder = new Builder(parent); - return builder; - } - /** - * - * - *
-   * Response for `UnbindDeviceFromGateway`.
-   * 
- * - * Protobuf type {@code google.cloud.iot.v1.UnbindDeviceFromGatewayResponse} - */ - public static final class Builder extends com.google.protobuf.GeneratedMessageV3.Builder - implements - // @@protoc_insertion_point(builder_implements:google.cloud.iot.v1.UnbindDeviceFromGatewayResponse) - com.google.cloud.iot.v1.UnbindDeviceFromGatewayResponseOrBuilder { - public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { - return com.google.cloud.iot.v1.DeviceManagerProto - .internal_static_google_cloud_iot_v1_UnbindDeviceFromGatewayResponse_descriptor; - } - - @java.lang.Override - protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable - internalGetFieldAccessorTable() { - return com.google.cloud.iot.v1.DeviceManagerProto - .internal_static_google_cloud_iot_v1_UnbindDeviceFromGatewayResponse_fieldAccessorTable - .ensureFieldAccessorsInitialized( - com.google.cloud.iot.v1.UnbindDeviceFromGatewayResponse.class, - com.google.cloud.iot.v1.UnbindDeviceFromGatewayResponse.Builder.class); - } - - // Construct using com.google.cloud.iot.v1.UnbindDeviceFromGatewayResponse.newBuilder() - private Builder() {} - - private Builder(com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { - super(parent); - } - - @java.lang.Override - public Builder clear() { - super.clear(); - return this; - } - - @java.lang.Override - public com.google.protobuf.Descriptors.Descriptor getDescriptorForType() { - return com.google.cloud.iot.v1.DeviceManagerProto - .internal_static_google_cloud_iot_v1_UnbindDeviceFromGatewayResponse_descriptor; - } - - @java.lang.Override - public com.google.cloud.iot.v1.UnbindDeviceFromGatewayResponse getDefaultInstanceForType() { - return com.google.cloud.iot.v1.UnbindDeviceFromGatewayResponse.getDefaultInstance(); - } - - @java.lang.Override - public com.google.cloud.iot.v1.UnbindDeviceFromGatewayResponse build() { - com.google.cloud.iot.v1.UnbindDeviceFromGatewayResponse result = buildPartial(); - if (!result.isInitialized()) { - throw newUninitializedMessageException(result); - } - return result; - } - - @java.lang.Override - public com.google.cloud.iot.v1.UnbindDeviceFromGatewayResponse buildPartial() { - com.google.cloud.iot.v1.UnbindDeviceFromGatewayResponse result = - new com.google.cloud.iot.v1.UnbindDeviceFromGatewayResponse(this); - onBuilt(); - return result; - } - - @java.lang.Override - public Builder clone() { - return super.clone(); - } - - @java.lang.Override - public Builder setField( - com.google.protobuf.Descriptors.FieldDescriptor field, java.lang.Object value) { - return super.setField(field, value); - } - - @java.lang.Override - public Builder clearField(com.google.protobuf.Descriptors.FieldDescriptor field) { - return super.clearField(field); - } - - @java.lang.Override - public Builder clearOneof(com.google.protobuf.Descriptors.OneofDescriptor oneof) { - return super.clearOneof(oneof); - } - - @java.lang.Override - public Builder setRepeatedField( - com.google.protobuf.Descriptors.FieldDescriptor field, int index, java.lang.Object value) { - return super.setRepeatedField(field, index, value); - } - - @java.lang.Override - public Builder addRepeatedField( - com.google.protobuf.Descriptors.FieldDescriptor field, java.lang.Object value) { - return super.addRepeatedField(field, value); - } - - @java.lang.Override - public Builder mergeFrom(com.google.protobuf.Message other) { - if (other instanceof com.google.cloud.iot.v1.UnbindDeviceFromGatewayResponse) { - return mergeFrom((com.google.cloud.iot.v1.UnbindDeviceFromGatewayResponse) other); - } else { - super.mergeFrom(other); - return this; - } - } - - public Builder mergeFrom(com.google.cloud.iot.v1.UnbindDeviceFromGatewayResponse other) { - if (other == com.google.cloud.iot.v1.UnbindDeviceFromGatewayResponse.getDefaultInstance()) - return this; - this.mergeUnknownFields(other.getUnknownFields()); - onChanged(); - return this; - } - - @java.lang.Override - public final boolean isInitialized() { - return true; - } - - @java.lang.Override - public Builder mergeFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - if (extensionRegistry == null) { - throw new java.lang.NullPointerException(); - } - try { - boolean done = false; - while (!done) { - int tag = input.readTag(); - switch (tag) { - case 0: - done = true; - break; - default: - { - if (!super.parseUnknownField(input, extensionRegistry, tag)) { - done = true; // was an endgroup tag - } - break; - } // default: - } // switch (tag) - } // while (!done) - } catch (com.google.protobuf.InvalidProtocolBufferException e) { - throw e.unwrapIOException(); - } finally { - onChanged(); - } // finally - return this; - } - - @java.lang.Override - public final Builder setUnknownFields(final com.google.protobuf.UnknownFieldSet unknownFields) { - return super.setUnknownFields(unknownFields); - } - - @java.lang.Override - public final Builder mergeUnknownFields( - final com.google.protobuf.UnknownFieldSet unknownFields) { - return super.mergeUnknownFields(unknownFields); - } - - // @@protoc_insertion_point(builder_scope:google.cloud.iot.v1.UnbindDeviceFromGatewayResponse) - } - - // @@protoc_insertion_point(class_scope:google.cloud.iot.v1.UnbindDeviceFromGatewayResponse) - private static final com.google.cloud.iot.v1.UnbindDeviceFromGatewayResponse DEFAULT_INSTANCE; - - static { - DEFAULT_INSTANCE = new com.google.cloud.iot.v1.UnbindDeviceFromGatewayResponse(); - } - - public static com.google.cloud.iot.v1.UnbindDeviceFromGatewayResponse getDefaultInstance() { - return DEFAULT_INSTANCE; - } - - private static final com.google.protobuf.Parser PARSER = - new com.google.protobuf.AbstractParser() { - @java.lang.Override - public UnbindDeviceFromGatewayResponse parsePartialFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - Builder builder = newBuilder(); - try { - builder.mergeFrom(input, extensionRegistry); - } catch (com.google.protobuf.InvalidProtocolBufferException e) { - throw e.setUnfinishedMessage(builder.buildPartial()); - } catch (com.google.protobuf.UninitializedMessageException e) { - throw e.asInvalidProtocolBufferException().setUnfinishedMessage(builder.buildPartial()); - } catch (java.io.IOException e) { - throw new com.google.protobuf.InvalidProtocolBufferException(e) - .setUnfinishedMessage(builder.buildPartial()); - } - return builder.buildPartial(); - } - }; - - public static com.google.protobuf.Parser parser() { - return PARSER; - } - - @java.lang.Override - public com.google.protobuf.Parser getParserForType() { - return PARSER; - } - - @java.lang.Override - public com.google.cloud.iot.v1.UnbindDeviceFromGatewayResponse getDefaultInstanceForType() { - return DEFAULT_INSTANCE; - } -} diff --git a/proto-google-cloud-iot-v1/src/main/java/com/google/cloud/iot/v1/UnbindDeviceFromGatewayResponseOrBuilder.java b/proto-google-cloud-iot-v1/src/main/java/com/google/cloud/iot/v1/UnbindDeviceFromGatewayResponseOrBuilder.java deleted file mode 100644 index 52c1371e..00000000 --- a/proto-google-cloud-iot-v1/src/main/java/com/google/cloud/iot/v1/UnbindDeviceFromGatewayResponseOrBuilder.java +++ /dev/null @@ -1,24 +0,0 @@ -/* - * Copyright 2020 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. - */ -// Generated by the protocol buffer compiler. DO NOT EDIT! -// source: google/cloud/iot/v1/device_manager.proto - -package com.google.cloud.iot.v1; - -public interface UnbindDeviceFromGatewayResponseOrBuilder - extends - // @@protoc_insertion_point(interface_extends:google.cloud.iot.v1.UnbindDeviceFromGatewayResponse) - com.google.protobuf.MessageOrBuilder {} diff --git a/proto-google-cloud-iot-v1/src/main/java/com/google/cloud/iot/v1/UpdateDeviceRegistryRequest.java b/proto-google-cloud-iot-v1/src/main/java/com/google/cloud/iot/v1/UpdateDeviceRegistryRequest.java deleted file mode 100644 index 5ea31620..00000000 --- a/proto-google-cloud-iot-v1/src/main/java/com/google/cloud/iot/v1/UpdateDeviceRegistryRequest.java +++ /dev/null @@ -1,1075 +0,0 @@ -/* - * Copyright 2020 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. - */ -// Generated by the protocol buffer compiler. DO NOT EDIT! -// source: google/cloud/iot/v1/device_manager.proto - -package com.google.cloud.iot.v1; - -/** - * - * - *
- * Request for `UpdateDeviceRegistry`.
- * 
- * - * Protobuf type {@code google.cloud.iot.v1.UpdateDeviceRegistryRequest} - */ -public final class UpdateDeviceRegistryRequest extends com.google.protobuf.GeneratedMessageV3 - implements - // @@protoc_insertion_point(message_implements:google.cloud.iot.v1.UpdateDeviceRegistryRequest) - UpdateDeviceRegistryRequestOrBuilder { - private static final long serialVersionUID = 0L; - // Use UpdateDeviceRegistryRequest.newBuilder() to construct. - private UpdateDeviceRegistryRequest(com.google.protobuf.GeneratedMessageV3.Builder builder) { - super(builder); - } - - private UpdateDeviceRegistryRequest() {} - - @java.lang.Override - @SuppressWarnings({"unused"}) - protected java.lang.Object newInstance(UnusedPrivateParameter unused) { - return new UpdateDeviceRegistryRequest(); - } - - @java.lang.Override - public final com.google.protobuf.UnknownFieldSet getUnknownFields() { - return this.unknownFields; - } - - public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { - return com.google.cloud.iot.v1.DeviceManagerProto - .internal_static_google_cloud_iot_v1_UpdateDeviceRegistryRequest_descriptor; - } - - @java.lang.Override - protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable - internalGetFieldAccessorTable() { - return com.google.cloud.iot.v1.DeviceManagerProto - .internal_static_google_cloud_iot_v1_UpdateDeviceRegistryRequest_fieldAccessorTable - .ensureFieldAccessorsInitialized( - com.google.cloud.iot.v1.UpdateDeviceRegistryRequest.class, - com.google.cloud.iot.v1.UpdateDeviceRegistryRequest.Builder.class); - } - - public static final int DEVICE_REGISTRY_FIELD_NUMBER = 1; - private com.google.cloud.iot.v1.DeviceRegistry deviceRegistry_; - /** - * - * - *
-   * Required. The new values for the device registry. The `id` field must be empty, and
-   * the `name` field must indicate the path of the resource. For example,
-   * `projects/example-project/locations/us-central1/registries/my-registry`.
-   * 
- * - * - * .google.cloud.iot.v1.DeviceRegistry device_registry = 1 [(.google.api.field_behavior) = REQUIRED]; - * - * - * @return Whether the deviceRegistry field is set. - */ - @java.lang.Override - public boolean hasDeviceRegistry() { - return deviceRegistry_ != null; - } - /** - * - * - *
-   * Required. The new values for the device registry. The `id` field must be empty, and
-   * the `name` field must indicate the path of the resource. For example,
-   * `projects/example-project/locations/us-central1/registries/my-registry`.
-   * 
- * - * - * .google.cloud.iot.v1.DeviceRegistry device_registry = 1 [(.google.api.field_behavior) = REQUIRED]; - * - * - * @return The deviceRegistry. - */ - @java.lang.Override - public com.google.cloud.iot.v1.DeviceRegistry getDeviceRegistry() { - return deviceRegistry_ == null - ? com.google.cloud.iot.v1.DeviceRegistry.getDefaultInstance() - : deviceRegistry_; - } - /** - * - * - *
-   * Required. The new values for the device registry. The `id` field must be empty, and
-   * the `name` field must indicate the path of the resource. For example,
-   * `projects/example-project/locations/us-central1/registries/my-registry`.
-   * 
- * - * - * .google.cloud.iot.v1.DeviceRegistry device_registry = 1 [(.google.api.field_behavior) = REQUIRED]; - * - */ - @java.lang.Override - public com.google.cloud.iot.v1.DeviceRegistryOrBuilder getDeviceRegistryOrBuilder() { - return getDeviceRegistry(); - } - - public static final int UPDATE_MASK_FIELD_NUMBER = 2; - private com.google.protobuf.FieldMask updateMask_; - /** - * - * - *
-   * Required. Only updates the `device_registry` fields indicated by this mask.
-   * The field mask must not be empty, and it must not contain fields that
-   * are immutable or only set by the server.
-   * Mutable top-level fields: `event_notification_config`, `http_config`,
-   * `mqtt_config`, and `state_notification_config`.
-   * 
- * - * .google.protobuf.FieldMask update_mask = 2 [(.google.api.field_behavior) = REQUIRED]; - * - * - * @return Whether the updateMask field is set. - */ - @java.lang.Override - public boolean hasUpdateMask() { - return updateMask_ != null; - } - /** - * - * - *
-   * Required. Only updates the `device_registry` fields indicated by this mask.
-   * The field mask must not be empty, and it must not contain fields that
-   * are immutable or only set by the server.
-   * Mutable top-level fields: `event_notification_config`, `http_config`,
-   * `mqtt_config`, and `state_notification_config`.
-   * 
- * - * .google.protobuf.FieldMask update_mask = 2 [(.google.api.field_behavior) = REQUIRED]; - * - * - * @return The updateMask. - */ - @java.lang.Override - public com.google.protobuf.FieldMask getUpdateMask() { - return updateMask_ == null ? com.google.protobuf.FieldMask.getDefaultInstance() : updateMask_; - } - /** - * - * - *
-   * Required. Only updates the `device_registry` fields indicated by this mask.
-   * The field mask must not be empty, and it must not contain fields that
-   * are immutable or only set by the server.
-   * Mutable top-level fields: `event_notification_config`, `http_config`,
-   * `mqtt_config`, and `state_notification_config`.
-   * 
- * - * .google.protobuf.FieldMask update_mask = 2 [(.google.api.field_behavior) = REQUIRED]; - * - */ - @java.lang.Override - public com.google.protobuf.FieldMaskOrBuilder getUpdateMaskOrBuilder() { - return getUpdateMask(); - } - - private byte memoizedIsInitialized = -1; - - @java.lang.Override - public final boolean isInitialized() { - byte isInitialized = memoizedIsInitialized; - if (isInitialized == 1) return true; - if (isInitialized == 0) return false; - - memoizedIsInitialized = 1; - return true; - } - - @java.lang.Override - public void writeTo(com.google.protobuf.CodedOutputStream output) throws java.io.IOException { - if (deviceRegistry_ != null) { - output.writeMessage(1, getDeviceRegistry()); - } - if (updateMask_ != null) { - output.writeMessage(2, getUpdateMask()); - } - getUnknownFields().writeTo(output); - } - - @java.lang.Override - public int getSerializedSize() { - int size = memoizedSize; - if (size != -1) return size; - - size = 0; - if (deviceRegistry_ != null) { - size += com.google.protobuf.CodedOutputStream.computeMessageSize(1, getDeviceRegistry()); - } - if (updateMask_ != null) { - size += com.google.protobuf.CodedOutputStream.computeMessageSize(2, getUpdateMask()); - } - size += getUnknownFields().getSerializedSize(); - memoizedSize = size; - return size; - } - - @java.lang.Override - public boolean equals(final java.lang.Object obj) { - if (obj == this) { - return true; - } - if (!(obj instanceof com.google.cloud.iot.v1.UpdateDeviceRegistryRequest)) { - return super.equals(obj); - } - com.google.cloud.iot.v1.UpdateDeviceRegistryRequest other = - (com.google.cloud.iot.v1.UpdateDeviceRegistryRequest) obj; - - if (hasDeviceRegistry() != other.hasDeviceRegistry()) return false; - if (hasDeviceRegistry()) { - if (!getDeviceRegistry().equals(other.getDeviceRegistry())) return false; - } - if (hasUpdateMask() != other.hasUpdateMask()) return false; - if (hasUpdateMask()) { - if (!getUpdateMask().equals(other.getUpdateMask())) return false; - } - if (!getUnknownFields().equals(other.getUnknownFields())) return false; - return true; - } - - @java.lang.Override - public int hashCode() { - if (memoizedHashCode != 0) { - return memoizedHashCode; - } - int hash = 41; - hash = (19 * hash) + getDescriptor().hashCode(); - if (hasDeviceRegistry()) { - hash = (37 * hash) + DEVICE_REGISTRY_FIELD_NUMBER; - hash = (53 * hash) + getDeviceRegistry().hashCode(); - } - if (hasUpdateMask()) { - hash = (37 * hash) + UPDATE_MASK_FIELD_NUMBER; - hash = (53 * hash) + getUpdateMask().hashCode(); - } - hash = (29 * hash) + getUnknownFields().hashCode(); - memoizedHashCode = hash; - return hash; - } - - public static com.google.cloud.iot.v1.UpdateDeviceRegistryRequest parseFrom( - java.nio.ByteBuffer data) throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); - } - - public static com.google.cloud.iot.v1.UpdateDeviceRegistryRequest parseFrom( - java.nio.ByteBuffer data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); - } - - public static com.google.cloud.iot.v1.UpdateDeviceRegistryRequest parseFrom( - com.google.protobuf.ByteString data) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); - } - - public static com.google.cloud.iot.v1.UpdateDeviceRegistryRequest parseFrom( - com.google.protobuf.ByteString data, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); - } - - public static com.google.cloud.iot.v1.UpdateDeviceRegistryRequest parseFrom(byte[] data) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); - } - - public static com.google.cloud.iot.v1.UpdateDeviceRegistryRequest parseFrom( - byte[] data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); - } - - public static com.google.cloud.iot.v1.UpdateDeviceRegistryRequest parseFrom( - java.io.InputStream input) throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input); - } - - public static com.google.cloud.iot.v1.UpdateDeviceRegistryRequest parseFrom( - java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3.parseWithIOException( - PARSER, input, extensionRegistry); - } - - public static com.google.cloud.iot.v1.UpdateDeviceRegistryRequest parseDelimitedFrom( - java.io.InputStream input) throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3.parseDelimitedWithIOException(PARSER, input); - } - - public static com.google.cloud.iot.v1.UpdateDeviceRegistryRequest parseDelimitedFrom( - java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3.parseDelimitedWithIOException( - PARSER, input, extensionRegistry); - } - - public static com.google.cloud.iot.v1.UpdateDeviceRegistryRequest parseFrom( - com.google.protobuf.CodedInputStream input) throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input); - } - - public static com.google.cloud.iot.v1.UpdateDeviceRegistryRequest parseFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3.parseWithIOException( - PARSER, input, extensionRegistry); - } - - @java.lang.Override - public Builder newBuilderForType() { - return newBuilder(); - } - - public static Builder newBuilder() { - return DEFAULT_INSTANCE.toBuilder(); - } - - public static Builder newBuilder(com.google.cloud.iot.v1.UpdateDeviceRegistryRequest prototype) { - return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); - } - - @java.lang.Override - public Builder toBuilder() { - return this == DEFAULT_INSTANCE ? new Builder() : new Builder().mergeFrom(this); - } - - @java.lang.Override - protected Builder newBuilderForType(com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { - Builder builder = new Builder(parent); - return builder; - } - /** - * - * - *
-   * Request for `UpdateDeviceRegistry`.
-   * 
- * - * Protobuf type {@code google.cloud.iot.v1.UpdateDeviceRegistryRequest} - */ - public static final class Builder extends com.google.protobuf.GeneratedMessageV3.Builder - implements - // @@protoc_insertion_point(builder_implements:google.cloud.iot.v1.UpdateDeviceRegistryRequest) - com.google.cloud.iot.v1.UpdateDeviceRegistryRequestOrBuilder { - public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { - return com.google.cloud.iot.v1.DeviceManagerProto - .internal_static_google_cloud_iot_v1_UpdateDeviceRegistryRequest_descriptor; - } - - @java.lang.Override - protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable - internalGetFieldAccessorTable() { - return com.google.cloud.iot.v1.DeviceManagerProto - .internal_static_google_cloud_iot_v1_UpdateDeviceRegistryRequest_fieldAccessorTable - .ensureFieldAccessorsInitialized( - com.google.cloud.iot.v1.UpdateDeviceRegistryRequest.class, - com.google.cloud.iot.v1.UpdateDeviceRegistryRequest.Builder.class); - } - - // Construct using com.google.cloud.iot.v1.UpdateDeviceRegistryRequest.newBuilder() - private Builder() {} - - private Builder(com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { - super(parent); - } - - @java.lang.Override - public Builder clear() { - super.clear(); - if (deviceRegistryBuilder_ == null) { - deviceRegistry_ = null; - } else { - deviceRegistry_ = null; - deviceRegistryBuilder_ = null; - } - if (updateMaskBuilder_ == null) { - updateMask_ = null; - } else { - updateMask_ = null; - updateMaskBuilder_ = null; - } - return this; - } - - @java.lang.Override - public com.google.protobuf.Descriptors.Descriptor getDescriptorForType() { - return com.google.cloud.iot.v1.DeviceManagerProto - .internal_static_google_cloud_iot_v1_UpdateDeviceRegistryRequest_descriptor; - } - - @java.lang.Override - public com.google.cloud.iot.v1.UpdateDeviceRegistryRequest getDefaultInstanceForType() { - return com.google.cloud.iot.v1.UpdateDeviceRegistryRequest.getDefaultInstance(); - } - - @java.lang.Override - public com.google.cloud.iot.v1.UpdateDeviceRegistryRequest build() { - com.google.cloud.iot.v1.UpdateDeviceRegistryRequest result = buildPartial(); - if (!result.isInitialized()) { - throw newUninitializedMessageException(result); - } - return result; - } - - @java.lang.Override - public com.google.cloud.iot.v1.UpdateDeviceRegistryRequest buildPartial() { - com.google.cloud.iot.v1.UpdateDeviceRegistryRequest result = - new com.google.cloud.iot.v1.UpdateDeviceRegistryRequest(this); - if (deviceRegistryBuilder_ == null) { - result.deviceRegistry_ = deviceRegistry_; - } else { - result.deviceRegistry_ = deviceRegistryBuilder_.build(); - } - if (updateMaskBuilder_ == null) { - result.updateMask_ = updateMask_; - } else { - result.updateMask_ = updateMaskBuilder_.build(); - } - onBuilt(); - return result; - } - - @java.lang.Override - public Builder clone() { - return super.clone(); - } - - @java.lang.Override - public Builder setField( - com.google.protobuf.Descriptors.FieldDescriptor field, java.lang.Object value) { - return super.setField(field, value); - } - - @java.lang.Override - public Builder clearField(com.google.protobuf.Descriptors.FieldDescriptor field) { - return super.clearField(field); - } - - @java.lang.Override - public Builder clearOneof(com.google.protobuf.Descriptors.OneofDescriptor oneof) { - return super.clearOneof(oneof); - } - - @java.lang.Override - public Builder setRepeatedField( - com.google.protobuf.Descriptors.FieldDescriptor field, int index, java.lang.Object value) { - return super.setRepeatedField(field, index, value); - } - - @java.lang.Override - public Builder addRepeatedField( - com.google.protobuf.Descriptors.FieldDescriptor field, java.lang.Object value) { - return super.addRepeatedField(field, value); - } - - @java.lang.Override - public Builder mergeFrom(com.google.protobuf.Message other) { - if (other instanceof com.google.cloud.iot.v1.UpdateDeviceRegistryRequest) { - return mergeFrom((com.google.cloud.iot.v1.UpdateDeviceRegistryRequest) other); - } else { - super.mergeFrom(other); - return this; - } - } - - public Builder mergeFrom(com.google.cloud.iot.v1.UpdateDeviceRegistryRequest other) { - if (other == com.google.cloud.iot.v1.UpdateDeviceRegistryRequest.getDefaultInstance()) - return this; - if (other.hasDeviceRegistry()) { - mergeDeviceRegistry(other.getDeviceRegistry()); - } - if (other.hasUpdateMask()) { - mergeUpdateMask(other.getUpdateMask()); - } - this.mergeUnknownFields(other.getUnknownFields()); - onChanged(); - return this; - } - - @java.lang.Override - public final boolean isInitialized() { - return true; - } - - @java.lang.Override - public Builder mergeFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - if (extensionRegistry == null) { - throw new java.lang.NullPointerException(); - } - try { - boolean done = false; - while (!done) { - int tag = input.readTag(); - switch (tag) { - case 0: - done = true; - break; - case 10: - { - input.readMessage(getDeviceRegistryFieldBuilder().getBuilder(), extensionRegistry); - - break; - } // case 10 - case 18: - { - input.readMessage(getUpdateMaskFieldBuilder().getBuilder(), extensionRegistry); - - break; - } // case 18 - default: - { - if (!super.parseUnknownField(input, extensionRegistry, tag)) { - done = true; // was an endgroup tag - } - break; - } // default: - } // switch (tag) - } // while (!done) - } catch (com.google.protobuf.InvalidProtocolBufferException e) { - throw e.unwrapIOException(); - } finally { - onChanged(); - } // finally - return this; - } - - private com.google.cloud.iot.v1.DeviceRegistry deviceRegistry_; - private com.google.protobuf.SingleFieldBuilderV3< - com.google.cloud.iot.v1.DeviceRegistry, - com.google.cloud.iot.v1.DeviceRegistry.Builder, - com.google.cloud.iot.v1.DeviceRegistryOrBuilder> - deviceRegistryBuilder_; - /** - * - * - *
-     * Required. The new values for the device registry. The `id` field must be empty, and
-     * the `name` field must indicate the path of the resource. For example,
-     * `projects/example-project/locations/us-central1/registries/my-registry`.
-     * 
- * - * - * .google.cloud.iot.v1.DeviceRegistry device_registry = 1 [(.google.api.field_behavior) = REQUIRED]; - * - * - * @return Whether the deviceRegistry field is set. - */ - public boolean hasDeviceRegistry() { - return deviceRegistryBuilder_ != null || deviceRegistry_ != null; - } - /** - * - * - *
-     * Required. The new values for the device registry. The `id` field must be empty, and
-     * the `name` field must indicate the path of the resource. For example,
-     * `projects/example-project/locations/us-central1/registries/my-registry`.
-     * 
- * - * - * .google.cloud.iot.v1.DeviceRegistry device_registry = 1 [(.google.api.field_behavior) = REQUIRED]; - * - * - * @return The deviceRegistry. - */ - public com.google.cloud.iot.v1.DeviceRegistry getDeviceRegistry() { - if (deviceRegistryBuilder_ == null) { - return deviceRegistry_ == null - ? com.google.cloud.iot.v1.DeviceRegistry.getDefaultInstance() - : deviceRegistry_; - } else { - return deviceRegistryBuilder_.getMessage(); - } - } - /** - * - * - *
-     * Required. The new values for the device registry. The `id` field must be empty, and
-     * the `name` field must indicate the path of the resource. For example,
-     * `projects/example-project/locations/us-central1/registries/my-registry`.
-     * 
- * - * - * .google.cloud.iot.v1.DeviceRegistry device_registry = 1 [(.google.api.field_behavior) = REQUIRED]; - * - */ - public Builder setDeviceRegistry(com.google.cloud.iot.v1.DeviceRegistry value) { - if (deviceRegistryBuilder_ == null) { - if (value == null) { - throw new NullPointerException(); - } - deviceRegistry_ = value; - onChanged(); - } else { - deviceRegistryBuilder_.setMessage(value); - } - - return this; - } - /** - * - * - *
-     * Required. The new values for the device registry. The `id` field must be empty, and
-     * the `name` field must indicate the path of the resource. For example,
-     * `projects/example-project/locations/us-central1/registries/my-registry`.
-     * 
- * - * - * .google.cloud.iot.v1.DeviceRegistry device_registry = 1 [(.google.api.field_behavior) = REQUIRED]; - * - */ - public Builder setDeviceRegistry( - com.google.cloud.iot.v1.DeviceRegistry.Builder builderForValue) { - if (deviceRegistryBuilder_ == null) { - deviceRegistry_ = builderForValue.build(); - onChanged(); - } else { - deviceRegistryBuilder_.setMessage(builderForValue.build()); - } - - return this; - } - /** - * - * - *
-     * Required. The new values for the device registry. The `id` field must be empty, and
-     * the `name` field must indicate the path of the resource. For example,
-     * `projects/example-project/locations/us-central1/registries/my-registry`.
-     * 
- * - * - * .google.cloud.iot.v1.DeviceRegistry device_registry = 1 [(.google.api.field_behavior) = REQUIRED]; - * - */ - public Builder mergeDeviceRegistry(com.google.cloud.iot.v1.DeviceRegistry value) { - if (deviceRegistryBuilder_ == null) { - if (deviceRegistry_ != null) { - deviceRegistry_ = - com.google.cloud.iot.v1.DeviceRegistry.newBuilder(deviceRegistry_) - .mergeFrom(value) - .buildPartial(); - } else { - deviceRegistry_ = value; - } - onChanged(); - } else { - deviceRegistryBuilder_.mergeFrom(value); - } - - return this; - } - /** - * - * - *
-     * Required. The new values for the device registry. The `id` field must be empty, and
-     * the `name` field must indicate the path of the resource. For example,
-     * `projects/example-project/locations/us-central1/registries/my-registry`.
-     * 
- * - * - * .google.cloud.iot.v1.DeviceRegistry device_registry = 1 [(.google.api.field_behavior) = REQUIRED]; - * - */ - public Builder clearDeviceRegistry() { - if (deviceRegistryBuilder_ == null) { - deviceRegistry_ = null; - onChanged(); - } else { - deviceRegistry_ = null; - deviceRegistryBuilder_ = null; - } - - return this; - } - /** - * - * - *
-     * Required. The new values for the device registry. The `id` field must be empty, and
-     * the `name` field must indicate the path of the resource. For example,
-     * `projects/example-project/locations/us-central1/registries/my-registry`.
-     * 
- * - * - * .google.cloud.iot.v1.DeviceRegistry device_registry = 1 [(.google.api.field_behavior) = REQUIRED]; - * - */ - public com.google.cloud.iot.v1.DeviceRegistry.Builder getDeviceRegistryBuilder() { - - onChanged(); - return getDeviceRegistryFieldBuilder().getBuilder(); - } - /** - * - * - *
-     * Required. The new values for the device registry. The `id` field must be empty, and
-     * the `name` field must indicate the path of the resource. For example,
-     * `projects/example-project/locations/us-central1/registries/my-registry`.
-     * 
- * - * - * .google.cloud.iot.v1.DeviceRegistry device_registry = 1 [(.google.api.field_behavior) = REQUIRED]; - * - */ - public com.google.cloud.iot.v1.DeviceRegistryOrBuilder getDeviceRegistryOrBuilder() { - if (deviceRegistryBuilder_ != null) { - return deviceRegistryBuilder_.getMessageOrBuilder(); - } else { - return deviceRegistry_ == null - ? com.google.cloud.iot.v1.DeviceRegistry.getDefaultInstance() - : deviceRegistry_; - } - } - /** - * - * - *
-     * Required. The new values for the device registry. The `id` field must be empty, and
-     * the `name` field must indicate the path of the resource. For example,
-     * `projects/example-project/locations/us-central1/registries/my-registry`.
-     * 
- * - * - * .google.cloud.iot.v1.DeviceRegistry device_registry = 1 [(.google.api.field_behavior) = REQUIRED]; - * - */ - private com.google.protobuf.SingleFieldBuilderV3< - com.google.cloud.iot.v1.DeviceRegistry, - com.google.cloud.iot.v1.DeviceRegistry.Builder, - com.google.cloud.iot.v1.DeviceRegistryOrBuilder> - getDeviceRegistryFieldBuilder() { - if (deviceRegistryBuilder_ == null) { - deviceRegistryBuilder_ = - new com.google.protobuf.SingleFieldBuilderV3< - com.google.cloud.iot.v1.DeviceRegistry, - com.google.cloud.iot.v1.DeviceRegistry.Builder, - com.google.cloud.iot.v1.DeviceRegistryOrBuilder>( - getDeviceRegistry(), getParentForChildren(), isClean()); - deviceRegistry_ = null; - } - return deviceRegistryBuilder_; - } - - private com.google.protobuf.FieldMask updateMask_; - private com.google.protobuf.SingleFieldBuilderV3< - com.google.protobuf.FieldMask, - com.google.protobuf.FieldMask.Builder, - com.google.protobuf.FieldMaskOrBuilder> - updateMaskBuilder_; - /** - * - * - *
-     * Required. Only updates the `device_registry` fields indicated by this mask.
-     * The field mask must not be empty, and it must not contain fields that
-     * are immutable or only set by the server.
-     * Mutable top-level fields: `event_notification_config`, `http_config`,
-     * `mqtt_config`, and `state_notification_config`.
-     * 
- * - * .google.protobuf.FieldMask update_mask = 2 [(.google.api.field_behavior) = REQUIRED]; - * - * - * @return Whether the updateMask field is set. - */ - public boolean hasUpdateMask() { - return updateMaskBuilder_ != null || updateMask_ != null; - } - /** - * - * - *
-     * Required. Only updates the `device_registry` fields indicated by this mask.
-     * The field mask must not be empty, and it must not contain fields that
-     * are immutable or only set by the server.
-     * Mutable top-level fields: `event_notification_config`, `http_config`,
-     * `mqtt_config`, and `state_notification_config`.
-     * 
- * - * .google.protobuf.FieldMask update_mask = 2 [(.google.api.field_behavior) = REQUIRED]; - * - * - * @return The updateMask. - */ - public com.google.protobuf.FieldMask getUpdateMask() { - if (updateMaskBuilder_ == null) { - return updateMask_ == null - ? com.google.protobuf.FieldMask.getDefaultInstance() - : updateMask_; - } else { - return updateMaskBuilder_.getMessage(); - } - } - /** - * - * - *
-     * Required. Only updates the `device_registry` fields indicated by this mask.
-     * The field mask must not be empty, and it must not contain fields that
-     * are immutable or only set by the server.
-     * Mutable top-level fields: `event_notification_config`, `http_config`,
-     * `mqtt_config`, and `state_notification_config`.
-     * 
- * - * .google.protobuf.FieldMask update_mask = 2 [(.google.api.field_behavior) = REQUIRED]; - * - */ - public Builder setUpdateMask(com.google.protobuf.FieldMask value) { - if (updateMaskBuilder_ == null) { - if (value == null) { - throw new NullPointerException(); - } - updateMask_ = value; - onChanged(); - } else { - updateMaskBuilder_.setMessage(value); - } - - return this; - } - /** - * - * - *
-     * Required. Only updates the `device_registry` fields indicated by this mask.
-     * The field mask must not be empty, and it must not contain fields that
-     * are immutable or only set by the server.
-     * Mutable top-level fields: `event_notification_config`, `http_config`,
-     * `mqtt_config`, and `state_notification_config`.
-     * 
- * - * .google.protobuf.FieldMask update_mask = 2 [(.google.api.field_behavior) = REQUIRED]; - * - */ - public Builder setUpdateMask(com.google.protobuf.FieldMask.Builder builderForValue) { - if (updateMaskBuilder_ == null) { - updateMask_ = builderForValue.build(); - onChanged(); - } else { - updateMaskBuilder_.setMessage(builderForValue.build()); - } - - return this; - } - /** - * - * - *
-     * Required. Only updates the `device_registry` fields indicated by this mask.
-     * The field mask must not be empty, and it must not contain fields that
-     * are immutable or only set by the server.
-     * Mutable top-level fields: `event_notification_config`, `http_config`,
-     * `mqtt_config`, and `state_notification_config`.
-     * 
- * - * .google.protobuf.FieldMask update_mask = 2 [(.google.api.field_behavior) = REQUIRED]; - * - */ - public Builder mergeUpdateMask(com.google.protobuf.FieldMask value) { - if (updateMaskBuilder_ == null) { - if (updateMask_ != null) { - updateMask_ = - com.google.protobuf.FieldMask.newBuilder(updateMask_).mergeFrom(value).buildPartial(); - } else { - updateMask_ = value; - } - onChanged(); - } else { - updateMaskBuilder_.mergeFrom(value); - } - - return this; - } - /** - * - * - *
-     * Required. Only updates the `device_registry` fields indicated by this mask.
-     * The field mask must not be empty, and it must not contain fields that
-     * are immutable or only set by the server.
-     * Mutable top-level fields: `event_notification_config`, `http_config`,
-     * `mqtt_config`, and `state_notification_config`.
-     * 
- * - * .google.protobuf.FieldMask update_mask = 2 [(.google.api.field_behavior) = REQUIRED]; - * - */ - public Builder clearUpdateMask() { - if (updateMaskBuilder_ == null) { - updateMask_ = null; - onChanged(); - } else { - updateMask_ = null; - updateMaskBuilder_ = null; - } - - return this; - } - /** - * - * - *
-     * Required. Only updates the `device_registry` fields indicated by this mask.
-     * The field mask must not be empty, and it must not contain fields that
-     * are immutable or only set by the server.
-     * Mutable top-level fields: `event_notification_config`, `http_config`,
-     * `mqtt_config`, and `state_notification_config`.
-     * 
- * - * .google.protobuf.FieldMask update_mask = 2 [(.google.api.field_behavior) = REQUIRED]; - * - */ - public com.google.protobuf.FieldMask.Builder getUpdateMaskBuilder() { - - onChanged(); - return getUpdateMaskFieldBuilder().getBuilder(); - } - /** - * - * - *
-     * Required. Only updates the `device_registry` fields indicated by this mask.
-     * The field mask must not be empty, and it must not contain fields that
-     * are immutable or only set by the server.
-     * Mutable top-level fields: `event_notification_config`, `http_config`,
-     * `mqtt_config`, and `state_notification_config`.
-     * 
- * - * .google.protobuf.FieldMask update_mask = 2 [(.google.api.field_behavior) = REQUIRED]; - * - */ - public com.google.protobuf.FieldMaskOrBuilder getUpdateMaskOrBuilder() { - if (updateMaskBuilder_ != null) { - return updateMaskBuilder_.getMessageOrBuilder(); - } else { - return updateMask_ == null - ? com.google.protobuf.FieldMask.getDefaultInstance() - : updateMask_; - } - } - /** - * - * - *
-     * Required. Only updates the `device_registry` fields indicated by this mask.
-     * The field mask must not be empty, and it must not contain fields that
-     * are immutable or only set by the server.
-     * Mutable top-level fields: `event_notification_config`, `http_config`,
-     * `mqtt_config`, and `state_notification_config`.
-     * 
- * - * .google.protobuf.FieldMask update_mask = 2 [(.google.api.field_behavior) = REQUIRED]; - * - */ - private com.google.protobuf.SingleFieldBuilderV3< - com.google.protobuf.FieldMask, - com.google.protobuf.FieldMask.Builder, - com.google.protobuf.FieldMaskOrBuilder> - getUpdateMaskFieldBuilder() { - if (updateMaskBuilder_ == null) { - updateMaskBuilder_ = - new com.google.protobuf.SingleFieldBuilderV3< - com.google.protobuf.FieldMask, - com.google.protobuf.FieldMask.Builder, - com.google.protobuf.FieldMaskOrBuilder>( - getUpdateMask(), getParentForChildren(), isClean()); - updateMask_ = null; - } - return updateMaskBuilder_; - } - - @java.lang.Override - public final Builder setUnknownFields(final com.google.protobuf.UnknownFieldSet unknownFields) { - return super.setUnknownFields(unknownFields); - } - - @java.lang.Override - public final Builder mergeUnknownFields( - final com.google.protobuf.UnknownFieldSet unknownFields) { - return super.mergeUnknownFields(unknownFields); - } - - // @@protoc_insertion_point(builder_scope:google.cloud.iot.v1.UpdateDeviceRegistryRequest) - } - - // @@protoc_insertion_point(class_scope:google.cloud.iot.v1.UpdateDeviceRegistryRequest) - private static final com.google.cloud.iot.v1.UpdateDeviceRegistryRequest DEFAULT_INSTANCE; - - static { - DEFAULT_INSTANCE = new com.google.cloud.iot.v1.UpdateDeviceRegistryRequest(); - } - - public static com.google.cloud.iot.v1.UpdateDeviceRegistryRequest getDefaultInstance() { - return DEFAULT_INSTANCE; - } - - private static final com.google.protobuf.Parser PARSER = - new com.google.protobuf.AbstractParser() { - @java.lang.Override - public UpdateDeviceRegistryRequest parsePartialFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - Builder builder = newBuilder(); - try { - builder.mergeFrom(input, extensionRegistry); - } catch (com.google.protobuf.InvalidProtocolBufferException e) { - throw e.setUnfinishedMessage(builder.buildPartial()); - } catch (com.google.protobuf.UninitializedMessageException e) { - throw e.asInvalidProtocolBufferException().setUnfinishedMessage(builder.buildPartial()); - } catch (java.io.IOException e) { - throw new com.google.protobuf.InvalidProtocolBufferException(e) - .setUnfinishedMessage(builder.buildPartial()); - } - return builder.buildPartial(); - } - }; - - public static com.google.protobuf.Parser parser() { - return PARSER; - } - - @java.lang.Override - public com.google.protobuf.Parser getParserForType() { - return PARSER; - } - - @java.lang.Override - public com.google.cloud.iot.v1.UpdateDeviceRegistryRequest getDefaultInstanceForType() { - return DEFAULT_INSTANCE; - } -} diff --git a/proto-google-cloud-iot-v1/src/main/java/com/google/cloud/iot/v1/UpdateDeviceRegistryRequestOrBuilder.java b/proto-google-cloud-iot-v1/src/main/java/com/google/cloud/iot/v1/UpdateDeviceRegistryRequestOrBuilder.java deleted file mode 100644 index 7fcb8a25..00000000 --- a/proto-google-cloud-iot-v1/src/main/java/com/google/cloud/iot/v1/UpdateDeviceRegistryRequestOrBuilder.java +++ /dev/null @@ -1,122 +0,0 @@ -/* - * Copyright 2020 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. - */ -// Generated by the protocol buffer compiler. DO NOT EDIT! -// source: google/cloud/iot/v1/device_manager.proto - -package com.google.cloud.iot.v1; - -public interface UpdateDeviceRegistryRequestOrBuilder - extends - // @@protoc_insertion_point(interface_extends:google.cloud.iot.v1.UpdateDeviceRegistryRequest) - com.google.protobuf.MessageOrBuilder { - - /** - * - * - *
-   * Required. The new values for the device registry. The `id` field must be empty, and
-   * the `name` field must indicate the path of the resource. For example,
-   * `projects/example-project/locations/us-central1/registries/my-registry`.
-   * 
- * - * - * .google.cloud.iot.v1.DeviceRegistry device_registry = 1 [(.google.api.field_behavior) = REQUIRED]; - * - * - * @return Whether the deviceRegistry field is set. - */ - boolean hasDeviceRegistry(); - /** - * - * - *
-   * Required. The new values for the device registry. The `id` field must be empty, and
-   * the `name` field must indicate the path of the resource. For example,
-   * `projects/example-project/locations/us-central1/registries/my-registry`.
-   * 
- * - * - * .google.cloud.iot.v1.DeviceRegistry device_registry = 1 [(.google.api.field_behavior) = REQUIRED]; - * - * - * @return The deviceRegistry. - */ - com.google.cloud.iot.v1.DeviceRegistry getDeviceRegistry(); - /** - * - * - *
-   * Required. The new values for the device registry. The `id` field must be empty, and
-   * the `name` field must indicate the path of the resource. For example,
-   * `projects/example-project/locations/us-central1/registries/my-registry`.
-   * 
- * - * - * .google.cloud.iot.v1.DeviceRegistry device_registry = 1 [(.google.api.field_behavior) = REQUIRED]; - * - */ - com.google.cloud.iot.v1.DeviceRegistryOrBuilder getDeviceRegistryOrBuilder(); - - /** - * - * - *
-   * Required. Only updates the `device_registry` fields indicated by this mask.
-   * The field mask must not be empty, and it must not contain fields that
-   * are immutable or only set by the server.
-   * Mutable top-level fields: `event_notification_config`, `http_config`,
-   * `mqtt_config`, and `state_notification_config`.
-   * 
- * - * .google.protobuf.FieldMask update_mask = 2 [(.google.api.field_behavior) = REQUIRED]; - * - * - * @return Whether the updateMask field is set. - */ - boolean hasUpdateMask(); - /** - * - * - *
-   * Required. Only updates the `device_registry` fields indicated by this mask.
-   * The field mask must not be empty, and it must not contain fields that
-   * are immutable or only set by the server.
-   * Mutable top-level fields: `event_notification_config`, `http_config`,
-   * `mqtt_config`, and `state_notification_config`.
-   * 
- * - * .google.protobuf.FieldMask update_mask = 2 [(.google.api.field_behavior) = REQUIRED]; - * - * - * @return The updateMask. - */ - com.google.protobuf.FieldMask getUpdateMask(); - /** - * - * - *
-   * Required. Only updates the `device_registry` fields indicated by this mask.
-   * The field mask must not be empty, and it must not contain fields that
-   * are immutable or only set by the server.
-   * Mutable top-level fields: `event_notification_config`, `http_config`,
-   * `mqtt_config`, and `state_notification_config`.
-   * 
- * - * .google.protobuf.FieldMask update_mask = 2 [(.google.api.field_behavior) = REQUIRED]; - * - */ - com.google.protobuf.FieldMaskOrBuilder getUpdateMaskOrBuilder(); -} diff --git a/proto-google-cloud-iot-v1/src/main/java/com/google/cloud/iot/v1/UpdateDeviceRequest.java b/proto-google-cloud-iot-v1/src/main/java/com/google/cloud/iot/v1/UpdateDeviceRequest.java deleted file mode 100644 index 2dc91ad7..00000000 --- a/proto-google-cloud-iot-v1/src/main/java/com/google/cloud/iot/v1/UpdateDeviceRequest.java +++ /dev/null @@ -1,1050 +0,0 @@ -/* - * Copyright 2020 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. - */ -// Generated by the protocol buffer compiler. DO NOT EDIT! -// source: google/cloud/iot/v1/device_manager.proto - -package com.google.cloud.iot.v1; - -/** - * - * - *
- * Request for `UpdateDevice`.
- * 
- * - * Protobuf type {@code google.cloud.iot.v1.UpdateDeviceRequest} - */ -public final class UpdateDeviceRequest extends com.google.protobuf.GeneratedMessageV3 - implements - // @@protoc_insertion_point(message_implements:google.cloud.iot.v1.UpdateDeviceRequest) - UpdateDeviceRequestOrBuilder { - private static final long serialVersionUID = 0L; - // Use UpdateDeviceRequest.newBuilder() to construct. - private UpdateDeviceRequest(com.google.protobuf.GeneratedMessageV3.Builder builder) { - super(builder); - } - - private UpdateDeviceRequest() {} - - @java.lang.Override - @SuppressWarnings({"unused"}) - protected java.lang.Object newInstance(UnusedPrivateParameter unused) { - return new UpdateDeviceRequest(); - } - - @java.lang.Override - public final com.google.protobuf.UnknownFieldSet getUnknownFields() { - return this.unknownFields; - } - - public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { - return com.google.cloud.iot.v1.DeviceManagerProto - .internal_static_google_cloud_iot_v1_UpdateDeviceRequest_descriptor; - } - - @java.lang.Override - protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable - internalGetFieldAccessorTable() { - return com.google.cloud.iot.v1.DeviceManagerProto - .internal_static_google_cloud_iot_v1_UpdateDeviceRequest_fieldAccessorTable - .ensureFieldAccessorsInitialized( - com.google.cloud.iot.v1.UpdateDeviceRequest.class, - com.google.cloud.iot.v1.UpdateDeviceRequest.Builder.class); - } - - public static final int DEVICE_FIELD_NUMBER = 2; - private com.google.cloud.iot.v1.Device device_; - /** - * - * - *
-   * Required. The new values for the device. The `id` and `num_id` fields must
-   * be empty, and the field `name` must specify the name path. For example,
-   * `projects/p0/locations/us-central1/registries/registry0/devices/device0`or
-   * `projects/p0/locations/us-central1/registries/registry0/devices/{num_id}`.
-   * 
- * - * .google.cloud.iot.v1.Device device = 2 [(.google.api.field_behavior) = REQUIRED]; - * - * @return Whether the device field is set. - */ - @java.lang.Override - public boolean hasDevice() { - return device_ != null; - } - /** - * - * - *
-   * Required. The new values for the device. The `id` and `num_id` fields must
-   * be empty, and the field `name` must specify the name path. For example,
-   * `projects/p0/locations/us-central1/registries/registry0/devices/device0`or
-   * `projects/p0/locations/us-central1/registries/registry0/devices/{num_id}`.
-   * 
- * - * .google.cloud.iot.v1.Device device = 2 [(.google.api.field_behavior) = REQUIRED]; - * - * @return The device. - */ - @java.lang.Override - public com.google.cloud.iot.v1.Device getDevice() { - return device_ == null ? com.google.cloud.iot.v1.Device.getDefaultInstance() : device_; - } - /** - * - * - *
-   * Required. The new values for the device. The `id` and `num_id` fields must
-   * be empty, and the field `name` must specify the name path. For example,
-   * `projects/p0/locations/us-central1/registries/registry0/devices/device0`or
-   * `projects/p0/locations/us-central1/registries/registry0/devices/{num_id}`.
-   * 
- * - * .google.cloud.iot.v1.Device device = 2 [(.google.api.field_behavior) = REQUIRED]; - */ - @java.lang.Override - public com.google.cloud.iot.v1.DeviceOrBuilder getDeviceOrBuilder() { - return getDevice(); - } - - public static final int UPDATE_MASK_FIELD_NUMBER = 3; - private com.google.protobuf.FieldMask updateMask_; - /** - * - * - *
-   * Required. Only updates the `device` fields indicated by this mask.
-   * The field mask must not be empty, and it must not contain fields that
-   * are immutable or only set by the server.
-   * Mutable top-level fields: `credentials`, `blocked`, and `metadata`
-   * 
- * - * .google.protobuf.FieldMask update_mask = 3 [(.google.api.field_behavior) = REQUIRED]; - * - * - * @return Whether the updateMask field is set. - */ - @java.lang.Override - public boolean hasUpdateMask() { - return updateMask_ != null; - } - /** - * - * - *
-   * Required. Only updates the `device` fields indicated by this mask.
-   * The field mask must not be empty, and it must not contain fields that
-   * are immutable or only set by the server.
-   * Mutable top-level fields: `credentials`, `blocked`, and `metadata`
-   * 
- * - * .google.protobuf.FieldMask update_mask = 3 [(.google.api.field_behavior) = REQUIRED]; - * - * - * @return The updateMask. - */ - @java.lang.Override - public com.google.protobuf.FieldMask getUpdateMask() { - return updateMask_ == null ? com.google.protobuf.FieldMask.getDefaultInstance() : updateMask_; - } - /** - * - * - *
-   * Required. Only updates the `device` fields indicated by this mask.
-   * The field mask must not be empty, and it must not contain fields that
-   * are immutable or only set by the server.
-   * Mutable top-level fields: `credentials`, `blocked`, and `metadata`
-   * 
- * - * .google.protobuf.FieldMask update_mask = 3 [(.google.api.field_behavior) = REQUIRED]; - * - */ - @java.lang.Override - public com.google.protobuf.FieldMaskOrBuilder getUpdateMaskOrBuilder() { - return getUpdateMask(); - } - - private byte memoizedIsInitialized = -1; - - @java.lang.Override - public final boolean isInitialized() { - byte isInitialized = memoizedIsInitialized; - if (isInitialized == 1) return true; - if (isInitialized == 0) return false; - - memoizedIsInitialized = 1; - return true; - } - - @java.lang.Override - public void writeTo(com.google.protobuf.CodedOutputStream output) throws java.io.IOException { - if (device_ != null) { - output.writeMessage(2, getDevice()); - } - if (updateMask_ != null) { - output.writeMessage(3, getUpdateMask()); - } - getUnknownFields().writeTo(output); - } - - @java.lang.Override - public int getSerializedSize() { - int size = memoizedSize; - if (size != -1) return size; - - size = 0; - if (device_ != null) { - size += com.google.protobuf.CodedOutputStream.computeMessageSize(2, getDevice()); - } - if (updateMask_ != null) { - size += com.google.protobuf.CodedOutputStream.computeMessageSize(3, getUpdateMask()); - } - size += getUnknownFields().getSerializedSize(); - memoizedSize = size; - return size; - } - - @java.lang.Override - public boolean equals(final java.lang.Object obj) { - if (obj == this) { - return true; - } - if (!(obj instanceof com.google.cloud.iot.v1.UpdateDeviceRequest)) { - return super.equals(obj); - } - com.google.cloud.iot.v1.UpdateDeviceRequest other = - (com.google.cloud.iot.v1.UpdateDeviceRequest) obj; - - if (hasDevice() != other.hasDevice()) return false; - if (hasDevice()) { - if (!getDevice().equals(other.getDevice())) return false; - } - if (hasUpdateMask() != other.hasUpdateMask()) return false; - if (hasUpdateMask()) { - if (!getUpdateMask().equals(other.getUpdateMask())) return false; - } - if (!getUnknownFields().equals(other.getUnknownFields())) return false; - return true; - } - - @java.lang.Override - public int hashCode() { - if (memoizedHashCode != 0) { - return memoizedHashCode; - } - int hash = 41; - hash = (19 * hash) + getDescriptor().hashCode(); - if (hasDevice()) { - hash = (37 * hash) + DEVICE_FIELD_NUMBER; - hash = (53 * hash) + getDevice().hashCode(); - } - if (hasUpdateMask()) { - hash = (37 * hash) + UPDATE_MASK_FIELD_NUMBER; - hash = (53 * hash) + getUpdateMask().hashCode(); - } - hash = (29 * hash) + getUnknownFields().hashCode(); - memoizedHashCode = hash; - return hash; - } - - public static com.google.cloud.iot.v1.UpdateDeviceRequest parseFrom(java.nio.ByteBuffer data) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); - } - - public static com.google.cloud.iot.v1.UpdateDeviceRequest parseFrom( - java.nio.ByteBuffer data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); - } - - public static com.google.cloud.iot.v1.UpdateDeviceRequest parseFrom( - com.google.protobuf.ByteString data) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); - } - - public static com.google.cloud.iot.v1.UpdateDeviceRequest parseFrom( - com.google.protobuf.ByteString data, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); - } - - public static com.google.cloud.iot.v1.UpdateDeviceRequest parseFrom(byte[] data) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); - } - - public static com.google.cloud.iot.v1.UpdateDeviceRequest parseFrom( - byte[] data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); - } - - public static com.google.cloud.iot.v1.UpdateDeviceRequest parseFrom(java.io.InputStream input) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input); - } - - public static com.google.cloud.iot.v1.UpdateDeviceRequest parseFrom( - java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3.parseWithIOException( - PARSER, input, extensionRegistry); - } - - public static com.google.cloud.iot.v1.UpdateDeviceRequest parseDelimitedFrom( - java.io.InputStream input) throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3.parseDelimitedWithIOException(PARSER, input); - } - - public static com.google.cloud.iot.v1.UpdateDeviceRequest parseDelimitedFrom( - java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3.parseDelimitedWithIOException( - PARSER, input, extensionRegistry); - } - - public static com.google.cloud.iot.v1.UpdateDeviceRequest parseFrom( - com.google.protobuf.CodedInputStream input) throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input); - } - - public static com.google.cloud.iot.v1.UpdateDeviceRequest parseFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3.parseWithIOException( - PARSER, input, extensionRegistry); - } - - @java.lang.Override - public Builder newBuilderForType() { - return newBuilder(); - } - - public static Builder newBuilder() { - return DEFAULT_INSTANCE.toBuilder(); - } - - public static Builder newBuilder(com.google.cloud.iot.v1.UpdateDeviceRequest prototype) { - return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); - } - - @java.lang.Override - public Builder toBuilder() { - return this == DEFAULT_INSTANCE ? new Builder() : new Builder().mergeFrom(this); - } - - @java.lang.Override - protected Builder newBuilderForType(com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { - Builder builder = new Builder(parent); - return builder; - } - /** - * - * - *
-   * Request for `UpdateDevice`.
-   * 
- * - * Protobuf type {@code google.cloud.iot.v1.UpdateDeviceRequest} - */ - public static final class Builder extends com.google.protobuf.GeneratedMessageV3.Builder - implements - // @@protoc_insertion_point(builder_implements:google.cloud.iot.v1.UpdateDeviceRequest) - com.google.cloud.iot.v1.UpdateDeviceRequestOrBuilder { - public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { - return com.google.cloud.iot.v1.DeviceManagerProto - .internal_static_google_cloud_iot_v1_UpdateDeviceRequest_descriptor; - } - - @java.lang.Override - protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable - internalGetFieldAccessorTable() { - return com.google.cloud.iot.v1.DeviceManagerProto - .internal_static_google_cloud_iot_v1_UpdateDeviceRequest_fieldAccessorTable - .ensureFieldAccessorsInitialized( - com.google.cloud.iot.v1.UpdateDeviceRequest.class, - com.google.cloud.iot.v1.UpdateDeviceRequest.Builder.class); - } - - // Construct using com.google.cloud.iot.v1.UpdateDeviceRequest.newBuilder() - private Builder() {} - - private Builder(com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { - super(parent); - } - - @java.lang.Override - public Builder clear() { - super.clear(); - if (deviceBuilder_ == null) { - device_ = null; - } else { - device_ = null; - deviceBuilder_ = null; - } - if (updateMaskBuilder_ == null) { - updateMask_ = null; - } else { - updateMask_ = null; - updateMaskBuilder_ = null; - } - return this; - } - - @java.lang.Override - public com.google.protobuf.Descriptors.Descriptor getDescriptorForType() { - return com.google.cloud.iot.v1.DeviceManagerProto - .internal_static_google_cloud_iot_v1_UpdateDeviceRequest_descriptor; - } - - @java.lang.Override - public com.google.cloud.iot.v1.UpdateDeviceRequest getDefaultInstanceForType() { - return com.google.cloud.iot.v1.UpdateDeviceRequest.getDefaultInstance(); - } - - @java.lang.Override - public com.google.cloud.iot.v1.UpdateDeviceRequest build() { - com.google.cloud.iot.v1.UpdateDeviceRequest result = buildPartial(); - if (!result.isInitialized()) { - throw newUninitializedMessageException(result); - } - return result; - } - - @java.lang.Override - public com.google.cloud.iot.v1.UpdateDeviceRequest buildPartial() { - com.google.cloud.iot.v1.UpdateDeviceRequest result = - new com.google.cloud.iot.v1.UpdateDeviceRequest(this); - if (deviceBuilder_ == null) { - result.device_ = device_; - } else { - result.device_ = deviceBuilder_.build(); - } - if (updateMaskBuilder_ == null) { - result.updateMask_ = updateMask_; - } else { - result.updateMask_ = updateMaskBuilder_.build(); - } - onBuilt(); - return result; - } - - @java.lang.Override - public Builder clone() { - return super.clone(); - } - - @java.lang.Override - public Builder setField( - com.google.protobuf.Descriptors.FieldDescriptor field, java.lang.Object value) { - return super.setField(field, value); - } - - @java.lang.Override - public Builder clearField(com.google.protobuf.Descriptors.FieldDescriptor field) { - return super.clearField(field); - } - - @java.lang.Override - public Builder clearOneof(com.google.protobuf.Descriptors.OneofDescriptor oneof) { - return super.clearOneof(oneof); - } - - @java.lang.Override - public Builder setRepeatedField( - com.google.protobuf.Descriptors.FieldDescriptor field, int index, java.lang.Object value) { - return super.setRepeatedField(field, index, value); - } - - @java.lang.Override - public Builder addRepeatedField( - com.google.protobuf.Descriptors.FieldDescriptor field, java.lang.Object value) { - return super.addRepeatedField(field, value); - } - - @java.lang.Override - public Builder mergeFrom(com.google.protobuf.Message other) { - if (other instanceof com.google.cloud.iot.v1.UpdateDeviceRequest) { - return mergeFrom((com.google.cloud.iot.v1.UpdateDeviceRequest) other); - } else { - super.mergeFrom(other); - return this; - } - } - - public Builder mergeFrom(com.google.cloud.iot.v1.UpdateDeviceRequest other) { - if (other == com.google.cloud.iot.v1.UpdateDeviceRequest.getDefaultInstance()) return this; - if (other.hasDevice()) { - mergeDevice(other.getDevice()); - } - if (other.hasUpdateMask()) { - mergeUpdateMask(other.getUpdateMask()); - } - this.mergeUnknownFields(other.getUnknownFields()); - onChanged(); - return this; - } - - @java.lang.Override - public final boolean isInitialized() { - return true; - } - - @java.lang.Override - public Builder mergeFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - if (extensionRegistry == null) { - throw new java.lang.NullPointerException(); - } - try { - boolean done = false; - while (!done) { - int tag = input.readTag(); - switch (tag) { - case 0: - done = true; - break; - case 18: - { - input.readMessage(getDeviceFieldBuilder().getBuilder(), extensionRegistry); - - break; - } // case 18 - case 26: - { - input.readMessage(getUpdateMaskFieldBuilder().getBuilder(), extensionRegistry); - - break; - } // case 26 - default: - { - if (!super.parseUnknownField(input, extensionRegistry, tag)) { - done = true; // was an endgroup tag - } - break; - } // default: - } // switch (tag) - } // while (!done) - } catch (com.google.protobuf.InvalidProtocolBufferException e) { - throw e.unwrapIOException(); - } finally { - onChanged(); - } // finally - return this; - } - - private com.google.cloud.iot.v1.Device device_; - private com.google.protobuf.SingleFieldBuilderV3< - com.google.cloud.iot.v1.Device, - com.google.cloud.iot.v1.Device.Builder, - com.google.cloud.iot.v1.DeviceOrBuilder> - deviceBuilder_; - /** - * - * - *
-     * Required. The new values for the device. The `id` and `num_id` fields must
-     * be empty, and the field `name` must specify the name path. For example,
-     * `projects/p0/locations/us-central1/registries/registry0/devices/device0`or
-     * `projects/p0/locations/us-central1/registries/registry0/devices/{num_id}`.
-     * 
- * - * .google.cloud.iot.v1.Device device = 2 [(.google.api.field_behavior) = REQUIRED]; - * - * - * @return Whether the device field is set. - */ - public boolean hasDevice() { - return deviceBuilder_ != null || device_ != null; - } - /** - * - * - *
-     * Required. The new values for the device. The `id` and `num_id` fields must
-     * be empty, and the field `name` must specify the name path. For example,
-     * `projects/p0/locations/us-central1/registries/registry0/devices/device0`or
-     * `projects/p0/locations/us-central1/registries/registry0/devices/{num_id}`.
-     * 
- * - * .google.cloud.iot.v1.Device device = 2 [(.google.api.field_behavior) = REQUIRED]; - * - * - * @return The device. - */ - public com.google.cloud.iot.v1.Device getDevice() { - if (deviceBuilder_ == null) { - return device_ == null ? com.google.cloud.iot.v1.Device.getDefaultInstance() : device_; - } else { - return deviceBuilder_.getMessage(); - } - } - /** - * - * - *
-     * Required. The new values for the device. The `id` and `num_id` fields must
-     * be empty, and the field `name` must specify the name path. For example,
-     * `projects/p0/locations/us-central1/registries/registry0/devices/device0`or
-     * `projects/p0/locations/us-central1/registries/registry0/devices/{num_id}`.
-     * 
- * - * .google.cloud.iot.v1.Device device = 2 [(.google.api.field_behavior) = REQUIRED]; - * - */ - public Builder setDevice(com.google.cloud.iot.v1.Device value) { - if (deviceBuilder_ == null) { - if (value == null) { - throw new NullPointerException(); - } - device_ = value; - onChanged(); - } else { - deviceBuilder_.setMessage(value); - } - - return this; - } - /** - * - * - *
-     * Required. The new values for the device. The `id` and `num_id` fields must
-     * be empty, and the field `name` must specify the name path. For example,
-     * `projects/p0/locations/us-central1/registries/registry0/devices/device0`or
-     * `projects/p0/locations/us-central1/registries/registry0/devices/{num_id}`.
-     * 
- * - * .google.cloud.iot.v1.Device device = 2 [(.google.api.field_behavior) = REQUIRED]; - * - */ - public Builder setDevice(com.google.cloud.iot.v1.Device.Builder builderForValue) { - if (deviceBuilder_ == null) { - device_ = builderForValue.build(); - onChanged(); - } else { - deviceBuilder_.setMessage(builderForValue.build()); - } - - return this; - } - /** - * - * - *
-     * Required. The new values for the device. The `id` and `num_id` fields must
-     * be empty, and the field `name` must specify the name path. For example,
-     * `projects/p0/locations/us-central1/registries/registry0/devices/device0`or
-     * `projects/p0/locations/us-central1/registries/registry0/devices/{num_id}`.
-     * 
- * - * .google.cloud.iot.v1.Device device = 2 [(.google.api.field_behavior) = REQUIRED]; - * - */ - public Builder mergeDevice(com.google.cloud.iot.v1.Device value) { - if (deviceBuilder_ == null) { - if (device_ != null) { - device_ = - com.google.cloud.iot.v1.Device.newBuilder(device_).mergeFrom(value).buildPartial(); - } else { - device_ = value; - } - onChanged(); - } else { - deviceBuilder_.mergeFrom(value); - } - - return this; - } - /** - * - * - *
-     * Required. The new values for the device. The `id` and `num_id` fields must
-     * be empty, and the field `name` must specify the name path. For example,
-     * `projects/p0/locations/us-central1/registries/registry0/devices/device0`or
-     * `projects/p0/locations/us-central1/registries/registry0/devices/{num_id}`.
-     * 
- * - * .google.cloud.iot.v1.Device device = 2 [(.google.api.field_behavior) = REQUIRED]; - * - */ - public Builder clearDevice() { - if (deviceBuilder_ == null) { - device_ = null; - onChanged(); - } else { - device_ = null; - deviceBuilder_ = null; - } - - return this; - } - /** - * - * - *
-     * Required. The new values for the device. The `id` and `num_id` fields must
-     * be empty, and the field `name` must specify the name path. For example,
-     * `projects/p0/locations/us-central1/registries/registry0/devices/device0`or
-     * `projects/p0/locations/us-central1/registries/registry0/devices/{num_id}`.
-     * 
- * - * .google.cloud.iot.v1.Device device = 2 [(.google.api.field_behavior) = REQUIRED]; - * - */ - public com.google.cloud.iot.v1.Device.Builder getDeviceBuilder() { - - onChanged(); - return getDeviceFieldBuilder().getBuilder(); - } - /** - * - * - *
-     * Required. The new values for the device. The `id` and `num_id` fields must
-     * be empty, and the field `name` must specify the name path. For example,
-     * `projects/p0/locations/us-central1/registries/registry0/devices/device0`or
-     * `projects/p0/locations/us-central1/registries/registry0/devices/{num_id}`.
-     * 
- * - * .google.cloud.iot.v1.Device device = 2 [(.google.api.field_behavior) = REQUIRED]; - * - */ - public com.google.cloud.iot.v1.DeviceOrBuilder getDeviceOrBuilder() { - if (deviceBuilder_ != null) { - return deviceBuilder_.getMessageOrBuilder(); - } else { - return device_ == null ? com.google.cloud.iot.v1.Device.getDefaultInstance() : device_; - } - } - /** - * - * - *
-     * Required. The new values for the device. The `id` and `num_id` fields must
-     * be empty, and the field `name` must specify the name path. For example,
-     * `projects/p0/locations/us-central1/registries/registry0/devices/device0`or
-     * `projects/p0/locations/us-central1/registries/registry0/devices/{num_id}`.
-     * 
- * - * .google.cloud.iot.v1.Device device = 2 [(.google.api.field_behavior) = REQUIRED]; - * - */ - private com.google.protobuf.SingleFieldBuilderV3< - com.google.cloud.iot.v1.Device, - com.google.cloud.iot.v1.Device.Builder, - com.google.cloud.iot.v1.DeviceOrBuilder> - getDeviceFieldBuilder() { - if (deviceBuilder_ == null) { - deviceBuilder_ = - new com.google.protobuf.SingleFieldBuilderV3< - com.google.cloud.iot.v1.Device, - com.google.cloud.iot.v1.Device.Builder, - com.google.cloud.iot.v1.DeviceOrBuilder>( - getDevice(), getParentForChildren(), isClean()); - device_ = null; - } - return deviceBuilder_; - } - - private com.google.protobuf.FieldMask updateMask_; - private com.google.protobuf.SingleFieldBuilderV3< - com.google.protobuf.FieldMask, - com.google.protobuf.FieldMask.Builder, - com.google.protobuf.FieldMaskOrBuilder> - updateMaskBuilder_; - /** - * - * - *
-     * Required. Only updates the `device` fields indicated by this mask.
-     * The field mask must not be empty, and it must not contain fields that
-     * are immutable or only set by the server.
-     * Mutable top-level fields: `credentials`, `blocked`, and `metadata`
-     * 
- * - * .google.protobuf.FieldMask update_mask = 3 [(.google.api.field_behavior) = REQUIRED]; - * - * - * @return Whether the updateMask field is set. - */ - public boolean hasUpdateMask() { - return updateMaskBuilder_ != null || updateMask_ != null; - } - /** - * - * - *
-     * Required. Only updates the `device` fields indicated by this mask.
-     * The field mask must not be empty, and it must not contain fields that
-     * are immutable or only set by the server.
-     * Mutable top-level fields: `credentials`, `blocked`, and `metadata`
-     * 
- * - * .google.protobuf.FieldMask update_mask = 3 [(.google.api.field_behavior) = REQUIRED]; - * - * - * @return The updateMask. - */ - public com.google.protobuf.FieldMask getUpdateMask() { - if (updateMaskBuilder_ == null) { - return updateMask_ == null - ? com.google.protobuf.FieldMask.getDefaultInstance() - : updateMask_; - } else { - return updateMaskBuilder_.getMessage(); - } - } - /** - * - * - *
-     * Required. Only updates the `device` fields indicated by this mask.
-     * The field mask must not be empty, and it must not contain fields that
-     * are immutable or only set by the server.
-     * Mutable top-level fields: `credentials`, `blocked`, and `metadata`
-     * 
- * - * .google.protobuf.FieldMask update_mask = 3 [(.google.api.field_behavior) = REQUIRED]; - * - */ - public Builder setUpdateMask(com.google.protobuf.FieldMask value) { - if (updateMaskBuilder_ == null) { - if (value == null) { - throw new NullPointerException(); - } - updateMask_ = value; - onChanged(); - } else { - updateMaskBuilder_.setMessage(value); - } - - return this; - } - /** - * - * - *
-     * Required. Only updates the `device` fields indicated by this mask.
-     * The field mask must not be empty, and it must not contain fields that
-     * are immutable or only set by the server.
-     * Mutable top-level fields: `credentials`, `blocked`, and `metadata`
-     * 
- * - * .google.protobuf.FieldMask update_mask = 3 [(.google.api.field_behavior) = REQUIRED]; - * - */ - public Builder setUpdateMask(com.google.protobuf.FieldMask.Builder builderForValue) { - if (updateMaskBuilder_ == null) { - updateMask_ = builderForValue.build(); - onChanged(); - } else { - updateMaskBuilder_.setMessage(builderForValue.build()); - } - - return this; - } - /** - * - * - *
-     * Required. Only updates the `device` fields indicated by this mask.
-     * The field mask must not be empty, and it must not contain fields that
-     * are immutable or only set by the server.
-     * Mutable top-level fields: `credentials`, `blocked`, and `metadata`
-     * 
- * - * .google.protobuf.FieldMask update_mask = 3 [(.google.api.field_behavior) = REQUIRED]; - * - */ - public Builder mergeUpdateMask(com.google.protobuf.FieldMask value) { - if (updateMaskBuilder_ == null) { - if (updateMask_ != null) { - updateMask_ = - com.google.protobuf.FieldMask.newBuilder(updateMask_).mergeFrom(value).buildPartial(); - } else { - updateMask_ = value; - } - onChanged(); - } else { - updateMaskBuilder_.mergeFrom(value); - } - - return this; - } - /** - * - * - *
-     * Required. Only updates the `device` fields indicated by this mask.
-     * The field mask must not be empty, and it must not contain fields that
-     * are immutable or only set by the server.
-     * Mutable top-level fields: `credentials`, `blocked`, and `metadata`
-     * 
- * - * .google.protobuf.FieldMask update_mask = 3 [(.google.api.field_behavior) = REQUIRED]; - * - */ - public Builder clearUpdateMask() { - if (updateMaskBuilder_ == null) { - updateMask_ = null; - onChanged(); - } else { - updateMask_ = null; - updateMaskBuilder_ = null; - } - - return this; - } - /** - * - * - *
-     * Required. Only updates the `device` fields indicated by this mask.
-     * The field mask must not be empty, and it must not contain fields that
-     * are immutable or only set by the server.
-     * Mutable top-level fields: `credentials`, `blocked`, and `metadata`
-     * 
- * - * .google.protobuf.FieldMask update_mask = 3 [(.google.api.field_behavior) = REQUIRED]; - * - */ - public com.google.protobuf.FieldMask.Builder getUpdateMaskBuilder() { - - onChanged(); - return getUpdateMaskFieldBuilder().getBuilder(); - } - /** - * - * - *
-     * Required. Only updates the `device` fields indicated by this mask.
-     * The field mask must not be empty, and it must not contain fields that
-     * are immutable or only set by the server.
-     * Mutable top-level fields: `credentials`, `blocked`, and `metadata`
-     * 
- * - * .google.protobuf.FieldMask update_mask = 3 [(.google.api.field_behavior) = REQUIRED]; - * - */ - public com.google.protobuf.FieldMaskOrBuilder getUpdateMaskOrBuilder() { - if (updateMaskBuilder_ != null) { - return updateMaskBuilder_.getMessageOrBuilder(); - } else { - return updateMask_ == null - ? com.google.protobuf.FieldMask.getDefaultInstance() - : updateMask_; - } - } - /** - * - * - *
-     * Required. Only updates the `device` fields indicated by this mask.
-     * The field mask must not be empty, and it must not contain fields that
-     * are immutable or only set by the server.
-     * Mutable top-level fields: `credentials`, `blocked`, and `metadata`
-     * 
- * - * .google.protobuf.FieldMask update_mask = 3 [(.google.api.field_behavior) = REQUIRED]; - * - */ - private com.google.protobuf.SingleFieldBuilderV3< - com.google.protobuf.FieldMask, - com.google.protobuf.FieldMask.Builder, - com.google.protobuf.FieldMaskOrBuilder> - getUpdateMaskFieldBuilder() { - if (updateMaskBuilder_ == null) { - updateMaskBuilder_ = - new com.google.protobuf.SingleFieldBuilderV3< - com.google.protobuf.FieldMask, - com.google.protobuf.FieldMask.Builder, - com.google.protobuf.FieldMaskOrBuilder>( - getUpdateMask(), getParentForChildren(), isClean()); - updateMask_ = null; - } - return updateMaskBuilder_; - } - - @java.lang.Override - public final Builder setUnknownFields(final com.google.protobuf.UnknownFieldSet unknownFields) { - return super.setUnknownFields(unknownFields); - } - - @java.lang.Override - public final Builder mergeUnknownFields( - final com.google.protobuf.UnknownFieldSet unknownFields) { - return super.mergeUnknownFields(unknownFields); - } - - // @@protoc_insertion_point(builder_scope:google.cloud.iot.v1.UpdateDeviceRequest) - } - - // @@protoc_insertion_point(class_scope:google.cloud.iot.v1.UpdateDeviceRequest) - private static final com.google.cloud.iot.v1.UpdateDeviceRequest DEFAULT_INSTANCE; - - static { - DEFAULT_INSTANCE = new com.google.cloud.iot.v1.UpdateDeviceRequest(); - } - - public static com.google.cloud.iot.v1.UpdateDeviceRequest getDefaultInstance() { - return DEFAULT_INSTANCE; - } - - private static final com.google.protobuf.Parser PARSER = - new com.google.protobuf.AbstractParser() { - @java.lang.Override - public UpdateDeviceRequest parsePartialFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - Builder builder = newBuilder(); - try { - builder.mergeFrom(input, extensionRegistry); - } catch (com.google.protobuf.InvalidProtocolBufferException e) { - throw e.setUnfinishedMessage(builder.buildPartial()); - } catch (com.google.protobuf.UninitializedMessageException e) { - throw e.asInvalidProtocolBufferException().setUnfinishedMessage(builder.buildPartial()); - } catch (java.io.IOException e) { - throw new com.google.protobuf.InvalidProtocolBufferException(e) - .setUnfinishedMessage(builder.buildPartial()); - } - return builder.buildPartial(); - } - }; - - public static com.google.protobuf.Parser parser() { - return PARSER; - } - - @java.lang.Override - public com.google.protobuf.Parser getParserForType() { - return PARSER; - } - - @java.lang.Override - public com.google.cloud.iot.v1.UpdateDeviceRequest getDefaultInstanceForType() { - return DEFAULT_INSTANCE; - } -} diff --git a/proto-google-cloud-iot-v1/src/main/java/com/google/cloud/iot/v1/UpdateDeviceRequestOrBuilder.java b/proto-google-cloud-iot-v1/src/main/java/com/google/cloud/iot/v1/UpdateDeviceRequestOrBuilder.java deleted file mode 100644 index 8d26fb3f..00000000 --- a/proto-google-cloud-iot-v1/src/main/java/com/google/cloud/iot/v1/UpdateDeviceRequestOrBuilder.java +++ /dev/null @@ -1,116 +0,0 @@ -/* - * Copyright 2020 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. - */ -// Generated by the protocol buffer compiler. DO NOT EDIT! -// source: google/cloud/iot/v1/device_manager.proto - -package com.google.cloud.iot.v1; - -public interface UpdateDeviceRequestOrBuilder - extends - // @@protoc_insertion_point(interface_extends:google.cloud.iot.v1.UpdateDeviceRequest) - com.google.protobuf.MessageOrBuilder { - - /** - * - * - *
-   * Required. The new values for the device. The `id` and `num_id` fields must
-   * be empty, and the field `name` must specify the name path. For example,
-   * `projects/p0/locations/us-central1/registries/registry0/devices/device0`or
-   * `projects/p0/locations/us-central1/registries/registry0/devices/{num_id}`.
-   * 
- * - * .google.cloud.iot.v1.Device device = 2 [(.google.api.field_behavior) = REQUIRED]; - * - * @return Whether the device field is set. - */ - boolean hasDevice(); - /** - * - * - *
-   * Required. The new values for the device. The `id` and `num_id` fields must
-   * be empty, and the field `name` must specify the name path. For example,
-   * `projects/p0/locations/us-central1/registries/registry0/devices/device0`or
-   * `projects/p0/locations/us-central1/registries/registry0/devices/{num_id}`.
-   * 
- * - * .google.cloud.iot.v1.Device device = 2 [(.google.api.field_behavior) = REQUIRED]; - * - * @return The device. - */ - com.google.cloud.iot.v1.Device getDevice(); - /** - * - * - *
-   * Required. The new values for the device. The `id` and `num_id` fields must
-   * be empty, and the field `name` must specify the name path. For example,
-   * `projects/p0/locations/us-central1/registries/registry0/devices/device0`or
-   * `projects/p0/locations/us-central1/registries/registry0/devices/{num_id}`.
-   * 
- * - * .google.cloud.iot.v1.Device device = 2 [(.google.api.field_behavior) = REQUIRED]; - */ - com.google.cloud.iot.v1.DeviceOrBuilder getDeviceOrBuilder(); - - /** - * - * - *
-   * Required. Only updates the `device` fields indicated by this mask.
-   * The field mask must not be empty, and it must not contain fields that
-   * are immutable or only set by the server.
-   * Mutable top-level fields: `credentials`, `blocked`, and `metadata`
-   * 
- * - * .google.protobuf.FieldMask update_mask = 3 [(.google.api.field_behavior) = REQUIRED]; - * - * - * @return Whether the updateMask field is set. - */ - boolean hasUpdateMask(); - /** - * - * - *
-   * Required. Only updates the `device` fields indicated by this mask.
-   * The field mask must not be empty, and it must not contain fields that
-   * are immutable or only set by the server.
-   * Mutable top-level fields: `credentials`, `blocked`, and `metadata`
-   * 
- * - * .google.protobuf.FieldMask update_mask = 3 [(.google.api.field_behavior) = REQUIRED]; - * - * - * @return The updateMask. - */ - com.google.protobuf.FieldMask getUpdateMask(); - /** - * - * - *
-   * Required. Only updates the `device` fields indicated by this mask.
-   * The field mask must not be empty, and it must not contain fields that
-   * are immutable or only set by the server.
-   * Mutable top-level fields: `credentials`, `blocked`, and `metadata`
-   * 
- * - * .google.protobuf.FieldMask update_mask = 3 [(.google.api.field_behavior) = REQUIRED]; - * - */ - com.google.protobuf.FieldMaskOrBuilder getUpdateMaskOrBuilder(); -} diff --git a/proto-google-cloud-iot-v1/src/main/java/com/google/cloud/iot/v1/X509CertificateDetails.java b/proto-google-cloud-iot-v1/src/main/java/com/google/cloud/iot/v1/X509CertificateDetails.java deleted file mode 100644 index 8f67eac4..00000000 --- a/proto-google-cloud-iot-v1/src/main/java/com/google/cloud/iot/v1/X509CertificateDetails.java +++ /dev/null @@ -1,1670 +0,0 @@ -/* - * Copyright 2020 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. - */ -// Generated by the protocol buffer compiler. DO NOT EDIT! -// source: google/cloud/iot/v1/resources.proto - -package com.google.cloud.iot.v1; - -/** - * - * - *
- * Details of an X.509 certificate. For informational purposes only.
- * 
- * - * Protobuf type {@code google.cloud.iot.v1.X509CertificateDetails} - */ -public final class X509CertificateDetails extends com.google.protobuf.GeneratedMessageV3 - implements - // @@protoc_insertion_point(message_implements:google.cloud.iot.v1.X509CertificateDetails) - X509CertificateDetailsOrBuilder { - private static final long serialVersionUID = 0L; - // Use X509CertificateDetails.newBuilder() to construct. - private X509CertificateDetails(com.google.protobuf.GeneratedMessageV3.Builder builder) { - super(builder); - } - - private X509CertificateDetails() { - issuer_ = ""; - subject_ = ""; - signatureAlgorithm_ = ""; - publicKeyType_ = ""; - } - - @java.lang.Override - @SuppressWarnings({"unused"}) - protected java.lang.Object newInstance(UnusedPrivateParameter unused) { - return new X509CertificateDetails(); - } - - @java.lang.Override - public final com.google.protobuf.UnknownFieldSet getUnknownFields() { - return this.unknownFields; - } - - public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { - return com.google.cloud.iot.v1.ResourcesProto - .internal_static_google_cloud_iot_v1_X509CertificateDetails_descriptor; - } - - @java.lang.Override - protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable - internalGetFieldAccessorTable() { - return com.google.cloud.iot.v1.ResourcesProto - .internal_static_google_cloud_iot_v1_X509CertificateDetails_fieldAccessorTable - .ensureFieldAccessorsInitialized( - com.google.cloud.iot.v1.X509CertificateDetails.class, - com.google.cloud.iot.v1.X509CertificateDetails.Builder.class); - } - - public static final int ISSUER_FIELD_NUMBER = 1; - private volatile java.lang.Object issuer_; - /** - * - * - *
-   * The entity that signed the certificate.
-   * 
- * - * string issuer = 1; - * - * @return The issuer. - */ - @java.lang.Override - public java.lang.String getIssuer() { - java.lang.Object ref = issuer_; - if (ref instanceof java.lang.String) { - return (java.lang.String) ref; - } else { - com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; - java.lang.String s = bs.toStringUtf8(); - issuer_ = s; - return s; - } - } - /** - * - * - *
-   * The entity that signed the certificate.
-   * 
- * - * string issuer = 1; - * - * @return The bytes for issuer. - */ - @java.lang.Override - public com.google.protobuf.ByteString getIssuerBytes() { - java.lang.Object ref = issuer_; - if (ref instanceof java.lang.String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); - issuer_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - - public static final int SUBJECT_FIELD_NUMBER = 2; - private volatile java.lang.Object subject_; - /** - * - * - *
-   * The entity the certificate and public key belong to.
-   * 
- * - * string subject = 2; - * - * @return The subject. - */ - @java.lang.Override - public java.lang.String getSubject() { - java.lang.Object ref = subject_; - if (ref instanceof java.lang.String) { - return (java.lang.String) ref; - } else { - com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; - java.lang.String s = bs.toStringUtf8(); - subject_ = s; - return s; - } - } - /** - * - * - *
-   * The entity the certificate and public key belong to.
-   * 
- * - * string subject = 2; - * - * @return The bytes for subject. - */ - @java.lang.Override - public com.google.protobuf.ByteString getSubjectBytes() { - java.lang.Object ref = subject_; - if (ref instanceof java.lang.String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); - subject_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - - public static final int START_TIME_FIELD_NUMBER = 3; - private com.google.protobuf.Timestamp startTime_; - /** - * - * - *
-   * The time the certificate becomes valid.
-   * 
- * - * .google.protobuf.Timestamp start_time = 3; - * - * @return Whether the startTime field is set. - */ - @java.lang.Override - public boolean hasStartTime() { - return startTime_ != null; - } - /** - * - * - *
-   * The time the certificate becomes valid.
-   * 
- * - * .google.protobuf.Timestamp start_time = 3; - * - * @return The startTime. - */ - @java.lang.Override - public com.google.protobuf.Timestamp getStartTime() { - return startTime_ == null ? com.google.protobuf.Timestamp.getDefaultInstance() : startTime_; - } - /** - * - * - *
-   * The time the certificate becomes valid.
-   * 
- * - * .google.protobuf.Timestamp start_time = 3; - */ - @java.lang.Override - public com.google.protobuf.TimestampOrBuilder getStartTimeOrBuilder() { - return getStartTime(); - } - - public static final int EXPIRY_TIME_FIELD_NUMBER = 4; - private com.google.protobuf.Timestamp expiryTime_; - /** - * - * - *
-   * The time the certificate becomes invalid.
-   * 
- * - * .google.protobuf.Timestamp expiry_time = 4; - * - * @return Whether the expiryTime field is set. - */ - @java.lang.Override - public boolean hasExpiryTime() { - return expiryTime_ != null; - } - /** - * - * - *
-   * The time the certificate becomes invalid.
-   * 
- * - * .google.protobuf.Timestamp expiry_time = 4; - * - * @return The expiryTime. - */ - @java.lang.Override - public com.google.protobuf.Timestamp getExpiryTime() { - return expiryTime_ == null ? com.google.protobuf.Timestamp.getDefaultInstance() : expiryTime_; - } - /** - * - * - *
-   * The time the certificate becomes invalid.
-   * 
- * - * .google.protobuf.Timestamp expiry_time = 4; - */ - @java.lang.Override - public com.google.protobuf.TimestampOrBuilder getExpiryTimeOrBuilder() { - return getExpiryTime(); - } - - public static final int SIGNATURE_ALGORITHM_FIELD_NUMBER = 5; - private volatile java.lang.Object signatureAlgorithm_; - /** - * - * - *
-   * The algorithm used to sign the certificate.
-   * 
- * - * string signature_algorithm = 5; - * - * @return The signatureAlgorithm. - */ - @java.lang.Override - public java.lang.String getSignatureAlgorithm() { - java.lang.Object ref = signatureAlgorithm_; - if (ref instanceof java.lang.String) { - return (java.lang.String) ref; - } else { - com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; - java.lang.String s = bs.toStringUtf8(); - signatureAlgorithm_ = s; - return s; - } - } - /** - * - * - *
-   * The algorithm used to sign the certificate.
-   * 
- * - * string signature_algorithm = 5; - * - * @return The bytes for signatureAlgorithm. - */ - @java.lang.Override - public com.google.protobuf.ByteString getSignatureAlgorithmBytes() { - java.lang.Object ref = signatureAlgorithm_; - if (ref instanceof java.lang.String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); - signatureAlgorithm_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - - public static final int PUBLIC_KEY_TYPE_FIELD_NUMBER = 6; - private volatile java.lang.Object publicKeyType_; - /** - * - * - *
-   * The type of public key in the certificate.
-   * 
- * - * string public_key_type = 6; - * - * @return The publicKeyType. - */ - @java.lang.Override - public java.lang.String getPublicKeyType() { - java.lang.Object ref = publicKeyType_; - if (ref instanceof java.lang.String) { - return (java.lang.String) ref; - } else { - com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; - java.lang.String s = bs.toStringUtf8(); - publicKeyType_ = s; - return s; - } - } - /** - * - * - *
-   * The type of public key in the certificate.
-   * 
- * - * string public_key_type = 6; - * - * @return The bytes for publicKeyType. - */ - @java.lang.Override - public com.google.protobuf.ByteString getPublicKeyTypeBytes() { - java.lang.Object ref = publicKeyType_; - if (ref instanceof java.lang.String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); - publicKeyType_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - - private byte memoizedIsInitialized = -1; - - @java.lang.Override - public final boolean isInitialized() { - byte isInitialized = memoizedIsInitialized; - if (isInitialized == 1) return true; - if (isInitialized == 0) return false; - - memoizedIsInitialized = 1; - return true; - } - - @java.lang.Override - public void writeTo(com.google.protobuf.CodedOutputStream output) throws java.io.IOException { - if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(issuer_)) { - com.google.protobuf.GeneratedMessageV3.writeString(output, 1, issuer_); - } - if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(subject_)) { - com.google.protobuf.GeneratedMessageV3.writeString(output, 2, subject_); - } - if (startTime_ != null) { - output.writeMessage(3, getStartTime()); - } - if (expiryTime_ != null) { - output.writeMessage(4, getExpiryTime()); - } - if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(signatureAlgorithm_)) { - com.google.protobuf.GeneratedMessageV3.writeString(output, 5, signatureAlgorithm_); - } - if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(publicKeyType_)) { - com.google.protobuf.GeneratedMessageV3.writeString(output, 6, publicKeyType_); - } - getUnknownFields().writeTo(output); - } - - @java.lang.Override - public int getSerializedSize() { - int size = memoizedSize; - if (size != -1) return size; - - size = 0; - if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(issuer_)) { - size += com.google.protobuf.GeneratedMessageV3.computeStringSize(1, issuer_); - } - if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(subject_)) { - size += com.google.protobuf.GeneratedMessageV3.computeStringSize(2, subject_); - } - if (startTime_ != null) { - size += com.google.protobuf.CodedOutputStream.computeMessageSize(3, getStartTime()); - } - if (expiryTime_ != null) { - size += com.google.protobuf.CodedOutputStream.computeMessageSize(4, getExpiryTime()); - } - if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(signatureAlgorithm_)) { - size += com.google.protobuf.GeneratedMessageV3.computeStringSize(5, signatureAlgorithm_); - } - if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(publicKeyType_)) { - size += com.google.protobuf.GeneratedMessageV3.computeStringSize(6, publicKeyType_); - } - size += getUnknownFields().getSerializedSize(); - memoizedSize = size; - return size; - } - - @java.lang.Override - public boolean equals(final java.lang.Object obj) { - if (obj == this) { - return true; - } - if (!(obj instanceof com.google.cloud.iot.v1.X509CertificateDetails)) { - return super.equals(obj); - } - com.google.cloud.iot.v1.X509CertificateDetails other = - (com.google.cloud.iot.v1.X509CertificateDetails) obj; - - if (!getIssuer().equals(other.getIssuer())) return false; - if (!getSubject().equals(other.getSubject())) return false; - if (hasStartTime() != other.hasStartTime()) return false; - if (hasStartTime()) { - if (!getStartTime().equals(other.getStartTime())) return false; - } - if (hasExpiryTime() != other.hasExpiryTime()) return false; - if (hasExpiryTime()) { - if (!getExpiryTime().equals(other.getExpiryTime())) return false; - } - if (!getSignatureAlgorithm().equals(other.getSignatureAlgorithm())) return false; - if (!getPublicKeyType().equals(other.getPublicKeyType())) return false; - if (!getUnknownFields().equals(other.getUnknownFields())) return false; - return true; - } - - @java.lang.Override - public int hashCode() { - if (memoizedHashCode != 0) { - return memoizedHashCode; - } - int hash = 41; - hash = (19 * hash) + getDescriptor().hashCode(); - hash = (37 * hash) + ISSUER_FIELD_NUMBER; - hash = (53 * hash) + getIssuer().hashCode(); - hash = (37 * hash) + SUBJECT_FIELD_NUMBER; - hash = (53 * hash) + getSubject().hashCode(); - if (hasStartTime()) { - hash = (37 * hash) + START_TIME_FIELD_NUMBER; - hash = (53 * hash) + getStartTime().hashCode(); - } - if (hasExpiryTime()) { - hash = (37 * hash) + EXPIRY_TIME_FIELD_NUMBER; - hash = (53 * hash) + getExpiryTime().hashCode(); - } - hash = (37 * hash) + SIGNATURE_ALGORITHM_FIELD_NUMBER; - hash = (53 * hash) + getSignatureAlgorithm().hashCode(); - hash = (37 * hash) + PUBLIC_KEY_TYPE_FIELD_NUMBER; - hash = (53 * hash) + getPublicKeyType().hashCode(); - hash = (29 * hash) + getUnknownFields().hashCode(); - memoizedHashCode = hash; - return hash; - } - - public static com.google.cloud.iot.v1.X509CertificateDetails parseFrom(java.nio.ByteBuffer data) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); - } - - public static com.google.cloud.iot.v1.X509CertificateDetails parseFrom( - java.nio.ByteBuffer data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); - } - - public static com.google.cloud.iot.v1.X509CertificateDetails parseFrom( - com.google.protobuf.ByteString data) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); - } - - public static com.google.cloud.iot.v1.X509CertificateDetails parseFrom( - com.google.protobuf.ByteString data, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); - } - - public static com.google.cloud.iot.v1.X509CertificateDetails parseFrom(byte[] data) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); - } - - public static com.google.cloud.iot.v1.X509CertificateDetails parseFrom( - byte[] data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); - } - - public static com.google.cloud.iot.v1.X509CertificateDetails parseFrom(java.io.InputStream input) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input); - } - - public static com.google.cloud.iot.v1.X509CertificateDetails parseFrom( - java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3.parseWithIOException( - PARSER, input, extensionRegistry); - } - - public static com.google.cloud.iot.v1.X509CertificateDetails parseDelimitedFrom( - java.io.InputStream input) throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3.parseDelimitedWithIOException(PARSER, input); - } - - public static com.google.cloud.iot.v1.X509CertificateDetails parseDelimitedFrom( - java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3.parseDelimitedWithIOException( - PARSER, input, extensionRegistry); - } - - public static com.google.cloud.iot.v1.X509CertificateDetails parseFrom( - com.google.protobuf.CodedInputStream input) throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input); - } - - public static com.google.cloud.iot.v1.X509CertificateDetails parseFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3.parseWithIOException( - PARSER, input, extensionRegistry); - } - - @java.lang.Override - public Builder newBuilderForType() { - return newBuilder(); - } - - public static Builder newBuilder() { - return DEFAULT_INSTANCE.toBuilder(); - } - - public static Builder newBuilder(com.google.cloud.iot.v1.X509CertificateDetails prototype) { - return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); - } - - @java.lang.Override - public Builder toBuilder() { - return this == DEFAULT_INSTANCE ? new Builder() : new Builder().mergeFrom(this); - } - - @java.lang.Override - protected Builder newBuilderForType(com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { - Builder builder = new Builder(parent); - return builder; - } - /** - * - * - *
-   * Details of an X.509 certificate. For informational purposes only.
-   * 
- * - * Protobuf type {@code google.cloud.iot.v1.X509CertificateDetails} - */ - public static final class Builder extends com.google.protobuf.GeneratedMessageV3.Builder - implements - // @@protoc_insertion_point(builder_implements:google.cloud.iot.v1.X509CertificateDetails) - com.google.cloud.iot.v1.X509CertificateDetailsOrBuilder { - public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { - return com.google.cloud.iot.v1.ResourcesProto - .internal_static_google_cloud_iot_v1_X509CertificateDetails_descriptor; - } - - @java.lang.Override - protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable - internalGetFieldAccessorTable() { - return com.google.cloud.iot.v1.ResourcesProto - .internal_static_google_cloud_iot_v1_X509CertificateDetails_fieldAccessorTable - .ensureFieldAccessorsInitialized( - com.google.cloud.iot.v1.X509CertificateDetails.class, - com.google.cloud.iot.v1.X509CertificateDetails.Builder.class); - } - - // Construct using com.google.cloud.iot.v1.X509CertificateDetails.newBuilder() - private Builder() {} - - private Builder(com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { - super(parent); - } - - @java.lang.Override - public Builder clear() { - super.clear(); - issuer_ = ""; - - subject_ = ""; - - if (startTimeBuilder_ == null) { - startTime_ = null; - } else { - startTime_ = null; - startTimeBuilder_ = null; - } - if (expiryTimeBuilder_ == null) { - expiryTime_ = null; - } else { - expiryTime_ = null; - expiryTimeBuilder_ = null; - } - signatureAlgorithm_ = ""; - - publicKeyType_ = ""; - - return this; - } - - @java.lang.Override - public com.google.protobuf.Descriptors.Descriptor getDescriptorForType() { - return com.google.cloud.iot.v1.ResourcesProto - .internal_static_google_cloud_iot_v1_X509CertificateDetails_descriptor; - } - - @java.lang.Override - public com.google.cloud.iot.v1.X509CertificateDetails getDefaultInstanceForType() { - return com.google.cloud.iot.v1.X509CertificateDetails.getDefaultInstance(); - } - - @java.lang.Override - public com.google.cloud.iot.v1.X509CertificateDetails build() { - com.google.cloud.iot.v1.X509CertificateDetails result = buildPartial(); - if (!result.isInitialized()) { - throw newUninitializedMessageException(result); - } - return result; - } - - @java.lang.Override - public com.google.cloud.iot.v1.X509CertificateDetails buildPartial() { - com.google.cloud.iot.v1.X509CertificateDetails result = - new com.google.cloud.iot.v1.X509CertificateDetails(this); - result.issuer_ = issuer_; - result.subject_ = subject_; - if (startTimeBuilder_ == null) { - result.startTime_ = startTime_; - } else { - result.startTime_ = startTimeBuilder_.build(); - } - if (expiryTimeBuilder_ == null) { - result.expiryTime_ = expiryTime_; - } else { - result.expiryTime_ = expiryTimeBuilder_.build(); - } - result.signatureAlgorithm_ = signatureAlgorithm_; - result.publicKeyType_ = publicKeyType_; - onBuilt(); - return result; - } - - @java.lang.Override - public Builder clone() { - return super.clone(); - } - - @java.lang.Override - public Builder setField( - com.google.protobuf.Descriptors.FieldDescriptor field, java.lang.Object value) { - return super.setField(field, value); - } - - @java.lang.Override - public Builder clearField(com.google.protobuf.Descriptors.FieldDescriptor field) { - return super.clearField(field); - } - - @java.lang.Override - public Builder clearOneof(com.google.protobuf.Descriptors.OneofDescriptor oneof) { - return super.clearOneof(oneof); - } - - @java.lang.Override - public Builder setRepeatedField( - com.google.protobuf.Descriptors.FieldDescriptor field, int index, java.lang.Object value) { - return super.setRepeatedField(field, index, value); - } - - @java.lang.Override - public Builder addRepeatedField( - com.google.protobuf.Descriptors.FieldDescriptor field, java.lang.Object value) { - return super.addRepeatedField(field, value); - } - - @java.lang.Override - public Builder mergeFrom(com.google.protobuf.Message other) { - if (other instanceof com.google.cloud.iot.v1.X509CertificateDetails) { - return mergeFrom((com.google.cloud.iot.v1.X509CertificateDetails) other); - } else { - super.mergeFrom(other); - return this; - } - } - - public Builder mergeFrom(com.google.cloud.iot.v1.X509CertificateDetails other) { - if (other == com.google.cloud.iot.v1.X509CertificateDetails.getDefaultInstance()) return this; - if (!other.getIssuer().isEmpty()) { - issuer_ = other.issuer_; - onChanged(); - } - if (!other.getSubject().isEmpty()) { - subject_ = other.subject_; - onChanged(); - } - if (other.hasStartTime()) { - mergeStartTime(other.getStartTime()); - } - if (other.hasExpiryTime()) { - mergeExpiryTime(other.getExpiryTime()); - } - if (!other.getSignatureAlgorithm().isEmpty()) { - signatureAlgorithm_ = other.signatureAlgorithm_; - onChanged(); - } - if (!other.getPublicKeyType().isEmpty()) { - publicKeyType_ = other.publicKeyType_; - onChanged(); - } - this.mergeUnknownFields(other.getUnknownFields()); - onChanged(); - return this; - } - - @java.lang.Override - public final boolean isInitialized() { - return true; - } - - @java.lang.Override - public Builder mergeFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - if (extensionRegistry == null) { - throw new java.lang.NullPointerException(); - } - try { - boolean done = false; - while (!done) { - int tag = input.readTag(); - switch (tag) { - case 0: - done = true; - break; - case 10: - { - issuer_ = input.readStringRequireUtf8(); - - break; - } // case 10 - case 18: - { - subject_ = input.readStringRequireUtf8(); - - break; - } // case 18 - case 26: - { - input.readMessage(getStartTimeFieldBuilder().getBuilder(), extensionRegistry); - - break; - } // case 26 - case 34: - { - input.readMessage(getExpiryTimeFieldBuilder().getBuilder(), extensionRegistry); - - break; - } // case 34 - case 42: - { - signatureAlgorithm_ = input.readStringRequireUtf8(); - - break; - } // case 42 - case 50: - { - publicKeyType_ = input.readStringRequireUtf8(); - - break; - } // case 50 - default: - { - if (!super.parseUnknownField(input, extensionRegistry, tag)) { - done = true; // was an endgroup tag - } - break; - } // default: - } // switch (tag) - } // while (!done) - } catch (com.google.protobuf.InvalidProtocolBufferException e) { - throw e.unwrapIOException(); - } finally { - onChanged(); - } // finally - return this; - } - - private java.lang.Object issuer_ = ""; - /** - * - * - *
-     * The entity that signed the certificate.
-     * 
- * - * string issuer = 1; - * - * @return The issuer. - */ - public java.lang.String getIssuer() { - java.lang.Object ref = issuer_; - if (!(ref instanceof java.lang.String)) { - com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; - java.lang.String s = bs.toStringUtf8(); - issuer_ = s; - return s; - } else { - return (java.lang.String) ref; - } - } - /** - * - * - *
-     * The entity that signed the certificate.
-     * 
- * - * string issuer = 1; - * - * @return The bytes for issuer. - */ - public com.google.protobuf.ByteString getIssuerBytes() { - java.lang.Object ref = issuer_; - if (ref instanceof String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); - issuer_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - /** - * - * - *
-     * The entity that signed the certificate.
-     * 
- * - * string issuer = 1; - * - * @param value The issuer to set. - * @return This builder for chaining. - */ - public Builder setIssuer(java.lang.String value) { - if (value == null) { - throw new NullPointerException(); - } - - issuer_ = value; - onChanged(); - return this; - } - /** - * - * - *
-     * The entity that signed the certificate.
-     * 
- * - * string issuer = 1; - * - * @return This builder for chaining. - */ - public Builder clearIssuer() { - - issuer_ = getDefaultInstance().getIssuer(); - onChanged(); - return this; - } - /** - * - * - *
-     * The entity that signed the certificate.
-     * 
- * - * string issuer = 1; - * - * @param value The bytes for issuer to set. - * @return This builder for chaining. - */ - public Builder setIssuerBytes(com.google.protobuf.ByteString value) { - if (value == null) { - throw new NullPointerException(); - } - checkByteStringIsUtf8(value); - - issuer_ = value; - onChanged(); - return this; - } - - private java.lang.Object subject_ = ""; - /** - * - * - *
-     * The entity the certificate and public key belong to.
-     * 
- * - * string subject = 2; - * - * @return The subject. - */ - public java.lang.String getSubject() { - java.lang.Object ref = subject_; - if (!(ref instanceof java.lang.String)) { - com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; - java.lang.String s = bs.toStringUtf8(); - subject_ = s; - return s; - } else { - return (java.lang.String) ref; - } - } - /** - * - * - *
-     * The entity the certificate and public key belong to.
-     * 
- * - * string subject = 2; - * - * @return The bytes for subject. - */ - public com.google.protobuf.ByteString getSubjectBytes() { - java.lang.Object ref = subject_; - if (ref instanceof String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); - subject_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - /** - * - * - *
-     * The entity the certificate and public key belong to.
-     * 
- * - * string subject = 2; - * - * @param value The subject to set. - * @return This builder for chaining. - */ - public Builder setSubject(java.lang.String value) { - if (value == null) { - throw new NullPointerException(); - } - - subject_ = value; - onChanged(); - return this; - } - /** - * - * - *
-     * The entity the certificate and public key belong to.
-     * 
- * - * string subject = 2; - * - * @return This builder for chaining. - */ - public Builder clearSubject() { - - subject_ = getDefaultInstance().getSubject(); - onChanged(); - return this; - } - /** - * - * - *
-     * The entity the certificate and public key belong to.
-     * 
- * - * string subject = 2; - * - * @param value The bytes for subject to set. - * @return This builder for chaining. - */ - public Builder setSubjectBytes(com.google.protobuf.ByteString value) { - if (value == null) { - throw new NullPointerException(); - } - checkByteStringIsUtf8(value); - - subject_ = value; - onChanged(); - return this; - } - - private com.google.protobuf.Timestamp startTime_; - private com.google.protobuf.SingleFieldBuilderV3< - com.google.protobuf.Timestamp, - com.google.protobuf.Timestamp.Builder, - com.google.protobuf.TimestampOrBuilder> - startTimeBuilder_; - /** - * - * - *
-     * The time the certificate becomes valid.
-     * 
- * - * .google.protobuf.Timestamp start_time = 3; - * - * @return Whether the startTime field is set. - */ - public boolean hasStartTime() { - return startTimeBuilder_ != null || startTime_ != null; - } - /** - * - * - *
-     * The time the certificate becomes valid.
-     * 
- * - * .google.protobuf.Timestamp start_time = 3; - * - * @return The startTime. - */ - public com.google.protobuf.Timestamp getStartTime() { - if (startTimeBuilder_ == null) { - return startTime_ == null ? com.google.protobuf.Timestamp.getDefaultInstance() : startTime_; - } else { - return startTimeBuilder_.getMessage(); - } - } - /** - * - * - *
-     * The time the certificate becomes valid.
-     * 
- * - * .google.protobuf.Timestamp start_time = 3; - */ - public Builder setStartTime(com.google.protobuf.Timestamp value) { - if (startTimeBuilder_ == null) { - if (value == null) { - throw new NullPointerException(); - } - startTime_ = value; - onChanged(); - } else { - startTimeBuilder_.setMessage(value); - } - - return this; - } - /** - * - * - *
-     * The time the certificate becomes valid.
-     * 
- * - * .google.protobuf.Timestamp start_time = 3; - */ - public Builder setStartTime(com.google.protobuf.Timestamp.Builder builderForValue) { - if (startTimeBuilder_ == null) { - startTime_ = builderForValue.build(); - onChanged(); - } else { - startTimeBuilder_.setMessage(builderForValue.build()); - } - - return this; - } - /** - * - * - *
-     * The time the certificate becomes valid.
-     * 
- * - * .google.protobuf.Timestamp start_time = 3; - */ - public Builder mergeStartTime(com.google.protobuf.Timestamp value) { - if (startTimeBuilder_ == null) { - if (startTime_ != null) { - startTime_ = - com.google.protobuf.Timestamp.newBuilder(startTime_).mergeFrom(value).buildPartial(); - } else { - startTime_ = value; - } - onChanged(); - } else { - startTimeBuilder_.mergeFrom(value); - } - - return this; - } - /** - * - * - *
-     * The time the certificate becomes valid.
-     * 
- * - * .google.protobuf.Timestamp start_time = 3; - */ - public Builder clearStartTime() { - if (startTimeBuilder_ == null) { - startTime_ = null; - onChanged(); - } else { - startTime_ = null; - startTimeBuilder_ = null; - } - - return this; - } - /** - * - * - *
-     * The time the certificate becomes valid.
-     * 
- * - * .google.protobuf.Timestamp start_time = 3; - */ - public com.google.protobuf.Timestamp.Builder getStartTimeBuilder() { - - onChanged(); - return getStartTimeFieldBuilder().getBuilder(); - } - /** - * - * - *
-     * The time the certificate becomes valid.
-     * 
- * - * .google.protobuf.Timestamp start_time = 3; - */ - public com.google.protobuf.TimestampOrBuilder getStartTimeOrBuilder() { - if (startTimeBuilder_ != null) { - return startTimeBuilder_.getMessageOrBuilder(); - } else { - return startTime_ == null ? com.google.protobuf.Timestamp.getDefaultInstance() : startTime_; - } - } - /** - * - * - *
-     * The time the certificate becomes valid.
-     * 
- * - * .google.protobuf.Timestamp start_time = 3; - */ - private com.google.protobuf.SingleFieldBuilderV3< - com.google.protobuf.Timestamp, - com.google.protobuf.Timestamp.Builder, - com.google.protobuf.TimestampOrBuilder> - getStartTimeFieldBuilder() { - if (startTimeBuilder_ == null) { - startTimeBuilder_ = - new com.google.protobuf.SingleFieldBuilderV3< - com.google.protobuf.Timestamp, - com.google.protobuf.Timestamp.Builder, - com.google.protobuf.TimestampOrBuilder>( - getStartTime(), getParentForChildren(), isClean()); - startTime_ = null; - } - return startTimeBuilder_; - } - - private com.google.protobuf.Timestamp expiryTime_; - private com.google.protobuf.SingleFieldBuilderV3< - com.google.protobuf.Timestamp, - com.google.protobuf.Timestamp.Builder, - com.google.protobuf.TimestampOrBuilder> - expiryTimeBuilder_; - /** - * - * - *
-     * The time the certificate becomes invalid.
-     * 
- * - * .google.protobuf.Timestamp expiry_time = 4; - * - * @return Whether the expiryTime field is set. - */ - public boolean hasExpiryTime() { - return expiryTimeBuilder_ != null || expiryTime_ != null; - } - /** - * - * - *
-     * The time the certificate becomes invalid.
-     * 
- * - * .google.protobuf.Timestamp expiry_time = 4; - * - * @return The expiryTime. - */ - public com.google.protobuf.Timestamp getExpiryTime() { - if (expiryTimeBuilder_ == null) { - return expiryTime_ == null - ? com.google.protobuf.Timestamp.getDefaultInstance() - : expiryTime_; - } else { - return expiryTimeBuilder_.getMessage(); - } - } - /** - * - * - *
-     * The time the certificate becomes invalid.
-     * 
- * - * .google.protobuf.Timestamp expiry_time = 4; - */ - public Builder setExpiryTime(com.google.protobuf.Timestamp value) { - if (expiryTimeBuilder_ == null) { - if (value == null) { - throw new NullPointerException(); - } - expiryTime_ = value; - onChanged(); - } else { - expiryTimeBuilder_.setMessage(value); - } - - return this; - } - /** - * - * - *
-     * The time the certificate becomes invalid.
-     * 
- * - * .google.protobuf.Timestamp expiry_time = 4; - */ - public Builder setExpiryTime(com.google.protobuf.Timestamp.Builder builderForValue) { - if (expiryTimeBuilder_ == null) { - expiryTime_ = builderForValue.build(); - onChanged(); - } else { - expiryTimeBuilder_.setMessage(builderForValue.build()); - } - - return this; - } - /** - * - * - *
-     * The time the certificate becomes invalid.
-     * 
- * - * .google.protobuf.Timestamp expiry_time = 4; - */ - public Builder mergeExpiryTime(com.google.protobuf.Timestamp value) { - if (expiryTimeBuilder_ == null) { - if (expiryTime_ != null) { - expiryTime_ = - com.google.protobuf.Timestamp.newBuilder(expiryTime_).mergeFrom(value).buildPartial(); - } else { - expiryTime_ = value; - } - onChanged(); - } else { - expiryTimeBuilder_.mergeFrom(value); - } - - return this; - } - /** - * - * - *
-     * The time the certificate becomes invalid.
-     * 
- * - * .google.protobuf.Timestamp expiry_time = 4; - */ - public Builder clearExpiryTime() { - if (expiryTimeBuilder_ == null) { - expiryTime_ = null; - onChanged(); - } else { - expiryTime_ = null; - expiryTimeBuilder_ = null; - } - - return this; - } - /** - * - * - *
-     * The time the certificate becomes invalid.
-     * 
- * - * .google.protobuf.Timestamp expiry_time = 4; - */ - public com.google.protobuf.Timestamp.Builder getExpiryTimeBuilder() { - - onChanged(); - return getExpiryTimeFieldBuilder().getBuilder(); - } - /** - * - * - *
-     * The time the certificate becomes invalid.
-     * 
- * - * .google.protobuf.Timestamp expiry_time = 4; - */ - public com.google.protobuf.TimestampOrBuilder getExpiryTimeOrBuilder() { - if (expiryTimeBuilder_ != null) { - return expiryTimeBuilder_.getMessageOrBuilder(); - } else { - return expiryTime_ == null - ? com.google.protobuf.Timestamp.getDefaultInstance() - : expiryTime_; - } - } - /** - * - * - *
-     * The time the certificate becomes invalid.
-     * 
- * - * .google.protobuf.Timestamp expiry_time = 4; - */ - private com.google.protobuf.SingleFieldBuilderV3< - com.google.protobuf.Timestamp, - com.google.protobuf.Timestamp.Builder, - com.google.protobuf.TimestampOrBuilder> - getExpiryTimeFieldBuilder() { - if (expiryTimeBuilder_ == null) { - expiryTimeBuilder_ = - new com.google.protobuf.SingleFieldBuilderV3< - com.google.protobuf.Timestamp, - com.google.protobuf.Timestamp.Builder, - com.google.protobuf.TimestampOrBuilder>( - getExpiryTime(), getParentForChildren(), isClean()); - expiryTime_ = null; - } - return expiryTimeBuilder_; - } - - private java.lang.Object signatureAlgorithm_ = ""; - /** - * - * - *
-     * The algorithm used to sign the certificate.
-     * 
- * - * string signature_algorithm = 5; - * - * @return The signatureAlgorithm. - */ - public java.lang.String getSignatureAlgorithm() { - java.lang.Object ref = signatureAlgorithm_; - if (!(ref instanceof java.lang.String)) { - com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; - java.lang.String s = bs.toStringUtf8(); - signatureAlgorithm_ = s; - return s; - } else { - return (java.lang.String) ref; - } - } - /** - * - * - *
-     * The algorithm used to sign the certificate.
-     * 
- * - * string signature_algorithm = 5; - * - * @return The bytes for signatureAlgorithm. - */ - public com.google.protobuf.ByteString getSignatureAlgorithmBytes() { - java.lang.Object ref = signatureAlgorithm_; - if (ref instanceof String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); - signatureAlgorithm_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - /** - * - * - *
-     * The algorithm used to sign the certificate.
-     * 
- * - * string signature_algorithm = 5; - * - * @param value The signatureAlgorithm to set. - * @return This builder for chaining. - */ - public Builder setSignatureAlgorithm(java.lang.String value) { - if (value == null) { - throw new NullPointerException(); - } - - signatureAlgorithm_ = value; - onChanged(); - return this; - } - /** - * - * - *
-     * The algorithm used to sign the certificate.
-     * 
- * - * string signature_algorithm = 5; - * - * @return This builder for chaining. - */ - public Builder clearSignatureAlgorithm() { - - signatureAlgorithm_ = getDefaultInstance().getSignatureAlgorithm(); - onChanged(); - return this; - } - /** - * - * - *
-     * The algorithm used to sign the certificate.
-     * 
- * - * string signature_algorithm = 5; - * - * @param value The bytes for signatureAlgorithm to set. - * @return This builder for chaining. - */ - public Builder setSignatureAlgorithmBytes(com.google.protobuf.ByteString value) { - if (value == null) { - throw new NullPointerException(); - } - checkByteStringIsUtf8(value); - - signatureAlgorithm_ = value; - onChanged(); - return this; - } - - private java.lang.Object publicKeyType_ = ""; - /** - * - * - *
-     * The type of public key in the certificate.
-     * 
- * - * string public_key_type = 6; - * - * @return The publicKeyType. - */ - public java.lang.String getPublicKeyType() { - java.lang.Object ref = publicKeyType_; - if (!(ref instanceof java.lang.String)) { - com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; - java.lang.String s = bs.toStringUtf8(); - publicKeyType_ = s; - return s; - } else { - return (java.lang.String) ref; - } - } - /** - * - * - *
-     * The type of public key in the certificate.
-     * 
- * - * string public_key_type = 6; - * - * @return The bytes for publicKeyType. - */ - public com.google.protobuf.ByteString getPublicKeyTypeBytes() { - java.lang.Object ref = publicKeyType_; - if (ref instanceof String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); - publicKeyType_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - /** - * - * - *
-     * The type of public key in the certificate.
-     * 
- * - * string public_key_type = 6; - * - * @param value The publicKeyType to set. - * @return This builder for chaining. - */ - public Builder setPublicKeyType(java.lang.String value) { - if (value == null) { - throw new NullPointerException(); - } - - publicKeyType_ = value; - onChanged(); - return this; - } - /** - * - * - *
-     * The type of public key in the certificate.
-     * 
- * - * string public_key_type = 6; - * - * @return This builder for chaining. - */ - public Builder clearPublicKeyType() { - - publicKeyType_ = getDefaultInstance().getPublicKeyType(); - onChanged(); - return this; - } - /** - * - * - *
-     * The type of public key in the certificate.
-     * 
- * - * string public_key_type = 6; - * - * @param value The bytes for publicKeyType to set. - * @return This builder for chaining. - */ - public Builder setPublicKeyTypeBytes(com.google.protobuf.ByteString value) { - if (value == null) { - throw new NullPointerException(); - } - checkByteStringIsUtf8(value); - - publicKeyType_ = value; - onChanged(); - return this; - } - - @java.lang.Override - public final Builder setUnknownFields(final com.google.protobuf.UnknownFieldSet unknownFields) { - return super.setUnknownFields(unknownFields); - } - - @java.lang.Override - public final Builder mergeUnknownFields( - final com.google.protobuf.UnknownFieldSet unknownFields) { - return super.mergeUnknownFields(unknownFields); - } - - // @@protoc_insertion_point(builder_scope:google.cloud.iot.v1.X509CertificateDetails) - } - - // @@protoc_insertion_point(class_scope:google.cloud.iot.v1.X509CertificateDetails) - private static final com.google.cloud.iot.v1.X509CertificateDetails DEFAULT_INSTANCE; - - static { - DEFAULT_INSTANCE = new com.google.cloud.iot.v1.X509CertificateDetails(); - } - - public static com.google.cloud.iot.v1.X509CertificateDetails getDefaultInstance() { - return DEFAULT_INSTANCE; - } - - private static final com.google.protobuf.Parser PARSER = - new com.google.protobuf.AbstractParser() { - @java.lang.Override - public X509CertificateDetails parsePartialFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - Builder builder = newBuilder(); - try { - builder.mergeFrom(input, extensionRegistry); - } catch (com.google.protobuf.InvalidProtocolBufferException e) { - throw e.setUnfinishedMessage(builder.buildPartial()); - } catch (com.google.protobuf.UninitializedMessageException e) { - throw e.asInvalidProtocolBufferException().setUnfinishedMessage(builder.buildPartial()); - } catch (java.io.IOException e) { - throw new com.google.protobuf.InvalidProtocolBufferException(e) - .setUnfinishedMessage(builder.buildPartial()); - } - return builder.buildPartial(); - } - }; - - public static com.google.protobuf.Parser parser() { - return PARSER; - } - - @java.lang.Override - public com.google.protobuf.Parser getParserForType() { - return PARSER; - } - - @java.lang.Override - public com.google.cloud.iot.v1.X509CertificateDetails getDefaultInstanceForType() { - return DEFAULT_INSTANCE; - } -} diff --git a/proto-google-cloud-iot-v1/src/main/java/com/google/cloud/iot/v1/X509CertificateDetailsOrBuilder.java b/proto-google-cloud-iot-v1/src/main/java/com/google/cloud/iot/v1/X509CertificateDetailsOrBuilder.java deleted file mode 100644 index 743fff38..00000000 --- a/proto-google-cloud-iot-v1/src/main/java/com/google/cloud/iot/v1/X509CertificateDetailsOrBuilder.java +++ /dev/null @@ -1,195 +0,0 @@ -/* - * Copyright 2020 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. - */ -// Generated by the protocol buffer compiler. DO NOT EDIT! -// source: google/cloud/iot/v1/resources.proto - -package com.google.cloud.iot.v1; - -public interface X509CertificateDetailsOrBuilder - extends - // @@protoc_insertion_point(interface_extends:google.cloud.iot.v1.X509CertificateDetails) - com.google.protobuf.MessageOrBuilder { - - /** - * - * - *
-   * The entity that signed the certificate.
-   * 
- * - * string issuer = 1; - * - * @return The issuer. - */ - java.lang.String getIssuer(); - /** - * - * - *
-   * The entity that signed the certificate.
-   * 
- * - * string issuer = 1; - * - * @return The bytes for issuer. - */ - com.google.protobuf.ByteString getIssuerBytes(); - - /** - * - * - *
-   * The entity the certificate and public key belong to.
-   * 
- * - * string subject = 2; - * - * @return The subject. - */ - java.lang.String getSubject(); - /** - * - * - *
-   * The entity the certificate and public key belong to.
-   * 
- * - * string subject = 2; - * - * @return The bytes for subject. - */ - com.google.protobuf.ByteString getSubjectBytes(); - - /** - * - * - *
-   * The time the certificate becomes valid.
-   * 
- * - * .google.protobuf.Timestamp start_time = 3; - * - * @return Whether the startTime field is set. - */ - boolean hasStartTime(); - /** - * - * - *
-   * The time the certificate becomes valid.
-   * 
- * - * .google.protobuf.Timestamp start_time = 3; - * - * @return The startTime. - */ - com.google.protobuf.Timestamp getStartTime(); - /** - * - * - *
-   * The time the certificate becomes valid.
-   * 
- * - * .google.protobuf.Timestamp start_time = 3; - */ - com.google.protobuf.TimestampOrBuilder getStartTimeOrBuilder(); - - /** - * - * - *
-   * The time the certificate becomes invalid.
-   * 
- * - * .google.protobuf.Timestamp expiry_time = 4; - * - * @return Whether the expiryTime field is set. - */ - boolean hasExpiryTime(); - /** - * - * - *
-   * The time the certificate becomes invalid.
-   * 
- * - * .google.protobuf.Timestamp expiry_time = 4; - * - * @return The expiryTime. - */ - com.google.protobuf.Timestamp getExpiryTime(); - /** - * - * - *
-   * The time the certificate becomes invalid.
-   * 
- * - * .google.protobuf.Timestamp expiry_time = 4; - */ - com.google.protobuf.TimestampOrBuilder getExpiryTimeOrBuilder(); - - /** - * - * - *
-   * The algorithm used to sign the certificate.
-   * 
- * - * string signature_algorithm = 5; - * - * @return The signatureAlgorithm. - */ - java.lang.String getSignatureAlgorithm(); - /** - * - * - *
-   * The algorithm used to sign the certificate.
-   * 
- * - * string signature_algorithm = 5; - * - * @return The bytes for signatureAlgorithm. - */ - com.google.protobuf.ByteString getSignatureAlgorithmBytes(); - - /** - * - * - *
-   * The type of public key in the certificate.
-   * 
- * - * string public_key_type = 6; - * - * @return The publicKeyType. - */ - java.lang.String getPublicKeyType(); - /** - * - * - *
-   * The type of public key in the certificate.
-   * 
- * - * string public_key_type = 6; - * - * @return The bytes for publicKeyType. - */ - com.google.protobuf.ByteString getPublicKeyTypeBytes(); -} diff --git a/proto-google-cloud-iot-v1/src/main/proto/google/cloud/iot/v1/device_manager.proto b/proto-google-cloud-iot-v1/src/main/proto/google/cloud/iot/v1/device_manager.proto deleted file mode 100644 index b28140ce..00000000 --- a/proto-google-cloud-iot-v1/src/main/proto/google/cloud/iot/v1/device_manager.proto +++ /dev/null @@ -1,651 +0,0 @@ -// Copyright 2020 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -syntax = "proto3"; - -package google.cloud.iot.v1; - -import "google/api/annotations.proto"; -import "google/api/client.proto"; -import "google/api/field_behavior.proto"; -import "google/api/resource.proto"; -import "google/cloud/iot/v1/resources.proto"; -import "google/iam/v1/iam_policy.proto"; -import "google/iam/v1/policy.proto"; -import "google/protobuf/empty.proto"; -import "google/protobuf/field_mask.proto"; - -option cc_enable_arenas = true; -option go_package = "google.golang.org/genproto/googleapis/cloud/iot/v1;iot"; -option java_multiple_files = true; -option java_outer_classname = "DeviceManagerProto"; -option java_package = "com.google.cloud.iot.v1"; - -// Internet of Things (IoT) service. Securely connect and manage IoT devices. -service DeviceManager { - option (google.api.default_host) = "cloudiot.googleapis.com"; - option (google.api.oauth_scopes) = - "https://www.googleapis.com/auth/cloud-platform," - "https://www.googleapis.com/auth/cloudiot"; - - // Creates a device registry that contains devices. - rpc CreateDeviceRegistry(CreateDeviceRegistryRequest) returns (DeviceRegistry) { - option (google.api.http) = { - post: "/v1/{parent=projects/*/locations/*}/registries" - body: "device_registry" - }; - option (google.api.method_signature) = "parent,device_registry"; - } - - // Gets a device registry configuration. - rpc GetDeviceRegistry(GetDeviceRegistryRequest) returns (DeviceRegistry) { - option (google.api.http) = { - get: "/v1/{name=projects/*/locations/*/registries/*}" - }; - option (google.api.method_signature) = "name"; - } - - // Updates a device registry configuration. - rpc UpdateDeviceRegistry(UpdateDeviceRegistryRequest) returns (DeviceRegistry) { - option (google.api.http) = { - patch: "/v1/{device_registry.name=projects/*/locations/*/registries/*}" - body: "device_registry" - }; - option (google.api.method_signature) = "device_registry,update_mask"; - } - - // Deletes a device registry configuration. - rpc DeleteDeviceRegistry(DeleteDeviceRegistryRequest) returns (google.protobuf.Empty) { - option (google.api.http) = { - delete: "/v1/{name=projects/*/locations/*/registries/*}" - }; - option (google.api.method_signature) = "name"; - } - - // Lists device registries. - rpc ListDeviceRegistries(ListDeviceRegistriesRequest) returns (ListDeviceRegistriesResponse) { - option (google.api.http) = { - get: "/v1/{parent=projects/*/locations/*}/registries" - }; - option (google.api.method_signature) = "parent"; - } - - // Creates a device in a device registry. - rpc CreateDevice(CreateDeviceRequest) returns (Device) { - option (google.api.http) = { - post: "/v1/{parent=projects/*/locations/*/registries/*}/devices" - body: "device" - }; - option (google.api.method_signature) = "parent,device"; - } - - // Gets details about a device. - rpc GetDevice(GetDeviceRequest) returns (Device) { - option (google.api.http) = { - get: "/v1/{name=projects/*/locations/*/registries/*/devices/*}" - additional_bindings { - get: "/v1/{name=projects/*/locations/*/registries/*/groups/*/devices/*}" - } - }; - option (google.api.method_signature) = "name"; - } - - // Updates a device. - rpc UpdateDevice(UpdateDeviceRequest) returns (Device) { - option (google.api.http) = { - patch: "/v1/{device.name=projects/*/locations/*/registries/*/devices/*}" - body: "device" - additional_bindings { - patch: "/v1/{device.name=projects/*/locations/*/registries/*/groups/*/devices/*}" - body: "device" - } - }; - option (google.api.method_signature) = "device,update_mask"; - } - - // Deletes a device. - rpc DeleteDevice(DeleteDeviceRequest) returns (google.protobuf.Empty) { - option (google.api.http) = { - delete: "/v1/{name=projects/*/locations/*/registries/*/devices/*}" - }; - option (google.api.method_signature) = "name"; - } - - // List devices in a device registry. - rpc ListDevices(ListDevicesRequest) returns (ListDevicesResponse) { - option (google.api.http) = { - get: "/v1/{parent=projects/*/locations/*/registries/*}/devices" - additional_bindings { - get: "/v1/{parent=projects/*/locations/*/registries/*/groups/*}/devices" - } - }; - option (google.api.method_signature) = "parent"; - } - - // Modifies the configuration for the device, which is eventually sent from - // the Cloud IoT Core servers. Returns the modified configuration version and - // its metadata. - rpc ModifyCloudToDeviceConfig(ModifyCloudToDeviceConfigRequest) returns (DeviceConfig) { - option (google.api.http) = { - post: "/v1/{name=projects/*/locations/*/registries/*/devices/*}:modifyCloudToDeviceConfig" - body: "*" - additional_bindings { - post: "/v1/{name=projects/*/locations/*/registries/*/groups/*/devices/*}:modifyCloudToDeviceConfig" - body: "*" - } - }; - option (google.api.method_signature) = "name,binary_data"; - } - - // Lists the last few versions of the device configuration in descending - // order (i.e.: newest first). - rpc ListDeviceConfigVersions(ListDeviceConfigVersionsRequest) returns (ListDeviceConfigVersionsResponse) { - option (google.api.http) = { - get: "/v1/{name=projects/*/locations/*/registries/*/devices/*}/configVersions" - additional_bindings { - get: "/v1/{name=projects/*/locations/*/registries/*/groups/*/devices/*}/configVersions" - } - }; - option (google.api.method_signature) = "name"; - } - - // Lists the last few versions of the device state in descending order (i.e.: - // newest first). - rpc ListDeviceStates(ListDeviceStatesRequest) returns (ListDeviceStatesResponse) { - option (google.api.http) = { - get: "/v1/{name=projects/*/locations/*/registries/*/devices/*}/states" - additional_bindings { - get: "/v1/{name=projects/*/locations/*/registries/*/groups/*/devices/*}/states" - } - }; - option (google.api.method_signature) = "name"; - } - - // Sets the access control policy on the specified resource. Replaces any - // existing policy. - rpc SetIamPolicy(google.iam.v1.SetIamPolicyRequest) returns (google.iam.v1.Policy) { - option (google.api.http) = { - post: "/v1/{resource=projects/*/locations/*/registries/*}:setIamPolicy" - body: "*" - additional_bindings { - post: "/v1/{resource=projects/*/locations/*/registries/*/groups/*}:setIamPolicy" - body: "*" - } - }; - option (google.api.method_signature) = "resource,policy"; - } - - // Gets the access control policy for a resource. - // Returns an empty policy if the resource exists and does not have a policy - // set. - rpc GetIamPolicy(google.iam.v1.GetIamPolicyRequest) returns (google.iam.v1.Policy) { - option (google.api.http) = { - post: "/v1/{resource=projects/*/locations/*/registries/*}:getIamPolicy" - body: "*" - additional_bindings { - post: "/v1/{resource=projects/*/locations/*/registries/*/groups/*}:getIamPolicy" - body: "*" - } - }; - option (google.api.method_signature) = "resource"; - } - - // Returns permissions that a caller has on the specified resource. - // If the resource does not exist, this will return an empty set of - // permissions, not a NOT_FOUND error. - rpc TestIamPermissions(google.iam.v1.TestIamPermissionsRequest) returns (google.iam.v1.TestIamPermissionsResponse) { - option (google.api.http) = { - post: "/v1/{resource=projects/*/locations/*/registries/*}:testIamPermissions" - body: "*" - additional_bindings { - post: "/v1/{resource=projects/*/locations/*/registries/*/groups/*}:testIamPermissions" - body: "*" - } - }; - option (google.api.method_signature) = "resource,permissions"; - } - - // Sends a command to the specified device. In order for a device to be able - // to receive commands, it must: - // 1) be connected to Cloud IoT Core using the MQTT protocol, and - // 2) be subscribed to the group of MQTT topics specified by - // /devices/{device-id}/commands/#. This subscription will receive commands - // at the top-level topic /devices/{device-id}/commands as well as commands - // for subfolders, like /devices/{device-id}/commands/subfolder. - // Note that subscribing to specific subfolders is not supported. - // If the command could not be delivered to the device, this method will - // return an error; in particular, if the device is not subscribed, this - // method will return FAILED_PRECONDITION. Otherwise, this method will - // return OK. If the subscription is QoS 1, at least once delivery will be - // guaranteed; for QoS 0, no acknowledgment will be expected from the device. - rpc SendCommandToDevice(SendCommandToDeviceRequest) returns (SendCommandToDeviceResponse) { - option (google.api.http) = { - post: "/v1/{name=projects/*/locations/*/registries/*/devices/*}:sendCommandToDevice" - body: "*" - additional_bindings { - post: "/v1/{name=projects/*/locations/*/registries/*/groups/*/devices/*}:sendCommandToDevice" - body: "*" - } - }; - option (google.api.method_signature) = "name,binary_data"; - option (google.api.method_signature) = "name,binary_data,subfolder"; - } - - // Associates the device with the gateway. - rpc BindDeviceToGateway(BindDeviceToGatewayRequest) returns (BindDeviceToGatewayResponse) { - option (google.api.http) = { - post: "/v1/{parent=projects/*/locations/*/registries/*}:bindDeviceToGateway" - body: "*" - additional_bindings { - post: "/v1/{parent=projects/*/locations/*/registries/*/groups/*}:bindDeviceToGateway" - body: "*" - } - }; - option (google.api.method_signature) = "parent,gateway_id,device_id"; - } - - // Deletes the association between the device and the gateway. - rpc UnbindDeviceFromGateway(UnbindDeviceFromGatewayRequest) returns (UnbindDeviceFromGatewayResponse) { - option (google.api.http) = { - post: "/v1/{parent=projects/*/locations/*/registries/*}:unbindDeviceFromGateway" - body: "*" - additional_bindings { - post: "/v1/{parent=projects/*/locations/*/registries/*/groups/*}:unbindDeviceFromGateway" - body: "*" - } - }; - option (google.api.method_signature) = "parent,gateway_id,device_id"; - } -} - -// Request for `CreateDeviceRegistry`. -message CreateDeviceRegistryRequest { - // Required. The project and cloud region where this device registry must be created. - // For example, `projects/example-project/locations/us-central1`. - string parent = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "locations.googleapis.com/Location" - } - ]; - - // Required. The device registry. The field `name` must be empty. The server will - // generate that field from the device registry `id` provided and the - // `parent` field. - DeviceRegistry device_registry = 2 [(google.api.field_behavior) = REQUIRED]; -} - -// Request for `GetDeviceRegistry`. -message GetDeviceRegistryRequest { - // Required. The name of the device registry. For example, - // `projects/example-project/locations/us-central1/registries/my-registry`. - string name = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "cloudiot.googleapis.com/Registry" - } - ]; -} - -// Request for `DeleteDeviceRegistry`. -message DeleteDeviceRegistryRequest { - // Required. The name of the device registry. For example, - // `projects/example-project/locations/us-central1/registries/my-registry`. - string name = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "cloudiot.googleapis.com/Registry" - } - ]; -} - -// Request for `UpdateDeviceRegistry`. -message UpdateDeviceRegistryRequest { - // Required. The new values for the device registry. The `id` field must be empty, and - // the `name` field must indicate the path of the resource. For example, - // `projects/example-project/locations/us-central1/registries/my-registry`. - DeviceRegistry device_registry = 1 [(google.api.field_behavior) = REQUIRED]; - - // Required. Only updates the `device_registry` fields indicated by this mask. - // The field mask must not be empty, and it must not contain fields that - // are immutable or only set by the server. - // Mutable top-level fields: `event_notification_config`, `http_config`, - // `mqtt_config`, and `state_notification_config`. - google.protobuf.FieldMask update_mask = 2 [(google.api.field_behavior) = REQUIRED]; -} - -// Request for `ListDeviceRegistries`. -message ListDeviceRegistriesRequest { - // Required. The project and cloud region path. For example, - // `projects/example-project/locations/us-central1`. - string parent = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "locations.googleapis.com/Location" - } - ]; - - // The maximum number of registries to return in the response. If this value - // is zero, the service will select a default size. A call may return fewer - // objects than requested. A non-empty `next_page_token` in the response - // indicates that more data is available. - int32 page_size = 2; - - // The value returned by the last `ListDeviceRegistriesResponse`; indicates - // that this is a continuation of a prior `ListDeviceRegistries` call and - // the system should return the next page of data. - string page_token = 3; -} - -// Response for `ListDeviceRegistries`. -message ListDeviceRegistriesResponse { - // The registries that matched the query. - repeated DeviceRegistry device_registries = 1; - - // If not empty, indicates that there may be more registries that match the - // request; this value should be passed in a new - // `ListDeviceRegistriesRequest`. - string next_page_token = 2; -} - -// Request for `CreateDevice`. -message CreateDeviceRequest { - // Required. The name of the device registry where this device should be created. - // For example, - // `projects/example-project/locations/us-central1/registries/my-registry`. - string parent = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "cloudiot.googleapis.com/Registry" - } - ]; - - // Required. The device registration details. The field `name` must be empty. The server - // generates `name` from the device registry `id` and the - // `parent` field. - Device device = 2 [(google.api.field_behavior) = REQUIRED]; -} - -// Request for `GetDevice`. -message GetDeviceRequest { - // Required. The name of the device. For example, - // `projects/p0/locations/us-central1/registries/registry0/devices/device0` or - // `projects/p0/locations/us-central1/registries/registry0/devices/{num_id}`. - string name = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "cloudiot.googleapis.com/Device" - } - ]; - - // The fields of the `Device` resource to be returned in the response. If the - // field mask is unset or empty, all fields are returned. Fields have to be - // provided in snake_case format, for example: `last_heartbeat_time`. - google.protobuf.FieldMask field_mask = 2; -} - -// Request for `UpdateDevice`. -message UpdateDeviceRequest { - // Required. The new values for the device. The `id` and `num_id` fields must - // be empty, and the field `name` must specify the name path. For example, - // `projects/p0/locations/us-central1/registries/registry0/devices/device0`or - // `projects/p0/locations/us-central1/registries/registry0/devices/{num_id}`. - Device device = 2 [(google.api.field_behavior) = REQUIRED]; - - // Required. Only updates the `device` fields indicated by this mask. - // The field mask must not be empty, and it must not contain fields that - // are immutable or only set by the server. - // Mutable top-level fields: `credentials`, `blocked`, and `metadata` - google.protobuf.FieldMask update_mask = 3 [(google.api.field_behavior) = REQUIRED]; -} - -// Request for `DeleteDevice`. -message DeleteDeviceRequest { - // Required. The name of the device. For example, - // `projects/p0/locations/us-central1/registries/registry0/devices/device0` or - // `projects/p0/locations/us-central1/registries/registry0/devices/{num_id}`. - string name = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "cloudiot.googleapis.com/Device" - } - ]; -} - -// Request for `ListDevices`. -message ListDevicesRequest { - // Required. The device registry path. Required. For example, - // `projects/my-project/locations/us-central1/registries/my-registry`. - string parent = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "cloudiot.googleapis.com/Registry" - } - ]; - - // A list of device numeric IDs. If empty, this field is ignored. Maximum - // IDs: 10,000. - repeated uint64 device_num_ids = 2; - - // A list of device string IDs. For example, `['device0', 'device12']`. - // If empty, this field is ignored. Maximum IDs: 10,000 - repeated string device_ids = 3; - - // The fields of the `Device` resource to be returned in the response. The - // fields `id` and `num_id` are always returned, along with any - // other fields specified in snake_case format, for example: - // `last_heartbeat_time`. - google.protobuf.FieldMask field_mask = 4; - - // Options related to gateways. - GatewayListOptions gateway_list_options = 6; - - // The maximum number of devices to return in the response. If this value - // is zero, the service will select a default size. A call may return fewer - // objects than requested. A non-empty `next_page_token` in the response - // indicates that more data is available. - int32 page_size = 100; - - // The value returned by the last `ListDevicesResponse`; indicates - // that this is a continuation of a prior `ListDevices` call and - // the system should return the next page of data. - string page_token = 101; -} - -// Options for limiting the list based on gateway type and associations. -message GatewayListOptions { - // If not set, all devices and gateways are returned. If set, the list is - // filtered based on gateway type and associations. - oneof filter { - // If `GATEWAY` is specified, only gateways are returned. If `NON_GATEWAY` - // is specified, only non-gateway devices are returned. If - // `GATEWAY_TYPE_UNSPECIFIED` is specified, all devices are returned. - GatewayType gateway_type = 1; - - // If set, only devices associated with the specified gateway are returned. - // The gateway ID can be numeric (`num_id`) or the user-defined string - // (`id`). For example, if `123` is specified, only devices bound to the - // gateway with `num_id` 123 are returned. - string associations_gateway_id = 2; - - // If set, returns only the gateways with which the specified device is - // associated. The device ID can be numeric (`num_id`) or the user-defined - // string (`id`). For example, if `456` is specified, returns only the - // gateways to which the device with `num_id` 456 is bound. - string associations_device_id = 3; - } -} - -// Response for `ListDevices`. -message ListDevicesResponse { - // The devices that match the request. - repeated Device devices = 1; - - // If not empty, indicates that there may be more devices that match the - // request; this value should be passed in a new `ListDevicesRequest`. - string next_page_token = 2; -} - -// Request for `ModifyCloudToDeviceConfig`. -message ModifyCloudToDeviceConfigRequest { - // Required. The name of the device. For example, - // `projects/p0/locations/us-central1/registries/registry0/devices/device0` or - // `projects/p0/locations/us-central1/registries/registry0/devices/{num_id}`. - string name = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "cloudiot.googleapis.com/Device" - } - ]; - - // The version number to update. If this value is zero, it will not check the - // version number of the server and will always update the current version; - // otherwise, this update will fail if the version number found on the server - // does not match this version number. This is used to support multiple - // simultaneous updates without losing data. - int64 version_to_update = 2; - - // Required. The configuration data for the device. - bytes binary_data = 3 [(google.api.field_behavior) = REQUIRED]; -} - -// Request for `ListDeviceConfigVersions`. -message ListDeviceConfigVersionsRequest { - // Required. The name of the device. For example, - // `projects/p0/locations/us-central1/registries/registry0/devices/device0` or - // `projects/p0/locations/us-central1/registries/registry0/devices/{num_id}`. - string name = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "cloudiot.googleapis.com/Device" - } - ]; - - // The number of versions to list. Versions are listed in decreasing order of - // the version number. The maximum number of versions retained is 10. If this - // value is zero, it will return all the versions available. - int32 num_versions = 2; -} - -// Response for `ListDeviceConfigVersions`. -message ListDeviceConfigVersionsResponse { - // The device configuration for the last few versions. Versions are listed - // in decreasing order, starting from the most recent one. - repeated DeviceConfig device_configs = 1; -} - -// Request for `ListDeviceStates`. -message ListDeviceStatesRequest { - // Required. The name of the device. For example, - // `projects/p0/locations/us-central1/registries/registry0/devices/device0` or - // `projects/p0/locations/us-central1/registries/registry0/devices/{num_id}`. - string name = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "cloudiot.googleapis.com/Device" - } - ]; - - // The number of states to list. States are listed in descending order of - // update time. The maximum number of states retained is 10. If this - // value is zero, it will return all the states available. - int32 num_states = 2; -} - -// Response for `ListDeviceStates`. -message ListDeviceStatesResponse { - // The last few device states. States are listed in descending order of server - // update time, starting from the most recent one. - repeated DeviceState device_states = 1; -} - -// Request for `SendCommandToDevice`. -message SendCommandToDeviceRequest { - // Required. The name of the device. For example, - // `projects/p0/locations/us-central1/registries/registry0/devices/device0` or - // `projects/p0/locations/us-central1/registries/registry0/devices/{num_id}`. - string name = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "cloudiot.googleapis.com/Device" - } - ]; - - // Required. The command data to send to the device. - bytes binary_data = 2 [(google.api.field_behavior) = REQUIRED]; - - // Optional subfolder for the command. If empty, the command will be delivered - // to the /devices/{device-id}/commands topic, otherwise it will be delivered - // to the /devices/{device-id}/commands/{subfolder} topic. Multi-level - // subfolders are allowed. This field must not have more than 256 characters, - // and must not contain any MQTT wildcards ("+" or "#") or null characters. - string subfolder = 3; -} - -// Response for `SendCommandToDevice`. -message SendCommandToDeviceResponse { - -} - -// Request for `BindDeviceToGateway`. -message BindDeviceToGatewayRequest { - // Required. The name of the registry. For example, - // `projects/example-project/locations/us-central1/registries/my-registry`. - string parent = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "cloudiot.googleapis.com/Registry" - } - ]; - - // Required. The value of `gateway_id` can be either the device numeric ID or the - // user-defined device identifier. - string gateway_id = 2 [(google.api.field_behavior) = REQUIRED]; - - // Required. The device to associate with the specified gateway. The value of - // `device_id` can be either the device numeric ID or the user-defined device - // identifier. - string device_id = 3 [(google.api.field_behavior) = REQUIRED]; -} - -// Response for `BindDeviceToGateway`. -message BindDeviceToGatewayResponse { - -} - -// Request for `UnbindDeviceFromGateway`. -message UnbindDeviceFromGatewayRequest { - // Required. The name of the registry. For example, - // `projects/example-project/locations/us-central1/registries/my-registry`. - string parent = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "cloudiot.googleapis.com/Registry" - } - ]; - - // Required. The value of `gateway_id` can be either the device numeric ID or the - // user-defined device identifier. - string gateway_id = 2 [(google.api.field_behavior) = REQUIRED]; - - // Required. The device to disassociate from the specified gateway. The value of - // `device_id` can be either the device numeric ID or the user-defined device - // identifier. - string device_id = 3 [(google.api.field_behavior) = REQUIRED]; -} - -// Response for `UnbindDeviceFromGateway`. -message UnbindDeviceFromGatewayResponse { - -} diff --git a/proto-google-cloud-iot-v1/src/main/proto/google/cloud/iot/v1/resources.proto b/proto-google-cloud-iot-v1/src/main/proto/google/cloud/iot/v1/resources.proto deleted file mode 100644 index a14fc027..00000000 --- a/proto-google-cloud-iot-v1/src/main/proto/google/cloud/iot/v1/resources.proto +++ /dev/null @@ -1,483 +0,0 @@ -// Copyright 2020 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -syntax = "proto3"; - -package google.cloud.iot.v1; - -import "google/api/resource.proto"; -import "google/protobuf/timestamp.proto"; -import "google/rpc/status.proto"; - -option cc_enable_arenas = true; -option go_package = "google.golang.org/genproto/googleapis/cloud/iot/v1;iot"; -option java_multiple_files = true; -option java_outer_classname = "ResourcesProto"; -option java_package = "com.google.cloud.iot.v1"; - -// The device resource. -message Device { - option (google.api.resource) = { - type: "cloudiot.googleapis.com/Device" - pattern: "projects/{project}/locations/{location}/registries/{registry}/devices/{device}" - }; - - // The user-defined device identifier. The device ID must be unique - // within a device registry. - string id = 1; - - // The resource path name. For example, - // `projects/p1/locations/us-central1/registries/registry0/devices/dev0` or - // `projects/p1/locations/us-central1/registries/registry0/devices/{num_id}`. - // When `name` is populated as a response from the service, it always ends - // in the device numeric ID. - string name = 2; - - // [Output only] A server-defined unique numeric ID for the device. This is a - // more compact way to identify devices, and it is globally unique. - uint64 num_id = 3; - - // The credentials used to authenticate this device. To allow credential - // rotation without interruption, multiple device credentials can be bound to - // this device. No more than 3 credentials can be bound to a single device at - // a time. When new credentials are added to a device, they are verified - // against the registry credentials. For details, see the description of the - // `DeviceRegistry.credentials` field. - repeated DeviceCredential credentials = 12; - - // [Output only] The last time an MQTT `PINGREQ` was received. This field - // applies only to devices connecting through MQTT. MQTT clients usually only - // send `PINGREQ` messages if the connection is idle, and no other messages - // have been sent. Timestamps are periodically collected and written to - // storage; they may be stale by a few minutes. - google.protobuf.Timestamp last_heartbeat_time = 7; - - // [Output only] The last time a telemetry event was received. Timestamps are - // periodically collected and written to storage; they may be stale by a few - // minutes. - google.protobuf.Timestamp last_event_time = 8; - - // [Output only] The last time a state event was received. Timestamps are - // periodically collected and written to storage; they may be stale by a few - // minutes. - google.protobuf.Timestamp last_state_time = 20; - - // [Output only] The last time a cloud-to-device config version acknowledgment - // was received from the device. This field is only for configurations - // sent through MQTT. - google.protobuf.Timestamp last_config_ack_time = 14; - - // [Output only] The last time a cloud-to-device config version was sent to - // the device. - google.protobuf.Timestamp last_config_send_time = 18; - - // If a device is blocked, connections or requests from this device will fail. - // Can be used to temporarily prevent the device from connecting if, for - // example, the sensor is generating bad data and needs maintenance. - bool blocked = 19; - - // [Output only] The time the most recent error occurred, such as a failure to - // publish to Cloud Pub/Sub. This field is the timestamp of - // 'last_error_status'. - google.protobuf.Timestamp last_error_time = 10; - - // [Output only] The error message of the most recent error, such as a failure - // to publish to Cloud Pub/Sub. 'last_error_time' is the timestamp of this - // field. If no errors have occurred, this field has an empty message - // and the status code 0 == OK. Otherwise, this field is expected to have a - // status code other than OK. - google.rpc.Status last_error_status = 11; - - // The most recent device configuration, which is eventually sent from - // Cloud IoT Core to the device. If not present on creation, the - // configuration will be initialized with an empty payload and version value - // of `1`. To update this field after creation, use the - // `DeviceManager.ModifyCloudToDeviceConfig` method. - DeviceConfig config = 13; - - // [Output only] The state most recently received from the device. If no state - // has been reported, this field is not present. - DeviceState state = 16; - - // **Beta Feature** - // - // The logging verbosity for device activity. If unspecified, - // DeviceRegistry.log_level will be used. - LogLevel log_level = 21; - - // The metadata key-value pairs assigned to the device. This metadata is not - // interpreted or indexed by Cloud IoT Core. It can be used to add contextual - // information for the device. - // - // Keys must conform to the regular expression [a-zA-Z][a-zA-Z0-9-_.+~%]+ and - // be less than 128 bytes in length. - // - // Values are free-form strings. Each value must be less than or equal to 32 - // KB in size. - // - // The total size of all keys and values must be less than 256 KB, and the - // maximum number of key-value pairs is 500. - map metadata = 17; - - // Gateway-related configuration and state. - GatewayConfig gateway_config = 24; -} - -// Gateway-related configuration and state. -message GatewayConfig { - // Indicates whether the device is a gateway. - GatewayType gateway_type = 1; - - // Indicates how to authorize and/or authenticate devices to access the - // gateway. - GatewayAuthMethod gateway_auth_method = 2; - - // [Output only] The ID of the gateway the device accessed most recently. - string last_accessed_gateway_id = 3; - - // [Output only] The most recent time at which the device accessed the gateway - // specified in `last_accessed_gateway`. - google.protobuf.Timestamp last_accessed_gateway_time = 4; -} - -// A container for a group of devices. -message DeviceRegistry { - option (google.api.resource) = { - type: "cloudiot.googleapis.com/Registry" - pattern: "projects/{project}/locations/{location}/registries/{registry}" - }; - - // The identifier of this device registry. For example, `myRegistry`. - string id = 1; - - // The resource path name. For example, - // `projects/example-project/locations/us-central1/registries/my-registry`. - string name = 2; - - // The configuration for notification of telemetry events received from the - // device. All telemetry events that were successfully published by the - // device and acknowledged by Cloud IoT Core are guaranteed to be - // delivered to Cloud Pub/Sub. If multiple configurations match a message, - // only the first matching configuration is used. If you try to publish a - // device telemetry event using MQTT without specifying a Cloud Pub/Sub topic - // for the device's registry, the connection closes automatically. If you try - // to do so using an HTTP connection, an error is returned. Up to 10 - // configurations may be provided. - repeated EventNotificationConfig event_notification_configs = 10; - - // The configuration for notification of new states received from the device. - // State updates are guaranteed to be stored in the state history, but - // notifications to Cloud Pub/Sub are not guaranteed. For example, if - // permissions are misconfigured or the specified topic doesn't exist, no - // notification will be published but the state will still be stored in Cloud - // IoT Core. - StateNotificationConfig state_notification_config = 7; - - // The MQTT configuration for this device registry. - MqttConfig mqtt_config = 4; - - // The DeviceService (HTTP) configuration for this device registry. - HttpConfig http_config = 9; - - // **Beta Feature** - // - // The default logging verbosity for activity from devices in this registry. - // The verbosity level can be overridden by Device.log_level. - LogLevel log_level = 11; - - // The credentials used to verify the device credentials. No more than 10 - // credentials can be bound to a single registry at a time. The verification - // process occurs at the time of device creation or update. If this field is - // empty, no verification is performed. Otherwise, the credentials of a newly - // created device or added credentials of an updated device should be signed - // with one of these registry credentials. - // - // Note, however, that existing devices will never be affected by - // modifications to this list of credentials: after a device has been - // successfully created in a registry, it should be able to connect even if - // its registry credentials are revoked, deleted, or modified. - repeated RegistryCredential credentials = 8; -} - -// The configuration of MQTT for a device registry. -message MqttConfig { - // If enabled, allows connections using the MQTT protocol. Otherwise, MQTT - // connections to this registry will fail. - MqttState mqtt_enabled_state = 1; -} - -// Indicates whether an MQTT connection is enabled or disabled. See the field -// description for details. -enum MqttState { - // No MQTT state specified. If not specified, MQTT will be enabled by default. - MQTT_STATE_UNSPECIFIED = 0; - - // Enables a MQTT connection. - MQTT_ENABLED = 1; - - // Disables a MQTT connection. - MQTT_DISABLED = 2; -} - -// The configuration of the HTTP bridge for a device registry. -message HttpConfig { - // If enabled, allows devices to use DeviceService via the HTTP protocol. - // Otherwise, any requests to DeviceService will fail for this registry. - HttpState http_enabled_state = 1; -} - -// Indicates whether DeviceService (HTTP) is enabled or disabled for the -// registry. See the field description for details. -enum HttpState { - // No HTTP state specified. If not specified, DeviceService will be - // enabled by default. - HTTP_STATE_UNSPECIFIED = 0; - - // Enables DeviceService (HTTP) service for the registry. - HTTP_ENABLED = 1; - - // Disables DeviceService (HTTP) service for the registry. - HTTP_DISABLED = 2; -} - -// **Beta Feature** -// -// The logging verbosity for device activity. Specifies which events should be -// written to logs. For example, if the LogLevel is ERROR, only events that -// terminate in errors will be logged. LogLevel is inclusive; enabling INFO -// logging will also enable ERROR logging. -enum LogLevel { - // No logging specified. If not specified, logging will be disabled. - LOG_LEVEL_UNSPECIFIED = 0; - - // Disables logging. - NONE = 10; - - // Error events will be logged. - ERROR = 20; - - // Informational events will be logged, such as connections and - // disconnections. - INFO = 30; - - // All events will be logged. - DEBUG = 40; -} - -// Gateway type. -enum GatewayType { - // If unspecified, the device is considered a non-gateway device. - GATEWAY_TYPE_UNSPECIFIED = 0; - - // The device is a gateway. - GATEWAY = 1; - - // The device is not a gateway. - NON_GATEWAY = 2; -} - -// The gateway authorization/authentication method. This setting determines how -// Cloud IoT Core authorizes/authenticate devices to access the gateway. -enum GatewayAuthMethod { - // No authentication/authorization method specified. No devices are allowed to - // access the gateway. - GATEWAY_AUTH_METHOD_UNSPECIFIED = 0; - - // The device is authenticated through the gateway association only. Device - // credentials are ignored even if provided. - ASSOCIATION_ONLY = 1; - - // The device is authenticated through its own credentials. Gateway - // association is not checked. - DEVICE_AUTH_TOKEN_ONLY = 2; - - // The device is authenticated through both device credentials and gateway - // association. The device must be bound to the gateway and must provide its - // own credentials. - ASSOCIATION_AND_DEVICE_AUTH_TOKEN = 3; -} - -// The configuration for forwarding telemetry events. -message EventNotificationConfig { - // If the subfolder name matches this string exactly, this configuration will - // be used. The string must not include the leading '/' character. If empty, - // all strings are matched. This field is used only for telemetry events; - // subfolders are not supported for state changes. - string subfolder_matches = 2; - - // A Cloud Pub/Sub topic name. For example, - // `projects/myProject/topics/deviceEvents`. - string pubsub_topic_name = 1; -} - -// The configuration for notification of new states received from the device. -message StateNotificationConfig { - // A Cloud Pub/Sub topic name. For example, - // `projects/myProject/topics/deviceEvents`. - string pubsub_topic_name = 1; -} - -// A server-stored registry credential used to validate device credentials. -message RegistryCredential { - // The credential data. Reserved for expansion in the future. - oneof credential { - // A public key certificate used to verify the device credentials. - PublicKeyCertificate public_key_certificate = 1; - } -} - -// Details of an X.509 certificate. For informational purposes only. -message X509CertificateDetails { - // The entity that signed the certificate. - string issuer = 1; - - // The entity the certificate and public key belong to. - string subject = 2; - - // The time the certificate becomes valid. - google.protobuf.Timestamp start_time = 3; - - // The time the certificate becomes invalid. - google.protobuf.Timestamp expiry_time = 4; - - // The algorithm used to sign the certificate. - string signature_algorithm = 5; - - // The type of public key in the certificate. - string public_key_type = 6; -} - -// A public key certificate format and data. -message PublicKeyCertificate { - // The certificate format. - PublicKeyCertificateFormat format = 1; - - // The certificate data. - string certificate = 2; - - // [Output only] The certificate details. Used only for X.509 certificates. - X509CertificateDetails x509_details = 3; -} - -// The supported formats for the public key. -enum PublicKeyCertificateFormat { - // The format has not been specified. This is an invalid default value and - // must not be used. - UNSPECIFIED_PUBLIC_KEY_CERTIFICATE_FORMAT = 0; - - // An X.509v3 certificate ([RFC5280](https://www.ietf.org/rfc/rfc5280.txt)), - // encoded in base64, and wrapped by `-----BEGIN CERTIFICATE-----` and - // `-----END CERTIFICATE-----`. - X509_CERTIFICATE_PEM = 1; -} - -// A server-stored device credential used for authentication. -message DeviceCredential { - // The credential data. Reserved for expansion in the future. - oneof credential { - // A public key used to verify the signature of JSON Web Tokens (JWTs). - // When adding a new device credential, either via device creation or via - // modifications, this public key credential may be required to be signed by - // one of the registry level certificates. More specifically, if the - // registry contains at least one certificate, any new device credential - // must be signed by one of the registry certificates. As a result, - // when the registry contains certificates, only X.509 certificates are - // accepted as device credentials. However, if the registry does - // not contain a certificate, self-signed certificates and public keys will - // be accepted. New device credentials must be different from every - // registry-level certificate. - PublicKeyCredential public_key = 2; - } - - // [Optional] The time at which this credential becomes invalid. This - // credential will be ignored for new client authentication requests after - // this timestamp; however, it will not be automatically deleted. - google.protobuf.Timestamp expiration_time = 6; -} - -// A public key format and data. -message PublicKeyCredential { - // The format of the key. - PublicKeyFormat format = 1; - - // The key data. - string key = 2; -} - -// The supported formats for the public key. -enum PublicKeyFormat { - // The format has not been specified. This is an invalid default value and - // must not be used. - UNSPECIFIED_PUBLIC_KEY_FORMAT = 0; - - // An RSA public key encoded in base64, and wrapped by - // `-----BEGIN PUBLIC KEY-----` and `-----END PUBLIC KEY-----`. This can be - // used to verify `RS256` signatures in JWT tokens ([RFC7518]( - // https://www.ietf.org/rfc/rfc7518.txt)). - RSA_PEM = 3; - - // As RSA_PEM, but wrapped in an X.509v3 certificate ([RFC5280]( - // https://www.ietf.org/rfc/rfc5280.txt)), encoded in base64, and wrapped by - // `-----BEGIN CERTIFICATE-----` and `-----END CERTIFICATE-----`. - RSA_X509_PEM = 1; - - // Public key for the ECDSA algorithm using P-256 and SHA-256, encoded in - // base64, and wrapped by `-----BEGIN PUBLIC KEY-----` and `-----END - // PUBLIC KEY-----`. This can be used to verify JWT tokens with the `ES256` - // algorithm ([RFC7518](https://www.ietf.org/rfc/rfc7518.txt)). This curve is - // defined in [OpenSSL](https://www.openssl.org/) as the `prime256v1` curve. - ES256_PEM = 2; - - // As ES256_PEM, but wrapped in an X.509v3 certificate ([RFC5280]( - // https://www.ietf.org/rfc/rfc5280.txt)), encoded in base64, and wrapped by - // `-----BEGIN CERTIFICATE-----` and `-----END CERTIFICATE-----`. - ES256_X509_PEM = 4; -} - -// The device configuration. Eventually delivered to devices. -message DeviceConfig { - // [Output only] The version of this update. The version number is assigned by - // the server, and is always greater than 0 after device creation. The - // version must be 0 on the `CreateDevice` request if a `config` is - // specified; the response of `CreateDevice` will always have a value of 1. - int64 version = 1; - - // [Output only] The time at which this configuration version was updated in - // Cloud IoT Core. This timestamp is set by the server. - google.protobuf.Timestamp cloud_update_time = 2; - - // [Output only] The time at which Cloud IoT Core received the - // acknowledgment from the device, indicating that the device has received - // this configuration version. If this field is not present, the device has - // not yet acknowledged that it received this version. Note that when - // the config was sent to the device, many config versions may have been - // available in Cloud IoT Core while the device was disconnected, and on - // connection, only the latest version is sent to the device. Some - // versions may never be sent to the device, and therefore are never - // acknowledged. This timestamp is set by Cloud IoT Core. - google.protobuf.Timestamp device_ack_time = 3; - - // The device configuration data. - bytes binary_data = 4; -} - -// The device state, as reported by the device. -message DeviceState { - // [Output only] The time at which this state version was updated in Cloud - // IoT Core. - google.protobuf.Timestamp update_time = 1; - - // The device state data. - bytes binary_data = 2; -} diff --git a/renovate.json b/renovate.json deleted file mode 100644 index 6fa7afa4..00000000 --- a/renovate.json +++ /dev/null @@ -1,75 +0,0 @@ -{ - "extends": [ - ":separateMajorReleases", - ":combinePatchMinorReleases", - ":ignoreUnstable", - ":prImmediately", - ":updateNotScheduled", - ":automergeDisabled", - ":ignoreModulesAndTests", - ":maintainLockFilesDisabled", - ":autodetectPinVersions" - ], - "ignorePaths": [".kokoro/requirements.txt"], - "packageRules": [ - { - "packagePatterns": [ - "^com.google.guava:" - ], - "versionScheme": "docker" - }, - { - "packagePatterns": [ - "*" - ], - "semanticCommitType": "deps", - "semanticCommitScope": null - }, - { - "packagePatterns": [ - "^org.apache.maven", - "^org.jacoco:", - "^org.codehaus.mojo:", - "^org.sonatype.plugins:", - "^com.coveo:", - "^com.google.cloud:google-cloud-shared-config" - ], - "semanticCommitType": "build", - "semanticCommitScope": "deps" - }, - { - "packagePatterns": [ - "^com.google.cloud:google-cloud-iot", - "^com.google.cloud:libraries-bom", - "^com.google.cloud.samples:shared-configuration" - ], - "semanticCommitType": "chore", - "semanticCommitScope": "deps" - }, - { - "packagePatterns": [ - "^junit:junit", - "^com.google.truth:truth", - "^org.mockito:mockito-core", - "^org.objenesis:objenesis", - "^com.google.cloud:google-cloud-conformance-tests" - ], - "semanticCommitType": "test", - "semanticCommitScope": "deps" - }, - { - "packagePatterns": [ - "^com.google.cloud:google-cloud-" - ], - "ignoreUnstable": false - }, - { - "packagePatterns": [ - "^com.fasterxml.jackson.core" - ], - "groupName": "jackson dependencies" - } - ], - "semanticCommits": true, - "dependencyDashboard": true -} diff --git a/samples/install-without-bom/pom.xml b/samples/install-without-bom/pom.xml deleted file mode 100644 index ade4ee06..00000000 --- a/samples/install-without-bom/pom.xml +++ /dev/null @@ -1,84 +0,0 @@ - - - 4.0.0 - com.google.cloud - cloudiot-install-without-bom - jar - Google Google Cloud Internet of Things (IoT) Core Install Without Bom - https://github.com/googleapis/java-iot - - - - com.google.cloud.samples - shared-configuration - 1.2.0 - - - - 1.8 - 1.8 - UTF-8 - - - - - - - com.google.cloud - google-cloud-iot - 2.3.4 - - - - - junit - junit - 4.13.2 - test - - - com.google.truth - truth - 1.1.3 - test - - - - - - - - org.codehaus.mojo - build-helper-maven-plugin - 3.3.0 - - - add-snippets-source - - add-source - - - - ../snippets/src/main/java - - - - - add-snippets-tests - - add-test-source - - - - ../snippets/src/test/java - - - - - - - - diff --git a/samples/pom.xml b/samples/pom.xml deleted file mode 100644 index 6f87504e..00000000 --- a/samples/pom.xml +++ /dev/null @@ -1,56 +0,0 @@ - - - 4.0.0 - com.google.cloud - google-cloud-cloudiot-samples - 0.0.1-SNAPSHOT - pom - Google Google Cloud Internet of Things (IoT) Core Samples Parent - https://github.com/googleapis/java-iot - - Java idiomatic client for Google Cloud Platform services. - - - - - com.google.cloud.samples - shared-configuration - 1.2.0 - - - - 1.8 - 1.8 - UTF-8 - - - - install-without-bom - snapshot - snippets - - - - - - org.apache.maven.plugins - maven-deploy-plugin - 3.0.0 - - true - - - - org.sonatype.plugins - nexus-staging-maven-plugin - 1.6.13 - - true - - - - - diff --git a/samples/snapshot/pom.xml b/samples/snapshot/pom.xml deleted file mode 100644 index b6ca7539..00000000 --- a/samples/snapshot/pom.xml +++ /dev/null @@ -1,83 +0,0 @@ - - - 4.0.0 - com.google.cloud - cloudiot-snapshot - jar - Google Google Cloud Internet of Things (IoT) Core Snapshot Samples - https://github.com/googleapis/java-iot - - - - com.google.cloud.samples - shared-configuration - 1.2.0 - - - - 1.8 - 1.8 - UTF-8 - - - - - - com.google.cloud - google-cloud-iot - 2.3.4 - - - - junit - junit - 4.13.2 - test - - - com.google.truth - truth - 1.1.3 - test - - - - - - - - - org.codehaus.mojo - build-helper-maven-plugin - 3.3.0 - - - add-snippets-source - - add-source - - - - ../snippets/src/main/java - - - - - add-snippets-tests - - add-test-source - - - - ../snippets/src/test/java - - - - - - - - \ No newline at end of file diff --git a/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/binddevicetogateway/AsyncBindDeviceToGateway.java b/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/binddevicetogateway/AsyncBindDeviceToGateway.java deleted file mode 100644 index bf0600eb..00000000 --- a/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/binddevicetogateway/AsyncBindDeviceToGateway.java +++ /dev/null @@ -1,52 +0,0 @@ -/* - * 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 and should be regarded as a code template only. - // It will require modifications to work: - // - It may require correct/in-range values for request initialization. - // - It may require specifying regional endpoints when creating the service client as shown in - // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library - 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/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/binddevicetogateway/SyncBindDeviceToGateway.java b/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/binddevicetogateway/SyncBindDeviceToGateway.java deleted file mode 100644 index 93b5e8b6..00000000 --- a/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/binddevicetogateway/SyncBindDeviceToGateway.java +++ /dev/null @@ -1,48 +0,0 @@ -/* - * 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 and should be regarded as a code template only. - // It will require modifications to work: - // - It may require correct/in-range values for request initialization. - // - It may require specifying regional endpoints when creating the service client as shown in - // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library - 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/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/binddevicetogateway/SyncBindDeviceToGatewayRegistrynameStringString.java b/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/binddevicetogateway/SyncBindDeviceToGatewayRegistrynameStringString.java deleted file mode 100644 index f9aa834a..00000000 --- a/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/binddevicetogateway/SyncBindDeviceToGatewayRegistrynameStringString.java +++ /dev/null @@ -1,45 +0,0 @@ -/* - * 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 and should be regarded as a code template only. - // It will require modifications to work: - // - It may require correct/in-range values for request initialization. - // - It may require specifying regional endpoints when creating the service client as shown in - // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library - 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/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/binddevicetogateway/SyncBindDeviceToGatewayStringStringString.java b/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/binddevicetogateway/SyncBindDeviceToGatewayStringStringString.java deleted file mode 100644 index 3320bcdb..00000000 --- a/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/binddevicetogateway/SyncBindDeviceToGatewayStringStringString.java +++ /dev/null @@ -1,45 +0,0 @@ -/* - * 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 and should be regarded as a code template only. - // It will require modifications to work: - // - It may require correct/in-range values for request initialization. - // - It may require specifying regional endpoints when creating the service client as shown in - // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library - 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/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/create/SyncCreateSetCredentialsProvider.java b/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/create/SyncCreateSetCredentialsProvider.java deleted file mode 100644 index 285f027e..00000000 --- a/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/create/SyncCreateSetCredentialsProvider.java +++ /dev/null @@ -1,44 +0,0 @@ -/* - * 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 and should be regarded as a code template only. - // It will require modifications to work: - // - It may require correct/in-range values for request initialization. - // - It may require specifying regional endpoints when creating the service client as shown in - // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library - 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/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/create/SyncCreateSetCredentialsProvider1.java b/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/create/SyncCreateSetCredentialsProvider1.java deleted file mode 100644 index c5109cf4..00000000 --- a/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/create/SyncCreateSetCredentialsProvider1.java +++ /dev/null @@ -1,43 +0,0 @@ -/* - * 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 and should be regarded as a code template only. - // It will require modifications to work: - // - It may require correct/in-range values for request initialization. - // - It may require specifying regional endpoints when creating the service client as shown in - // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library - 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/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/create/SyncCreateSetEndpoint.java b/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/create/SyncCreateSetEndpoint.java deleted file mode 100644 index 5fddcdd7..00000000 --- a/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/create/SyncCreateSetEndpoint.java +++ /dev/null @@ -1,41 +0,0 @@ -/* - * 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 and should be regarded as a code template only. - // It will require modifications to work: - // - It may require correct/in-range values for request initialization. - // - It may require specifying regional endpoints when creating the service client as shown in - // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library - DeviceManagerSettings deviceManagerSettings = - DeviceManagerSettings.newBuilder().setEndpoint(myEndpoint).build(); - DeviceManagerClient deviceManagerClient = DeviceManagerClient.create(deviceManagerSettings); - } -} -// [END iot_v1_generated_devicemanagerclient_create_setendpoint_sync] diff --git a/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/createdevice/AsyncCreateDevice.java b/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/createdevice/AsyncCreateDevice.java deleted file mode 100644 index c32dd9f7..00000000 --- a/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/createdevice/AsyncCreateDevice.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * 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 and should be regarded as a code template only. - // It will require modifications to work: - // - It may require correct/in-range values for request initialization. - // - It may require specifying regional endpoints when creating the service client as shown in - // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library - 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/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/createdevice/SyncCreateDevice.java b/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/createdevice/SyncCreateDevice.java deleted file mode 100644 index ed4c38ef..00000000 --- a/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/createdevice/SyncCreateDevice.java +++ /dev/null @@ -1,47 +0,0 @@ -/* - * 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 and should be regarded as a code template only. - // It will require modifications to work: - // - It may require correct/in-range values for request initialization. - // - It may require specifying regional endpoints when creating the service client as shown in - // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library - 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/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/createdevice/SyncCreateDeviceRegistrynameDevice.java b/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/createdevice/SyncCreateDeviceRegistrynameDevice.java deleted file mode 100644 index 0668b8e9..00000000 --- a/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/createdevice/SyncCreateDeviceRegistrynameDevice.java +++ /dev/null @@ -1,43 +0,0 @@ -/* - * 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 and should be regarded as a code template only. - // It will require modifications to work: - // - It may require correct/in-range values for request initialization. - // - It may require specifying regional endpoints when creating the service client as shown in - // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library - 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/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/createdevice/SyncCreateDeviceStringDevice.java b/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/createdevice/SyncCreateDeviceStringDevice.java deleted file mode 100644 index 1b9d6368..00000000 --- a/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/createdevice/SyncCreateDeviceStringDevice.java +++ /dev/null @@ -1,43 +0,0 @@ -/* - * 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 and should be regarded as a code template only. - // It will require modifications to work: - // - It may require correct/in-range values for request initialization. - // - It may require specifying regional endpoints when creating the service client as shown in - // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library - 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/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/createdeviceregistry/AsyncCreateDeviceRegistry.java b/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/createdeviceregistry/AsyncCreateDeviceRegistry.java deleted file mode 100644 index 4e86e807..00000000 --- a/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/createdeviceregistry/AsyncCreateDeviceRegistry.java +++ /dev/null @@ -1,51 +0,0 @@ -/* - * 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 and should be regarded as a code template only. - // It will require modifications to work: - // - It may require correct/in-range values for request initialization. - // - It may require specifying regional endpoints when creating the service client as shown in - // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library - 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/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/createdeviceregistry/SyncCreateDeviceRegistry.java b/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/createdeviceregistry/SyncCreateDeviceRegistry.java deleted file mode 100644 index f006a234..00000000 --- a/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/createdeviceregistry/SyncCreateDeviceRegistry.java +++ /dev/null @@ -1,47 +0,0 @@ -/* - * 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 and should be regarded as a code template only. - // It will require modifications to work: - // - It may require correct/in-range values for request initialization. - // - It may require specifying regional endpoints when creating the service client as shown in - // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library - 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/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/createdeviceregistry/SyncCreateDeviceRegistryLocationnameDeviceregistry.java b/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/createdeviceregistry/SyncCreateDeviceRegistryLocationnameDeviceregistry.java deleted file mode 100644 index aec64c2c..00000000 --- a/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/createdeviceregistry/SyncCreateDeviceRegistryLocationnameDeviceregistry.java +++ /dev/null @@ -1,43 +0,0 @@ -/* - * 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 and should be regarded as a code template only. - // It will require modifications to work: - // - It may require correct/in-range values for request initialization. - // - It may require specifying regional endpoints when creating the service client as shown in - // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library - 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/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/createdeviceregistry/SyncCreateDeviceRegistryStringDeviceregistry.java b/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/createdeviceregistry/SyncCreateDeviceRegistryStringDeviceregistry.java deleted file mode 100644 index 53edea10..00000000 --- a/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/createdeviceregistry/SyncCreateDeviceRegistryStringDeviceregistry.java +++ /dev/null @@ -1,43 +0,0 @@ -/* - * 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 and should be regarded as a code template only. - // It will require modifications to work: - // - It may require correct/in-range values for request initialization. - // - It may require specifying regional endpoints when creating the service client as shown in - // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library - 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/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/deletedevice/AsyncDeleteDevice.java b/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/deletedevice/AsyncDeleteDevice.java deleted file mode 100644 index 4fe186ce..00000000 --- a/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/deletedevice/AsyncDeleteDevice.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * 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 and should be regarded as a code template only. - // It will require modifications to work: - // - It may require correct/in-range values for request initialization. - // - It may require specifying regional endpoints when creating the service client as shown in - // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library - 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/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/deletedevice/SyncDeleteDevice.java b/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/deletedevice/SyncDeleteDevice.java deleted file mode 100644 index 672164f4..00000000 --- a/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/deletedevice/SyncDeleteDevice.java +++ /dev/null @@ -1,47 +0,0 @@ -/* - * 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; -import com.google.protobuf.Empty; - -public class SyncDeleteDevice { - - public static void main(String[] args) throws Exception { - syncDeleteDevice(); - } - - public static void syncDeleteDevice() throws Exception { - // This snippet has been automatically generated and should be regarded as a code template only. - // It will require modifications to work: - // - It may require correct/in-range values for request initialization. - // - It may require specifying regional endpoints when creating the service client as shown in - // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library - 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/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/deletedevice/SyncDeleteDeviceDevicename.java b/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/deletedevice/SyncDeleteDeviceDevicename.java deleted file mode 100644 index b0d90aeb..00000000 --- a/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/deletedevice/SyncDeleteDeviceDevicename.java +++ /dev/null @@ -1,42 +0,0 @@ -/* - * 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; -import com.google.protobuf.Empty; - -public class SyncDeleteDeviceDevicename { - - public static void main(String[] args) throws Exception { - syncDeleteDeviceDevicename(); - } - - public static void syncDeleteDeviceDevicename() throws Exception { - // This snippet has been automatically generated and should be regarded as a code template only. - // It will require modifications to work: - // - It may require correct/in-range values for request initialization. - // - It may require specifying regional endpoints when creating the service client as shown in - // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library - 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/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/deletedevice/SyncDeleteDeviceString.java b/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/deletedevice/SyncDeleteDeviceString.java deleted file mode 100644 index e76460d9..00000000 --- a/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/deletedevice/SyncDeleteDeviceString.java +++ /dev/null @@ -1,42 +0,0 @@ -/* - * 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; -import com.google.protobuf.Empty; - -public class SyncDeleteDeviceString { - - public static void main(String[] args) throws Exception { - syncDeleteDeviceString(); - } - - public static void syncDeleteDeviceString() throws Exception { - // This snippet has been automatically generated and should be regarded as a code template only. - // It will require modifications to work: - // - It may require correct/in-range values for request initialization. - // - It may require specifying regional endpoints when creating the service client as shown in - // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library - 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/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/deletedeviceregistry/AsyncDeleteDeviceRegistry.java b/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/deletedeviceregistry/AsyncDeleteDeviceRegistry.java deleted file mode 100644 index eb0c74f9..00000000 --- a/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/deletedeviceregistry/AsyncDeleteDeviceRegistry.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * 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 and should be regarded as a code template only. - // It will require modifications to work: - // - It may require correct/in-range values for request initialization. - // - It may require specifying regional endpoints when creating the service client as shown in - // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library - 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/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/deletedeviceregistry/SyncDeleteDeviceRegistry.java b/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/deletedeviceregistry/SyncDeleteDeviceRegistry.java deleted file mode 100644 index 8e2faadf..00000000 --- a/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/deletedeviceregistry/SyncDeleteDeviceRegistry.java +++ /dev/null @@ -1,46 +0,0 @@ -/* - * 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; -import com.google.protobuf.Empty; - -public class SyncDeleteDeviceRegistry { - - public static void main(String[] args) throws Exception { - syncDeleteDeviceRegistry(); - } - - public static void syncDeleteDeviceRegistry() throws Exception { - // This snippet has been automatically generated and should be regarded as a code template only. - // It will require modifications to work: - // - It may require correct/in-range values for request initialization. - // - It may require specifying regional endpoints when creating the service client as shown in - // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library - 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/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/deletedeviceregistry/SyncDeleteDeviceRegistryRegistryname.java b/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/deletedeviceregistry/SyncDeleteDeviceRegistryRegistryname.java deleted file mode 100644 index c789b761..00000000 --- a/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/deletedeviceregistry/SyncDeleteDeviceRegistryRegistryname.java +++ /dev/null @@ -1,42 +0,0 @@ -/* - * 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; -import com.google.protobuf.Empty; - -public class SyncDeleteDeviceRegistryRegistryname { - - public static void main(String[] args) throws Exception { - syncDeleteDeviceRegistryRegistryname(); - } - - public static void syncDeleteDeviceRegistryRegistryname() throws Exception { - // This snippet has been automatically generated and should be regarded as a code template only. - // It will require modifications to work: - // - It may require correct/in-range values for request initialization. - // - It may require specifying regional endpoints when creating the service client as shown in - // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library - 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/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/deletedeviceregistry/SyncDeleteDeviceRegistryString.java b/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/deletedeviceregistry/SyncDeleteDeviceRegistryString.java deleted file mode 100644 index 1c52d298..00000000 --- a/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/deletedeviceregistry/SyncDeleteDeviceRegistryString.java +++ /dev/null @@ -1,42 +0,0 @@ -/* - * 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; -import com.google.protobuf.Empty; - -public class SyncDeleteDeviceRegistryString { - - public static void main(String[] args) throws Exception { - syncDeleteDeviceRegistryString(); - } - - public static void syncDeleteDeviceRegistryString() throws Exception { - // This snippet has been automatically generated and should be regarded as a code template only. - // It will require modifications to work: - // - It may require correct/in-range values for request initialization. - // - It may require specifying regional endpoints when creating the service client as shown in - // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library - 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/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/getdevice/AsyncGetDevice.java b/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/getdevice/AsyncGetDevice.java deleted file mode 100644 index 6ed1480d..00000000 --- a/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/getdevice/AsyncGetDevice.java +++ /dev/null @@ -1,52 +0,0 @@ -/* - * 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 and should be regarded as a code template only. - // It will require modifications to work: - // - It may require correct/in-range values for request initialization. - // - It may require specifying regional endpoints when creating the service client as shown in - // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library - 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/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/getdevice/SyncGetDevice.java b/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/getdevice/SyncGetDevice.java deleted file mode 100644 index f512ba34..00000000 --- a/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/getdevice/SyncGetDevice.java +++ /dev/null @@ -1,49 +0,0 @@ -/* - * 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 and should be regarded as a code template only. - // It will require modifications to work: - // - It may require correct/in-range values for request initialization. - // - It may require specifying regional endpoints when creating the service client as shown in - // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library - 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/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/getdevice/SyncGetDeviceDevicename.java b/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/getdevice/SyncGetDeviceDevicename.java deleted file mode 100644 index 329c3f63..00000000 --- a/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/getdevice/SyncGetDeviceDevicename.java +++ /dev/null @@ -1,42 +0,0 @@ -/* - * 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 and should be regarded as a code template only. - // It will require modifications to work: - // - It may require correct/in-range values for request initialization. - // - It may require specifying regional endpoints when creating the service client as shown in - // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library - 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/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/getdevice/SyncGetDeviceString.java b/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/getdevice/SyncGetDeviceString.java deleted file mode 100644 index 59a9bcaf..00000000 --- a/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/getdevice/SyncGetDeviceString.java +++ /dev/null @@ -1,42 +0,0 @@ -/* - * 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 and should be regarded as a code template only. - // It will require modifications to work: - // - It may require correct/in-range values for request initialization. - // - It may require specifying regional endpoints when creating the service client as shown in - // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library - 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/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/getdeviceregistry/AsyncGetDeviceRegistry.java b/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/getdeviceregistry/AsyncGetDeviceRegistry.java deleted file mode 100644 index 4db67f49..00000000 --- a/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/getdeviceregistry/AsyncGetDeviceRegistry.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * 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 and should be regarded as a code template only. - // It will require modifications to work: - // - It may require correct/in-range values for request initialization. - // - It may require specifying regional endpoints when creating the service client as shown in - // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library - 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/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/getdeviceregistry/SyncGetDeviceRegistry.java b/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/getdeviceregistry/SyncGetDeviceRegistry.java deleted file mode 100644 index 97b7b58c..00000000 --- a/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/getdeviceregistry/SyncGetDeviceRegistry.java +++ /dev/null @@ -1,46 +0,0 @@ -/* - * 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 and should be regarded as a code template only. - // It will require modifications to work: - // - It may require correct/in-range values for request initialization. - // - It may require specifying regional endpoints when creating the service client as shown in - // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library - 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/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/getdeviceregistry/SyncGetDeviceRegistryRegistryname.java b/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/getdeviceregistry/SyncGetDeviceRegistryRegistryname.java deleted file mode 100644 index 93391ae8..00000000 --- a/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/getdeviceregistry/SyncGetDeviceRegistryRegistryname.java +++ /dev/null @@ -1,42 +0,0 @@ -/* - * 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 and should be regarded as a code template only. - // It will require modifications to work: - // - It may require correct/in-range values for request initialization. - // - It may require specifying regional endpoints when creating the service client as shown in - // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library - 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/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/getdeviceregistry/SyncGetDeviceRegistryString.java b/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/getdeviceregistry/SyncGetDeviceRegistryString.java deleted file mode 100644 index 11b118e0..00000000 --- a/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/getdeviceregistry/SyncGetDeviceRegistryString.java +++ /dev/null @@ -1,42 +0,0 @@ -/* - * 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 and should be regarded as a code template only. - // It will require modifications to work: - // - It may require correct/in-range values for request initialization. - // - It may require specifying regional endpoints when creating the service client as shown in - // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library - 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/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/getiampolicy/AsyncGetIamPolicy.java b/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/getiampolicy/AsyncGetIamPolicy.java deleted file mode 100644 index dadf1c5f..00000000 --- a/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/getiampolicy/AsyncGetIamPolicy.java +++ /dev/null @@ -1,51 +0,0 @@ -/* - * 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 and should be regarded as a code template only. - // It will require modifications to work: - // - It may require correct/in-range values for request initialization. - // - It may require specifying regional endpoints when creating the service client as shown in - // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library - 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/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/getiampolicy/SyncGetIamPolicy.java b/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/getiampolicy/SyncGetIamPolicy.java deleted file mode 100644 index d39aaef8..00000000 --- a/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/getiampolicy/SyncGetIamPolicy.java +++ /dev/null @@ -1,48 +0,0 @@ -/* - * 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 and should be regarded as a code template only. - // It will require modifications to work: - // - It may require correct/in-range values for request initialization. - // - It may require specifying regional endpoints when creating the service client as shown in - // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library - 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/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/getiampolicy/SyncGetIamPolicyResourcename.java b/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/getiampolicy/SyncGetIamPolicyResourcename.java deleted file mode 100644 index afd18cc1..00000000 --- a/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/getiampolicy/SyncGetIamPolicyResourcename.java +++ /dev/null @@ -1,43 +0,0 @@ -/* - * 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 and should be regarded as a code template only. - // It will require modifications to work: - // - It may require correct/in-range values for request initialization. - // - It may require specifying regional endpoints when creating the service client as shown in - // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library - 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/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/getiampolicy/SyncGetIamPolicyString.java b/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/getiampolicy/SyncGetIamPolicyString.java deleted file mode 100644 index 325b52bc..00000000 --- a/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/getiampolicy/SyncGetIamPolicyString.java +++ /dev/null @@ -1,43 +0,0 @@ -/* - * 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 and should be regarded as a code template only. - // It will require modifications to work: - // - It may require correct/in-range values for request initialization. - // - It may require specifying regional endpoints when creating the service client as shown in - // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library - 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/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/listdeviceconfigversions/AsyncListDeviceConfigVersions.java b/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/listdeviceconfigversions/AsyncListDeviceConfigVersions.java deleted file mode 100644 index 3bc78f65..00000000 --- a/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/listdeviceconfigversions/AsyncListDeviceConfigVersions.java +++ /dev/null @@ -1,52 +0,0 @@ -/* - * 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 and should be regarded as a code template only. - // It will require modifications to work: - // - It may require correct/in-range values for request initialization. - // - It may require specifying regional endpoints when creating the service client as shown in - // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library - 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/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/listdeviceconfigversions/SyncListDeviceConfigVersions.java b/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/listdeviceconfigversions/SyncListDeviceConfigVersions.java deleted file mode 100644 index 099c31bc..00000000 --- a/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/listdeviceconfigversions/SyncListDeviceConfigVersions.java +++ /dev/null @@ -1,49 +0,0 @@ -/* - * 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 and should be regarded as a code template only. - // It will require modifications to work: - // - It may require correct/in-range values for request initialization. - // - It may require specifying regional endpoints when creating the service client as shown in - // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library - 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/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/listdeviceconfigversions/SyncListDeviceConfigVersionsDevicename.java b/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/listdeviceconfigversions/SyncListDeviceConfigVersionsDevicename.java deleted file mode 100644 index f1b1ab27..00000000 --- a/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/listdeviceconfigversions/SyncListDeviceConfigVersionsDevicename.java +++ /dev/null @@ -1,43 +0,0 @@ -/* - * 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 and should be regarded as a code template only. - // It will require modifications to work: - // - It may require correct/in-range values for request initialization. - // - It may require specifying regional endpoints when creating the service client as shown in - // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library - 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/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/listdeviceconfigversions/SyncListDeviceConfigVersionsString.java b/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/listdeviceconfigversions/SyncListDeviceConfigVersionsString.java deleted file mode 100644 index ce453141..00000000 --- a/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/listdeviceconfigversions/SyncListDeviceConfigVersionsString.java +++ /dev/null @@ -1,43 +0,0 @@ -/* - * 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 and should be regarded as a code template only. - // It will require modifications to work: - // - It may require correct/in-range values for request initialization. - // - It may require specifying regional endpoints when creating the service client as shown in - // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library - 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/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/listdeviceregistries/AsyncListDeviceRegistries.java b/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/listdeviceregistries/AsyncListDeviceRegistries.java deleted file mode 100644 index 1505390e..00000000 --- a/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/listdeviceregistries/AsyncListDeviceRegistries.java +++ /dev/null @@ -1,54 +0,0 @@ -/* - * 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 and should be regarded as a code template only. - // It will require modifications to work: - // - It may require correct/in-range values for request initialization. - // - It may require specifying regional endpoints when creating the service client as shown in - // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library - 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/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/listdeviceregistries/AsyncListDeviceRegistriesPaged.java b/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/listdeviceregistries/AsyncListDeviceRegistriesPaged.java deleted file mode 100644 index 1d15147f..00000000 --- a/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/listdeviceregistries/AsyncListDeviceRegistriesPaged.java +++ /dev/null @@ -1,62 +0,0 @@ -/* - * 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 and should be regarded as a code template only. - // It will require modifications to work: - // - It may require correct/in-range values for request initialization. - // - It may require specifying regional endpoints when creating the service client as shown in - // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library - 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/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/listdeviceregistries/SyncListDeviceRegistries.java b/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/listdeviceregistries/SyncListDeviceRegistries.java deleted file mode 100644 index aa193ba2..00000000 --- a/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/listdeviceregistries/SyncListDeviceRegistries.java +++ /dev/null @@ -1,51 +0,0 @@ -/* - * 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 and should be regarded as a code template only. - // It will require modifications to work: - // - It may require correct/in-range values for request initialization. - // - It may require specifying regional endpoints when creating the service client as shown in - // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library - 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/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/listdeviceregistries/SyncListDeviceRegistriesLocationname.java b/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/listdeviceregistries/SyncListDeviceRegistriesLocationname.java deleted file mode 100644 index 9fbe430e..00000000 --- a/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/listdeviceregistries/SyncListDeviceRegistriesLocationname.java +++ /dev/null @@ -1,44 +0,0 @@ -/* - * 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 and should be regarded as a code template only. - // It will require modifications to work: - // - It may require correct/in-range values for request initialization. - // - It may require specifying regional endpoints when creating the service client as shown in - // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library - 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/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/listdeviceregistries/SyncListDeviceRegistriesString.java b/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/listdeviceregistries/SyncListDeviceRegistriesString.java deleted file mode 100644 index 66eb18bc..00000000 --- a/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/listdeviceregistries/SyncListDeviceRegistriesString.java +++ /dev/null @@ -1,44 +0,0 @@ -/* - * 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 and should be regarded as a code template only. - // It will require modifications to work: - // - It may require correct/in-range values for request initialization. - // - It may require specifying regional endpoints when creating the service client as shown in - // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library - 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/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/listdevices/AsyncListDevices.java b/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/listdevices/AsyncListDevices.java deleted file mode 100644 index 5de58634..00000000 --- a/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/listdevices/AsyncListDevices.java +++ /dev/null @@ -1,60 +0,0 @@ -/* - * 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 and should be regarded as a code template only. - // It will require modifications to work: - // - It may require correct/in-range values for request initialization. - // - It may require specifying regional endpoints when creating the service client as shown in - // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library - 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/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/listdevices/AsyncListDevicesPaged.java b/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/listdevices/AsyncListDevicesPaged.java deleted file mode 100644 index b6834b22..00000000 --- a/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/listdevices/AsyncListDevicesPaged.java +++ /dev/null @@ -1,68 +0,0 @@ -/* - * 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 and should be regarded as a code template only. - // It will require modifications to work: - // - It may require correct/in-range values for request initialization. - // - It may require specifying regional endpoints when creating the service client as shown in - // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library - 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/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/listdevices/SyncListDevices.java b/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/listdevices/SyncListDevices.java deleted file mode 100644 index 35f931f4..00000000 --- a/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/listdevices/SyncListDevices.java +++ /dev/null @@ -1,57 +0,0 @@ -/* - * 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 and should be regarded as a code template only. - // It will require modifications to work: - // - It may require correct/in-range values for request initialization. - // - It may require specifying regional endpoints when creating the service client as shown in - // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library - 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/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/listdevices/SyncListDevicesRegistryname.java b/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/listdevices/SyncListDevicesRegistryname.java deleted file mode 100644 index babdca15..00000000 --- a/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/listdevices/SyncListDevicesRegistryname.java +++ /dev/null @@ -1,44 +0,0 @@ -/* - * 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 and should be regarded as a code template only. - // It will require modifications to work: - // - It may require correct/in-range values for request initialization. - // - It may require specifying regional endpoints when creating the service client as shown in - // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library - 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/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/listdevices/SyncListDevicesString.java b/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/listdevices/SyncListDevicesString.java deleted file mode 100644 index 30f00c4b..00000000 --- a/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/listdevices/SyncListDevicesString.java +++ /dev/null @@ -1,44 +0,0 @@ -/* - * 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 and should be regarded as a code template only. - // It will require modifications to work: - // - It may require correct/in-range values for request initialization. - // - It may require specifying regional endpoints when creating the service client as shown in - // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library - 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/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/listdevicestates/AsyncListDeviceStates.java b/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/listdevicestates/AsyncListDeviceStates.java deleted file mode 100644 index 13e122b8..00000000 --- a/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/listdevicestates/AsyncListDeviceStates.java +++ /dev/null @@ -1,52 +0,0 @@ -/* - * 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 and should be regarded as a code template only. - // It will require modifications to work: - // - It may require correct/in-range values for request initialization. - // - It may require specifying regional endpoints when creating the service client as shown in - // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library - 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/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/listdevicestates/SyncListDeviceStates.java b/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/listdevicestates/SyncListDeviceStates.java deleted file mode 100644 index b94cdca6..00000000 --- a/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/listdevicestates/SyncListDeviceStates.java +++ /dev/null @@ -1,48 +0,0 @@ -/* - * 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 and should be regarded as a code template only. - // It will require modifications to work: - // - It may require correct/in-range values for request initialization. - // - It may require specifying regional endpoints when creating the service client as shown in - // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library - 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/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/listdevicestates/SyncListDeviceStatesDevicename.java b/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/listdevicestates/SyncListDeviceStatesDevicename.java deleted file mode 100644 index 28087811..00000000 --- a/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/listdevicestates/SyncListDeviceStatesDevicename.java +++ /dev/null @@ -1,42 +0,0 @@ -/* - * 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 and should be regarded as a code template only. - // It will require modifications to work: - // - It may require correct/in-range values for request initialization. - // - It may require specifying regional endpoints when creating the service client as shown in - // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library - 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/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/listdevicestates/SyncListDeviceStatesString.java b/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/listdevicestates/SyncListDeviceStatesString.java deleted file mode 100644 index bef4b985..00000000 --- a/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/listdevicestates/SyncListDeviceStatesString.java +++ /dev/null @@ -1,42 +0,0 @@ -/* - * 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 and should be regarded as a code template only. - // It will require modifications to work: - // - It may require correct/in-range values for request initialization. - // - It may require specifying regional endpoints when creating the service client as shown in - // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library - 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/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/modifycloudtodeviceconfig/AsyncModifyCloudToDeviceConfig.java b/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/modifycloudtodeviceconfig/AsyncModifyCloudToDeviceConfig.java deleted file mode 100644 index 53ac67b0..00000000 --- a/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/modifycloudtodeviceconfig/AsyncModifyCloudToDeviceConfig.java +++ /dev/null @@ -1,54 +0,0 @@ -/* - * 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 and should be regarded as a code template only. - // It will require modifications to work: - // - It may require correct/in-range values for request initialization. - // - It may require specifying regional endpoints when creating the service client as shown in - // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library - 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/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/modifycloudtodeviceconfig/SyncModifyCloudToDeviceConfig.java b/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/modifycloudtodeviceconfig/SyncModifyCloudToDeviceConfig.java deleted file mode 100644 index b969d5c5..00000000 --- a/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/modifycloudtodeviceconfig/SyncModifyCloudToDeviceConfig.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * 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 and should be regarded as a code template only. - // It will require modifications to work: - // - It may require correct/in-range values for request initialization. - // - It may require specifying regional endpoints when creating the service client as shown in - // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library - 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/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/modifycloudtodeviceconfig/SyncModifyCloudToDeviceConfigDevicenameBytestring.java b/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/modifycloudtodeviceconfig/SyncModifyCloudToDeviceConfigDevicenameBytestring.java deleted file mode 100644 index 3e15c46c..00000000 --- a/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/modifycloudtodeviceconfig/SyncModifyCloudToDeviceConfigDevicenameBytestring.java +++ /dev/null @@ -1,44 +0,0 @@ -/* - * 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 and should be regarded as a code template only. - // It will require modifications to work: - // - It may require correct/in-range values for request initialization. - // - It may require specifying regional endpoints when creating the service client as shown in - // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library - 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/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/modifycloudtodeviceconfig/SyncModifyCloudToDeviceConfigStringBytestring.java b/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/modifycloudtodeviceconfig/SyncModifyCloudToDeviceConfigStringBytestring.java deleted file mode 100644 index af28c7a2..00000000 --- a/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/modifycloudtodeviceconfig/SyncModifyCloudToDeviceConfigStringBytestring.java +++ /dev/null @@ -1,44 +0,0 @@ -/* - * 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 and should be regarded as a code template only. - // It will require modifications to work: - // - It may require correct/in-range values for request initialization. - // - It may require specifying regional endpoints when creating the service client as shown in - // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library - 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/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/sendcommandtodevice/AsyncSendCommandToDevice.java b/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/sendcommandtodevice/AsyncSendCommandToDevice.java deleted file mode 100644 index b43ab6dd..00000000 --- a/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/sendcommandtodevice/AsyncSendCommandToDevice.java +++ /dev/null @@ -1,54 +0,0 @@ -/* - * 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 and should be regarded as a code template only. - // It will require modifications to work: - // - It may require correct/in-range values for request initialization. - // - It may require specifying regional endpoints when creating the service client as shown in - // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library - 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/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/sendcommandtodevice/SyncSendCommandToDevice.java b/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/sendcommandtodevice/SyncSendCommandToDevice.java deleted file mode 100644 index 245161f7..00000000 --- a/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/sendcommandtodevice/SyncSendCommandToDevice.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * 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 and should be regarded as a code template only. - // It will require modifications to work: - // - It may require correct/in-range values for request initialization. - // - It may require specifying regional endpoints when creating the service client as shown in - // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library - 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/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/sendcommandtodevice/SyncSendCommandToDeviceDevicenameBytestring.java b/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/sendcommandtodevice/SyncSendCommandToDeviceDevicenameBytestring.java deleted file mode 100644 index 9d671416..00000000 --- a/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/sendcommandtodevice/SyncSendCommandToDeviceDevicenameBytestring.java +++ /dev/null @@ -1,45 +0,0 @@ -/* - * 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 and should be regarded as a code template only. - // It will require modifications to work: - // - It may require correct/in-range values for request initialization. - // - It may require specifying regional endpoints when creating the service client as shown in - // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library - 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/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/sendcommandtodevice/SyncSendCommandToDeviceDevicenameBytestringString.java b/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/sendcommandtodevice/SyncSendCommandToDeviceDevicenameBytestringString.java deleted file mode 100644 index 4a5cbcae..00000000 --- a/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/sendcommandtodevice/SyncSendCommandToDeviceDevicenameBytestringString.java +++ /dev/null @@ -1,46 +0,0 @@ -/* - * 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 and should be regarded as a code template only. - // It will require modifications to work: - // - It may require correct/in-range values for request initialization. - // - It may require specifying regional endpoints when creating the service client as shown in - // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library - 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/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/sendcommandtodevice/SyncSendCommandToDeviceStringBytestring.java b/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/sendcommandtodevice/SyncSendCommandToDeviceStringBytestring.java deleted file mode 100644 index 37db077a..00000000 --- a/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/sendcommandtodevice/SyncSendCommandToDeviceStringBytestring.java +++ /dev/null @@ -1,45 +0,0 @@ -/* - * 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 and should be regarded as a code template only. - // It will require modifications to work: - // - It may require correct/in-range values for request initialization. - // - It may require specifying regional endpoints when creating the service client as shown in - // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library - 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/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/sendcommandtodevice/SyncSendCommandToDeviceStringBytestringString.java b/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/sendcommandtodevice/SyncSendCommandToDeviceStringBytestringString.java deleted file mode 100644 index e4c4ec9a..00000000 --- a/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/sendcommandtodevice/SyncSendCommandToDeviceStringBytestringString.java +++ /dev/null @@ -1,46 +0,0 @@ -/* - * 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 and should be regarded as a code template only. - // It will require modifications to work: - // - It may require correct/in-range values for request initialization. - // - It may require specifying regional endpoints when creating the service client as shown in - // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library - 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/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/setiampolicy/AsyncSetIamPolicy.java b/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/setiampolicy/AsyncSetIamPolicy.java deleted file mode 100644 index 444ef29a..00000000 --- a/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/setiampolicy/AsyncSetIamPolicy.java +++ /dev/null @@ -1,52 +0,0 @@ -/* - * 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 and should be regarded as a code template only. - // It will require modifications to work: - // - It may require correct/in-range values for request initialization. - // - It may require specifying regional endpoints when creating the service client as shown in - // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library - 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/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/setiampolicy/SyncSetIamPolicy.java b/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/setiampolicy/SyncSetIamPolicy.java deleted file mode 100644 index de60829e..00000000 --- a/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/setiampolicy/SyncSetIamPolicy.java +++ /dev/null @@ -1,49 +0,0 @@ -/* - * 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 and should be regarded as a code template only. - // It will require modifications to work: - // - It may require correct/in-range values for request initialization. - // - It may require specifying regional endpoints when creating the service client as shown in - // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library - 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/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/setiampolicy/SyncSetIamPolicyResourcenamePolicy.java b/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/setiampolicy/SyncSetIamPolicyResourcenamePolicy.java deleted file mode 100644 index 8f685e72..00000000 --- a/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/setiampolicy/SyncSetIamPolicyResourcenamePolicy.java +++ /dev/null @@ -1,44 +0,0 @@ -/* - * 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 and should be regarded as a code template only. - // It will require modifications to work: - // - It may require correct/in-range values for request initialization. - // - It may require specifying regional endpoints when creating the service client as shown in - // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library - 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/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/setiampolicy/SyncSetIamPolicyStringPolicy.java b/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/setiampolicy/SyncSetIamPolicyStringPolicy.java deleted file mode 100644 index 14b780a8..00000000 --- a/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/setiampolicy/SyncSetIamPolicyStringPolicy.java +++ /dev/null @@ -1,44 +0,0 @@ -/* - * 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 and should be regarded as a code template only. - // It will require modifications to work: - // - It may require correct/in-range values for request initialization. - // - It may require specifying regional endpoints when creating the service client as shown in - // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library - 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/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/testiampermissions/AsyncTestIamPermissions.java b/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/testiampermissions/AsyncTestIamPermissions.java deleted file mode 100644 index f64a9771..00000000 --- a/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/testiampermissions/AsyncTestIamPermissions.java +++ /dev/null @@ -1,52 +0,0 @@ -/* - * 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 and should be regarded as a code template only. - // It will require modifications to work: - // - It may require correct/in-range values for request initialization. - // - It may require specifying regional endpoints when creating the service client as shown in - // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library - 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/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/testiampermissions/SyncTestIamPermissions.java b/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/testiampermissions/SyncTestIamPermissions.java deleted file mode 100644 index 24804e6e..00000000 --- a/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/testiampermissions/SyncTestIamPermissions.java +++ /dev/null @@ -1,48 +0,0 @@ -/* - * 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 and should be regarded as a code template only. - // It will require modifications to work: - // - It may require correct/in-range values for request initialization. - // - It may require specifying regional endpoints when creating the service client as shown in - // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library - 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/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/testiampermissions/SyncTestIamPermissionsResourcenameListstring.java b/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/testiampermissions/SyncTestIamPermissionsResourcenameListstring.java deleted file mode 100644 index 408a6e2d..00000000 --- a/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/testiampermissions/SyncTestIamPermissionsResourcenameListstring.java +++ /dev/null @@ -1,47 +0,0 @@ -/* - * 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 and should be regarded as a code template only. - // It will require modifications to work: - // - It may require correct/in-range values for request initialization. - // - It may require specifying regional endpoints when creating the service client as shown in - // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library - 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/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/testiampermissions/SyncTestIamPermissionsStringListstring.java b/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/testiampermissions/SyncTestIamPermissionsStringListstring.java deleted file mode 100644 index ea6b4057..00000000 --- a/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/testiampermissions/SyncTestIamPermissionsStringListstring.java +++ /dev/null @@ -1,47 +0,0 @@ -/* - * 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 and should be regarded as a code template only. - // It will require modifications to work: - // - It may require correct/in-range values for request initialization. - // - It may require specifying regional endpoints when creating the service client as shown in - // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library - 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/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/unbinddevicefromgateway/AsyncUnbindDeviceFromGateway.java b/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/unbinddevicefromgateway/AsyncUnbindDeviceFromGateway.java deleted file mode 100644 index 1e750960..00000000 --- a/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/unbinddevicefromgateway/AsyncUnbindDeviceFromGateway.java +++ /dev/null @@ -1,52 +0,0 @@ -/* - * 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 and should be regarded as a code template only. - // It will require modifications to work: - // - It may require correct/in-range values for request initialization. - // - It may require specifying regional endpoints when creating the service client as shown in - // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library - 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/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/unbinddevicefromgateway/SyncUnbindDeviceFromGateway.java b/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/unbinddevicefromgateway/SyncUnbindDeviceFromGateway.java deleted file mode 100644 index 05ac4995..00000000 --- a/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/unbinddevicefromgateway/SyncUnbindDeviceFromGateway.java +++ /dev/null @@ -1,49 +0,0 @@ -/* - * 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 and should be regarded as a code template only. - // It will require modifications to work: - // - It may require correct/in-range values for request initialization. - // - It may require specifying regional endpoints when creating the service client as shown in - // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library - 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/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/unbinddevicefromgateway/SyncUnbindDeviceFromGatewayRegistrynameStringString.java b/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/unbinddevicefromgateway/SyncUnbindDeviceFromGatewayRegistrynameStringString.java deleted file mode 100644 index b5ca333b..00000000 --- a/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/unbinddevicefromgateway/SyncUnbindDeviceFromGatewayRegistrynameStringString.java +++ /dev/null @@ -1,45 +0,0 @@ -/* - * 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 and should be regarded as a code template only. - // It will require modifications to work: - // - It may require correct/in-range values for request initialization. - // - It may require specifying regional endpoints when creating the service client as shown in - // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library - 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/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/unbinddevicefromgateway/SyncUnbindDeviceFromGatewayStringStringString.java b/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/unbinddevicefromgateway/SyncUnbindDeviceFromGatewayStringStringString.java deleted file mode 100644 index c3242587..00000000 --- a/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/unbinddevicefromgateway/SyncUnbindDeviceFromGatewayStringStringString.java +++ /dev/null @@ -1,45 +0,0 @@ -/* - * 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 and should be regarded as a code template only. - // It will require modifications to work: - // - It may require correct/in-range values for request initialization. - // - It may require specifying regional endpoints when creating the service client as shown in - // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library - 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/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/updatedevice/AsyncUpdateDevice.java b/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/updatedevice/AsyncUpdateDevice.java deleted file mode 100644 index e7fe139f..00000000 --- a/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/updatedevice/AsyncUpdateDevice.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * 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 and should be regarded as a code template only. - // It will require modifications to work: - // - It may require correct/in-range values for request initialization. - // - It may require specifying regional endpoints when creating the service client as shown in - // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library - 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/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/updatedevice/SyncUpdateDevice.java b/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/updatedevice/SyncUpdateDevice.java deleted file mode 100644 index d4738692..00000000 --- a/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/updatedevice/SyncUpdateDevice.java +++ /dev/null @@ -1,47 +0,0 @@ -/* - * 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 and should be regarded as a code template only. - // It will require modifications to work: - // - It may require correct/in-range values for request initialization. - // - It may require specifying regional endpoints when creating the service client as shown in - // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library - 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/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/updatedevice/SyncUpdateDeviceDeviceFieldmask.java b/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/updatedevice/SyncUpdateDeviceDeviceFieldmask.java deleted file mode 100644 index 340f7f05..00000000 --- a/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/updatedevice/SyncUpdateDeviceDeviceFieldmask.java +++ /dev/null @@ -1,43 +0,0 @@ -/* - * 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 and should be regarded as a code template only. - // It will require modifications to work: - // - It may require correct/in-range values for request initialization. - // - It may require specifying regional endpoints when creating the service client as shown in - // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library - 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/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/updatedeviceregistry/AsyncUpdateDeviceRegistry.java b/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/updatedeviceregistry/AsyncUpdateDeviceRegistry.java deleted file mode 100644 index 61f76c97..00000000 --- a/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/updatedeviceregistry/AsyncUpdateDeviceRegistry.java +++ /dev/null @@ -1,51 +0,0 @@ -/* - * 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 and should be regarded as a code template only. - // It will require modifications to work: - // - It may require correct/in-range values for request initialization. - // - It may require specifying regional endpoints when creating the service client as shown in - // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library - 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/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/updatedeviceregistry/SyncUpdateDeviceRegistry.java b/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/updatedeviceregistry/SyncUpdateDeviceRegistry.java deleted file mode 100644 index a4c294e8..00000000 --- a/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/updatedeviceregistry/SyncUpdateDeviceRegistry.java +++ /dev/null @@ -1,47 +0,0 @@ -/* - * 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 and should be regarded as a code template only. - // It will require modifications to work: - // - It may require correct/in-range values for request initialization. - // - It may require specifying regional endpoints when creating the service client as shown in - // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library - 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/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/updatedeviceregistry/SyncUpdateDeviceRegistryDeviceregistryFieldmask.java b/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/updatedeviceregistry/SyncUpdateDeviceRegistryDeviceregistryFieldmask.java deleted file mode 100644 index 02623e6a..00000000 --- a/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagerclient/updatedeviceregistry/SyncUpdateDeviceRegistryDeviceregistryFieldmask.java +++ /dev/null @@ -1,44 +0,0 @@ -/* - * 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 and should be regarded as a code template only. - // It will require modifications to work: - // - It may require correct/in-range values for request initialization. - // - It may require specifying regional endpoints when creating the service client as shown in - // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library - 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/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagersettings/createdeviceregistry/SyncCreateDeviceRegistry.java b/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagersettings/createdeviceregistry/SyncCreateDeviceRegistry.java deleted file mode 100644 index 2f78cb64..00000000 --- a/samples/snippets/generated/com/google/cloud/iot/v1/devicemanagersettings/createdeviceregistry/SyncCreateDeviceRegistry.java +++ /dev/null @@ -1,48 +0,0 @@ -/* - * 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 and should be regarded as a code template only. - // It will require modifications to work: - // - It may require correct/in-range values for request initialization. - // - It may require specifying regional endpoints when creating the service client as shown in - // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library - 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/samples/snippets/generated/com/google/cloud/iot/v1/stub/devicemanagerstubsettings/createdeviceregistry/SyncCreateDeviceRegistry.java b/samples/snippets/generated/com/google/cloud/iot/v1/stub/devicemanagerstubsettings/createdeviceregistry/SyncCreateDeviceRegistry.java deleted file mode 100644 index b4d979e5..00000000 --- a/samples/snippets/generated/com/google/cloud/iot/v1/stub/devicemanagerstubsettings/createdeviceregistry/SyncCreateDeviceRegistry.java +++ /dev/null @@ -1,49 +0,0 @@ -/* - * 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 and should be regarded as a code template only. - // It will require modifications to work: - // - It may require correct/in-range values for request initialization. - // - It may require specifying regional endpoints when creating the service client as shown in - // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library - 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] diff --git a/samples/snippets/pom.xml b/samples/snippets/pom.xml deleted file mode 100644 index 4ee878a1..00000000 --- a/samples/snippets/pom.xml +++ /dev/null @@ -1,60 +0,0 @@ - - - 4.0.0 - com.google.cloud - cloudiot-snippets - jar - Google Google Cloud Internet of Things (IoT) Core Snippets - https://github.com/googleapis/java-iot - - - - com.google.cloud.samples - shared-configuration - 1.2.0 - - - - 1.8 - 1.8 - UTF-8 - - - - - - - - com.google.cloud - libraries-bom - 26.1.2 - pom - import - - - - - - - com.google.cloud - google-cloud-iot - - - - - junit - junit - 4.13.2 - test - - - com.google.truth - truth - 1.1.3 - test - - - diff --git a/synth.metadata b/synth.metadata deleted file mode 100644 index b71f6294..00000000 --- a/synth.metadata +++ /dev/null @@ -1,214 +0,0 @@ -{ - "sources": [ - { - "git": { - "name": ".", - "remote": "https://github.com/googleapis/java-iot.git", - "sha": "41703ce9dae6fe99b72b588f3ba5d6382b369405" - } - }, - { - "git": { - "name": "googleapis", - "remote": "https://github.com/googleapis/googleapis.git", - "sha": "08c4eeb531c01ad031134dca94b18e3f7dd35902", - "internalRef": "378718217" - } - }, - { - "git": { - "name": "synthtool", - "remote": "https://github.com/googleapis/synthtool.git", - "sha": "8eae0234a16b26c2ff616d305dbd9786c8b10a47" - } - } - ], - "destinations": [ - { - "client": { - "source": "googleapis", - "apiName": "iot", - "apiVersion": "v1", - "language": "java", - "generator": "bazel" - } - } - ], - "generatedFiles": [ - ".github/CODEOWNERS", - ".github/ISSUE_TEMPLATE/bug_report.md", - ".github/ISSUE_TEMPLATE/feature_request.md", - ".github/ISSUE_TEMPLATE/support_request.md", - ".github/PULL_REQUEST_TEMPLATE.md", - ".github/generated-files-bot.yml", - ".github/readme/synth.py", - ".github/release-please.yml", - ".github/snippet-bot.yml", - ".github/sync-repo-settings.yaml", - ".github/trusted-contribution.yml", - ".github/workflows/approve-readme.yaml", - ".github/workflows/auto-release.yaml", - ".github/workflows/ci.yaml", - ".github/workflows/samples.yaml", - ".kokoro/build.bat", - ".kokoro/build.sh", - ".kokoro/coerce_logs.sh", - ".kokoro/common.cfg", - ".kokoro/common.sh", - ".kokoro/continuous/common.cfg", - ".kokoro/continuous/java8.cfg", - ".kokoro/continuous/readme.cfg", - ".kokoro/dependencies.sh", - ".kokoro/nightly/common.cfg", - ".kokoro/nightly/integration.cfg", - ".kokoro/nightly/java11.cfg", - ".kokoro/nightly/java7.cfg", - ".kokoro/nightly/java8-osx.cfg", - ".kokoro/nightly/java8-win.cfg", - ".kokoro/nightly/java8.cfg", - ".kokoro/nightly/samples.cfg", - ".kokoro/populate-secrets.sh", - ".kokoro/presubmit/clirr.cfg", - ".kokoro/presubmit/common.cfg", - ".kokoro/presubmit/dependencies.cfg", - ".kokoro/presubmit/integration.cfg", - ".kokoro/presubmit/java11.cfg", - ".kokoro/presubmit/java7.cfg", - ".kokoro/presubmit/java8-osx.cfg", - ".kokoro/presubmit/java8-win.cfg", - ".kokoro/presubmit/java8.cfg", - ".kokoro/presubmit/linkage-monitor.cfg", - ".kokoro/presubmit/lint.cfg", - ".kokoro/presubmit/samples.cfg", - ".kokoro/readme.sh", - ".kokoro/release/bump_snapshot.cfg", - ".kokoro/release/common.cfg", - ".kokoro/release/common.sh", - ".kokoro/release/drop.cfg", - ".kokoro/release/drop.sh", - ".kokoro/release/promote.cfg", - ".kokoro/release/promote.sh", - ".kokoro/release/publish_javadoc.cfg", - ".kokoro/release/publish_javadoc.sh", - ".kokoro/release/publish_javadoc11.cfg", - ".kokoro/release/publish_javadoc11.sh", - ".kokoro/release/snapshot.cfg", - ".kokoro/release/snapshot.sh", - ".kokoro/release/stage.cfg", - ".kokoro/release/stage.sh", - ".kokoro/trampoline.sh", - "CODE_OF_CONDUCT.md", - "CONTRIBUTING.md", - "LICENSE", - "codecov.yaml", - "google-cloud-iot/src/main/java/com/google/cloud/iot/v1/DeviceManagerClient.java", - "google-cloud-iot/src/main/java/com/google/cloud/iot/v1/DeviceManagerSettings.java", - "google-cloud-iot/src/main/java/com/google/cloud/iot/v1/gapic_metadata.json", - "google-cloud-iot/src/main/java/com/google/cloud/iot/v1/package-info.java", - "google-cloud-iot/src/main/java/com/google/cloud/iot/v1/stub/DeviceManagerStub.java", - "google-cloud-iot/src/main/java/com/google/cloud/iot/v1/stub/DeviceManagerStubSettings.java", - "google-cloud-iot/src/main/java/com/google/cloud/iot/v1/stub/GrpcDeviceManagerCallableFactory.java", - "google-cloud-iot/src/main/java/com/google/cloud/iot/v1/stub/GrpcDeviceManagerStub.java", - "google-cloud-iot/src/test/java/com/google/cloud/iot/v1/DeviceManagerClientTest.java", - "google-cloud-iot/src/test/java/com/google/cloud/iot/v1/MockDeviceManager.java", - "google-cloud-iot/src/test/java/com/google/cloud/iot/v1/MockDeviceManagerImpl.java", - "grpc-google-cloud-iot-v1/src/main/java/com/google/cloud/iot/v1/DeviceManagerGrpc.java", - "java.header", - "license-checks.xml", - "proto-google-cloud-iot-v1/src/main/java/com/google/cloud/iot/v1/BindDeviceToGatewayRequest.java", - "proto-google-cloud-iot-v1/src/main/java/com/google/cloud/iot/v1/BindDeviceToGatewayRequestOrBuilder.java", - "proto-google-cloud-iot-v1/src/main/java/com/google/cloud/iot/v1/BindDeviceToGatewayResponse.java", - "proto-google-cloud-iot-v1/src/main/java/com/google/cloud/iot/v1/BindDeviceToGatewayResponseOrBuilder.java", - "proto-google-cloud-iot-v1/src/main/java/com/google/cloud/iot/v1/CreateDeviceRegistryRequest.java", - "proto-google-cloud-iot-v1/src/main/java/com/google/cloud/iot/v1/CreateDeviceRegistryRequestOrBuilder.java", - "proto-google-cloud-iot-v1/src/main/java/com/google/cloud/iot/v1/CreateDeviceRequest.java", - "proto-google-cloud-iot-v1/src/main/java/com/google/cloud/iot/v1/CreateDeviceRequestOrBuilder.java", - "proto-google-cloud-iot-v1/src/main/java/com/google/cloud/iot/v1/DeleteDeviceRegistryRequest.java", - "proto-google-cloud-iot-v1/src/main/java/com/google/cloud/iot/v1/DeleteDeviceRegistryRequestOrBuilder.java", - "proto-google-cloud-iot-v1/src/main/java/com/google/cloud/iot/v1/DeleteDeviceRequest.java", - "proto-google-cloud-iot-v1/src/main/java/com/google/cloud/iot/v1/DeleteDeviceRequestOrBuilder.java", - "proto-google-cloud-iot-v1/src/main/java/com/google/cloud/iot/v1/Device.java", - "proto-google-cloud-iot-v1/src/main/java/com/google/cloud/iot/v1/DeviceConfig.java", - "proto-google-cloud-iot-v1/src/main/java/com/google/cloud/iot/v1/DeviceConfigOrBuilder.java", - "proto-google-cloud-iot-v1/src/main/java/com/google/cloud/iot/v1/DeviceCredential.java", - "proto-google-cloud-iot-v1/src/main/java/com/google/cloud/iot/v1/DeviceCredentialOrBuilder.java", - "proto-google-cloud-iot-v1/src/main/java/com/google/cloud/iot/v1/DeviceManagerProto.java", - "proto-google-cloud-iot-v1/src/main/java/com/google/cloud/iot/v1/DeviceName.java", - "proto-google-cloud-iot-v1/src/main/java/com/google/cloud/iot/v1/DeviceOrBuilder.java", - "proto-google-cloud-iot-v1/src/main/java/com/google/cloud/iot/v1/DeviceRegistry.java", - "proto-google-cloud-iot-v1/src/main/java/com/google/cloud/iot/v1/DeviceRegistryOrBuilder.java", - "proto-google-cloud-iot-v1/src/main/java/com/google/cloud/iot/v1/DeviceState.java", - "proto-google-cloud-iot-v1/src/main/java/com/google/cloud/iot/v1/DeviceStateOrBuilder.java", - "proto-google-cloud-iot-v1/src/main/java/com/google/cloud/iot/v1/EventNotificationConfig.java", - "proto-google-cloud-iot-v1/src/main/java/com/google/cloud/iot/v1/EventNotificationConfigOrBuilder.java", - "proto-google-cloud-iot-v1/src/main/java/com/google/cloud/iot/v1/GatewayAuthMethod.java", - "proto-google-cloud-iot-v1/src/main/java/com/google/cloud/iot/v1/GatewayConfig.java", - "proto-google-cloud-iot-v1/src/main/java/com/google/cloud/iot/v1/GatewayConfigOrBuilder.java", - "proto-google-cloud-iot-v1/src/main/java/com/google/cloud/iot/v1/GatewayListOptions.java", - "proto-google-cloud-iot-v1/src/main/java/com/google/cloud/iot/v1/GatewayListOptionsOrBuilder.java", - "proto-google-cloud-iot-v1/src/main/java/com/google/cloud/iot/v1/GatewayType.java", - "proto-google-cloud-iot-v1/src/main/java/com/google/cloud/iot/v1/GetDeviceRegistryRequest.java", - "proto-google-cloud-iot-v1/src/main/java/com/google/cloud/iot/v1/GetDeviceRegistryRequestOrBuilder.java", - "proto-google-cloud-iot-v1/src/main/java/com/google/cloud/iot/v1/GetDeviceRequest.java", - "proto-google-cloud-iot-v1/src/main/java/com/google/cloud/iot/v1/GetDeviceRequestOrBuilder.java", - "proto-google-cloud-iot-v1/src/main/java/com/google/cloud/iot/v1/HttpConfig.java", - "proto-google-cloud-iot-v1/src/main/java/com/google/cloud/iot/v1/HttpConfigOrBuilder.java", - "proto-google-cloud-iot-v1/src/main/java/com/google/cloud/iot/v1/HttpState.java", - "proto-google-cloud-iot-v1/src/main/java/com/google/cloud/iot/v1/ListDeviceConfigVersionsRequest.java", - "proto-google-cloud-iot-v1/src/main/java/com/google/cloud/iot/v1/ListDeviceConfigVersionsRequestOrBuilder.java", - "proto-google-cloud-iot-v1/src/main/java/com/google/cloud/iot/v1/ListDeviceConfigVersionsResponse.java", - "proto-google-cloud-iot-v1/src/main/java/com/google/cloud/iot/v1/ListDeviceConfigVersionsResponseOrBuilder.java", - "proto-google-cloud-iot-v1/src/main/java/com/google/cloud/iot/v1/ListDeviceRegistriesRequest.java", - "proto-google-cloud-iot-v1/src/main/java/com/google/cloud/iot/v1/ListDeviceRegistriesRequestOrBuilder.java", - "proto-google-cloud-iot-v1/src/main/java/com/google/cloud/iot/v1/ListDeviceRegistriesResponse.java", - "proto-google-cloud-iot-v1/src/main/java/com/google/cloud/iot/v1/ListDeviceRegistriesResponseOrBuilder.java", - "proto-google-cloud-iot-v1/src/main/java/com/google/cloud/iot/v1/ListDeviceStatesRequest.java", - "proto-google-cloud-iot-v1/src/main/java/com/google/cloud/iot/v1/ListDeviceStatesRequestOrBuilder.java", - "proto-google-cloud-iot-v1/src/main/java/com/google/cloud/iot/v1/ListDeviceStatesResponse.java", - "proto-google-cloud-iot-v1/src/main/java/com/google/cloud/iot/v1/ListDeviceStatesResponseOrBuilder.java", - "proto-google-cloud-iot-v1/src/main/java/com/google/cloud/iot/v1/ListDevicesRequest.java", - "proto-google-cloud-iot-v1/src/main/java/com/google/cloud/iot/v1/ListDevicesRequestOrBuilder.java", - "proto-google-cloud-iot-v1/src/main/java/com/google/cloud/iot/v1/ListDevicesResponse.java", - "proto-google-cloud-iot-v1/src/main/java/com/google/cloud/iot/v1/ListDevicesResponseOrBuilder.java", - "proto-google-cloud-iot-v1/src/main/java/com/google/cloud/iot/v1/LocationName.java", - "proto-google-cloud-iot-v1/src/main/java/com/google/cloud/iot/v1/LogLevel.java", - "proto-google-cloud-iot-v1/src/main/java/com/google/cloud/iot/v1/ModifyCloudToDeviceConfigRequest.java", - "proto-google-cloud-iot-v1/src/main/java/com/google/cloud/iot/v1/ModifyCloudToDeviceConfigRequestOrBuilder.java", - "proto-google-cloud-iot-v1/src/main/java/com/google/cloud/iot/v1/MqttConfig.java", - "proto-google-cloud-iot-v1/src/main/java/com/google/cloud/iot/v1/MqttConfigOrBuilder.java", - "proto-google-cloud-iot-v1/src/main/java/com/google/cloud/iot/v1/MqttState.java", - "proto-google-cloud-iot-v1/src/main/java/com/google/cloud/iot/v1/PublicKeyCertificate.java", - "proto-google-cloud-iot-v1/src/main/java/com/google/cloud/iot/v1/PublicKeyCertificateFormat.java", - "proto-google-cloud-iot-v1/src/main/java/com/google/cloud/iot/v1/PublicKeyCertificateOrBuilder.java", - "proto-google-cloud-iot-v1/src/main/java/com/google/cloud/iot/v1/PublicKeyCredential.java", - "proto-google-cloud-iot-v1/src/main/java/com/google/cloud/iot/v1/PublicKeyCredentialOrBuilder.java", - "proto-google-cloud-iot-v1/src/main/java/com/google/cloud/iot/v1/PublicKeyFormat.java", - "proto-google-cloud-iot-v1/src/main/java/com/google/cloud/iot/v1/RegistryCredential.java", - "proto-google-cloud-iot-v1/src/main/java/com/google/cloud/iot/v1/RegistryCredentialOrBuilder.java", - "proto-google-cloud-iot-v1/src/main/java/com/google/cloud/iot/v1/RegistryName.java", - "proto-google-cloud-iot-v1/src/main/java/com/google/cloud/iot/v1/ResourcesProto.java", - "proto-google-cloud-iot-v1/src/main/java/com/google/cloud/iot/v1/SendCommandToDeviceRequest.java", - "proto-google-cloud-iot-v1/src/main/java/com/google/cloud/iot/v1/SendCommandToDeviceRequestOrBuilder.java", - "proto-google-cloud-iot-v1/src/main/java/com/google/cloud/iot/v1/SendCommandToDeviceResponse.java", - "proto-google-cloud-iot-v1/src/main/java/com/google/cloud/iot/v1/SendCommandToDeviceResponseOrBuilder.java", - "proto-google-cloud-iot-v1/src/main/java/com/google/cloud/iot/v1/StateNotificationConfig.java", - "proto-google-cloud-iot-v1/src/main/java/com/google/cloud/iot/v1/StateNotificationConfigOrBuilder.java", - "proto-google-cloud-iot-v1/src/main/java/com/google/cloud/iot/v1/UnbindDeviceFromGatewayRequest.java", - "proto-google-cloud-iot-v1/src/main/java/com/google/cloud/iot/v1/UnbindDeviceFromGatewayRequestOrBuilder.java", - "proto-google-cloud-iot-v1/src/main/java/com/google/cloud/iot/v1/UnbindDeviceFromGatewayResponse.java", - "proto-google-cloud-iot-v1/src/main/java/com/google/cloud/iot/v1/UnbindDeviceFromGatewayResponseOrBuilder.java", - "proto-google-cloud-iot-v1/src/main/java/com/google/cloud/iot/v1/UpdateDeviceRegistryRequest.java", - "proto-google-cloud-iot-v1/src/main/java/com/google/cloud/iot/v1/UpdateDeviceRegistryRequestOrBuilder.java", - "proto-google-cloud-iot-v1/src/main/java/com/google/cloud/iot/v1/UpdateDeviceRequest.java", - "proto-google-cloud-iot-v1/src/main/java/com/google/cloud/iot/v1/UpdateDeviceRequestOrBuilder.java", - "proto-google-cloud-iot-v1/src/main/java/com/google/cloud/iot/v1/X509CertificateDetails.java", - "proto-google-cloud-iot-v1/src/main/java/com/google/cloud/iot/v1/X509CertificateDetailsOrBuilder.java", - "proto-google-cloud-iot-v1/src/main/proto/google/cloud/iot/v1/device_manager.proto", - "proto-google-cloud-iot-v1/src/main/proto/google/cloud/iot/v1/resources.proto", - "renovate.json", - "samples/install-without-bom/pom.xml", - "samples/pom.xml", - "samples/snapshot/pom.xml", - "samples/snippets/pom.xml" - ] -} \ No newline at end of file diff --git a/versions.txt b/versions.txt deleted file mode 100644 index 77173b8c..00000000 --- a/versions.txt +++ /dev/null @@ -1,6 +0,0 @@ -# Format: -# module:released-version:current-version - -google-cloud-iot:2.3.5:2.3.5 -grpc-google-cloud-iot-v1:2.3.5:2.3.5 -proto-google-cloud-iot-v1:2.3.5:2.3.5 From 4a61017389a60c40136a31d986643d79b90292d3 Mon Sep 17 00:00:00 2001 From: RashmiK14 Date: Tue, 25 Oct 2022 19:30:04 +0530 Subject: [PATCH 002/151] Lint changes applied on initial commit --- clearblade-cloud-iot/.metadata/.lock | 0 clearblade-cloud-iot/.metadata/.log | 253 ++ .../.metadata/.mylyn/repositories.xml.zip | Bin 0 -> 685 bytes .../.org.eclipse.egit.core.cmp/.location | Bin 0 -> 163 bytes .../.root/.indexes/history.version | 1 + .../.root/.indexes/properties.index | Bin 0 -> 57 bytes .../.root/.indexes/properties.version | 1 + .../org.eclipse.core.resources/.root/2.tree | Bin 0 -> 189 bytes .../.safetable/org.eclipse.core.resources | Bin 0 -> 653 bytes .../org.eclipse.e4.workbench/workbench.xmi | 3024 +++++++++++++++++ .../org.eclipse.egit.ui/dialog_settings.xml | 11 + .../assumedExternalFilesCache | Bin 0 -> 4 bytes .../org.eclipse.jdt.core/externalFilesCache | Bin 0 -> 4 bytes .../org.eclipse.jdt.core/javaLikeNames.txt | 1 + .../org.eclipse.jdt.core/nonChainingJarsCache | Bin 0 -> 4 bytes .../variablesAndContainers.dat | Bin 0 -> 129 bytes .../org.eclipse.jdt.ui/OpenTypeHistory.xml | 2 + .../QualifiedTypeNameHistory.xml | 2 + .../org.eclipse.m2e.core/workspaceState.ser | Bin 0 -> 538 bytes .../0.log | 2 + .../logback.1.16.3.20211002-1029.xml | 41 + .../org.eclipse.oomph.setup/workspace.setup | 6 + .../org.eclipse.tips.ide/dialog_settings.xml | 3 + .../org.eclipse.ui.ide/dialog_settings.xml | 26 + .../.plugins/org.eclipse.ui.intro/introstate | 2 + .../dialog_settings.xml | 12 + .../dialog_settings.xml | 11 + .../org.eclipse.ui.workbench/workingsets.xml | 6 + .../system-catalog.xml | 229 ++ .../hidden.xml | Bin 0 -> 138 bytes .../org.eclipse.wst.common.snippets/user.xml | Bin 0 -> 766 bytes .../dialog_settings.xml | 5 + clearblade-cloud-iot/.metadata/version.ini | 3 + .../cloud/iot/v1/SyncSendCommandToDevice.java | 35 +- .../cloud/iot/v1/DeviceManagerClient.java | 36 +- .../iot/v1/SendCommandToDeviceRequest.java | 87 +- .../iot/v1/SendCommandToDeviceResponse.java | 103 +- .../cloud/iot/v1/utils/ByteString.java | 31 + .../cloud/iot/v1/utils/Constants.java | 12 +- .../cloud/iot/v1/utils/DeviceName.java | 48 +- 40 files changed, 3828 insertions(+), 165 deletions(-) create mode 100644 clearblade-cloud-iot/.metadata/.lock create mode 100644 clearblade-cloud-iot/.metadata/.log create mode 100644 clearblade-cloud-iot/.metadata/.mylyn/repositories.xml.zip create mode 100644 clearblade-cloud-iot/.metadata/.plugins/org.eclipse.core.resources/.projects/.org.eclipse.egit.core.cmp/.location create mode 100644 clearblade-cloud-iot/.metadata/.plugins/org.eclipse.core.resources/.root/.indexes/history.version create mode 100644 clearblade-cloud-iot/.metadata/.plugins/org.eclipse.core.resources/.root/.indexes/properties.index create mode 100644 clearblade-cloud-iot/.metadata/.plugins/org.eclipse.core.resources/.root/.indexes/properties.version create mode 100644 clearblade-cloud-iot/.metadata/.plugins/org.eclipse.core.resources/.root/2.tree create mode 100644 clearblade-cloud-iot/.metadata/.plugins/org.eclipse.core.resources/.safetable/org.eclipse.core.resources create mode 100644 clearblade-cloud-iot/.metadata/.plugins/org.eclipse.e4.workbench/workbench.xmi create mode 100644 clearblade-cloud-iot/.metadata/.plugins/org.eclipse.egit.ui/dialog_settings.xml create mode 100644 clearblade-cloud-iot/.metadata/.plugins/org.eclipse.jdt.core/assumedExternalFilesCache create mode 100644 clearblade-cloud-iot/.metadata/.plugins/org.eclipse.jdt.core/externalFilesCache create mode 100644 clearblade-cloud-iot/.metadata/.plugins/org.eclipse.jdt.core/javaLikeNames.txt create mode 100644 clearblade-cloud-iot/.metadata/.plugins/org.eclipse.jdt.core/nonChainingJarsCache create mode 100644 clearblade-cloud-iot/.metadata/.plugins/org.eclipse.jdt.core/variablesAndContainers.dat create mode 100644 clearblade-cloud-iot/.metadata/.plugins/org.eclipse.jdt.ui/OpenTypeHistory.xml create mode 100644 clearblade-cloud-iot/.metadata/.plugins/org.eclipse.jdt.ui/QualifiedTypeNameHistory.xml create mode 100644 clearblade-cloud-iot/.metadata/.plugins/org.eclipse.m2e.core/workspaceState.ser create mode 100644 clearblade-cloud-iot/.metadata/.plugins/org.eclipse.m2e.logback.configuration/0.log create mode 100644 clearblade-cloud-iot/.metadata/.plugins/org.eclipse.m2e.logback.configuration/logback.1.16.3.20211002-1029.xml create mode 100644 clearblade-cloud-iot/.metadata/.plugins/org.eclipse.oomph.setup/workspace.setup create mode 100644 clearblade-cloud-iot/.metadata/.plugins/org.eclipse.tips.ide/dialog_settings.xml create mode 100644 clearblade-cloud-iot/.metadata/.plugins/org.eclipse.ui.ide/dialog_settings.xml create mode 100644 clearblade-cloud-iot/.metadata/.plugins/org.eclipse.ui.intro/introstate create mode 100644 clearblade-cloud-iot/.metadata/.plugins/org.eclipse.ui.views.log/dialog_settings.xml create mode 100644 clearblade-cloud-iot/.metadata/.plugins/org.eclipse.ui.workbench/dialog_settings.xml create mode 100644 clearblade-cloud-iot/.metadata/.plugins/org.eclipse.ui.workbench/workingsets.xml create mode 100644 clearblade-cloud-iot/.metadata/.plugins/org.eclipse.wildwebdeveloper.xml/system-catalog.xml create mode 100644 clearblade-cloud-iot/.metadata/.plugins/org.eclipse.wst.common.snippets/hidden.xml create mode 100644 clearblade-cloud-iot/.metadata/.plugins/org.eclipse.wst.common.snippets/user.xml create mode 100644 clearblade-cloud-iot/.metadata/.plugins/org.eclipse.wst.sse.ui/dialog_settings.xml create mode 100644 clearblade-cloud-iot/.metadata/version.ini create mode 100644 clearblade-cloud-iot/src/main/java/com/clearblade/cloud/iot/v1/utils/ByteString.java diff --git a/clearblade-cloud-iot/.metadata/.lock b/clearblade-cloud-iot/.metadata/.lock new file mode 100644 index 00000000..e69de29b diff --git a/clearblade-cloud-iot/.metadata/.log b/clearblade-cloud-iot/.metadata/.log new file mode 100644 index 00000000..77a46ed9 --- /dev/null +++ b/clearblade-cloud-iot/.metadata/.log @@ -0,0 +1,253 @@ +!SESSION 2022-10-25 12:50:37.162 ----------------------------------------------- +eclipse.buildId=4.23.0.I20220308-0310 +java.version=18.0.1.1 +java.vendor=Oracle Corporation +BootLoader constants: OS=win32, ARCH=x86_64, WS=win32, NL=en_IN +Framework arguments: -product org.eclipse.epp.package.jee.product +Command-line arguments: -os win32 -ws win32 -arch x86_64 -product org.eclipse.epp.package.jee.product + +!ENTRY org.eclipse.jface 2 0 2022-10-25 12:50:50.177 +!MESSAGE Keybinding conflicts occurred. They may interfere with normal accelerator operation. +!SUBENTRY 1 org.eclipse.jface 2 0 2022-10-25 12:50:50.177 +!MESSAGE A conflict occurred for CTRL+SHIFT+T: +Binding(CTRL+SHIFT+T, + ParameterizedCommand(Command(org.eclipse.jdt.ui.navigate.open.type,Open Type, + Open a type in a Java editor, + Category(org.eclipse.ui.category.navigate,Navigate,null,true), + org.eclipse.ui.internal.WorkbenchHandlerServiceHandler@46059b73, + ,,true),null), + org.eclipse.ui.defaultAcceleratorConfiguration, + org.eclipse.ui.contexts.window,,,system) +Binding(CTRL+SHIFT+T, + ParameterizedCommand(Command(org.eclipse.lsp4e.symbolinworkspace,Go to Symbol in Workspace, + , + Category(org.eclipse.lsp4e.category,Language Servers,null,true), + org.eclipse.ui.internal.WorkbenchHandlerServiceHandler@3b446d7, + ,,true),null), + org.eclipse.ui.defaultAcceleratorConfiguration, + org.eclipse.ui.contexts.window,,,system) +!SUBENTRY 1 org.eclipse.jface 2 0 2022-10-25 12:50:50.177 +!MESSAGE A conflict occurred for ALT+SHIFT+R: +Binding(ALT+SHIFT+R, + ParameterizedCommand(Command(org.eclipse.jdt.ui.edit.text.java.rename.element,Rename - Refactoring , + Rename the selected element, + Category(org.eclipse.jdt.ui.category.refactoring,Refactor - Java,Java Refactoring Actions,true), + org.eclipse.ui.internal.WorkbenchHandlerServiceHandler@6bb46040, + ,,true),null), + org.eclipse.ui.defaultAcceleratorConfiguration, + org.eclipse.ui.contexts.window,,,system) +Binding(ALT+SHIFT+R, + ParameterizedCommand(Command(org.eclipse.ui.edit.rename,Rename, + Rename the selected item, + Category(org.eclipse.ui.category.file,File,null,true), + org.eclipse.ui.internal.WorkbenchHandlerServiceHandler@2b71a12e, + ,,true),null), + org.eclipse.ui.defaultAcceleratorConfiguration, + org.eclipse.ui.contexts.window,,,system) + +!ENTRY org.eclipse.ui.navigator 2 0 2022-10-25 12:50:55.177 +!MESSAGE Can't find Navigator Content Descriptor with id: org.eclipse.jst.servlet.ui.EnhancedJavaRendering + +!ENTRY org.eclipse.ui.navigator 2 0 2022-10-25 12:50:55.179 +!MESSAGE Can't find Navigator Content Descriptor with id: org.eclipse.jst.servlet.ui.EnhancedJavaRendering + +!ENTRY org.eclipse.egit.ui 2 0 2022-10-25 12:50:55.338 +!MESSAGE Warning: The environment variable HOME is not set. The following directory will be used to store the Git +user global configuration and to define the default location to store repositories: 'C:\Users\DELL'. If this is +not correct please set the HOME environment variable and restart Eclipse. Otherwise Git for Windows and +EGit might behave differently since they see different configuration options. +This warning can be switched off on the Team > Git > Confirmations and Warnings preference page. +!SESSION 2022-10-25 12:57:39.100 ----------------------------------------------- +eclipse.buildId=4.23.0.I20220308-0310 +java.version=18.0.1.1 +java.vendor=Oracle Corporation +BootLoader constants: OS=win32, ARCH=x86_64, WS=win32, NL=en_IN +Framework arguments: -product org.eclipse.epp.package.jee.product +Command-line arguments: -os win32 -ws win32 -arch x86_64 -product org.eclipse.epp.package.jee.product + +!ENTRY org.eclipse.jface 2 0 2022-10-25 12:58:00.480 +!MESSAGE Keybinding conflicts occurred. They may interfere with normal accelerator operation. +!SUBENTRY 1 org.eclipse.jface 2 0 2022-10-25 12:58:00.480 +!MESSAGE A conflict occurred for CTRL+SHIFT+T: +Binding(CTRL+SHIFT+T, + ParameterizedCommand(Command(org.eclipse.jdt.ui.navigate.open.type,Open Type, + Open a type in a Java editor, + Category(org.eclipse.ui.category.navigate,Navigate,null,true), + org.eclipse.ui.internal.WorkbenchHandlerServiceHandler@768f2398, + ,,true),null), + org.eclipse.ui.defaultAcceleratorConfiguration, + org.eclipse.ui.contexts.window,,,system) +Binding(CTRL+SHIFT+T, + ParameterizedCommand(Command(org.eclipse.lsp4e.symbolinworkspace,Go to Symbol in Workspace, + , + Category(org.eclipse.lsp4e.category,Language Servers,null,true), + org.eclipse.ui.internal.WorkbenchHandlerServiceHandler@1f4fa465, + ,,true),null), + org.eclipse.ui.defaultAcceleratorConfiguration, + org.eclipse.ui.contexts.window,,,system) +!SUBENTRY 1 org.eclipse.jface 2 0 2022-10-25 12:58:00.480 +!MESSAGE A conflict occurred for ALT+SHIFT+R: +Binding(ALT+SHIFT+R, + ParameterizedCommand(Command(org.eclipse.jdt.ui.edit.text.java.rename.element,Rename - Refactoring , + Rename the selected element, + Category(org.eclipse.jdt.ui.category.refactoring,Refactor - Java,Java Refactoring Actions,true), + org.eclipse.ui.internal.WorkbenchHandlerServiceHandler@1e65c4d, + ,,true),null), + org.eclipse.ui.defaultAcceleratorConfiguration, + org.eclipse.ui.contexts.window,,,system) +Binding(ALT+SHIFT+R, + ParameterizedCommand(Command(org.eclipse.ui.edit.rename,Rename, + Rename the selected item, + Category(org.eclipse.ui.category.file,File,null,true), + org.eclipse.ui.internal.WorkbenchHandlerServiceHandler@6b888692, + ,,true),null), + org.eclipse.ui.defaultAcceleratorConfiguration, + org.eclipse.ui.contexts.window,,,system) + +!ENTRY org.eclipse.ui.navigator 2 0 2022-10-25 12:58:03.611 +!MESSAGE Can't find Navigator Content Descriptor with id: org.eclipse.jst.servlet.ui.EnhancedJavaRendering + +!ENTRY org.eclipse.ui.navigator 2 0 2022-10-25 12:58:03.612 +!MESSAGE Can't find Navigator Content Descriptor with id: org.eclipse.jst.servlet.ui.EnhancedJavaRendering + +!ENTRY org.eclipse.egit.ui 2 0 2022-10-25 12:58:03.671 +!MESSAGE Warning: The environment variable HOME is not set. The following directory will be used to store the Git +user global configuration and to define the default location to store repositories: 'C:\Users\DELL'. If this is +not correct please set the HOME environment variable and restart Eclipse. Otherwise Git for Windows and +EGit might behave differently since they see different configuration options. +This warning can be switched off on the Team > Git > Confirmations and Warnings preference page. + +!ENTRY org.eclipse.wildwebdeveloper.xml 4 0 2022-10-25 12:58:59.996 +!MESSAGE /org/eclipse/persistence/jaxb/eclipselink_oxm_2_5.xsd +!STACK 0 +java.io.FileNotFoundException: /org/eclipse/persistence/jaxb/eclipselink_oxm_2_5.xsd + at org.eclipse.osgi.storage.url.bundleentry.Handler.findBundleEntry(Handler.java:55) + at org.eclipse.osgi.storage.url.BundleResourceHandler.openConnection(BundleResourceHandler.java:182) + at java.base/java.net.URL.openConnection(URL.java:1094) + at org.eclipse.core.internal.boot.PlatformURLConnection.connect(PlatformURLConnection.java:115) + at org.eclipse.core.internal.boot.PlatformURLConnection.getURLAsLocal(PlatformURLConnection.java:240) + at org.eclipse.core.internal.runtime.PlatformURLConverter.toFileURL(PlatformURLConverter.java:37) + at org.eclipse.core.runtime.FileLocator.toFileURL(FileLocator.java:263) + at org.eclipse.wildwebdeveloper.xml.internal.ui.preferences.XMLCatalogs.createURI(XMLCatalogs.java:139) + at org.eclipse.wildwebdeveloper.xml.internal.ui.preferences.XMLCatalogs.lambda$3(XMLCatalogs.java:87) + at java.base/java.util.stream.ForEachOps$ForEachOp$OfRef.accept(ForEachOps.java:183) + at java.base/java.util.Spliterators$ArraySpliterator.forEachRemaining(Spliterators.java:992) + at java.base/java.util.stream.ReferencePipeline$Head.forEach(ReferencePipeline.java:762) + at java.base/java.util.stream.ReferencePipeline$7$1.accept(ReferencePipeline.java:276) + at java.base/java.util.stream.ReferencePipeline$2$1.accept(ReferencePipeline.java:179) + at java.base/java.util.Spliterators$ArraySpliterator.forEachRemaining(Spliterators.java:992) + at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:509) + at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:499) + at java.base/java.util.stream.ForEachOps$ForEachOp.evaluateSequential(ForEachOps.java:150) + at java.base/java.util.stream.ForEachOps$ForEachOp$OfRef.evaluateSequential(ForEachOps.java:173) + at java.base/java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234) + at java.base/java.util.stream.ReferencePipeline.forEach(ReferencePipeline.java:596) + at org.eclipse.wildwebdeveloper.xml.internal.ui.preferences.XMLCatalogs.getWTPExtensionCatalog(XMLCatalogs.java:65) + at org.eclipse.wildwebdeveloper.xml.internal.ui.preferences.XMLCatalogs.getAllCatalogs(XMLCatalogs.java:52) + at org.eclipse.wildwebdeveloper.xml.internal.ui.preferences.XMLPreferenceConstants.storePreferencesToLemminxOptions(XMLPreferenceConstants.java:90) + at org.eclipse.wildwebdeveloper.xml.internal.XMLLanguageServer.mergeCustomInitializationOptions(XMLLanguageServer.java:163) + at org.eclipse.wildwebdeveloper.xml.internal.XMLLanguageServer.getInitializationOptions(XMLLanguageServer.java:158) + at org.eclipse.lsp4e.LanguageServerWrapper.lambda$8(LanguageServerWrapper.java:353) + at java.base/java.util.concurrent.CompletableFuture$UniCompose.tryFire(CompletableFuture.java:1150) + at java.base/java.util.concurrent.CompletableFuture.postComplete(CompletableFuture.java:510) + at java.base/java.util.concurrent.CompletableFuture$AsyncSupply.run(CompletableFuture.java:1773) + at java.base/java.util.concurrent.CompletableFuture$AsyncSupply.exec(CompletableFuture.java:1760) + at java.base/java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:373) + at java.base/java.util.concurrent.ForkJoinPool$WorkQueue.topLevelExec(ForkJoinPool.java:1182) + at java.base/java.util.concurrent.ForkJoinPool.scan(ForkJoinPool.java:1655) + at java.base/java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1622) + at java.base/java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:165) + +!ENTRY org.eclipse.egit.ui 4 0 2022-10-25 13:00:26.178 +!MESSAGE file:///E:\Git\java-iot\clearblade-cloud-iot: not found. +!STACK 0 +org.eclipse.jgit.api.errors.TransportException: file:///E:\Git\java-iot\clearblade-cloud-iot: not found. + at org.eclipse.jgit.api.LsRemoteCommand.execute(LsRemoteCommand.java:189) + at org.eclipse.jgit.api.LsRemoteCommand.call(LsRemoteCommand.java:128) + at org.eclipse.egit.core.op.ListRemoteOperation.run(ListRemoteOperation.java:116) + at org.eclipse.egit.ui.internal.clone.SourceBranchPage$9.run(SourceBranchPage.java:377) + at org.eclipse.jface.operation.ModalContext$ModalContextThread.run(ModalContext.java:122) +Caused by: org.eclipse.jgit.errors.NoRemoteRepositoryException: file:///E:\Git\java-iot\clearblade-cloud-iot: not found. + at org.eclipse.jgit.transport.TransportLocal$1.open(TransportLocal.java:115) + at org.eclipse.jgit.transport.TransportBundleFile$1.open(TransportBundleFile.java:84) + at org.eclipse.jgit.transport.Transport.open(Transport.java:551) + at org.eclipse.jgit.api.LsRemoteCommand.execute(LsRemoteCommand.java:156) + ... 4 more + +!ENTRY org.eclipse.egit.ui 4 0 2022-10-25 13:01:15.121 +!MESSAGE Invalid project description. +!STACK 1 +org.eclipse.core.internal.resources.ResourceException: Invalid project description. + at org.eclipse.core.internal.resources.Project.checkDescription(Project.java:173) + at org.eclipse.core.internal.resources.Project.assertCreateRequirements(Project.java:57) + at org.eclipse.core.internal.resources.Project.create(Project.java:267) + at org.eclipse.core.internal.resources.Project.create(Project.java:253) + at org.eclipse.egit.ui.internal.clone.ProjectUtils.createExistingProject(ProjectUtils.java:179) + at org.eclipse.egit.ui.internal.clone.ProjectUtils$1.run(ProjectUtils.java:104) + at org.eclipse.core.internal.resources.Workspace.run(Workspace.java:2315) + at org.eclipse.core.internal.resources.Workspace.run(Workspace.java:2335) + at org.eclipse.egit.ui.internal.clone.ProjectUtils.createProjects(ProjectUtils.java:138) + at org.eclipse.egit.ui.internal.clone.ProjectUtils.createProjects(ProjectUtils.java:62) + at org.eclipse.egit.ui.internal.clone.GitImportWizard.importProjects(GitImportWizard.java:254) + at org.eclipse.egit.ui.internal.clone.GitImportWizard$4.run(GitImportWizard.java:206) + at org.eclipse.jface.operation.ModalContext$ModalContextThread.run(ModalContext.java:122) +Contains: OK +Contains: E:\Git\java-iot\clearblade-cloud-iot overlaps the workspace location: E:\Git\java-iot\clearblade-cloud-iot +!SUBENTRY 1 org.eclipse.core.resources 4 77 2022-10-25 13:01:15.122 +!MESSAGE Invalid project description. +!SUBENTRY 2 unknown 0 0 2022-10-25 13:01:15.122 +!MESSAGE OK +!SUBENTRY 2 org.eclipse.core.resources 4 77 2022-10-25 13:01:15.122 +!MESSAGE E:\Git\java-iot\clearblade-cloud-iot overlaps the workspace location: E:\Git\java-iot\clearblade-cloud-iot + +!ENTRY org.eclipse.egit.ui 4 0 2022-10-25 13:01:42.849 +!MESSAGE Invalid project description. +!STACK 1 +org.eclipse.core.internal.resources.ResourceException: Invalid project description. + at org.eclipse.core.internal.resources.Project.checkDescription(Project.java:173) + at org.eclipse.core.internal.resources.Project.assertCreateRequirements(Project.java:57) + at org.eclipse.core.internal.resources.Project.create(Project.java:267) + at org.eclipse.core.internal.resources.Project.create(Project.java:253) + at org.eclipse.egit.ui.internal.clone.ProjectUtils.createExistingProject(ProjectUtils.java:179) + at org.eclipse.egit.ui.internal.clone.ProjectUtils$1.run(ProjectUtils.java:104) + at org.eclipse.core.internal.resources.Workspace.run(Workspace.java:2315) + at org.eclipse.core.internal.resources.Workspace.run(Workspace.java:2335) + at org.eclipse.egit.ui.internal.clone.ProjectUtils.createProjects(ProjectUtils.java:138) + at org.eclipse.egit.ui.internal.clone.ProjectUtils.createProjects(ProjectUtils.java:62) + at org.eclipse.egit.ui.internal.clone.GitImportWizard.importProjects(GitImportWizard.java:254) + at org.eclipse.egit.ui.internal.clone.GitImportWizard$4.run(GitImportWizard.java:206) + at org.eclipse.jface.operation.ModalContext$ModalContextThread.run(ModalContext.java:122) +Contains: OK +Contains: E:\Git\java-iot\clearblade-cloud-iot overlaps the workspace location: E:\Git\java-iot\clearblade-cloud-iot +!SUBENTRY 1 org.eclipse.core.resources 4 77 2022-10-25 13:01:42.849 +!MESSAGE Invalid project description. +!SUBENTRY 2 unknown 0 0 2022-10-25 13:01:42.849 +!MESSAGE OK +!SUBENTRY 2 org.eclipse.core.resources 4 77 2022-10-25 13:01:42.849 +!MESSAGE E:\Git\java-iot\clearblade-cloud-iot overlaps the workspace location: E:\Git\java-iot\clearblade-cloud-iot + +!ENTRY org.eclipse.egit.ui 4 0 2022-10-25 13:01:55.130 +!MESSAGE Invalid project description. +!STACK 1 +org.eclipse.core.internal.resources.ResourceException: Invalid project description. + at org.eclipse.core.internal.resources.Project.checkDescription(Project.java:173) + at org.eclipse.core.internal.resources.Project.assertCreateRequirements(Project.java:57) + at org.eclipse.core.internal.resources.Project.create(Project.java:267) + at org.eclipse.core.internal.resources.Project.create(Project.java:253) + at org.eclipse.egit.ui.internal.clone.ProjectUtils.createExistingProject(ProjectUtils.java:179) + at org.eclipse.egit.ui.internal.clone.ProjectUtils$1.run(ProjectUtils.java:104) + at org.eclipse.core.internal.resources.Workspace.run(Workspace.java:2315) + at org.eclipse.core.internal.resources.Workspace.run(Workspace.java:2335) + at org.eclipse.egit.ui.internal.clone.ProjectUtils.createProjects(ProjectUtils.java:138) + at org.eclipse.egit.ui.internal.clone.ProjectUtils.createProjects(ProjectUtils.java:62) + at org.eclipse.egit.ui.internal.clone.GitImportWizard.importProjects(GitImportWizard.java:254) + at org.eclipse.egit.ui.internal.clone.GitImportWizard$4.run(GitImportWizard.java:206) + at org.eclipse.jface.operation.ModalContext$ModalContextThread.run(ModalContext.java:122) +Contains: OK +Contains: E:\Git\java-iot\clearblade-cloud-iot overlaps the workspace location: E:\Git\java-iot\clearblade-cloud-iot +!SUBENTRY 1 org.eclipse.core.resources 4 77 2022-10-25 13:01:55.131 +!MESSAGE Invalid project description. +!SUBENTRY 2 unknown 0 0 2022-10-25 13:01:55.131 +!MESSAGE OK +!SUBENTRY 2 org.eclipse.core.resources 4 77 2022-10-25 13:01:55.131 +!MESSAGE E:\Git\java-iot\clearblade-cloud-iot overlaps the workspace location: E:\Git\java-iot\clearblade-cloud-iot diff --git a/clearblade-cloud-iot/.metadata/.mylyn/repositories.xml.zip b/clearblade-cloud-iot/.metadata/.mylyn/repositories.xml.zip new file mode 100644 index 0000000000000000000000000000000000000000..e077dca6333d48e6d32da99de4fced76baf63fdf GIT binary patch literal 685 zcmWIWW@Zs#;Nak3=t_$WWk3P~Kz31TL4I*&Nq$jgYO!8LZqD2A`}vm*1pb99?VoHg zLBPp(d1ljc#Z`s^`Ik-iE(@D$apU>AoALdxRnFd8V!>PMRNZ}N_xbyOf1JC1@~fHf zLAI&SjQVee{+Px(L%rzWXOlF0xqW+no>;ehGW&(s)jCU_sffDE))V{`OmC}kQ+Z8J|u)1~5Slhw%SF`KQMm|HqJr^XrrtV_C_NhX??!_mLj`SZo#XUEB zp9$P;^5B_xbQ?$YmNg=&a+6e*cPtCon;bO^X9cJUWQXVW4^!D_H2d&ZqY`GhDJh>gaQz&uqQ|~;-nCdGw{pfFwafm$1C{Nfq+h!J{rdG?UD<5~KXqeO z?vN0+a~rOmm&#Sm^4z#0J7o2#nWj;%H(LwM-kiVWMtXcXc=*ga4eh${pXcGutm5bolr*>A`}JF_tBNdRlM# zFWty+{BTxD)GbA`X{YM8^gavd-7~kkWJl(l8#XOI4p*|>|K43^x&HLg8BZUr^Lo4> zy{^3VUFFPmarc-0{}Q`u_v82aleQ=Ca^A1}{l$;_C%*6pc(ZfJeU(;~W@2DC#>2o6 l;LXS+!hlFx$a0{hg$mFUT7Wkz8%PBs5ZVFhNT8_<3;_ObD<}W} literal 0 HcmV?d00001 diff --git a/clearblade-cloud-iot/.metadata/.plugins/org.eclipse.core.resources/.projects/.org.eclipse.egit.core.cmp/.location b/clearblade-cloud-iot/.metadata/.plugins/org.eclipse.core.resources/.projects/.org.eclipse.egit.core.cmp/.location new file mode 100644 index 0000000000000000000000000000000000000000..d72bf60cc0c883b7bc40e6ec018872d158dbbff0 GIT binary patch literal 163 zcmZ?R*xjhShe1S2b=vdAllRFn6o&?R>g%Uv=A>HbyISeHXO`$^C6*=XX6BdZC+DOl z7A55*rljg7=j4~BfCcq(Q%e$45=#>G^$K!I(=+pm_4A9;^-_~_G7E}R^-|L_OZ1ZS fi&FLVunOxX=N2%afCCY~KZBhV__?Qgclj{@ox(Wp literal 0 HcmV?d00001 diff --git a/clearblade-cloud-iot/.metadata/.plugins/org.eclipse.core.resources/.root/.indexes/history.version b/clearblade-cloud-iot/.metadata/.plugins/org.eclipse.core.resources/.root/.indexes/history.version new file mode 100644 index 00000000..25cb955b --- /dev/null +++ b/clearblade-cloud-iot/.metadata/.plugins/org.eclipse.core.resources/.root/.indexes/history.version @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/clearblade-cloud-iot/.metadata/.plugins/org.eclipse.core.resources/.root/.indexes/properties.index b/clearblade-cloud-iot/.metadata/.plugins/org.eclipse.core.resources/.root/.indexes/properties.index new file mode 100644 index 0000000000000000000000000000000000000000..bb5ccc45e269530cb0369a289d8392463eaff5f0 GIT binary patch literal 57 zcmZQ%U|?WmVAN+|WMUA>FG|--P0qu4pI&6}TZ-ZNS$NL6P23qtF{L~PgD z?@Y^hkad9tLxq5%2tBTNxNz z8JjD328SpZ85kMya_Q@p6s4xx0$Is9sfk4{sW~Ny@%csRda21dnFYnEdMT+%rRjRf z`9-O=X^A<-KofB&%t|RCMp + + + activeSchemeId:org.eclipse.ui.defaultAcceleratorConfiguration + + + + + + + + topLevel + shellMaximized + + + + + persp.actionSet:org.eclipse.mylyn.doc.actionSet + persp.actionSet:org.eclipse.mylyn.tasks.ui.navigation + persp.actionSet:org.eclipse.ui.cheatsheets.actionSet + persp.actionSet:org.eclipse.search.searchActionSet + persp.actionSet:org.eclipse.text.quicksearch.actionSet + persp.actionSet:org.eclipse.ui.edit.text.actionSet.annotationNavigation + persp.actionSet:org.eclipse.ui.edit.text.actionSet.navigation + persp.actionSet:org.eclipse.ui.edit.text.actionSet.convertLineDelimitersTo + persp.actionSet:org.eclipse.ui.externaltools.ExternalToolsSet + persp.actionSet:org.eclipse.ui.actionSet.keyBindings + persp.actionSet:org.eclipse.ui.actionSet.openFiles + persp.actionSet:org.eclipse.jst.j2ee.J2eeMainActionSet + persp.actionSet:org.eclipse.jdt.ui.JavaActionSet + persp.actionSet:org.eclipse.debug.ui.launchActionSet + persp.actionSet:org.eclipse.debug.ui.debugActionSet + persp.actionSet:org.eclipse.ui.NavigateActionSet + persp.viewSC:org.eclipse.ui.navigator.ProjectExplorer + persp.viewSC:org.eclipse.wst.server.ui.ServersView + persp.viewSC:org.eclipse.datatools.connectivity.DataSourceExplorerNavigator + persp.viewSC:org.eclipse.ui.views.BookmarkView + persp.viewSC:org.eclipse.ui.views.ContentOutline + persp.viewSC:org.eclipse.ui.views.PropertySheet + persp.viewSC:org.eclipse.ui.views.ResourceNavigator + persp.viewSC:org.eclipse.wst.common.snippets.internal.ui.SnippetsView + persp.viewSC:org.eclipse.ui.views.AllMarkersView + persp.viewSC:org.eclipse.mylyn.tasks.ui.views.tasks + persp.viewSC:org.eclipse.search.ui.views.SearchView + persp.viewSC:org.eclipse.ui.console.ConsoleView + persp.showIn:org.eclipse.ui.navigator.ProjectExplorer + persp.actionSet:org.eclipse.wst.ws.explorer.explorer + persp.newWizSC:org.eclipse.m2e.core.wizards.Maven2ProjectWizard + persp.newWizSC:org.eclipse.wst.css.ui.internal.wizard.NewCSSWizard + persp.newWizSC:org.eclipse.wst.jsdt.ui.NewJSWizard + persp.actionSet:org.eclipse.eclemma.ui.CoverageActionSet + persp.showIn:org.eclipse.eclemma.ui.CoverageView + persp.showIn:org.eclipse.tm.terminal.view.ui.TerminalsView + persp.perspSC:org.eclipse.debug.ui.DebugPerspective + persp.perspSC:org.eclipse.jdt.ui.JavaPerspective + persp.perspSC:org.eclipse.ui.resourcePerspective + persp.perspSC:org.eclipse.wst.web.ui.webDevPerspective + persp.newWizSC:org.eclipse.jst.j2ee.ui.project.facet.EarProjectWizard + persp.newWizSC:org.eclipse.jst.servlet.ui.project.facet.WebProjectWizard + persp.newWizSC:org.eclipse.jst.ejb.ui.project.facet.EjbProjectWizard + persp.newWizSC:org.eclipse.jst.j2ee.jca.ui.internal.wizard.ConnectorProjectWizard + persp.newWizSC:org.eclipse.jst.j2ee.ui.project.facet.appclient.AppClientProjectWizard + persp.newWizSC:org.eclipse.wst.web.ui.internal.wizards.SimpleWebProjectWizard + persp.newWizSC:org.eclipse.jpt.ui.wizard.newJpaProject + persp.newWizSC:org.eclipse.jst.servlet.ui.internal.wizard.AddServletWizard + persp.newWizSC:org.eclipse.jst.ejb.ui.internal.wizard.AddSessionBeanWizard + persp.newWizSC:org.eclipse.jst.ejb.ui.internal.wizard.AddMessageDrivenBeanWizard + persp.newWizSC:org.eclipse.jpt.ui.wizard.newEntity + persp.newWizSC:org.eclipse.jst.ws.creation.ui.wizard.serverwizard + persp.newWizSC:org.eclipse.ui.wizards.new.folder + persp.newWizSC:org.eclipse.ui.wizards.new.file + persp.actionSet:org.eclipse.wst.server.ui.internal.webbrowser.actionSet + persp.actionSet:org.eclipse.debug.ui.breakpointActionSet + persp.newWizSC:org.eclipse.jpt.jpa.ui.wizard.newJpaProject + persp.perspSC:org.eclipse.jpt.ui.jpaPerspective + persp.newWizSC:org.eclipse.jst.jsp.ui.internal.wizard.NewJSPWizard + + + + View + categoryTag:General + + + View + categoryTag:General + + + View + categoryTag:Java + + + View + categoryTag:Java Browsing + + + + + + + + View + categoryTag:General + + + View + categoryTag:Mylyn + + + View + categoryTag:General + + + + + General + active + + View + categoryTag:General + + + View + categoryTag:General + + + View + categoryTag:Server + + + View + categoryTag:Data Management + + + View + categoryTag:General + + + View + categoryTag:General + + + View + categoryTag:General + + + View + categoryTag:General + + + View + categoryTag:General + + + View + categoryTag:General + + + View + categoryTag:General + + + View + categoryTag:General + + + + + + + + + View + categoryTag:Help + + + View + categoryTag:General + + + View + categoryTag:Help + + + + + + + View + categoryTag:Help + + + + + + View + categoryTag:General + + ViewMenu + menuContribution:menu + + + + + + + View + categoryTag:Help + + + + org.eclipse.e4.primaryDataStack + EditorStack + + + + + + + View + categoryTag:General + + ViewMenu + menuContribution:menu + + + + + + + View + categoryTag:General + + + + + View + categoryTag:Java + + + + + View + categoryTag:Java Browsing + + + + + + View + categoryTag:General + + ViewMenu + menuContribution:menu + + + + + + + + View + categoryTag:General + + ViewMenu + menuContribution:menu + + + + + + + + View + categoryTag:Server + + ViewMenu + menuContribution:menu + + + + + + + + View + categoryTag:Data Management + + ViewMenu + menuContribution:menu + + + + + + + + View + categoryTag:General + + ViewMenu + menuContribution:menu + + + + + + + View + categoryTag:General + + + + + View + categoryTag:General + + + + + View + categoryTag:General + + + + + View + categoryTag:General + + + + + View + categoryTag:General + + + + + View + categoryTag:General + + + + + + View + categoryTag:General + + ViewMenu + menuContribution:menu + + + + + + + View + categoryTag:Mylyn + + + + + View + categoryTag:General + + + + + + View + categoryTag:General + active + activeOnClose + + ViewMenu + menuContribution:menu + + + + + + toolbarSeparator + + + + Draggable + + + + toolbarSeparator + + + + Draggable + + + toolbarSeparator + + + + Draggable + + + Draggable + + + Draggable + + + Draggable + + + Draggable + + + toolbarSeparator + + + + Draggable + + + + toolbarSeparator + + + + toolbarSeparator + + + + Draggable + + + stretch + SHOW_RESTORE_MENU + + + Draggable + HIDEABLE + SHOW_RESTORE_MENU + + + + + stretch + + + Draggable + + + Draggable + + + + + TrimStack + Draggable + + + + + + + + + + + + + + + + + + + + + + platform:win32 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + platform:win32 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + View + Spy + categoryTag:Eclipse Runtime Spies + + + + + + + + + + + + + + + + + + + + + + + + + View + Spy + categoryTag:Eclipse Runtime Spies + + + View + Spy + categoryTag:Eclipse Runtime Spies + + + View + Spy + categoryTag:Eclipse Runtime Spies + + + View + Spy + categoryTag:Eclipse Runtime Spies + + + View + Spy + categoryTag:Eclipse Runtime Spies + + + Editor + removeOnHide + + + + + View + categoryTag:Ant + + + + + View + categoryTag:Gradle + + + + + View + categoryTag:Gradle + + + + + View + categoryTag:Data Management + + + + + View + categoryTag:Data Management + + + + + View + categoryTag:Data Management + + + + + View + categoryTag:Debug + + + + + View + categoryTag:Debug + + + + + View + categoryTag:Debug + + + + + View + categoryTag:Debug + + + + + View + categoryTag:Debug + + + + + View + categoryTag:Debug + + + + + View + categoryTag:Debug + + + View + categoryTag:Debug + + + + + View + categoryTag:Java + + + + + View + categoryTag:Git + + + + + View + categoryTag:Git + + + + + View + categoryTag:Git + + + + + View + categoryTag:Git + NoRestore + + + + + View + categoryTag:Git + + + + + View + categoryTag:General + + + + + View + categoryTag:Help + + + + + View + categoryTag:Debug + + + + + View + categoryTag:Java + + + + + View + categoryTag:Java + + + + + View + categoryTag:Java + + + + + View + categoryTag:Java Browsing + + + + + View + categoryTag:Java Browsing + + + + + View + categoryTag:Java Browsing + + + + + View + categoryTag:Java Browsing + + + + + View + categoryTag:Java + + + + + View + categoryTag:General + + + + + View + categoryTag:Java + + + + + View + categoryTag:Java + + + + + View + categoryTag:JPA + + + + + View + categoryTag:JPA + + + + + View + categoryTag:JavaServer Faces + + + + + View + categoryTag:JavaServer Faces + + + + + View + categoryTag:Web Services + + + + + View + categoryTag:Maven + + + + + View + categoryTag:Maven + + + + + View + categoryTag:Maven + + + + + View + categoryTag:Mylyn + + + + + View + categoryTag:Mylyn + + + + + View + categoryTag:Mylyn + + + + + View + categoryTag:Oomph + + + + + View + categoryTag:API Tools + + + + + View + categoryTag:Plug-in Development + + + + + View + categoryTag:Plug-in Development + + + + + View + categoryTag:Plug-in Development + + + + + View + categoryTag:Plug-in Development + + + + + View + categoryTag:Plug-in Development + + + + + View + categoryTag:Plug-in Development + + + + + View + categoryTag:General + + + + + View + categoryTag:Version Control (Team) + + + + + View + categoryTag:Version Control (Team) + + + View + categoryTag:Help + + + + + View + categoryTag:Terminal + + + + + View + categoryTag:Other + + + + + View + categoryTag:General + + + + + View + categoryTag:General + + + + + View + categoryTag:Help + + + + + View + categoryTag:General + + + + + View + categoryTag:General + + + + + View + categoryTag:General + + + + + View + categoryTag:General + + + + + View + categoryTag:General + + + + + View + categoryTag:General + + + + + View + categoryTag:General + + + + + View + categoryTag:General + + + + + View + categoryTag:General + + + + + View + categoryTag:General + + + + + View + categoryTag:General + + + + + View + categoryTag:General + + + + + View + categoryTag:General + + + + + View + categoryTag:Debug + + + + + View + categoryTag:Other + + + + + View + categoryTag:Other + + + + + View + categoryTag:Other + + + + + View + categoryTag:Server + + + + + View + categoryTag:XML + + + + + View + categoryTag:XML + + + + + View + categoryTag:XML + + + + + View + categoryTag:XML + + + + + View + categoryTag:XML + + + + glue + move_after:PerspectiveSpacer + SHOW_RESTORE_MENU + + + move_after:Spacer Glue + HIDEABLE + SHOW_RESTORE_MENU + + + glue + move_after:SearchField + SHOW_RESTORE_MENU + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/clearblade-cloud-iot/.metadata/.plugins/org.eclipse.egit.ui/dialog_settings.xml b/clearblade-cloud-iot/.metadata/.plugins/org.eclipse.egit.ui/dialog_settings.xml new file mode 100644 index 00000000..171dcdb3 --- /dev/null +++ b/clearblade-cloud-iot/.metadata/.plugins/org.eclipse.egit.ui/dialog_settings.xml @@ -0,0 +1,11 @@ + +
+ + + + + +
+ +
+
diff --git a/clearblade-cloud-iot/.metadata/.plugins/org.eclipse.jdt.core/assumedExternalFilesCache b/clearblade-cloud-iot/.metadata/.plugins/org.eclipse.jdt.core/assumedExternalFilesCache new file mode 100644 index 0000000000000000000000000000000000000000..593f4708db84ac8fd0f5cc47c634f38c013fe9e4 GIT binary patch literal 4 LcmZQzU|;|M00aO5 literal 0 HcmV?d00001 diff --git a/clearblade-cloud-iot/.metadata/.plugins/org.eclipse.jdt.core/externalFilesCache b/clearblade-cloud-iot/.metadata/.plugins/org.eclipse.jdt.core/externalFilesCache new file mode 100644 index 0000000000000000000000000000000000000000..593f4708db84ac8fd0f5cc47c634f38c013fe9e4 GIT binary patch literal 4 LcmZQzU|;|M00aO5 literal 0 HcmV?d00001 diff --git a/clearblade-cloud-iot/.metadata/.plugins/org.eclipse.jdt.core/javaLikeNames.txt b/clearblade-cloud-iot/.metadata/.plugins/org.eclipse.jdt.core/javaLikeNames.txt new file mode 100644 index 00000000..85863977 --- /dev/null +++ b/clearblade-cloud-iot/.metadata/.plugins/org.eclipse.jdt.core/javaLikeNames.txt @@ -0,0 +1 @@ +java \ No newline at end of file diff --git a/clearblade-cloud-iot/.metadata/.plugins/org.eclipse.jdt.core/nonChainingJarsCache b/clearblade-cloud-iot/.metadata/.plugins/org.eclipse.jdt.core/nonChainingJarsCache new file mode 100644 index 0000000000000000000000000000000000000000..593f4708db84ac8fd0f5cc47c634f38c013fe9e4 GIT binary patch literal 4 LcmZQzU|;|M00aO5 literal 0 HcmV?d00001 diff --git a/clearblade-cloud-iot/.metadata/.plugins/org.eclipse.jdt.core/variablesAndContainers.dat b/clearblade-cloud-iot/.metadata/.plugins/org.eclipse.jdt.core/variablesAndContainers.dat new file mode 100644 index 0000000000000000000000000000000000000000..3de398e8f2856ff30f4c5dd9cf8cfd66b137fcc8 GIT binary patch literal 129 zcmX|&TMB?66hudR2o)`+B_tP8G)3*({qG_l;QblSnYjQs`iT}o2g*j>tPn$^7-S`m py>^9ybE%pMoBm#v^5ZO3G2cM$*bk0n6(Ils literal 0 HcmV?d00001 diff --git a/clearblade-cloud-iot/.metadata/.plugins/org.eclipse.jdt.ui/OpenTypeHistory.xml b/clearblade-cloud-iot/.metadata/.plugins/org.eclipse.jdt.ui/OpenTypeHistory.xml new file mode 100644 index 00000000..a4ee3cbc --- /dev/null +++ b/clearblade-cloud-iot/.metadata/.plugins/org.eclipse.jdt.ui/OpenTypeHistory.xml @@ -0,0 +1,2 @@ + + diff --git a/clearblade-cloud-iot/.metadata/.plugins/org.eclipse.jdt.ui/QualifiedTypeNameHistory.xml b/clearblade-cloud-iot/.metadata/.plugins/org.eclipse.jdt.ui/QualifiedTypeNameHistory.xml new file mode 100644 index 00000000..9e390f50 --- /dev/null +++ b/clearblade-cloud-iot/.metadata/.plugins/org.eclipse.jdt.ui/QualifiedTypeNameHistory.xml @@ -0,0 +1,2 @@ + + diff --git a/clearblade-cloud-iot/.metadata/.plugins/org.eclipse.m2e.core/workspaceState.ser b/clearblade-cloud-iot/.metadata/.plugins/org.eclipse.m2e.core/workspaceState.ser new file mode 100644 index 0000000000000000000000000000000000000000..abbf8e5211b6a04431b29bc5ab1269fb2676782d GIT binary patch literal 538 zcmc(bO-{ow5QRs9@+$-d#4%inEfPPi6oC|^stc9~;|z^cCw9j!O(n`PI0aW=QE>s- zus~daJCHP?RP0#c&3NAPeDmbTPpDafLrqoNGVs$kd9F}M%b0s z(TKH6p;PtPoUD&~PcI&T$p~71q&2yf;urE_eE0D7aT$BC6u?dupv4WpmP$H_*1={F z^IP5+IH?-v+#LM8>tKH%2@_16?ZZ8I0qjz#h4YNc+a7A_S;GaMkdrrD%%zrT zD*VQ6%p0X>GL!#gy~xChOzf1~D9=?}exE$=UA-=V=fj%PJoNJon$BR=MT9oeD$Hk( Tj$wL+D|y)}uGy5k_)o?cALX5n literal 0 HcmV?d00001 diff --git a/clearblade-cloud-iot/.metadata/.plugins/org.eclipse.m2e.logback.configuration/0.log b/clearblade-cloud-iot/.metadata/.plugins/org.eclipse.m2e.logback.configuration/0.log new file mode 100644 index 00000000..67d19c80 --- /dev/null +++ b/clearblade-cloud-iot/.metadata/.plugins/org.eclipse.m2e.logback.configuration/0.log @@ -0,0 +1,2 @@ +2022-10-25 12:50:54,986 [Worker-4: Loading available Gradle versions] INFO o.e.b.c.i.u.g.PublishedGradleVersions - Gradle version information cache is up-to-date. Trying to read. +2022-10-25 12:58:03,944 [Worker-4: Loading available Gradle versions] INFO o.e.b.c.i.u.g.PublishedGradleVersions - Gradle version information cache is up-to-date. Trying to read. diff --git a/clearblade-cloud-iot/.metadata/.plugins/org.eclipse.m2e.logback.configuration/logback.1.16.3.20211002-1029.xml b/clearblade-cloud-iot/.metadata/.plugins/org.eclipse.m2e.logback.configuration/logback.1.16.3.20211002-1029.xml new file mode 100644 index 00000000..45125560 --- /dev/null +++ b/clearblade-cloud-iot/.metadata/.plugins/org.eclipse.m2e.logback.configuration/logback.1.16.3.20211002-1029.xml @@ -0,0 +1,41 @@ + + + + %date [%thread] %-5level %logger{35} - %msg%n + + + OFF + + + + + ${org.eclipse.m2e.log.dir}/0.log + + ${org.eclipse.m2e.log.dir}/%i.log + 1 + 10 + + + 100MB + + + %date [%thread] %-5level %logger{35} - %msg%n + + + + + + WARN + + + + + + + + + + + + + diff --git a/clearblade-cloud-iot/.metadata/.plugins/org.eclipse.oomph.setup/workspace.setup b/clearblade-cloud-iot/.metadata/.plugins/org.eclipse.oomph.setup/workspace.setup new file mode 100644 index 00000000..1f73e14c --- /dev/null +++ b/clearblade-cloud-iot/.metadata/.plugins/org.eclipse.oomph.setup/workspace.setup @@ -0,0 +1,6 @@ + + diff --git a/clearblade-cloud-iot/.metadata/.plugins/org.eclipse.tips.ide/dialog_settings.xml b/clearblade-cloud-iot/.metadata/.plugins/org.eclipse.tips.ide/dialog_settings.xml new file mode 100644 index 00000000..5ca0b776 --- /dev/null +++ b/clearblade-cloud-iot/.metadata/.plugins/org.eclipse.tips.ide/dialog_settings.xml @@ -0,0 +1,3 @@ + +
+
diff --git a/clearblade-cloud-iot/.metadata/.plugins/org.eclipse.ui.ide/dialog_settings.xml b/clearblade-cloud-iot/.metadata/.plugins/org.eclipse.ui.ide/dialog_settings.xml new file mode 100644 index 00000000..20bb49b7 --- /dev/null +++ b/clearblade-cloud-iot/.metadata/.plugins/org.eclipse.ui.ide/dialog_settings.xml @@ -0,0 +1,26 @@ + +
+
+ + + + + + + + +
+
+ + + + + + + + + + + +
+
diff --git a/clearblade-cloud-iot/.metadata/.plugins/org.eclipse.ui.intro/introstate b/clearblade-cloud-iot/.metadata/.plugins/org.eclipse.ui.intro/introstate new file mode 100644 index 00000000..02f134f0 --- /dev/null +++ b/clearblade-cloud-iot/.metadata/.plugins/org.eclipse.ui.intro/introstate @@ -0,0 +1,2 @@ + + \ No newline at end of file diff --git a/clearblade-cloud-iot/.metadata/.plugins/org.eclipse.ui.views.log/dialog_settings.xml b/clearblade-cloud-iot/.metadata/.plugins/org.eclipse.ui.views.log/dialog_settings.xml new file mode 100644 index 00000000..24973136 --- /dev/null +++ b/clearblade-cloud-iot/.metadata/.plugins/org.eclipse.ui.views.log/dialog_settings.xml @@ -0,0 +1,12 @@ + +
+
+ + + + + + + +
+
diff --git a/clearblade-cloud-iot/.metadata/.plugins/org.eclipse.ui.workbench/dialog_settings.xml b/clearblade-cloud-iot/.metadata/.plugins/org.eclipse.ui.workbench/dialog_settings.xml new file mode 100644 index 00000000..7de9758f --- /dev/null +++ b/clearblade-cloud-iot/.metadata/.plugins/org.eclipse.ui.workbench/dialog_settings.xml @@ -0,0 +1,11 @@ + +
+
+ + + + +
+
+
+
diff --git a/clearblade-cloud-iot/.metadata/.plugins/org.eclipse.ui.workbench/workingsets.xml b/clearblade-cloud-iot/.metadata/.plugins/org.eclipse.ui.workbench/workingsets.xml new file mode 100644 index 00000000..fbed79c9 --- /dev/null +++ b/clearblade-cloud-iot/.metadata/.plugins/org.eclipse.ui.workbench/workingsets.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/clearblade-cloud-iot/.metadata/.plugins/org.eclipse.wildwebdeveloper.xml/system-catalog.xml b/clearblade-cloud-iot/.metadata/.plugins/org.eclipse.wildwebdeveloper.xml/system-catalog.xml new file mode 100644 index 00000000..54283dcd --- /dev/null +++ b/clearblade-cloud-iot/.metadata/.plugins/org.eclipse.wildwebdeveloper.xml/system-catalog.xml @@ -0,0 +1,229 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/clearblade-cloud-iot/.metadata/.plugins/org.eclipse.wst.common.snippets/hidden.xml b/clearblade-cloud-iot/.metadata/.plugins/org.eclipse.wst.common.snippets/hidden.xml new file mode 100644 index 0000000000000000000000000000000000000000..ab946b83f7b748424b8707693bcfdfa71590470b GIT binary patch literal 138 zcmXAiK?;LF5CrQi_y^g05_8E(&CM4i50LDV1l9?-67qVrvobI literal 0 HcmV?d00001 diff --git a/clearblade-cloud-iot/.metadata/.plugins/org.eclipse.wst.common.snippets/user.xml b/clearblade-cloud-iot/.metadata/.plugins/org.eclipse.wst.common.snippets/user.xml new file mode 100644 index 0000000000000000000000000000000000000000..79e43e1b9d872e8512dbae8fadce2d6c9ab17603 GIT binary patch literal 766 zcmchV!A`?K3`FOQ#6LtiRw9H#t0D!s@da>36HtV@80T0*E#|3~}kJe%>HYeM{TtHQUz8}|v= CiF`Z& literal 0 HcmV?d00001 diff --git a/clearblade-cloud-iot/.metadata/.plugins/org.eclipse.wst.sse.ui/dialog_settings.xml b/clearblade-cloud-iot/.metadata/.plugins/org.eclipse.wst.sse.ui/dialog_settings.xml new file mode 100644 index 00000000..63fae25e --- /dev/null +++ b/clearblade-cloud-iot/.metadata/.plugins/org.eclipse.wst.sse.ui/dialog_settings.xml @@ -0,0 +1,5 @@ + +
+
+
+
diff --git a/clearblade-cloud-iot/.metadata/version.ini b/clearblade-cloud-iot/.metadata/version.ini new file mode 100644 index 00000000..1676b3db --- /dev/null +++ b/clearblade-cloud-iot/.metadata/version.ini @@ -0,0 +1,3 @@ +#Tue Oct 25 12:57:57 IST 2022 +org.eclipse.core.runtime=2 +org.eclipse.platform=4.23.0.v20220308-0310 diff --git a/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/SyncSendCommandToDevice.java b/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/SyncSendCommandToDevice.java index 23a6b078..cd7afb6f 100644 --- a/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/SyncSendCommandToDevice.java +++ b/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/SyncSendCommandToDevice.java @@ -1,27 +1,26 @@ package com.clearblade.cloud.iot.v1; +import com.clearblade.cloud.iot.v1.utils.ByteString; import com.clearblade.cloud.iot.v1.utils.Constants; import com.clearblade.cloud.iot.v1.utils.DeviceName; public class SyncSendCommandToDevice { - public static void main(String[] args) throws Exception { - syncSendCommandToDevice(); - } + public static void main(String[] args) { + syncSendCommandToDevice(); + } - public static void syncSendCommandToDevice() throws Exception { - DeviceManagerClient deviceManagerClient = new DeviceManagerClient(); - Constants constants = new Constants(); - DeviceName name = DeviceName.of(constants.getBuilder().getProject(), constants.getBuilder().getLocation(), constants.getBuilder().getRegistry(), constants.getBuilder().getDevice()); - SendCommandToDeviceRequest request = SendCommandToDeviceRequest.Builder - .newBuilder() - .setName(name) - .setBinaryData("c2VuZEZ1bm55TWVzc2FnZVRvRGV2aWNl") - .build(); - SendCommandToDeviceResponse response = deviceManagerClient.sendCommandToDevice(request); - response.processRequest(); - if(response != null) { - System.out.println("POST Response is :: " + response.toString()); - } - } + public static void syncSendCommandToDevice() { + DeviceManagerClient deviceManagerClient = new DeviceManagerClient(); + Constants constants = new Constants(); + DeviceName name = DeviceName.of(constants.getBuilder().getProject(), constants.getBuilder().getLocation(), + constants.getBuilder().getRegistry(), constants.getBuilder().getDevice()); + SendCommandToDeviceRequest request = SendCommandToDeviceRequest.Builder.newBuilder().setName(name) + .setBinaryData(new ByteString("c2VuZEZ1bm55TWVzc2FnZVRvRGV2aWNl")).setSubFolder("subfolder153561774").build(); + SendCommandToDeviceResponse response = deviceManagerClient.sendCommandToDevice(request); + if (response != null) { + response.processRequest(); + System.out.println("POST Response is :: " + response.toString()); + } } +} diff --git a/clearblade-cloud-iot/src/main/java/com/clearblade/cloud/iot/v1/DeviceManagerClient.java b/clearblade-cloud-iot/src/main/java/com/clearblade/cloud/iot/v1/DeviceManagerClient.java index c33f6596..5d7679c3 100644 --- a/clearblade-cloud-iot/src/main/java/com/clearblade/cloud/iot/v1/DeviceManagerClient.java +++ b/clearblade-cloud-iot/src/main/java/com/clearblade/cloud/iot/v1/DeviceManagerClient.java @@ -19,26 +19,22 @@ public void init() { * @param name * @param binaryData */ - public void sendCommandToDevice(DeviceName name, String binaryData) { - init(); - SendCommandToDeviceRequest request = SendCommandToDeviceRequest.Builder.newBuilder() - .setName(name) - .setBinaryData(binaryData) - .build(); - SendCommandToDeviceResponse response = this.sendCommandToDevice(request); - //response.processRequest(); - } + public void sendCommandToDevice(DeviceName name, com.clearblade.cloud.iot.v1.utils.ByteString binaryData, String subFolder) { + init(); + SendCommandToDeviceRequest request = SendCommandToDeviceRequest.Builder.newBuilder().setName(name) + .setBinaryData(binaryData).setSubFolder(subFolder).build(); + SendCommandToDeviceResponse response = this.sendCommandToDevice(request); + response.processRequest(); + } - /** - * Print the response for sendCommandToDevice - * @param request - * @return - */ - public SendCommandToDeviceResponse sendCommandToDevice(SendCommandToDeviceRequest request) { - SendCommandToDeviceResponse response = SendCommandToDeviceResponse.Builder.newBuilder() - .setSendCommandToDeviceRequest(request) - .build(); - return response; - } + /** + * Print the response for sendCommandToDevice + * + * @param request + * @return + */ + public SendCommandToDeviceResponse sendCommandToDevice(SendCommandToDeviceRequest request) { + return (SendCommandToDeviceResponse.Builder.newBuilder().setSendCommandToDeviceRequest(request).build()); + } } diff --git a/clearblade-cloud-iot/src/main/java/com/clearblade/cloud/iot/v1/SendCommandToDeviceRequest.java b/clearblade-cloud-iot/src/main/java/com/clearblade/cloud/iot/v1/SendCommandToDeviceRequest.java index 9f373978..a169879d 100644 --- a/clearblade-cloud-iot/src/main/java/com/clearblade/cloud/iot/v1/SendCommandToDeviceRequest.java +++ b/clearblade-cloud-iot/src/main/java/com/clearblade/cloud/iot/v1/SendCommandToDeviceRequest.java @@ -1,55 +1,60 @@ package com.clearblade.cloud.iot.v1; +import com.clearblade.cloud.iot.v1.utils.ByteString; import com.clearblade.cloud.iot.v1.utils.DeviceName; final class SendCommandToDeviceRequest { - - private final DeviceName name; - private final String binaryData; - - private SendCommandToDeviceRequest(Builder builder){ - this.name = builder.name; - this.binaryData = builder.binaryData; - } + + private final DeviceName name; + private final ByteString binaryData; + private final String subFolder; + + private SendCommandToDeviceRequest(Builder builder) { + this.name = builder.name; + this.binaryData = builder.binaryData; + this.subFolder = builder.subFolder; + } // Static class Builder public static class Builder { - /// instance fields - private DeviceName name; - private String binaryData; - - public static Builder newBuilder() - { - return new Builder(); - } - - private Builder() {} - - // Setter methods - public Builder setName(DeviceName name) - { - this.name = name; - return this; - } - public Builder setBinaryData(String binaryData) - { - this.binaryData = binaryData; - return this; - } - - // build method to deal with outer class - // to return outer instance - public SendCommandToDeviceRequest build() - { - return new SendCommandToDeviceRequest(this); - } + /// instance fields + private DeviceName name; + private ByteString binaryData; + private String subFolder; + + public static Builder newBuilder() { + return new Builder(); } - @Override - public String toString() - { - return "name = " + this.name.getDevice() + ", binaryData = " + this.binaryData; + private Builder() { + } + + // Setter methods + public Builder setName(DeviceName name) { + this.name = name; + return this; + } + + public Builder setBinaryData(ByteString binaryData) { + this.binaryData = binaryData; + return this; + } + + public Builder setSubFolder(String subFolder) { + this.subFolder = subFolder; + return this; + } + + // build method to deal with outer class + // to return outer instance + public SendCommandToDeviceRequest build() { + return new SendCommandToDeviceRequest(this); } } + @Override + public String toString() { + return "name = " + this.name.getDevice() + ", binaryData = " + this.binaryData+ ", subFolder = "+this.subFolder; + } +} diff --git a/clearblade-cloud-iot/src/main/java/com/clearblade/cloud/iot/v1/SendCommandToDeviceResponse.java b/clearblade-cloud-iot/src/main/java/com/clearblade/cloud/iot/v1/SendCommandToDeviceResponse.java index fffcaf94..2b7c0bc7 100644 --- a/clearblade-cloud-iot/src/main/java/com/clearblade/cloud/iot/v1/SendCommandToDeviceResponse.java +++ b/clearblade-cloud-iot/src/main/java/com/clearblade/cloud/iot/v1/SendCommandToDeviceResponse.java @@ -7,6 +7,7 @@ import java.net.HttpURLConnection; import java.net.MalformedURLException; import java.net.URL; +import java.nio.charset.StandardCharsets; import javax.net.ssl.HttpsURLConnection; @@ -49,24 +50,22 @@ public static class Builder { /// instance fields private SendCommandToDeviceRequest request; - public static Builder newBuilder() - { + public static Builder newBuilder() { return new Builder(); } - private Builder() {} + private Builder() { + } // Setter methods - public Builder setSendCommandToDeviceRequest(SendCommandToDeviceRequest request) - { + public Builder setSendCommandToDeviceRequest(SendCommandToDeviceRequest request) { this.request = request; return this; } // build method to deal with outer class // to return outer instance - public SendCommandToDeviceResponse build() - { + public SendCommandToDeviceResponse build() { return new SendCommandToDeviceResponse(this); } } @@ -76,54 +75,54 @@ public void init() { } public void processRequest() { - init(); - try { - String post_param ="?name="+constants.getBuilder().getDevice()+"&method="+constants.getMethodName(); - URL obj = new URL("https://"+constants.getEndPoint()+constants.getPath()+constants.getSystemKey()+"/cloudiot_devices"+post_param); - HttpsURLConnection con = (HttpsURLConnection) obj.openConnection(); con.setRequestMethod("POST"); - - String cBTOken = constants.getToken(); - con.setRequestProperty("ClearBlade-UserToken", cBTOken); - con.setRequestProperty("Content-Type", "application/json"); - con.setRequestProperty("Accept", "application/json"); - - String jsonInputString = - "{\"binaryData\": \"c2VuZEZ1bm55TWVzc2FnZVRvRGV2aWNl\"}"; - - - con.setDoOutput(true); try(OutputStream os = con.getOutputStream()) { byte[] - input = jsonInputString.getBytes("utf-8"); os.write(input, 0, input.length); - } - - int responseCode = con.getResponseCode(); - if (responseCode == HttpURLConnection.HTTP_OK) { - this.setHttpStatusCode(responseCode); - this.setHttpStatusResponse("HTTP_OK"); - //success - BufferedReader in = new BufferedReader(new InputStreamReader( con.getInputStream())); - String inputLine; - StringBuffer response = new StringBuffer(); - - while ((inputLine = in.readLine()) != null) { - response.append(inputLine); - } - in.close(); - } else { - System.out.println("POST request not worked"); - } - } catch(MalformedURLException e) { - e.printStackTrace(); - }catch (IOException e) { - e.printStackTrace(); - }catch(Exception e) { - e.printStackTrace(); + init(); + try { + String params = "?name=" + constants.getBuilder().getDevice() + "&method=" + constants.getMethodName(); + URL obj = new URL("https://" + constants.getEndPoint() + constants.getPath() + constants.getSystemKey() + + "/cloudiot_devices" + params); + HttpsURLConnection con = (HttpsURLConnection) obj.openConnection(); + con.setRequestMethod("POST"); + + String cBTOken = constants.getToken(); + con.setRequestProperty("ClearBlade-UserToken", cBTOken); + con.setRequestProperty("Content-Type", "application/json"); + con.setRequestProperty("Accept", "application/json"); + + String jsonInputString = "{\"binaryData\": \"c2VuZEZ1bm55TWVzc2FnZVRvRGV2aWNl\"}"; + + con.setDoOutput(true); + try (OutputStream os = con.getOutputStream()) { + byte[] input = jsonInputString.getBytes(StandardCharsets.UTF_8); + os.write(input, 0, input.length); + + int responseCode = con.getResponseCode(); + if (responseCode == HttpURLConnection.HTTP_OK) { + this.setHttpStatusCode(responseCode); + this.setHttpStatusResponse("HTTP_OK"); + // success + BufferedReader in = new BufferedReader(new InputStreamReader(con.getInputStream())); + String inputLine; + StringBuilder response = new StringBuilder(); + + while ((inputLine = in.readLine()) != null) { + response.append(inputLine); + } + in.close(); + } else { + System.out.println("POST request not worked"); } - + } catch (MalformedURLException e) { + e.printStackTrace(); + } + } catch (IOException e) { + e.printStackTrace(); + } + } @Override - public String toString() - { - return "Http Status Code :: " + this.getHttpStatusCode() +" Http Status Response :: " + this.getHttpStatusResponse(); + public String toString() { + return "Http Status Code :: " + this.getHttpStatusCode() + " Http Status Response :: " + + this.getHttpStatusResponse(); } } diff --git a/clearblade-cloud-iot/src/main/java/com/clearblade/cloud/iot/v1/utils/ByteString.java b/clearblade-cloud-iot/src/main/java/com/clearblade/cloud/iot/v1/utils/ByteString.java new file mode 100644 index 00000000..6cd026f7 --- /dev/null +++ b/clearblade-cloud-iot/src/main/java/com/clearblade/cloud/iot/v1/utils/ByteString.java @@ -0,0 +1,31 @@ +package com.clearblade.cloud.iot.v1.utils; + +import java.nio.charset.StandardCharsets; + +public class ByteString { + + private ByteString binaryData; + private byte[] binaryDataArray; + public static final byte[] EMPTY = new byte[0]; + + public ByteString(String str) { + this.setBinaryDataArray(str.getBytes(StandardCharsets.UTF_8)); + } + + public ByteString getBinaryData() { + return binaryData; + } + + public void setBinaryData(ByteString binaryData) { + this.binaryData = binaryData; + } + + public byte[] getBinaryDataArray() { + return binaryDataArray; + } + + public void setBinaryDataArray(byte[] binaryDataArray) { + this.binaryDataArray = binaryDataArray; + } + +} diff --git a/clearblade-cloud-iot/src/main/java/com/clearblade/cloud/iot/v1/utils/Constants.java b/clearblade-cloud-iot/src/main/java/com/clearblade/cloud/iot/v1/utils/Constants.java index 74e978a7..d7b340c9 100644 --- a/clearblade-cloud-iot/src/main/java/com/clearblade/cloud/iot/v1/utils/Constants.java +++ b/clearblade-cloud-iot/src/main/java/com/clearblade/cloud/iot/v1/utils/Constants.java @@ -11,16 +11,14 @@ public class Constants { public Constants() { this.setEndPoint("iot-sandbox.clearblade.com:443"); - this.setBuilder(DeviceName.newBuilder() - .setProject("ingressdevelopmentenv") - .setLocation("us-central1") - .setRegistry("Rashmi_Registry_Test") - .setDevice("Rashmi_Device_Test")); + this.setBuilder(DeviceName.newBuilder().setProject("ingressdevelopmentenv").setLocation("us-central1") + .setRegistry("Rashmi_Registry_Test").setDevice("Rashmi_Device_Test")); this.setPath("/api/v/4/webhook/execute/"); this.setSystemKey("fedbc9b40cde90befbd9b2dfde9d01"); //Rashmi System Key this.setMethodName("sendCommandToDevice"); - this.setToken("eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1aWQiOiI4NmRjYzliNDBjOWVkMmI4YWFmZmMwOWRhMmNkMDEiLCJzaWQiOiJmZTdkNWIyMy1hODg4LTQ2NGUtOGE4MC01ZWM1NTYwOTBjZTIiLCJ1dCI6MiwidHQiOjEsImV4cCI6LTEsImlhdCI6MTY2NTc0MjU5NX0.osrsmcqunC6IMfgLfZis0UlC4s7W4mmKe73mq_SSJ8Q"); - } + this.setToken( + "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1aWQiOiI4NmRjYzliNDBjOWVkMmI4YWFmZmMwOWRhMmNkMDEiLCJzaWQiOiJmZTdkNWIyMy1hODg4LTQ2NGUtOGE4MC01ZWM1NTYwOTBjZTIiLCJ1dCI6MiwidHQiOjEsImV4cCI6LTEsImlhdCI6MTY2NTc0MjU5NX0.osrsmcqunC6IMfgLfZis0UlC4s7W4mmKe73mq_SSJ8Q"); + } public String getEndPoint() { return endPoint; diff --git a/clearblade-cloud-iot/src/main/java/com/clearblade/cloud/iot/v1/utils/DeviceName.java b/clearblade-cloud-iot/src/main/java/com/clearblade/cloud/iot/v1/utils/DeviceName.java index 91a6c4c2..ac72b530 100644 --- a/clearblade-cloud-iot/src/main/java/com/clearblade/cloud/iot/v1/utils/DeviceName.java +++ b/clearblade-cloud-iot/src/main/java/com/clearblade/cloud/iot/v1/utils/DeviceName.java @@ -45,33 +45,27 @@ public Builder toBuilder() { return new Builder(this); } - public static DeviceName of(String project, String location, String registry, String device) { - return newBuilder() - .setProject(project) - .setLocation(location) - .setRegistry(registry) - .setDevice(device) - .build(); - } - - public static String format(String project, String location, String registry, String device) { - return newBuilder() - .setProject(project) - .setLocation(location) - .setRegistry(registry) - .setDevice(device) - .build() - .toString(); - } - - /** Builder for projects/{project}/locations/{location}/registries/{registry}/devices/{device}. */ - public static class Builder { - private String project; - private String location; - private String registry; - private String device; - - protected Builder() {} + public static DeviceName of(String project, String location, String registry, String device) { + return newBuilder().setProject(project).setLocation(location).setRegistry(registry).setDevice(device).build(); + } + + public static String format(String project, String location, String registry, String device) { + return newBuilder().setProject(project).setLocation(location).setRegistry(registry).setDevice(device).build() + .toString(); + } + + /** + * Builder for + * projects/{project}/locations/{location}/registries/{registry}/devices/{device}. + */ + public static class Builder { + private String project; + private String location; + private String registry; + private String device; + + protected Builder() { + } public String getProject() { return project; From a11390b07e41e93aa72aa1b2b04e2ea81b78326a Mon Sep 17 00:00:00 2001 From: RashmiK14 Date: Thu, 27 Oct 2022 12:09:49 +0530 Subject: [PATCH 003/151] AsyncSendCommand Sample added --- .../iot/v1/AsyncSendCommandToDevice.java | 27 +++++++++++++++++++ .../cloud/iot/v1/DeviceManagerClient.java | 5 ++-- .../iot/v1/SendCommandToDeviceRequest.java | 16 ++++++++--- .../iot/v1/SendCommandToDeviceResponse.java | 11 +++----- 4 files changed, 47 insertions(+), 12 deletions(-) create mode 100644 clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/AsyncSendCommandToDevice.java diff --git a/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/AsyncSendCommandToDevice.java b/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/AsyncSendCommandToDevice.java new file mode 100644 index 00000000..78beb629 --- /dev/null +++ b/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/AsyncSendCommandToDevice.java @@ -0,0 +1,27 @@ +package com.clearblade.cloud.iot.v1; + +import com.clearblade.cloud.iot.v1.utils.ByteString; +import com.clearblade.cloud.iot.v1.utils.Constants; +import com.clearblade.cloud.iot.v1.utils.DeviceName; + +public class AsyncSendCommandToDevice { + + public static void main(String[] args) { + asyncSendCommandToDevice(); + } + + public static void asyncSendCommandToDevice() { + DeviceManagerClient deviceManagerClient = new DeviceManagerClient(); + Constants constants = new Constants(); + DeviceName name = DeviceName.of(constants.getBuilder().getProject(), constants.getBuilder().getLocation(), + constants.getBuilder().getRegistry(), constants.getBuilder().getDevice()); + + SendCommandToDeviceRequest request = SendCommandToDeviceRequest.Builder.newBuilder().setName(name) + .setBinaryDataByte(ByteString.EMPTY).setSubFolder("subfolder153561774").build(); + SendCommandToDeviceResponse response = deviceManagerClient.sendCommandToDevice(request); + if (response != null) { + response.processRequest(); + System.out.println("POST Response is :: " + response.toString()); + } + } +} diff --git a/clearblade-cloud-iot/src/main/java/com/clearblade/cloud/iot/v1/DeviceManagerClient.java b/clearblade-cloud-iot/src/main/java/com/clearblade/cloud/iot/v1/DeviceManagerClient.java index 5d7679c3..5704f843 100644 --- a/clearblade-cloud-iot/src/main/java/com/clearblade/cloud/iot/v1/DeviceManagerClient.java +++ b/clearblade-cloud-iot/src/main/java/com/clearblade/cloud/iot/v1/DeviceManagerClient.java @@ -7,8 +7,8 @@ public class DeviceManagerClient { Constants constants = null; /** - * Initialise the Constants object - * This method will set details like project, location, registry, device + * Initialise the Constants object This method will set details like project, + * location, registry, device */ public void init() { constants = new Constants(); @@ -16,6 +16,7 @@ public void init() { /** * SendCommandToDevice method + * * @param name * @param binaryData */ diff --git a/clearblade-cloud-iot/src/main/java/com/clearblade/cloud/iot/v1/SendCommandToDeviceRequest.java b/clearblade-cloud-iot/src/main/java/com/clearblade/cloud/iot/v1/SendCommandToDeviceRequest.java index a169879d..dfe5d8fb 100644 --- a/clearblade-cloud-iot/src/main/java/com/clearblade/cloud/iot/v1/SendCommandToDeviceRequest.java +++ b/clearblade-cloud-iot/src/main/java/com/clearblade/cloud/iot/v1/SendCommandToDeviceRequest.java @@ -1,5 +1,7 @@ package com.clearblade.cloud.iot.v1; +import java.util.Arrays; + import com.clearblade.cloud.iot.v1.utils.ByteString; import com.clearblade.cloud.iot.v1.utils.DeviceName; @@ -7,21 +9,24 @@ final class SendCommandToDeviceRequest { private final DeviceName name; private final ByteString binaryData; + private final byte[] binaryDataByte; private final String subFolder; private SendCommandToDeviceRequest(Builder builder) { this.name = builder.name; this.binaryData = builder.binaryData; this.subFolder = builder.subFolder; + this.binaryDataByte = builder.binaryDataByte; } - // Static class Builder - public static class Builder { + // Static class Builder + public static class Builder { /// instance fields private DeviceName name; private ByteString binaryData; private String subFolder; + private byte[] binaryDataByte; public static Builder newBuilder() { return new Builder(); @@ -41,6 +46,11 @@ public Builder setBinaryData(ByteString binaryData) { return this; } + public Builder setBinaryDataByte(byte[] binaryDataByte) { + this.binaryDataByte = binaryDataByte; + return this; + } + public Builder setSubFolder(String subFolder) { this.subFolder = subFolder; return this; @@ -55,6 +65,6 @@ public SendCommandToDeviceRequest build() { @Override public String toString() { - return "name = " + this.name.getDevice() + ", binaryData = " + this.binaryData+ ", subFolder = "+this.subFolder; + return "name = " + this.name.getDevice() + ", binaryData = " + this.binaryData+ ", subFolder = "+this.subFolder+ ", binaryDataByte = "+Arrays.toString(this.binaryDataByte); } } diff --git a/clearblade-cloud-iot/src/main/java/com/clearblade/cloud/iot/v1/SendCommandToDeviceResponse.java b/clearblade-cloud-iot/src/main/java/com/clearblade/cloud/iot/v1/SendCommandToDeviceResponse.java index 2b7c0bc7..04b0b569 100644 --- a/clearblade-cloud-iot/src/main/java/com/clearblade/cloud/iot/v1/SendCommandToDeviceResponse.java +++ b/clearblade-cloud-iot/src/main/java/com/clearblade/cloud/iot/v1/SendCommandToDeviceResponse.java @@ -19,11 +19,10 @@ public class SendCommandToDeviceResponse { private int httpStatusCode; private String httpStatusResponse; private Constants constants; - - protected SendCommandToDeviceResponse(Builder builder){ - this.request = builder.request; - } - + + protected SendCommandToDeviceResponse(Builder builder) { + this.request = builder.request; + } public int getHttpStatusCode() { return httpStatusCode; @@ -34,7 +33,6 @@ public void setHttpStatusCode(int httpStatusCode) { this.httpStatusCode = httpStatusCode; } - public String getHttpStatusResponse() { return httpStatusResponse; } @@ -43,7 +41,6 @@ public void setHttpStatusResponse(String httpStatusResponse) { this.httpStatusResponse = httpStatusResponse; } - // Static class Builder public static class Builder { From d4b799e48b3f63ebd348874767820656d973afb2 Mon Sep 17 00:00:00 2001 From: RashmiK14 Date: Mon, 31 Oct 2022 16:34:25 +0530 Subject: [PATCH 004/151] IOT_519 SendCommandToDevice This commit includes following changes :-> 1) Added config.properties file 2) Updated Constants file - fetching key-values from config.properties file 3) Added ProcessRequest class - to execute the sendCommandToDevice call 4) Added SetUpHttpConnection class - to set up actual connection to send request and receive response in return. 5) Removed all lint errors from all the classes 6) Added logs in place of println or error messages 7) Added JUnit test class - added test case for sendCommandToDevice --- .../iot/v1/AsyncSendCommandToDevice.java | 24 +- .../cloud/iot/v1/SyncSendCommandToDevice.java | 21 +- .../cloud/iot/v1/DeviceManagerClient.java | 18 +- .../cloud/iot/v1/ProcessRequest.java | 109 +++++++++ .../iot/v1/SendCommandToDeviceRequest.java | 2 +- .../iot/v1/SendCommandToDeviceResponse.java | 80 ++----- .../cloud/iot/v1/utils/Constants.java | 226 +++++++++++++++--- .../cloud/iot/v1/utils/DeviceName.java | 178 +++++++------- .../cloud/iot/v1/utils/SetHttpConnection.java | 26 ++ .../src/main/java/config.properties | 24 ++ .../iot/v1/test/DeviceManagerClientTest.java | 85 +++++++ 11 files changed, 600 insertions(+), 193 deletions(-) create mode 100644 clearblade-cloud-iot/src/main/java/com/clearblade/cloud/iot/v1/ProcessRequest.java create mode 100644 clearblade-cloud-iot/src/main/java/com/clearblade/cloud/iot/v1/utils/SetHttpConnection.java create mode 100644 clearblade-cloud-iot/src/main/java/config.properties create mode 100644 clearblade-cloud-iot/src/test/java/com/clearblade/cloud/iot/v1/test/DeviceManagerClientTest.java diff --git a/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/AsyncSendCommandToDevice.java b/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/AsyncSendCommandToDevice.java index 78beb629..b616609c 100644 --- a/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/AsyncSendCommandToDevice.java +++ b/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/AsyncSendCommandToDevice.java @@ -1,11 +1,16 @@ package com.clearblade.cloud.iot.v1; +import java.util.logging.Level; +import java.util.logging.Logger; + import com.clearblade.cloud.iot.v1.utils.ByteString; import com.clearblade.cloud.iot.v1.utils.Constants; import com.clearblade.cloud.iot.v1.utils.DeviceName; public class AsyncSendCommandToDevice { - + + static Logger log = Logger.getLogger(AsyncSendCommandToDevice.class.getName()); + public static void main(String[] args) { asyncSendCommandToDevice(); } @@ -13,15 +18,24 @@ public static void main(String[] args) { public static void asyncSendCommandToDevice() { DeviceManagerClient deviceManagerClient = new DeviceManagerClient(); Constants constants = new Constants(); - DeviceName name = DeviceName.of(constants.getBuilder().getProject(), constants.getBuilder().getLocation(), - constants.getBuilder().getRegistry(), constants.getBuilder().getDevice()); - + String msg = ""; + DeviceName name = DeviceName.of(constants.getProject(), constants.getLocation(), + constants.getRegistry(), constants.getDeviceName()); SendCommandToDeviceRequest request = SendCommandToDeviceRequest.Builder.newBuilder().setName(name) .setBinaryDataByte(ByteString.EMPTY).setSubFolder("subfolder153561774").build(); SendCommandToDeviceResponse response = deviceManagerClient.sendCommandToDevice(request); if (response != null) { response.processRequest(); - System.out.println("POST Response is :: " + response.toString()); + if(response.getHttpStatusCode() == 200) { + msg = "AsyncSendCommandToDevice Method execution successful :: " + response.toString() + "\n HTTP RESPONSE IS :: Status Code : "+response.getHttpStatusCode() +" Status Message : " + response.getHttpStatusResponse(); + log.log(Level.INFO, msg); + }else { + msg = "AsyncSendCommandToDevice Method execution failed :: " + response.toString() + "\n HTTP RESPONSE IS :: Status Code : "+response.getHttpStatusCode() +" Status Message : " + response.getHttpStatusResponse(); + log.log(Level.WARNING, msg); + } + }else { + msg = "AsyncSendCommandToDevice Method execution failed"; + log.log(Level.SEVERE, msg); } } } diff --git a/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/SyncSendCommandToDevice.java b/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/SyncSendCommandToDevice.java index cd7afb6f..faccc833 100644 --- a/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/SyncSendCommandToDevice.java +++ b/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/SyncSendCommandToDevice.java @@ -1,11 +1,16 @@ package com.clearblade.cloud.iot.v1; + +import java.util.logging.Level; +import java.util.logging.Logger; + import com.clearblade.cloud.iot.v1.utils.ByteString; import com.clearblade.cloud.iot.v1.utils.Constants; import com.clearblade.cloud.iot.v1.utils.DeviceName; public class SyncSendCommandToDevice { + static Logger log = Logger.getLogger(SyncSendCommandToDevice.class.getName()); public static void main(String[] args) { syncSendCommandToDevice(); } @@ -13,14 +18,24 @@ public static void main(String[] args) { public static void syncSendCommandToDevice() { DeviceManagerClient deviceManagerClient = new DeviceManagerClient(); Constants constants = new Constants(); - DeviceName name = DeviceName.of(constants.getBuilder().getProject(), constants.getBuilder().getLocation(), - constants.getBuilder().getRegistry(), constants.getBuilder().getDevice()); + String msg = ""; + com.clearblade.cloud.iot.v1.utils.DeviceName name = DeviceName.of(constants.getProject(), constants.getLocation(), + constants.getRegistry(), constants.getDeviceName()); SendCommandToDeviceRequest request = SendCommandToDeviceRequest.Builder.newBuilder().setName(name) .setBinaryData(new ByteString("c2VuZEZ1bm55TWVzc2FnZVRvRGV2aWNl")).setSubFolder("subfolder153561774").build(); SendCommandToDeviceResponse response = deviceManagerClient.sendCommandToDevice(request); if (response != null) { response.processRequest(); - System.out.println("POST Response is :: " + response.toString()); + if(response.getHttpStatusCode() == 200) { + msg = "SyncSendCommandToDevice Method execution successful :: " + response.toString() + "\n HTTP RESPONSE IS :: Status Code : "+response.getHttpStatusCode() +" Status Message : " + response.getHttpStatusResponse(); + log.log(Level.INFO, msg); + }else { + msg = "SyncSendCommandToDevice Method execution failed :: " + response.toString() + "\n HTTP RESPONSE IS :: Status Code : "+response.getHttpStatusCode() +" Status Message : " + response.getHttpStatusResponse(); + log.log(Level.WARNING, msg); + } + }else { + msg = "SyncSendCommandToDevice Method execution failed"; + log.log(Level.SEVERE, msg); } } } diff --git a/clearblade-cloud-iot/src/main/java/com/clearblade/cloud/iot/v1/DeviceManagerClient.java b/clearblade-cloud-iot/src/main/java/com/clearblade/cloud/iot/v1/DeviceManagerClient.java index 5704f843..e20e9029 100644 --- a/clearblade-cloud-iot/src/main/java/com/clearblade/cloud/iot/v1/DeviceManagerClient.java +++ b/clearblade-cloud-iot/src/main/java/com/clearblade/cloud/iot/v1/DeviceManagerClient.java @@ -1,27 +1,33 @@ package com.clearblade.cloud.iot.v1; import com.clearblade.cloud.iot.v1.utils.Constants; - +import com.clearblade.cloud.iot.v1.utils.Device; import com.clearblade.cloud.iot.v1.utils.DeviceName; +import com.clearblade.cloud.iot.v1.utils.RegistryName; public class DeviceManagerClient { Constants constants = null; + + public DeviceManagerClient() { + init(); + } + /** * Initialise the Constants object This method will set details like project, * location, registry, device */ public void init() { constants = new Constants(); - } - + } + /** * SendCommandToDevice method * * @param name * @param binaryData */ - public void sendCommandToDevice(DeviceName name, com.clearblade.cloud.iot.v1.utils.ByteString binaryData, String subFolder) { - init(); + public void sendCommandToDevice(DeviceName name, com.clearblade.cloud.iot.v1.utils.ByteString binaryData, + String subFolder) { SendCommandToDeviceRequest request = SendCommandToDeviceRequest.Builder.newBuilder().setName(name) .setBinaryData(binaryData).setSubFolder(subFolder).build(); SendCommandToDeviceResponse response = this.sendCommandToDevice(request); @@ -32,7 +38,7 @@ public void sendCommandToDevice(DeviceName name, com.clearblade.cloud.iot.v1.uti * Print the response for sendCommandToDevice * * @param request - * @return + * @return Response object */ public SendCommandToDeviceResponse sendCommandToDevice(SendCommandToDeviceRequest request) { return (SendCommandToDeviceResponse.Builder.newBuilder().setSendCommandToDeviceRequest(request).build()); diff --git a/clearblade-cloud-iot/src/main/java/com/clearblade/cloud/iot/v1/ProcessRequest.java b/clearblade-cloud-iot/src/main/java/com/clearblade/cloud/iot/v1/ProcessRequest.java new file mode 100644 index 00000000..ac7acfcf --- /dev/null +++ b/clearblade-cloud-iot/src/main/java/com/clearblade/cloud/iot/v1/ProcessRequest.java @@ -0,0 +1,109 @@ +package com.clearblade.cloud.iot.v1; + +import java.io.IOException; +import java.io.OutputStream; +import java.net.MalformedURLException; +import java.net.ProtocolException; +import java.net.URL; +import java.nio.charset.StandardCharsets; + +import javax.net.ssl.HttpsURLConnection; + +import com.clearblade.cloud.iot.v1.utils.Constants; +import com.clearblade.cloud.iot.v1.utils.SetHttpConnection; + +public class ProcessRequest { + + Constants constants; + URL obj; + HttpsURLConnection con; + int responseCode; + String inputString; + + // Empty Constructor + public ProcessRequest() { + constants = new Constants(); + obj = null; + con = null; + responseCode = 0; + inputString = null; + } + + /** + * Method used to get process the request when inputString and connection object + * are inputs ResponseCode - integer value is sent as return value + * + * @param methodName + * @return int - response code + */ + public int processRequestForMethod(String methodName) { + // https://iot-sandbox.clearblade.com:443/api/v/4/webhook/execute/fedbc9b40cde90befbd9b2dfde9d01/cloudiot_devices?name=Rashmi_Device_Test&method=sendCommandToDevice + if (methodName.equals("sendCommandToDevice")) { + + String name = constants.getDeviceName(); + String params = "?name=" + name + "&method=" + methodName; + + try { + obj = new URL( + constants.getHttpURLBegin() + constants.getEndPoint() + constants.getSendCommandPathPart1() + + constants.getSystemKey() + constants.getSendCommandPathPart2() + params); + con = SetHttpConnection.getConnection(obj); + // Calling setConnectionMethod + responseCode = setConnectionMethods(con, methodName); + } catch (Exception e) { + e.printStackTrace(); + } + } + return responseCode; + } + /** + * Set connection methods + * @param con + * @returning response code + */ + public int setConnectionMethods(HttpsURLConnection con,String methodName) { + if (con != null) { + try { + con.setRequestMethod(constants.getHttpRequestMethodType()); + } catch (ProtocolException e) { + e.printStackTrace(); + } + con.setRequestProperty(constants.getHttpRequestPropertyTokenKey(), constants.getToken()); + con.setRequestProperty(constants.getHttpRequestPropertyContentTypeKey(), + constants.getHttpRequestPropertyContentTypeOrAcceptValue()); + con.addRequestProperty(constants.getHttpRequestPropertyAcceptKey(), + constants.getHttpRequestPropertyContentTypeOrAcceptValue()); + if(methodName.equals("sendCommandToDevice")){ + inputString = constants.getJsonInputString(); + } + // SetOutput to connection + con.setDoOutput(true); + // Get responseCode from Connection + responseCode = getResponse(con, inputString); + } else { + responseCode = 0; + } + return responseCode; + } + + /** + * Method used to get Response when inputString and connection object are inputs + * ResponseCode - integer value is sent as return value + * + * @param con + * @param inputString + * @return responseCode + */ + public int getResponse(HttpsURLConnection con, String inputString) { + try (OutputStream os = con.getOutputStream()) { + byte[] input = inputString.getBytes(StandardCharsets.UTF_8); + os.write(input, 0, input.length); + responseCode = con.getResponseCode(); + } catch (MalformedURLException e) { + e.printStackTrace(); + } catch (IOException e1) { + e1.printStackTrace(); + } + return responseCode; + } +} diff --git a/clearblade-cloud-iot/src/main/java/com/clearblade/cloud/iot/v1/SendCommandToDeviceRequest.java b/clearblade-cloud-iot/src/main/java/com/clearblade/cloud/iot/v1/SendCommandToDeviceRequest.java index dfe5d8fb..ceb33a02 100644 --- a/clearblade-cloud-iot/src/main/java/com/clearblade/cloud/iot/v1/SendCommandToDeviceRequest.java +++ b/clearblade-cloud-iot/src/main/java/com/clearblade/cloud/iot/v1/SendCommandToDeviceRequest.java @@ -5,7 +5,7 @@ import com.clearblade.cloud.iot.v1.utils.ByteString; import com.clearblade.cloud.iot.v1.utils.DeviceName; -final class SendCommandToDeviceRequest { +public class SendCommandToDeviceRequest { private final DeviceName name; private final ByteString binaryData; diff --git a/clearblade-cloud-iot/src/main/java/com/clearblade/cloud/iot/v1/SendCommandToDeviceResponse.java b/clearblade-cloud-iot/src/main/java/com/clearblade/cloud/iot/v1/SendCommandToDeviceResponse.java index 04b0b569..2957ce00 100644 --- a/clearblade-cloud-iot/src/main/java/com/clearblade/cloud/iot/v1/SendCommandToDeviceResponse.java +++ b/clearblade-cloud-iot/src/main/java/com/clearblade/cloud/iot/v1/SendCommandToDeviceResponse.java @@ -1,24 +1,15 @@ package com.clearblade.cloud.iot.v1; -import java.io.BufferedReader; -import java.io.IOException; -import java.io.InputStreamReader; -import java.io.OutputStream; import java.net.HttpURLConnection; -import java.net.MalformedURLException; -import java.net.URL; -import java.nio.charset.StandardCharsets; - -import javax.net.ssl.HttpsURLConnection; - -import com.clearblade.cloud.iot.v1.utils.Constants; +import java.util.logging.Level; +import java.util.logging.Logger; public class SendCommandToDeviceResponse { + static Logger log = Logger.getLogger(SendCommandToDeviceResponse.class.getName()); private final SendCommandToDeviceRequest request; private int httpStatusCode; private String httpStatusResponse; - private Constants constants; protected SendCommandToDeviceResponse(Builder builder) { this.request = builder.request; @@ -28,7 +19,6 @@ public int getHttpStatusCode() { return httpStatusCode; } - public void setHttpStatusCode(int httpStatusCode) { this.httpStatusCode = httpStatusCode; } @@ -67,52 +57,22 @@ public SendCommandToDeviceResponse build() { } } - public void init() { - constants = new Constants(); - } - + /** + * Mehtod used to process the request + * Calling processRequestForMethod - sendCommandToDevice + */ public void processRequest() { - init(); - try { - String params = "?name=" + constants.getBuilder().getDevice() + "&method=" + constants.getMethodName(); - URL obj = new URL("https://" + constants.getEndPoint() + constants.getPath() + constants.getSystemKey() - + "/cloudiot_devices" + params); - HttpsURLConnection con = (HttpsURLConnection) obj.openConnection(); - con.setRequestMethod("POST"); - - String cBTOken = constants.getToken(); - con.setRequestProperty("ClearBlade-UserToken", cBTOken); - con.setRequestProperty("Content-Type", "application/json"); - con.setRequestProperty("Accept", "application/json"); - - String jsonInputString = "{\"binaryData\": \"c2VuZEZ1bm55TWVzc2FnZVRvRGV2aWNl\"}"; - - con.setDoOutput(true); - try (OutputStream os = con.getOutputStream()) { - byte[] input = jsonInputString.getBytes(StandardCharsets.UTF_8); - os.write(input, 0, input.length); - - int responseCode = con.getResponseCode(); - if (responseCode == HttpURLConnection.HTTP_OK) { - this.setHttpStatusCode(responseCode); - this.setHttpStatusResponse("HTTP_OK"); - // success - BufferedReader in = new BufferedReader(new InputStreamReader(con.getInputStream())); - String inputLine; - StringBuilder response = new StringBuilder(); - - while ((inputLine = in.readLine()) != null) { - response.append(inputLine); - } - in.close(); - } else { - System.out.println("POST request not worked"); - } - } catch (MalformedURLException e) { - e.printStackTrace(); - } - } catch (IOException e) { - e.printStackTrace(); + + ProcessRequest processRequest = new ProcessRequest(); + int responseCode = processRequest.processRequestForMethod("sendCommandToDevice"); + this.setHttpStatusCode(responseCode); + + if (responseCode == HttpURLConnection.HTTP_OK) { + this.setHttpStatusCode(responseCode); + this.setHttpStatusResponse("HTTP_OK"); + log.log(Level.INFO, "Request processed successfully for SendCommandToDevice method"); + } else { + log.log(Level.SEVERE, "POST request not worked for sendCommandToDevice Method"); } } @@ -122,4 +82,8 @@ public String toString() { return "Http Status Code :: " + this.getHttpStatusCode() + " Http Status Response :: " + this.getHttpStatusResponse(); } + + public SendCommandToDeviceRequest getRequest() { + return request; + } } diff --git a/clearblade-cloud-iot/src/main/java/com/clearblade/cloud/iot/v1/utils/Constants.java b/clearblade-cloud-iot/src/main/java/com/clearblade/cloud/iot/v1/utils/Constants.java index d7b340c9..2bb45e83 100644 --- a/clearblade-cloud-iot/src/main/java/com/clearblade/cloud/iot/v1/utils/Constants.java +++ b/clearblade-cloud-iot/src/main/java/com/clearblade/cloud/iot/v1/utils/Constants.java @@ -1,23 +1,107 @@ package com.clearblade.cloud.iot.v1.utils; +import java.io.IOException; +import java.io.InputStream; +import java.util.Properties; + public class Constants { + //Fields used to set values from properties file private String endPoint; - private String path; private String systemKey; - private String methodName; private String token; - private DeviceName.Builder builder; + private String project; + private String location; + private String registry; + private String deviceName; + + //Fields used to set key- values related to httpconnection - for common use + private String httpRequestMethodType; + private String httpRequestPropertyTokenKey; + private String httpRequestPropertyContentTypeKey; + private String httpRequestPropertyAcceptKey; + private String httpRequestPropertyContentTypeOrAcceptValue; + + private String httpURLBegin; + + //Fields used to set values related for sendCommandToDevice method + private String sendCommandMethodName; + private String sendCommandPathPart1; + private String sendCommandPathPart2; + private String jsonInputString; + + + //Fields used to fetch values from Properties file + Properties properties; + InputStream input; public Constants() { - this.setEndPoint("iot-sandbox.clearblade.com:443"); - this.setBuilder(DeviceName.newBuilder().setProject("ingressdevelopmentenv").setLocation("us-central1") - .setRegistry("Rashmi_Registry_Test").setDevice("Rashmi_Device_Test")); - this.setPath("/api/v/4/webhook/execute/"); - this.setSystemKey("fedbc9b40cde90befbd9b2dfde9d01"); //Rashmi System Key - this.setMethodName("sendCommandToDevice"); - this.setToken( - "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1aWQiOiI4NmRjYzliNDBjOWVkMmI4YWFmZmMwOWRhMmNkMDEiLCJzaWQiOiJmZTdkNWIyMy1hODg4LTQ2NGUtOGE4MC01ZWM1NTYwOTBjZTIiLCJ1dCI6MiwidHQiOjEsImV4cCI6LTEsImlhdCI6MTY2NTc0MjU5NX0.osrsmcqunC6IMfgLfZis0UlC4s7W4mmKe73mq_SSJ8Q"); + properties = null; + input = null; + setValues(); + } + + /** + * Method used to read values form config.properties file and setting in + * field setters + */ + public void getConfigurations() { + // Read inputs from properties file + properties = new Properties(); + input = getClass().getClassLoader().getResourceAsStream("config.properties"); + try { + properties.load(input); + }catch(IOException ex) { + ex.printStackTrace(); + }finally { + if(input != null) { + try { + input.close(); + } catch (IOException e) { + e.printStackTrace(); + } + } + } + } + + /** + * Method used to set values in Constants setter method + */ + public void setValues() { + + getConfigurations(); + + this.setEndPoint(properties.getProperty("endPoint")); + this.setSystemKey(properties.getProperty("systemKey")); + this.setToken(properties.getProperty("token")); + this.setProject(properties.getProperty("project")); + this.setLocation(properties.getProperty("location")); + this.setRegistry(properties.getProperty("registry")); + this.setDeviceName(properties.getProperty("deviceName")); + + this.setHttpRequestMethodType(properties.getProperty("httpRequestMethodType")); + this.setHttpRequestPropertyTokenKey(properties.getProperty("httpRequestPropertyTokenKey")); + this.setHttpRequestPropertyContentTypeKey(properties.getProperty("httpRequestPropertyContentTypeKey")); + this.setHttpRequestPropertyAcceptKey(properties.getProperty("httpRequestPropertyAcceptKey")); + this.setHttpRequestPropertyContentTypeOrAcceptValue(properties.getProperty("httpRequestPropertyContentTypeOrAcceptValue")); + + this.setHttpURLBegin(properties.getProperty("httpURLBegin")); + + this.setSendCommandMethodName(properties.getProperty("sendCommandMethodName")); + this.setSendCommandPathPart1(properties.getProperty("sendCommandPathPart1")); + this.setSendCommandPathPart2(properties.getProperty("sendCommandPathPart2")); + + this.setJsonInputString(properties.getProperty("jsonInputString")); + + + } + + public String getJsonInputString() { + return jsonInputString; + } + + public void setJsonInputString(String jsonInputString) { + this.jsonInputString = jsonInputString; } public String getEndPoint() { @@ -28,14 +112,6 @@ public void setEndPoint(String endPoint) { this.endPoint = endPoint; } - public String getPath() { - return path; - } - - public void setPath(String path) { - this.path = path; - } - public String getSystemKey() { return systemKey; } @@ -44,14 +120,6 @@ public void setSystemKey(String systemKey) { this.systemKey = systemKey; } - public String getMethodName() { - return methodName; - } - - public void setMethodName(String methodName) { - this.methodName = methodName; - } - public String getToken() { return token; } @@ -60,12 +128,108 @@ public void setToken(String token) { this.token = token; } - public DeviceName.Builder getBuilder() { - return builder; + public String getProject() { + return project; + } + + public void setProject(String project) { + this.project = project; + } + + public String getLocation() { + return location; + } + + public void setLocation(String location) { + this.location = location; + } + + public String getRegistry() { + return registry; + } + + public void setRegistry(String registry) { + this.registry = registry; + } + + public String getDeviceName() { + return deviceName; + } + + public void setDeviceName(String deviceName) { + this.deviceName = deviceName; + } + + public String getHttpRequestMethodType() { + return httpRequestMethodType; + } + + public void setHttpRequestMethodType(String httpRequestMethodType) { + this.httpRequestMethodType = httpRequestMethodType; + } + + public String getHttpRequestPropertyTokenKey() { + return httpRequestPropertyTokenKey; + } + + public void setHttpRequestPropertyTokenKey(String httpRequestPropertyTokenKey) { + this.httpRequestPropertyTokenKey = httpRequestPropertyTokenKey; + } + + public String getHttpRequestPropertyContentTypeKey() { + return httpRequestPropertyContentTypeKey; + } + + public void setHttpRequestPropertyContentTypeKey(String httpRequestPropertyContentTypeKey) { + this.httpRequestPropertyContentTypeKey = httpRequestPropertyContentTypeKey; + } + + public String getHttpRequestPropertyAcceptKey() { + return httpRequestPropertyAcceptKey; + } + + public void setHttpRequestPropertyAcceptKey(String httpRequestPropertyAcceptKey) { + this.httpRequestPropertyAcceptKey = httpRequestPropertyAcceptKey; + } + + public String getHttpRequestPropertyContentTypeOrAcceptValue() { + return httpRequestPropertyContentTypeOrAcceptValue; + } + + public void setHttpRequestPropertyContentTypeOrAcceptValue(String httpRequestPropertyContentTypeOrAcceptValue) { + this.httpRequestPropertyContentTypeOrAcceptValue = httpRequestPropertyContentTypeOrAcceptValue; + } + + public String getHttpURLBegin() { + return httpURLBegin; + } + + public void setHttpURLBegin(String httpURLBegin) { + this.httpURLBegin = httpURLBegin; + } + + public String getSendCommandMethodName() { + return sendCommandMethodName; + } + + public void setSendCommandMethodName(String sendCommandMethodName) { + this.sendCommandMethodName = sendCommandMethodName; + } + + public String getSendCommandPathPart1() { + return sendCommandPathPart1; + } + + public void setSendCommandPathPart1(String sendCommandPathPart1) { + this.sendCommandPathPart1 = sendCommandPathPart1; + } + + public String getSendCommandPathPart2() { + return sendCommandPathPart2; } - public void setBuilder(DeviceName.Builder builder) { - this.builder = builder; + public void setSendCommandPathPart2(String sendCommandPathPart2) { + this.sendCommandPathPart2 = sendCommandPathPart2; } } diff --git a/clearblade-cloud-iot/src/main/java/com/clearblade/cloud/iot/v1/utils/DeviceName.java b/clearblade-cloud-iot/src/main/java/com/clearblade/cloud/iot/v1/utils/DeviceName.java index ac72b530..ca088206 100644 --- a/clearblade-cloud-iot/src/main/java/com/clearblade/cloud/iot/v1/utils/DeviceName.java +++ b/clearblade-cloud-iot/src/main/java/com/clearblade/cloud/iot/v1/utils/DeviceName.java @@ -2,48 +2,48 @@ public class DeviceName { - private final String project; - private final String location; - private final String registry; - private final String device; - - protected DeviceName() { - project = null; - location = null; - registry = null; - device = null; - } - - private DeviceName(Builder builder) { - project = builder.getProject(); - location = builder.getLocation(); - registry = builder.getRegistry(); - device = builder.getDevice(); - } - - public String getProject() { - return project; - } - - public String getLocation() { - return location; - } - - public String getRegistry() { - return registry; - } - - public String getDevice() { - return device; - } - - public static Builder newBuilder() { - return new Builder(); - } - - public Builder toBuilder() { - return new Builder(this); - } + private final String project; + private final String location; + private final String registry; + private final String device; + + protected DeviceName() { + project = null; + location = null; + registry = null; + device = null; + } + + private DeviceName(Builder builder) { + project = builder.getProject(); + location = builder.getLocation(); + registry = builder.getRegistry(); + device = builder.getDevice(); + } + + public String getProject() { + return project; + } + + public String getLocation() { + return location; + } + + public String getRegistry() { + return registry; + } + + public String getDevice() { + return device; + } + + public static Builder newBuilder() { + return new Builder(); + } + + public Builder toBuilder() { + return new Builder(this); + } public static DeviceName of(String project, String location, String registry, String device) { return newBuilder().setProject(project).setLocation(location).setRegistry(registry).setDevice(device).build(); @@ -67,51 +67,51 @@ public static class Builder { protected Builder() { } - public String getProject() { - return project; - } - - public String getLocation() { - return location; - } - - public String getRegistry() { - return registry; - } - - public String getDevice() { - return device; - } - - public Builder setProject(String project) { - this.project = project; - return this; - } - - public Builder setLocation(String location) { - this.location = location; - return this; - } - - public Builder setRegistry(String registry) { - this.registry = registry; - return this; - } - - public Builder setDevice(String device) { - this.device = device; - return this; - } - - private Builder(DeviceName deviceName) { - this.project = deviceName.project; - this.location = deviceName.location; - this.registry = deviceName.registry; - this.device = deviceName.device; - } - - public DeviceName build() { - return new DeviceName(this); - } - } + public String getProject() { + return project; + } + + public String getLocation() { + return location; + } + + public String getRegistry() { + return registry; + } + + public String getDevice() { + return device; + } + + public Builder setProject(String project) { + this.project = project; + return this; + } + + public Builder setLocation(String location) { + this.location = location; + return this; + } + + public Builder setRegistry(String registry) { + this.registry = registry; + return this; + } + + public Builder setDevice(String device) { + this.device = device; + return this; + } + + private Builder(DeviceName deviceName) { + this.project = deviceName.project; + this.location = deviceName.location; + this.registry = deviceName.registry; + this.device = deviceName.device; + } + + public DeviceName build() { + return new DeviceName(this); + } + } } diff --git a/clearblade-cloud-iot/src/main/java/com/clearblade/cloud/iot/v1/utils/SetHttpConnection.java b/clearblade-cloud-iot/src/main/java/com/clearblade/cloud/iot/v1/utils/SetHttpConnection.java new file mode 100644 index 00000000..2bc61bf1 --- /dev/null +++ b/clearblade-cloud-iot/src/main/java/com/clearblade/cloud/iot/v1/utils/SetHttpConnection.java @@ -0,0 +1,26 @@ +package com.clearblade.cloud.iot.v1.utils; + +import java.io.IOException; +import java.net.URL; + +import javax.net.ssl.HttpsURLConnection; + +public class SetHttpConnection { + private static HttpsURLConnection con; + + private SetHttpConnection() { + } + + public static HttpsURLConnection getConnection(URL url) { + if(SetHttpConnection.con != null) { + return SetHttpConnection.con; + }else { + try { + con = (HttpsURLConnection) url.openConnection(); + } catch (IOException e) { + e.printStackTrace(); + } + return con; + } + } +} diff --git a/clearblade-cloud-iot/src/main/java/config.properties b/clearblade-cloud-iot/src/main/java/config.properties new file mode 100644 index 00000000..2383b8a9 --- /dev/null +++ b/clearblade-cloud-iot/src/main/java/config.properties @@ -0,0 +1,24 @@ +endPoint=iot-sandbox.clearblade.com:443 +systemKey=fedbc9b40cde90befbd9b2dfde9d01 +token=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1aWQiOiI4NmRjYzliNDBjOWVkMmI4YWFmZmMwOWRhMmNkMDEiLCJzaWQiOiJmZTdkNWIyMy1hODg4LTQ2NGUtOGE4MC01ZWM1NTYwOTBjZTIiLCJ1dCI6MiwidHQiOjEsImV4cCI6LTEsImlhdCI6MTY2NTc0MjU5NX0.osrsmcqunC6IMfgLfZis0UlC4s7W4mmKe73mq_SSJ8Q +project=ingressdevelopmentenv +location=us-central1 +registry=Rashmi_Registry_Test +deviceName=Rashmi_Device_Test + +httpRequestMethodType=POST +httpRequestPropertyTokenKey=ClearBlade-UserToken +httpRequestPropertyContentTypeKey=Content-Type +httpRequestPropertyAcceptKey=Accept +httpRequestPropertyContentTypeOrAcceptValue=application/json + + +httpURLBegin=https:// + +sendCommandMethodName=sendCommandToDevice +sendCommandPathPart1=/api/v/4/webhook/execute/ +sendCommandPathPart2=/cloudiot_devices + +jsonInputString={\"binaryData\": \"c2VuZEZ1bm55TWVzc2FnZVRvRGV2aWNl\"} + + diff --git a/clearblade-cloud-iot/src/test/java/com/clearblade/cloud/iot/v1/test/DeviceManagerClientTest.java b/clearblade-cloud-iot/src/test/java/com/clearblade/cloud/iot/v1/test/DeviceManagerClientTest.java new file mode 100644 index 00000000..9840fada --- /dev/null +++ b/clearblade-cloud-iot/src/test/java/com/clearblade/cloud/iot/v1/test/DeviceManagerClientTest.java @@ -0,0 +1,85 @@ +package com.clearblade.cloud.iot.v1.test; + +import static org.junit.jupiter.api.Assertions.fail; + +import java.util.logging.Level; +import java.util.logging.Logger; + +import org.junit.jupiter.api.Test; + +import com.clearblade.cloud.iot.v1.DeviceManagerClient; +import com.clearblade.cloud.iot.v1.SendCommandToDeviceRequest; +import com.clearblade.cloud.iot.v1.SendCommandToDeviceResponse; +import com.clearblade.cloud.iot.v1.utils.ByteString; +import com.clearblade.cloud.iot.v1.utils.Constants; +import com.clearblade.cloud.iot.v1.utils.DeviceName; + +class DeviceManagerClientTest { + + private DeviceManagerClient client; + private Constants constants; + static Logger log = Logger.getLogger(DeviceManagerClientTest.class.getName()); + + void init() { + client = new DeviceManagerClient(); + constants = new Constants(); + } + + @Test + void testSendCommandToDeviceDeviceNameByteStringString() { + init(); + int expectedResponse = 200; + String msg = ""; + + DeviceName name = DeviceName.of(constants.getProject(), constants.getLocation(), constants.getRegistry(), + constants.getDeviceName()); + ByteString binaryData = new ByteString(""); + + SendCommandToDeviceRequest request = SendCommandToDeviceRequest.Builder.newBuilder().setName(name) + .setBinaryData(binaryData).setSubFolder(null).build(); + SendCommandToDeviceResponse actualResponse = client.sendCommandToDevice(request); + if (actualResponse != null) { + actualResponse.processRequest(); + if(actualResponse.getHttpStatusCode() == expectedResponse) { + msg = "SendCommandToDeviceTest successfully executed"; + log.log(Level.INFO, msg); + }else { + msg = "SendCommandToDeviceTest execution failed"; + log.log(Level.WARNING, msg); + fail(msg); + } + } else { + msg = "SendCommandToDeviceTest execution failed"; + log.log(Level.SEVERE,msg); + fail(msg); + } + } + + @Test + void testSendCommandToDeviceDeviceNameByteStringStringFail() { + init(); + int expectedResponse = 200; + String msg =""; + DeviceName name = DeviceName.of("","","",""); + ByteString binaryData = new ByteString(""); + + SendCommandToDeviceRequest request = SendCommandToDeviceRequest.Builder.newBuilder().setName(name) + .setBinaryData(binaryData).setSubFolder(null).build(); + SendCommandToDeviceResponse actualResponse = client.sendCommandToDevice(request); + if (actualResponse != null) { + actualResponse.processRequest(); + if(actualResponse.getHttpStatusCode() != expectedResponse) { + msg = "SendCommandToDeviceTest Failure Case is Successful"; + log.log(Level.INFO, msg); + }else { + msg = "SendCommandToDeviceTest Failure case testing is failed"; + log.log(Level.WARNING,msg); + } + }else { + msg = "SendCommandToDeviceTest Failure case testing is failed"; + log.log(Level.SEVERE, msg); + fail(msg); + } + } + +} From 9a9fe5ac62a835038443d0d93bb3f3760d65f717 Mon Sep 17 00:00:00 2001 From: RashmiK14 Date: Mon, 31 Oct 2022 16:50:37 +0530 Subject: [PATCH 005/151] IOT_605 devicesCreate-endpoint regional This commit includes following changes :-> 1) Implemented createDevice endpoint - regional api 2) Updated config.properties and constants file for setting createDevice related changes 3) Added JUnit test case for createDevice 4) Added sample for SyncCreateDevice class --- .../cloud/iot/v1/SyncCreateDevice.java | 41 +++++++ .../cloud/iot/v1/CreateDeviceRequest.java | 50 +++++++++ .../cloud/iot/v1/CreateDeviceResponse.java | 101 +++++++++++++++++ .../cloud/iot/v1/DeviceManagerClient.java | 24 ++++ .../cloud/iot/v1/ProcessRequest.java | 18 +++ .../iot/v1/SendCommandToDeviceResponse.java | 2 - .../cloud/iot/v1/utils/Constants.java | 62 +++++++++++ .../clearblade/cloud/iot/v1/utils/Device.java | 105 ++++++++++++++++++ .../cloud/iot/v1/utils/RegistryName.java | 100 +++++++++++++++++ .../src/main/java/config.properties | 6 + .../iot/v1/test/DeviceManagerClientTest.java | 30 +++++ 11 files changed, 537 insertions(+), 2 deletions(-) create mode 100644 clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/SyncCreateDevice.java create mode 100644 clearblade-cloud-iot/src/main/java/com/clearblade/cloud/iot/v1/CreateDeviceRequest.java create mode 100644 clearblade-cloud-iot/src/main/java/com/clearblade/cloud/iot/v1/CreateDeviceResponse.java create mode 100644 clearblade-cloud-iot/src/main/java/com/clearblade/cloud/iot/v1/utils/Device.java create mode 100644 clearblade-cloud-iot/src/main/java/com/clearblade/cloud/iot/v1/utils/RegistryName.java diff --git a/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/SyncCreateDevice.java b/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/SyncCreateDevice.java new file mode 100644 index 00000000..79c3404f --- /dev/null +++ b/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/SyncCreateDevice.java @@ -0,0 +1,41 @@ +package com.clearblade.cloud.iot.v1; + +import java.util.logging.Level; +import java.util.logging.Logger; + +import com.clearblade.cloud.iot.v1.utils.Constants; +import com.clearblade.cloud.iot.v1.utils.Device; +import com.clearblade.cloud.iot.v1.utils.RegistryName; + +public class SyncCreateDevice { + static Logger log = Logger.getLogger(SyncCreateDevice.class.getName()); + + public static void main(String[] args) { + syncCreateDevice(); + } + + public static void syncCreateDevice() { + + DeviceManagerClient deviceManagerClient = new DeviceManagerClient(); + Constants constants = new Constants(); + String msg = ""; + RegistryName registryName = RegistryName.of(constants.getProject(), constants.getLocation(), + constants.getRegistry()); + CreateDeviceRequest request = CreateDeviceRequest.Builder.newBuilder().setParent(registryName.toString()) + .setDevice(Device.newBuilder().build()).build(); + CreateDeviceResponse response = deviceManagerClient.createDevice(request); + if (response != null) { + response.processRequest(); + if(response.getHttpStatusCode() == 200) { + msg = "SyncCreateDevice Method worked successfully :: " + response.toString() + "\n HTTP RESPONSE IS :: Status Code : "+response.getHttpStatusCode() +" Status Message : " + response.getHttpStatusResponse(); + log.log(Level.INFO, msg); + }else { + msg = "SyncCreateDevice Method execution failed :: " + response.toString() + "\n HTTP RESPONSE IS :: Status Code : "+response.getHttpStatusCode() +" Status Message : " + response.getHttpStatusResponse(); + log.log(Level.WARNING, msg); + } + }else { + msg = "SyncCreateDevice Method execution failed"; + log.log(Level.SEVERE, msg); + } + } +} diff --git a/clearblade-cloud-iot/src/main/java/com/clearblade/cloud/iot/v1/CreateDeviceRequest.java b/clearblade-cloud-iot/src/main/java/com/clearblade/cloud/iot/v1/CreateDeviceRequest.java new file mode 100644 index 00000000..2118c851 --- /dev/null +++ b/clearblade-cloud-iot/src/main/java/com/clearblade/cloud/iot/v1/CreateDeviceRequest.java @@ -0,0 +1,50 @@ +package com.clearblade.cloud.iot.v1; + +import com.clearblade.cloud.iot.v1.utils.Device; + +public class CreateDeviceRequest { + private final String parent; + private final Device device; + + private CreateDeviceRequest(Builder builder) { + this.parent = builder.parent; + this.device = builder.device; + } + + // Static class Builder + public static class Builder { + + /// instance fields + private String parent; + private Device device; + + public static Builder newBuilder() { + return new Builder(); + } + + private Builder() { + } + + // Setter methods + public Builder setParent(String parent) { + this.parent = parent; + return this; + } + + public Builder setDevice(Device device) { + this.device = device; + return this; + } + + // build method to deal with outer class + // to return outer instance + public CreateDeviceRequest build() { + return new CreateDeviceRequest(this); + } + } + + @Override + public String toString() { + return "parent = " + this.parent + ", device = " + this.device.toString(); + } +} diff --git a/clearblade-cloud-iot/src/main/java/com/clearblade/cloud/iot/v1/CreateDeviceResponse.java b/clearblade-cloud-iot/src/main/java/com/clearblade/cloud/iot/v1/CreateDeviceResponse.java new file mode 100644 index 00000000..8e378a03 --- /dev/null +++ b/clearblade-cloud-iot/src/main/java/com/clearblade/cloud/iot/v1/CreateDeviceResponse.java @@ -0,0 +1,101 @@ +package com.clearblade.cloud.iot.v1; + +import java.net.HttpURLConnection; +import java.util.logging.Level; +import java.util.logging.Logger; + +public class CreateDeviceResponse { + + static Logger log = Logger.getLogger(CreateDeviceResponse.class.getName()); + private final CreateDeviceRequest request; + private int httpStatusCode; + private String httpStatusResponse; + + protected CreateDeviceResponse(Builder builder) { + this.request = builder.request; + } + + public int getHttpStatusCode() { + return httpStatusCode; + } + + public void setHttpStatusCode(int httpStatusCode) { + this.httpStatusCode = httpStatusCode; + } + + public String getHttpStatusResponse() { + return httpStatusResponse; + } + + public void setHttpStatusResponse(String httpStatusResponse) { + this.httpStatusResponse = httpStatusResponse; + } + + // Static class Builder + public static class Builder { + + /// instance fields + private CreateDeviceRequest request; + + public static Builder newBuilder() { + return new Builder(); + } + + private Builder() { + } + + // Setter methods + public Builder setCreateDeviceRequest(CreateDeviceRequest request) { + this.request = request; + return this; + } + + // build method to deal with outer class + // to return outer instance + public CreateDeviceResponse build() { + return new CreateDeviceResponse(this); + } + } + + /** + * Mehtod used to process the request + * Calling processRequestForMethod - CreateDevice + */ + public void processRequest() { + + ProcessRequest processRequest = new ProcessRequest(); + String msg = ""; + + int responseCode = processRequest.processRequestForMethod("createDevice"); + this.setHttpStatusCode(responseCode); + switch(responseCode) { + case HttpURLConnection.HTTP_BAD_REQUEST: + this.setHttpStatusResponse("HTTP_BAD_REQUEST"); + break; + case HttpURLConnection.HTTP_INTERNAL_ERROR: + this.setHttpStatusResponse("HTTP_INTERNAL_ERROR"); + break; + default: + this.setHttpStatusResponse("HTTP_OK"); + break; + } + if (responseCode == HttpURLConnection.HTTP_OK) { + msg = "Request processed for CreateDevice method.\n HTTP RESPONSE IS :: Status Code : "+this.getHttpStatusCode()+" Status Message : "+this.getHttpStatusResponse(); + log.log(Level.INFO, msg); + } else { + msg = "Request is not processed for CreateDevice method.\n HTTP RESPONSE IS :: Status Code : "+this.getHttpStatusCode()+" Status Message : "+this.getHttpStatusResponse(); + log.log(Level.SEVERE, msg); + } + } + + @Override + public String toString() { + return "Http Status Code :: " + this.getHttpStatusCode() + " Http Status Response :: " + + this.getHttpStatusResponse(); + } + + public CreateDeviceRequest getRequest() { + return request; + } + +} diff --git a/clearblade-cloud-iot/src/main/java/com/clearblade/cloud/iot/v1/DeviceManagerClient.java b/clearblade-cloud-iot/src/main/java/com/clearblade/cloud/iot/v1/DeviceManagerClient.java index e20e9029..4dbb8865 100644 --- a/clearblade-cloud-iot/src/main/java/com/clearblade/cloud/iot/v1/DeviceManagerClient.java +++ b/clearblade-cloud-iot/src/main/java/com/clearblade/cloud/iot/v1/DeviceManagerClient.java @@ -44,4 +44,28 @@ public SendCommandToDeviceResponse sendCommandToDevice(SendCommandToDeviceReques return (SendCommandToDeviceResponse.Builder.newBuilder().setSendCommandToDeviceRequest(request).build()); } + /** + * Method used to call createDevice apicall + * + * @param parent + * @param device + * @return Device object + */ + public void createDevice(RegistryName parent, Device device) { + CreateDeviceRequest request = CreateDeviceRequest.Builder.newBuilder() + .setParent(parent == null ? null : parent.toString()).setDevice(device).build(); + CreateDeviceResponse response = this.createDevice(request); + response.processRequest(); + } + + /** + * Print the response for createDevice + * + * @param request + * @return Response Object + */ + public CreateDeviceResponse createDevice(CreateDeviceRequest request) { + return (CreateDeviceResponse.Builder.newBuilder().setCreateDeviceRequest(request).build()); + } + } diff --git a/clearblade-cloud-iot/src/main/java/com/clearblade/cloud/iot/v1/ProcessRequest.java b/clearblade-cloud-iot/src/main/java/com/clearblade/cloud/iot/v1/ProcessRequest.java index ac7acfcf..b7ba3b2f 100644 --- a/clearblade-cloud-iot/src/main/java/com/clearblade/cloud/iot/v1/ProcessRequest.java +++ b/clearblade-cloud-iot/src/main/java/com/clearblade/cloud/iot/v1/ProcessRequest.java @@ -53,6 +53,22 @@ public int processRequestForMethod(String methodName) { } catch (Exception e) { e.printStackTrace(); } + } else if (methodName.equals("createDevice")) { + // https://iot-sandbox.clearblade.com/api/v/4/webhook/execute/fedbc9b40cde90befbd9b2dfde9d01/cloudiot_devices?deviceNumIds=124,666&subfolder=775 + String deviceNumIds = constants.getNumIds(); + String subfolder = constants.getSubFolder(); + String params = "?deviceNumIds=" + deviceNumIds + "&subfolder=" + subfolder; + + try { + obj = new URL( + constants.getHttpURLBegin() + constants.getEndPoint() + constants.getCreateDevicePathPart1() + + constants.getSystemKey() + constants.getCreateDevicePathPart2() + params); + con = SetHttpConnection.getConnection(obj); + // Calling setConnectionMethod + responseCode = setConnectionMethods(con, methodName); + } catch (Exception e) { + e.printStackTrace(); + } } return responseCode; } @@ -75,6 +91,8 @@ public int setConnectionMethods(HttpsURLConnection con,String methodName) { constants.getHttpRequestPropertyContentTypeOrAcceptValue()); if(methodName.equals("sendCommandToDevice")){ inputString = constants.getJsonInputString(); + }else if (methodName.equals("createDevice")) { + inputString = constants.getCreateDeviceInputString(); } // SetOutput to connection con.setDoOutput(true); diff --git a/clearblade-cloud-iot/src/main/java/com/clearblade/cloud/iot/v1/SendCommandToDeviceResponse.java b/clearblade-cloud-iot/src/main/java/com/clearblade/cloud/iot/v1/SendCommandToDeviceResponse.java index 2957ce00..22d9c7a6 100644 --- a/clearblade-cloud-iot/src/main/java/com/clearblade/cloud/iot/v1/SendCommandToDeviceResponse.java +++ b/clearblade-cloud-iot/src/main/java/com/clearblade/cloud/iot/v1/SendCommandToDeviceResponse.java @@ -66,9 +66,7 @@ public void processRequest() { ProcessRequest processRequest = new ProcessRequest(); int responseCode = processRequest.processRequestForMethod("sendCommandToDevice"); this.setHttpStatusCode(responseCode); - if (responseCode == HttpURLConnection.HTTP_OK) { - this.setHttpStatusCode(responseCode); this.setHttpStatusResponse("HTTP_OK"); log.log(Level.INFO, "Request processed successfully for SendCommandToDevice method"); } else { diff --git a/clearblade-cloud-iot/src/main/java/com/clearblade/cloud/iot/v1/utils/Constants.java b/clearblade-cloud-iot/src/main/java/com/clearblade/cloud/iot/v1/utils/Constants.java index 2bb45e83..ac9d3d01 100644 --- a/clearblade-cloud-iot/src/main/java/com/clearblade/cloud/iot/v1/utils/Constants.java +++ b/clearblade-cloud-iot/src/main/java/com/clearblade/cloud/iot/v1/utils/Constants.java @@ -30,6 +30,13 @@ public class Constants { private String sendCommandPathPart2; private String jsonInputString; + //Fields used to set values for createDevice method + private String createDeviceMethodName; + private String createDevicePathPart1; + private String createDevicePathPart2; + private String numIds; + private String subFolder; + private String createDeviceInputString; //Fields used to fetch values from Properties file Properties properties; @@ -93,6 +100,12 @@ public void setValues() { this.setJsonInputString(properties.getProperty("jsonInputString")); + this.setCreateDeviceMethodName(properties.getProperty("createDeviceMethodName")); + this.setCreateDevicePathPart1(properties.getProperty("createDevicePathPart1")); + this.setCreateDevicePathPart2(properties.getProperty("createDevicePathPart2")); + this.setNumIds(properties.getProperty("numIds")); + this.setSubFolder(properties.getProperty("subFolder")); + this.setCreateDeviceInputString(properties.getProperty("createDeviceInputString")); } @@ -232,4 +245,53 @@ public void setSendCommandPathPart2(String sendCommandPathPart2) { this.sendCommandPathPart2 = sendCommandPathPart2; } + public String getCreateDeviceMethodName() { + return createDeviceMethodName; + } + + public void setCreateDeviceMethodName(String createDeviceMethodName) { + this.createDeviceMethodName = createDeviceMethodName; + } + + public String getCreateDevicePathPart1() { + return createDevicePathPart1; + } + + public void setCreateDevicePathPart1(String createDevicePathPart1) { + this.createDevicePathPart1 = createDevicePathPart1; + } + + public String getCreateDevicePathPart2() { + return createDevicePathPart2; + } + + public void setCreateDevicePathPart2(String createDevicePathPart2) { + this.createDevicePathPart2 = createDevicePathPart2; + } + + public String getNumIds() { + return numIds; + } + + public void setNumIds(String numIds) { + this.numIds = numIds; + } + + public String getSubFolder() { + return subFolder; + } + + public void setSubFolder(String subFolder) { + this.subFolder = subFolder; + } + + public String getCreateDeviceInputString() { + return createDeviceInputString; + } + + public void setCreateDeviceInputString(String createDeviceInputString) { + this.createDeviceInputString = createDeviceInputString; + } + + } diff --git a/clearblade-cloud-iot/src/main/java/com/clearblade/cloud/iot/v1/utils/Device.java b/clearblade-cloud-iot/src/main/java/com/clearblade/cloud/iot/v1/utils/Device.java new file mode 100644 index 00000000..509ebb77 --- /dev/null +++ b/clearblade-cloud-iot/src/main/java/com/clearblade/cloud/iot/v1/utils/Device.java @@ -0,0 +1,105 @@ +package com.clearblade.cloud.iot.v1.utils; + +import java.util.ArrayList; +import java.util.List; + +public class Device { + + private final String id; + private final String name; + private final List credentials; + private final int logLevel; + + public Device() { + id = ""; + name = ""; + credentials = new ArrayList<>(); + logLevel = 0; + } + + private Device(Builder builder) { + id = builder.getId(); + name = builder.getName(); + credentials = builder.getCredentials(); + logLevel = builder.getLogLevel(); + } + + + public static Builder newBuilder() { + return new Builder(); + } + + public Builder toBuilder() { + return new Builder(this); + } + + public static Device of(String id, String name, List credentials, int logLevel) { + return newBuilder().setId(id).setName(name).setCredentials(credentials).setLogLevel(logLevel).build(); + } + + public static String format(String id, String name, List credentials, int logLevel) { + return newBuilder().setId(id).setName(name).setCredentials(credentials).setLogLevel(logLevel).build() + .toString(); + } + + /** + * Builder for setting + * Device - id, name, credentials and logLevel + */ + public static class Builder { + private String id; + private String name; + private List credentials; + private int logLevel; + + protected Builder() { + } + + public String getId() { + return id; + } + + public String getName() { + return name; + } + + public List getCredentials() { + return credentials; + } + + public int getLogLevel() { + return logLevel; + } + + public Builder setId(String id) { + this.id = id; + return this; + } + + public Builder setName(String name) { + this.name = name; + return this; + } + + public Builder setCredentials(List credentials) { + this.credentials = credentials; + return this; + } + + public Builder setLogLevel(int logLevel) { + this.logLevel = logLevel; + return this; + } + + private Builder(Device device) { + this.id = device.id; + this.name = device.name; + this.credentials = device.credentials; + this.logLevel = device.logLevel; + } + + public Device build() { + return new Device(this); + } + } +} diff --git a/clearblade-cloud-iot/src/main/java/com/clearblade/cloud/iot/v1/utils/RegistryName.java b/clearblade-cloud-iot/src/main/java/com/clearblade/cloud/iot/v1/utils/RegistryName.java new file mode 100644 index 00000000..bdfbb393 --- /dev/null +++ b/clearblade-cloud-iot/src/main/java/com/clearblade/cloud/iot/v1/utils/RegistryName.java @@ -0,0 +1,100 @@ +package com.clearblade.cloud.iot.v1.utils; + +public class RegistryName { + + private final String project; + private final String location; + private final String registry; + + protected RegistryName() { + project = null; + location = null; + registry = null; + } + + private RegistryName(Builder builder) { + project = builder.getProject(); + location = builder.getLocation(); + registry = builder.getRegistry(); + } + + public String getProject() { + return project; + } + + public String getLocation() { + return location; + } + + public String getRegistry() { + return registry; + } + + public static Builder newBuilder() { + return new Builder(); + } + + public Builder toBuilder() { + return new Builder(this); + } + + public static RegistryName of(String project, String location, String registry) { + return newBuilder().setProject(project).setLocation(location).setRegistry(registry).build(); + } + + public static String format(String project, String location, String registry) { + return newBuilder().setProject(project).setLocation(location).setRegistry(registry).build() + .toString(); + } + + /** + * Builder for + * projects/{project}/locations/{location}/registries/{registry}. + */ + public static class Builder { + private String project; + private String location; + private String registry; + + protected Builder() { + } + + public String getProject() { + return project; + } + + public String getLocation() { + return location; + } + + public String getRegistry() { + return registry; + } + + public Builder setProject(String project) { + this.project = project; + return this; + } + + public Builder setLocation(String location) { + this.location = location; + return this; + } + + public Builder setRegistry(String registry) { + this.registry = registry; + return this; + } + + private Builder(RegistryName registryName) { + this.project = registryName.project; + this.location = registryName.location; + this.registry = registryName.registry; + } + + public RegistryName build() { + return new RegistryName(this); + } + } + +} diff --git a/clearblade-cloud-iot/src/main/java/config.properties b/clearblade-cloud-iot/src/main/java/config.properties index 2383b8a9..7a88ad92 100644 --- a/clearblade-cloud-iot/src/main/java/config.properties +++ b/clearblade-cloud-iot/src/main/java/config.properties @@ -21,4 +21,10 @@ sendCommandPathPart2=/cloudiot_devices jsonInputString={\"binaryData\": \"c2VuZEZ1bm55TWVzc2FnZVRvRGV2aWNl\"} +createDeviceMethodName=createDevice +createDevicePathPart1=/api/v/4/webhook/execute/ +createDevicePathPart2=/cloudiot_devices +numIds=113,114 +subFolder=789 +createDeviceInputString={\"id\": \"myOldDevice3\",\"name\": \"myOldDevice3\",\"numId\": 987,\"credentials\": [],\"lastErrorStatus\": {},\"config\": {},\"state\": {},\"logLevel\": \"NONE\",\"metadata\": {},\"gatewayConfig\": {}} diff --git a/clearblade-cloud-iot/src/test/java/com/clearblade/cloud/iot/v1/test/DeviceManagerClientTest.java b/clearblade-cloud-iot/src/test/java/com/clearblade/cloud/iot/v1/test/DeviceManagerClientTest.java index 9840fada..90c85b29 100644 --- a/clearblade-cloud-iot/src/test/java/com/clearblade/cloud/iot/v1/test/DeviceManagerClientTest.java +++ b/clearblade-cloud-iot/src/test/java/com/clearblade/cloud/iot/v1/test/DeviceManagerClientTest.java @@ -7,12 +7,16 @@ import org.junit.jupiter.api.Test; +import com.clearblade.cloud.iot.v1.CreateDeviceRequest; +import com.clearblade.cloud.iot.v1.CreateDeviceResponse; import com.clearblade.cloud.iot.v1.DeviceManagerClient; import com.clearblade.cloud.iot.v1.SendCommandToDeviceRequest; import com.clearblade.cloud.iot.v1.SendCommandToDeviceResponse; import com.clearblade.cloud.iot.v1.utils.ByteString; import com.clearblade.cloud.iot.v1.utils.Constants; +import com.clearblade.cloud.iot.v1.utils.Device; import com.clearblade.cloud.iot.v1.utils.DeviceName; +import com.clearblade.cloud.iot.v1.utils.RegistryName; class DeviceManagerClientTest { @@ -81,5 +85,31 @@ void testSendCommandToDeviceDeviceNameByteStringStringFail() { fail(msg); } } + + @Test + void testCreateDeviceRegistryNameDevice() { + init(); + int expectedResponse = 200; + String msg = ""; + RegistryName registryName = RegistryName.of(constants.getProject(), constants.getLocation(), + constants.getRegistry()); + CreateDeviceRequest request = CreateDeviceRequest.Builder.newBuilder().setParent(registryName.toString()) + .setDevice(Device.newBuilder().build()).build(); + CreateDeviceResponse actualResponse = client.createDevice(request); + if (actualResponse != null) { + actualResponse.processRequest(); + if(actualResponse.getHttpStatusCode() == expectedResponse) { + msg = "CreateDeviceTest execution is successful"; + log.log(Level.INFO, msg); + }else { + msg = "CreateDeviceTest failed"; + log.log(Level.WARNING,msg); + } + }else { + msg = "CreateDeviceTest failed"; + log.log(Level.SEVERE, msg); + fail(msg); + } + } } From d1e53d9c613524c0d85b9fa41c310d0be7ccc558 Mon Sep 17 00:00:00 2001 From: RashmiK14 Date: Mon, 31 Oct 2022 20:28:47 +0530 Subject: [PATCH 006/151] IOT_605 devicesCreate-endpoint regional This commit include changes related to Error Handling. --- .../iot/v1/AsyncSendCommandToDevice.java | 8 +-- .../cloud/iot/v1/SyncCreateDevice.java | 8 +-- .../cloud/iot/v1/SyncSendCommandToDevice.java | 8 +-- .../cloud/iot/v1/CreateDeviceResponse.java | 35 +++++-------- .../cloud/iot/v1/DeviceManagerClient.java | 2 +- .../cloud/iot/v1/ProcessRequest.java | 50 +++++++++++++------ .../iot/v1/SendCommandToDeviceResponse.java | 16 +++--- .../iot/v1/test/DeviceManagerClientTest.java | 12 ++--- 8 files changed, 75 insertions(+), 64 deletions(-) diff --git a/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/AsyncSendCommandToDevice.java b/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/AsyncSendCommandToDevice.java index b616609c..1dd58ed3 100644 --- a/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/AsyncSendCommandToDevice.java +++ b/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/AsyncSendCommandToDevice.java @@ -26,12 +26,12 @@ public static void asyncSendCommandToDevice() { SendCommandToDeviceResponse response = deviceManagerClient.sendCommandToDevice(request); if (response != null) { response.processRequest(); - if(response.getHttpStatusCode() == 200) { - msg = "AsyncSendCommandToDevice Method execution successful :: " + response.toString() + "\n HTTP RESPONSE IS :: Status Code : "+response.getHttpStatusCode() +" Status Message : " + response.getHttpStatusResponse(); + if(response.getHttpStatusResponse().equals("OK")) { + msg = "AsyncSendCommandToDevice Method worked successfully :: " + response.getHttpStatusResponse(); log.log(Level.INFO, msg); }else { - msg = "AsyncSendCommandToDevice Method execution failed :: " + response.toString() + "\n HTTP RESPONSE IS :: Status Code : "+response.getHttpStatusCode() +" Status Message : " + response.getHttpStatusResponse(); - log.log(Level.WARNING, msg); + msg = "AsyncSendCommandToDevice Method execution failed :: " + response.getHttpStatusResponse(); + log.log(Level.SEVERE, msg); } }else { msg = "AsyncSendCommandToDevice Method execution failed"; diff --git a/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/SyncCreateDevice.java b/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/SyncCreateDevice.java index 79c3404f..f7b48bcf 100644 --- a/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/SyncCreateDevice.java +++ b/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/SyncCreateDevice.java @@ -26,12 +26,12 @@ public static void syncCreateDevice() { CreateDeviceResponse response = deviceManagerClient.createDevice(request); if (response != null) { response.processRequest(); - if(response.getHttpStatusCode() == 200) { - msg = "SyncCreateDevice Method worked successfully :: " + response.toString() + "\n HTTP RESPONSE IS :: Status Code : "+response.getHttpStatusCode() +" Status Message : " + response.getHttpStatusResponse(); + if(response.getHttpStatusResponse().equals("OK")) { + msg = "SyncCreateDevice Method worked successfully :: " + response.getHttpStatusResponse(); log.log(Level.INFO, msg); }else { - msg = "SyncCreateDevice Method execution failed :: " + response.toString() + "\n HTTP RESPONSE IS :: Status Code : "+response.getHttpStatusCode() +" Status Message : " + response.getHttpStatusResponse(); - log.log(Level.WARNING, msg); + msg = "SyncCreateDevice Method execution failed :: " + response.getHttpStatusResponse(); + log.log(Level.SEVERE, msg); } }else { msg = "SyncCreateDevice Method execution failed"; diff --git a/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/SyncSendCommandToDevice.java b/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/SyncSendCommandToDevice.java index faccc833..a7e749c9 100644 --- a/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/SyncSendCommandToDevice.java +++ b/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/SyncSendCommandToDevice.java @@ -26,12 +26,12 @@ public static void syncSendCommandToDevice() { SendCommandToDeviceResponse response = deviceManagerClient.sendCommandToDevice(request); if (response != null) { response.processRequest(); - if(response.getHttpStatusCode() == 200) { - msg = "SyncSendCommandToDevice Method execution successful :: " + response.toString() + "\n HTTP RESPONSE IS :: Status Code : "+response.getHttpStatusCode() +" Status Message : " + response.getHttpStatusResponse(); + if(response.getHttpStatusResponse().equals("OK")) { + msg = "SyncSendCommandToDevice Method worked successfully :: " + response.getHttpStatusResponse(); log.log(Level.INFO, msg); }else { - msg = "SyncSendCommandToDevice Method execution failed :: " + response.toString() + "\n HTTP RESPONSE IS :: Status Code : "+response.getHttpStatusCode() +" Status Message : " + response.getHttpStatusResponse(); - log.log(Level.WARNING, msg); + msg = "SyncSendCommandToDevice Method execution failed :: " + response.getHttpStatusResponse(); + log.log(Level.SEVERE, msg); } }else { msg = "SyncSendCommandToDevice Method execution failed"; diff --git a/clearblade-cloud-iot/src/main/java/com/clearblade/cloud/iot/v1/CreateDeviceResponse.java b/clearblade-cloud-iot/src/main/java/com/clearblade/cloud/iot/v1/CreateDeviceResponse.java index 8e378a03..d29f8dd2 100644 --- a/clearblade-cloud-iot/src/main/java/com/clearblade/cloud/iot/v1/CreateDeviceResponse.java +++ b/clearblade-cloud-iot/src/main/java/com/clearblade/cloud/iot/v1/CreateDeviceResponse.java @@ -1,11 +1,10 @@ package com.clearblade.cloud.iot.v1; -import java.net.HttpURLConnection; import java.util.logging.Level; import java.util.logging.Logger; public class CreateDeviceResponse { - + static Logger log = Logger.getLogger(CreateDeviceResponse.class.getName()); private final CreateDeviceRequest request; private int httpStatusCode; @@ -56,34 +55,24 @@ public CreateDeviceResponse build() { return new CreateDeviceResponse(this); } } - + /** - * Mehtod used to process the request - * Calling processRequestForMethod - CreateDevice + * Mehtod used to process the request Calling processRequestForMethod - + * CreateDevice */ public void processRequest() { - + ProcessRequest processRequest = new ProcessRequest(); String msg = ""; - - int responseCode = processRequest.processRequestForMethod("createDevice"); - this.setHttpStatusCode(responseCode); - switch(responseCode) { - case HttpURLConnection.HTTP_BAD_REQUEST: - this.setHttpStatusResponse("HTTP_BAD_REQUEST"); - break; - case HttpURLConnection.HTTP_INTERNAL_ERROR: - this.setHttpStatusResponse("HTTP_INTERNAL_ERROR"); - break; - default: - this.setHttpStatusResponse("HTTP_OK"); - break; - } - if (responseCode == HttpURLConnection.HTTP_OK) { - msg = "Request processed for CreateDevice method.\n HTTP RESPONSE IS :: Status Code : "+this.getHttpStatusCode()+" Status Message : "+this.getHttpStatusResponse(); + String responseMessage = processRequest.processRequestForMethod("createDevice"); + this.setHttpStatusResponse(responseMessage); + if (responseMessage.equals("OK")) { + this.setHttpStatusCode(200); + msg = "Request processed for CreateDevice method"; log.log(Level.INFO, msg); } else { - msg = "Request is not processed for CreateDevice method.\n HTTP RESPONSE IS :: Status Code : "+this.getHttpStatusCode()+" Status Message : "+this.getHttpStatusResponse(); + this.setHttpStatusCode(0); + msg = "Request for CreateDevice failed \n" .concat(responseMessage); log.log(Level.SEVERE, msg); } } diff --git a/clearblade-cloud-iot/src/main/java/com/clearblade/cloud/iot/v1/DeviceManagerClient.java b/clearblade-cloud-iot/src/main/java/com/clearblade/cloud/iot/v1/DeviceManagerClient.java index 4dbb8865..b0b01e49 100644 --- a/clearblade-cloud-iot/src/main/java/com/clearblade/cloud/iot/v1/DeviceManagerClient.java +++ b/clearblade-cloud-iot/src/main/java/com/clearblade/cloud/iot/v1/DeviceManagerClient.java @@ -45,7 +45,7 @@ public SendCommandToDeviceResponse sendCommandToDevice(SendCommandToDeviceReques } /** - * Method used to call createDevice apicall + * Method used to call createDevice api call * * @param parent * @param device diff --git a/clearblade-cloud-iot/src/main/java/com/clearblade/cloud/iot/v1/ProcessRequest.java b/clearblade-cloud-iot/src/main/java/com/clearblade/cloud/iot/v1/ProcessRequest.java index b7ba3b2f..fc7b885e 100644 --- a/clearblade-cloud-iot/src/main/java/com/clearblade/cloud/iot/v1/ProcessRequest.java +++ b/clearblade-cloud-iot/src/main/java/com/clearblade/cloud/iot/v1/ProcessRequest.java @@ -1,6 +1,8 @@ package com.clearblade.cloud.iot.v1; +import java.io.BufferedReader; import java.io.IOException; +import java.io.InputStreamReader; import java.io.OutputStream; import java.net.MalformedURLException; import java.net.ProtocolException; @@ -17,6 +19,7 @@ public class ProcessRequest { Constants constants; URL obj; HttpsURLConnection con; + String responseMessage; int responseCode; String inputString; @@ -27,6 +30,7 @@ public ProcessRequest() { con = null; responseCode = 0; inputString = null; + responseMessage = null; } /** @@ -34,9 +38,9 @@ public ProcessRequest() { * are inputs ResponseCode - integer value is sent as return value * * @param methodName - * @return int - response code + * @return String - response message */ - public int processRequestForMethod(String methodName) { + public String processRequestForMethod(String methodName) { // https://iot-sandbox.clearblade.com:443/api/v/4/webhook/execute/fedbc9b40cde90befbd9b2dfde9d01/cloudiot_devices?name=Rashmi_Device_Test&method=sendCommandToDevice if (methodName.equals("sendCommandToDevice")) { @@ -49,7 +53,7 @@ public int processRequestForMethod(String methodName) { + constants.getSystemKey() + constants.getSendCommandPathPart2() + params); con = SetHttpConnection.getConnection(obj); // Calling setConnectionMethod - responseCode = setConnectionMethods(con, methodName); + responseMessage = setConnectionMethods(con, methodName); } catch (Exception e) { e.printStackTrace(); } @@ -65,19 +69,19 @@ public int processRequestForMethod(String methodName) { + constants.getSystemKey() + constants.getCreateDevicePathPart2() + params); con = SetHttpConnection.getConnection(obj); // Calling setConnectionMethod - responseCode = setConnectionMethods(con, methodName); + responseMessage = setConnectionMethods(con, methodName); } catch (Exception e) { e.printStackTrace(); } } - return responseCode; + return responseMessage; } /** * Set connection methods * @param con - * @returning response code + * @returning response message */ - public int setConnectionMethods(HttpsURLConnection con,String methodName) { + public String setConnectionMethods(HttpsURLConnection con,String methodName) { if (con != null) { try { con.setRequestMethod(constants.getHttpRequestMethodType()); @@ -97,31 +101,49 @@ public int setConnectionMethods(HttpsURLConnection con,String methodName) { // SetOutput to connection con.setDoOutput(true); // Get responseCode from Connection - responseCode = getResponse(con, inputString); + responseMessage = getResponse(con, inputString); } else { - responseCode = 0; + responseMessage = null; } - return responseCode; + return responseMessage; } /** * Method used to get Response when inputString and connection object are inputs - * ResponseCode - integer value is sent as return value + * ResponseMessage - String value is sent as return value * * @param con * @param inputString - * @return responseCode + * @return responseMessage */ - public int getResponse(HttpsURLConnection con, String inputString) { + public String getResponse(HttpsURLConnection con, String inputString) { try (OutputStream os = con.getOutputStream()) { + StringBuilder response = new StringBuilder(); byte[] input = inputString.getBytes(StandardCharsets.UTF_8); os.write(input, 0, input.length); responseCode = con.getResponseCode(); + if(responseCode != 200) { + BufferedReader in = null; + if(con.getErrorStream() != null) { + in = new BufferedReader(new InputStreamReader(con.getErrorStream())); + }else if(con.getInputStream() != null) { + in = new BufferedReader(new InputStreamReader(con.getInputStream())); + } + String inputLine; + if(in != null) { + while((inputLine = in.readLine()) != null) { + response.append(inputLine); + } + } + responseMessage = response.toString(); + }else if(responseCode == 200) { + responseMessage = "OK"; + } } catch (MalformedURLException e) { e.printStackTrace(); } catch (IOException e1) { e1.printStackTrace(); } - return responseCode; + return responseMessage; } } diff --git a/clearblade-cloud-iot/src/main/java/com/clearblade/cloud/iot/v1/SendCommandToDeviceResponse.java b/clearblade-cloud-iot/src/main/java/com/clearblade/cloud/iot/v1/SendCommandToDeviceResponse.java index 22d9c7a6..1a90287f 100644 --- a/clearblade-cloud-iot/src/main/java/com/clearblade/cloud/iot/v1/SendCommandToDeviceResponse.java +++ b/clearblade-cloud-iot/src/main/java/com/clearblade/cloud/iot/v1/SendCommandToDeviceResponse.java @@ -1,6 +1,5 @@ package com.clearblade.cloud.iot.v1; -import java.net.HttpURLConnection; import java.util.logging.Level; import java.util.logging.Logger; @@ -62,15 +61,16 @@ public SendCommandToDeviceResponse build() { * Calling processRequestForMethod - sendCommandToDevice */ public void processRequest() { - ProcessRequest processRequest = new ProcessRequest(); - int responseCode = processRequest.processRequestForMethod("sendCommandToDevice"); - this.setHttpStatusCode(responseCode); - if (responseCode == HttpURLConnection.HTTP_OK) { - this.setHttpStatusResponse("HTTP_OK"); - log.log(Level.INFO, "Request processed successfully for SendCommandToDevice method"); + String msg = ""; + String responseMessage = processRequest.processRequestForMethod("sendCommandToDevice"); + this.setHttpStatusResponse(responseMessage); + if (responseMessage.equals("OK")) { + msg = "Request processed successfully for SendCommandToDevice method"; + log.log(Level.INFO, msg); } else { - log.log(Level.SEVERE, "POST request not worked for sendCommandToDevice Method"); + msg = "POST request not worked for sendCommandToDevice Method \n".concat(responseMessage); + log.log(Level.SEVERE, msg); } } diff --git a/clearblade-cloud-iot/src/test/java/com/clearblade/cloud/iot/v1/test/DeviceManagerClientTest.java b/clearblade-cloud-iot/src/test/java/com/clearblade/cloud/iot/v1/test/DeviceManagerClientTest.java index 90c85b29..9e5e3a9a 100644 --- a/clearblade-cloud-iot/src/test/java/com/clearblade/cloud/iot/v1/test/DeviceManagerClientTest.java +++ b/clearblade-cloud-iot/src/test/java/com/clearblade/cloud/iot/v1/test/DeviceManagerClientTest.java @@ -32,7 +32,7 @@ void init() { @Test void testSendCommandToDeviceDeviceNameByteStringString() { init(); - int expectedResponse = 200; + String expectedResponse = "OK"; String msg = ""; DeviceName name = DeviceName.of(constants.getProject(), constants.getLocation(), constants.getRegistry(), @@ -44,7 +44,7 @@ void testSendCommandToDeviceDeviceNameByteStringString() { SendCommandToDeviceResponse actualResponse = client.sendCommandToDevice(request); if (actualResponse != null) { actualResponse.processRequest(); - if(actualResponse.getHttpStatusCode() == expectedResponse) { + if(actualResponse.getHttpStatusResponse().equals(expectedResponse)) { msg = "SendCommandToDeviceTest successfully executed"; log.log(Level.INFO, msg); }else { @@ -62,7 +62,7 @@ void testSendCommandToDeviceDeviceNameByteStringString() { @Test void testSendCommandToDeviceDeviceNameByteStringStringFail() { init(); - int expectedResponse = 200; + String expectedResponse = "OK"; String msg =""; DeviceName name = DeviceName.of("","","",""); ByteString binaryData = new ByteString(""); @@ -72,7 +72,7 @@ void testSendCommandToDeviceDeviceNameByteStringStringFail() { SendCommandToDeviceResponse actualResponse = client.sendCommandToDevice(request); if (actualResponse != null) { actualResponse.processRequest(); - if(actualResponse.getHttpStatusCode() != expectedResponse) { + if(actualResponse.getHttpStatusResponse().equals(expectedResponse)) { msg = "SendCommandToDeviceTest Failure Case is Successful"; log.log(Level.INFO, msg); }else { @@ -89,7 +89,7 @@ void testSendCommandToDeviceDeviceNameByteStringStringFail() { @Test void testCreateDeviceRegistryNameDevice() { init(); - int expectedResponse = 200; + String expectedResponse = "OK"; String msg = ""; RegistryName registryName = RegistryName.of(constants.getProject(), constants.getLocation(), constants.getRegistry()); @@ -98,7 +98,7 @@ void testCreateDeviceRegistryNameDevice() { CreateDeviceResponse actualResponse = client.createDevice(request); if (actualResponse != null) { actualResponse.processRequest(); - if(actualResponse.getHttpStatusCode() == expectedResponse) { + if(actualResponse.getHttpStatusResponse().equals(expectedResponse)) { msg = "CreateDeviceTest execution is successful"; log.log(Level.INFO, msg); }else { From c16d5b5e8970e78dbf992941a5c77415f7387d80 Mon Sep 17 00:00:00 2001 From: RashmiK14 Date: Wed, 2 Nov 2022 20:18:01 +0530 Subject: [PATCH 007/151] IOT_605-devicesCreate-endpoint regional Commit includes following - 1) Refactored code 2) Edited constants and config file 3) Added more samples to sendCommandToDevice and CreateDevice --- .../v1/createdevice/AsyncCreateDevice.java | 41 +++ .../{ => createdevice}/SyncCreateDevice.java | 17 +- .../AsyncSendCommandToDevice.java | 17 +- .../SyncSendCommandToDevice.java | 17 +- .../SyncSendCommandToDeviceDataEmpty.java | 40 +++ .../SyncSendCommandToDeviceDeviceName.java | 44 +++ .../SyncSendCommandToDeviceNoSubfolder.java | 39 +++ .../cloud/iot/v1/CreateDeviceRequest.java | 63 +++- .../cloud/iot/v1/CreateDeviceResponse.java | 11 +- .../cloud/iot/v1/DeviceManagerClient.java | 25 +- .../cloud/iot/v1/ProcessRequest.java | 205 ++++++++---- .../iot/v1/SendCommandToDeviceRequest.java | 39 ++- .../iot/v1/SendCommandToDeviceResponse.java | 5 +- .../cloud/iot/v1/utils/ByteString.java | 17 +- .../cloud/iot/v1/utils/ConfigParameters.java | 101 ++++++ .../cloud/iot/v1/utils/Constants.java | 302 +----------------- .../clearblade/cloud/iot/v1/utils/Device.java | 101 +++++- .../src/main/java/config.properties | 31 +- 18 files changed, 675 insertions(+), 440 deletions(-) create mode 100644 clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/createdevice/AsyncCreateDevice.java rename clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/{ => createdevice}/SyncCreateDevice.java (66%) rename clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/{ => sendcommandtodevice}/AsyncSendCommandToDevice.java (69%) rename clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/{ => sendcommandtodevice}/SyncSendCommandToDevice.java (70%) create mode 100644 clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/sendcommandtodevice/SyncSendCommandToDeviceDataEmpty.java create mode 100644 clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/sendcommandtodevice/SyncSendCommandToDeviceDeviceName.java create mode 100644 clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/sendcommandtodevice/SyncSendCommandToDeviceNoSubfolder.java create mode 100644 clearblade-cloud-iot/src/main/java/com/clearblade/cloud/iot/v1/utils/ConfigParameters.java diff --git a/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/createdevice/AsyncCreateDevice.java b/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/createdevice/AsyncCreateDevice.java new file mode 100644 index 00000000..d5902ade --- /dev/null +++ b/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/createdevice/AsyncCreateDevice.java @@ -0,0 +1,41 @@ +package com.clearblade.cloud.iot.v1.createdevice; + +import java.util.logging.Level; +import java.util.logging.Logger; + +import com.clearblade.cloud.iot.v1.CreateDeviceRequest; +import com.clearblade.cloud.iot.v1.CreateDeviceResponse; +import com.clearblade.cloud.iot.v1.DeviceManagerClient; +import com.clearblade.cloud.iot.v1.utils.Device; +import com.clearblade.cloud.iot.v1.utils.RegistryName; + +public class AsyncCreateDevice { + static Logger log = Logger.getLogger(AsyncCreateDevice.class.getName()); + + public static void main(String[] args) { + asyncCreateDevice(); + } + + public static void asyncCreateDevice() { + DeviceManagerClient deviceManagerClient = new DeviceManagerClient(); + String msg = ""; + String registryName = "Rashmi_Registry_Test"; + RegistryName registryNm = RegistryName.newBuilder().setRegistry(registryName).build(); + CreateDeviceRequest request = CreateDeviceRequest.Builder.newBuilder().setParent(registryNm) + .setDevice(Device.newBuilder().setId("NewAsyncDeviceTest").setName("NewAsyncDeviceTest").setNumId(79869).build()).build(); + CreateDeviceResponse response = deviceManagerClient.createDevice(request); + if (response != null) { + response.processRequest(request); + if(response.getHttpStatusResponse().equals("OK")) { + msg = "AsyncCreateDevice Method worked successfully :: " + response.getHttpStatusResponse(); + log.log(Level.INFO, msg); + }else { + msg = "AsyncCreateDevice Method execution failed :: " + response.getHttpStatusResponse(); + log.log(Level.SEVERE, msg); + } + }else { + msg = "AsyncCreateDevice Method execution failed"; + log.log(Level.SEVERE, msg); + } + } +} diff --git a/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/SyncCreateDevice.java b/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/createdevice/SyncCreateDevice.java similarity index 66% rename from clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/SyncCreateDevice.java rename to clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/createdevice/SyncCreateDevice.java index f7b48bcf..e51d7acd 100644 --- a/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/SyncCreateDevice.java +++ b/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/createdevice/SyncCreateDevice.java @@ -1,9 +1,11 @@ -package com.clearblade.cloud.iot.v1; +package com.clearblade.cloud.iot.v1.createdevice; import java.util.logging.Level; import java.util.logging.Logger; -import com.clearblade.cloud.iot.v1.utils.Constants; +import com.clearblade.cloud.iot.v1.CreateDeviceRequest; +import com.clearblade.cloud.iot.v1.CreateDeviceResponse; +import com.clearblade.cloud.iot.v1.DeviceManagerClient; import com.clearblade.cloud.iot.v1.utils.Device; import com.clearblade.cloud.iot.v1.utils.RegistryName; @@ -17,15 +19,14 @@ public static void main(String[] args) { public static void syncCreateDevice() { DeviceManagerClient deviceManagerClient = new DeviceManagerClient(); - Constants constants = new Constants(); String msg = ""; - RegistryName registryName = RegistryName.of(constants.getProject(), constants.getLocation(), - constants.getRegistry()); - CreateDeviceRequest request = CreateDeviceRequest.Builder.newBuilder().setParent(registryName.toString()) - .setDevice(Device.newBuilder().build()).build(); + String registryName = "Rashmi_Registry_Test"; + RegistryName registryNm = RegistryName.newBuilder().setRegistry(registryName).build(); + CreateDeviceRequest request = CreateDeviceRequest.Builder.newBuilder().setParent(registryNm) + .setDevice(Device.newBuilder().setId("SyncDeviceTest").setName("SyncDeviceTest").setNumId(69869).build()).build(); CreateDeviceResponse response = deviceManagerClient.createDevice(request); if (response != null) { - response.processRequest(); + response.processRequest(request); if(response.getHttpStatusResponse().equals("OK")) { msg = "SyncCreateDevice Method worked successfully :: " + response.getHttpStatusResponse(); log.log(Level.INFO, msg); diff --git a/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/AsyncSendCommandToDevice.java b/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/sendcommandtodevice/AsyncSendCommandToDevice.java similarity index 69% rename from clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/AsyncSendCommandToDevice.java rename to clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/sendcommandtodevice/AsyncSendCommandToDevice.java index 1dd58ed3..d0f3ccd5 100644 --- a/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/AsyncSendCommandToDevice.java +++ b/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/sendcommandtodevice/AsyncSendCommandToDevice.java @@ -1,11 +1,12 @@ -package com.clearblade.cloud.iot.v1; +package com.clearblade.cloud.iot.v1.sendcommandtodevice; import java.util.logging.Level; import java.util.logging.Logger; +import com.clearblade.cloud.iot.v1.DeviceManagerClient; +import com.clearblade.cloud.iot.v1.SendCommandToDeviceRequest; +import com.clearblade.cloud.iot.v1.SendCommandToDeviceResponse; import com.clearblade.cloud.iot.v1.utils.ByteString; -import com.clearblade.cloud.iot.v1.utils.Constants; -import com.clearblade.cloud.iot.v1.utils.DeviceName; public class AsyncSendCommandToDevice { @@ -17,15 +18,13 @@ public static void main(String[] args) { public static void asyncSendCommandToDevice() { DeviceManagerClient deviceManagerClient = new DeviceManagerClient(); - Constants constants = new Constants(); String msg = ""; - DeviceName name = DeviceName.of(constants.getProject(), constants.getLocation(), - constants.getRegistry(), constants.getDeviceName()); - SendCommandToDeviceRequest request = SendCommandToDeviceRequest.Builder.newBuilder().setName(name) - .setBinaryDataByte(ByteString.EMPTY).setSubFolder("subfolder153561774").build(); + String name = "Rashmi_Device_Test"; + SendCommandToDeviceRequest request = SendCommandToDeviceRequest.Builder.newBuilder().setDeviceName(name) + .setBinaryDataByte(ByteString.EMPTY).setSubfolder("subfolder1").build(); SendCommandToDeviceResponse response = deviceManagerClient.sendCommandToDevice(request); if (response != null) { - response.processRequest(); + response.processRequest(request); if(response.getHttpStatusResponse().equals("OK")) { msg = "AsyncSendCommandToDevice Method worked successfully :: " + response.getHttpStatusResponse(); log.log(Level.INFO, msg); diff --git a/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/SyncSendCommandToDevice.java b/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/sendcommandtodevice/SyncSendCommandToDevice.java similarity index 70% rename from clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/SyncSendCommandToDevice.java rename to clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/sendcommandtodevice/SyncSendCommandToDevice.java index a7e749c9..d3105fea 100644 --- a/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/SyncSendCommandToDevice.java +++ b/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/sendcommandtodevice/SyncSendCommandToDevice.java @@ -1,12 +1,13 @@ -package com.clearblade.cloud.iot.v1; +package com.clearblade.cloud.iot.v1.sendcommandtodevice; import java.util.logging.Level; import java.util.logging.Logger; +import com.clearblade.cloud.iot.v1.DeviceManagerClient; +import com.clearblade.cloud.iot.v1.SendCommandToDeviceRequest; +import com.clearblade.cloud.iot.v1.SendCommandToDeviceResponse; import com.clearblade.cloud.iot.v1.utils.ByteString; -import com.clearblade.cloud.iot.v1.utils.Constants; -import com.clearblade.cloud.iot.v1.utils.DeviceName; public class SyncSendCommandToDevice { @@ -17,15 +18,13 @@ public static void main(String[] args) { public static void syncSendCommandToDevice() { DeviceManagerClient deviceManagerClient = new DeviceManagerClient(); - Constants constants = new Constants(); String msg = ""; - com.clearblade.cloud.iot.v1.utils.DeviceName name = DeviceName.of(constants.getProject(), constants.getLocation(), - constants.getRegistry(), constants.getDeviceName()); - SendCommandToDeviceRequest request = SendCommandToDeviceRequest.Builder.newBuilder().setName(name) - .setBinaryData(new ByteString("c2VuZEZ1bm55TWVzc2FnZVRvRGV2aWNl")).setSubFolder("subfolder153561774").build(); + String name = "Rashmi_Device_Test"; + SendCommandToDeviceRequest request = SendCommandToDeviceRequest.Builder.newBuilder().setDeviceName(name) + .setBinaryData(new ByteString("c2VuZEZ1bm55TWVzc2FnZVRvRGV2aWNl")).setSubfolder("subfolder1").build(); SendCommandToDeviceResponse response = deviceManagerClient.sendCommandToDevice(request); if (response != null) { - response.processRequest(); + response.processRequest(request); if(response.getHttpStatusResponse().equals("OK")) { msg = "SyncSendCommandToDevice Method worked successfully :: " + response.getHttpStatusResponse(); log.log(Level.INFO, msg); diff --git a/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/sendcommandtodevice/SyncSendCommandToDeviceDataEmpty.java b/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/sendcommandtodevice/SyncSendCommandToDeviceDataEmpty.java new file mode 100644 index 00000000..097a1eef --- /dev/null +++ b/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/sendcommandtodevice/SyncSendCommandToDeviceDataEmpty.java @@ -0,0 +1,40 @@ +package com.clearblade.cloud.iot.v1.sendcommandtodevice; + +import java.util.logging.Level; +import java.util.logging.Logger; + +import com.clearblade.cloud.iot.v1.DeviceManagerClient; +import com.clearblade.cloud.iot.v1.SendCommandToDeviceRequest; +import com.clearblade.cloud.iot.v1.SendCommandToDeviceResponse; +import com.clearblade.cloud.iot.v1.utils.ByteString; + +public class SyncSendCommandToDeviceDataEmpty { + + static Logger log = Logger.getLogger(SyncSendCommandToDeviceDataEmpty.class.getName()); + public static void main(String[] args) { + syncSendCommandToDeviceDataEmpty(); + } + + public static void syncSendCommandToDeviceDataEmpty() { + DeviceManagerClient deviceManagerClient = new DeviceManagerClient(); + String msg = ""; + String name = "Rashmi_Device_Test"; + SendCommandToDeviceRequest request = SendCommandToDeviceRequest.Builder.newBuilder().setDeviceName(name) + .setBinaryDataByte(ByteString.EMPTY).setSubfolder("subfolder1").build(); + SendCommandToDeviceResponse response = deviceManagerClient.sendCommandToDevice(request); + if (response != null) { + response.processRequest(request); + if(response.getHttpStatusResponse().equals("OK")) { + msg = "syncSendCommandToDeviceDataEmpty Method worked successfully :: " + response.getHttpStatusResponse(); + log.log(Level.INFO, msg); + }else { + msg = "syncSendCommandToDeviceDataEmpty Method execution failed :: " + response.getHttpStatusResponse(); + log.log(Level.SEVERE, msg); + } + }else { + msg = "syncSendCommandToDeviceDataEmpty Method execution failed"; + log.log(Level.SEVERE, msg); + } + } + +} diff --git a/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/sendcommandtodevice/SyncSendCommandToDeviceDeviceName.java b/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/sendcommandtodevice/SyncSendCommandToDeviceDeviceName.java new file mode 100644 index 00000000..0d525326 --- /dev/null +++ b/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/sendcommandtodevice/SyncSendCommandToDeviceDeviceName.java @@ -0,0 +1,44 @@ +package com.clearblade.cloud.iot.v1.sendcommandtodevice; + +import java.util.logging.Level; +import java.util.logging.Logger; + +import com.clearblade.cloud.iot.v1.DeviceManagerClient; +import com.clearblade.cloud.iot.v1.SendCommandToDeviceRequest; +import com.clearblade.cloud.iot.v1.SendCommandToDeviceResponse; +import com.clearblade.cloud.iot.v1.utils.ByteString; +import com.clearblade.cloud.iot.v1.utils.DeviceName; + +public class SyncSendCommandToDeviceDeviceName { + static Logger log = Logger.getLogger(SyncSendCommandToDeviceDeviceName.class.getName()); + public static void main(String[] args) { + syncSendCommandToDeviceDeviceName(); + } + + public static void syncSendCommandToDeviceDeviceName() { + DeviceManagerClient deviceManagerClient = new DeviceManagerClient(); + String msg = ""; + String project = "ingressdevelopmentenv"; + String location = "central1"; + String registry = "Rashmi_Registry_Test"; + String name = "Rashmi_Device_Test"; + DeviceName deviceName = DeviceName.of(project, location, registry, name); + SendCommandToDeviceRequest request = SendCommandToDeviceRequest.Builder.newBuilder().setName(deviceName) + .setBinaryData(new ByteString("c2VuZEZ1bm55TWVzc2FnZVRvRGV2aWNl")).setSubfolder("subfolder1").build(); + SendCommandToDeviceResponse response = deviceManagerClient.sendCommandToDevice(request); + if (response != null) { + response.processRequest(request); + if(response.getHttpStatusResponse().equals("OK")) { + msg = "SyncSendCommandToDeviceDeviceName Method worked successfully :: " + response.getHttpStatusResponse(); + log.log(Level.INFO, msg); + }else { + msg = "SyncSendCommandToDeviceDeviceName Method execution failed :: " + response.getHttpStatusResponse(); + log.log(Level.SEVERE, msg); + } + }else { + msg = "SyncSendCommandToDeviceDeviceName Method execution failed"; + log.log(Level.SEVERE, msg); + } + } + +} diff --git a/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/sendcommandtodevice/SyncSendCommandToDeviceNoSubfolder.java b/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/sendcommandtodevice/SyncSendCommandToDeviceNoSubfolder.java new file mode 100644 index 00000000..c81f7b8a --- /dev/null +++ b/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/sendcommandtodevice/SyncSendCommandToDeviceNoSubfolder.java @@ -0,0 +1,39 @@ +package com.clearblade.cloud.iot.v1.sendcommandtodevice; + +import java.util.logging.Level; +import java.util.logging.Logger; + +import com.clearblade.cloud.iot.v1.DeviceManagerClient; +import com.clearblade.cloud.iot.v1.SendCommandToDeviceRequest; +import com.clearblade.cloud.iot.v1.SendCommandToDeviceResponse; +import com.clearblade.cloud.iot.v1.utils.ByteString; + +public class SyncSendCommandToDeviceNoSubfolder { + static Logger log = Logger.getLogger(SyncSendCommandToDeviceNoSubfolder.class.getName()); + public static void main(String[] args) { + syncSendCommandToDeviceNoSubfolder(); + } + + public static void syncSendCommandToDeviceNoSubfolder() { + DeviceManagerClient deviceManagerClient = new DeviceManagerClient(); + String msg = ""; + String name = "Rashmi_Device_Test"; + SendCommandToDeviceRequest request = SendCommandToDeviceRequest.Builder.newBuilder().setDeviceName(name) + .setBinaryDataByte(ByteString.EMPTY).build(); + SendCommandToDeviceResponse response = deviceManagerClient.sendCommandToDevice(request); + if (response != null) { + response.processRequest(request); + if(response.getHttpStatusResponse().equals("OK")) { + msg = "SyncSendCommandToDeviceNoSubfolder Method worked successfully :: " + response.getHttpStatusResponse(); + log.log(Level.INFO, msg); + }else { + msg = "SyncSendCommandToDeviceNoSubfolder Method execution failed :: " + response.getHttpStatusResponse(); + log.log(Level.SEVERE, msg); + } + }else { + msg = "SyncSendCommandToDeviceNoSubfolder Method execution failed"; + log.log(Level.SEVERE, msg); + } + } + +} diff --git a/clearblade-cloud-iot/src/main/java/com/clearblade/cloud/iot/v1/CreateDeviceRequest.java b/clearblade-cloud-iot/src/main/java/com/clearblade/cloud/iot/v1/CreateDeviceRequest.java index 2118c851..0623eb75 100644 --- a/clearblade-cloud-iot/src/main/java/com/clearblade/cloud/iot/v1/CreateDeviceRequest.java +++ b/clearblade-cloud-iot/src/main/java/com/clearblade/cloud/iot/v1/CreateDeviceRequest.java @@ -1,22 +1,31 @@ package com.clearblade.cloud.iot.v1; +import java.util.Arrays; + import com.clearblade.cloud.iot.v1.utils.Device; +import com.clearblade.cloud.iot.v1.utils.RegistryName; public class CreateDeviceRequest { - private final String parent; + private final RegistryName parent; private final Device device; + private final String subfolder; + private String deviceId; + private String deviceName; + private int deviceNumId; private CreateDeviceRequest(Builder builder) { this.parent = builder.parent; this.device = builder.device; + this.subfolder = builder.subfolder; } // Static class Builder public static class Builder { /// instance fields - private String parent; + private RegistryName parent; private Device device; + private String subfolder; public static Builder newBuilder() { return new Builder(); @@ -26,7 +35,7 @@ private Builder() { } // Setter methods - public Builder setParent(String parent) { + public Builder setParent(RegistryName parent) { this.parent = parent; return this; } @@ -36,6 +45,11 @@ public Builder setDevice(Device device) { return this; } + public Builder setSubfolder(String subfolder) { + this.subfolder = subfolder; + return this; + } + // build method to deal with outer class // to return outer instance public CreateDeviceRequest build() { @@ -45,6 +59,47 @@ public CreateDeviceRequest build() { @Override public String toString() { - return "parent = " + this.parent + ", device = " + this.device.toString(); + String str = ""; + if(parent != null) { + str = str.concat("parent ="+parent.getRegistry()); + } + if(device != null) { + this.setDeviceId(this.device.toBuilder().getId()); + this.setDeviceName(this.device.toBuilder().getName()); + this.setDeviceNumId(this.device.toBuilder().getNumId()); + str = str.concat(",id="+this.getDeviceId()+",name="+this.getDeviceName()+",numId="+this.getDeviceNumId()); + }else { + str = str.concat(",device =EMPTY"); + } + if(subfolder != null) { + str = str.concat(",subfolder ="+subfolder); + }else { + str = str.concat(",subfolder =EMPTY"); + } + return str; + } + + public String getDeviceId() { + return deviceId; + } + + public void setDeviceId(String deviceId) { + this.deviceId = deviceId; + } + + public String getDeviceName() { + return deviceName; + } + + public void setDeviceName(String deviceName) { + this.deviceName = deviceName; + } + + public int getDeviceNumId() { + return deviceNumId; + } + + public void setDeviceNumId(int deviceNumId) { + this.deviceNumId = deviceNumId; } } diff --git a/clearblade-cloud-iot/src/main/java/com/clearblade/cloud/iot/v1/CreateDeviceResponse.java b/clearblade-cloud-iot/src/main/java/com/clearblade/cloud/iot/v1/CreateDeviceResponse.java index d29f8dd2..9d7e712a 100644 --- a/clearblade-cloud-iot/src/main/java/com/clearblade/cloud/iot/v1/CreateDeviceResponse.java +++ b/clearblade-cloud-iot/src/main/java/com/clearblade/cloud/iot/v1/CreateDeviceResponse.java @@ -3,6 +3,8 @@ import java.util.logging.Level; import java.util.logging.Logger; +import com.clearblade.cloud.iot.v1.SendCommandToDeviceResponse.Builder; + public class CreateDeviceResponse { static Logger log = Logger.getLogger(CreateDeviceResponse.class.getName()); @@ -39,7 +41,7 @@ public static class Builder { public static Builder newBuilder() { return new Builder(); } - + private Builder() { } @@ -60,12 +62,13 @@ public CreateDeviceResponse build() { * Mehtod used to process the request Calling processRequestForMethod - * CreateDevice */ - public void processRequest() { + public void processRequest(CreateDeviceRequest request) { ProcessRequest processRequest = new ProcessRequest(); String msg = ""; - String responseMessage = processRequest.processRequestForMethod("createDevice"); - this.setHttpStatusResponse(responseMessage); + String[] requestParamsArray = request.toString().split(","); + String responseMessage = processRequest.processRequestForMethod("createDevice",requestParamsArray); + this.setHttpStatusResponse(responseMessage); if (responseMessage.equals("OK")) { this.setHttpStatusCode(200); msg = "Request processed for CreateDevice method"; diff --git a/clearblade-cloud-iot/src/main/java/com/clearblade/cloud/iot/v1/DeviceManagerClient.java b/clearblade-cloud-iot/src/main/java/com/clearblade/cloud/iot/v1/DeviceManagerClient.java index b0b01e49..fb7a2288 100644 --- a/clearblade-cloud-iot/src/main/java/com/clearblade/cloud/iot/v1/DeviceManagerClient.java +++ b/clearblade-cloud-iot/src/main/java/com/clearblade/cloud/iot/v1/DeviceManagerClient.java @@ -1,24 +1,10 @@ package com.clearblade.cloud.iot.v1; -import com.clearblade.cloud.iot.v1.utils.Constants; import com.clearblade.cloud.iot.v1.utils.Device; import com.clearblade.cloud.iot.v1.utils.DeviceName; import com.clearblade.cloud.iot.v1.utils.RegistryName; public class DeviceManagerClient { - Constants constants = null; - - public DeviceManagerClient() { - init(); - } - - /** - * Initialise the Constants object This method will set details like project, - * location, registry, device - */ - public void init() { - constants = new Constants(); - } /** * SendCommandToDevice method @@ -27,11 +13,12 @@ public void init() { * @param binaryData */ public void sendCommandToDevice(DeviceName name, com.clearblade.cloud.iot.v1.utils.ByteString binaryData, - String subFolder) { + String subfolder) { SendCommandToDeviceRequest request = SendCommandToDeviceRequest.Builder.newBuilder().setName(name) - .setBinaryData(binaryData).setSubFolder(subFolder).build(); + .setBinaryData(binaryData).setSubfolder(subfolder).build(); + this.sendCommandToDevice(request); SendCommandToDeviceResponse response = this.sendCommandToDevice(request); - response.processRequest(); + response.processRequest(request); } /** @@ -53,9 +40,9 @@ public SendCommandToDeviceResponse sendCommandToDevice(SendCommandToDeviceReques */ public void createDevice(RegistryName parent, Device device) { CreateDeviceRequest request = CreateDeviceRequest.Builder.newBuilder() - .setParent(parent == null ? null : parent.toString()).setDevice(device).build(); + .setParent(parent == null ? null : parent).setDevice(device).build(); CreateDeviceResponse response = this.createDevice(request); - response.processRequest(); + response.processRequest(request); } /** diff --git a/clearblade-cloud-iot/src/main/java/com/clearblade/cloud/iot/v1/ProcessRequest.java b/clearblade-cloud-iot/src/main/java/com/clearblade/cloud/iot/v1/ProcessRequest.java index fc7b885e..ec92ee4c 100644 --- a/clearblade-cloud-iot/src/main/java/com/clearblade/cloud/iot/v1/ProcessRequest.java +++ b/clearblade-cloud-iot/src/main/java/com/clearblade/cloud/iot/v1/ProcessRequest.java @@ -7,30 +7,120 @@ import java.net.MalformedURLException; import java.net.ProtocolException; import java.net.URL; -import java.nio.charset.StandardCharsets; +import java.nio.charset.Charset; import javax.net.ssl.HttpsURLConnection; +import com.clearblade.cloud.iot.v1.utils.ConfigParameters; import com.clearblade.cloud.iot.v1.utils.Constants; import com.clearblade.cloud.iot.v1.utils.SetHttpConnection; public class ProcessRequest { - Constants constants; URL obj; HttpsURLConnection con; String responseMessage; int responseCode; + String jsonInputString; + String subfolderStr; String inputString; + String deviceId; + String deviceName; + String deviceNumId; + String bodyParams; + ConfigParameters configParameters; // Empty Constructor public ProcessRequest() { - constants = new Constants(); + configParameters = new ConfigParameters(); obj = null; con = null; responseCode = 0; inputString = null; responseMessage = null; + jsonInputString = null; + subfolderStr = null; + deviceId = null; + deviceName = null; + deviceNumId = null; + } + + public String setRequestBodyParams(String methodName, String[] requestParamsArray) { + String requestParams = ""; + String bodyParamsStr = "{"; + if (methodName.equals(Constants.SEND_COMMAND_TO_DEVICE)) { + if (requestParamsArray != null) { + for (int i = 0; i < requestParamsArray.length; i++) { + String element = requestParamsArray[i]; + if (element.contains("name") || element.contains("deviceName")) { + String subStr = element.substring(element.indexOf("=") + 1, element.length()).trim(); + requestParams = requestParams.concat(subStr); + } else { + if (element.contains("binaryData") || element.contains("binaryDataByte")) { + String subStr = element.substring(element.indexOf("=") + 1, element.length()).trim(); + if(subStr.equals("EMPTY")) { + bodyParamsStr = bodyParamsStr.concat("binaryData:\"\""); + }else { + bodyParamsStr = bodyParamsStr.concat("binaryData:" + subStr); + } + } + if (element.contains(Constants.SUBFOLDER)) { + subfolderStr = element.substring(element.indexOf("=") + 1, element.length()).trim(); + bodyParamsStr = bodyParamsStr.concat(",subfolder:\"" + subfolderStr+"\""); + } + } + } + bodyParamsStr = bodyParamsStr.concat("}"); + this.setBodyParams(bodyParamsStr); + + } + } else if (methodName.equals(Constants.CREATE_DEVICE)) { + String bodyStr2 = ""; + if (requestParamsArray != null) { + for (String element : requestParamsArray) { + + if (element.contains("parent")) { + requestParams = requestParams.concat("112,113"); + } + if (element.contains("id")) { + deviceId = element.substring(element.indexOf("=") + 1, element.length()).trim(); + bodyStr2 = bodyStr2.concat("{\"id\":\"" + deviceId+"\""); + } + if (element.contains("name")) { + deviceName = element.substring(element.indexOf("=") + 1, element.length()).trim(); + bodyStr2 = bodyStr2.concat(",\"name\":\"" + deviceName+"\""); + } + if (element.contains("numId")) { + deviceNumId = element.substring(element.indexOf("=") + 1, element.length()).trim(); + bodyStr2 = bodyStr2.concat(",\"numId\":" + deviceNumId); + } + if (element.contains("subfolder")) { + subfolderStr = element.substring(element.indexOf("=") + 1, element.length()).trim(); + if(subfolderStr.equals("EMPTY")) { + bodyStr2 = bodyStr2.concat(",\"subfolder\":\"\""); + }else { + bodyStr2 = bodyStr2.concat(",\"subfolder\":" + subfolderStr); + } + System.out.println(bodyStr2); + } + } + bodyStr2 = bodyStr2.concat(", \"credentials\":[]"); + bodyStr2 = bodyStr2.concat(", \"lastErrorStatus\":{}"); + bodyStr2 = bodyStr2.concat(", \"config\":{}"); + bodyStr2 = bodyStr2.concat(", \"state\":{}"); + bodyStr2 = bodyStr2.concat(", \"logLevel\":\"NONE\""); + bodyStr2 = bodyStr2.concat(", \"metadata\":{}"); + bodyStr2 = bodyStr2.concat(", \"gatewayConfig\":{}"); + bodyStr2 = bodyStr2.concat("}"); + + if (bodyStr2 != null) { + this.setBodyParams(bodyStr2); + } + System.out.println(requestParams); + System.out.println(bodyStr2); + } + } + return requestParams; } /** @@ -40,40 +130,32 @@ public ProcessRequest() { * @param methodName * @return String - response message */ - public String processRequestForMethod(String methodName) { - // https://iot-sandbox.clearblade.com:443/api/v/4/webhook/execute/fedbc9b40cde90befbd9b2dfde9d01/cloudiot_devices?name=Rashmi_Device_Test&method=sendCommandToDevice - if (methodName.equals("sendCommandToDevice")) { - - String name = constants.getDeviceName(); - String params = "?name=" + name + "&method=" + methodName; - - try { - obj = new URL( - constants.getHttpURLBegin() + constants.getEndPoint() + constants.getSendCommandPathPart1() - + constants.getSystemKey() + constants.getSendCommandPathPart2() + params); - con = SetHttpConnection.getConnection(obj); - // Calling setConnectionMethod - responseMessage = setConnectionMethods(con, methodName); - } catch (Exception e) { - e.printStackTrace(); - } - } else if (methodName.equals("createDevice")) { - // https://iot-sandbox.clearblade.com/api/v/4/webhook/execute/fedbc9b40cde90befbd9b2dfde9d01/cloudiot_devices?deviceNumIds=124,666&subfolder=775 - String deviceNumIds = constants.getNumIds(); - String subfolder = constants.getSubFolder(); - String params = "?deviceNumIds=" + deviceNumIds + "&subfolder=" + subfolder; - - try { - obj = new URL( - constants.getHttpURLBegin() + constants.getEndPoint() + constants.getCreateDevicePathPart1() - + constants.getSystemKey() + constants.getCreateDevicePathPart2() + params); - con = SetHttpConnection.getConnection(obj); - // Calling setConnectionMethod - responseMessage = setConnectionMethods(con, methodName); - } catch (Exception e) { - e.printStackTrace(); - } + // https://iot-sandbox.clearblade.com:443/api/v/4/webhook/execute/fedbc9b40cde90befbd9b2dfde9d01/cloudiot_devices?name=Rashmi_Device_Test&method=sendCommandToDevice + public String processRequestForMethod(String methodName, String[] requestParamsArray) { + + // Setting up request params and body params + String requestParams = setRequestBodyParams(methodName, requestParamsArray); + String URLPartial = ""; + // Setting partial URL + URLPartial = URLPartial.concat(Constants.HTTPS_URL_PREFIX).concat(configParameters.getEndPoint()) + .concat(configParameters.getBaseURL()).concat(configParameters.getSystemKey()) + .concat(configParameters.getDevicesURLExtension()); + + String finalURL = ""; + if (methodName.equals(Constants.SEND_COMMAND_TO_DEVICE)) { + finalURL = URLPartial.concat("?name=" + requestParams + "&method=" + methodName); + } else if (methodName.equals(Constants.CREATE_DEVICE)) { + finalURL = URLPartial.concat("?deviceNumIds=" + requestParams + "&subfolder=" + subfolderStr); } + try { + obj = new URL(finalURL); + con = SetHttpConnection.getConnection(obj); + // Calling setConnectionMethod + responseMessage = setConnectionMethods(con, methodName); + } catch (Exception e) { + e.printStackTrace(); + } + return responseMessage; } /** @@ -83,25 +165,27 @@ public String processRequestForMethod(String methodName) { */ public String setConnectionMethods(HttpsURLConnection con,String methodName) { if (con != null) { - try { - con.setRequestMethod(constants.getHttpRequestMethodType()); - } catch (ProtocolException e) { - e.printStackTrace(); - } - con.setRequestProperty(constants.getHttpRequestPropertyTokenKey(), constants.getToken()); - con.setRequestProperty(constants.getHttpRequestPropertyContentTypeKey(), - constants.getHttpRequestPropertyContentTypeOrAcceptValue()); - con.addRequestProperty(constants.getHttpRequestPropertyAcceptKey(), - constants.getHttpRequestPropertyContentTypeOrAcceptValue()); - if(methodName.equals("sendCommandToDevice")){ - inputString = constants.getJsonInputString(); - }else if (methodName.equals("createDevice")) { - inputString = constants.getCreateDeviceInputString(); + + con.setRequestProperty(Constants.HTTP_REQUEST_PROPERTY_TOKEN_KEY, configParameters.getToken()); + con.setRequestProperty(Constants.HTTP_REQUEST_PROPERTY_CONTENT_TYPE_KEY, + Constants.HTTP_REQUEST_PROPERTY_CONTENT_TYPE_ACCEPT_VALUE); + con.addRequestProperty(Constants.HTTP_REQUEST_PROPERTY_ACCEPT_KEY, + Constants.HTTP_REQUEST_PROPERTY_CONTENT_TYPE_ACCEPT_VALUE); + + if ((methodName.equals(Constants.SEND_COMMAND_TO_DEVICE) || methodName.equals(Constants.CREATE_DEVICE))) { + + try { + con.setRequestMethod(Constants.HTTP_REQUEST_METHOD_TYPE_POST); + } catch (ProtocolException e) { + e.printStackTrace(); + } + + // SetOutput to connection + con.setDoOutput(true); + + // Get responseCode from Connection + responseMessage = getResponse(con, this.getBodyParams()); } - // SetOutput to connection - con.setDoOutput(true); - // Get responseCode from Connection - responseMessage = getResponse(con, inputString); } else { responseMessage = null; } @@ -116,10 +200,10 @@ public String setConnectionMethods(HttpsURLConnection con,String methodName) { * @param inputString * @return responseMessage */ - public String getResponse(HttpsURLConnection con, String inputString) { + public String getResponse(HttpsURLConnection con, String bodyData) { try (OutputStream os = con.getOutputStream()) { StringBuilder response = new StringBuilder(); - byte[] input = inputString.getBytes(StandardCharsets.UTF_8); + byte[] input = bodyData.getBytes("utf-8"); os.write(input, 0, input.length); responseCode = con.getResponseCode(); if(responseCode != 200) { @@ -146,4 +230,13 @@ public String getResponse(HttpsURLConnection con, String inputString) { } return responseMessage; } + + public String getBodyParams() { + return bodyParams; + } + + public void setBodyParams(String bodyParams) { + this.bodyParams = bodyParams; + } + } diff --git a/clearblade-cloud-iot/src/main/java/com/clearblade/cloud/iot/v1/SendCommandToDeviceRequest.java b/clearblade-cloud-iot/src/main/java/com/clearblade/cloud/iot/v1/SendCommandToDeviceRequest.java index ceb33a02..7506306e 100644 --- a/clearblade-cloud-iot/src/main/java/com/clearblade/cloud/iot/v1/SendCommandToDeviceRequest.java +++ b/clearblade-cloud-iot/src/main/java/com/clearblade/cloud/iot/v1/SendCommandToDeviceRequest.java @@ -10,13 +10,15 @@ public class SendCommandToDeviceRequest { private final DeviceName name; private final ByteString binaryData; private final byte[] binaryDataByte; - private final String subFolder; + private final String subfolder; + private final String deviceName; private SendCommandToDeviceRequest(Builder builder) { this.name = builder.name; this.binaryData = builder.binaryData; - this.subFolder = builder.subFolder; + this.subfolder = builder.subfolder; this.binaryDataByte = builder.binaryDataByte; + this.deviceName = builder.deviceName; } // Static class Builder @@ -25,8 +27,9 @@ public static class Builder { /// instance fields private DeviceName name; private ByteString binaryData; - private String subFolder; + private String subfolder; private byte[] binaryDataByte; + private String deviceName; public static Builder newBuilder() { return new Builder(); @@ -51,11 +54,16 @@ public Builder setBinaryDataByte(byte[] binaryDataByte) { return this; } - public Builder setSubFolder(String subFolder) { - this.subFolder = subFolder; + public Builder setSubfolder(String subfolder) { + this.subfolder = subfolder; return this; } + public Builder setDeviceName(String deviceName) { + this.deviceName = deviceName; + return this; + } + // build method to deal with outer class // to return outer instance public SendCommandToDeviceRequest build() { @@ -65,6 +73,25 @@ public SendCommandToDeviceRequest build() { @Override public String toString() { - return "name = " + this.name.getDevice() + ", binaryData = " + this.binaryData+ ", subFolder = "+this.subFolder+ ", binaryDataByte = "+Arrays.toString(this.binaryDataByte); + String requestParams=""; + String bodyParams=""; + if(this.name != null) { + requestParams = requestParams.concat("name = " + this.name.getDevice()); + }else if(this.deviceName != null) { + requestParams = requestParams.concat("deviceName = "+this.deviceName); + } + if(this.binaryData != null) { + bodyParams = bodyParams.concat(",binaryData="); + bodyParams = bodyParams.concat(new String(this.binaryData.getBinaryDataArray())); + }else if(this.binaryDataByte != null) { + if(this.binaryDataByte.length == 0){ + bodyParams = bodyParams.concat(",binaryDataByte=EMPTY"); + }else { + bodyParams = bodyParams.concat(",binaryDataByte="+Arrays.toString(this.binaryDataByte)); + } + } + bodyParams = bodyParams.concat(",subfolder = "+this.subfolder); + + return requestParams.concat(bodyParams); } } diff --git a/clearblade-cloud-iot/src/main/java/com/clearblade/cloud/iot/v1/SendCommandToDeviceResponse.java b/clearblade-cloud-iot/src/main/java/com/clearblade/cloud/iot/v1/SendCommandToDeviceResponse.java index 1a90287f..0eb4e46b 100644 --- a/clearblade-cloud-iot/src/main/java/com/clearblade/cloud/iot/v1/SendCommandToDeviceResponse.java +++ b/clearblade-cloud-iot/src/main/java/com/clearblade/cloud/iot/v1/SendCommandToDeviceResponse.java @@ -60,10 +60,11 @@ public SendCommandToDeviceResponse build() { * Mehtod used to process the request * Calling processRequestForMethod - sendCommandToDevice */ - public void processRequest() { + public void processRequest(SendCommandToDeviceRequest request) { ProcessRequest processRequest = new ProcessRequest(); String msg = ""; - String responseMessage = processRequest.processRequestForMethod("sendCommandToDevice"); + String[] requestParamsArray = request.toString().split(","); + String responseMessage = processRequest.processRequestForMethod("sendCommandToDevice",requestParamsArray); this.setHttpStatusResponse(responseMessage); if (responseMessage.equals("OK")) { msg = "Request processed successfully for SendCommandToDevice method"; diff --git a/clearblade-cloud-iot/src/main/java/com/clearblade/cloud/iot/v1/utils/ByteString.java b/clearblade-cloud-iot/src/main/java/com/clearblade/cloud/iot/v1/utils/ByteString.java index 6cd026f7..8270a7ae 100644 --- a/clearblade-cloud-iot/src/main/java/com/clearblade/cloud/iot/v1/utils/ByteString.java +++ b/clearblade-cloud-iot/src/main/java/com/clearblade/cloud/iot/v1/utils/ByteString.java @@ -1,15 +1,14 @@ package com.clearblade.cloud.iot.v1.utils; -import java.nio.charset.StandardCharsets; - public class ByteString { + private String binaryDataStr; private ByteString binaryData; private byte[] binaryDataArray; public static final byte[] EMPTY = new byte[0]; - public ByteString(String str) { - this.setBinaryDataArray(str.getBytes(StandardCharsets.UTF_8)); + public ByteString(String str) { + this.setBinaryDataArray(str.getBytes()); } public ByteString getBinaryData() { @@ -28,4 +27,14 @@ public void setBinaryDataArray(byte[] binaryDataArray) { this.binaryDataArray = binaryDataArray; } + public String getBinaryDataStr() { + return binaryDataStr; + } + + public void setBinaryDataStr(String binaryDataStr) { + this.binaryDataStr = binaryDataStr; + } + + + } diff --git a/clearblade-cloud-iot/src/main/java/com/clearblade/cloud/iot/v1/utils/ConfigParameters.java b/clearblade-cloud-iot/src/main/java/com/clearblade/cloud/iot/v1/utils/ConfigParameters.java new file mode 100644 index 00000000..a56439bc --- /dev/null +++ b/clearblade-cloud-iot/src/main/java/com/clearblade/cloud/iot/v1/utils/ConfigParameters.java @@ -0,0 +1,101 @@ +package com.clearblade.cloud.iot.v1.utils; + +import java.io.IOException; +import java.io.InputStream; +import java.util.Properties; + +public class ConfigParameters { + // Fields used to set values from properties file + private String endPoint; + private String systemKey; + private String token; + private String baseURL; + private String devicesURLExtension; + + // Fields used to fetch values from Properties file + Properties properties; + InputStream input; + + public ConfigParameters() { + properties = null; + input = null; + setValues(); + } + + /** + * Method used to read values form config.properties file and setting in field + * setters + */ + public void getConfigurations() { + // Read inputs from properties file + properties = new Properties(); + input = getClass().getClassLoader().getResourceAsStream("config.properties"); + try { + properties.load(input); + } catch (IOException ex) { + ex.printStackTrace(); + } finally { + if (input != null) { + try { + input.close(); + } catch (IOException e) { + e.printStackTrace(); + } + } + } + } + + /** + * Method used to set values in Constants setter method + */ + public void setValues() { + //get Configurations uploaded from config.properties file + getConfigurations(); + this.setEndPoint(properties.getProperty("endPoint")); + this.setSystemKey(properties.getProperty("systemKey")); + this.setToken(properties.getProperty("token")); + this.setBaseURL(properties.getProperty("baseURL")); + this.setDevicesURLExtension(properties.getProperty("devicesURLExtension")); + } + + public String getEndPoint() { + return endPoint; + } + + public void setEndPoint(String endPoint) { + this.endPoint = endPoint; + } + + public String getSystemKey() { + return systemKey; + } + + public void setSystemKey(String systemKey) { + this.systemKey = systemKey; + } + + public String getToken() { + return token; + } + + public void setToken(String token) { + this.token = token; + } + + public String getBaseURL() { + return baseURL; + } + + public void setBaseURL(String baseURL) { + this.baseURL = baseURL; + } + + public String getDevicesURLExtension() { + return devicesURLExtension; + } + + public void setDevicesURLExtension(String devicesURLExtension) { + this.devicesURLExtension = devicesURLExtension; + } + +} diff --git a/clearblade-cloud-iot/src/main/java/com/clearblade/cloud/iot/v1/utils/Constants.java b/clearblade-cloud-iot/src/main/java/com/clearblade/cloud/iot/v1/utils/Constants.java index ac9d3d01..79d01a29 100644 --- a/clearblade-cloud-iot/src/main/java/com/clearblade/cloud/iot/v1/utils/Constants.java +++ b/clearblade-cloud-iot/src/main/java/com/clearblade/cloud/iot/v1/utils/Constants.java @@ -1,297 +1,23 @@ package com.clearblade.cloud.iot.v1.utils; -import java.io.IOException; -import java.io.InputStream; -import java.util.Properties; - public class Constants { - - //Fields used to set values from properties file - private String endPoint; - private String systemKey; - private String token; - private String project; - private String location; - private String registry; - private String deviceName; - - //Fields used to set key- values related to httpconnection - for common use - private String httpRequestMethodType; - private String httpRequestPropertyTokenKey; - private String httpRequestPropertyContentTypeKey; - private String httpRequestPropertyAcceptKey; - private String httpRequestPropertyContentTypeOrAcceptValue; - - private String httpURLBegin; - //Fields used to set values related for sendCommandToDevice method - private String sendCommandMethodName; - private String sendCommandPathPart1; - private String sendCommandPathPart2; - private String jsonInputString; - - //Fields used to set values for createDevice method - private String createDeviceMethodName; - private String createDevicePathPart1; - private String createDevicePathPart2; - private String numIds; - private String subFolder; - private String createDeviceInputString; - - //Fields used to fetch values from Properties file - Properties properties; - InputStream input; + private Constants() {} - public Constants() { - properties = null; - input = null; - setValues(); - } - - /** - * Method used to read values form config.properties file and setting in - * field setters - */ - public void getConfigurations() { - // Read inputs from properties file - properties = new Properties(); - input = getClass().getClassLoader().getResourceAsStream("config.properties"); - try { - properties.load(input); - }catch(IOException ex) { - ex.printStackTrace(); - }finally { - if(input != null) { - try { - input.close(); - } catch (IOException e) { - e.printStackTrace(); - } - } - } - } - - /** - * Method used to set values in Constants setter method - */ - public void setValues() { - - getConfigurations(); - - this.setEndPoint(properties.getProperty("endPoint")); - this.setSystemKey(properties.getProperty("systemKey")); - this.setToken(properties.getProperty("token")); - this.setProject(properties.getProperty("project")); - this.setLocation(properties.getProperty("location")); - this.setRegistry(properties.getProperty("registry")); - this.setDeviceName(properties.getProperty("deviceName")); - - this.setHttpRequestMethodType(properties.getProperty("httpRequestMethodType")); - this.setHttpRequestPropertyTokenKey(properties.getProperty("httpRequestPropertyTokenKey")); - this.setHttpRequestPropertyContentTypeKey(properties.getProperty("httpRequestPropertyContentTypeKey")); - this.setHttpRequestPropertyAcceptKey(properties.getProperty("httpRequestPropertyAcceptKey")); - this.setHttpRequestPropertyContentTypeOrAcceptValue(properties.getProperty("httpRequestPropertyContentTypeOrAcceptValue")); - - this.setHttpURLBegin(properties.getProperty("httpURLBegin")); - - this.setSendCommandMethodName(properties.getProperty("sendCommandMethodName")); - this.setSendCommandPathPart1(properties.getProperty("sendCommandPathPart1")); - this.setSendCommandPathPart2(properties.getProperty("sendCommandPathPart2")); + public static final String SEND_COMMAND_TO_DEVICE = "sendCommandToDevice"; + public static final String CREATE_DEVICE = "createDevice"; - this.setJsonInputString(properties.getProperty("jsonInputString")); - - this.setCreateDeviceMethodName(properties.getProperty("createDeviceMethodName")); - this.setCreateDevicePathPart1(properties.getProperty("createDevicePathPart1")); - this.setCreateDevicePathPart2(properties.getProperty("createDevicePathPart2")); - this.setNumIds(properties.getProperty("numIds")); - this.setSubFolder(properties.getProperty("subFolder")); - this.setCreateDeviceInputString(properties.getProperty("createDeviceInputString")); - - } - - public String getJsonInputString() { - return jsonInputString; - } - - public void setJsonInputString(String jsonInputString) { - this.jsonInputString = jsonInputString; - } - - public String getEndPoint() { - return endPoint; - } - - public void setEndPoint(String endPoint) { - this.endPoint = endPoint; - } - - public String getSystemKey() { - return systemKey; - } - - public void setSystemKey(String systemKey) { - this.systemKey = systemKey; - } - - public String getToken() { - return token; - } - - public void setToken(String token) { - this.token = token; - } - - public String getProject() { - return project; - } - - public void setProject(String project) { - this.project = project; - } - - public String getLocation() { - return location; - } - - public void setLocation(String location) { - this.location = location; - } - - public String getRegistry() { - return registry; - } - - public void setRegistry(String registry) { - this.registry = registry; - } - - public String getDeviceName() { - return deviceName; - } - - public void setDeviceName(String deviceName) { - this.deviceName = deviceName; - } - - public String getHttpRequestMethodType() { - return httpRequestMethodType; - } - - public void setHttpRequestMethodType(String httpRequestMethodType) { - this.httpRequestMethodType = httpRequestMethodType; - } - - public String getHttpRequestPropertyTokenKey() { - return httpRequestPropertyTokenKey; - } - - public void setHttpRequestPropertyTokenKey(String httpRequestPropertyTokenKey) { - this.httpRequestPropertyTokenKey = httpRequestPropertyTokenKey; - } - - public String getHttpRequestPropertyContentTypeKey() { - return httpRequestPropertyContentTypeKey; - } - - public void setHttpRequestPropertyContentTypeKey(String httpRequestPropertyContentTypeKey) { - this.httpRequestPropertyContentTypeKey = httpRequestPropertyContentTypeKey; - } - - public String getHttpRequestPropertyAcceptKey() { - return httpRequestPropertyAcceptKey; - } - - public void setHttpRequestPropertyAcceptKey(String httpRequestPropertyAcceptKey) { - this.httpRequestPropertyAcceptKey = httpRequestPropertyAcceptKey; - } - - public String getHttpRequestPropertyContentTypeOrAcceptValue() { - return httpRequestPropertyContentTypeOrAcceptValue; - } - - public void setHttpRequestPropertyContentTypeOrAcceptValue(String httpRequestPropertyContentTypeOrAcceptValue) { - this.httpRequestPropertyContentTypeOrAcceptValue = httpRequestPropertyContentTypeOrAcceptValue; - } - - public String getHttpURLBegin() { - return httpURLBegin; - } - - public void setHttpURLBegin(String httpURLBegin) { - this.httpURLBegin = httpURLBegin; - } - - public String getSendCommandMethodName() { - return sendCommandMethodName; - } - - public void setSendCommandMethodName(String sendCommandMethodName) { - this.sendCommandMethodName = sendCommandMethodName; - } - - public String getSendCommandPathPart1() { - return sendCommandPathPart1; - } - - public void setSendCommandPathPart1(String sendCommandPathPart1) { - this.sendCommandPathPart1 = sendCommandPathPart1; - } - - public String getSendCommandPathPart2() { - return sendCommandPathPart2; - } - - public void setSendCommandPathPart2(String sendCommandPathPart2) { - this.sendCommandPathPart2 = sendCommandPathPart2; - } - - public String getCreateDeviceMethodName() { - return createDeviceMethodName; - } - - public void setCreateDeviceMethodName(String createDeviceMethodName) { - this.createDeviceMethodName = createDeviceMethodName; - } - - public String getCreateDevicePathPart1() { - return createDevicePathPart1; - } - - public void setCreateDevicePathPart1(String createDevicePathPart1) { - this.createDevicePathPart1 = createDevicePathPart1; - } - - public String getCreateDevicePathPart2() { - return createDevicePathPart2; - } - - public void setCreateDevicePathPart2(String createDevicePathPart2) { - this.createDevicePathPart2 = createDevicePathPart2; - } - - public String getNumIds() { - return numIds; - } - - public void setNumIds(String numIds) { - this.numIds = numIds; - } - - public String getSubFolder() { - return subFolder; - } - - public void setSubFolder(String subFolder) { - this.subFolder = subFolder; - } - - public String getCreateDeviceInputString() { - return createDeviceInputString; - } - - public void setCreateDeviceInputString(String createDeviceInputString) { - this.createDeviceInputString = createDeviceInputString; - } + // Constants used for setting up http connection - for common use + public static final String HTTPS_URL_PREFIX = "https://"; + public static final String HTTP_REQUEST_METHOD_TYPE_POST = "POST"; + public static final String HTTP_REQUEST_METHOD_TYPE_DELETE = "DELETE"; + public static final String HTTP_REQUEST_PROPERTY_TOKEN_KEY = "ClearBlade-UserToken"; + public static final String HTTP_REQUEST_PROPERTY_CONTENT_TYPE_KEY = "Content-Type"; + public static final String HTTP_REQUEST_PROPERTY_ACCEPT_KEY = "Accept"; + public static final String HTTP_REQUEST_PROPERTY_CONTENT_TYPE_ACCEPT_VALUE = "application/json"; + //Commonly used String literal + public static final String SUBFOLDER = "subfolder"; + } diff --git a/clearblade-cloud-iot/src/main/java/com/clearblade/cloud/iot/v1/utils/Device.java b/clearblade-cloud-iot/src/main/java/com/clearblade/cloud/iot/v1/utils/Device.java index 509ebb77..5371ec3f 100644 --- a/clearblade-cloud-iot/src/main/java/com/clearblade/cloud/iot/v1/utils/Device.java +++ b/clearblade-cloud-iot/src/main/java/com/clearblade/cloud/iot/v1/utils/Device.java @@ -7,21 +7,39 @@ public class Device { private final String id; private final String name; + private final int numId; private final List credentials; + private final List lastErrorStatus; + private final List config; + private final List state; private final int logLevel; + private final List metadata; + private final List gatewayConfig; public Device() { id = ""; name = ""; - credentials = new ArrayList<>(); + numId = 0; + credentials = null; + lastErrorStatus = new ArrayList<>(); + config = new ArrayList<>(); + state = new ArrayList<>(); logLevel = 0; + metadata = new ArrayList<>(); + gatewayConfig = new ArrayList<>(); } private Device(Builder builder) { id = builder.getId(); name = builder.getName(); + numId = builder.getNumId(); credentials = builder.getCredentials(); + lastErrorStatus = builder.getLastErrorStatus(); + config = builder.getConfig(); + state = builder.getState(); logLevel = builder.getLogLevel(); + metadata = builder.getMetadata(); + gatewayConfig = builder.getGatewayConfig(); } @@ -33,12 +51,12 @@ public Builder toBuilder() { return new Builder(this); } - public static Device of(String id, String name, List credentials, int logLevel) { - return newBuilder().setId(id).setName(name).setCredentials(credentials).setLogLevel(logLevel).build(); + public static Device of(String id, String name, int numId, List credentials, List lastErrorStatus,List config, List state, int logLevel, List metadata, List gatewayConfig) { + return newBuilder().setId(id).setName(name).setNumId(numId).setCredentials(credentials).setLastErrorStatus(lastErrorStatus).setConfig(config).setState(state).setLogLevel(logLevel).setMetadata(metadata).setGatewayConfig(gatewayConfig).build(); } - public static String format(String id, String name, List credentials, int logLevel) { - return newBuilder().setId(id).setName(name).setCredentials(credentials).setLogLevel(logLevel).build() + public static String format(String id, String name, int numId, List credentials, List lastErrorStatus,List config, List state, int logLevel, List metadata, List gatewayConfig) { + return newBuilder().setId(id).setName(name).setNumId(numId).setCredentials(credentials).setLastErrorStatus(lastErrorStatus).setConfig(config).setState(state).setLogLevel(logLevel).setMetadata(metadata).setGatewayConfig(gatewayConfig).build() .toString(); } @@ -49,12 +67,20 @@ public static String format(String id, String name, List credentials, in public static class Builder { private String id; private String name; + private int numId; private List credentials; + private List lastErrorStatus; + private List config; + private List state; private int logLevel; + private List metadata; + private List gatewayConfig; + protected Builder() { + } - + public String getId() { return id; } @@ -63,13 +89,41 @@ public String getName() { return name; } + public int getNumId() { + return numId; + } + public List getCredentials() { return credentials; } + public List getLastErrorStatus() { + return lastErrorStatus; + } + + public List getConfig() { + return config; + } + + public List getState() { + return state; + } + + public List getMetadata() { + return metadata; + } + + public List getGatewayConfig() { + return gatewayConfig; + } + public int getLogLevel() { return logLevel; } + + public static Builder newBuilder() { + return newBuilder(); + } public Builder setId(String id) { this.id = id; @@ -81,21 +135,56 @@ public Builder setName(String name) { return this; } + public Builder setNumId(int numId) { + this.numId = numId; + return this; + } + public Builder setCredentials(List credentials) { this.credentials = credentials; return this; } + public Builder setLastErrorStatus(List lastErrorStatus) { + this.lastErrorStatus = lastErrorStatus; + return this; + } + + public Builder setConfig(List config) { + this.config = config; + return this; + } + public Builder setLogLevel(int logLevel) { this.logLevel = logLevel; return this; } + public Builder setState(List state) { + this.state = state; + return this; + } + + public Builder setMetadata(List metadata) { + this.metadata = metadata; + return this; + } + + public Builder setGatewayConfig(List gatewayConfig) { + this.gatewayConfig = gatewayConfig; + return this; + } private Builder(Device device) { this.id = device.id; this.name = device.name; + this.numId = device.numId; this.credentials = device.credentials; + this.lastErrorStatus = device.lastErrorStatus; + this.config = device.config; + this.state = device.state; this.logLevel = device.logLevel; + this.metadata = device.metadata; + this.gatewayConfig = device.gatewayConfig; } public Device build() { diff --git a/clearblade-cloud-iot/src/main/java/config.properties b/clearblade-cloud-iot/src/main/java/config.properties index 7a88ad92..5fbd2d44 100644 --- a/clearblade-cloud-iot/src/main/java/config.properties +++ b/clearblade-cloud-iot/src/main/java/config.properties @@ -1,30 +1,11 @@ endPoint=iot-sandbox.clearblade.com:443 systemKey=fedbc9b40cde90befbd9b2dfde9d01 token=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1aWQiOiI4NmRjYzliNDBjOWVkMmI4YWFmZmMwOWRhMmNkMDEiLCJzaWQiOiJmZTdkNWIyMy1hODg4LTQ2NGUtOGE4MC01ZWM1NTYwOTBjZTIiLCJ1dCI6MiwidHQiOjEsImV4cCI6LTEsImlhdCI6MTY2NTc0MjU5NX0.osrsmcqunC6IMfgLfZis0UlC4s7W4mmKe73mq_SSJ8Q -project=ingressdevelopmentenv -location=us-central1 -registry=Rashmi_Registry_Test -deviceName=Rashmi_Device_Test +#project=ingressdevelopmentenv +#location=us-central1 +#registry=Rashmi_Registry_Test +#deviceName=Rashmi_Device_Test -httpRequestMethodType=POST -httpRequestPropertyTokenKey=ClearBlade-UserToken -httpRequestPropertyContentTypeKey=Content-Type -httpRequestPropertyAcceptKey=Accept -httpRequestPropertyContentTypeOrAcceptValue=application/json - - -httpURLBegin=https:// - -sendCommandMethodName=sendCommandToDevice -sendCommandPathPart1=/api/v/4/webhook/execute/ -sendCommandPathPart2=/cloudiot_devices - -jsonInputString={\"binaryData\": \"c2VuZEZ1bm55TWVzc2FnZVRvRGV2aWNl\"} - -createDeviceMethodName=createDevice -createDevicePathPart1=/api/v/4/webhook/execute/ -createDevicePathPart2=/cloudiot_devices -numIds=113,114 -subFolder=789 -createDeviceInputString={\"id\": \"myOldDevice3\",\"name\": \"myOldDevice3\",\"numId\": 987,\"credentials\": [],\"lastErrorStatus\": {},\"config\": {},\"state\": {},\"logLevel\": \"NONE\",\"metadata\": {},\"gatewayConfig\": {}} +baseURL=/api/v/4/webhook/execute/ +devicesURLExtension=/cloudiot_devices From 43458aa60d0acd9d9fa9416f2940ff0c2f5c3118 Mon Sep 17 00:00:00 2001 From: RashmiK14 Date: Mon, 7 Nov 2022 22:14:06 +0530 Subject: [PATCH 008/151] IOT_606_607 deviceDelete getDevice endpoint regional changes Committed changes related to deviceDelete and getDevice endpoint regional --- .../v1/deletedevice/AsyncDeleteDevice.java | 38 +++++++ .../iot/v1/deletedevice/SyncDeleteDevice.java | 38 +++++++ .../iot/v1/getdevice/AsyncGetDevice.java | 38 +++++++ .../cloud/iot/v1/getdevice/SyncGetDevice.java | 40 +++++++ .../cloud/iot/v1/DeleteDeviceRequest.java | 41 +++++++ .../cloud/iot/v1/DeleteDeviceResponse.java | 91 ++++++++++++++++ .../cloud/iot/v1/DeviceManagerClient.java | 36 ++++++ .../cloud/iot/v1/GetDeviceRequest.java | 43 ++++++++ .../cloud/iot/v1/GetDeviceResponse.java | 103 ++++++++++++++++++ .../cloud/iot/v1/utils/Constants.java | 3 + 10 files changed, 471 insertions(+) create mode 100644 clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/deletedevice/AsyncDeleteDevice.java create mode 100644 clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/deletedevice/SyncDeleteDevice.java create mode 100644 clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/getdevice/AsyncGetDevice.java create mode 100644 clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/getdevice/SyncGetDevice.java create mode 100644 clearblade-cloud-iot/src/main/java/com/clearblade/cloud/iot/v1/DeleteDeviceRequest.java create mode 100644 clearblade-cloud-iot/src/main/java/com/clearblade/cloud/iot/v1/DeleteDeviceResponse.java create mode 100644 clearblade-cloud-iot/src/main/java/com/clearblade/cloud/iot/v1/GetDeviceRequest.java create mode 100644 clearblade-cloud-iot/src/main/java/com/clearblade/cloud/iot/v1/GetDeviceResponse.java diff --git a/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/deletedevice/AsyncDeleteDevice.java b/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/deletedevice/AsyncDeleteDevice.java new file mode 100644 index 00000000..72430ca4 --- /dev/null +++ b/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/deletedevice/AsyncDeleteDevice.java @@ -0,0 +1,38 @@ +package com.clearblade.cloud.iot.v1.deletedevice; + +import java.util.logging.Level; +import java.util.logging.Logger; + +import com.clearblade.cloud.iot.v1.DeleteDeviceRequest; +import com.clearblade.cloud.iot.v1.DeleteDeviceResponse; +import com.clearblade.cloud.iot.v1.DeviceManagerClient; + +public class AsyncDeleteDevice { + static Logger log = Logger.getLogger(AsyncDeleteDevice.class.getName()); + + public static void main(String[] args) { + asyncDeleteDevice(); + } + + public static void asyncDeleteDevice() { + DeviceManagerClient deviceManagerClient = new DeviceManagerClient(); + String msg = ""; + String deviceName = "AsyncDeviceTest"; + DeleteDeviceRequest request = DeleteDeviceRequest.Builder.newBuilder().setDeviceName(deviceName).build(); + DeleteDeviceResponse response = deviceManagerClient.deleteDevice(request); + if (response != null) { + response.processRequest(request); + if (response.getHttpStatusResponse().equals("OK")) { + msg = "AsyncDeleteDevice Method worked successfully :: " + response.getHttpStatusResponse(); + log.log(Level.INFO, msg); + } else { + msg = "AsyncDeleteDevice Method execution failed :: " + response.getHttpStatusResponse(); + log.log(Level.SEVERE, msg); + } + } else { + msg = "AsyncDeleteDevice Method execution failed"; + log.log(Level.SEVERE, msg); + } + } + +} diff --git a/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/deletedevice/SyncDeleteDevice.java b/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/deletedevice/SyncDeleteDevice.java new file mode 100644 index 00000000..24786522 --- /dev/null +++ b/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/deletedevice/SyncDeleteDevice.java @@ -0,0 +1,38 @@ +package com.clearblade.cloud.iot.v1.deletedevice; + +import java.util.logging.Level; +import java.util.logging.Logger; + +import com.clearblade.cloud.iot.v1.DeleteDeviceRequest; +import com.clearblade.cloud.iot.v1.DeleteDeviceResponse; +import com.clearblade.cloud.iot.v1.DeviceManagerClient; + +public class SyncDeleteDevice { + static Logger log = Logger.getLogger(SyncDeleteDevice.class.getName()); + + public static void main(String[] args) { + syncDeleteDevice(); + } + + public static void syncDeleteDevice() { + DeviceManagerClient deviceManagerClient = new DeviceManagerClient(); + String msg = ""; + String deviceName = "SyncDeviceTest2"; + DeleteDeviceRequest request = DeleteDeviceRequest.Builder.newBuilder().setDeviceName(deviceName).build(); + DeleteDeviceResponse response = deviceManagerClient.deleteDevice(request); + if (response != null) { + response.processRequest(request); + if (response.getHttpStatusResponse().equals("OK")) { + msg = "AsyncDeleteDevice Method worked successfully :: " + response.getHttpStatusResponse(); + log.log(Level.INFO, msg); + } else { + msg = "AsyncDeleteDevice Method execution failed :: " + response.getHttpStatusResponse(); + log.log(Level.SEVERE, msg); + } + } else { + msg = "AsyncDeleteDevice Method execution failed"; + log.log(Level.SEVERE, msg); + } + } + +} diff --git a/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/getdevice/AsyncGetDevice.java b/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/getdevice/AsyncGetDevice.java new file mode 100644 index 00000000..9016d6d5 --- /dev/null +++ b/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/getdevice/AsyncGetDevice.java @@ -0,0 +1,38 @@ +package com.clearblade.cloud.iot.v1.getdevice; + +import java.util.logging.Level; +import java.util.logging.Logger; + +import com.clearblade.cloud.iot.v1.DeviceManagerClient; +import com.clearblade.cloud.iot.v1.GetDeviceRequest; +import com.clearblade.cloud.iot.v1.GetDeviceResponse; + +public class AsyncGetDevice { + static Logger log = Logger.getLogger(AsyncGetDevice.class.getName()); + + public static void main(String[] args) { + asyncGetDevice(); + } + + public static void asyncGetDevice() { + DeviceManagerClient deviceManagerClient = new DeviceManagerClient(); + String msg = ""; + String deviceName = "myOldDevice"; + GetDeviceRequest request = GetDeviceRequest.Builder.newBuilder().setDeviceName(deviceName).build(); + GetDeviceResponse response = deviceManagerClient.getDevice(request); + if (response != null) { + response.processRequest(request); + if (response.getHttpStatusResponse().equals("OK")) { + msg = "AsyncGetDevice Method worked successfully :: " + response.getHttpStatusResponse(); + log.log(Level.INFO, msg); + } else { + msg = "AsyncGetDevice Method execution failed :: " + response.getHttpStatusResponse(); + log.log(Level.SEVERE, msg); + } + } else { + msg = "AsyncGetDevice Method execution failed"; + log.log(Level.SEVERE, msg); + } + } + +} diff --git a/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/getdevice/SyncGetDevice.java b/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/getdevice/SyncGetDevice.java new file mode 100644 index 00000000..7868720e --- /dev/null +++ b/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/getdevice/SyncGetDevice.java @@ -0,0 +1,40 @@ +package com.clearblade.cloud.iot.v1.getdevice; + +import java.util.logging.Level; +import java.util.logging.Logger; + +import com.clearblade.cloud.iot.v1.DeviceManagerClient; + +import com.clearblade.cloud.iot.v1.GetDeviceRequest; +import com.clearblade.cloud.iot.v1.GetDeviceResponse; + +public class SyncGetDevice { + static Logger log = Logger.getLogger(SyncGetDevice.class.getName()); + + public static void main(String[] args) { + syncGetDevice(); + } + + public static void syncGetDevice() { + DeviceManagerClient deviceManagerClient = new DeviceManagerClient(); + String msg = ""; + String deviceName = "Rashmi_Device_Test"; + GetDeviceRequest request = GetDeviceRequest.Builder.newBuilder().setDeviceName(deviceName).build(); + GetDeviceResponse response = deviceManagerClient.getDevice(request); + if (response != null) { + response.processRequest(request); + if (response.getHttpStatusResponse().equals("OK")) { + msg = "SyncGetDevice Method worked successfully :: " + response.getHttpStatusResponse(); + log.log(Level.INFO, msg); + } else { + msg = "SyncGetDevice Method execution failed :: " + response.getHttpStatusResponse(); + log.log(Level.SEVERE, msg); + } + } else { + msg = "SyncGetDevice Method execution failed"; + log.log(Level.SEVERE, msg); + } + } + + +} diff --git a/clearblade-cloud-iot/src/main/java/com/clearblade/cloud/iot/v1/DeleteDeviceRequest.java b/clearblade-cloud-iot/src/main/java/com/clearblade/cloud/iot/v1/DeleteDeviceRequest.java new file mode 100644 index 00000000..766b2cad --- /dev/null +++ b/clearblade-cloud-iot/src/main/java/com/clearblade/cloud/iot/v1/DeleteDeviceRequest.java @@ -0,0 +1,41 @@ +package com.clearblade.cloud.iot.v1; + +public class DeleteDeviceRequest { + private final String deviceName; + + private DeleteDeviceRequest(Builder builder) { + this.deviceName = builder.deviceName; + } + + // Static class Builder + public static class Builder { + + /// instance fields + private String deviceName; + + public static Builder newBuilder() { + return new Builder(); + } + + private Builder() { + } + + // Setter methods + public Builder setDeviceName(String deviceName) { + this.deviceName = deviceName; + return this; + } + + // build method to deal with outer class + // to return outer instance + public DeleteDeviceRequest build() { + return new DeleteDeviceRequest(this); + } + } + + @Override + public String toString() { + return "deviceName = " + this.deviceName; + } + +} diff --git a/clearblade-cloud-iot/src/main/java/com/clearblade/cloud/iot/v1/DeleteDeviceResponse.java b/clearblade-cloud-iot/src/main/java/com/clearblade/cloud/iot/v1/DeleteDeviceResponse.java new file mode 100644 index 00000000..caa861a8 --- /dev/null +++ b/clearblade-cloud-iot/src/main/java/com/clearblade/cloud/iot/v1/DeleteDeviceResponse.java @@ -0,0 +1,91 @@ +package com.clearblade.cloud.iot.v1; + +import java.util.logging.Level; +import java.util.logging.Logger; + +public class DeleteDeviceResponse { + + static Logger log = Logger.getLogger(DeleteDeviceResponse.class.getName()); + private final DeleteDeviceRequest request; + private int httpStatusCode; + private String httpStatusResponse; + + protected DeleteDeviceResponse(Builder builder) { + this.request = builder.request; + } + + public int getHttpStatusCode() { + return httpStatusCode; + } + + public void setHttpStatusCode(int httpStatusCode) { + this.httpStatusCode = httpStatusCode; + } + + public String getHttpStatusResponse() { + return httpStatusResponse; + } + + public void setHttpStatusResponse(String httpStatusResponse) { + this.httpStatusResponse = httpStatusResponse; + } + + // Static class Builder + public static class Builder { + + /// instance fields + private DeleteDeviceRequest request; + + public static Builder newBuilder() { + return new Builder(); + } + + private Builder() { + } + + // Setter methods + public Builder setDeleteDeviceRequest(DeleteDeviceRequest request) { + this.request = request; + return this; + } + + // build method to deal with outer class + // to return outer instance + public DeleteDeviceResponse build() { + return new DeleteDeviceResponse(this); + } + } + + /** + * Mehtod used to process the request Calling processRequestForMethod - + * DeleteDevice + */ + public void processRequest(DeleteDeviceRequest request) { + ProcessRequest processRequest = new ProcessRequest(); + String msg = ""; + String[] requestParamsArray = new String[] { request.toString() }; + + String responseMessage = processRequest.processRequestForMethod("deleteDevice", requestParamsArray); + this.setHttpStatusResponse(responseMessage); + if (responseMessage.equals("OK")) { + this.setHttpStatusCode(200); + msg = "Request processed for DeleteDevice method"; + log.log(Level.INFO, msg); + } else { + this.setHttpStatusCode(0); + msg = "Request for DeleteDevice failed \n".concat(responseMessage); + log.log(Level.SEVERE, msg); + } + } + + @Override + public String toString() { + return "Http Status Code :: " + this.getHttpStatusCode() + " Http Status Response :: " + + this.getHttpStatusResponse(); + } + + public DeleteDeviceRequest getRequest() { + return request; + } + +} diff --git a/clearblade-cloud-iot/src/main/java/com/clearblade/cloud/iot/v1/DeviceManagerClient.java b/clearblade-cloud-iot/src/main/java/com/clearblade/cloud/iot/v1/DeviceManagerClient.java index fb7a2288..0b2b06c0 100644 --- a/clearblade-cloud-iot/src/main/java/com/clearblade/cloud/iot/v1/DeviceManagerClient.java +++ b/clearblade-cloud-iot/src/main/java/com/clearblade/cloud/iot/v1/DeviceManagerClient.java @@ -55,4 +55,40 @@ public CreateDeviceResponse createDevice(CreateDeviceRequest request) { return (CreateDeviceResponse.Builder.newBuilder().setCreateDeviceRequest(request).build()); } + public final void deleteDevice(DeviceName name) { + DeleteDeviceRequest request = DeleteDeviceRequest.Builder.newBuilder().setDeviceName(name == null ? null : name.toString()) + .build(); + deleteDevice(request); + } + + /** + * Print the response for deleteDevice + * + * @param request + * @return Response object + */ + public DeleteDeviceResponse deleteDevice(DeleteDeviceRequest request) { + return (DeleteDeviceResponse.Builder.newBuilder().setDeleteDeviceRequest(request).build()); + } + + /** + * Method used to call getDevice api + * @param name + * @return Device object + */ + public void getDevice(DeviceName name) { + GetDeviceRequest request = GetDeviceRequest.Builder.newBuilder().setDeviceName(name == null ? null : name.toString()).build(); + getDevice(request); + } + + /** + * Print the response for getDevice + * + * @param request + * @return Response object + */ + public GetDeviceResponse getDevice(GetDeviceRequest request) { + return (GetDeviceResponse.Builder.newBuilder().setGetDeviceRequest(request).build()); + } + } diff --git a/clearblade-cloud-iot/src/main/java/com/clearblade/cloud/iot/v1/GetDeviceRequest.java b/clearblade-cloud-iot/src/main/java/com/clearblade/cloud/iot/v1/GetDeviceRequest.java new file mode 100644 index 00000000..5d909f39 --- /dev/null +++ b/clearblade-cloud-iot/src/main/java/com/clearblade/cloud/iot/v1/GetDeviceRequest.java @@ -0,0 +1,43 @@ +package com.clearblade.cloud.iot.v1; + +public class GetDeviceRequest { + + private final String deviceName; + + private GetDeviceRequest(Builder builder) { + this.deviceName = builder.deviceName; + } + + // Static class Builder + public static class Builder { + + /// instance fields + private String deviceName; + + public static Builder newBuilder() { + return new Builder(); + } + + private Builder() { + } + + // Setter methods + public Builder setDeviceName(String deviceName) { + this.deviceName = deviceName; + return this; + } + + // build method to deal with outer class + // to return outer instance + public GetDeviceRequest build() { + return new GetDeviceRequest(this); + } + } + + @Override + public String toString() { + return "deviceName = " + this.deviceName; + } + + +} diff --git a/clearblade-cloud-iot/src/main/java/com/clearblade/cloud/iot/v1/GetDeviceResponse.java b/clearblade-cloud-iot/src/main/java/com/clearblade/cloud/iot/v1/GetDeviceResponse.java new file mode 100644 index 00000000..f6fcd73c --- /dev/null +++ b/clearblade-cloud-iot/src/main/java/com/clearblade/cloud/iot/v1/GetDeviceResponse.java @@ -0,0 +1,103 @@ +package com.clearblade.cloud.iot.v1; + +import java.util.logging.Level; +import java.util.logging.Logger; + +import com.clearblade.cloud.iot.v1.utils.Device; + +public class GetDeviceResponse { + + static Logger log = Logger.getLogger(GetDeviceResponse.class.getName()); + + private final GetDeviceRequest request; + private int httpStatusCode; + private String httpStatusResponse; + private Device device; + + protected GetDeviceResponse(Builder builder) { + this.request = builder.request; + } + + public int getHttpStatusCode() { + return httpStatusCode; + } + + public void setHttpStatusCode(int httpStatusCode) { + this.httpStatusCode = httpStatusCode; + } + + public String getHttpStatusResponse() { + return httpStatusResponse; + } + + public void setHttpStatusResponse(String httpStatusResponse) { + this.httpStatusResponse = httpStatusResponse; + } + + // Static class Builder + public static class Builder { + + /// instance fields + private GetDeviceRequest request; + + public static Builder newBuilder() { + return new Builder(); + } + + private Builder() { + } + + // Setter methods + public Builder setGetDeviceRequest(GetDeviceRequest request) { + this.request = request; + return this; + } + + // build method to deal with outer class + // to return outer instance + public GetDeviceResponse build() { + return new GetDeviceResponse(this); + } + } + + /** + * Mehtod used to process the request Calling processRequestForMethod - + * GetDevice + */ + public void processRequest(GetDeviceRequest request) { + + ProcessRequest processRequest = new ProcessRequest(); + String msg = ""; + String[] requestParamsArray = new String[] { request.toString() }; + String responseMessage = processRequest.processRequestForMethod("getDevice", requestParamsArray); + this.setHttpStatusResponse(responseMessage); + if (responseMessage.equals("OK")) { + this.setHttpStatusCode(200); + msg = "Request processed for GetDevice method"; + log.log(Level.INFO, msg); + } else { + this.setHttpStatusCode(0); + msg = "Request for GetDevice failed \n" .concat(responseMessage); + log.log(Level.SEVERE, msg); + } + } + + @Override + public String toString() { + return "Http Status Code :: " + this.getHttpStatusCode() + " Http Status Response :: " + + this.getHttpStatusResponse(); + } + + public GetDeviceRequest getRequest() { + return request; + } + + public Device getDevice() { + return device; + } + + public void setDevice(Device device) { + this.device = device; + } + +} diff --git a/clearblade-cloud-iot/src/main/java/com/clearblade/cloud/iot/v1/utils/Constants.java b/clearblade-cloud-iot/src/main/java/com/clearblade/cloud/iot/v1/utils/Constants.java index 79d01a29..28e18e68 100644 --- a/clearblade-cloud-iot/src/main/java/com/clearblade/cloud/iot/v1/utils/Constants.java +++ b/clearblade-cloud-iot/src/main/java/com/clearblade/cloud/iot/v1/utils/Constants.java @@ -6,11 +6,14 @@ private Constants() {} public static final String SEND_COMMAND_TO_DEVICE = "sendCommandToDevice"; public static final String CREATE_DEVICE = "createDevice"; + public static final String DELETE_DEVICE = "deleteDevice"; + public static final String GET_DEVICE = "getDevice"; // Constants used for setting up http connection - for common use public static final String HTTPS_URL_PREFIX = "https://"; public static final String HTTP_REQUEST_METHOD_TYPE_POST = "POST"; public static final String HTTP_REQUEST_METHOD_TYPE_DELETE = "DELETE"; + public static final String HTTP_REQUEST_METHOD_TYPE_GET = "GET"; public static final String HTTP_REQUEST_PROPERTY_TOKEN_KEY = "ClearBlade-UserToken"; public static final String HTTP_REQUEST_PROPERTY_CONTENT_TYPE_KEY = "Content-Type"; public static final String HTTP_REQUEST_PROPERTY_ACCEPT_KEY = "Accept"; From 613f88939dcf1b03746ec454d97ae9d1d1aef6ec Mon Sep 17 00:00:00 2001 From: RashmiK14 Date: Tue, 8 Nov 2022 18:49:04 +0530 Subject: [PATCH 009/151] IOT_606_607_520_612 Devices Delete, Get, List and State List endpoint - regional Committing changes related to following issues :-> 1) IOT_606 devicesDelete endpoint 2) IOT_607 devicesGet endpoint 3) IOT_520 devicesList endpoint 4) IOT_612 devicesStateList endpoint --- clearblade-cloud-iot/pom.xml | 33 +++ .../v1/createdevice/AsyncCreateDevice.java | 3 +- .../iot/v1/createdevice/SyncCreateDevice.java | 3 +- .../iot/v1/deviceslist/AsyncDevicesList.java | 42 +++ .../iot/v1/deviceslist/SyncDevicesList.java | 42 +++ .../AsyncDeviceStatesList.java | 40 +++ .../SyncDeviceStatesList.java | 39 +++ .../iot/v1/getdevice/AsyncGetDevice.java | 2 +- .../cloud/iot/v1/CreateDeviceRequest.java | 141 ++++++++++ .../cloud/iot/v1/CreateDeviceResponse.java | 16 +- .../cloud/iot/v1/DeleteDeviceRequest.java | 2 +- .../cloud/iot/v1/DeleteDeviceResponse.java | 13 +- .../cloud/iot/v1/DeviceManagerClient.java | 43 ++- .../cloud/iot/v1/DeviceStatesListRequest.java | 67 +++++ .../iot/v1/DeviceStatesListResponse.java | 112 ++++++++ .../cloud/iot/v1/DevicesListRequest.java | 44 +++ .../cloud/iot/v1/DevicesListResponse.java | 111 ++++++++ .../cloud/iot/v1/GetDeviceRequest.java | 4 +- .../cloud/iot/v1/GetDeviceResponse.java | 16 +- .../cloud/iot/v1/ProcessRequest.java | 262 ++++++++++++++++++ .../iot/v1/SendCommandToDeviceRequest.java | 37 ++- .../iot/v1/SendCommandToDeviceResponse.java | 18 +- .../iot/v1/test/DeviceManagerClientTest.java | 123 ++++++++ .../cloud/iot/v1/utils/ByteString.java | 0 .../cloud/iot/v1/utils/ConfigParameters.java | 32 ++- .../cloud/iot/v1/utils/Constants.java | 2 + .../clearblade/cloud/iot/v1/utils/Device.java | 91 +++++- .../cloud/iot/v1/utils/DeviceName.java | 0 .../cloud/iot/v1/utils/DeviceState.java | 45 +++ .../cloud/iot/v1/utils/RegistryName.java | 5 +- .../cloud/iot/v1/utils/SetHttpConnection.java | 23 ++ .../src/{main/java => }/config.properties | 6 +- .../cloud/iot/v1/CreateDeviceRequest.java | 105 ------- .../cloud/iot/v1/ProcessRequest.java | 242 ---------------- .../cloud/iot/v1/utils/SetHttpConnection.java | 26 -- .../iot/v1/test/DeviceManagerClientTest.java | 115 -------- 36 files changed, 1371 insertions(+), 534 deletions(-) create mode 100644 clearblade-cloud-iot/pom.xml create mode 100644 clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/deviceslist/AsyncDevicesList.java create mode 100644 clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/deviceslist/SyncDevicesList.java create mode 100644 clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/devicestateslist/AsyncDeviceStatesList.java create mode 100644 clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/devicestateslist/SyncDeviceStatesList.java create mode 100644 clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/CreateDeviceRequest.java rename clearblade-cloud-iot/src/{main/java => }/com/clearblade/cloud/iot/v1/CreateDeviceResponse.java (83%) rename clearblade-cloud-iot/src/{main/java => }/com/clearblade/cloud/iot/v1/DeleteDeviceRequest.java (94%) rename clearblade-cloud-iot/src/{main/java => }/com/clearblade/cloud/iot/v1/DeleteDeviceResponse.java (88%) rename clearblade-cloud-iot/src/{main/java => }/com/clearblade/cloud/iot/v1/DeviceManagerClient.java (69%) create mode 100644 clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/DeviceStatesListRequest.java create mode 100644 clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/DeviceStatesListResponse.java create mode 100644 clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/DevicesListRequest.java create mode 100644 clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/DevicesListResponse.java rename clearblade-cloud-iot/src/{main/java => }/com/clearblade/cloud/iot/v1/GetDeviceRequest.java (94%) rename clearblade-cloud-iot/src/{main/java => }/com/clearblade/cloud/iot/v1/GetDeviceResponse.java (87%) create mode 100644 clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/ProcessRequest.java rename clearblade-cloud-iot/src/{main/java => }/com/clearblade/cloud/iot/v1/SendCommandToDeviceRequest.java (74%) rename clearblade-cloud-iot/src/{main/java => }/com/clearblade/cloud/iot/v1/SendCommandToDeviceResponse.java (83%) create mode 100644 clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/test/DeviceManagerClientTest.java rename clearblade-cloud-iot/src/{main/java => }/com/clearblade/cloud/iot/v1/utils/ByteString.java (100%) rename clearblade-cloud-iot/src/{main/java => }/com/clearblade/cloud/iot/v1/utils/ConfigParameters.java (75%) rename clearblade-cloud-iot/src/{main/java => }/com/clearblade/cloud/iot/v1/utils/Constants.java (89%) rename clearblade-cloud-iot/src/{main/java => }/com/clearblade/cloud/iot/v1/utils/Device.java (59%) rename clearblade-cloud-iot/src/{main/java => }/com/clearblade/cloud/iot/v1/utils/DeviceName.java (100%) create mode 100644 clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/utils/DeviceState.java rename clearblade-cloud-iot/src/{main/java => }/com/clearblade/cloud/iot/v1/utils/RegistryName.java (94%) create mode 100644 clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/utils/SetHttpConnection.java rename clearblade-cloud-iot/src/{main/java => }/config.properties (84%) delete mode 100644 clearblade-cloud-iot/src/main/java/com/clearblade/cloud/iot/v1/CreateDeviceRequest.java delete mode 100644 clearblade-cloud-iot/src/main/java/com/clearblade/cloud/iot/v1/ProcessRequest.java delete mode 100644 clearblade-cloud-iot/src/main/java/com/clearblade/cloud/iot/v1/utils/SetHttpConnection.java delete mode 100644 clearblade-cloud-iot/src/test/java/com/clearblade/cloud/iot/v1/test/DeviceManagerClientTest.java diff --git a/clearblade-cloud-iot/pom.xml b/clearblade-cloud-iot/pom.xml new file mode 100644 index 00000000..0d72fc53 --- /dev/null +++ b/clearblade-cloud-iot/pom.xml @@ -0,0 +1,33 @@ + + 4.0.0 + clearblade-cloud-iot + clearblade-cloud-iot + 0.0.1-SNAPSHOT + + src + + + maven-compiler-plugin + 3.8.1 + + 17 + + + + + + + + com.googlecode.json-simple + json-simple + 1.1.1 + + + + org.junit.jupiter + junit-jupiter-api + 5.9.1 + test + + + \ No newline at end of file diff --git a/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/createdevice/AsyncCreateDevice.java b/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/createdevice/AsyncCreateDevice.java index d5902ade..eac59d63 100644 --- a/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/createdevice/AsyncCreateDevice.java +++ b/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/createdevice/AsyncCreateDevice.java @@ -22,7 +22,8 @@ public static void asyncCreateDevice() { String registryName = "Rashmi_Registry_Test"; RegistryName registryNm = RegistryName.newBuilder().setRegistry(registryName).build(); CreateDeviceRequest request = CreateDeviceRequest.Builder.newBuilder().setParent(registryNm) - .setDevice(Device.newBuilder().setId("NewAsyncDeviceTest").setName("NewAsyncDeviceTest").setNumId(79869).build()).build(); + .setDevice(Device.newBuilder().setId("AsyncDeviceTest1").setName("AsyncDeviceTest1").setNumId(11111).build()) + .setDeviceNumIds(new String[]{"123,153"}).setSubfolder("777").build(); CreateDeviceResponse response = deviceManagerClient.createDevice(request); if (response != null) { response.processRequest(request); diff --git a/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/createdevice/SyncCreateDevice.java b/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/createdevice/SyncCreateDevice.java index e51d7acd..177624cb 100644 --- a/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/createdevice/SyncCreateDevice.java +++ b/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/createdevice/SyncCreateDevice.java @@ -23,7 +23,8 @@ public static void syncCreateDevice() { String registryName = "Rashmi_Registry_Test"; RegistryName registryNm = RegistryName.newBuilder().setRegistry(registryName).build(); CreateDeviceRequest request = CreateDeviceRequest.Builder.newBuilder().setParent(registryNm) - .setDevice(Device.newBuilder().setId("SyncDeviceTest").setName("SyncDeviceTest").setNumId(69869).build()).build(); + .setDevice(Device.newBuilder().setId("SyncDeviceTest1").setName("SyncDeviceTest1").setNumId(99998).build()) + .setDeviceNumIds(new String[]{"223,553"}).setSubfolder("753").build(); CreateDeviceResponse response = deviceManagerClient.createDevice(request); if (response != null) { response.processRequest(request); diff --git a/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/deviceslist/AsyncDevicesList.java b/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/deviceslist/AsyncDevicesList.java new file mode 100644 index 00000000..731817a0 --- /dev/null +++ b/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/deviceslist/AsyncDevicesList.java @@ -0,0 +1,42 @@ +package com.clearblade.cloud.iot.v1.deviceslist; + +import java.util.logging.Level; +import java.util.logging.Logger; + +import com.clearblade.cloud.iot.v1.DeviceManagerClient; +import com.clearblade.cloud.iot.v1.DevicesListRequest; +import com.clearblade.cloud.iot.v1.DevicesListResponse; +import com.clearblade.cloud.iot.v1.utils.ConfigParameters; +import com.clearblade.cloud.iot.v1.utils.RegistryName; + +public class AsyncDevicesList { + + static Logger log = Logger.getLogger(AsyncDevicesList.class.getName()); + + public static void main(String[] args){ + asyncDevicesList(); + } + + public static void asyncDevicesList(){ + String msg = ""; + DeviceManagerClient deviceManagerClient = new DeviceManagerClient(); + ConfigParameters configParams = new ConfigParameters(); + RegistryName parent = RegistryName.of(configParams.getProject(), configParams.getLocation(), configParams.getRegistry()); + DevicesListRequest request = DevicesListRequest.Builder.newBuilder().setParent(parent).build(); + DevicesListResponse response = deviceManagerClient.devicesList(request); + if (response != null) { + response.processRequest(request); + if (response.getHttpStatusResponse().equals("OK")) { + msg = "AsyncDevicesList Method worked successfully :: " + response.getHttpStatusResponse(); + log.log(Level.INFO, msg); + } else { + msg = "AsyncDevicesList Method execution failed :: " + response.getHttpStatusResponse(); + log.log(Level.SEVERE, msg); + } + } else { + msg = "AsyncDevicesList Method execution failed"; + log.log(Level.SEVERE, msg); + } + + } +} diff --git a/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/deviceslist/SyncDevicesList.java b/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/deviceslist/SyncDevicesList.java new file mode 100644 index 00000000..9c5cb84b --- /dev/null +++ b/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/deviceslist/SyncDevicesList.java @@ -0,0 +1,42 @@ +package com.clearblade.cloud.iot.v1.deviceslist; + +import java.util.logging.Level; +import java.util.logging.Logger; + +import com.clearblade.cloud.iot.v1.DeviceManagerClient; +import com.clearblade.cloud.iot.v1.DevicesListRequest; +import com.clearblade.cloud.iot.v1.DevicesListResponse; +import com.clearblade.cloud.iot.v1.utils.ConfigParameters; +import com.clearblade.cloud.iot.v1.utils.RegistryName; + +public class SyncDevicesList { + static Logger log = Logger.getLogger(SyncDevicesList.class.getName()); + + public static void main(String[] args){ + syncDevicesList(); + } + + public static void syncDevicesList(){ + String msg = ""; + DeviceManagerClient deviceManagerClient = new DeviceManagerClient(); + ConfigParameters configParams = new ConfigParameters(); + RegistryName parent = RegistryName.of(configParams.getProject(), configParams.getLocation(), configParams.getRegistry()); + DevicesListRequest request = DevicesListRequest.Builder.newBuilder().setParent(parent).build(); + DevicesListResponse response = deviceManagerClient.devicesList(request); + if (response != null) { + response.processRequest(request); + if (response.getHttpStatusResponse().equals("OK")) { + msg = "SyncDevicesList Method worked successfully :: " + response.getHttpStatusResponse(); + log.log(Level.INFO, msg); + } else { + msg = "SyncDevicesList Method execution failed :: " + response.getHttpStatusResponse(); + log.log(Level.SEVERE, msg); + } + } else { + msg = "SyncDevicesList Method execution failed"; + log.log(Level.SEVERE, msg); + } + + } + +} diff --git a/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/devicestateslist/AsyncDeviceStatesList.java b/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/devicestateslist/AsyncDeviceStatesList.java new file mode 100644 index 00000000..5e3f5ab2 --- /dev/null +++ b/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/devicestateslist/AsyncDeviceStatesList.java @@ -0,0 +1,40 @@ +package com.clearblade.cloud.iot.v1.devicestateslist; + +import java.util.logging.Level; +import java.util.logging.Logger; + +import com.clearblade.cloud.iot.v1.DeviceManagerClient; +import com.clearblade.cloud.iot.v1.DeviceStatesListRequest; +import com.clearblade.cloud.iot.v1.DeviceStatesListResponse; + +public class AsyncDeviceStatesList { + + static Logger log = Logger.getLogger(AsyncDeviceStatesList.class.getName()); + + public static void main(String[] args) { + asyncDeviceStatesList(); + } + + public static void asyncDeviceStatesList() { + String msg = ""; + String name = "Rashmi_Device_Test"; + DeviceManagerClient deviceManagerClient = new DeviceManagerClient(); + + DeviceStatesListRequest request = DeviceStatesListRequest.Builder.newBuilder().setName(name).setNumStates(1643330779).build(); + DeviceStatesListResponse response = deviceManagerClient.deviceStatesList(request); + if (response != null) { + response.processRequest(request); + if (response.getHttpStatusResponse().equals("OK")) { + msg = "AsyncDeviceStatesList Method worked successfully :: " + response.getHttpStatusResponse(); + log.log(Level.INFO, msg); + } else { + msg = "AsyncDeviceStatesList Method execution failed :: " + response.getHttpStatusResponse(); + log.log(Level.SEVERE, msg); + } + } else { + msg = "AsyncDeviceStatesList Method execution failed"; + log.log(Level.SEVERE, msg); + } + } + +} diff --git a/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/devicestateslist/SyncDeviceStatesList.java b/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/devicestateslist/SyncDeviceStatesList.java new file mode 100644 index 00000000..9d13518c --- /dev/null +++ b/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/devicestateslist/SyncDeviceStatesList.java @@ -0,0 +1,39 @@ +package com.clearblade.cloud.iot.v1.devicestateslist; + +import java.util.logging.Level; +import java.util.logging.Logger; + +import com.clearblade.cloud.iot.v1.DeviceManagerClient; +import com.clearblade.cloud.iot.v1.DeviceStatesListRequest; +import com.clearblade.cloud.iot.v1.DeviceStatesListResponse; + +public class SyncDeviceStatesList { + static Logger log = Logger.getLogger(SyncDeviceStatesList.class.getName()); + + public static void main(String[] args) { + syncDeviceStatesList(); + } + + public static void syncDeviceStatesList() { + String msg = ""; + String name = "Rashmi_Device_Test"; + DeviceManagerClient deviceManagerClient = new DeviceManagerClient(); + + DeviceStatesListRequest request = DeviceStatesListRequest.Builder.newBuilder().setName(name).setNumStates(1643330779).build(); + DeviceStatesListResponse response = deviceManagerClient.deviceStatesList(request); + if (response != null) { + response.processRequest(request); + if (response.getHttpStatusResponse().equals("OK")) { + msg = "SyncDeviceStatesList Method worked successfully :: " + response.getHttpStatusResponse(); + log.log(Level.INFO, msg); + } else { + msg = "SyncDeviceStatesList Method execution failed :: " + response.getHttpStatusResponse(); + log.log(Level.SEVERE, msg); + } + } else { + msg = "SyncDeviceStatesList Method execution failed"; + log.log(Level.SEVERE, msg); + } + } + +} diff --git a/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/getdevice/AsyncGetDevice.java b/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/getdevice/AsyncGetDevice.java index 9016d6d5..ff65a084 100644 --- a/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/getdevice/AsyncGetDevice.java +++ b/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/getdevice/AsyncGetDevice.java @@ -15,8 +15,8 @@ public static void main(String[] args) { } public static void asyncGetDevice() { - DeviceManagerClient deviceManagerClient = new DeviceManagerClient(); String msg = ""; + DeviceManagerClient deviceManagerClient = new DeviceManagerClient(); String deviceName = "myOldDevice"; GetDeviceRequest request = GetDeviceRequest.Builder.newBuilder().setDeviceName(deviceName).build(); GetDeviceResponse response = deviceManagerClient.getDevice(request); diff --git a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/CreateDeviceRequest.java b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/CreateDeviceRequest.java new file mode 100644 index 00000000..4feb53e2 --- /dev/null +++ b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/CreateDeviceRequest.java @@ -0,0 +1,141 @@ +package com.clearblade.cloud.iot.v1; + +import java.util.Collections; + +import org.json.simple.JSONObject; + +import com.clearblade.cloud.iot.v1.utils.Device; +import com.clearblade.cloud.iot.v1.utils.RegistryName; + +public class CreateDeviceRequest { + private final RegistryName parent; + private final Device device; + private final String subfolder; + private final String[] deviceNumIds; + public JSONObject requestParams; + public JSONObject bodyParams; + + private CreateDeviceRequest(Builder builder) { + this.parent = builder.parent; + this.device = builder.device; + this.deviceNumIds = builder.deviceNumIds; + this.subfolder = builder.subfolder; + } + + // Static class Builder + public static class Builder { + + /// instance fields + private RegistryName parent; + private Device device; + private String subfolder; + private String[] deviceNumIds; + + public static Builder newBuilder() { + return new Builder(); + } + + private Builder() { + } + + // Setter methods + public Builder setParent(RegistryName parent) { + this.parent = parent; + return this; + } + + public Builder setDevice(Device device) { + this.device = device; + return this; + } + + public Builder setDeviceNumIds(String[] numIds) { + this.deviceNumIds = numIds; + return this; + } + + public Builder setSubfolder(String subfolder) { + this.subfolder = subfolder; + return this; + } + + // build method to deal with outer class + // to return outer instance + public CreateDeviceRequest build() { + return new CreateDeviceRequest(this); + } + } + + public JSONObject getRequestParams() { + return requestParams; + } + + public void setRequestParams(JSONObject requestParams) { + this.requestParams = requestParams; + } + + public JSONObject getBodyParams() { + return bodyParams; + } + + public void setBodyParams(JSONObject bodyParams) { + this.bodyParams = bodyParams; + } + + @SuppressWarnings("unchecked") + @Override + public String toString() { + requestParams = new JSONObject(); + bodyParams = new JSONObject(); + String emptyStr = "EMPTY"; + + // if(this.parent != null) { bodyParams.put("parent",parent.getRegistry()); } + + if (this.device != null) { + + bodyParams.put("id", this.device.toBuilder().getId()); + bodyParams.put("name", this.device.toBuilder().getName()); + bodyParams.put("numId", this.device.toBuilder().getNumId()); + + bodyParams.put("credentials", Collections.emptyList()); + bodyParams.put("lastErrorStatus", this.device.toBuilder().getLastErrorStatus()); + bodyParams.put("config", this.device.toBuilder().getConfig()); + bodyParams.put("state", this.device.toBuilder().getState()); + bodyParams.put("logLevel", this.device.toBuilder().getLogLevel()); + bodyParams.put("metadata", this.device.toBuilder().getMetadata()); + bodyParams.put("gatewayConfig", this.device.toBuilder().getGatewayConfig()); + + } else { + bodyParams.put("device", emptyStr); + } + + String numIdStr = ""; + if (this.deviceNumIds != null) { + for (int i = 0; i < deviceNumIds.length; i++) { + if (i == 0) { + numIdStr = numIdStr.concat(deviceNumIds[i]); + } + if (i > 0) { + numIdStr = numIdStr.concat("," + deviceNumIds[i]); + } + } + } + requestParams.put("deviceNumIds", numIdStr); + String subfolderStr = ""; + if (this.subfolder != null) { + subfolderStr = subfolderStr.concat(subfolder); + } else { + subfolderStr = subfolderStr.concat(emptyStr); + } + requestParams.put("subfolder", subfolderStr); + + this.setBodyParams(bodyParams); + this.setRequestParams(requestParams); + if (this.device != null) { + return this.parent + ", " + this.device.toString(); + } else { + return emptyStr; + } + } + +} diff --git a/clearblade-cloud-iot/src/main/java/com/clearblade/cloud/iot/v1/CreateDeviceResponse.java b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/CreateDeviceResponse.java similarity index 83% rename from clearblade-cloud-iot/src/main/java/com/clearblade/cloud/iot/v1/CreateDeviceResponse.java rename to clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/CreateDeviceResponse.java index 9d7e712a..46fbe0e2 100644 --- a/clearblade-cloud-iot/src/main/java/com/clearblade/cloud/iot/v1/CreateDeviceResponse.java +++ b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/CreateDeviceResponse.java @@ -3,7 +3,7 @@ import java.util.logging.Level; import java.util.logging.Logger; -import com.clearblade.cloud.iot.v1.SendCommandToDeviceResponse.Builder; +import org.json.simple.JSONObject; public class CreateDeviceResponse { @@ -63,11 +63,17 @@ public CreateDeviceResponse build() { * CreateDevice */ public void processRequest(CreateDeviceRequest request) { - - ProcessRequest processRequest = new ProcessRequest(); String msg = ""; - String[] requestParamsArray = request.toString().split(","); - String responseMessage = processRequest.processRequestForMethod("createDevice",requestParamsArray); + JSONObject requestParams = new JSONObject(); + JSONObject bodyParams = new JSONObject(); + ProcessRequest processRequest = new ProcessRequest(); + if(request != null) { + String logMsg = "Sending request to device :: "+request.toString(); + log.log(Level.INFO,logMsg); + requestParams = (JSONObject) request.requestParams.clone(); + bodyParams = (JSONObject) request.bodyParams.clone(); + } + String responseMessage = processRequest.processRequestForMethod("createDevice",requestParams,bodyParams); this.setHttpStatusResponse(responseMessage); if (responseMessage.equals("OK")) { this.setHttpStatusCode(200); diff --git a/clearblade-cloud-iot/src/main/java/com/clearblade/cloud/iot/v1/DeleteDeviceRequest.java b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/DeleteDeviceRequest.java similarity index 94% rename from clearblade-cloud-iot/src/main/java/com/clearblade/cloud/iot/v1/DeleteDeviceRequest.java rename to clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/DeleteDeviceRequest.java index 766b2cad..8c1284b4 100644 --- a/clearblade-cloud-iot/src/main/java/com/clearblade/cloud/iot/v1/DeleteDeviceRequest.java +++ b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/DeleteDeviceRequest.java @@ -35,7 +35,7 @@ public DeleteDeviceRequest build() { @Override public String toString() { - return "deviceName = " + this.deviceName; + return this.deviceName; } } diff --git a/clearblade-cloud-iot/src/main/java/com/clearblade/cloud/iot/v1/DeleteDeviceResponse.java b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/DeleteDeviceResponse.java similarity index 88% rename from clearblade-cloud-iot/src/main/java/com/clearblade/cloud/iot/v1/DeleteDeviceResponse.java rename to clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/DeleteDeviceResponse.java index caa861a8..fe127dc5 100644 --- a/clearblade-cloud-iot/src/main/java/com/clearblade/cloud/iot/v1/DeleteDeviceResponse.java +++ b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/DeleteDeviceResponse.java @@ -3,6 +3,8 @@ import java.util.logging.Level; import java.util.logging.Logger; +import org.json.simple.JSONObject; + public class DeleteDeviceResponse { static Logger log = Logger.getLogger(DeleteDeviceResponse.class.getName()); @@ -60,12 +62,17 @@ public DeleteDeviceResponse build() { * Mehtod used to process the request Calling processRequestForMethod - * DeleteDevice */ + @SuppressWarnings("unchecked") public void processRequest(DeleteDeviceRequest request) { - ProcessRequest processRequest = new ProcessRequest(); String msg = ""; - String[] requestParamsArray = new String[] { request.toString() }; - String responseMessage = processRequest.processRequestForMethod("deleteDevice", requestParamsArray); + ProcessRequest processRequest = new ProcessRequest(); + JSONObject requestParams = new JSONObject(); + JSONObject bodyParams = new JSONObject(); + if(request != null) { + requestParams.put("name", request.toString()); + } + String responseMessage = processRequest.processRequestForMethod("deleteDevice", requestParams, bodyParams); this.setHttpStatusResponse(responseMessage); if (responseMessage.equals("OK")) { this.setHttpStatusCode(200); diff --git a/clearblade-cloud-iot/src/main/java/com/clearblade/cloud/iot/v1/DeviceManagerClient.java b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/DeviceManagerClient.java similarity index 69% rename from clearblade-cloud-iot/src/main/java/com/clearblade/cloud/iot/v1/DeviceManagerClient.java rename to clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/DeviceManagerClient.java index 0b2b06c0..1b901bcb 100644 --- a/clearblade-cloud-iot/src/main/java/com/clearblade/cloud/iot/v1/DeviceManagerClient.java +++ b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/DeviceManagerClient.java @@ -20,7 +20,6 @@ public void sendCommandToDevice(DeviceName name, com.clearblade.cloud.iot.v1.uti SendCommandToDeviceResponse response = this.sendCommandToDevice(request); response.processRequest(request); } - /** * Print the response for sendCommandToDevice * @@ -46,7 +45,7 @@ public void createDevice(RegistryName parent, Device device) { } /** - * Print the response for createDevice + * Method used to call deleteDevice api * * @param request * @return Response Object @@ -90,5 +89,45 @@ public void getDevice(DeviceName name) { public GetDeviceResponse getDevice(GetDeviceRequest request) { return (GetDeviceResponse.Builder.newBuilder().setGetDeviceRequest(request).build()); } + + /** + * Method used to call devicesList api + * @param parent + * @return Device object + */ + public void devicesList(RegistryName parent) { + DevicesListRequest request = DevicesListRequest.Builder.newBuilder().setParent(parent).build(); + devicesList(request); + } + + /** + * Print the response for deviceList + * + * @param request + * @return Response object + */ + public DevicesListResponse devicesList(DevicesListRequest request) { + return (DevicesListResponse.Builder.newBuilder().setDevicesListRequest(request).build()); + } + + /** + * Method used to call deviceStatesList api + * @param parent + * @return Device object + */ + public void deviceStatesList(String name, int numStates) { + DeviceStatesListRequest request = DeviceStatesListRequest.Builder.newBuilder().setName(name).setNumStates(numStates).build(); + deviceStatesList(request); + } + + /** + * Print the response for deviceStatesList + * + * @param request + * @return Response object + */ + public DeviceStatesListResponse deviceStatesList(DeviceStatesListRequest request) { + return (DeviceStatesListResponse.Builder.newBuilder().setDeviceStatesListRequest(request).build()); + } } diff --git a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/DeviceStatesListRequest.java b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/DeviceStatesListRequest.java new file mode 100644 index 00000000..0ae39828 --- /dev/null +++ b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/DeviceStatesListRequest.java @@ -0,0 +1,67 @@ +package com.clearblade.cloud.iot.v1; + +import org.json.simple.JSONObject; + +public class DeviceStatesListRequest { + + private final String name; + private final String numStates; + JSONObject requestParams; + + + private DeviceStatesListRequest(Builder builder) { + this.name = builder.name; + this.numStates = builder.numStates; + } + + // Static class Builder + public static class Builder { + + /// instance fields + private String name; + private String numStates; + + public static Builder newBuilder() { + return new Builder(); + } + + private Builder() { + } + + // Setter methods + public Builder setName(String name) { + this.name = name; + return this; + } + + public Builder setNumStates(int numStates) { + this.numStates = String.valueOf(numStates); + return this; + } + + // build method to deal with outer class + // to return outer instance + public DeviceStatesListRequest build() { + return new DeviceStatesListRequest(this); + } + + } + + public JSONObject getRequestParams() { + return requestParams; + } + + public void setRequestParams(JSONObject requestParams) { + this.requestParams = requestParams; + } + + @SuppressWarnings("unchecked") + @Override + public String toString() { + requestParams = new JSONObject(); + requestParams.put("name", this.name); + requestParams.put("numStates", this.numStates.toString()); + this.setRequestParams(requestParams); + return "name="+this.name+",numStates="+this.numStates; + } +} diff --git a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/DeviceStatesListResponse.java b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/DeviceStatesListResponse.java new file mode 100644 index 00000000..28ec3924 --- /dev/null +++ b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/DeviceStatesListResponse.java @@ -0,0 +1,112 @@ +package com.clearblade.cloud.iot.v1; + +import java.util.List; +import java.util.Map; +import java.util.logging.Level; +import java.util.logging.Logger; + +import org.json.simple.JSONObject; + +import com.clearblade.cloud.iot.v1.utils.DeviceState; + +public class DeviceStatesListResponse { + + static Logger log = Logger.getLogger(DeviceStatesListResponse.class.getName()); + + private final DeviceStatesListRequest request; + private int httpStatusCode; + private String httpStatusResponse; + private List deviceStatesList; + + protected DeviceStatesListResponse(Builder builder) { + this.request = builder.request; + } + + public int getHttpStatusCode() { + return httpStatusCode; + } + + public void setHttpStatusCode(int httpStatusCode) { + this.httpStatusCode = httpStatusCode; + } + + public String getHttpStatusResponse() { + return httpStatusResponse; + } + + public void setHttpStatusResponse(String httpStatusResponse) { + this.httpStatusResponse = httpStatusResponse; + } + + // Static class Builder + public static class Builder { + + /// instance fields + private DeviceStatesListRequest request; + + public static Builder newBuilder() { + return new Builder(); + } + + private Builder() { + } + + // Setter methods + public Builder setDeviceStatesListRequest(DeviceStatesListRequest request) { + this.request = request; + return this; + } + + // build method to deal with outer class + // to return outer instance + public DeviceStatesListResponse build() { + return new DeviceStatesListResponse(this); + } + } + /** + * Mehtod used to process the request Calling processRequestForMethod - + * DevicesList + */ + @SuppressWarnings("unchecked") + public void processRequest(DeviceStatesListRequest request) { + String msg = ""; + ProcessRequest processRequest = new ProcessRequest(); + JSONObject requestParams = new JSONObject(); + JSONObject bodyParams = new JSONObject(); + if(request != null) { + log.log(Level.INFO,request.toString()); + requestParams = (JSONObject) request.requestParams.clone(); + } + String responseMessage = processRequest.processRequestForMethod("deviceStatesList", requestParams, bodyParams); + this.setHttpStatusResponse(responseMessage); + if (responseMessage.equals("OK")) { + this.setHttpStatusCode(200); + msg = "Request processed for DeviceStatesList method"; + + log.log(Level.INFO, msg); + } else { + this.setHttpStatusCode(0); + msg = "Request for DeviceStatesList failed \n" .concat(responseMessage); + log.log(Level.SEVERE, msg); + } + } + + @Override + public String toString() { + return "Http Status Code :: " + this.getHttpStatusCode() + " Http Status Response :: " + + this.getHttpStatusResponse(); + } + + public DeviceStatesListRequest getRequest() { + return request; + } + + public List getDeviceStatesList() { + return deviceStatesList; + } + + public void setDeviceStatesList(List deviceStatesList) { + this.deviceStatesList = deviceStatesList; + } + +} diff --git a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/DevicesListRequest.java b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/DevicesListRequest.java new file mode 100644 index 00000000..514f62a8 --- /dev/null +++ b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/DevicesListRequest.java @@ -0,0 +1,44 @@ +package com.clearblade.cloud.iot.v1; + +import com.clearblade.cloud.iot.v1.utils.RegistryName; + +public class DevicesListRequest { + + private final RegistryName parent; + + private DevicesListRequest(Builder builder) { + this.parent = builder.parent; + } + + // Static class Builder + public static class Builder { + + /// instance fields + private RegistryName parent; + public static Builder newBuilder() { + return new Builder(); + } + + private Builder() { + } + + // Setter methods + public Builder setParent(RegistryName parent) { + this.parent = parent; + return this; + } + + // build method to deal with outer class + // to return outer instance + public DevicesListRequest build() { + return new DevicesListRequest(this); + } + + } + + @Override + public String toString() { + return this.parent.toString(); + } + +} diff --git a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/DevicesListResponse.java b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/DevicesListResponse.java new file mode 100644 index 00000000..7de25144 --- /dev/null +++ b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/DevicesListResponse.java @@ -0,0 +1,111 @@ +package com.clearblade.cloud.iot.v1; + +import java.util.List; +import java.util.logging.Level; +import java.util.logging.Logger; + +import org.json.simple.JSONObject; + +import com.clearblade.cloud.iot.v1.utils.Device; + +public class DevicesListResponse { + + static Logger log = Logger.getLogger(DevicesListResponse.class.getName()); + + private final DevicesListRequest request; + private int httpStatusCode; + private String httpStatusResponse; + private List devicesList; + + protected DevicesListResponse(Builder builder) { + this.request = builder.request; + } + + public int getHttpStatusCode() { + return httpStatusCode; + } + + public void setHttpStatusCode(int httpStatusCode) { + this.httpStatusCode = httpStatusCode; + } + + public String getHttpStatusResponse() { + return httpStatusResponse; + } + + public void setHttpStatusResponse(String httpStatusResponse) { + this.httpStatusResponse = httpStatusResponse; + } + + // Static class Builder + public static class Builder { + + /// instance fields + private DevicesListRequest request; + + public static Builder newBuilder() { + return new Builder(); + } + + private Builder() { + } + + // Setter methods + public Builder setDevicesListRequest(DevicesListRequest request) { + this.request = request; + return this; + } + + // build method to deal with outer class + // to return outer instance + public DevicesListResponse build() { + return new DevicesListResponse(this); + } + } + + /** + * Mehtod used to process the request Calling processRequestForMethod - + * DevicesList + */ + @SuppressWarnings("unchecked") + public void processRequest(DevicesListRequest request) { + String msg = ""; + ProcessRequest processRequest = new ProcessRequest(); + JSONObject requestParams = new JSONObject(); + JSONObject bodyParams = new JSONObject(); + if(request != null) { + requestParams.put("parent", request.toString()); + requestParams.put("fieldMask", "EMPTY"); + } + String responseMessage = processRequest.processRequestForMethod("devicesList", requestParams, bodyParams); + this.setHttpStatusResponse(responseMessage); + if (responseMessage.equals("OK")) { + this.setHttpStatusCode(200); + msg = "Request processed for DevicesList method"; + + log.log(Level.INFO, msg); + } else { + this.setHttpStatusCode(0); + msg = "Request for DevicesList failed \n" .concat(responseMessage); + log.log(Level.SEVERE, msg); + } + } + + @Override + public String toString() { + return "Http Status Code :: " + this.getHttpStatusCode() + " Http Status Response :: " + + this.getHttpStatusResponse(); + } + + public DevicesListRequest getRequest() { + return request; + } + + public List getDevicesList() { + return devicesList; + } + + public void setDevicesList(List devicesList) { + this.devicesList = devicesList; + } +} diff --git a/clearblade-cloud-iot/src/main/java/com/clearblade/cloud/iot/v1/GetDeviceRequest.java b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/GetDeviceRequest.java similarity index 94% rename from clearblade-cloud-iot/src/main/java/com/clearblade/cloud/iot/v1/GetDeviceRequest.java rename to clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/GetDeviceRequest.java index 5d909f39..9da62644 100644 --- a/clearblade-cloud-iot/src/main/java/com/clearblade/cloud/iot/v1/GetDeviceRequest.java +++ b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/GetDeviceRequest.java @@ -7,7 +7,7 @@ public class GetDeviceRequest { private GetDeviceRequest(Builder builder) { this.deviceName = builder.deviceName; } - + // Static class Builder public static class Builder { @@ -36,7 +36,7 @@ public GetDeviceRequest build() { @Override public String toString() { - return "deviceName = " + this.deviceName; + return this.deviceName; } diff --git a/clearblade-cloud-iot/src/main/java/com/clearblade/cloud/iot/v1/GetDeviceResponse.java b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/GetDeviceResponse.java similarity index 87% rename from clearblade-cloud-iot/src/main/java/com/clearblade/cloud/iot/v1/GetDeviceResponse.java rename to clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/GetDeviceResponse.java index f6fcd73c..609eb37a 100644 --- a/clearblade-cloud-iot/src/main/java/com/clearblade/cloud/iot/v1/GetDeviceResponse.java +++ b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/GetDeviceResponse.java @@ -3,6 +3,8 @@ import java.util.logging.Level; import java.util.logging.Logger; +import org.json.simple.JSONObject; + import com.clearblade.cloud.iot.v1.utils.Device; public class GetDeviceResponse { @@ -64,16 +66,22 @@ public GetDeviceResponse build() { * Mehtod used to process the request Calling processRequestForMethod - * GetDevice */ + @SuppressWarnings("unchecked") public void processRequest(GetDeviceRequest request) { - - ProcessRequest processRequest = new ProcessRequest(); String msg = ""; - String[] requestParamsArray = new String[] { request.toString() }; - String responseMessage = processRequest.processRequestForMethod("getDevice", requestParamsArray); + ProcessRequest processRequest = new ProcessRequest(); + JSONObject requestParams = new JSONObject(); + JSONObject bodyParams = new JSONObject(); + if(request != null) { + requestParams.put("name", request.toString()); + requestParams.put("fieldMask", "EMPTY"); + } + String responseMessage = processRequest.processRequestForMethod("getDevice", requestParams, bodyParams); this.setHttpStatusResponse(responseMessage); if (responseMessage.equals("OK")) { this.setHttpStatusCode(200); msg = "Request processed for GetDevice method"; + log.log(Level.INFO, msg); } else { this.setHttpStatusCode(0); diff --git a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/ProcessRequest.java b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/ProcessRequest.java new file mode 100644 index 00000000..54323719 --- /dev/null +++ b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/ProcessRequest.java @@ -0,0 +1,262 @@ +package com.clearblade.cloud.iot.v1; + +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStream; +import java.io.InputStreamReader; +import java.io.OutputStream; +import java.net.ProtocolException; +import java.net.URL; + +import javax.net.ssl.HttpsURLConnection; + +import org.json.simple.JSONObject; + +import com.clearblade.cloud.iot.v1.utils.ConfigParameters; +import com.clearblade.cloud.iot.v1.utils.Constants; +import com.clearblade.cloud.iot.v1.utils.SetHttpConnection; + +public class ProcessRequest { + + URL obj; + HttpsURLConnection con; + String responseMessage; + JSONObject bodyJSONObj; + int responseCode; + ConfigParameters configParameters; + SetHttpConnection setCon; + String emptyStr; + + // Empty Constructor + public ProcessRequest() { + emptyStr = ""; + configParameters = new ConfigParameters(); + obj = null; + con = null; + setCon = null; + responseCode = 0; + responseMessage = null; + } + + /** + * Method used to get process the request when inputString and connection object + * are inputs ResponseCode - integer value is sent as return value + * + * @param methodName + * @return String - response message + */ + public String processRequestForMethod(String methodName, JSONObject requestParams, JSONObject bodyParams) { + + String finalURL = emptyStr; + String name; + String deviceNumIds; + String subfolder; + String parent; + String numStates; + + + // Setting partial URL + String urlPartial = Constants.HTTPS_URL_PREFIX.concat(configParameters.getEndPoint()) + .concat(configParameters.getBaseURL()).concat(configParameters.getSystemKey()) + .concat(configParameters.getDevicesURLExtension()); + + if (bodyParams != null && bodyParams.size() > 0) { + this.setBodyJSONObj(bodyParams); + } + if (methodName.equals(Constants.SEND_COMMAND_TO_DEVICE) && requestParams != null && requestParams.size() > 0) { + name = requestParams.get("name").toString(); + finalURL = urlPartial.concat("?name=" + name + "&method=" + methodName); + } else if (methodName.equals(Constants.CREATE_DEVICE) && requestParams != null && requestParams.size() > 0) { + deviceNumIds = requestParams.get("deviceNumIds").toString(); + subfolder = requestParams.get("subfolder").toString(); + finalURL = urlPartial.concat("?deviceNumIds=" + deviceNumIds + "&subfolder=" + subfolder); + } else if (((methodName.equals(Constants.DELETE_DEVICE)) || (methodName.equals(Constants.GET_DEVICE))) + && (requestParams != null && requestParams.size() > 0)) { + name = requestParams.get("name").toString(); + finalURL = urlPartial.concat("?name=" + name); + } else if (methodName.equals(Constants.DEVICES_LIST) && (requestParams != null && requestParams.size() > 0)) { + parent = requestParams.get("parent").toString(); + finalURL = urlPartial.concat("?parent=" + parent); + }else if (methodName.equals(Constants.DEVICE_STATES_LIST) && (requestParams != null && requestParams.size() > 0)) { + name = requestParams.get("name").toString(); + numStates = requestParams.get("numStates").toString(); + finalURL = urlPartial.concat("?name=" + name+"&numStates="+Integer.parseInt(numStates)); + } + try { + obj = new URL(finalURL); + setCon = new SetHttpConnection(); + con = setCon.getConnection(obj); + // Calling setConnectionMethod + responseMessage = setConnectionMethods(con, methodName); + } catch (Exception e) { + e.printStackTrace(); + } + return responseMessage; + } + + /** + * Set connection methods + * + * @param con + * @returning response message + */ + public String setConnectionMethods(HttpsURLConnection con, String methodName) { + + if (con != null) { + con.setRequestProperty(Constants.HTTP_REQUEST_PROPERTY_TOKEN_KEY, configParameters.getToken()); + con.setRequestProperty(Constants.HTTP_REQUEST_PROPERTY_CONTENT_TYPE_KEY, + Constants.HTTP_REQUEST_PROPERTY_CONTENT_TYPE_ACCEPT_VALUE); + con.addRequestProperty(Constants.HTTP_REQUEST_PROPERTY_ACCEPT_KEY, + Constants.HTTP_REQUEST_PROPERTY_CONTENT_TYPE_ACCEPT_VALUE); + + String methodType = ""; + if ((methodName.equals(Constants.SEND_COMMAND_TO_DEVICE) || methodName.equals(Constants.CREATE_DEVICE))) { + methodType = Constants.HTTP_REQUEST_METHOD_TYPE_POST; + } else if (methodName.equals(Constants.DELETE_DEVICE)) { + methodType = Constants.HTTP_REQUEST_METHOD_TYPE_DELETE; + } else if ((methodName.equals(Constants.GET_DEVICE)) || (methodName.equals(Constants.DEVICES_LIST)) || (methodName.equals(Constants.DEVICE_STATES_LIST))) { + methodType = Constants.HTTP_REQUEST_METHOD_TYPE_GET; + } + try { + con.setRequestMethod(methodType); + } catch (ProtocolException e) { + e.printStackTrace(); + } + + // SetOutput to connection + con.setDoOutput(true); + + // Get responseCode from Connection + if (methodName.equals(Constants.SEND_COMMAND_TO_DEVICE) || methodName.equals(Constants.CREATE_DEVICE)) { + responseMessage = getResponseForSendCommandCreateDevice(con); + } else if (methodName.equals(Constants.DELETE_DEVICE)) { + responseMessage = getResponseForDeleteDevice(con); + } else if (methodName.equals(Constants.GET_DEVICE)) { + responseMessage = getResponseForGetRequest(con); + }else if (methodName.equals(Constants.DEVICES_LIST)) { + responseMessage = getResponseForGetRequest(con); + }else if (methodName.equals(Constants.DEVICE_STATES_LIST)) { + responseMessage = getResponseForGetRequest(con); + } + } + return responseMessage; + } + + /** + * Method used to get Response when inputString and connection object are inputs + * ResponseMessage - String value is sent as return value + * + * @param con + * @param inputString + * @return responseMessage + */ + public String getResponseForGetRequest(HttpsURLConnection con) { + StringBuilder response = new StringBuilder(); + InputStream inStr = null; + BufferedReader in = null; + try { + responseCode = con.getResponseCode(); + if (responseCode != 200) { + if (con.getErrorStream() != null) { + inStr = con.getErrorStream(); + } else if (con.getInputStream() != null) { + inStr = con.getInputStream(); + } + in = new BufferedReader(new InputStreamReader(inStr)); + String inputLine; + while ((inputLine = in.readLine()) != null) { + response.append(inputLine); + } + in.close(); + responseMessage = response.toString(); + } else if (responseCode == 200) { + + String splitResponse = ""; + String inputLine = ""; + if (con.getInputStream() != null) { + in = new BufferedReader(new InputStreamReader(con.getInputStream())); + } + if(in != null) { + while ((inputLine = in.readLine()) != null) { + response.append(inputLine); + splitResponse = splitResponse.concat(inputLine); + } + System.out.println(splitResponse); + in.close(); + } + responseMessage = "OK"; + } + + } catch (IOException e) { + e.printStackTrace(); + } + return responseMessage; + } + + public String getResponseForSendCommandCreateDevice(HttpsURLConnection con) { + StringBuilder response = new StringBuilder(); + try (OutputStream os = con.getOutputStream()) { + JSONObject js = this.getBodyJSONObj(); + byte[] input = js.toString().getBytes("utf-8"); + os.write(input, 0, input.length); + os.flush(); + responseCode = con.getResponseCode(); + if (responseCode != 200) { + BufferedReader in = null; + if (con.getErrorStream() != null) { + in = new BufferedReader(new InputStreamReader(con.getErrorStream())); + } else if (con.getInputStream() != null) { + in = new BufferedReader(new InputStreamReader(con.getInputStream())); + } + String inputLine; + if (in != null) { + while ((inputLine = in.readLine()) != null) { + response.append(inputLine); + } + } + responseMessage = response.toString(); + } else if (responseCode == 200) { + responseMessage = "OK"; + } + } catch (IOException e1) { + e1.printStackTrace(); + } + return responseMessage; + } + + public String getResponseForDeleteDevice(HttpsURLConnection con) { + StringBuilder response = new StringBuilder(); + try { + responseCode = con.getResponseCode(); + if (responseCode != 200) { + BufferedReader in = null; + if (con.getErrorStream() != null) { + in = new BufferedReader(new InputStreamReader(con.getErrorStream())); + } else if (con.getInputStream() != null) { + in = new BufferedReader(new InputStreamReader(con.getInputStream())); + } + String inputLine; + if (in != null) { + while ((inputLine = in.readLine()) != null) { + response.append(inputLine); + } + } + responseMessage = response.toString(); + } else if (responseCode == 200) { + responseMessage = "OK"; + } + } catch (IOException e) { + e.printStackTrace(); + } + return responseMessage; + } + + public JSONObject getBodyJSONObj() { + return bodyJSONObj; + } + + public void setBodyJSONObj(JSONObject bodyJSONObj) { + this.bodyJSONObj = bodyJSONObj; + } + +} \ No newline at end of file diff --git a/clearblade-cloud-iot/src/main/java/com/clearblade/cloud/iot/v1/SendCommandToDeviceRequest.java b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/SendCommandToDeviceRequest.java similarity index 74% rename from clearblade-cloud-iot/src/main/java/com/clearblade/cloud/iot/v1/SendCommandToDeviceRequest.java rename to clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/SendCommandToDeviceRequest.java index 7506306e..a00b1baa 100644 --- a/clearblade-cloud-iot/src/main/java/com/clearblade/cloud/iot/v1/SendCommandToDeviceRequest.java +++ b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/SendCommandToDeviceRequest.java @@ -2,6 +2,8 @@ import java.util.Arrays; +import org.json.simple.JSONObject; + import com.clearblade.cloud.iot.v1.utils.ByteString; import com.clearblade.cloud.iot.v1.utils.DeviceName; @@ -12,6 +14,8 @@ public class SendCommandToDeviceRequest { private final byte[] binaryDataByte; private final String subfolder; private final String deviceName; + public JSONObject requestParams; + public JSONObject bodyParams; private SendCommandToDeviceRequest(Builder builder) { this.name = builder.name; @@ -69,29 +73,40 @@ public Builder setDeviceName(String deviceName) { public SendCommandToDeviceRequest build() { return new SendCommandToDeviceRequest(this); } - } + } + @SuppressWarnings("unchecked") @Override public String toString() { - String requestParams=""; - String bodyParams=""; + requestParams = new JSONObject(); + bodyParams = new JSONObject(); + + String dName = ""; + String bData = null; + if(this.name != null) { - requestParams = requestParams.concat("name = " + this.name.getDevice()); + dName = this.name.getDevice(); }else if(this.deviceName != null) { - requestParams = requestParams.concat("deviceName = "+this.deviceName); + dName = this.deviceName; } if(this.binaryData != null) { - bodyParams = bodyParams.concat(",binaryData="); - bodyParams = bodyParams.concat(new String(this.binaryData.getBinaryDataArray())); + bData = new String(this.binaryData.getBinaryDataArray()); }else if(this.binaryDataByte != null) { if(this.binaryDataByte.length == 0){ - bodyParams = bodyParams.concat(",binaryDataByte=EMPTY"); + bData = "EMPTY"; }else { - bodyParams = bodyParams.concat(",binaryDataByte="+Arrays.toString(this.binaryDataByte)); + bData = Arrays.toString(this.binaryDataByte); } } - bodyParams = bodyParams.concat(",subfolder = "+this.subfolder); - return requestParams.concat(bodyParams); + requestParams.put("name", dName); + bodyParams.put("binaryData", bData); + bodyParams.put("subfolder", subfolder); + + return "name = "+dName+", binaryData = "+bData+", subfolder = "+subfolder; + } + + + } diff --git a/clearblade-cloud-iot/src/main/java/com/clearblade/cloud/iot/v1/SendCommandToDeviceResponse.java b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/SendCommandToDeviceResponse.java similarity index 83% rename from clearblade-cloud-iot/src/main/java/com/clearblade/cloud/iot/v1/SendCommandToDeviceResponse.java rename to clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/SendCommandToDeviceResponse.java index 0eb4e46b..66ffb519 100644 --- a/clearblade-cloud-iot/src/main/java/com/clearblade/cloud/iot/v1/SendCommandToDeviceResponse.java +++ b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/SendCommandToDeviceResponse.java @@ -3,6 +3,8 @@ import java.util.logging.Level; import java.util.logging.Logger; +import org.json.simple.JSONObject; + public class SendCommandToDeviceResponse { static Logger log = Logger.getLogger(SendCommandToDeviceResponse.class.getName()); @@ -60,11 +62,21 @@ public SendCommandToDeviceResponse build() { * Mehtod used to process the request * Calling processRequestForMethod - sendCommandToDevice */ + public void processRequest(SendCommandToDeviceRequest request) { - ProcessRequest processRequest = new ProcessRequest(); String msg = ""; - String[] requestParamsArray = request.toString().split(","); - String responseMessage = processRequest.processRequestForMethod("sendCommandToDevice",requestParamsArray); + JSONObject requestParams = new JSONObject(); + JSONObject bodyParams = new JSONObject(); + ProcessRequest processRequest = new ProcessRequest(); + + if(request != null) { + String logMsg = "Sending request to device :: "+request.toString(); + log.log(Level.INFO,logMsg); + requestParams = (JSONObject) request.requestParams.clone(); + bodyParams = (JSONObject) request.bodyParams.clone(); + } + + String responseMessage = processRequest.processRequestForMethod("sendCommandToDevice",requestParams,bodyParams); this.setHttpStatusResponse(responseMessage); if (responseMessage.equals("OK")) { msg = "Request processed successfully for SendCommandToDevice method"; diff --git a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/test/DeviceManagerClientTest.java b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/test/DeviceManagerClientTest.java new file mode 100644 index 00000000..d066d8d0 --- /dev/null +++ b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/test/DeviceManagerClientTest.java @@ -0,0 +1,123 @@ +package com.clearblade.cloud.iot.v1.test; + +import java.util.logging.Logger; + +import org.junit.Assert; +import org.junit.Test; + +import com.clearblade.cloud.iot.v1.CreateDeviceRequest; +import com.clearblade.cloud.iot.v1.CreateDeviceResponse; +import com.clearblade.cloud.iot.v1.DeviceManagerClient; +import com.clearblade.cloud.iot.v1.SendCommandToDeviceRequest; +import com.clearblade.cloud.iot.v1.SendCommandToDeviceResponse; +import com.clearblade.cloud.iot.v1.utils.ByteString; +import com.clearblade.cloud.iot.v1.utils.Device; +import com.clearblade.cloud.iot.v1.utils.DeviceName; +import com.clearblade.cloud.iot.v1.utils.RegistryName; + +class DeviceManagerClientTest { + + static Logger log = Logger.getLogger(DeviceManagerClientTest.class.getName()); + DeviceManagerClient client = null; + String project; + String location; + String registry; + String name; + String bData; + + public void setUP() { + project = "ingressdevelopmentenv"; + location = "central1"; + registry = "Rashmi_Registry_Test"; + name = "Rashmi_Device_Test"; + bData = "c2VuZEZ1bm55TWVzc2FnZVRvRGV2aWNl"; + } + + + @Test + public void sendCommandToDeviceTestFail() { + setUP(); + client = new DeviceManagerClient(); + + DeviceName deviceName = DeviceName.of(project, location, registry, name); + ByteString binaryData = new ByteString(bData); + + SendCommandToDeviceRequest expectedRequest = SendCommandToDeviceRequest.Builder.newBuilder().setDeviceName(name) + .setBinaryData(binaryData).setSubfolder("").build(); + + SendCommandToDeviceResponse expectedResponse = SendCommandToDeviceResponse.Builder.newBuilder() + .setSendCommandToDeviceRequest(expectedRequest).build(); + + expectedResponse.setHttpStatusCode(200); + expectedResponse.setHttpStatusResponse("OK"); + + SendCommandToDeviceResponse actualResponse; + DeviceName actualDeviceName = DeviceName.of(project, location, registry, "Rashmi_Device"); + ByteString actualBinaryData = new ByteString(""); + SendCommandToDeviceRequest actualRequest = SendCommandToDeviceRequest.Builder.newBuilder() + .setName(actualDeviceName).setBinaryData(actualBinaryData).setSubfolder("").build(); + actualResponse = client.sendCommandToDevice(actualRequest); + actualResponse.processRequest(actualRequest); + + Assert.assertEquals(deviceName.getDevice(), actualDeviceName.getDevice()); + Assert.assertEquals(binaryData.getBinaryDataArray(), actualBinaryData.getBinaryDataArray()); + Assert.assertTrue((actualResponse.getHttpStatusResponse()).equals(expectedResponse.getHttpStatusResponse())); + } + + @Test + public void sendCommandToDeviceTestPass() { + DeviceName deviceName = DeviceName.of(project, location, registry, name); + ByteString binaryData = new ByteString(bData); + + SendCommandToDeviceRequest expectedRequest = SendCommandToDeviceRequest.Builder.newBuilder().setDeviceName(name) + .setBinaryData(binaryData).setSubfolder("").build(); + + SendCommandToDeviceResponse expectedResponse = SendCommandToDeviceResponse.Builder.newBuilder() + .setSendCommandToDeviceRequest(expectedRequest).build(); + + expectedResponse.setHttpStatusCode(200); + expectedResponse.setHttpStatusResponse("OK"); + + SendCommandToDeviceResponse actualResponse = SendCommandToDeviceResponse.Builder.newBuilder().build(); + DeviceName actualDeviceName = DeviceName.of(project, location, registry, name); + ByteString actualBinaryData = binaryData; + SendCommandToDeviceRequest actualRequest = SendCommandToDeviceRequest.Builder.newBuilder() + .setName(actualDeviceName).setBinaryData(actualBinaryData).setSubfolder("").build(); + actualResponse.processRequest(actualRequest); + + Assert.assertEquals(deviceName.getDevice(), actualDeviceName.getDevice()); + Assert.assertEquals(binaryData.getBinaryDataArray(), actualBinaryData.getBinaryDataArray()); + Assert.assertTrue((actualResponse.getHttpStatusResponse()).equals(expectedResponse.getHttpStatusResponse())); + } + + @Test + public void createDeviceTest() { + setUP(); + RegistryName expectedParent = RegistryName.of(project, location, "Rashmi_Registry"); + Device expectedDevice = + Device.newBuilder() + .setId("id3355") + .setName(DeviceName.of(project, location, registry, name).toString()) + .setNumId(-1034366860) + .build(); + CreateDeviceRequest expectedRequest = CreateDeviceRequest.Builder.newBuilder().setParent(expectedParent).setDevice(expectedDevice).build(); + CreateDeviceResponse expectedResponse = client.createDevice(expectedRequest); + + RegistryName parent = RegistryName.of(project, location, registry); + + Device device = Device.newBuilder().build(); + CreateDeviceRequest actualRequest = CreateDeviceRequest.Builder.newBuilder() + .setParent(parent).setDevice(device).build(); + CreateDeviceResponse actualResponse = client.createDevice(actualRequest); + + Assert.assertEquals(expectedResponse.getHttpStatusResponse(), actualResponse.getHttpStatusResponse()); + + Assert.assertEquals(expectedParent.getRegistry(), parent.getRegistry()); + Assert.assertEquals(expectedDevice, device); + Assert.assertTrue(actualResponse.getHttpStatusResponse().equals(expectedResponse.getHttpStatusResponse())); + } + + +} + + diff --git a/clearblade-cloud-iot/src/main/java/com/clearblade/cloud/iot/v1/utils/ByteString.java b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/utils/ByteString.java similarity index 100% rename from clearblade-cloud-iot/src/main/java/com/clearblade/cloud/iot/v1/utils/ByteString.java rename to clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/utils/ByteString.java diff --git a/clearblade-cloud-iot/src/main/java/com/clearblade/cloud/iot/v1/utils/ConfigParameters.java b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/utils/ConfigParameters.java similarity index 75% rename from clearblade-cloud-iot/src/main/java/com/clearblade/cloud/iot/v1/utils/ConfigParameters.java rename to clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/utils/ConfigParameters.java index a56439bc..4ac3ff14 100644 --- a/clearblade-cloud-iot/src/main/java/com/clearblade/cloud/iot/v1/utils/ConfigParameters.java +++ b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/utils/ConfigParameters.java @@ -11,6 +11,9 @@ public class ConfigParameters { private String token; private String baseURL; private String devicesURLExtension; + private String project; + private String location; + private String registry; // Fields used to fetch values from Properties file Properties properties; @@ -49,13 +52,16 @@ public void getConfigurations() { * Method used to set values in Constants setter method */ public void setValues() { - //get Configurations uploaded from config.properties file + // get Configurations uploaded from config.properties file getConfigurations(); this.setEndPoint(properties.getProperty("endPoint")); this.setSystemKey(properties.getProperty("systemKey")); this.setToken(properties.getProperty("token")); this.setBaseURL(properties.getProperty("baseURL")); this.setDevicesURLExtension(properties.getProperty("devicesURLExtension")); + this.setProject(properties.getProperty("project")); + this.setLocation(properties.getProperty("location")); + this.setRegistry(properties.getProperty("registry")); } public String getEndPoint() { @@ -98,4 +104,28 @@ public void setDevicesURLExtension(String devicesURLExtension) { this.devicesURLExtension = devicesURLExtension; } + public String getProject() { + return project; + } + + public void setProject(String project) { + this.project = project; + } + + public String getLocation() { + return location; + } + + public void setLocation(String location) { + this.location = location; + } + + public String getRegistry() { + return registry; + } + + public void setRegistry(String registry) { + this.registry = registry; + } + } diff --git a/clearblade-cloud-iot/src/main/java/com/clearblade/cloud/iot/v1/utils/Constants.java b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/utils/Constants.java similarity index 89% rename from clearblade-cloud-iot/src/main/java/com/clearblade/cloud/iot/v1/utils/Constants.java rename to clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/utils/Constants.java index 28e18e68..c73cb309 100644 --- a/clearblade-cloud-iot/src/main/java/com/clearblade/cloud/iot/v1/utils/Constants.java +++ b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/utils/Constants.java @@ -8,6 +8,8 @@ private Constants() {} public static final String CREATE_DEVICE = "createDevice"; public static final String DELETE_DEVICE = "deleteDevice"; public static final String GET_DEVICE = "getDevice"; + public static final String DEVICES_LIST = "devicesList"; + public static final String DEVICE_STATES_LIST = "deviceStatesList"; // Constants used for setting up http connection - for common use public static final String HTTPS_URL_PREFIX = "https://"; diff --git a/clearblade-cloud-iot/src/main/java/com/clearblade/cloud/iot/v1/utils/Device.java b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/utils/Device.java similarity index 59% rename from clearblade-cloud-iot/src/main/java/com/clearblade/cloud/iot/v1/utils/Device.java rename to clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/utils/Device.java index 5371ec3f..2d46d101 100644 --- a/clearblade-cloud-iot/src/main/java/com/clearblade/cloud/iot/v1/utils/Device.java +++ b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/utils/Device.java @@ -1,5 +1,6 @@ package com.clearblade.cloud.iot.v1.utils; +import java.sql.Timestamp; import java.util.ArrayList; import java.util.List; @@ -8,7 +9,14 @@ public class Device { private final String id; private final String name; private final int numId; - private final List credentials; + private final List credentials; + private final Timestamp lastHeartbeatTime; + private final Timestamp lastEventTime; + private final Timestamp lastStateTime; + private final Timestamp lastConfigAckTime; + private final Timestamp lastConfigSendTime; + private final boolean blocked; + private final Timestamp lastErrorTime; private final List lastErrorStatus; private final List config; private final List state; @@ -20,7 +28,14 @@ public Device() { id = ""; name = ""; numId = 0; - credentials = null; + credentials = new ArrayList<>(); + lastHeartbeatTime = new Timestamp(0); + lastEventTime = new Timestamp(0); + lastStateTime = new Timestamp(0); + lastConfigAckTime = new Timestamp(0); + lastConfigSendTime = new Timestamp(0); + blocked = false; + lastErrorTime = new Timestamp(0); lastErrorStatus = new ArrayList<>(); config = new ArrayList<>(); state = new ArrayList<>(); @@ -34,6 +49,13 @@ private Device(Builder builder) { name = builder.getName(); numId = builder.getNumId(); credentials = builder.getCredentials(); + lastHeartbeatTime = builder.getLastHeartbeatTime(); + lastEventTime = builder.getLastEventTime(); + lastStateTime = builder.getLastStateTime(); + lastConfigAckTime = builder.getLastConfigAckTime(); + lastConfigSendTime = builder.getLastConfigSendTime(); + blocked = builder.isBlocked(); + lastErrorTime = builder.getLastErrorTime(); lastErrorStatus = builder.getLastErrorStatus(); config = builder.getConfig(); state = builder.getState(); @@ -51,11 +73,11 @@ public Builder toBuilder() { return new Builder(this); } - public static Device of(String id, String name, int numId, List credentials, List lastErrorStatus,List config, List state, int logLevel, List metadata, List gatewayConfig) { + public static Device of(String id, String name, int numId, List credentials, List lastErrorStatus,List config, List state, int logLevel, List metadata, List gatewayConfig) { return newBuilder().setId(id).setName(name).setNumId(numId).setCredentials(credentials).setLastErrorStatus(lastErrorStatus).setConfig(config).setState(state).setLogLevel(logLevel).setMetadata(metadata).setGatewayConfig(gatewayConfig).build(); } - public static String format(String id, String name, int numId, List credentials, List lastErrorStatus,List config, List state, int logLevel, List metadata, List gatewayConfig) { + public static String format(String id, String name, int numId, List credentials, List lastErrorStatus,List config, List state, int logLevel, List metadata, List gatewayConfig) { return newBuilder().setId(id).setName(name).setNumId(numId).setCredentials(credentials).setLastErrorStatus(lastErrorStatus).setConfig(config).setState(state).setLogLevel(logLevel).setMetadata(metadata).setGatewayConfig(gatewayConfig).build() .toString(); } @@ -68,7 +90,14 @@ public static class Builder { private String id; private String name; private int numId; - private List credentials; + private List credentials; + private Timestamp lastHeartbeatTime; + private Timestamp lastEventTime; + private Timestamp lastStateTime; + private Timestamp lastConfigAckTime; + private Timestamp lastConfigSendTime; + private boolean blocked; + private Timestamp lastErrorTime; private List lastErrorStatus; private List config; private List state; @@ -93,8 +122,36 @@ public int getNumId() { return numId; } - public List getCredentials() { + public List getCredentials() { return credentials; + } + + public Timestamp getLastHeartbeatTime() { + return lastHeartbeatTime; + } + + public Timestamp getLastEventTime() { + return lastEventTime; + } + + public Timestamp getLastStateTime() { + return lastStateTime; + } + + public Timestamp getLastConfigAckTime() { + return lastConfigAckTime; + } + + public Timestamp getLastConfigSendTime() { + return lastConfigSendTime; + } + + public boolean isBlocked() { + return blocked; + } + + public Timestamp getLastErrorTime() { + return lastErrorTime; } public List getLastErrorStatus() { @@ -140,7 +197,7 @@ public Builder setNumId(int numId) { return this; } - public Builder setCredentials(List credentials) { + public Builder setCredentials(List credentials) { this.credentials = credentials; return this; } @@ -179,6 +236,13 @@ private Builder(Device device) { this.name = device.name; this.numId = device.numId; this.credentials = device.credentials; + this.lastHeartbeatTime = device.lastHeartbeatTime; + this.lastEventTime = device.lastEventTime; + this.lastStateTime = device.lastStateTime; + this.lastConfigAckTime = device.lastConfigAckTime; + this.lastConfigSendTime = device.lastConfigSendTime; + this.blocked = device.blocked; + this.lastErrorTime = device.lastErrorTime; this.lastErrorStatus = device.lastErrorStatus; this.config = device.config; this.state = device.state; @@ -191,4 +255,17 @@ public Device build() { return new Device(this); } } + @Override + public String toString() { + String deviceStr =""; + deviceStr = deviceStr.concat("id="+this.id+",name="+this.name+",numId="+this.numId+",credentials="+this.credentials + +",lastHeartbeatTime="+this.lastHeartbeatTime+",lastEventTime="+this.lastEventTime + +",lastStateTime="+this.lastStateTime+",lastConfigAckTime="+this.lastConfigAckTime + +",lastConfigSendTime="+this.lastConfigSendTime+",blocked="+this.blocked + +",lastErrorTime="+this.lastErrorTime + + ",lastErrorStatus="+this.lastErrorStatus+",config="+this.config + +",state="+this.state+",logLevel="+this.logLevel+",metadata="+this.metadata + +",gatewayConfig="+this.gatewayConfig); + return deviceStr; + } } diff --git a/clearblade-cloud-iot/src/main/java/com/clearblade/cloud/iot/v1/utils/DeviceName.java b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/utils/DeviceName.java similarity index 100% rename from clearblade-cloud-iot/src/main/java/com/clearblade/cloud/iot/v1/utils/DeviceName.java rename to clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/utils/DeviceName.java diff --git a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/utils/DeviceState.java b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/utils/DeviceState.java new file mode 100644 index 00000000..81041c01 --- /dev/null +++ b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/utils/DeviceState.java @@ -0,0 +1,45 @@ +package com.clearblade.cloud.iot.v1.utils; + +public class DeviceState { + private final ByteString binaryData; + + public DeviceState(Builder builder) { + binaryData = builder.getBinaryData(); + } + + public ByteString getBinaryData() { + return binaryData; + } + + public static Builder newBuilder() { + return new Builder(); + } + + public Builder toBuilder() { + return new Builder(this); + } + + public static class Builder { + private ByteString binaryData; + + protected Builder() { + } + + public ByteString getBinaryData() { + return binaryData; + } + + public Builder setBinaryData(ByteString binaryData) { + this.binaryData = binaryData; + return this; + } + private Builder(DeviceState deviceState) { + this.binaryData = deviceState.binaryData; + } + + public DeviceState build() { + return new DeviceState(this); + } + } + +} diff --git a/clearblade-cloud-iot/src/main/java/com/clearblade/cloud/iot/v1/utils/RegistryName.java b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/utils/RegistryName.java similarity index 94% rename from clearblade-cloud-iot/src/main/java/com/clearblade/cloud/iot/v1/utils/RegistryName.java rename to clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/utils/RegistryName.java index bdfbb393..ea886db7 100644 --- a/clearblade-cloud-iot/src/main/java/com/clearblade/cloud/iot/v1/utils/RegistryName.java +++ b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/utils/RegistryName.java @@ -96,5 +96,8 @@ public RegistryName build() { return new RegistryName(this); } } - + @Override + public String toString() { + return "projects/"+this.getProject()+"/locations/"+this.getLocation(); + } } diff --git a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/utils/SetHttpConnection.java b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/utils/SetHttpConnection.java new file mode 100644 index 00000000..9ba92993 --- /dev/null +++ b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/utils/SetHttpConnection.java @@ -0,0 +1,23 @@ +package com.clearblade.cloud.iot.v1.utils; + +import java.io.IOException; +import java.net.URL; + +import javax.net.ssl.HttpsURLConnection; + +public class SetHttpConnection { + public HttpsURLConnection con; + + public SetHttpConnection() { + con = null; + } + + public HttpsURLConnection getConnection(URL url) { + try { + con = (HttpsURLConnection) url.openConnection(); + } catch (IOException e) { + e.printStackTrace(); + } + return con; + } +} diff --git a/clearblade-cloud-iot/src/main/java/config.properties b/clearblade-cloud-iot/src/config.properties similarity index 84% rename from clearblade-cloud-iot/src/main/java/config.properties rename to clearblade-cloud-iot/src/config.properties index 5fbd2d44..4df9cbb6 100644 --- a/clearblade-cloud-iot/src/main/java/config.properties +++ b/clearblade-cloud-iot/src/config.properties @@ -1,9 +1,9 @@ endPoint=iot-sandbox.clearblade.com:443 systemKey=fedbc9b40cde90befbd9b2dfde9d01 token=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1aWQiOiI4NmRjYzliNDBjOWVkMmI4YWFmZmMwOWRhMmNkMDEiLCJzaWQiOiJmZTdkNWIyMy1hODg4LTQ2NGUtOGE4MC01ZWM1NTYwOTBjZTIiLCJ1dCI6MiwidHQiOjEsImV4cCI6LTEsImlhdCI6MTY2NTc0MjU5NX0.osrsmcqunC6IMfgLfZis0UlC4s7W4mmKe73mq_SSJ8Q -#project=ingressdevelopmentenv -#location=us-central1 -#registry=Rashmi_Registry_Test +project=ingressdevelopmentenv +location=us-central1 +registry=Rashmi_Registry_Test #deviceName=Rashmi_Device_Test diff --git a/clearblade-cloud-iot/src/main/java/com/clearblade/cloud/iot/v1/CreateDeviceRequest.java b/clearblade-cloud-iot/src/main/java/com/clearblade/cloud/iot/v1/CreateDeviceRequest.java deleted file mode 100644 index 0623eb75..00000000 --- a/clearblade-cloud-iot/src/main/java/com/clearblade/cloud/iot/v1/CreateDeviceRequest.java +++ /dev/null @@ -1,105 +0,0 @@ -package com.clearblade.cloud.iot.v1; - -import java.util.Arrays; - -import com.clearblade.cloud.iot.v1.utils.Device; -import com.clearblade.cloud.iot.v1.utils.RegistryName; - -public class CreateDeviceRequest { - private final RegistryName parent; - private final Device device; - private final String subfolder; - private String deviceId; - private String deviceName; - private int deviceNumId; - - private CreateDeviceRequest(Builder builder) { - this.parent = builder.parent; - this.device = builder.device; - this.subfolder = builder.subfolder; - } - - // Static class Builder - public static class Builder { - - /// instance fields - private RegistryName parent; - private Device device; - private String subfolder; - - public static Builder newBuilder() { - return new Builder(); - } - - private Builder() { - } - - // Setter methods - public Builder setParent(RegistryName parent) { - this.parent = parent; - return this; - } - - public Builder setDevice(Device device) { - this.device = device; - return this; - } - - public Builder setSubfolder(String subfolder) { - this.subfolder = subfolder; - return this; - } - - // build method to deal with outer class - // to return outer instance - public CreateDeviceRequest build() { - return new CreateDeviceRequest(this); - } - } - - @Override - public String toString() { - String str = ""; - if(parent != null) { - str = str.concat("parent ="+parent.getRegistry()); - } - if(device != null) { - this.setDeviceId(this.device.toBuilder().getId()); - this.setDeviceName(this.device.toBuilder().getName()); - this.setDeviceNumId(this.device.toBuilder().getNumId()); - str = str.concat(",id="+this.getDeviceId()+",name="+this.getDeviceName()+",numId="+this.getDeviceNumId()); - }else { - str = str.concat(",device =EMPTY"); - } - if(subfolder != null) { - str = str.concat(",subfolder ="+subfolder); - }else { - str = str.concat(",subfolder =EMPTY"); - } - return str; - } - - public String getDeviceId() { - return deviceId; - } - - public void setDeviceId(String deviceId) { - this.deviceId = deviceId; - } - - public String getDeviceName() { - return deviceName; - } - - public void setDeviceName(String deviceName) { - this.deviceName = deviceName; - } - - public int getDeviceNumId() { - return deviceNumId; - } - - public void setDeviceNumId(int deviceNumId) { - this.deviceNumId = deviceNumId; - } -} diff --git a/clearblade-cloud-iot/src/main/java/com/clearblade/cloud/iot/v1/ProcessRequest.java b/clearblade-cloud-iot/src/main/java/com/clearblade/cloud/iot/v1/ProcessRequest.java deleted file mode 100644 index ec92ee4c..00000000 --- a/clearblade-cloud-iot/src/main/java/com/clearblade/cloud/iot/v1/ProcessRequest.java +++ /dev/null @@ -1,242 +0,0 @@ -package com.clearblade.cloud.iot.v1; - -import java.io.BufferedReader; -import java.io.IOException; -import java.io.InputStreamReader; -import java.io.OutputStream; -import java.net.MalformedURLException; -import java.net.ProtocolException; -import java.net.URL; -import java.nio.charset.Charset; - -import javax.net.ssl.HttpsURLConnection; - -import com.clearblade.cloud.iot.v1.utils.ConfigParameters; -import com.clearblade.cloud.iot.v1.utils.Constants; -import com.clearblade.cloud.iot.v1.utils.SetHttpConnection; - -public class ProcessRequest { - - URL obj; - HttpsURLConnection con; - String responseMessage; - int responseCode; - String jsonInputString; - String subfolderStr; - String inputString; - String deviceId; - String deviceName; - String deviceNumId; - String bodyParams; - ConfigParameters configParameters; - - // Empty Constructor - public ProcessRequest() { - configParameters = new ConfigParameters(); - obj = null; - con = null; - responseCode = 0; - inputString = null; - responseMessage = null; - jsonInputString = null; - subfolderStr = null; - deviceId = null; - deviceName = null; - deviceNumId = null; - } - - public String setRequestBodyParams(String methodName, String[] requestParamsArray) { - String requestParams = ""; - String bodyParamsStr = "{"; - if (methodName.equals(Constants.SEND_COMMAND_TO_DEVICE)) { - if (requestParamsArray != null) { - for (int i = 0; i < requestParamsArray.length; i++) { - String element = requestParamsArray[i]; - if (element.contains("name") || element.contains("deviceName")) { - String subStr = element.substring(element.indexOf("=") + 1, element.length()).trim(); - requestParams = requestParams.concat(subStr); - } else { - if (element.contains("binaryData") || element.contains("binaryDataByte")) { - String subStr = element.substring(element.indexOf("=") + 1, element.length()).trim(); - if(subStr.equals("EMPTY")) { - bodyParamsStr = bodyParamsStr.concat("binaryData:\"\""); - }else { - bodyParamsStr = bodyParamsStr.concat("binaryData:" + subStr); - } - } - if (element.contains(Constants.SUBFOLDER)) { - subfolderStr = element.substring(element.indexOf("=") + 1, element.length()).trim(); - bodyParamsStr = bodyParamsStr.concat(",subfolder:\"" + subfolderStr+"\""); - } - } - } - bodyParamsStr = bodyParamsStr.concat("}"); - this.setBodyParams(bodyParamsStr); - - } - } else if (methodName.equals(Constants.CREATE_DEVICE)) { - String bodyStr2 = ""; - if (requestParamsArray != null) { - for (String element : requestParamsArray) { - - if (element.contains("parent")) { - requestParams = requestParams.concat("112,113"); - } - if (element.contains("id")) { - deviceId = element.substring(element.indexOf("=") + 1, element.length()).trim(); - bodyStr2 = bodyStr2.concat("{\"id\":\"" + deviceId+"\""); - } - if (element.contains("name")) { - deviceName = element.substring(element.indexOf("=") + 1, element.length()).trim(); - bodyStr2 = bodyStr2.concat(",\"name\":\"" + deviceName+"\""); - } - if (element.contains("numId")) { - deviceNumId = element.substring(element.indexOf("=") + 1, element.length()).trim(); - bodyStr2 = bodyStr2.concat(",\"numId\":" + deviceNumId); - } - if (element.contains("subfolder")) { - subfolderStr = element.substring(element.indexOf("=") + 1, element.length()).trim(); - if(subfolderStr.equals("EMPTY")) { - bodyStr2 = bodyStr2.concat(",\"subfolder\":\"\""); - }else { - bodyStr2 = bodyStr2.concat(",\"subfolder\":" + subfolderStr); - } - System.out.println(bodyStr2); - } - } - bodyStr2 = bodyStr2.concat(", \"credentials\":[]"); - bodyStr2 = bodyStr2.concat(", \"lastErrorStatus\":{}"); - bodyStr2 = bodyStr2.concat(", \"config\":{}"); - bodyStr2 = bodyStr2.concat(", \"state\":{}"); - bodyStr2 = bodyStr2.concat(", \"logLevel\":\"NONE\""); - bodyStr2 = bodyStr2.concat(", \"metadata\":{}"); - bodyStr2 = bodyStr2.concat(", \"gatewayConfig\":{}"); - bodyStr2 = bodyStr2.concat("}"); - - if (bodyStr2 != null) { - this.setBodyParams(bodyStr2); - } - System.out.println(requestParams); - System.out.println(bodyStr2); - } - } - return requestParams; - } - - /** - * Method used to get process the request when inputString and connection object - * are inputs ResponseCode - integer value is sent as return value - * - * @param methodName - * @return String - response message - */ - // https://iot-sandbox.clearblade.com:443/api/v/4/webhook/execute/fedbc9b40cde90befbd9b2dfde9d01/cloudiot_devices?name=Rashmi_Device_Test&method=sendCommandToDevice - public String processRequestForMethod(String methodName, String[] requestParamsArray) { - - // Setting up request params and body params - String requestParams = setRequestBodyParams(methodName, requestParamsArray); - String URLPartial = ""; - // Setting partial URL - URLPartial = URLPartial.concat(Constants.HTTPS_URL_PREFIX).concat(configParameters.getEndPoint()) - .concat(configParameters.getBaseURL()).concat(configParameters.getSystemKey()) - .concat(configParameters.getDevicesURLExtension()); - - String finalURL = ""; - if (methodName.equals(Constants.SEND_COMMAND_TO_DEVICE)) { - finalURL = URLPartial.concat("?name=" + requestParams + "&method=" + methodName); - } else if (methodName.equals(Constants.CREATE_DEVICE)) { - finalURL = URLPartial.concat("?deviceNumIds=" + requestParams + "&subfolder=" + subfolderStr); - } - try { - obj = new URL(finalURL); - con = SetHttpConnection.getConnection(obj); - // Calling setConnectionMethod - responseMessage = setConnectionMethods(con, methodName); - } catch (Exception e) { - e.printStackTrace(); - } - - return responseMessage; - } - /** - * Set connection methods - * @param con - * @returning response message - */ - public String setConnectionMethods(HttpsURLConnection con,String methodName) { - if (con != null) { - - con.setRequestProperty(Constants.HTTP_REQUEST_PROPERTY_TOKEN_KEY, configParameters.getToken()); - con.setRequestProperty(Constants.HTTP_REQUEST_PROPERTY_CONTENT_TYPE_KEY, - Constants.HTTP_REQUEST_PROPERTY_CONTENT_TYPE_ACCEPT_VALUE); - con.addRequestProperty(Constants.HTTP_REQUEST_PROPERTY_ACCEPT_KEY, - Constants.HTTP_REQUEST_PROPERTY_CONTENT_TYPE_ACCEPT_VALUE); - - if ((methodName.equals(Constants.SEND_COMMAND_TO_DEVICE) || methodName.equals(Constants.CREATE_DEVICE))) { - - try { - con.setRequestMethod(Constants.HTTP_REQUEST_METHOD_TYPE_POST); - } catch (ProtocolException e) { - e.printStackTrace(); - } - - // SetOutput to connection - con.setDoOutput(true); - - // Get responseCode from Connection - responseMessage = getResponse(con, this.getBodyParams()); - } - } else { - responseMessage = null; - } - return responseMessage; - } - - /** - * Method used to get Response when inputString and connection object are inputs - * ResponseMessage - String value is sent as return value - * - * @param con - * @param inputString - * @return responseMessage - */ - public String getResponse(HttpsURLConnection con, String bodyData) { - try (OutputStream os = con.getOutputStream()) { - StringBuilder response = new StringBuilder(); - byte[] input = bodyData.getBytes("utf-8"); - os.write(input, 0, input.length); - responseCode = con.getResponseCode(); - if(responseCode != 200) { - BufferedReader in = null; - if(con.getErrorStream() != null) { - in = new BufferedReader(new InputStreamReader(con.getErrorStream())); - }else if(con.getInputStream() != null) { - in = new BufferedReader(new InputStreamReader(con.getInputStream())); - } - String inputLine; - if(in != null) { - while((inputLine = in.readLine()) != null) { - response.append(inputLine); - } - } - responseMessage = response.toString(); - }else if(responseCode == 200) { - responseMessage = "OK"; - } - } catch (MalformedURLException e) { - e.printStackTrace(); - } catch (IOException e1) { - e1.printStackTrace(); - } - return responseMessage; - } - - public String getBodyParams() { - return bodyParams; - } - - public void setBodyParams(String bodyParams) { - this.bodyParams = bodyParams; - } - -} diff --git a/clearblade-cloud-iot/src/main/java/com/clearblade/cloud/iot/v1/utils/SetHttpConnection.java b/clearblade-cloud-iot/src/main/java/com/clearblade/cloud/iot/v1/utils/SetHttpConnection.java deleted file mode 100644 index 2bc61bf1..00000000 --- a/clearblade-cloud-iot/src/main/java/com/clearblade/cloud/iot/v1/utils/SetHttpConnection.java +++ /dev/null @@ -1,26 +0,0 @@ -package com.clearblade.cloud.iot.v1.utils; - -import java.io.IOException; -import java.net.URL; - -import javax.net.ssl.HttpsURLConnection; - -public class SetHttpConnection { - private static HttpsURLConnection con; - - private SetHttpConnection() { - } - - public static HttpsURLConnection getConnection(URL url) { - if(SetHttpConnection.con != null) { - return SetHttpConnection.con; - }else { - try { - con = (HttpsURLConnection) url.openConnection(); - } catch (IOException e) { - e.printStackTrace(); - } - return con; - } - } -} diff --git a/clearblade-cloud-iot/src/test/java/com/clearblade/cloud/iot/v1/test/DeviceManagerClientTest.java b/clearblade-cloud-iot/src/test/java/com/clearblade/cloud/iot/v1/test/DeviceManagerClientTest.java deleted file mode 100644 index 9e5e3a9a..00000000 --- a/clearblade-cloud-iot/src/test/java/com/clearblade/cloud/iot/v1/test/DeviceManagerClientTest.java +++ /dev/null @@ -1,115 +0,0 @@ -package com.clearblade.cloud.iot.v1.test; - -import static org.junit.jupiter.api.Assertions.fail; - -import java.util.logging.Level; -import java.util.logging.Logger; - -import org.junit.jupiter.api.Test; - -import com.clearblade.cloud.iot.v1.CreateDeviceRequest; -import com.clearblade.cloud.iot.v1.CreateDeviceResponse; -import com.clearblade.cloud.iot.v1.DeviceManagerClient; -import com.clearblade.cloud.iot.v1.SendCommandToDeviceRequest; -import com.clearblade.cloud.iot.v1.SendCommandToDeviceResponse; -import com.clearblade.cloud.iot.v1.utils.ByteString; -import com.clearblade.cloud.iot.v1.utils.Constants; -import com.clearblade.cloud.iot.v1.utils.Device; -import com.clearblade.cloud.iot.v1.utils.DeviceName; -import com.clearblade.cloud.iot.v1.utils.RegistryName; - -class DeviceManagerClientTest { - - private DeviceManagerClient client; - private Constants constants; - static Logger log = Logger.getLogger(DeviceManagerClientTest.class.getName()); - - void init() { - client = new DeviceManagerClient(); - constants = new Constants(); - } - - @Test - void testSendCommandToDeviceDeviceNameByteStringString() { - init(); - String expectedResponse = "OK"; - String msg = ""; - - DeviceName name = DeviceName.of(constants.getProject(), constants.getLocation(), constants.getRegistry(), - constants.getDeviceName()); - ByteString binaryData = new ByteString(""); - - SendCommandToDeviceRequest request = SendCommandToDeviceRequest.Builder.newBuilder().setName(name) - .setBinaryData(binaryData).setSubFolder(null).build(); - SendCommandToDeviceResponse actualResponse = client.sendCommandToDevice(request); - if (actualResponse != null) { - actualResponse.processRequest(); - if(actualResponse.getHttpStatusResponse().equals(expectedResponse)) { - msg = "SendCommandToDeviceTest successfully executed"; - log.log(Level.INFO, msg); - }else { - msg = "SendCommandToDeviceTest execution failed"; - log.log(Level.WARNING, msg); - fail(msg); - } - } else { - msg = "SendCommandToDeviceTest execution failed"; - log.log(Level.SEVERE,msg); - fail(msg); - } - } - - @Test - void testSendCommandToDeviceDeviceNameByteStringStringFail() { - init(); - String expectedResponse = "OK"; - String msg =""; - DeviceName name = DeviceName.of("","","",""); - ByteString binaryData = new ByteString(""); - - SendCommandToDeviceRequest request = SendCommandToDeviceRequest.Builder.newBuilder().setName(name) - .setBinaryData(binaryData).setSubFolder(null).build(); - SendCommandToDeviceResponse actualResponse = client.sendCommandToDevice(request); - if (actualResponse != null) { - actualResponse.processRequest(); - if(actualResponse.getHttpStatusResponse().equals(expectedResponse)) { - msg = "SendCommandToDeviceTest Failure Case is Successful"; - log.log(Level.INFO, msg); - }else { - msg = "SendCommandToDeviceTest Failure case testing is failed"; - log.log(Level.WARNING,msg); - } - }else { - msg = "SendCommandToDeviceTest Failure case testing is failed"; - log.log(Level.SEVERE, msg); - fail(msg); - } - } - - @Test - void testCreateDeviceRegistryNameDevice() { - init(); - String expectedResponse = "OK"; - String msg = ""; - RegistryName registryName = RegistryName.of(constants.getProject(), constants.getLocation(), - constants.getRegistry()); - CreateDeviceRequest request = CreateDeviceRequest.Builder.newBuilder().setParent(registryName.toString()) - .setDevice(Device.newBuilder().build()).build(); - CreateDeviceResponse actualResponse = client.createDevice(request); - if (actualResponse != null) { - actualResponse.processRequest(); - if(actualResponse.getHttpStatusResponse().equals(expectedResponse)) { - msg = "CreateDeviceTest execution is successful"; - log.log(Level.INFO, msg); - }else { - msg = "CreateDeviceTest failed"; - log.log(Level.WARNING,msg); - } - }else { - msg = "CreateDeviceTest failed"; - log.log(Level.SEVERE, msg); - fail(msg); - } - } - -} From 8f55719fb19c58c770bcd885af430f9d6441cae9 Mon Sep 17 00:00:00 2001 From: RashmiK14 Date: Wed, 9 Nov 2022 18:47:26 +0530 Subject: [PATCH 010/151] IOT_635_637 CloudeToDevice Get Config and setState endpoint - regional I have committed following changes :-> 1) IOT 635 CloudToDevice getConfig - api implementation , sample addition 2) IOT 637 CloudToDevice setState - api implementation , sample addition --- .../devicegetconfig/AsyncGetDeviceConfig.java | 41 ++++++ .../devicesetstates/AsyncDeviceSetStates.java | 40 ++++++ .../devicesetstates/SyncDeviceSetStates.java | 40 ++++++ .../cloud/iot/v1/DeviceManagerClient.java | 49 ++++++- .../cloud/iot/v1/DeviceSetStatesRequest.java | 102 ++++++++++++++ .../cloud/iot/v1/DeviceSetStatesResponse.java | 124 ++++++++++++++++++ .../cloud/iot/v1/GetDeviceConfigRequest.java | 65 +++++++++ .../cloud/iot/v1/GetDeviceConfigResponse.java | 112 ++++++++++++++++ .../cloud/iot/v1/utils/Constants.java | 2 + 9 files changed, 574 insertions(+), 1 deletion(-) create mode 100644 clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/devicegetconfig/AsyncGetDeviceConfig.java create mode 100644 clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/devicesetstates/AsyncDeviceSetStates.java create mode 100644 clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/devicesetstates/SyncDeviceSetStates.java create mode 100644 clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/DeviceSetStatesRequest.java create mode 100644 clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/DeviceSetStatesResponse.java create mode 100644 clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/GetDeviceConfigRequest.java create mode 100644 clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/GetDeviceConfigResponse.java diff --git a/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/devicegetconfig/AsyncGetDeviceConfig.java b/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/devicegetconfig/AsyncGetDeviceConfig.java new file mode 100644 index 00000000..4cec7c9e --- /dev/null +++ b/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/devicegetconfig/AsyncGetDeviceConfig.java @@ -0,0 +1,41 @@ +package com.clearblade.cloud.iot.v1.devicegetconfig; + +import java.util.logging.Level; +import java.util.logging.Logger; + +import com.clearblade.cloud.iot.v1.DeviceManagerClient; +import com.clearblade.cloud.iot.v1.GetDeviceConfigRequest; +import com.clearblade.cloud.iot.v1.GetDeviceConfigResponse; + +public class AsyncGetDeviceConfig { + static Logger log = Logger.getLogger(AsyncGetDeviceConfig.class.getName()); + + public static void main(String[] args) { + asyncGetDeviceConfig(); + } + + public static void asyncGetDeviceConfig() { + String msg = ""; + DeviceManagerClient deviceManagerClient = new DeviceManagerClient(); + String registryName = "Rashmi_Registry_Test"; + String deviceName = "Rashmi_Device_Test"; + String localVersion = "1"; + GetDeviceConfigRequest request = GetDeviceConfigRequest.Builder.newBuilder().setDeviceName(registryName + "/" + deviceName).setLocalVersion(localVersion) + .build(); + GetDeviceConfigResponse response = deviceManagerClient.getDeviceConfig(request); + if (response != null) { + response.processRequest(request); + if (response.getHttpStatusResponse().equals("OK")) { + msg = "AsyncGetDeviceConfig Method worked successfully :: " + response.getHttpStatusResponse(); + log.log(Level.INFO, msg); + } else { + msg = "AsyncGetDeviceConfig Method execution failed :: " + response.getHttpStatusResponse(); + log.log(Level.SEVERE, msg); + } + } else { + msg = "AsyncGetDeviceConfig Method execution failed"; + log.log(Level.SEVERE, msg); + } + } + +} diff --git a/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/devicesetstates/AsyncDeviceSetStates.java b/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/devicesetstates/AsyncDeviceSetStates.java new file mode 100644 index 00000000..decac6a5 --- /dev/null +++ b/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/devicesetstates/AsyncDeviceSetStates.java @@ -0,0 +1,40 @@ +package com.clearblade.cloud.iot.v1.devicesetstates; + +import java.util.logging.Level; +import java.util.logging.Logger; + +import com.clearblade.cloud.iot.v1.DeviceManagerClient; +import com.clearblade.cloud.iot.v1.DeviceSetStatesRequest; +import com.clearblade.cloud.iot.v1.DeviceSetStatesResponse; +import com.clearblade.cloud.iot.v1.utils.ByteString; + +public class AsyncDeviceSetStates { + static Logger log = Logger.getLogger(AsyncDeviceSetStates.class.getName()); + + public static void main(String[] args) { + asyncDeviceSetStates(); + } + + public static void asyncDeviceSetStates() { + DeviceManagerClient deviceManagerClient = new DeviceManagerClient(); + String msg = ""; + String registryName = "Rashmi_Registry_Test"; + String deviceName = "Rashmi_Device_Test"; + DeviceSetStatesRequest request = DeviceSetStatesRequest.Builder.newBuilder().setDeviceName(registryName+"/"+deviceName).setBinaryDataByte(ByteString.EMPTY).build(); + DeviceSetStatesResponse response = deviceManagerClient.deviceSetStates(request); + if (response != null) { + response.processRequest(request); + if(response.getHttpStatusResponse().equals("OK")) { + msg = "AsyncDeviceSetStates Method worked successfully :: " + response.getHttpStatusResponse(); + log.log(Level.INFO, msg); + }else { + msg = "AsyncDeviceSetStates Method execution failed :: " + response.getHttpStatusResponse(); + log.log(Level.SEVERE, msg); + } + }else { + msg = "AsyncDeviceSetStates Method execution failed"; + log.log(Level.SEVERE, msg); + } + } + +} diff --git a/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/devicesetstates/SyncDeviceSetStates.java b/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/devicesetstates/SyncDeviceSetStates.java new file mode 100644 index 00000000..9e38fe30 --- /dev/null +++ b/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/devicesetstates/SyncDeviceSetStates.java @@ -0,0 +1,40 @@ +package com.clearblade.cloud.iot.v1.devicesetstates; + +import java.util.logging.Level; +import java.util.logging.Logger; + +import com.clearblade.cloud.iot.v1.DeviceManagerClient; +import com.clearblade.cloud.iot.v1.DeviceSetStatesRequest; +import com.clearblade.cloud.iot.v1.DeviceSetStatesResponse; +import com.clearblade.cloud.iot.v1.utils.ByteString; + +public class SyncDeviceSetStates { + static Logger log = Logger.getLogger(SyncDeviceSetStates.class.getName()); + + public static void main(String[] args) { + syncDeviceSetStates(); + } + + public static void syncDeviceSetStates() { + DeviceManagerClient deviceManagerClient = new DeviceManagerClient(); + String msg = ""; + String registryName = "Rashmi_Registry_Test"; + String deviceName = "Rashmi_Device_Test"; + DeviceSetStatesRequest request = DeviceSetStatesRequest.Builder.newBuilder().setDeviceName(registryName+"/"+deviceName).setBinaryDataByte(ByteString.EMPTY).build(); + DeviceSetStatesResponse response = deviceManagerClient.deviceSetStates(request); + if (response != null) { + response.processRequest(request); + if(response.getHttpStatusResponse().equals("OK")) { + msg = "SyncDeviceSetStates Method worked successfully :: " + response.getHttpStatusResponse(); + log.log(Level.INFO, msg); + }else { + msg = "SyncDeviceSetStates Method execution failed :: " + response.getHttpStatusResponse(); + log.log(Level.SEVERE, msg); + } + }else { + msg = "SyncDeviceSetStates Method execution failed"; + log.log(Level.SEVERE, msg); + } + } + +} diff --git a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/DeviceManagerClient.java b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/DeviceManagerClient.java index 1b901bcb..9e9bc272 100644 --- a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/DeviceManagerClient.java +++ b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/DeviceManagerClient.java @@ -1,5 +1,6 @@ package com.clearblade.cloud.iot.v1; +import com.clearblade.cloud.iot.v1.utils.ByteString; import com.clearblade.cloud.iot.v1.utils.Device; import com.clearblade.cloud.iot.v1.utils.DeviceName; import com.clearblade.cloud.iot.v1.utils.RegistryName; @@ -129,5 +130,51 @@ public void deviceStatesList(String name, int numStates) { public DeviceStatesListResponse deviceStatesList(DeviceStatesListRequest request) { return (DeviceStatesListResponse.Builder.newBuilder().setDeviceStatesListRequest(request).build()); } - + + /** + * DeviceSetStates method + * + * @param name, method + * @param binaryData + */ + public void devicesSetStates(String name, ByteString binaryData) { + DeviceSetStatesRequest request = DeviceSetStatesRequest.Builder.newBuilder().setDeviceName(name) + .setBinaryData(binaryData).build(); + this.deviceSetStates(request); + DeviceSetStatesResponse response = this.deviceSetStates(request); + response.processRequest(request); + } + /** + * Print the response for DeviceSetStatesRequest + * + * @param request + * @return Response object + */ + public DeviceSetStatesResponse deviceSetStates(DeviceSetStatesRequest request) { + return (DeviceSetStatesResponse.Builder.newBuilder().setDeviceSetStatesRequest(request).build()); + } + + /** + * Method used to call getDeviceConfig api + * @param name + * @return Device Config - binary Data and version + */ + public void getDeviceConfig(DeviceName name,String localVersion) { + GetDeviceConfigRequest request = GetDeviceConfigRequest.Builder.newBuilder().setDeviceName(name == null ? null : name.toString()).setLocalVersion(localVersion).build(); + getDeviceConfig(request); + } + + /** + * Print the response for getDeviceConfig + * + * @param request + * @return Response object + */ + public GetDeviceConfigResponse getDeviceConfig(GetDeviceConfigRequest request) { + return (GetDeviceConfigResponse.Builder.newBuilder().setGetDeviceConfigRequest(request).build()); + } + + + } + diff --git a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/DeviceSetStatesRequest.java b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/DeviceSetStatesRequest.java new file mode 100644 index 00000000..1c9f7b27 --- /dev/null +++ b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/DeviceSetStatesRequest.java @@ -0,0 +1,102 @@ +package com.clearblade.cloud.iot.v1; + +import java.util.Arrays; + +import org.json.simple.JSONObject; + +import com.clearblade.cloud.iot.v1.utils.ByteString; + +public class DeviceSetStatesRequest { + + private final ByteString binaryData; + private final byte[] binaryDataByte; + private final String deviceName; + private final String method; + public JSONObject requestParams; + public JSONObject bodyParams; + + private DeviceSetStatesRequest(Builder builder) { + this.binaryData = builder.binaryData; + this.binaryDataByte = builder.binaryDataByte; + this.deviceName = builder.deviceName; + this.method = builder.method; + } + + // Static class Builder + public static class Builder { + + /// instance fields + private ByteString binaryData; + private byte[] binaryDataByte; + private String deviceName; + private String method; + + public static Builder newBuilder() { + return new Builder(); + } + + private Builder() { + } + + // Setter methods + public Builder setBinaryData(ByteString binaryData) { + this.binaryData = binaryData; + return this; + } + + public Builder setBinaryDataByte(byte[] binaryDataByte) { + this.binaryDataByte = binaryDataByte; + return this; + } + + public Builder setDeviceName(String deviceName) { + this.deviceName = deviceName; + return this; + } + + public Builder setMethod(String method) { + this.method = method; + return this; + } + + // build method to deal with outer class + // to return outer instance + public DeviceSetStatesRequest build() { + return new DeviceSetStatesRequest(this); + } + } + + @SuppressWarnings("unchecked") + @Override + public String toString() { + requestParams = new JSONObject(); + bodyParams = new JSONObject(); + + String dName = ""; + String bData = null; + String method = ""; + + if(this.deviceName != null) { + dName = this.deviceName; + } + if(this.method != null) { + method = this.method; + } + if(this.binaryData != null) { + bData = new String(this.binaryData.getBinaryDataArray()); + }else if(this.binaryDataByte != null) { + if(this.binaryDataByte.length == 0){ + bData = "EMPTY"; + }else { + bData = Arrays.toString(this.binaryDataByte); + } + } + + requestParams.put("name", dName); + requestParams.put("method", method); + bodyParams.put("binaryData", bData); + + return "name = "+dName+", binaryData = "+bData+", method = "+method; + + } +} diff --git a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/DeviceSetStatesResponse.java b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/DeviceSetStatesResponse.java new file mode 100644 index 00000000..3565173c --- /dev/null +++ b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/DeviceSetStatesResponse.java @@ -0,0 +1,124 @@ +package com.clearblade.cloud.iot.v1; + +import java.util.logging.Level; +import java.util.logging.Logger; + +import org.json.simple.JSONObject; + +public class DeviceSetStatesResponse { + + static Logger log = Logger.getLogger(DeviceSetStatesResponse.class.getName()); + private final DeviceSetStatesRequest request; + private int httpStatusCode; + private String httpStatusResponse; + + protected DeviceSetStatesResponse(Builder builder) { + this.request = builder.request; + } + + public int getHttpStatusCode() { + return httpStatusCode; + } + + public void setHttpStatusCode(int httpStatusCode) { + this.httpStatusCode = httpStatusCode; + } + + public String getHttpStatusResponse() { + return httpStatusResponse; + } + + public void setHttpStatusResponse(String httpStatusResponse) { + this.httpStatusResponse = httpStatusResponse; + } + + // Static class Builder + public static class Builder { + + /// instance fields + private DeviceSetStatesRequest request; + + public static Builder newBuilder() { + return new Builder(); + } + + private Builder() { + } + + // Setter methods + public Builder setDeviceSetStatesRequest(DeviceSetStatesRequest request) { + this.request = request; + return this; + } + + // build method to deal with outer class + // to return outer instance + public DeviceSetStatesResponse build() { + return new DeviceSetStatesResponse(this); + } + } + + /** + * Mehtod used to process the request + * Calling processRequestForMethod - sendCommandToDevice + */ + + public void processRequest(DeviceSetStatesRequest request) { + String msg = ""; + JSONObject requestParams = new JSONObject(); + JSONObject bodyParams = new JSONObject(); + ProcessRequest processRequest = new ProcessRequest(); + + if(request != null) { + String logMsg = "Setting states request on device :: "+request.toString(); + log.log(Level.INFO,logMsg); + requestParams = (JSONObject) request.requestParams.clone(); + bodyParams = (JSONObject) request.bodyParams.clone(); + } + + String responseMessage = processRequest.processRequestForMethod("setState",requestParams,bodyParams); + this.setHttpStatusResponse(responseMessage); + if (responseMessage.equals("OK")) { + msg = "Request processed successfully for DeviceSetStates method"; + log.log(Level.INFO, msg); + } else { + msg = "POST request not worked for DeviceSetStates Method \n".concat(responseMessage); + log.log(Level.SEVERE, msg); + } + + } + + /** + * Mehtod used to process the request + * Calling processRequestForMethod - DeviceSetStatesRequest + */ + + /* + * public String processRequestAsync(SendCommandToDeviceRequest request) { + * String msg = ""; JSONObject requestParams = new JSONObject(); JSONObject + * bodyParams = new JSONObject(); ProcessRequest processRequest = new + * ProcessRequest(); + * + * if(request != null) { String logMsg = + * "Sending request to device :: "+request.toString(); + * log.log(Level.INFO,logMsg); requestParams = (JSONObject) + * request.requestParams.clone(); bodyParams = (JSONObject) + * request.bodyParams.clone(); } + * + * String responseMessage = + * processRequest.asyncCallSendCommandToDevice(request); + * this.setHttpStatusResponse(responseMessage); if + * (responseMessage.equals("OK")) { msg = + * "Request processed successfully for SendCommandToDevice method"; + * log.log(Level.INFO, msg); } else { msg = + * "POST request not worked for sendCommandToDevice Method \n".concat( + * responseMessage); log.log(Level.SEVERE, msg); } return responseMessage; + * + * } + * + * @Override public String toString() { return "Http Status Code :: " + + * this.getHttpStatusCode() + " Http Status Response :: " + + * this.getHttpStatusResponse(); } + * + * public SendCommandToDeviceRequest getRequest() { return request; } + */} diff --git a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/GetDeviceConfigRequest.java b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/GetDeviceConfigRequest.java new file mode 100644 index 00000000..5e9d2b94 --- /dev/null +++ b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/GetDeviceConfigRequest.java @@ -0,0 +1,65 @@ +package com.clearblade.cloud.iot.v1; + +import org.json.simple.JSONObject; + +public class GetDeviceConfigRequest { + + private final String deviceName; + private final String localVersion; + JSONObject requestParams = new JSONObject(); + + private GetDeviceConfigRequest(Builder builder) { + this.deviceName = builder.deviceName; + this.localVersion = builder.localVersion; + } + + // Static class Builder + public static class Builder { + + /// instance fields + private String deviceName; + private String localVersion; + + public static Builder newBuilder() { + return new Builder(); + } + + private Builder() { + } + + // Setter methods + public Builder setDeviceName(String deviceName) { + this.deviceName = deviceName; + return this; + } + public Builder setLocalVersion(String localVersion) { + this.localVersion = localVersion; + return this; + } + + // build method to deal with outer class + // to return outer instance + public GetDeviceConfigRequest build() { + return new GetDeviceConfigRequest(this); + } + } + + @Override + public String toString() { + requestParams = new JSONObject(); + requestParams.put("name", this.deviceName); + requestParams.put("localVersion", this.localVersion); + this.setRequestParams(requestParams); + return "name="+this.deviceName+"localVersion="+this.localVersion; + } + + public JSONObject getRequestParams() { + return requestParams; + } + + public void setRequestParams(JSONObject requestParams) { + this.requestParams = requestParams; + } + + +} diff --git a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/GetDeviceConfigResponse.java b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/GetDeviceConfigResponse.java new file mode 100644 index 00000000..09948627 --- /dev/null +++ b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/GetDeviceConfigResponse.java @@ -0,0 +1,112 @@ +package com.clearblade.cloud.iot.v1; + +import java.util.logging.Level; +import java.util.logging.Logger; + +import org.json.simple.JSONObject; + +import com.clearblade.cloud.iot.v1.utils.Device; + +public class GetDeviceConfigResponse { + + static Logger log = Logger.getLogger(GetDeviceConfigResponse.class.getName()); + + private final GetDeviceConfigRequest request; + private int httpStatusCode; + private String httpStatusResponse; + private Device device; + + protected GetDeviceConfigResponse(Builder builder) { + this.request = builder.request; + } + + public int getHttpStatusCode() { + return httpStatusCode; + } + + public void setHttpStatusCode(int httpStatusCode) { + this.httpStatusCode = httpStatusCode; + } + + public String getHttpStatusResponse() { + return httpStatusResponse; + } + + public void setHttpStatusResponse(String httpStatusResponse) { + this.httpStatusResponse = httpStatusResponse; + } + + // Static class Builder + public static class Builder { + + /// instance fields + private GetDeviceConfigRequest request; + + public static Builder newBuilder() { + return new Builder(); + } + + private Builder() { + } + + // Setter methods + public Builder setGetDeviceConfigRequest(GetDeviceConfigRequest request) { + this.request = request; + return this; + } + + // build method to deal with outer class + // to return outer instance + public GetDeviceConfigResponse build() { + return new GetDeviceConfigResponse(this); + } + } + + /** + * Mehtod used to process the request Calling processRequestForMethod - + * GetDevice + */ + @SuppressWarnings("unchecked") + public void processRequest(GetDeviceConfigRequest request) { + String msg = ""; + ProcessRequest processRequest = new ProcessRequest(); + JSONObject requestParams = new JSONObject(); + JSONObject bodyParams = new JSONObject(); + if(request != null) { + String logMsg = "Calling get device config:: "+request.toString(); + log.log(Level.INFO,logMsg); + requestParams = (JSONObject) request.requestParams.clone(); + } + String responseMessage = processRequest.processRequestForMethod("deviceGetConfig", requestParams, bodyParams); + this.setHttpStatusResponse(responseMessage); + if (responseMessage.equals("OK")) { + this.setHttpStatusCode(200); + msg = "Request processed for GetDeviceConfig method"; + + log.log(Level.INFO, msg); + } else { + this.setHttpStatusCode(0); + msg = "Request for GetDeviceConfig failed \n" .concat(responseMessage); + log.log(Level.SEVERE, msg); + } + } + + @Override + public String toString() { + return "Http Status Code :: " + this.getHttpStatusCode() + " Http Status Response :: " + + this.getHttpStatusResponse(); + } + + public GetDeviceConfigRequest getRequest() { + return request; + } + + public Device getDevice() { + return device; + } + + public void setDevice(Device device) { + this.device = device; + } + +} diff --git a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/utils/Constants.java b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/utils/Constants.java index c73cb309..32c14f5a 100644 --- a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/utils/Constants.java +++ b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/utils/Constants.java @@ -10,6 +10,8 @@ private Constants() {} public static final String GET_DEVICE = "getDevice"; public static final String DEVICES_LIST = "devicesList"; public static final String DEVICE_STATES_LIST = "deviceStatesList"; + public static final String DEVICE_SET_STATES = "setState"; + public static final String DEVICE_GET_CONFIG = "deviceGetConfig"; // Constants used for setting up http connection - for common use public static final String HTTPS_URL_PREFIX = "https://"; From a345edb950338e6df375c9955399be0732659d08 Mon Sep 17 00:00:00 2001 From: RashmiK14 Date: Wed, 9 Nov 2022 21:24:50 +0530 Subject: [PATCH 011/151] IOT_635_637_ cloudIoTDevice-getConfig_setState endpoint regional Adding changes to earlier commit --- .../devicegetconfig/SyncGetDeviceConfig.java | 41 +++++++++++++++++++ .../cloud/iot/v1/ProcessRequest.java | 34 +++++++++++---- .../cloud/iot/v1/utils/ConfigParameters.java | 20 +++++++++ clearblade-cloud-iot/src/config.properties | 3 ++ 4 files changed, 91 insertions(+), 7 deletions(-) create mode 100644 clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/devicegetconfig/SyncGetDeviceConfig.java diff --git a/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/devicegetconfig/SyncGetDeviceConfig.java b/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/devicegetconfig/SyncGetDeviceConfig.java new file mode 100644 index 00000000..2230a62f --- /dev/null +++ b/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/devicegetconfig/SyncGetDeviceConfig.java @@ -0,0 +1,41 @@ +package com.clearblade.cloud.iot.v1.devicegetconfig; + +import java.util.logging.Level; +import java.util.logging.Logger; + +import com.clearblade.cloud.iot.v1.DeviceManagerClient; +import com.clearblade.cloud.iot.v1.GetDeviceConfigRequest; +import com.clearblade.cloud.iot.v1.GetDeviceConfigResponse; + +public class SyncGetDeviceConfig { + static Logger log = Logger.getLogger(SyncGetDeviceConfig.class.getName()); + + public static void main(String[] args) { + syncGetDeviceConfig(); + } + + public static void syncGetDeviceConfig() { + String msg = ""; + DeviceManagerClient deviceManagerClient = new DeviceManagerClient(); + String registryName = "Rashmi_Registry_Test"; + String deviceName = "Rashmi_Device_Test"; + String localVersion = "1"; + GetDeviceConfigRequest request = GetDeviceConfigRequest.Builder.newBuilder().setDeviceName(registryName + "/" + deviceName).setLocalVersion(localVersion) + .build(); + GetDeviceConfigResponse response = deviceManagerClient.getDeviceConfig(request); + if (response != null) { + response.processRequest(request); + if (response.getHttpStatusResponse().equals("OK")) { + msg = "SyncGetDeviceConfig Method worked successfully :: " + response.getHttpStatusResponse(); + log.log(Level.INFO, msg); + } else { + msg = "SyncGetDeviceConfig Method execution failed :: " + response.getHttpStatusResponse(); + log.log(Level.SEVERE, msg); + } + } else { + msg = "SyncGetDeviceConfig Method execution failed"; + log.log(Level.SEVERE, msg); + } + } + +} diff --git a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/ProcessRequest.java b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/ProcessRequest.java index 54323719..7f5ec31f 100644 --- a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/ProcessRequest.java +++ b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/ProcessRequest.java @@ -77,11 +77,29 @@ public String processRequestForMethod(String methodName, JSONObject requestParam } else if (methodName.equals(Constants.DEVICES_LIST) && (requestParams != null && requestParams.size() > 0)) { parent = requestParams.get("parent").toString(); finalURL = urlPartial.concat("?parent=" + parent); - }else if (methodName.equals(Constants.DEVICE_STATES_LIST) && (requestParams != null && requestParams.size() > 0)) { + }else if (methodName.equals(Constants.DEVICE_STATES_LIST) && (requestParams != null && requestParams.size() > 0)) { + urlPartial = Constants.HTTPS_URL_PREFIX.concat(configParameters.getEndPoint()) + .concat(configParameters.getBaseURL()).concat(configParameters.getSystemKey()) + .concat(configParameters.getDevicesStatesURLExtension()); name = requestParams.get("name").toString(); numStates = requestParams.get("numStates").toString(); finalURL = urlPartial.concat("?name=" + name+"&numStates="+Integer.parseInt(numStates)); - } + }else if (methodName.equals(Constants.DEVICE_SET_STATES) && requestParams != null && requestParams.size() > 0) { + urlPartial = Constants.HTTPS_URL_PREFIX.concat(configParameters.getEndPoint()) + .concat(configParameters.getBaseURL()).concat(configParameters.getSystemKey()) + .concat(configParameters.getCloudiotdevicesURLExtension()); + name = requestParams.get("name").toString(); + method = requestParams.get("method").toString(); + finalURL = urlPartial.concat("?name=" + name + "&method=" + method); + } else if (methodName.equals(Constants.DEVICE_GET_CONFIG) && requestParams != null && requestParams.size() > 0) { + urlPartial = Constants.HTTPS_URL_PREFIX.concat(configParameters.getEndPoint()) + .concat(configParameters.getBaseURL()).concat(configParameters.getSystemKey()) + .concat(configParameters.getCloudiotdevicesURLExtension()); + name = requestParams.get("name").toString(); + localVersion = requestParams.get("localVersion").toString(); + finalURL = urlPartial.concat("?name=" + name + "&localVersion=" + localVersion); + } + try { obj = new URL(finalURL); setCon = new SetHttpConnection(); @@ -110,11 +128,11 @@ public String setConnectionMethods(HttpsURLConnection con, String methodName) { Constants.HTTP_REQUEST_PROPERTY_CONTENT_TYPE_ACCEPT_VALUE); String methodType = ""; - if ((methodName.equals(Constants.SEND_COMMAND_TO_DEVICE) || methodName.equals(Constants.CREATE_DEVICE))) { + if ((methodName.equals(Constants.SEND_COMMAND_TO_DEVICE) || methodName.equals(Constants.CREATE_DEVICE)) || (methodName.equals(Constants.DEVICE_SET_STATES))) { methodType = Constants.HTTP_REQUEST_METHOD_TYPE_POST; } else if (methodName.equals(Constants.DELETE_DEVICE)) { methodType = Constants.HTTP_REQUEST_METHOD_TYPE_DELETE; - } else if ((methodName.equals(Constants.GET_DEVICE)) || (methodName.equals(Constants.DEVICES_LIST)) || (methodName.equals(Constants.DEVICE_STATES_LIST))) { + } else if ((methodName.equals(Constants.GET_DEVICE)) || (methodName.equals(Constants.DEVICES_LIST)) || (methodName.equals(Constants.DEVICE_STATES_LIST)) || (methodName.equals(Constants.DEVICE_GET_CONFIG))) { methodType = Constants.HTTP_REQUEST_METHOD_TYPE_GET; } try { @@ -127,8 +145,8 @@ public String setConnectionMethods(HttpsURLConnection con, String methodName) { con.setDoOutput(true); // Get responseCode from Connection - if (methodName.equals(Constants.SEND_COMMAND_TO_DEVICE) || methodName.equals(Constants.CREATE_DEVICE)) { - responseMessage = getResponseForSendCommandCreateDevice(con); + if (methodName.equals(Constants.SEND_COMMAND_TO_DEVICE) || methodName.equals(Constants.CREATE_DEVICE) || methodName.equals(Constants.DEVICE_SET_STATES)) { + responseMessage = getResponseForPostMethod(con); } else if (methodName.equals(Constants.DELETE_DEVICE)) { responseMessage = getResponseForDeleteDevice(con); } else if (methodName.equals(Constants.GET_DEVICE)) { @@ -137,6 +155,8 @@ public String setConnectionMethods(HttpsURLConnection con, String methodName) { responseMessage = getResponseForGetRequest(con); }else if (methodName.equals(Constants.DEVICE_STATES_LIST)) { responseMessage = getResponseForGetRequest(con); + }else if (methodName.equals(Constants.DEVICE_GET_CONFIG)) { + responseMessage = getResponseForGetRequest(con); } } return responseMessage; @@ -193,7 +213,7 @@ public String getResponseForGetRequest(HttpsURLConnection con) { return responseMessage; } - public String getResponseForSendCommandCreateDevice(HttpsURLConnection con) { + public String getResponseForPostMethod(HttpsURLConnection con) { StringBuilder response = new StringBuilder(); try (OutputStream os = con.getOutputStream()) { JSONObject js = this.getBodyJSONObj(); diff --git a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/utils/ConfigParameters.java b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/utils/ConfigParameters.java index 4ac3ff14..a849111f 100644 --- a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/utils/ConfigParameters.java +++ b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/utils/ConfigParameters.java @@ -11,6 +11,8 @@ public class ConfigParameters { private String token; private String baseURL; private String devicesURLExtension; + private String devicesStatesURLExtension; + private String cloudiotdevicesURLExtension; private String project; private String location; private String registry; @@ -59,6 +61,8 @@ public void setValues() { this.setToken(properties.getProperty("token")); this.setBaseURL(properties.getProperty("baseURL")); this.setDevicesURLExtension(properties.getProperty("devicesURLExtension")); + this.setCloudiotdevicesURLExtension(properties.getProperty("cloudiotdevicesURLExtension")); + this.setDevicesStatesURLExtension(properties.getProperty("devicesStatesURLExtension")); this.setProject(properties.getProperty("project")); this.setLocation(properties.getProperty("location")); this.setRegistry(properties.getProperty("registry")); @@ -104,6 +108,22 @@ public void setDevicesURLExtension(String devicesURLExtension) { this.devicesURLExtension = devicesURLExtension; } + public String getDevicesStatesURLExtension() { + return devicesStatesURLExtension; + } + + public void setDevicesStatesURLExtension(String devicesStatesURLExtension) { + this.devicesStatesURLExtension = devicesStatesURLExtension; + } + + public String getCloudiotdevicesURLExtension() { + return cloudiotdevicesURLExtension; + } + + public void setCloudiotdevicesURLExtension(String cloudiotdevicesURLExtension) { + this.cloudiotdevicesURLExtension = cloudiotdevicesURLExtension; + } + public String getProject() { return project; } diff --git a/clearblade-cloud-iot/src/config.properties b/clearblade-cloud-iot/src/config.properties index 4df9cbb6..6ef354af 100644 --- a/clearblade-cloud-iot/src/config.properties +++ b/clearblade-cloud-iot/src/config.properties @@ -9,3 +9,6 @@ registry=Rashmi_Registry_Test baseURL=/api/v/4/webhook/execute/ devicesURLExtension=/cloudiot_devices + +devicesStatesURLExtension=/cloudiot_devices_states +cloudiotdevicesURLExtension=/cloudiotdevice_devices From a32d289bef37a143d079576475fdd34a81771a00 Mon Sep 17 00:00:00 2001 From: RashmiK14 Date: Thu, 17 Nov 2022 12:02:31 +0530 Subject: [PATCH 012/151] IOT 609 devicePatch endpoint - regional IOT_639 removing hard coded param - use of credential.json implemented This commit includes following :-> 1) IOT 609 devicePatch endpoint - regional - api implementation and samples addition 2) IOT 639 pass parameters instead of hardcoding - changes related to credentials json implemented 3) Removed changes related to deviceSetState and deviceGetConfig - apis and samples 4) Misc changes related to refactoring and restructuring of code , logs --- clearblade-cloud-iot/.metadata/.lock | 0 clearblade-cloud-iot/.metadata/.log | 253 -- .../.metadata/.mylyn/repositories.xml.zip | Bin 685 -> 0 bytes .../.org.eclipse.egit.core.cmp/.location | Bin 163 -> 0 bytes .../.root/.indexes/history.version | 1 - .../.root/.indexes/properties.index | Bin 57 -> 0 bytes .../.root/.indexes/properties.version | 1 - .../org.eclipse.core.resources/.root/2.tree | Bin 189 -> 0 bytes .../.safetable/org.eclipse.core.resources | Bin 653 -> 0 bytes .../org.eclipse.e4.workbench/workbench.xmi | 3024 ----------------- .../org.eclipse.egit.ui/dialog_settings.xml | 11 - .../assumedExternalFilesCache | Bin 4 -> 0 bytes .../org.eclipse.jdt.core/externalFilesCache | Bin 4 -> 0 bytes .../org.eclipse.jdt.core/javaLikeNames.txt | 1 - .../org.eclipse.jdt.core/nonChainingJarsCache | Bin 4 -> 0 bytes .../variablesAndContainers.dat | Bin 129 -> 0 bytes .../org.eclipse.jdt.ui/OpenTypeHistory.xml | 2 - .../QualifiedTypeNameHistory.xml | 2 - .../org.eclipse.m2e.core/workspaceState.ser | Bin 538 -> 0 bytes .../0.log | 2 - .../logback.1.16.3.20211002-1029.xml | 41 - .../org.eclipse.oomph.setup/workspace.setup | 6 - .../org.eclipse.tips.ide/dialog_settings.xml | 3 - .../org.eclipse.ui.ide/dialog_settings.xml | 26 - .../.plugins/org.eclipse.ui.intro/introstate | 2 - .../dialog_settings.xml | 12 - .../dialog_settings.xml | 11 - .../org.eclipse.ui.workbench/workingsets.xml | 6 - .../system-catalog.xml | 229 -- .../hidden.xml | Bin 138 -> 0 bytes .../org.eclipse.wst.common.snippets/user.xml | Bin 766 -> 0 bytes .../dialog_settings.xml | 5 - clearblade-cloud-iot/.metadata/version.ini | 3 - .../cloud/iot/v1/DeviceManagerClient.class | Bin 2324 -> 0 bytes .../SendCommandToDeviceRequest$Builder.class | Bin 1358 -> 0 bytes .../iot/v1/SendCommandToDeviceRequest.class | Bin 1184 -> 0 bytes .../SendCommandToDeviceResponse$Builder.class | Bin 1179 -> 0 bytes .../iot/v1/SendCommandToDeviceResponse.class | Bin 4812 -> 0 bytes .../iot/v1/SyncSendCommandToDevice.class | Bin 2914 -> 0 bytes .../cloud/iot/v1/utils/Constants.class | Bin 2696 -> 0 bytes .../iot/v1/utils/DeviceName$Builder.class | Bin 1792 -> 0 bytes .../cloud/iot/v1/utils/DeviceName.class | Bin 2275 -> 0 bytes clearblade-cloud-iot/pom.xml | 14 +- .../AsyncBindDeviceToGateway.java | 36 + .../SyncBindDeviceToGateway.java | 37 + .../v1/createdevice/AsyncCreateDevice.java | 18 +- .../iot/v1/createdevice/SyncCreateDevice.java | 16 +- .../v1/deletedevice/AsyncDeleteDevice.java | 16 +- .../iot/v1/deletedevice/SyncDeleteDevice.java | 14 +- .../devicegetconfig/AsyncGetDeviceConfig.java | 41 - .../devicegetconfig/SyncGetDeviceConfig.java | 41 - .../iot/v1/devicepatch/AsyncDevicePatch.java | 38 + .../iot/v1/devicepatch/SyncDevicePatch.java | 38 + .../AsyncDevicesConfigVersionsList.java | 37 + .../SyncDevicesConfigVersionsList.java | 37 + .../devicesetstates/AsyncDeviceSetStates.java | 40 - .../devicesetstates/SyncDeviceSetStates.java | 40 - .../iot/v1/deviceslist/AsyncDevicesList.java | 16 +- .../iot/v1/deviceslist/SyncDevicesList.java | 16 +- .../AsyncDeviceStatesList.java | 12 +- .../SyncDeviceStatesList.java | 12 +- .../iot/v1/getdevice/AsyncGetDevice.java | 11 +- .../cloud/iot/v1/getdevice/SyncGetDevice.java | 13 +- .../AsyncModifyCloudToDeviceConfig.java | 36 + .../SyncModifyCloudToDeviceConfig.java | 36 + .../AsyncSendCommandToDevice.java | 31 +- .../SyncSendCommandToDevice.java | 14 +- .../SyncSendCommandToDeviceDataEmpty.java | 12 +- .../SyncSendCommandToDeviceDeviceName.java | 12 +- .../SyncSendCommandToDeviceNoSubfolder.java | 12 +- .../AsyncUnbindDeviceFromGateway.java | 36 + .../SyncUnbindDeviceFromGateway.java | 36 + .../cloud/iot/v1/DeviceManagerClient.java | 133 +- .../cloud/iot/v1/GetDeviceConfigRequest.java | 65 - .../cloud/iot/v1/ProcessRequest.java | 483 ++- .../cloud/iot/v1/auth/AdminAccess.java | 71 + .../cloud/iot/v1/auth/SystemAccess.java | 27 + .../BindDeviceToGatewayRequest.java | 91 + .../BindDeviceToGatewayResponse.java | 102 + .../CreateDeviceRequest.java | 2 +- .../CreateDeviceResponse.java | 4 +- .../DeleteDeviceRequest.java | 2 +- .../DeleteDeviceResponse.java | 4 +- .../DeviceConfigVersionsListRequest.java | 66 + .../DeviceConfigVersionsListResponse.java} | 40 +- .../v1/devicepatch/DevicePatchRequest.java | 92 + .../DevicePatchResponse.java} | 56 +- .../{ => deviceslist}/DevicesListRequest.java | 2 +- .../DevicesListResponse.java | 3 +- .../DeviceStatesListRequest.java | 4 +- .../DeviceStatesListResponse.java | 5 +- .../v1/{ => getdevice}/GetDeviceRequest.java | 2 +- .../v1/{ => getdevice}/GetDeviceResponse.java | 3 +- .../GetRegistryCredentialsRequest.java | 61 + .../GetRegistryCredentialsResponse.java | 69 + .../ModifyCloudToDeviceConfigRequest.java} | 86 +- .../ModifyCloudToDeviceConfigResponse.java | 102 + .../SendCommandToDeviceRequest.java | 2 +- .../SendCommandToDeviceResponse.java | 34 +- .../iot/v1/test/DeviceManagerClientTest.java | 8 +- .../UnbindDeviceFromGatewayRequest.java | 91 + .../UnbindDeviceFromGatewayResponse.java | 102 + .../cloud/iot/v1/utils/AuthParams.java | 37 + .../cloud/iot/v1/utils/ConfigParameters.java | 99 +- .../cloud/iot/v1/utils/Constants.java | 22 +- .../clearblade/cloud/iot/v1/utils/Device.java | 53 +- clearblade-cloud-iot/src/config.properties | 14 +- 107 files changed, 2149 insertions(+), 4297 deletions(-) delete mode 100644 clearblade-cloud-iot/.metadata/.lock delete mode 100644 clearblade-cloud-iot/.metadata/.log delete mode 100644 clearblade-cloud-iot/.metadata/.mylyn/repositories.xml.zip delete mode 100644 clearblade-cloud-iot/.metadata/.plugins/org.eclipse.core.resources/.projects/.org.eclipse.egit.core.cmp/.location delete mode 100644 clearblade-cloud-iot/.metadata/.plugins/org.eclipse.core.resources/.root/.indexes/history.version delete mode 100644 clearblade-cloud-iot/.metadata/.plugins/org.eclipse.core.resources/.root/.indexes/properties.index delete mode 100644 clearblade-cloud-iot/.metadata/.plugins/org.eclipse.core.resources/.root/.indexes/properties.version delete mode 100644 clearblade-cloud-iot/.metadata/.plugins/org.eclipse.core.resources/.root/2.tree delete mode 100644 clearblade-cloud-iot/.metadata/.plugins/org.eclipse.core.resources/.safetable/org.eclipse.core.resources delete mode 100644 clearblade-cloud-iot/.metadata/.plugins/org.eclipse.e4.workbench/workbench.xmi delete mode 100644 clearblade-cloud-iot/.metadata/.plugins/org.eclipse.egit.ui/dialog_settings.xml delete mode 100644 clearblade-cloud-iot/.metadata/.plugins/org.eclipse.jdt.core/assumedExternalFilesCache delete mode 100644 clearblade-cloud-iot/.metadata/.plugins/org.eclipse.jdt.core/externalFilesCache delete mode 100644 clearblade-cloud-iot/.metadata/.plugins/org.eclipse.jdt.core/javaLikeNames.txt delete mode 100644 clearblade-cloud-iot/.metadata/.plugins/org.eclipse.jdt.core/nonChainingJarsCache delete mode 100644 clearblade-cloud-iot/.metadata/.plugins/org.eclipse.jdt.core/variablesAndContainers.dat delete mode 100644 clearblade-cloud-iot/.metadata/.plugins/org.eclipse.jdt.ui/OpenTypeHistory.xml delete mode 100644 clearblade-cloud-iot/.metadata/.plugins/org.eclipse.jdt.ui/QualifiedTypeNameHistory.xml delete mode 100644 clearblade-cloud-iot/.metadata/.plugins/org.eclipse.m2e.core/workspaceState.ser delete mode 100644 clearblade-cloud-iot/.metadata/.plugins/org.eclipse.m2e.logback.configuration/0.log delete mode 100644 clearblade-cloud-iot/.metadata/.plugins/org.eclipse.m2e.logback.configuration/logback.1.16.3.20211002-1029.xml delete mode 100644 clearblade-cloud-iot/.metadata/.plugins/org.eclipse.oomph.setup/workspace.setup delete mode 100644 clearblade-cloud-iot/.metadata/.plugins/org.eclipse.tips.ide/dialog_settings.xml delete mode 100644 clearblade-cloud-iot/.metadata/.plugins/org.eclipse.ui.ide/dialog_settings.xml delete mode 100644 clearblade-cloud-iot/.metadata/.plugins/org.eclipse.ui.intro/introstate delete mode 100644 clearblade-cloud-iot/.metadata/.plugins/org.eclipse.ui.views.log/dialog_settings.xml delete mode 100644 clearblade-cloud-iot/.metadata/.plugins/org.eclipse.ui.workbench/dialog_settings.xml delete mode 100644 clearblade-cloud-iot/.metadata/.plugins/org.eclipse.ui.workbench/workingsets.xml delete mode 100644 clearblade-cloud-iot/.metadata/.plugins/org.eclipse.wildwebdeveloper.xml/system-catalog.xml delete mode 100644 clearblade-cloud-iot/.metadata/.plugins/org.eclipse.wst.common.snippets/hidden.xml delete mode 100644 clearblade-cloud-iot/.metadata/.plugins/org.eclipse.wst.common.snippets/user.xml delete mode 100644 clearblade-cloud-iot/.metadata/.plugins/org.eclipse.wst.sse.ui/dialog_settings.xml delete mode 100644 clearblade-cloud-iot/.metadata/version.ini delete mode 100644 clearblade-cloud-iot/bin/com/clearblade/cloud/iot/v1/DeviceManagerClient.class delete mode 100644 clearblade-cloud-iot/bin/com/clearblade/cloud/iot/v1/SendCommandToDeviceRequest$Builder.class delete mode 100644 clearblade-cloud-iot/bin/com/clearblade/cloud/iot/v1/SendCommandToDeviceRequest.class delete mode 100644 clearblade-cloud-iot/bin/com/clearblade/cloud/iot/v1/SendCommandToDeviceResponse$Builder.class delete mode 100644 clearblade-cloud-iot/bin/com/clearblade/cloud/iot/v1/SendCommandToDeviceResponse.class delete mode 100644 clearblade-cloud-iot/bin/com/clearblade/cloud/iot/v1/SyncSendCommandToDevice.class delete mode 100644 clearblade-cloud-iot/bin/com/clearblade/cloud/iot/v1/utils/Constants.class delete mode 100644 clearblade-cloud-iot/bin/com/clearblade/cloud/iot/v1/utils/DeviceName$Builder.class delete mode 100644 clearblade-cloud-iot/bin/com/clearblade/cloud/iot/v1/utils/DeviceName.class create mode 100644 clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/binddevicetogateway/AsyncBindDeviceToGateway.java create mode 100644 clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/binddevicetogateway/SyncBindDeviceToGateway.java delete mode 100644 clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/devicegetconfig/AsyncGetDeviceConfig.java delete mode 100644 clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/devicegetconfig/SyncGetDeviceConfig.java create mode 100644 clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/devicepatch/AsyncDevicePatch.java create mode 100644 clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/devicepatch/SyncDevicePatch.java create mode 100644 clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/devicesconfigversionslist/AsyncDevicesConfigVersionsList.java create mode 100644 clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/devicesconfigversionslist/SyncDevicesConfigVersionsList.java delete mode 100644 clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/devicesetstates/AsyncDeviceSetStates.java delete mode 100644 clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/devicesetstates/SyncDeviceSetStates.java create mode 100644 clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/modifycloudtodeviceconfig/AsyncModifyCloudToDeviceConfig.java create mode 100644 clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/modifycloudtodeviceconfig/SyncModifyCloudToDeviceConfig.java create mode 100644 clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/unbinddevicefromgateway/AsyncUnbindDeviceFromGateway.java create mode 100644 clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/unbinddevicefromgateway/SyncUnbindDeviceFromGateway.java delete mode 100644 clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/GetDeviceConfigRequest.java create mode 100644 clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/auth/AdminAccess.java create mode 100644 clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/auth/SystemAccess.java create mode 100644 clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/binddevicetogateway/BindDeviceToGatewayRequest.java create mode 100644 clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/binddevicetogateway/BindDeviceToGatewayResponse.java rename clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/{ => createdevice}/CreateDeviceRequest.java (98%) rename clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/{ => createdevice}/CreateDeviceResponse.java (96%) rename clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/{ => deletedevice}/DeleteDeviceRequest.java (93%) rename clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/{ => deletedevice}/DeleteDeviceResponse.java (95%) create mode 100644 clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/deviceconfigversionslist/DeviceConfigVersionsListRequest.java rename clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/{DeviceSetStatesResponse.java => deviceconfigversionslist/DeviceConfigVersionsListResponse.java} (69%) create mode 100644 clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/devicepatch/DevicePatchRequest.java rename clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/{GetDeviceConfigResponse.java => devicepatch/DevicePatchResponse.java} (60%) rename clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/{ => deviceslist}/DevicesListRequest.java (94%) rename clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/{ => deviceslist}/DevicesListResponse.java (96%) rename clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/{ => devicestateslist}/DeviceStatesListRequest.java (92%) rename clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/{ => devicestateslist}/DeviceStatesListResponse.java (96%) rename clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/{ => getdevice}/GetDeviceRequest.java (93%) rename clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/{ => getdevice}/GetDeviceResponse.java (96%) create mode 100644 clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/getregistrycredentials/GetRegistryCredentialsRequest.java create mode 100644 clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/getregistrycredentials/GetRegistryCredentialsResponse.java rename clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/{DeviceSetStatesRequest.java => modifycloudtodeviceconfig/ModifyCloudToDeviceConfigRequest.java} (51%) create mode 100644 clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/modifycloudtodeviceconfig/ModifyCloudToDeviceConfigResponse.java rename clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/{ => sendcommandtodevice}/SendCommandToDeviceRequest.java (97%) rename clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/{ => sendcommandtodevice}/SendCommandToDeviceResponse.java (71%) create mode 100644 clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/unbinddevicefromgateway/UnbindDeviceFromGatewayRequest.java create mode 100644 clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/unbinddevicefromgateway/UnbindDeviceFromGatewayResponse.java create mode 100644 clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/utils/AuthParams.java diff --git a/clearblade-cloud-iot/.metadata/.lock b/clearblade-cloud-iot/.metadata/.lock deleted file mode 100644 index e69de29b..00000000 diff --git a/clearblade-cloud-iot/.metadata/.log b/clearblade-cloud-iot/.metadata/.log deleted file mode 100644 index 77a46ed9..00000000 --- a/clearblade-cloud-iot/.metadata/.log +++ /dev/null @@ -1,253 +0,0 @@ -!SESSION 2022-10-25 12:50:37.162 ----------------------------------------------- -eclipse.buildId=4.23.0.I20220308-0310 -java.version=18.0.1.1 -java.vendor=Oracle Corporation -BootLoader constants: OS=win32, ARCH=x86_64, WS=win32, NL=en_IN -Framework arguments: -product org.eclipse.epp.package.jee.product -Command-line arguments: -os win32 -ws win32 -arch x86_64 -product org.eclipse.epp.package.jee.product - -!ENTRY org.eclipse.jface 2 0 2022-10-25 12:50:50.177 -!MESSAGE Keybinding conflicts occurred. They may interfere with normal accelerator operation. -!SUBENTRY 1 org.eclipse.jface 2 0 2022-10-25 12:50:50.177 -!MESSAGE A conflict occurred for CTRL+SHIFT+T: -Binding(CTRL+SHIFT+T, - ParameterizedCommand(Command(org.eclipse.jdt.ui.navigate.open.type,Open Type, - Open a type in a Java editor, - Category(org.eclipse.ui.category.navigate,Navigate,null,true), - org.eclipse.ui.internal.WorkbenchHandlerServiceHandler@46059b73, - ,,true),null), - org.eclipse.ui.defaultAcceleratorConfiguration, - org.eclipse.ui.contexts.window,,,system) -Binding(CTRL+SHIFT+T, - ParameterizedCommand(Command(org.eclipse.lsp4e.symbolinworkspace,Go to Symbol in Workspace, - , - Category(org.eclipse.lsp4e.category,Language Servers,null,true), - org.eclipse.ui.internal.WorkbenchHandlerServiceHandler@3b446d7, - ,,true),null), - org.eclipse.ui.defaultAcceleratorConfiguration, - org.eclipse.ui.contexts.window,,,system) -!SUBENTRY 1 org.eclipse.jface 2 0 2022-10-25 12:50:50.177 -!MESSAGE A conflict occurred for ALT+SHIFT+R: -Binding(ALT+SHIFT+R, - ParameterizedCommand(Command(org.eclipse.jdt.ui.edit.text.java.rename.element,Rename - Refactoring , - Rename the selected element, - Category(org.eclipse.jdt.ui.category.refactoring,Refactor - Java,Java Refactoring Actions,true), - org.eclipse.ui.internal.WorkbenchHandlerServiceHandler@6bb46040, - ,,true),null), - org.eclipse.ui.defaultAcceleratorConfiguration, - org.eclipse.ui.contexts.window,,,system) -Binding(ALT+SHIFT+R, - ParameterizedCommand(Command(org.eclipse.ui.edit.rename,Rename, - Rename the selected item, - Category(org.eclipse.ui.category.file,File,null,true), - org.eclipse.ui.internal.WorkbenchHandlerServiceHandler@2b71a12e, - ,,true),null), - org.eclipse.ui.defaultAcceleratorConfiguration, - org.eclipse.ui.contexts.window,,,system) - -!ENTRY org.eclipse.ui.navigator 2 0 2022-10-25 12:50:55.177 -!MESSAGE Can't find Navigator Content Descriptor with id: org.eclipse.jst.servlet.ui.EnhancedJavaRendering - -!ENTRY org.eclipse.ui.navigator 2 0 2022-10-25 12:50:55.179 -!MESSAGE Can't find Navigator Content Descriptor with id: org.eclipse.jst.servlet.ui.EnhancedJavaRendering - -!ENTRY org.eclipse.egit.ui 2 0 2022-10-25 12:50:55.338 -!MESSAGE Warning: The environment variable HOME is not set. The following directory will be used to store the Git -user global configuration and to define the default location to store repositories: 'C:\Users\DELL'. If this is -not correct please set the HOME environment variable and restart Eclipse. Otherwise Git for Windows and -EGit might behave differently since they see different configuration options. -This warning can be switched off on the Team > Git > Confirmations and Warnings preference page. -!SESSION 2022-10-25 12:57:39.100 ----------------------------------------------- -eclipse.buildId=4.23.0.I20220308-0310 -java.version=18.0.1.1 -java.vendor=Oracle Corporation -BootLoader constants: OS=win32, ARCH=x86_64, WS=win32, NL=en_IN -Framework arguments: -product org.eclipse.epp.package.jee.product -Command-line arguments: -os win32 -ws win32 -arch x86_64 -product org.eclipse.epp.package.jee.product - -!ENTRY org.eclipse.jface 2 0 2022-10-25 12:58:00.480 -!MESSAGE Keybinding conflicts occurred. They may interfere with normal accelerator operation. -!SUBENTRY 1 org.eclipse.jface 2 0 2022-10-25 12:58:00.480 -!MESSAGE A conflict occurred for CTRL+SHIFT+T: -Binding(CTRL+SHIFT+T, - ParameterizedCommand(Command(org.eclipse.jdt.ui.navigate.open.type,Open Type, - Open a type in a Java editor, - Category(org.eclipse.ui.category.navigate,Navigate,null,true), - org.eclipse.ui.internal.WorkbenchHandlerServiceHandler@768f2398, - ,,true),null), - org.eclipse.ui.defaultAcceleratorConfiguration, - org.eclipse.ui.contexts.window,,,system) -Binding(CTRL+SHIFT+T, - ParameterizedCommand(Command(org.eclipse.lsp4e.symbolinworkspace,Go to Symbol in Workspace, - , - Category(org.eclipse.lsp4e.category,Language Servers,null,true), - org.eclipse.ui.internal.WorkbenchHandlerServiceHandler@1f4fa465, - ,,true),null), - org.eclipse.ui.defaultAcceleratorConfiguration, - org.eclipse.ui.contexts.window,,,system) -!SUBENTRY 1 org.eclipse.jface 2 0 2022-10-25 12:58:00.480 -!MESSAGE A conflict occurred for ALT+SHIFT+R: -Binding(ALT+SHIFT+R, - ParameterizedCommand(Command(org.eclipse.jdt.ui.edit.text.java.rename.element,Rename - Refactoring , - Rename the selected element, - Category(org.eclipse.jdt.ui.category.refactoring,Refactor - Java,Java Refactoring Actions,true), - org.eclipse.ui.internal.WorkbenchHandlerServiceHandler@1e65c4d, - ,,true),null), - org.eclipse.ui.defaultAcceleratorConfiguration, - org.eclipse.ui.contexts.window,,,system) -Binding(ALT+SHIFT+R, - ParameterizedCommand(Command(org.eclipse.ui.edit.rename,Rename, - Rename the selected item, - Category(org.eclipse.ui.category.file,File,null,true), - org.eclipse.ui.internal.WorkbenchHandlerServiceHandler@6b888692, - ,,true),null), - org.eclipse.ui.defaultAcceleratorConfiguration, - org.eclipse.ui.contexts.window,,,system) - -!ENTRY org.eclipse.ui.navigator 2 0 2022-10-25 12:58:03.611 -!MESSAGE Can't find Navigator Content Descriptor with id: org.eclipse.jst.servlet.ui.EnhancedJavaRendering - -!ENTRY org.eclipse.ui.navigator 2 0 2022-10-25 12:58:03.612 -!MESSAGE Can't find Navigator Content Descriptor with id: org.eclipse.jst.servlet.ui.EnhancedJavaRendering - -!ENTRY org.eclipse.egit.ui 2 0 2022-10-25 12:58:03.671 -!MESSAGE Warning: The environment variable HOME is not set. The following directory will be used to store the Git -user global configuration and to define the default location to store repositories: 'C:\Users\DELL'. If this is -not correct please set the HOME environment variable and restart Eclipse. Otherwise Git for Windows and -EGit might behave differently since they see different configuration options. -This warning can be switched off on the Team > Git > Confirmations and Warnings preference page. - -!ENTRY org.eclipse.wildwebdeveloper.xml 4 0 2022-10-25 12:58:59.996 -!MESSAGE /org/eclipse/persistence/jaxb/eclipselink_oxm_2_5.xsd -!STACK 0 -java.io.FileNotFoundException: /org/eclipse/persistence/jaxb/eclipselink_oxm_2_5.xsd - at org.eclipse.osgi.storage.url.bundleentry.Handler.findBundleEntry(Handler.java:55) - at org.eclipse.osgi.storage.url.BundleResourceHandler.openConnection(BundleResourceHandler.java:182) - at java.base/java.net.URL.openConnection(URL.java:1094) - at org.eclipse.core.internal.boot.PlatformURLConnection.connect(PlatformURLConnection.java:115) - at org.eclipse.core.internal.boot.PlatformURLConnection.getURLAsLocal(PlatformURLConnection.java:240) - at org.eclipse.core.internal.runtime.PlatformURLConverter.toFileURL(PlatformURLConverter.java:37) - at org.eclipse.core.runtime.FileLocator.toFileURL(FileLocator.java:263) - at org.eclipse.wildwebdeveloper.xml.internal.ui.preferences.XMLCatalogs.createURI(XMLCatalogs.java:139) - at org.eclipse.wildwebdeveloper.xml.internal.ui.preferences.XMLCatalogs.lambda$3(XMLCatalogs.java:87) - at java.base/java.util.stream.ForEachOps$ForEachOp$OfRef.accept(ForEachOps.java:183) - at java.base/java.util.Spliterators$ArraySpliterator.forEachRemaining(Spliterators.java:992) - at java.base/java.util.stream.ReferencePipeline$Head.forEach(ReferencePipeline.java:762) - at java.base/java.util.stream.ReferencePipeline$7$1.accept(ReferencePipeline.java:276) - at java.base/java.util.stream.ReferencePipeline$2$1.accept(ReferencePipeline.java:179) - at java.base/java.util.Spliterators$ArraySpliterator.forEachRemaining(Spliterators.java:992) - at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:509) - at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:499) - at java.base/java.util.stream.ForEachOps$ForEachOp.evaluateSequential(ForEachOps.java:150) - at java.base/java.util.stream.ForEachOps$ForEachOp$OfRef.evaluateSequential(ForEachOps.java:173) - at java.base/java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234) - at java.base/java.util.stream.ReferencePipeline.forEach(ReferencePipeline.java:596) - at org.eclipse.wildwebdeveloper.xml.internal.ui.preferences.XMLCatalogs.getWTPExtensionCatalog(XMLCatalogs.java:65) - at org.eclipse.wildwebdeveloper.xml.internal.ui.preferences.XMLCatalogs.getAllCatalogs(XMLCatalogs.java:52) - at org.eclipse.wildwebdeveloper.xml.internal.ui.preferences.XMLPreferenceConstants.storePreferencesToLemminxOptions(XMLPreferenceConstants.java:90) - at org.eclipse.wildwebdeveloper.xml.internal.XMLLanguageServer.mergeCustomInitializationOptions(XMLLanguageServer.java:163) - at org.eclipse.wildwebdeveloper.xml.internal.XMLLanguageServer.getInitializationOptions(XMLLanguageServer.java:158) - at org.eclipse.lsp4e.LanguageServerWrapper.lambda$8(LanguageServerWrapper.java:353) - at java.base/java.util.concurrent.CompletableFuture$UniCompose.tryFire(CompletableFuture.java:1150) - at java.base/java.util.concurrent.CompletableFuture.postComplete(CompletableFuture.java:510) - at java.base/java.util.concurrent.CompletableFuture$AsyncSupply.run(CompletableFuture.java:1773) - at java.base/java.util.concurrent.CompletableFuture$AsyncSupply.exec(CompletableFuture.java:1760) - at java.base/java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:373) - at java.base/java.util.concurrent.ForkJoinPool$WorkQueue.topLevelExec(ForkJoinPool.java:1182) - at java.base/java.util.concurrent.ForkJoinPool.scan(ForkJoinPool.java:1655) - at java.base/java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1622) - at java.base/java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:165) - -!ENTRY org.eclipse.egit.ui 4 0 2022-10-25 13:00:26.178 -!MESSAGE file:///E:\Git\java-iot\clearblade-cloud-iot: not found. -!STACK 0 -org.eclipse.jgit.api.errors.TransportException: file:///E:\Git\java-iot\clearblade-cloud-iot: not found. - at org.eclipse.jgit.api.LsRemoteCommand.execute(LsRemoteCommand.java:189) - at org.eclipse.jgit.api.LsRemoteCommand.call(LsRemoteCommand.java:128) - at org.eclipse.egit.core.op.ListRemoteOperation.run(ListRemoteOperation.java:116) - at org.eclipse.egit.ui.internal.clone.SourceBranchPage$9.run(SourceBranchPage.java:377) - at org.eclipse.jface.operation.ModalContext$ModalContextThread.run(ModalContext.java:122) -Caused by: org.eclipse.jgit.errors.NoRemoteRepositoryException: file:///E:\Git\java-iot\clearblade-cloud-iot: not found. - at org.eclipse.jgit.transport.TransportLocal$1.open(TransportLocal.java:115) - at org.eclipse.jgit.transport.TransportBundleFile$1.open(TransportBundleFile.java:84) - at org.eclipse.jgit.transport.Transport.open(Transport.java:551) - at org.eclipse.jgit.api.LsRemoteCommand.execute(LsRemoteCommand.java:156) - ... 4 more - -!ENTRY org.eclipse.egit.ui 4 0 2022-10-25 13:01:15.121 -!MESSAGE Invalid project description. -!STACK 1 -org.eclipse.core.internal.resources.ResourceException: Invalid project description. - at org.eclipse.core.internal.resources.Project.checkDescription(Project.java:173) - at org.eclipse.core.internal.resources.Project.assertCreateRequirements(Project.java:57) - at org.eclipse.core.internal.resources.Project.create(Project.java:267) - at org.eclipse.core.internal.resources.Project.create(Project.java:253) - at org.eclipse.egit.ui.internal.clone.ProjectUtils.createExistingProject(ProjectUtils.java:179) - at org.eclipse.egit.ui.internal.clone.ProjectUtils$1.run(ProjectUtils.java:104) - at org.eclipse.core.internal.resources.Workspace.run(Workspace.java:2315) - at org.eclipse.core.internal.resources.Workspace.run(Workspace.java:2335) - at org.eclipse.egit.ui.internal.clone.ProjectUtils.createProjects(ProjectUtils.java:138) - at org.eclipse.egit.ui.internal.clone.ProjectUtils.createProjects(ProjectUtils.java:62) - at org.eclipse.egit.ui.internal.clone.GitImportWizard.importProjects(GitImportWizard.java:254) - at org.eclipse.egit.ui.internal.clone.GitImportWizard$4.run(GitImportWizard.java:206) - at org.eclipse.jface.operation.ModalContext$ModalContextThread.run(ModalContext.java:122) -Contains: OK -Contains: E:\Git\java-iot\clearblade-cloud-iot overlaps the workspace location: E:\Git\java-iot\clearblade-cloud-iot -!SUBENTRY 1 org.eclipse.core.resources 4 77 2022-10-25 13:01:15.122 -!MESSAGE Invalid project description. -!SUBENTRY 2 unknown 0 0 2022-10-25 13:01:15.122 -!MESSAGE OK -!SUBENTRY 2 org.eclipse.core.resources 4 77 2022-10-25 13:01:15.122 -!MESSAGE E:\Git\java-iot\clearblade-cloud-iot overlaps the workspace location: E:\Git\java-iot\clearblade-cloud-iot - -!ENTRY org.eclipse.egit.ui 4 0 2022-10-25 13:01:42.849 -!MESSAGE Invalid project description. -!STACK 1 -org.eclipse.core.internal.resources.ResourceException: Invalid project description. - at org.eclipse.core.internal.resources.Project.checkDescription(Project.java:173) - at org.eclipse.core.internal.resources.Project.assertCreateRequirements(Project.java:57) - at org.eclipse.core.internal.resources.Project.create(Project.java:267) - at org.eclipse.core.internal.resources.Project.create(Project.java:253) - at org.eclipse.egit.ui.internal.clone.ProjectUtils.createExistingProject(ProjectUtils.java:179) - at org.eclipse.egit.ui.internal.clone.ProjectUtils$1.run(ProjectUtils.java:104) - at org.eclipse.core.internal.resources.Workspace.run(Workspace.java:2315) - at org.eclipse.core.internal.resources.Workspace.run(Workspace.java:2335) - at org.eclipse.egit.ui.internal.clone.ProjectUtils.createProjects(ProjectUtils.java:138) - at org.eclipse.egit.ui.internal.clone.ProjectUtils.createProjects(ProjectUtils.java:62) - at org.eclipse.egit.ui.internal.clone.GitImportWizard.importProjects(GitImportWizard.java:254) - at org.eclipse.egit.ui.internal.clone.GitImportWizard$4.run(GitImportWizard.java:206) - at org.eclipse.jface.operation.ModalContext$ModalContextThread.run(ModalContext.java:122) -Contains: OK -Contains: E:\Git\java-iot\clearblade-cloud-iot overlaps the workspace location: E:\Git\java-iot\clearblade-cloud-iot -!SUBENTRY 1 org.eclipse.core.resources 4 77 2022-10-25 13:01:42.849 -!MESSAGE Invalid project description. -!SUBENTRY 2 unknown 0 0 2022-10-25 13:01:42.849 -!MESSAGE OK -!SUBENTRY 2 org.eclipse.core.resources 4 77 2022-10-25 13:01:42.849 -!MESSAGE E:\Git\java-iot\clearblade-cloud-iot overlaps the workspace location: E:\Git\java-iot\clearblade-cloud-iot - -!ENTRY org.eclipse.egit.ui 4 0 2022-10-25 13:01:55.130 -!MESSAGE Invalid project description. -!STACK 1 -org.eclipse.core.internal.resources.ResourceException: Invalid project description. - at org.eclipse.core.internal.resources.Project.checkDescription(Project.java:173) - at org.eclipse.core.internal.resources.Project.assertCreateRequirements(Project.java:57) - at org.eclipse.core.internal.resources.Project.create(Project.java:267) - at org.eclipse.core.internal.resources.Project.create(Project.java:253) - at org.eclipse.egit.ui.internal.clone.ProjectUtils.createExistingProject(ProjectUtils.java:179) - at org.eclipse.egit.ui.internal.clone.ProjectUtils$1.run(ProjectUtils.java:104) - at org.eclipse.core.internal.resources.Workspace.run(Workspace.java:2315) - at org.eclipse.core.internal.resources.Workspace.run(Workspace.java:2335) - at org.eclipse.egit.ui.internal.clone.ProjectUtils.createProjects(ProjectUtils.java:138) - at org.eclipse.egit.ui.internal.clone.ProjectUtils.createProjects(ProjectUtils.java:62) - at org.eclipse.egit.ui.internal.clone.GitImportWizard.importProjects(GitImportWizard.java:254) - at org.eclipse.egit.ui.internal.clone.GitImportWizard$4.run(GitImportWizard.java:206) - at org.eclipse.jface.operation.ModalContext$ModalContextThread.run(ModalContext.java:122) -Contains: OK -Contains: E:\Git\java-iot\clearblade-cloud-iot overlaps the workspace location: E:\Git\java-iot\clearblade-cloud-iot -!SUBENTRY 1 org.eclipse.core.resources 4 77 2022-10-25 13:01:55.131 -!MESSAGE Invalid project description. -!SUBENTRY 2 unknown 0 0 2022-10-25 13:01:55.131 -!MESSAGE OK -!SUBENTRY 2 org.eclipse.core.resources 4 77 2022-10-25 13:01:55.131 -!MESSAGE E:\Git\java-iot\clearblade-cloud-iot overlaps the workspace location: E:\Git\java-iot\clearblade-cloud-iot diff --git a/clearblade-cloud-iot/.metadata/.mylyn/repositories.xml.zip b/clearblade-cloud-iot/.metadata/.mylyn/repositories.xml.zip deleted file mode 100644 index e077dca6333d48e6d32da99de4fced76baf63fdf..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 685 zcmWIWW@Zs#;Nak3=t_$WWk3P~Kz31TL4I*&Nq$jgYO!8LZqD2A`}vm*1pb99?VoHg zLBPp(d1ljc#Z`s^`Ik-iE(@D$apU>AoALdxRnFd8V!>PMRNZ}N_xbyOf1JC1@~fHf zLAI&SjQVee{+Px(L%rzWXOlF0xqW+no>;ehGW&(s)jCU_sffDE))V{`OmC}kQ+Z8J|u)1~5Slhw%SF`KQMm|HqJr^XrrtV_C_NhX??!_mLj`SZo#XUEB zp9$P;^5B_xbQ?$YmNg=&a+6e*cPtCon;bO^X9cJUWQXVW4^!D_H2d&ZqY`GhDJh>gaQz&uqQ|~;-nCdGw{pfFwafm$1C{Nfq+h!J{rdG?UD<5~KXqeO z?vN0+a~rOmm&#Sm^4z#0J7o2#nWj;%H(LwM-kiVWMtXcXc=*ga4eh${pXcGutm5bolr*>A`}JF_tBNdRlM# zFWty+{BTxD)GbA`X{YM8^gavd-7~kkWJl(l8#XOI4p*|>|K43^x&HLg8BZUr^Lo4> zy{^3VUFFPmarc-0{}Q`u_v82aleQ=Ca^A1}{l$;_C%*6pc(ZfJeU(;~W@2DC#>2o6 l;LXS+!hlFx$a0{hg$mFUT7Wkz8%PBs5ZVFhNT8_<3;_ObD<}W} diff --git a/clearblade-cloud-iot/.metadata/.plugins/org.eclipse.core.resources/.projects/.org.eclipse.egit.core.cmp/.location b/clearblade-cloud-iot/.metadata/.plugins/org.eclipse.core.resources/.projects/.org.eclipse.egit.core.cmp/.location deleted file mode 100644 index d72bf60cc0c883b7bc40e6ec018872d158dbbff0..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 163 zcmZ?R*xjhShe1S2b=vdAllRFn6o&?R>g%Uv=A>HbyISeHXO`$^C6*=XX6BdZC+DOl z7A55*rljg7=j4~BfCcq(Q%e$45=#>G^$K!I(=+pm_4A9;^-_~_G7E}R^-|L_OZ1ZS fi&FLVunOxX=N2%afCCY~KZBhV__?Qgclj{@ox(Wp diff --git a/clearblade-cloud-iot/.metadata/.plugins/org.eclipse.core.resources/.root/.indexes/history.version b/clearblade-cloud-iot/.metadata/.plugins/org.eclipse.core.resources/.root/.indexes/history.version deleted file mode 100644 index 25cb955b..00000000 --- a/clearblade-cloud-iot/.metadata/.plugins/org.eclipse.core.resources/.root/.indexes/history.version +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/clearblade-cloud-iot/.metadata/.plugins/org.eclipse.core.resources/.root/.indexes/properties.index b/clearblade-cloud-iot/.metadata/.plugins/org.eclipse.core.resources/.root/.indexes/properties.index deleted file mode 100644 index bb5ccc45e269530cb0369a289d8392463eaff5f0..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 57 zcmZQ%U|?WmVAN+|WMUA>FG|--P0qu4pI&6}TZ-ZNS$NL6P23qtF{L~PgD z?@Y^hkad9tLxq5%2tBTNxNz z8JjD328SpZ85kMya_Q@p6s4xx0$Is9sfk4{sW~Ny@%csRda21dnFYnEdMT+%rRjRf z`9-O=X^A<-KofB&%t|RCMp - - - activeSchemeId:org.eclipse.ui.defaultAcceleratorConfiguration - - - - - - - - topLevel - shellMaximized - - - - - persp.actionSet:org.eclipse.mylyn.doc.actionSet - persp.actionSet:org.eclipse.mylyn.tasks.ui.navigation - persp.actionSet:org.eclipse.ui.cheatsheets.actionSet - persp.actionSet:org.eclipse.search.searchActionSet - persp.actionSet:org.eclipse.text.quicksearch.actionSet - persp.actionSet:org.eclipse.ui.edit.text.actionSet.annotationNavigation - persp.actionSet:org.eclipse.ui.edit.text.actionSet.navigation - persp.actionSet:org.eclipse.ui.edit.text.actionSet.convertLineDelimitersTo - persp.actionSet:org.eclipse.ui.externaltools.ExternalToolsSet - persp.actionSet:org.eclipse.ui.actionSet.keyBindings - persp.actionSet:org.eclipse.ui.actionSet.openFiles - persp.actionSet:org.eclipse.jst.j2ee.J2eeMainActionSet - persp.actionSet:org.eclipse.jdt.ui.JavaActionSet - persp.actionSet:org.eclipse.debug.ui.launchActionSet - persp.actionSet:org.eclipse.debug.ui.debugActionSet - persp.actionSet:org.eclipse.ui.NavigateActionSet - persp.viewSC:org.eclipse.ui.navigator.ProjectExplorer - persp.viewSC:org.eclipse.wst.server.ui.ServersView - persp.viewSC:org.eclipse.datatools.connectivity.DataSourceExplorerNavigator - persp.viewSC:org.eclipse.ui.views.BookmarkView - persp.viewSC:org.eclipse.ui.views.ContentOutline - persp.viewSC:org.eclipse.ui.views.PropertySheet - persp.viewSC:org.eclipse.ui.views.ResourceNavigator - persp.viewSC:org.eclipse.wst.common.snippets.internal.ui.SnippetsView - persp.viewSC:org.eclipse.ui.views.AllMarkersView - persp.viewSC:org.eclipse.mylyn.tasks.ui.views.tasks - persp.viewSC:org.eclipse.search.ui.views.SearchView - persp.viewSC:org.eclipse.ui.console.ConsoleView - persp.showIn:org.eclipse.ui.navigator.ProjectExplorer - persp.actionSet:org.eclipse.wst.ws.explorer.explorer - persp.newWizSC:org.eclipse.m2e.core.wizards.Maven2ProjectWizard - persp.newWizSC:org.eclipse.wst.css.ui.internal.wizard.NewCSSWizard - persp.newWizSC:org.eclipse.wst.jsdt.ui.NewJSWizard - persp.actionSet:org.eclipse.eclemma.ui.CoverageActionSet - persp.showIn:org.eclipse.eclemma.ui.CoverageView - persp.showIn:org.eclipse.tm.terminal.view.ui.TerminalsView - persp.perspSC:org.eclipse.debug.ui.DebugPerspective - persp.perspSC:org.eclipse.jdt.ui.JavaPerspective - persp.perspSC:org.eclipse.ui.resourcePerspective - persp.perspSC:org.eclipse.wst.web.ui.webDevPerspective - persp.newWizSC:org.eclipse.jst.j2ee.ui.project.facet.EarProjectWizard - persp.newWizSC:org.eclipse.jst.servlet.ui.project.facet.WebProjectWizard - persp.newWizSC:org.eclipse.jst.ejb.ui.project.facet.EjbProjectWizard - persp.newWizSC:org.eclipse.jst.j2ee.jca.ui.internal.wizard.ConnectorProjectWizard - persp.newWizSC:org.eclipse.jst.j2ee.ui.project.facet.appclient.AppClientProjectWizard - persp.newWizSC:org.eclipse.wst.web.ui.internal.wizards.SimpleWebProjectWizard - persp.newWizSC:org.eclipse.jpt.ui.wizard.newJpaProject - persp.newWizSC:org.eclipse.jst.servlet.ui.internal.wizard.AddServletWizard - persp.newWizSC:org.eclipse.jst.ejb.ui.internal.wizard.AddSessionBeanWizard - persp.newWizSC:org.eclipse.jst.ejb.ui.internal.wizard.AddMessageDrivenBeanWizard - persp.newWizSC:org.eclipse.jpt.ui.wizard.newEntity - persp.newWizSC:org.eclipse.jst.ws.creation.ui.wizard.serverwizard - persp.newWizSC:org.eclipse.ui.wizards.new.folder - persp.newWizSC:org.eclipse.ui.wizards.new.file - persp.actionSet:org.eclipse.wst.server.ui.internal.webbrowser.actionSet - persp.actionSet:org.eclipse.debug.ui.breakpointActionSet - persp.newWizSC:org.eclipse.jpt.jpa.ui.wizard.newJpaProject - persp.perspSC:org.eclipse.jpt.ui.jpaPerspective - persp.newWizSC:org.eclipse.jst.jsp.ui.internal.wizard.NewJSPWizard - - - - View - categoryTag:General - - - View - categoryTag:General - - - View - categoryTag:Java - - - View - categoryTag:Java Browsing - - - - - - - - View - categoryTag:General - - - View - categoryTag:Mylyn - - - View - categoryTag:General - - - - - General - active - - View - categoryTag:General - - - View - categoryTag:General - - - View - categoryTag:Server - - - View - categoryTag:Data Management - - - View - categoryTag:General - - - View - categoryTag:General - - - View - categoryTag:General - - - View - categoryTag:General - - - View - categoryTag:General - - - View - categoryTag:General - - - View - categoryTag:General - - - View - categoryTag:General - - - - - - - - - View - categoryTag:Help - - - View - categoryTag:General - - - View - categoryTag:Help - - - - - - - View - categoryTag:Help - - - - - - View - categoryTag:General - - ViewMenu - menuContribution:menu - - - - - - - View - categoryTag:Help - - - - org.eclipse.e4.primaryDataStack - EditorStack - - - - - - - View - categoryTag:General - - ViewMenu - menuContribution:menu - - - - - - - View - categoryTag:General - - - - - View - categoryTag:Java - - - - - View - categoryTag:Java Browsing - - - - - - View - categoryTag:General - - ViewMenu - menuContribution:menu - - - - - - - - View - categoryTag:General - - ViewMenu - menuContribution:menu - - - - - - - - View - categoryTag:Server - - ViewMenu - menuContribution:menu - - - - - - - - View - categoryTag:Data Management - - ViewMenu - menuContribution:menu - - - - - - - - View - categoryTag:General - - ViewMenu - menuContribution:menu - - - - - - - View - categoryTag:General - - - - - View - categoryTag:General - - - - - View - categoryTag:General - - - - - View - categoryTag:General - - - - - View - categoryTag:General - - - - - View - categoryTag:General - - - - - - View - categoryTag:General - - ViewMenu - menuContribution:menu - - - - - - - View - categoryTag:Mylyn - - - - - View - categoryTag:General - - - - - - View - categoryTag:General - active - activeOnClose - - ViewMenu - menuContribution:menu - - - - - - toolbarSeparator - - - - Draggable - - - - toolbarSeparator - - - - Draggable - - - toolbarSeparator - - - - Draggable - - - Draggable - - - Draggable - - - Draggable - - - Draggable - - - toolbarSeparator - - - - Draggable - - - - toolbarSeparator - - - - toolbarSeparator - - - - Draggable - - - stretch - SHOW_RESTORE_MENU - - - Draggable - HIDEABLE - SHOW_RESTORE_MENU - - - - - stretch - - - Draggable - - - Draggable - - - - - TrimStack - Draggable - - - - - - - - - - - - - - - - - - - - - - platform:win32 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - platform:win32 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - View - Spy - categoryTag:Eclipse Runtime Spies - - - - - - - - - - - - - - - - - - - - - - - - - View - Spy - categoryTag:Eclipse Runtime Spies - - - View - Spy - categoryTag:Eclipse Runtime Spies - - - View - Spy - categoryTag:Eclipse Runtime Spies - - - View - Spy - categoryTag:Eclipse Runtime Spies - - - View - Spy - categoryTag:Eclipse Runtime Spies - - - Editor - removeOnHide - - - - - View - categoryTag:Ant - - - - - View - categoryTag:Gradle - - - - - View - categoryTag:Gradle - - - - - View - categoryTag:Data Management - - - - - View - categoryTag:Data Management - - - - - View - categoryTag:Data Management - - - - - View - categoryTag:Debug - - - - - View - categoryTag:Debug - - - - - View - categoryTag:Debug - - - - - View - categoryTag:Debug - - - - - View - categoryTag:Debug - - - - - View - categoryTag:Debug - - - - - View - categoryTag:Debug - - - View - categoryTag:Debug - - - - - View - categoryTag:Java - - - - - View - categoryTag:Git - - - - - View - categoryTag:Git - - - - - View - categoryTag:Git - - - - - View - categoryTag:Git - NoRestore - - - - - View - categoryTag:Git - - - - - View - categoryTag:General - - - - - View - categoryTag:Help - - - - - View - categoryTag:Debug - - - - - View - categoryTag:Java - - - - - View - categoryTag:Java - - - - - View - categoryTag:Java - - - - - View - categoryTag:Java Browsing - - - - - View - categoryTag:Java Browsing - - - - - View - categoryTag:Java Browsing - - - - - View - categoryTag:Java Browsing - - - - - View - categoryTag:Java - - - - - View - categoryTag:General - - - - - View - categoryTag:Java - - - - - View - categoryTag:Java - - - - - View - categoryTag:JPA - - - - - View - categoryTag:JPA - - - - - View - categoryTag:JavaServer Faces - - - - - View - categoryTag:JavaServer Faces - - - - - View - categoryTag:Web Services - - - - - View - categoryTag:Maven - - - - - View - categoryTag:Maven - - - - - View - categoryTag:Maven - - - - - View - categoryTag:Mylyn - - - - - View - categoryTag:Mylyn - - - - - View - categoryTag:Mylyn - - - - - View - categoryTag:Oomph - - - - - View - categoryTag:API Tools - - - - - View - categoryTag:Plug-in Development - - - - - View - categoryTag:Plug-in Development - - - - - View - categoryTag:Plug-in Development - - - - - View - categoryTag:Plug-in Development - - - - - View - categoryTag:Plug-in Development - - - - - View - categoryTag:Plug-in Development - - - - - View - categoryTag:General - - - - - View - categoryTag:Version Control (Team) - - - - - View - categoryTag:Version Control (Team) - - - View - categoryTag:Help - - - - - View - categoryTag:Terminal - - - - - View - categoryTag:Other - - - - - View - categoryTag:General - - - - - View - categoryTag:General - - - - - View - categoryTag:Help - - - - - View - categoryTag:General - - - - - View - categoryTag:General - - - - - View - categoryTag:General - - - - - View - categoryTag:General - - - - - View - categoryTag:General - - - - - View - categoryTag:General - - - - - View - categoryTag:General - - - - - View - categoryTag:General - - - - - View - categoryTag:General - - - - - View - categoryTag:General - - - - - View - categoryTag:General - - - - - View - categoryTag:General - - - - - View - categoryTag:General - - - - - View - categoryTag:Debug - - - - - View - categoryTag:Other - - - - - View - categoryTag:Other - - - - - View - categoryTag:Other - - - - - View - categoryTag:Server - - - - - View - categoryTag:XML - - - - - View - categoryTag:XML - - - - - View - categoryTag:XML - - - - - View - categoryTag:XML - - - - - View - categoryTag:XML - - - - glue - move_after:PerspectiveSpacer - SHOW_RESTORE_MENU - - - move_after:Spacer Glue - HIDEABLE - SHOW_RESTORE_MENU - - - glue - move_after:SearchField - SHOW_RESTORE_MENU - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/clearblade-cloud-iot/.metadata/.plugins/org.eclipse.egit.ui/dialog_settings.xml b/clearblade-cloud-iot/.metadata/.plugins/org.eclipse.egit.ui/dialog_settings.xml deleted file mode 100644 index 171dcdb3..00000000 --- a/clearblade-cloud-iot/.metadata/.plugins/org.eclipse.egit.ui/dialog_settings.xml +++ /dev/null @@ -1,11 +0,0 @@ - -
- - - - - -
- -
-
diff --git a/clearblade-cloud-iot/.metadata/.plugins/org.eclipse.jdt.core/assumedExternalFilesCache b/clearblade-cloud-iot/.metadata/.plugins/org.eclipse.jdt.core/assumedExternalFilesCache deleted file mode 100644 index 593f4708db84ac8fd0f5cc47c634f38c013fe9e4..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 4 LcmZQzU|;|M00aO5 diff --git a/clearblade-cloud-iot/.metadata/.plugins/org.eclipse.jdt.core/externalFilesCache b/clearblade-cloud-iot/.metadata/.plugins/org.eclipse.jdt.core/externalFilesCache deleted file mode 100644 index 593f4708db84ac8fd0f5cc47c634f38c013fe9e4..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 4 LcmZQzU|;|M00aO5 diff --git a/clearblade-cloud-iot/.metadata/.plugins/org.eclipse.jdt.core/javaLikeNames.txt b/clearblade-cloud-iot/.metadata/.plugins/org.eclipse.jdt.core/javaLikeNames.txt deleted file mode 100644 index 85863977..00000000 --- a/clearblade-cloud-iot/.metadata/.plugins/org.eclipse.jdt.core/javaLikeNames.txt +++ /dev/null @@ -1 +0,0 @@ -java \ No newline at end of file diff --git a/clearblade-cloud-iot/.metadata/.plugins/org.eclipse.jdt.core/nonChainingJarsCache b/clearblade-cloud-iot/.metadata/.plugins/org.eclipse.jdt.core/nonChainingJarsCache deleted file mode 100644 index 593f4708db84ac8fd0f5cc47c634f38c013fe9e4..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 4 LcmZQzU|;|M00aO5 diff --git a/clearblade-cloud-iot/.metadata/.plugins/org.eclipse.jdt.core/variablesAndContainers.dat b/clearblade-cloud-iot/.metadata/.plugins/org.eclipse.jdt.core/variablesAndContainers.dat deleted file mode 100644 index 3de398e8f2856ff30f4c5dd9cf8cfd66b137fcc8..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 129 zcmX|&TMB?66hudR2o)`+B_tP8G)3*({qG_l;QblSnYjQs`iT}o2g*j>tPn$^7-S`m py>^9ybE%pMoBm#v^5ZO3G2cM$*bk0n6(Ils diff --git a/clearblade-cloud-iot/.metadata/.plugins/org.eclipse.jdt.ui/OpenTypeHistory.xml b/clearblade-cloud-iot/.metadata/.plugins/org.eclipse.jdt.ui/OpenTypeHistory.xml deleted file mode 100644 index a4ee3cbc..00000000 --- a/clearblade-cloud-iot/.metadata/.plugins/org.eclipse.jdt.ui/OpenTypeHistory.xml +++ /dev/null @@ -1,2 +0,0 @@ - - diff --git a/clearblade-cloud-iot/.metadata/.plugins/org.eclipse.jdt.ui/QualifiedTypeNameHistory.xml b/clearblade-cloud-iot/.metadata/.plugins/org.eclipse.jdt.ui/QualifiedTypeNameHistory.xml deleted file mode 100644 index 9e390f50..00000000 --- a/clearblade-cloud-iot/.metadata/.plugins/org.eclipse.jdt.ui/QualifiedTypeNameHistory.xml +++ /dev/null @@ -1,2 +0,0 @@ - - diff --git a/clearblade-cloud-iot/.metadata/.plugins/org.eclipse.m2e.core/workspaceState.ser b/clearblade-cloud-iot/.metadata/.plugins/org.eclipse.m2e.core/workspaceState.ser deleted file mode 100644 index abbf8e5211b6a04431b29bc5ab1269fb2676782d..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 538 zcmc(bO-{ow5QRs9@+$-d#4%inEfPPi6oC|^stc9~;|z^cCw9j!O(n`PI0aW=QE>s- zus~daJCHP?RP0#c&3NAPeDmbTPpDafLrqoNGVs$kd9F}M%b0s z(TKH6p;PtPoUD&~PcI&T$p~71q&2yf;urE_eE0D7aT$BC6u?dupv4WpmP$H_*1={F z^IP5+IH?-v+#LM8>tKH%2@_16?ZZ8I0qjz#h4YNc+a7A_S;GaMkdrrD%%zrT zD*VQ6%p0X>GL!#gy~xChOzf1~D9=?}exE$=UA-=V=fj%PJoNJon$BR=MT9oeD$Hk( Tj$wL+D|y)}uGy5k_)o?cALX5n diff --git a/clearblade-cloud-iot/.metadata/.plugins/org.eclipse.m2e.logback.configuration/0.log b/clearblade-cloud-iot/.metadata/.plugins/org.eclipse.m2e.logback.configuration/0.log deleted file mode 100644 index 67d19c80..00000000 --- a/clearblade-cloud-iot/.metadata/.plugins/org.eclipse.m2e.logback.configuration/0.log +++ /dev/null @@ -1,2 +0,0 @@ -2022-10-25 12:50:54,986 [Worker-4: Loading available Gradle versions] INFO o.e.b.c.i.u.g.PublishedGradleVersions - Gradle version information cache is up-to-date. Trying to read. -2022-10-25 12:58:03,944 [Worker-4: Loading available Gradle versions] INFO o.e.b.c.i.u.g.PublishedGradleVersions - Gradle version information cache is up-to-date. Trying to read. diff --git a/clearblade-cloud-iot/.metadata/.plugins/org.eclipse.m2e.logback.configuration/logback.1.16.3.20211002-1029.xml b/clearblade-cloud-iot/.metadata/.plugins/org.eclipse.m2e.logback.configuration/logback.1.16.3.20211002-1029.xml deleted file mode 100644 index 45125560..00000000 --- a/clearblade-cloud-iot/.metadata/.plugins/org.eclipse.m2e.logback.configuration/logback.1.16.3.20211002-1029.xml +++ /dev/null @@ -1,41 +0,0 @@ - - - - %date [%thread] %-5level %logger{35} - %msg%n - - - OFF - - - - - ${org.eclipse.m2e.log.dir}/0.log - - ${org.eclipse.m2e.log.dir}/%i.log - 1 - 10 - - - 100MB - - - %date [%thread] %-5level %logger{35} - %msg%n - - - - - - WARN - - - - - - - - - - - - - diff --git a/clearblade-cloud-iot/.metadata/.plugins/org.eclipse.oomph.setup/workspace.setup b/clearblade-cloud-iot/.metadata/.plugins/org.eclipse.oomph.setup/workspace.setup deleted file mode 100644 index 1f73e14c..00000000 --- a/clearblade-cloud-iot/.metadata/.plugins/org.eclipse.oomph.setup/workspace.setup +++ /dev/null @@ -1,6 +0,0 @@ - - diff --git a/clearblade-cloud-iot/.metadata/.plugins/org.eclipse.tips.ide/dialog_settings.xml b/clearblade-cloud-iot/.metadata/.plugins/org.eclipse.tips.ide/dialog_settings.xml deleted file mode 100644 index 5ca0b776..00000000 --- a/clearblade-cloud-iot/.metadata/.plugins/org.eclipse.tips.ide/dialog_settings.xml +++ /dev/null @@ -1,3 +0,0 @@ - -
-
diff --git a/clearblade-cloud-iot/.metadata/.plugins/org.eclipse.ui.ide/dialog_settings.xml b/clearblade-cloud-iot/.metadata/.plugins/org.eclipse.ui.ide/dialog_settings.xml deleted file mode 100644 index 20bb49b7..00000000 --- a/clearblade-cloud-iot/.metadata/.plugins/org.eclipse.ui.ide/dialog_settings.xml +++ /dev/null @@ -1,26 +0,0 @@ - -
-
- - - - - - - - -
-
- - - - - - - - - - - -
-
diff --git a/clearblade-cloud-iot/.metadata/.plugins/org.eclipse.ui.intro/introstate b/clearblade-cloud-iot/.metadata/.plugins/org.eclipse.ui.intro/introstate deleted file mode 100644 index 02f134f0..00000000 --- a/clearblade-cloud-iot/.metadata/.plugins/org.eclipse.ui.intro/introstate +++ /dev/null @@ -1,2 +0,0 @@ - - \ No newline at end of file diff --git a/clearblade-cloud-iot/.metadata/.plugins/org.eclipse.ui.views.log/dialog_settings.xml b/clearblade-cloud-iot/.metadata/.plugins/org.eclipse.ui.views.log/dialog_settings.xml deleted file mode 100644 index 24973136..00000000 --- a/clearblade-cloud-iot/.metadata/.plugins/org.eclipse.ui.views.log/dialog_settings.xml +++ /dev/null @@ -1,12 +0,0 @@ - -
-
- - - - - - - -
-
diff --git a/clearblade-cloud-iot/.metadata/.plugins/org.eclipse.ui.workbench/dialog_settings.xml b/clearblade-cloud-iot/.metadata/.plugins/org.eclipse.ui.workbench/dialog_settings.xml deleted file mode 100644 index 7de9758f..00000000 --- a/clearblade-cloud-iot/.metadata/.plugins/org.eclipse.ui.workbench/dialog_settings.xml +++ /dev/null @@ -1,11 +0,0 @@ - -
-
- - - - -
-
-
-
diff --git a/clearblade-cloud-iot/.metadata/.plugins/org.eclipse.ui.workbench/workingsets.xml b/clearblade-cloud-iot/.metadata/.plugins/org.eclipse.ui.workbench/workingsets.xml deleted file mode 100644 index fbed79c9..00000000 --- a/clearblade-cloud-iot/.metadata/.plugins/org.eclipse.ui.workbench/workingsets.xml +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/clearblade-cloud-iot/.metadata/.plugins/org.eclipse.wildwebdeveloper.xml/system-catalog.xml b/clearblade-cloud-iot/.metadata/.plugins/org.eclipse.wildwebdeveloper.xml/system-catalog.xml deleted file mode 100644 index 54283dcd..00000000 --- a/clearblade-cloud-iot/.metadata/.plugins/org.eclipse.wildwebdeveloper.xml/system-catalog.xml +++ /dev/null @@ -1,229 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/clearblade-cloud-iot/.metadata/.plugins/org.eclipse.wst.common.snippets/hidden.xml b/clearblade-cloud-iot/.metadata/.plugins/org.eclipse.wst.common.snippets/hidden.xml deleted file mode 100644 index ab946b83f7b748424b8707693bcfdfa71590470b..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 138 zcmXAiK?;LF5CrQi_y^g05_8E(&CM4i50LDV1l9?-67qVrvobI diff --git a/clearblade-cloud-iot/.metadata/.plugins/org.eclipse.wst.common.snippets/user.xml b/clearblade-cloud-iot/.metadata/.plugins/org.eclipse.wst.common.snippets/user.xml deleted file mode 100644 index 79e43e1b9d872e8512dbae8fadce2d6c9ab17603..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 766 zcmchV!A`?K3`FOQ#6LtiRw9H#t0D!s@da>36HtV@80T0*E#|3~}kJe%>HYeM{TtHQUz8}|v= CiF`Z& diff --git a/clearblade-cloud-iot/.metadata/.plugins/org.eclipse.wst.sse.ui/dialog_settings.xml b/clearblade-cloud-iot/.metadata/.plugins/org.eclipse.wst.sse.ui/dialog_settings.xml deleted file mode 100644 index 63fae25e..00000000 --- a/clearblade-cloud-iot/.metadata/.plugins/org.eclipse.wst.sse.ui/dialog_settings.xml +++ /dev/null @@ -1,5 +0,0 @@ - -
-
-
-
diff --git a/clearblade-cloud-iot/.metadata/version.ini b/clearblade-cloud-iot/.metadata/version.ini deleted file mode 100644 index 1676b3db..00000000 --- a/clearblade-cloud-iot/.metadata/version.ini +++ /dev/null @@ -1,3 +0,0 @@ -#Tue Oct 25 12:57:57 IST 2022 -org.eclipse.core.runtime=2 -org.eclipse.platform=4.23.0.v20220308-0310 diff --git a/clearblade-cloud-iot/bin/com/clearblade/cloud/iot/v1/DeviceManagerClient.class b/clearblade-cloud-iot/bin/com/clearblade/cloud/iot/v1/DeviceManagerClient.class deleted file mode 100644 index 0bf879c7a49ba19110c094cc20fedbb6ba6b2554..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 2324 zcmcgtZBNrs6n@Sa6iRtjT zN_pL|Tz!9BUzYnuPOb}6>_|IPFr?`!h!R?N#lFxB!rakcXLn`JB{bwL({Y9AI)u@+ zFwl}~6dXNsWS%C}%^9ZQE)Z%G$!$V3W96la8Z>H9P~QMTlZIN<5n9#^Q*M-sS!r*H zY(WxYYgSGawuNnY^U7k>eQz+2@lYNY1jk&W9u);Q3By$cp`s0qgf>T-`HWR83NycD z1r7+AL@19ykHC0C6lHqtMBPo-Hq4!La$98)IyJ;luOf~f1>J;&FoK)snY@u7O44x$ zmP$q;FKrEXaF?K(@?&L%u#`xKa{V`I+T+)!p&$1MiX&YwB*I>m8e9vF`x*u@#M#3% zmJCzapO%Fy2wRB@B)*QglNwSOCe&s zxIytd%HQ0y_}##>IYj(_YU%)LioQep#;XxD^SjyK$^DeA8+cC(uW5lbT5*GC+})0m zX4%^FqNRSK?d<_>oxxHW(?e`zloK577^fY#dAG;t3tQIm7*Cbaafq(rGI~eK7$_sL zks2*yWHx$2v7g<8w?@&y1UnhNi{ax;tAiU}H_z_)?j{1riaQ2}jt4&7IL7giUA8gO zBTR4*UA+DnlfF<~-72)+v5hBW(;=pq(p(u&)-e*f|H8-QnM7|1c~dg0LV0>L9U;J%=3nEH+k z6KC|$=?mp|!r_oBe-Q48k@Un{@jexCveiyy;ETvWfnnvCkGKjVw%u5m;qMI)VxbfI z!UV&Tg^O5bC_R-*Cc6xIyRpx(+?7i7(xEG&0e1sxtJ)1c9_;f->i^7WB9A4)N{(dA z@Z$Vc8L>z-DGcxIg=jM@o|}>iaj|Zph!Sx^Wwg)CWMIz@<-a7nVZlI|q3CL5F+BO_ z(Y6e1GCW?Sy!pB?QNwMmgF6hJ#l+7C`E@&5T0Uk!Oe0Uclv+8p`9V8c>PV>pr9nR59L&|o<9j!%F=+#=jKz}x!>!*AQc5njg6YXK&ifOV{97HuWrPof-J^=Ywrg6ikYVH&cLg;-+;T*75KXSjkj`s$R=2}&n5n)kop zYIB;=%*>lqVLgLb8@o*)C?M-ZXTFB(e*)W>0o$gKyK}%a9UAN=ZcV@*5oNlq$|-6G k)LMO7+n9|9XIiUF>dIq_LUP!qM96rh5#kmT!m_ov1?o3ws{*BLtF<<%ZHzQcOeiK&N&Gp$1gBYc>#~seR+_Xl z(ZmPvp^SIf)h5Ma(rk8S?#!KY?#G#*zrOtdu!AiP5r)l<+qXKl;9lG2T|rBC*tMkV zTcdTWDV%Q2?f1FUJ#_cPNOr_K@o6XqzJ?e>`iPIXWpk%zy=@$6~o zzO)BcfY%`ZZ3ew99qxVJ<349F>*v5t-;+*{JmN2a(Y2_OxeEyf$%Ma diff --git a/clearblade-cloud-iot/bin/com/clearblade/cloud/iot/v1/SendCommandToDeviceResponse$Builder.class b/clearblade-cloud-iot/bin/com/clearblade/cloud/iot/v1/SendCommandToDeviceResponse$Builder.class deleted file mode 100644 index 88f283bfdf8039df77236343e51552d65e511a23..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1179 zcmb_bO>fgc5Pg#`$F8BJKp{Y(1rBMDun-a-3N(UL6-ZH$XjQ4lwLJn?ju&hv9Qadk zK$WP(58y{3W^IcA>Lmpq*0ZxSZ)V?{{r=(>>+KOjsW2K*jqijm*AqI;dkou=2N2MtJrg+FH#xKauT<#E;$iiJ88DC zwc?_Q7NO}I*$MsAi_y1mh466hp(v$v(7`n$-6~=06r}t$5JqxmS5MM_w*IFAdmnvw&7 zGDWT4oiDi9n^klQ_onnYC?HnKunIyFiW`{9mvFfPyDzsho!H0d97s1;XK>{Owtwr! buAu6;E-5wKz?%Hc8zd2PUAntj_&YxVA^JJz{WbrX#_qX$6Ot1-p%Sq}d!C)Z>vJbDc31 z4I5oXDq+S`hJrGInfvu2Js8vD`+^;P`;D+Apd^h0X(Pqiiq_{X+U9H&nBH$$iEc}` z(y3-MVhD&90dHY32ZD>O1qj_%G8*4Uc6XQvEj@0f1Oii{NL$fZD%hMOC$H*JA5Ga9$#das6Ua$Vtir*8GjwH+FE$~BE^-NPx%7~EnEtJuvDb!sO|=bngNDpMY` zV}*R|(Qqqty56MztTu6$%BUF^xH=c3S!{*9Mg?I3zXX0LD0fq-SWsq3iYgSyR2Zx= zogLjh9`s?KhJMttE;F*T;pLb|BHyoJz%~t$_m~4lT*aWktY%sJn`G?|Y)!Fp$Q>!m z)R4dd){ug%&Lr_Ctzo9nWgIxkf2@BhSZOrEwT!qG=owBJD$>NqK!`=dx->#?f6643 zgA9+g;jodgRPca?+p7DbaXmS_PPg>xkiR6b!Q!1p6|WK~Pg{Ef^yD45Q^9M--Fr@yX?QJO$Ec#*reVvV(z7pPq1s(d9^8dD zDtH48Z^z_><21Ypck{f1$*4ugDmA;BT3F;H*F75EBJYoK-q0z=`Z2s+!P^9`Din;K z{-k+OR(cKZz&n{9dL+`FP9&17HU`sfZZW1jG2J9>^DYhdVZLLVTrG6&E`j%GsK!DS z?<1s5Jw2U!I=0BN^?nUCs8#R*s+-fMDZO{Eku)M*1|uq|;6VXjZm%UycQ_Vzw&l4a z8a{{*F*j(tA_7*zB9|0xG;FSIh2i)?-qxd@Q!0l!zb-jV{k>}tt=PsapMdgRq*NY z@nhEz4QKHfdjnI3Yn78pgxkr6CTlPT;%8_Rnd$y)i{+1-mj9rc955mtd=6hw@cCRg zjOW$xxU33FLW+wqyD#7g1z!}n*7l67E^T^jubCV)BCIa!56LuSYHIkBjJO##AKS6; zKu=N+Q<*0v|5u6*Yw5@{dGM6n{aS9QtfJDjbe`2eXY}P zmP9FVZk}^|Q1eu`%_}|2q|dSDIVMFEIRq*F1wAioZ;};!Uu4q4`gmhbTVvgh{~qZKSgW2R0bTa-NGv{*&NeZm*^rTd($iUHmMU z?flqiGi1}7!UAep%8#2ecx7MAS&3{P?U5~?J+cSmsFJ1v(@8&rZ!M%N;aE{OhM9Hs zr*YLN=A5$0=kht-7CM_ObI3dwKCaDn7;rVN;Tu^o4=m&SG-aT{8-Q0gT5!cmegRE&}4p1990JOCWSjR#q{P z#V02KS$tU_EbNnj)Q@8EL?CqpQvV!4q{$@^_O@ABAzD%@uhpGF{f;pNMzM6F#4T)- zTZ=GhdE>k|C#Uo%Po+D>fw~NqoxycGyvxUMBh9=tgOwSq%Am=+fe&Y86K5H0X+4AX z9X4@ip13Pdv^785&Y5=?ANBl^ZwxPOTav*o=g`+4@J2G&>xhkp$^zb)uPlRjz?<}1 z_BdpZ-b11C05=YckV}M=Kn5=lslIaW(F|T4a{E-DyVU1Co5AaS>f>1HQ!{w;2$qFh z@>R88eXhqsiqCZ(9-k6&jiA!!@+lAUjY9@+h#-ScY?G2QJ3{LDOBdzzQzKaTFdp%q z%iyyktbSDg{0L^s@yjDn<@nW8H2evi;|%~jgdg&c*(SD&UA$A|80L-~2Y3sV+R=U# ze$sR>d2U7kU2IUhF@&u+f?nLo{`zigXScEo_p-0P54TYI9?HKJ|3RM+?19~gh#Bm1 ztFTYhA}Sg%AeJL0R&m^fxM+hZI*}0DkrcbxZiZor2%F3S42c-q$^;JE!E_umWx!;E zDIn_cbvr!!aS`9ZH+5dORony~pS`&wgif2%A2`k~5%s{f^HY-#963fDKkZ{K) z@Itwa49Utg=8k+^*r?!1{+=r1JHNE}lm&EiHn075dOa=ED}&!<@CWaoWm;wM7ble_ q)}A9pdG61;rWAjp#1i}+|KRB5Y!*-XC%@TO<6rjp4Aly5&aph9ijsQ%eXlvtZ?N+{`4cMX{%ALV=H=b%*cqh{4TlWIeqjG?$@yMmKeL zmZ34+lVb2KSQ!ySBLXU#(9Ccxrki4|kV^|Y$t=RZ!U`_!Ya;LJmgy*HV`#7Jdiy5`h7J|iCF+|_^(fFu z+|Clv_9_P{=wgV}a=;7aDmQsn*b9a(OgD&51Qgt6=&Pk!aCO6pED(N|o30Z?Hv)3_ zNJR*D$-%5}=L@=#5jMkQxTj_uJ!2l2HJ%gq%bL?c+`|I}_Zdbn26J9t#V7dG!?Iyp zUVU^BmP)Y8DUs*&sOXiuuMl!s5i&V)y$ z!q8t2S`}j$XK1iqFzkoVgS*^HeG#WfPhv{JLx$N}*sEN`xOi0%j(d_b71NlZn49AD z+x*X8kpGLVmhjE0_zZIliX&WECJgy-U3E2GJ1Fk~!;g7}kQPl9wwJbt)48#+^Sa6HgGKIghGdlt|8H3Gz%Nuh#+M9DX?g7! zrY;?H3U()ADps*Z#NwRiUIwRj;NKm|%cQ``6U_)hwSl;TrwkKym#Ak#MM9G4)x2$K z!g0!#8^BlCR6wl!pLUWsa9oj7@in%nl~@JpEZ4n@s9TW@;&GR#L-5?Rf@eg}XBnkj z`hI*v9KNxhNQUCV!w}M)(9~2Yh;4i)ThjMrxLQf1q`PSqn&cS2Yk5p1)r5){$Wo`{ z`8?%@VW67+Io7Cf>Ne6r?7&d4d(wGMJEbBgaVdG}r$K$JJyYtrry2#raLvo-apEZz zYK#Hxq-7B9n)+utjBKiA>Cz9rhgzi*5xba_B-B5gR(Rk)W@bNTRe9hLC*!HTn)HO zkBmloih)Mr4m8uK&@4idk!HGD^CuUHAvKB>`2HY=8VxPhCcb$argwZv4i+C+biV{~pE;?|R6bd$Uj>nq~J zB0ly+*b{x87(Bx8>JcXTi+I%bc@YamtgQ786!B!r*X1i>z03C}?)--2F}Anbo*&{{ zxyp;k6!EeMT_Tnkf$@@$E%1|otr`8R?#OrRYz=%BvTiaC0!t&k5f^5Q8m=q_%R zyc;Fleq><6B1^4!jyzsbRE9{?hC`mtp&u>^bk+(UU=Od!*L~XC3HA?}X;RRspj$yy f!GS`wAhYp9Y5WmCk!+*+Bo6R1#q=IMLP-7#^YT2Z diff --git a/clearblade-cloud-iot/bin/com/clearblade/cloud/iot/v1/utils/Constants.class b/clearblade-cloud-iot/bin/com/clearblade/cloud/iot/v1/utils/Constants.class deleted file mode 100644 index 3c1dcd50fd2fabf5ce856790fb42752314b80d47..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 2696 zcmbW3Yg-dn5Xb+EKtf!+M6_zFR_g_VWD|@aYOy6;+?b1yB@t>%_i{)!>;{{z66s7Ej$U{ZH&Nw=8V z)GXCt^ysz>$#i{bFDv+EE_+A8q0?swmJyo()rzVxO2Ge~3QRWygUDKh* zc>YLT_M4_tdm>Qe0PUA0wP+=v<%i1Fq8jp ztVOnG>WrUod!b`Tu7;nQj_J<}I5j>|AQ$Bn+ID8^L%cR z6d@g294ezoQ#p1mIO-ot2v0BdNEFYgKDU{n>2q2pr5kK6rLk?znA4_> zZF)0Olpz6Mi&)@xBH5J>n<|P$0T(>##jI=FRNsnw6x*_h6>c#~7KL8xMIj6Liyh?Z z+KO(L%$&UbPEHq1*^`~Mhk90?k#}}qRkFFcByCEo)m7RgXNvY(W8ax9Q7xqilwR*uW?i3c6%zQTYu49w4Hx*;2Sd|Y72kClgv6jgztJB4mb-%Q- zlqqCW>CI{(T~s#qOUgoHQ<1rC+8}^}xo;ZJ$!}xHlkG}|L**6zY}Et3vN2s$^i-j- z{;>Eem2|zPXX|fTPIg8vY}fMJo2Hjqx3U>;wwkeN_{=`A-)xo3xksx!lP^T%d0wKF z7o{_W&gM;r65ix{estnrBD}&3bA|hNSlB{>@T(K!4$`zxeIJ#V}`BuaT*F;GZgvW*7i->Vy zjD+1f=VD#NX^12)yRD|qmQ5b|nI3zRbCPq}aac2Jsh-Cu{7ClzYC@X1^j#Uo04JxX z0ZtpN1Q)D?60GDsSjio&qhv|5nSRgG+YfY#Ky*A5!3mc-ySgXv(|KaKwL0*M|Z1jU9LP2PRg@J7JgCq$=Ist^276g*Zm+f1TuR92(N7p@?9v%RzJw&P!JkLVIW)mAoB$B>;w?rTpUED^6p&o@nY5b pK^8(m=sOq&qV+&i6f=5f#T_n#lX06fG!4GDo&+pC+lD=oj`T2)C$uUR!6 zFEkHV%x37gf%#M(I=0-h>T>=`({ZcP*N_qz*|!cY)3q8k^HpVE+M$4U;Cs<&wA}f1 zJM^7KZCzl<^=vD2yapY8S#yHW{~|D0Rs3{#;53}@kwCIg+!07^cvYz*iSq_@WCVuG zPD5@r>lNw0vns9>7%dZ_yJPtd-&@X9xaR}{Yvr?aMpf!H8NP1!F;*z{c9Mp`gn?^FSTLSm{Yree(Gz2Pt+iUu^eCDtqhof+C*L;4%86$Fx0skJtU zHegEz;d3ttag~ISq?Jq|!J48|f;FTpX+~L63E2$A&?->8K{u1EAUja{j&t8s*f4zu zm2(p#bT*;@T)-&Z1TJEXzW;-dF#fd*{4y4NDHc504So{~o{k02bc5f=f-lE{v)$m` zSnw4!VD9-b4K_hmD=i#jywri~%Kd?+|4~s)L}9J55kS2QPy1Rt*<=q{g&_7RWc;{H zc0HbKriZLXWP7KOu|k+^KAtSwL*^1${S-2mnV{x%U86oF!TL`B oM1GgjFLxd+()edZ6=^)(qDm5s7iblC$m)tRk2U(6y{r8Bzq&+4lK=n! diff --git a/clearblade-cloud-iot/bin/com/clearblade/cloud/iot/v1/utils/DeviceName.class b/clearblade-cloud-iot/bin/com/clearblade/cloud/iot/v1/utils/DeviceName.class deleted file mode 100644 index 9898c6967fd4cfb0cc5c9e1a287a81141be9abf4..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 2275 zcmbVNYi}Ay6g>kN3`|V@ZfKm=Nt^<)O^F>hi62ShG|huJXL;(mc?nm z^f$FqOR84t59p7odhYIm5#BFYh@F|cbMHC#!QtQk{`v>NE)G+ODXi9=R=M6ZmRoCD z4a2R|ZIo@tE1y)#UC(ZI$`8$nT{j0-%cPJ{_~@N=VwIa#`?&m~_RiEjh18F(6YOTH zr*98E*KQwgD@-<>y5-qUn_Jf$+a1sSSs~f*<8rfOw{34vAzmmRDJ1rthRGm~DUA%W zX%JFl0!i7;XrzMOoW^9ZThK@&sgSGMZFA6V)r|X{RcjjFt`fL;WVyDSLu11G!R{!m zSI5bmS==d%<#Fvn*KRh9yInlWUIz%uOPOTb=6zTIh1(>1p2W9> z;1s!eP8drJH)Sj~6e{EOgMCnlId2tyDx59d`7Gn5#dH+D)L6s1U zMsOPsr9U-(@pd)#1S3m~;c2+9@m1eGJPrFA55=D5{a_k|=_8GA@K|BOp9_UA#_T5p zCf_=4%c4}giAeCg#Xlo8q8e3==Q7Zfo)ZWVD}3m5-MV>Xizehw3fr@aR9(7)dbf$_$IM0qcFGo64>LQ%yN1az9oYV5V z4V?>qU4Y5IvGn=_%A@{8-(MQSAIrdNgYzRrNsAX7RT*_#8-h)T)kCa0+*$46-dYb2dieS@++|KCP$Aw;?lw4!n;fBA?C=&lTk&B^L8x$+8PuO< z;kPJ%tbT@z^2f?3X*|Kxki;(`iF`DP9-f`@xWY)F%EhtG=sV=GOCEdVagRLiGsU|@ mT=D}h`2m;wfJ;8)62}2!#_$3!xr(GN@%t^`zT!C{=l=m(9?bUu diff --git a/clearblade-cloud-iot/pom.xml b/clearblade-cloud-iot/pom.xml index 0d72fc53..33467c54 100644 --- a/clearblade-cloud-iot/pom.xml +++ b/clearblade-cloud-iot/pom.xml @@ -14,7 +14,7 @@ - + @@ -29,5 +29,17 @@ 5.9.1 test + + + com.google.code.findbugs + jsr305 + 3.0.2 + + + \ No newline at end of file diff --git a/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/binddevicetogateway/AsyncBindDeviceToGateway.java b/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/binddevicetogateway/AsyncBindDeviceToGateway.java new file mode 100644 index 00000000..80fc8669 --- /dev/null +++ b/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/binddevicetogateway/AsyncBindDeviceToGateway.java @@ -0,0 +1,36 @@ +package com.clearblade.cloud.iot.v1.binddevicetogateway; + +import java.util.logging.Level; +import java.util.logging.Logger; + +import com.clearblade.cloud.iot.v1.DeviceManagerClient; + +public class AsyncBindDeviceToGateway { + static Logger log = Logger.getLogger(AsyncBindDeviceToGateway.class.getName()); + + public static void main(String[] args) { + asyncBindDeviceToGateway(); + } + + public static void asyncBindDeviceToGateway() { + DeviceManagerClient deviceManagerClient = new DeviceManagerClient(); + String parent = "Rashmi_Device_Test"; + String gateway = "Rashmi_Gateway_Test"; + String device = "Rashmi_Device_Test"; + + BindDeviceToGatewayRequest request = BindDeviceToGatewayRequest.Builder.newBuilder().setParent(parent).setGateway(gateway).setDevice(device).build(); + BindDeviceToGatewayResponse response = deviceManagerClient.bindDeviceToGateway(request); + + if (response != null) { + response.processRequest(request); + if(response.getHttpStatusResponse().equals("OK")) { + log.log(Level.INFO, "AsyncBindDeviceToGateway Method worked successfully :: {0}",response.getHttpStatusResponse()); + }else { + log.log(Level.SEVERE, "AsyncBindDeviceToGateway Method execution failed :: {0}",response.getHttpStatusResponse()); + } + }else { + log.log(Level.SEVERE, "AsyncBindDeviceToGateway Method execution failed"); + } + + } +} diff --git a/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/binddevicetogateway/SyncBindDeviceToGateway.java b/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/binddevicetogateway/SyncBindDeviceToGateway.java new file mode 100644 index 00000000..ff183f21 --- /dev/null +++ b/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/binddevicetogateway/SyncBindDeviceToGateway.java @@ -0,0 +1,37 @@ +package com.clearblade.cloud.iot.v1.binddevicetogateway; + +import java.util.logging.Level; +import java.util.logging.Logger; + +import com.clearblade.cloud.iot.v1.DeviceManagerClient; + +public class SyncBindDeviceToGateway { + static Logger log = Logger.getLogger(SyncBindDeviceToGateway.class.getName()); + + public static void main(String[] args) { + syncBindDeviceToGateway(); + } + + public static void syncBindDeviceToGateway() { + DeviceManagerClient deviceManagerClient = new DeviceManagerClient(); + String parent = "Rashmi_Device_Test"; + String gateway = "Rashmi_Gateway_Test"; + String device = "Rashmi_Device_Test"; + + BindDeviceToGatewayRequest request = BindDeviceToGatewayRequest.Builder.newBuilder().setParent(parent) + .setGateway(gateway).setDevice(device).build(); + BindDeviceToGatewayResponse response = deviceManagerClient.bindDeviceToGateway(request); + + if (response != null) { + response.processRequest(request); + if (response.getHttpStatusResponse().equals("OK")) { + log.log(Level.INFO, "SyncBindDeviceToGateway Method worked successfully :: {0}", response.getHttpStatusResponse()); + } else { + log.log(Level.SEVERE, "SyncBindDeviceToGateway Method execution failed :: {0}", response.getHttpStatusResponse()); + } + } else { + log.log(Level.SEVERE, "SyncBindDeviceToGateway Method execution failed"); + } + + } +} diff --git a/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/createdevice/AsyncCreateDevice.java b/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/createdevice/AsyncCreateDevice.java index eac59d63..82c3eefd 100644 --- a/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/createdevice/AsyncCreateDevice.java +++ b/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/createdevice/AsyncCreateDevice.java @@ -3,8 +3,6 @@ import java.util.logging.Level; import java.util.logging.Logger; -import com.clearblade.cloud.iot.v1.CreateDeviceRequest; -import com.clearblade.cloud.iot.v1.CreateDeviceResponse; import com.clearblade.cloud.iot.v1.DeviceManagerClient; import com.clearblade.cloud.iot.v1.utils.Device; import com.clearblade.cloud.iot.v1.utils.RegistryName; @@ -18,25 +16,21 @@ public static void main(String[] args) { public static void asyncCreateDevice() { DeviceManagerClient deviceManagerClient = new DeviceManagerClient(); - String msg = ""; String registryName = "Rashmi_Registry_Test"; RegistryName registryNm = RegistryName.newBuilder().setRegistry(registryName).build(); CreateDeviceRequest request = CreateDeviceRequest.Builder.newBuilder().setParent(registryNm) - .setDevice(Device.newBuilder().setId("AsyncDeviceTest1").setName("AsyncDeviceTest1").setNumId(11111).build()) - .setDeviceNumIds(new String[]{"123,153"}).setSubfolder("777").build(); + .setDevice(Device.newBuilder().setId("AsyncDeviceTest2").setName("AsyncDeviceTest2").setNumId(11112).build()) + .setDeviceNumIds(new String[]{"133,134"}).setSubfolder("784").build(); CreateDeviceResponse response = deviceManagerClient.createDevice(request); - if (response != null) { + if (response != null) { response.processRequest(request); if(response.getHttpStatusResponse().equals("OK")) { - msg = "AsyncCreateDevice Method worked successfully :: " + response.getHttpStatusResponse(); - log.log(Level.INFO, msg); + log.log(Level.INFO, "AsyncCreateDevice Method worked successfully :: {0}",response.getHttpStatusResponse()); }else { - msg = "AsyncCreateDevice Method execution failed :: " + response.getHttpStatusResponse(); - log.log(Level.SEVERE, msg); + log.log(Level.INFO, "AsyncCreateDevice Method execution failed :: {0}",response.getHttpStatusResponse()); } }else { - msg = "AsyncCreateDevice Method execution failed"; - log.log(Level.SEVERE, msg); + log.log(Level.SEVERE, "AsyncCreateDevice Method execution failed"); } } } diff --git a/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/createdevice/SyncCreateDevice.java b/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/createdevice/SyncCreateDevice.java index 177624cb..9b40a921 100644 --- a/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/createdevice/SyncCreateDevice.java +++ b/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/createdevice/SyncCreateDevice.java @@ -3,8 +3,6 @@ import java.util.logging.Level; import java.util.logging.Logger; -import com.clearblade.cloud.iot.v1.CreateDeviceRequest; -import com.clearblade.cloud.iot.v1.CreateDeviceResponse; import com.clearblade.cloud.iot.v1.DeviceManagerClient; import com.clearblade.cloud.iot.v1.utils.Device; import com.clearblade.cloud.iot.v1.utils.RegistryName; @@ -19,25 +17,21 @@ public static void main(String[] args) { public static void syncCreateDevice() { DeviceManagerClient deviceManagerClient = new DeviceManagerClient(); - String msg = ""; String registryName = "Rashmi_Registry_Test"; RegistryName registryNm = RegistryName.newBuilder().setRegistry(registryName).build(); CreateDeviceRequest request = CreateDeviceRequest.Builder.newBuilder().setParent(registryNm) - .setDevice(Device.newBuilder().setId("SyncDeviceTest1").setName("SyncDeviceTest1").setNumId(99998).build()) - .setDeviceNumIds(new String[]{"223,553"}).setSubfolder("753").build(); + .setDevice(Device.newBuilder().setId("SyncDeviceTest2").setName("SyncDeviceTest2").setNumId(49998).build()) + .setDeviceNumIds(new String[]{"226,556"}).setSubfolder("758").build(); CreateDeviceResponse response = deviceManagerClient.createDevice(request); if (response != null) { response.processRequest(request); if(response.getHttpStatusResponse().equals("OK")) { - msg = "SyncCreateDevice Method worked successfully :: " + response.getHttpStatusResponse(); - log.log(Level.INFO, msg); + log.log(Level.INFO, "SyncCreateDevice Method worked successfully :: {0}",response.getHttpStatusResponse()); }else { - msg = "SyncCreateDevice Method execution failed :: " + response.getHttpStatusResponse(); - log.log(Level.SEVERE, msg); + log.log(Level.INFO, "SyncCreateDevice Method execution failed :: {0}",response.getHttpStatusResponse()); } }else { - msg = "SyncCreateDevice Method execution failed"; - log.log(Level.SEVERE, msg); + log.log(Level.SEVERE, "SyncCreateDevice Method execution failed"); } } } diff --git a/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/deletedevice/AsyncDeleteDevice.java b/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/deletedevice/AsyncDeleteDevice.java index 72430ca4..b77e52b1 100644 --- a/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/deletedevice/AsyncDeleteDevice.java +++ b/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/deletedevice/AsyncDeleteDevice.java @@ -3,35 +3,29 @@ import java.util.logging.Level; import java.util.logging.Logger; -import com.clearblade.cloud.iot.v1.DeleteDeviceRequest; -import com.clearblade.cloud.iot.v1.DeleteDeviceResponse; import com.clearblade.cloud.iot.v1.DeviceManagerClient; public class AsyncDeleteDevice { static Logger log = Logger.getLogger(AsyncDeleteDevice.class.getName()); - + public static void main(String[] args) { asyncDeleteDevice(); } public static void asyncDeleteDevice() { DeviceManagerClient deviceManagerClient = new DeviceManagerClient(); - String msg = ""; - String deviceName = "AsyncDeviceTest"; + String deviceName = "AsyncDeviceTest2"; DeleteDeviceRequest request = DeleteDeviceRequest.Builder.newBuilder().setDeviceName(deviceName).build(); DeleteDeviceResponse response = deviceManagerClient.deleteDevice(request); if (response != null) { response.processRequest(request); if (response.getHttpStatusResponse().equals("OK")) { - msg = "AsyncDeleteDevice Method worked successfully :: " + response.getHttpStatusResponse(); - log.log(Level.INFO, msg); + log.log(Level.INFO, "AsyncDeleteDevice Method worked successfully :: {0} ",response.getHttpStatusResponse()); } else { - msg = "AsyncDeleteDevice Method execution failed :: " + response.getHttpStatusResponse(); - log.log(Level.SEVERE, msg); + log.log(Level.SEVERE, "AsyncDeleteDevice Method execution failed :: {0}",response.getHttpStatusResponse()); } } else { - msg = "AsyncDeleteDevice Method execution failed"; - log.log(Level.SEVERE, msg); + log.log(Level.SEVERE, "AsyncDeleteDevice Method execution failed"); } } diff --git a/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/deletedevice/SyncDeleteDevice.java b/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/deletedevice/SyncDeleteDevice.java index 24786522..4796600f 100644 --- a/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/deletedevice/SyncDeleteDevice.java +++ b/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/deletedevice/SyncDeleteDevice.java @@ -3,8 +3,6 @@ import java.util.logging.Level; import java.util.logging.Logger; -import com.clearblade.cloud.iot.v1.DeleteDeviceRequest; -import com.clearblade.cloud.iot.v1.DeleteDeviceResponse; import com.clearblade.cloud.iot.v1.DeviceManagerClient; public class SyncDeleteDevice { @@ -16,22 +14,18 @@ public static void main(String[] args) { public static void syncDeleteDevice() { DeviceManagerClient deviceManagerClient = new DeviceManagerClient(); - String msg = ""; - String deviceName = "SyncDeviceTest2"; + String deviceName = "SyncDeviceTest2"; DeleteDeviceRequest request = DeleteDeviceRequest.Builder.newBuilder().setDeviceName(deviceName).build(); DeleteDeviceResponse response = deviceManagerClient.deleteDevice(request); if (response != null) { response.processRequest(request); if (response.getHttpStatusResponse().equals("OK")) { - msg = "AsyncDeleteDevice Method worked successfully :: " + response.getHttpStatusResponse(); - log.log(Level.INFO, msg); + log.log(Level.INFO, "SyncDeleteDevice Method worked successfully :: {0}",response.getHttpStatusResponse()); } else { - msg = "AsyncDeleteDevice Method execution failed :: " + response.getHttpStatusResponse(); - log.log(Level.SEVERE, msg); + log.log(Level.SEVERE, "SyncDeleteDevice Method execution failed :: {0}", response.getHttpStatusResponse()); } } else { - msg = "AsyncDeleteDevice Method execution failed"; - log.log(Level.SEVERE, msg); + log.log(Level.SEVERE, "SyncDeleteDevice Method execution failed"); } } diff --git a/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/devicegetconfig/AsyncGetDeviceConfig.java b/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/devicegetconfig/AsyncGetDeviceConfig.java deleted file mode 100644 index 4cec7c9e..00000000 --- a/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/devicegetconfig/AsyncGetDeviceConfig.java +++ /dev/null @@ -1,41 +0,0 @@ -package com.clearblade.cloud.iot.v1.devicegetconfig; - -import java.util.logging.Level; -import java.util.logging.Logger; - -import com.clearblade.cloud.iot.v1.DeviceManagerClient; -import com.clearblade.cloud.iot.v1.GetDeviceConfigRequest; -import com.clearblade.cloud.iot.v1.GetDeviceConfigResponse; - -public class AsyncGetDeviceConfig { - static Logger log = Logger.getLogger(AsyncGetDeviceConfig.class.getName()); - - public static void main(String[] args) { - asyncGetDeviceConfig(); - } - - public static void asyncGetDeviceConfig() { - String msg = ""; - DeviceManagerClient deviceManagerClient = new DeviceManagerClient(); - String registryName = "Rashmi_Registry_Test"; - String deviceName = "Rashmi_Device_Test"; - String localVersion = "1"; - GetDeviceConfigRequest request = GetDeviceConfigRequest.Builder.newBuilder().setDeviceName(registryName + "/" + deviceName).setLocalVersion(localVersion) - .build(); - GetDeviceConfigResponse response = deviceManagerClient.getDeviceConfig(request); - if (response != null) { - response.processRequest(request); - if (response.getHttpStatusResponse().equals("OK")) { - msg = "AsyncGetDeviceConfig Method worked successfully :: " + response.getHttpStatusResponse(); - log.log(Level.INFO, msg); - } else { - msg = "AsyncGetDeviceConfig Method execution failed :: " + response.getHttpStatusResponse(); - log.log(Level.SEVERE, msg); - } - } else { - msg = "AsyncGetDeviceConfig Method execution failed"; - log.log(Level.SEVERE, msg); - } - } - -} diff --git a/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/devicegetconfig/SyncGetDeviceConfig.java b/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/devicegetconfig/SyncGetDeviceConfig.java deleted file mode 100644 index 2230a62f..00000000 --- a/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/devicegetconfig/SyncGetDeviceConfig.java +++ /dev/null @@ -1,41 +0,0 @@ -package com.clearblade.cloud.iot.v1.devicegetconfig; - -import java.util.logging.Level; -import java.util.logging.Logger; - -import com.clearblade.cloud.iot.v1.DeviceManagerClient; -import com.clearblade.cloud.iot.v1.GetDeviceConfigRequest; -import com.clearblade.cloud.iot.v1.GetDeviceConfigResponse; - -public class SyncGetDeviceConfig { - static Logger log = Logger.getLogger(SyncGetDeviceConfig.class.getName()); - - public static void main(String[] args) { - syncGetDeviceConfig(); - } - - public static void syncGetDeviceConfig() { - String msg = ""; - DeviceManagerClient deviceManagerClient = new DeviceManagerClient(); - String registryName = "Rashmi_Registry_Test"; - String deviceName = "Rashmi_Device_Test"; - String localVersion = "1"; - GetDeviceConfigRequest request = GetDeviceConfigRequest.Builder.newBuilder().setDeviceName(registryName + "/" + deviceName).setLocalVersion(localVersion) - .build(); - GetDeviceConfigResponse response = deviceManagerClient.getDeviceConfig(request); - if (response != null) { - response.processRequest(request); - if (response.getHttpStatusResponse().equals("OK")) { - msg = "SyncGetDeviceConfig Method worked successfully :: " + response.getHttpStatusResponse(); - log.log(Level.INFO, msg); - } else { - msg = "SyncGetDeviceConfig Method execution failed :: " + response.getHttpStatusResponse(); - log.log(Level.SEVERE, msg); - } - } else { - msg = "SyncGetDeviceConfig Method execution failed"; - log.log(Level.SEVERE, msg); - } - } - -} diff --git a/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/devicepatch/AsyncDevicePatch.java b/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/devicepatch/AsyncDevicePatch.java new file mode 100644 index 00000000..f184321b --- /dev/null +++ b/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/devicepatch/AsyncDevicePatch.java @@ -0,0 +1,38 @@ +package com.clearblade.cloud.iot.v1.devicepatch; + +import java.util.logging.Level; +import java.util.logging.Logger; + +import com.clearblade.cloud.iot.v1.DeviceManagerClient; +import com.clearblade.cloud.iot.v1.utils.Device; + +public class AsyncDevicePatch { + static Logger log = Logger.getLogger(AsyncDevicePatch.class.getName()); + + public static void main(String[] args) { + asyncDevicePatch(); + } + + public static void asyncDevicePatch() { + DeviceManagerClient deviceManagerClient = new DeviceManagerClient(); + String name = "Rashmi_Device_Test"; + + Device device = Device.patch(name,name,"NONE",true); + String updateMask = "logLevel"; + + DevicePatchRequest request = DevicePatchRequest.Builder.newBuilder().setName(name).setDevice(device).setUpdateMask(updateMask).build(); + DevicePatchResponse response = deviceManagerClient.devicePatch(request); + + if (response != null) { + response.processRequest(request); + if(response.getHttpStatusResponse().equals("OK")) { + log.log(Level.INFO, "AsyncDevicePatch Method worked successfully :: {0}",response.getHttpStatusResponse()); + }else { + log.log(Level.SEVERE, "AsyncDevicePatch Method execution failed :: {0}",response.getHttpStatusResponse()); + } + }else { + log.log(Level.SEVERE, "AsyncDevicePatch Method execution failed"); + } + + } +} diff --git a/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/devicepatch/SyncDevicePatch.java b/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/devicepatch/SyncDevicePatch.java new file mode 100644 index 00000000..e618caf5 --- /dev/null +++ b/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/devicepatch/SyncDevicePatch.java @@ -0,0 +1,38 @@ +package com.clearblade.cloud.iot.v1.devicepatch; + +import java.util.logging.Level; +import java.util.logging.Logger; + +import com.clearblade.cloud.iot.v1.DeviceManagerClient; +import com.clearblade.cloud.iot.v1.utils.Device; + +public class SyncDevicePatch { + static Logger log = Logger.getLogger(SyncDevicePatch.class.getName()); + + public static void main(String[] args) { + syncDevicePatch(); + } + + public static void syncDevicePatch() { + DeviceManagerClient deviceManagerClient = new DeviceManagerClient(); + String name = "Rashmi_Device_Test"; + + Device device = Device.patch(name,name,"ERROR",true); + String updateMask = "logLevel"; + + DevicePatchRequest request = DevicePatchRequest.Builder.newBuilder().setName(name).setDevice(device).setUpdateMask(updateMask).build(); + DevicePatchResponse response = deviceManagerClient.devicePatch(request); + + if (response != null) { + response.processRequest(request); + if(response.getHttpStatusResponse().equals("OK")) { + log.log(Level.INFO, "SyncDevicePatch Method worked successfully :: {0}",response.getHttpStatusResponse()); + }else { + log.log(Level.SEVERE, "SyncDevicePatch Method execution failed :: {0}",response.getHttpStatusResponse()); + } + }else { + log.log(Level.SEVERE, "SyncDevicePatch Method execution failed"); + } + + } +} diff --git a/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/devicesconfigversionslist/AsyncDevicesConfigVersionsList.java b/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/devicesconfigversionslist/AsyncDevicesConfigVersionsList.java new file mode 100644 index 00000000..7b286e73 --- /dev/null +++ b/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/devicesconfigversionslist/AsyncDevicesConfigVersionsList.java @@ -0,0 +1,37 @@ +package com.clearblade.cloud.iot.v1.devicesconfigversionslist; + +import java.util.logging.Level; +import java.util.logging.Logger; + +import com.clearblade.cloud.iot.v1.DeviceManagerClient; +import com.clearblade.cloud.iot.v1.deviceconfigversionslist.DeviceConfigVersionsListRequest; +import com.clearblade.cloud.iot.v1.deviceconfigversionslist.DeviceConfigVersionsListResponse; + +public class AsyncDevicesConfigVersionsList { + + static Logger log = Logger.getLogger(AsyncDevicesConfigVersionsList.class.getName()); + + public static void main(String[] args) { + asyncDevicesConfigVersionsList(); + } + + public static void asyncDevicesConfigVersionsList() { + String msg = ""; + String name = "Rashmi_Device_Test"; + DeviceManagerClient deviceManagerClient = new DeviceManagerClient(); + + DeviceConfigVersionsListRequest request = DeviceConfigVersionsListRequest.Builder.newBuilder().setName(name).setNumVersions("2").build(); + DeviceConfigVersionsListResponse response = deviceManagerClient.deviceConfigVersionsList(request); + if (response != null) { + response.processRequest(request); + if (response.getHttpStatusResponse().equals("OK")) { + log.log(Level.INFO, "AsyncDevicesConfigVersionsList Method worked successfully :: {0}",response.getHttpStatusResponse()); + } else { + log.log(Level.SEVERE, "AsyncDevicesConfigVersionsList Method execution failed :: {0}",response.getHttpStatusResponse()); + } + } else { + log.log(Level.SEVERE, "AsyncDevicesConfigVersionsList Method execution failed"); + } + } + +} diff --git a/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/devicesconfigversionslist/SyncDevicesConfigVersionsList.java b/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/devicesconfigversionslist/SyncDevicesConfigVersionsList.java new file mode 100644 index 00000000..7c0d9b61 --- /dev/null +++ b/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/devicesconfigversionslist/SyncDevicesConfigVersionsList.java @@ -0,0 +1,37 @@ +package com.clearblade.cloud.iot.v1.devicesconfigversionslist; + +import java.util.logging.Level; +import java.util.logging.Logger; + +import com.clearblade.cloud.iot.v1.DeviceManagerClient; +import com.clearblade.cloud.iot.v1.deviceconfigversionslist.DeviceConfigVersionsListRequest; +import com.clearblade.cloud.iot.v1.deviceconfigversionslist.DeviceConfigVersionsListResponse; + +public class SyncDevicesConfigVersionsList { + + static Logger log = Logger.getLogger(SyncDevicesConfigVersionsList.class.getName()); + + public static void main(String[] args) { + syncDevicesConfigVersionsList(); + } + + public static void syncDevicesConfigVersionsList() { + String msg = ""; + String name = "Rashmi_Device_Test"; + DeviceManagerClient deviceManagerClient = new DeviceManagerClient(); + + DeviceConfigVersionsListRequest request = DeviceConfigVersionsListRequest.Builder.newBuilder().setName(name).setNumVersions("2").build(); + DeviceConfigVersionsListResponse response = deviceManagerClient.deviceConfigVersionsList(request); + if (response != null) { + response.processRequest(request); + if (response.getHttpStatusResponse().equals("OK")) { + log.log(Level.INFO, "SyncDevicesConfigVersionsList Method worked successfully :: {0}",response.getHttpStatusResponse()); + } else { + log.log(Level.SEVERE, "SyncDevicesConfigVersionsList Method execution failed :: {0}",response.getHttpStatusResponse()); + } + } else { + log.log(Level.SEVERE, "SyncDevicesConfigVersionsList Method execution failed"); + } + } + +} diff --git a/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/devicesetstates/AsyncDeviceSetStates.java b/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/devicesetstates/AsyncDeviceSetStates.java deleted file mode 100644 index decac6a5..00000000 --- a/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/devicesetstates/AsyncDeviceSetStates.java +++ /dev/null @@ -1,40 +0,0 @@ -package com.clearblade.cloud.iot.v1.devicesetstates; - -import java.util.logging.Level; -import java.util.logging.Logger; - -import com.clearblade.cloud.iot.v1.DeviceManagerClient; -import com.clearblade.cloud.iot.v1.DeviceSetStatesRequest; -import com.clearblade.cloud.iot.v1.DeviceSetStatesResponse; -import com.clearblade.cloud.iot.v1.utils.ByteString; - -public class AsyncDeviceSetStates { - static Logger log = Logger.getLogger(AsyncDeviceSetStates.class.getName()); - - public static void main(String[] args) { - asyncDeviceSetStates(); - } - - public static void asyncDeviceSetStates() { - DeviceManagerClient deviceManagerClient = new DeviceManagerClient(); - String msg = ""; - String registryName = "Rashmi_Registry_Test"; - String deviceName = "Rashmi_Device_Test"; - DeviceSetStatesRequest request = DeviceSetStatesRequest.Builder.newBuilder().setDeviceName(registryName+"/"+deviceName).setBinaryDataByte(ByteString.EMPTY).build(); - DeviceSetStatesResponse response = deviceManagerClient.deviceSetStates(request); - if (response != null) { - response.processRequest(request); - if(response.getHttpStatusResponse().equals("OK")) { - msg = "AsyncDeviceSetStates Method worked successfully :: " + response.getHttpStatusResponse(); - log.log(Level.INFO, msg); - }else { - msg = "AsyncDeviceSetStates Method execution failed :: " + response.getHttpStatusResponse(); - log.log(Level.SEVERE, msg); - } - }else { - msg = "AsyncDeviceSetStates Method execution failed"; - log.log(Level.SEVERE, msg); - } - } - -} diff --git a/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/devicesetstates/SyncDeviceSetStates.java b/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/devicesetstates/SyncDeviceSetStates.java deleted file mode 100644 index 9e38fe30..00000000 --- a/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/devicesetstates/SyncDeviceSetStates.java +++ /dev/null @@ -1,40 +0,0 @@ -package com.clearblade.cloud.iot.v1.devicesetstates; - -import java.util.logging.Level; -import java.util.logging.Logger; - -import com.clearblade.cloud.iot.v1.DeviceManagerClient; -import com.clearblade.cloud.iot.v1.DeviceSetStatesRequest; -import com.clearblade.cloud.iot.v1.DeviceSetStatesResponse; -import com.clearblade.cloud.iot.v1.utils.ByteString; - -public class SyncDeviceSetStates { - static Logger log = Logger.getLogger(SyncDeviceSetStates.class.getName()); - - public static void main(String[] args) { - syncDeviceSetStates(); - } - - public static void syncDeviceSetStates() { - DeviceManagerClient deviceManagerClient = new DeviceManagerClient(); - String msg = ""; - String registryName = "Rashmi_Registry_Test"; - String deviceName = "Rashmi_Device_Test"; - DeviceSetStatesRequest request = DeviceSetStatesRequest.Builder.newBuilder().setDeviceName(registryName+"/"+deviceName).setBinaryDataByte(ByteString.EMPTY).build(); - DeviceSetStatesResponse response = deviceManagerClient.deviceSetStates(request); - if (response != null) { - response.processRequest(request); - if(response.getHttpStatusResponse().equals("OK")) { - msg = "SyncDeviceSetStates Method worked successfully :: " + response.getHttpStatusResponse(); - log.log(Level.INFO, msg); - }else { - msg = "SyncDeviceSetStates Method execution failed :: " + response.getHttpStatusResponse(); - log.log(Level.SEVERE, msg); - } - }else { - msg = "SyncDeviceSetStates Method execution failed"; - log.log(Level.SEVERE, msg); - } - } - -} diff --git a/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/deviceslist/AsyncDevicesList.java b/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/deviceslist/AsyncDevicesList.java index 731817a0..779df6a0 100644 --- a/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/deviceslist/AsyncDevicesList.java +++ b/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/deviceslist/AsyncDevicesList.java @@ -4,9 +4,6 @@ import java.util.logging.Logger; import com.clearblade.cloud.iot.v1.DeviceManagerClient; -import com.clearblade.cloud.iot.v1.DevicesListRequest; -import com.clearblade.cloud.iot.v1.DevicesListResponse; -import com.clearblade.cloud.iot.v1.utils.ConfigParameters; import com.clearblade.cloud.iot.v1.utils.RegistryName; public class AsyncDevicesList { @@ -18,24 +15,19 @@ public static void main(String[] args){ } public static void asyncDevicesList(){ - String msg = ""; DeviceManagerClient deviceManagerClient = new DeviceManagerClient(); - ConfigParameters configParams = new ConfigParameters(); - RegistryName parent = RegistryName.of(configParams.getProject(), configParams.getLocation(), configParams.getRegistry()); + RegistryName parent = RegistryName.of("ingressdevelopmentenv","us-central1","Rashmi_Registry_Test"); DevicesListRequest request = DevicesListRequest.Builder.newBuilder().setParent(parent).build(); DevicesListResponse response = deviceManagerClient.devicesList(request); if (response != null) { response.processRequest(request); if (response.getHttpStatusResponse().equals("OK")) { - msg = "AsyncDevicesList Method worked successfully :: " + response.getHttpStatusResponse(); - log.log(Level.INFO, msg); + log.log(Level.INFO, "AsyncDevicesList Method worked successfully :: {0}",response.getHttpStatusResponse()); } else { - msg = "AsyncDevicesList Method execution failed :: " + response.getHttpStatusResponse(); - log.log(Level.SEVERE, msg); + log.log(Level.SEVERE, "AsyncDevicesList Method execution failed :: {0}",response.getHttpStatusResponse()); } } else { - msg = "AsyncDevicesList Method execution failed"; - log.log(Level.SEVERE, msg); + log.log(Level.SEVERE, "AsyncDevicesList Method execution failed"); } } diff --git a/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/deviceslist/SyncDevicesList.java b/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/deviceslist/SyncDevicesList.java index 9c5cb84b..d95b1041 100644 --- a/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/deviceslist/SyncDevicesList.java +++ b/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/deviceslist/SyncDevicesList.java @@ -4,9 +4,6 @@ import java.util.logging.Logger; import com.clearblade.cloud.iot.v1.DeviceManagerClient; -import com.clearblade.cloud.iot.v1.DevicesListRequest; -import com.clearblade.cloud.iot.v1.DevicesListResponse; -import com.clearblade.cloud.iot.v1.utils.ConfigParameters; import com.clearblade.cloud.iot.v1.utils.RegistryName; public class SyncDevicesList { @@ -17,24 +14,19 @@ public static void main(String[] args){ } public static void syncDevicesList(){ - String msg = ""; DeviceManagerClient deviceManagerClient = new DeviceManagerClient(); - ConfigParameters configParams = new ConfigParameters(); - RegistryName parent = RegistryName.of(configParams.getProject(), configParams.getLocation(), configParams.getRegistry()); + RegistryName parent = RegistryName.of("ingressdevelopmentenv","us-central1","Rashmi_Registry_Test"); DevicesListRequest request = DevicesListRequest.Builder.newBuilder().setParent(parent).build(); DevicesListResponse response = deviceManagerClient.devicesList(request); if (response != null) { response.processRequest(request); if (response.getHttpStatusResponse().equals("OK")) { - msg = "SyncDevicesList Method worked successfully :: " + response.getHttpStatusResponse(); - log.log(Level.INFO, msg); + log.log(Level.INFO, "SyncDevicesList Method worked successfully :: {0}",response.getHttpStatusResponse()); } else { - msg = "SyncDevicesList Method execution failed :: " + response.getHttpStatusResponse(); - log.log(Level.SEVERE, msg); + log.log(Level.SEVERE, "SyncDevicesList Method execution failed :: {0}", response.getHttpStatusResponse()); } } else { - msg = "SyncDevicesList Method execution failed"; - log.log(Level.SEVERE, msg); + log.log(Level.SEVERE, "SyncDevicesList Method execution failed"); } } diff --git a/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/devicestateslist/AsyncDeviceStatesList.java b/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/devicestateslist/AsyncDeviceStatesList.java index 5e3f5ab2..5b827d02 100644 --- a/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/devicestateslist/AsyncDeviceStatesList.java +++ b/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/devicestateslist/AsyncDeviceStatesList.java @@ -4,8 +4,6 @@ import java.util.logging.Logger; import com.clearblade.cloud.iot.v1.DeviceManagerClient; -import com.clearblade.cloud.iot.v1.DeviceStatesListRequest; -import com.clearblade.cloud.iot.v1.DeviceStatesListResponse; public class AsyncDeviceStatesList { @@ -16,7 +14,6 @@ public static void main(String[] args) { } public static void asyncDeviceStatesList() { - String msg = ""; String name = "Rashmi_Device_Test"; DeviceManagerClient deviceManagerClient = new DeviceManagerClient(); @@ -25,15 +22,12 @@ public static void asyncDeviceStatesList() { if (response != null) { response.processRequest(request); if (response.getHttpStatusResponse().equals("OK")) { - msg = "AsyncDeviceStatesList Method worked successfully :: " + response.getHttpStatusResponse(); - log.log(Level.INFO, msg); + log.log(Level.INFO, "AsyncDeviceStatesList Method worked successfully :: {0}",response.getHttpStatusResponse()); } else { - msg = "AsyncDeviceStatesList Method execution failed :: " + response.getHttpStatusResponse(); - log.log(Level.SEVERE, msg); + log.log(Level.SEVERE, "AsyncDeviceStatesList Method execution failed :: {0} ",response.getHttpStatusResponse()); } } else { - msg = "AsyncDeviceStatesList Method execution failed"; - log.log(Level.SEVERE, msg); + log.log(Level.SEVERE, "AsyncDeviceStatesList Method execution failed"); } } diff --git a/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/devicestateslist/SyncDeviceStatesList.java b/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/devicestateslist/SyncDeviceStatesList.java index 9d13518c..737e835c 100644 --- a/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/devicestateslist/SyncDeviceStatesList.java +++ b/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/devicestateslist/SyncDeviceStatesList.java @@ -4,8 +4,6 @@ import java.util.logging.Logger; import com.clearblade.cloud.iot.v1.DeviceManagerClient; -import com.clearblade.cloud.iot.v1.DeviceStatesListRequest; -import com.clearblade.cloud.iot.v1.DeviceStatesListResponse; public class SyncDeviceStatesList { static Logger log = Logger.getLogger(SyncDeviceStatesList.class.getName()); @@ -15,7 +13,6 @@ public static void main(String[] args) { } public static void syncDeviceStatesList() { - String msg = ""; String name = "Rashmi_Device_Test"; DeviceManagerClient deviceManagerClient = new DeviceManagerClient(); @@ -24,15 +21,12 @@ public static void syncDeviceStatesList() { if (response != null) { response.processRequest(request); if (response.getHttpStatusResponse().equals("OK")) { - msg = "SyncDeviceStatesList Method worked successfully :: " + response.getHttpStatusResponse(); - log.log(Level.INFO, msg); + log.log(Level.INFO, "SyncDeviceStatesList Method worked successfully ::{0} ",response.getHttpStatusResponse()); } else { - msg = "SyncDeviceStatesList Method execution failed :: " + response.getHttpStatusResponse(); - log.log(Level.SEVERE, msg); + log.log(Level.SEVERE, "SyncDeviceStatesList Method execution failed :: {0}", response.getHttpStatusResponse()); } } else { - msg = "SyncDeviceStatesList Method execution failed"; - log.log(Level.SEVERE, msg); + log.log(Level.SEVERE, "SyncDeviceStatesList Method execution failed"); } } diff --git a/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/getdevice/AsyncGetDevice.java b/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/getdevice/AsyncGetDevice.java index ff65a084..796b9d19 100644 --- a/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/getdevice/AsyncGetDevice.java +++ b/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/getdevice/AsyncGetDevice.java @@ -4,8 +4,6 @@ import java.util.logging.Logger; import com.clearblade.cloud.iot.v1.DeviceManagerClient; -import com.clearblade.cloud.iot.v1.GetDeviceRequest; -import com.clearblade.cloud.iot.v1.GetDeviceResponse; public class AsyncGetDevice { static Logger log = Logger.getLogger(AsyncGetDevice.class.getName()); @@ -23,15 +21,12 @@ public static void asyncGetDevice() { if (response != null) { response.processRequest(request); if (response.getHttpStatusResponse().equals("OK")) { - msg = "AsyncGetDevice Method worked successfully :: " + response.getHttpStatusResponse(); - log.log(Level.INFO, msg); + log.log(Level.INFO, "AsyncGetDevice Method worked successfully :: {0}",response.getHttpStatusResponse()); } else { - msg = "AsyncGetDevice Method execution failed :: " + response.getHttpStatusResponse(); - log.log(Level.SEVERE, msg); + log.log(Level.SEVERE, "AsyncGetDevice Method execution failed :: {0}",response.getHttpStatusResponse()); } } else { - msg = "AsyncGetDevice Method execution failed"; - log.log(Level.SEVERE, msg); + log.log(Level.SEVERE, "AsyncGetDevice Method execution failed"); } } diff --git a/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/getdevice/SyncGetDevice.java b/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/getdevice/SyncGetDevice.java index 7868720e..94aaedb8 100644 --- a/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/getdevice/SyncGetDevice.java +++ b/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/getdevice/SyncGetDevice.java @@ -5,9 +5,6 @@ import com.clearblade.cloud.iot.v1.DeviceManagerClient; -import com.clearblade.cloud.iot.v1.GetDeviceRequest; -import com.clearblade.cloud.iot.v1.GetDeviceResponse; - public class SyncGetDevice { static Logger log = Logger.getLogger(SyncGetDevice.class.getName()); @@ -17,22 +14,18 @@ public static void main(String[] args) { public static void syncGetDevice() { DeviceManagerClient deviceManagerClient = new DeviceManagerClient(); - String msg = ""; String deviceName = "Rashmi_Device_Test"; GetDeviceRequest request = GetDeviceRequest.Builder.newBuilder().setDeviceName(deviceName).build(); GetDeviceResponse response = deviceManagerClient.getDevice(request); if (response != null) { response.processRequest(request); if (response.getHttpStatusResponse().equals("OK")) { - msg = "SyncGetDevice Method worked successfully :: " + response.getHttpStatusResponse(); - log.log(Level.INFO, msg); + log.log(Level.INFO, "SyncGetDevice Method worked successfully :: {0}",response.getHttpStatusResponse()); } else { - msg = "SyncGetDevice Method execution failed :: " + response.getHttpStatusResponse(); - log.log(Level.SEVERE, msg); + log.log(Level.SEVERE, "SyncGetDevice Method execution failed :: {0}",response.getHttpStatusResponse()); } } else { - msg = "SyncGetDevice Method execution failed"; - log.log(Level.SEVERE, msg); + log.log(Level.SEVERE, "SyncGetDevice Method execution failed"); } } diff --git a/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/modifycloudtodeviceconfig/AsyncModifyCloudToDeviceConfig.java b/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/modifycloudtodeviceconfig/AsyncModifyCloudToDeviceConfig.java new file mode 100644 index 00000000..dc453f58 --- /dev/null +++ b/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/modifycloudtodeviceconfig/AsyncModifyCloudToDeviceConfig.java @@ -0,0 +1,36 @@ +package com.clearblade.cloud.iot.v1.modifycloudtodeviceconfig; + +import java.util.logging.Level; +import java.util.logging.Logger; + +import com.clearblade.cloud.iot.v1.DeviceManagerClient; +import com.clearblade.cloud.iot.v1.utils.ByteString; +import com.clearblade.cloud.iot.v1.utils.Device; + +public class AsyncModifyCloudToDeviceConfig { + static Logger log = Logger.getLogger(AsyncModifyCloudToDeviceConfig.class.getName()); + + public static void main(String[] args) { + asyncModifyCloudToDeviceConfig(); + } + + public static void asyncModifyCloudToDeviceConfig() { + DeviceManagerClient deviceManagerClient = new DeviceManagerClient(); + String deviceName = "Rashmi_Device_Test"; + ModifyCloudToDeviceConfigRequest request = ModifyCloudToDeviceConfigRequest.Builder.newBuilder() + .setDevice(Device.newBuilder().setId(deviceName).setName(deviceName).setNumId(11111).build()) + .setVersionToUpdate("3").setBinaryDataByte(ByteString.EMPTY).build(); + ModifyCloudToDeviceConfigResponse response = deviceManagerClient.modifyCloudToDeviceConfig(request); + if (response != null) { + response.processRequest(request); + if(response.getHttpStatusResponse().equals("OK")) { + log.log(Level.INFO, "ModifyCloudToDeviceConfig Method worked successfully :: {0}",response.getHttpStatusResponse()); + }else { + log.log(Level.SEVERE, "ModifyCloudToDeviceConfig Method execution failed :: {0}",response.getHttpStatusResponse()); + } + }else { + log.log(Level.SEVERE, "ModifyCloudToDeviceConfig Method execution failed"); + } + + } +} diff --git a/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/modifycloudtodeviceconfig/SyncModifyCloudToDeviceConfig.java b/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/modifycloudtodeviceconfig/SyncModifyCloudToDeviceConfig.java new file mode 100644 index 00000000..1ba35242 --- /dev/null +++ b/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/modifycloudtodeviceconfig/SyncModifyCloudToDeviceConfig.java @@ -0,0 +1,36 @@ +package com.clearblade.cloud.iot.v1.modifycloudtodeviceconfig; + +import java.util.logging.Level; +import java.util.logging.Logger; + +import com.clearblade.cloud.iot.v1.DeviceManagerClient; +import com.clearblade.cloud.iot.v1.utils.ByteString; +import com.clearblade.cloud.iot.v1.utils.Device; + +public class SyncModifyCloudToDeviceConfig { + static Logger log = Logger.getLogger(SyncModifyCloudToDeviceConfig.class.getName()); + + public static void main(String[] args) { + syncModifyCloudToDeviceConfig(); + } + + public static void syncModifyCloudToDeviceConfig() { + DeviceManagerClient deviceManagerClient = new DeviceManagerClient(); + String deviceName = "Rashmi_Device_Test"; + ModifyCloudToDeviceConfigRequest request = ModifyCloudToDeviceConfigRequest.Builder.newBuilder() + .setDevice(Device.newBuilder().setId(deviceName).setName(deviceName).setNumId(11111).build()) + .setVersionToUpdate("4").setBinaryDataByte(ByteString.EMPTY).build(); + ModifyCloudToDeviceConfigResponse response = deviceManagerClient.modifyCloudToDeviceConfig(request); + if (response != null) { + response.processRequest(request); + if(response.getHttpStatusResponse().equals("OK")) { + log.log(Level.INFO, "ModifyCloudToDeviceConfig Method worked successfully ::{0}",response.getHttpStatusResponse()); + }else { + log.log(Level.SEVERE, "ModifyCloudToDeviceConfig Method execution failed :: {0}",response.getHttpStatusResponse()); + } + }else { + log.log(Level.SEVERE, "ModifyCloudToDeviceConfig Method execution failed"); + } + + } +} diff --git a/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/sendcommandtodevice/AsyncSendCommandToDevice.java b/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/sendcommandtodevice/AsyncSendCommandToDevice.java index d0f3ccd5..06700a47 100644 --- a/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/sendcommandtodevice/AsyncSendCommandToDevice.java +++ b/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/sendcommandtodevice/AsyncSendCommandToDevice.java @@ -4,37 +4,34 @@ import java.util.logging.Logger; import com.clearblade.cloud.iot.v1.DeviceManagerClient; -import com.clearblade.cloud.iot.v1.SendCommandToDeviceRequest; -import com.clearblade.cloud.iot.v1.SendCommandToDeviceResponse; import com.clearblade.cloud.iot.v1.utils.ByteString; public class AsyncSendCommandToDevice { - + static Logger log = Logger.getLogger(AsyncSendCommandToDevice.class.getName()); - + public static void main(String[] args) { asyncSendCommandToDevice(); } public static void asyncSendCommandToDevice() { DeviceManagerClient deviceManagerClient = new DeviceManagerClient(); - String msg = ""; - String name = "Rashmi_Device_Test"; + String name = "AsyncDeviceTest1"; + SendCommandToDeviceRequest request = SendCommandToDeviceRequest.Builder.newBuilder().setDeviceName(name) .setBinaryDataByte(ByteString.EMPTY).setSubfolder("subfolder1").build(); - SendCommandToDeviceResponse response = deviceManagerClient.sendCommandToDevice(request); + + SendCommandToDeviceResponse response = deviceManagerClient.sendCommandToDeviceAsync(request); if (response != null) { - response.processRequest(request); - if(response.getHttpStatusResponse().equals("OK")) { - msg = "AsyncSendCommandToDevice Method worked successfully :: " + response.getHttpStatusResponse(); - log.log(Level.INFO, msg); - }else { - msg = "AsyncSendCommandToDevice Method execution failed :: " + response.getHttpStatusResponse(); - log.log(Level.SEVERE, msg); + response.processRequestAsync(request); + if (response.getHttpStatusResponse().equals("OK")) { + log.log(Level.INFO, "AsyncSendCommandToDevice Method worked successfully :: {0}",response.getHttpStatusResponse()); + } else { + log.log(Level.SEVERE, "AsyncSendCommandToDevice Method execution failed :: {0}",response.getHttpStatusResponse()); } - }else { - msg = "AsyncSendCommandToDevice Method execution failed"; - log.log(Level.SEVERE, msg); + } else { + log.log(Level.SEVERE, "AsyncSendCommandToDevice Method execution failed"); } + } } diff --git a/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/sendcommandtodevice/SyncSendCommandToDevice.java b/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/sendcommandtodevice/SyncSendCommandToDevice.java index d3105fea..9eb7dcfe 100644 --- a/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/sendcommandtodevice/SyncSendCommandToDevice.java +++ b/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/sendcommandtodevice/SyncSendCommandToDevice.java @@ -5,8 +5,6 @@ import java.util.logging.Logger; import com.clearblade.cloud.iot.v1.DeviceManagerClient; -import com.clearblade.cloud.iot.v1.SendCommandToDeviceRequest; -import com.clearblade.cloud.iot.v1.SendCommandToDeviceResponse; import com.clearblade.cloud.iot.v1.utils.ByteString; public class SyncSendCommandToDevice { @@ -18,23 +16,19 @@ public static void main(String[] args) { public static void syncSendCommandToDevice() { DeviceManagerClient deviceManagerClient = new DeviceManagerClient(); - String msg = ""; - String name = "Rashmi_Device_Test"; + String name = "SyncDeviceTest1"; SendCommandToDeviceRequest request = SendCommandToDeviceRequest.Builder.newBuilder().setDeviceName(name) .setBinaryData(new ByteString("c2VuZEZ1bm55TWVzc2FnZVRvRGV2aWNl")).setSubfolder("subfolder1").build(); SendCommandToDeviceResponse response = deviceManagerClient.sendCommandToDevice(request); if (response != null) { response.processRequest(request); if(response.getHttpStatusResponse().equals("OK")) { - msg = "SyncSendCommandToDevice Method worked successfully :: " + response.getHttpStatusResponse(); - log.log(Level.INFO, msg); + log.log(Level.INFO, "SyncSendCommandToDevice Method worked successfully :: {0}",response.getHttpStatusResponse()); }else { - msg = "SyncSendCommandToDevice Method execution failed :: " + response.getHttpStatusResponse(); - log.log(Level.SEVERE, msg); + log.log(Level.SEVERE, "SyncSendCommandToDevice Method execution failed :: {0}",response.getHttpStatusResponse()); } }else { - msg = "SyncSendCommandToDevice Method execution failed"; - log.log(Level.SEVERE, msg); + log.log(Level.SEVERE, "SyncSendCommandToDevice Method execution failed"); } } } diff --git a/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/sendcommandtodevice/SyncSendCommandToDeviceDataEmpty.java b/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/sendcommandtodevice/SyncSendCommandToDeviceDataEmpty.java index 097a1eef..034657b5 100644 --- a/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/sendcommandtodevice/SyncSendCommandToDeviceDataEmpty.java +++ b/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/sendcommandtodevice/SyncSendCommandToDeviceDataEmpty.java @@ -4,8 +4,6 @@ import java.util.logging.Logger; import com.clearblade.cloud.iot.v1.DeviceManagerClient; -import com.clearblade.cloud.iot.v1.SendCommandToDeviceRequest; -import com.clearblade.cloud.iot.v1.SendCommandToDeviceResponse; import com.clearblade.cloud.iot.v1.utils.ByteString; public class SyncSendCommandToDeviceDataEmpty { @@ -17,7 +15,6 @@ public static void main(String[] args) { public static void syncSendCommandToDeviceDataEmpty() { DeviceManagerClient deviceManagerClient = new DeviceManagerClient(); - String msg = ""; String name = "Rashmi_Device_Test"; SendCommandToDeviceRequest request = SendCommandToDeviceRequest.Builder.newBuilder().setDeviceName(name) .setBinaryDataByte(ByteString.EMPTY).setSubfolder("subfolder1").build(); @@ -25,15 +22,12 @@ public static void syncSendCommandToDeviceDataEmpty() { if (response != null) { response.processRequest(request); if(response.getHttpStatusResponse().equals("OK")) { - msg = "syncSendCommandToDeviceDataEmpty Method worked successfully :: " + response.getHttpStatusResponse(); - log.log(Level.INFO, msg); + log.log(Level.INFO, "SyncSendCommandToDeviceDataEmpty Method worked successfully ::{0}",response.getHttpStatusResponse()); }else { - msg = "syncSendCommandToDeviceDataEmpty Method execution failed :: " + response.getHttpStatusResponse(); - log.log(Level.SEVERE, msg); + log.log(Level.SEVERE, "SyncSendCommandToDeviceDataEmpty Method execution failed :: {0}",response.getHttpStatusResponse()); } }else { - msg = "syncSendCommandToDeviceDataEmpty Method execution failed"; - log.log(Level.SEVERE, msg); + log.log(Level.SEVERE, "SyncSendCommandToDeviceDataEmpty Method execution failed"); } } diff --git a/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/sendcommandtodevice/SyncSendCommandToDeviceDeviceName.java b/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/sendcommandtodevice/SyncSendCommandToDeviceDeviceName.java index 0d525326..b4db4d55 100644 --- a/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/sendcommandtodevice/SyncSendCommandToDeviceDeviceName.java +++ b/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/sendcommandtodevice/SyncSendCommandToDeviceDeviceName.java @@ -4,8 +4,6 @@ import java.util.logging.Logger; import com.clearblade.cloud.iot.v1.DeviceManagerClient; -import com.clearblade.cloud.iot.v1.SendCommandToDeviceRequest; -import com.clearblade.cloud.iot.v1.SendCommandToDeviceResponse; import com.clearblade.cloud.iot.v1.utils.ByteString; import com.clearblade.cloud.iot.v1.utils.DeviceName; @@ -17,7 +15,6 @@ public static void main(String[] args) { public static void syncSendCommandToDeviceDeviceName() { DeviceManagerClient deviceManagerClient = new DeviceManagerClient(); - String msg = ""; String project = "ingressdevelopmentenv"; String location = "central1"; String registry = "Rashmi_Registry_Test"; @@ -29,15 +26,12 @@ public static void syncSendCommandToDeviceDeviceName() { if (response != null) { response.processRequest(request); if(response.getHttpStatusResponse().equals("OK")) { - msg = "SyncSendCommandToDeviceDeviceName Method worked successfully :: " + response.getHttpStatusResponse(); - log.log(Level.INFO, msg); + log.log(Level.INFO, "SyncSendCommandToDeviceDeviceName Method worked successfully :: {0}",response.getHttpStatusResponse()); }else { - msg = "SyncSendCommandToDeviceDeviceName Method execution failed :: " + response.getHttpStatusResponse(); - log.log(Level.SEVERE, msg); + log.log(Level.SEVERE, "SyncSendCommandToDeviceDeviceName Method execution failed :: {0}",response.getHttpStatusResponse()); } }else { - msg = "SyncSendCommandToDeviceDeviceName Method execution failed"; - log.log(Level.SEVERE, msg); + log.log(Level.SEVERE, "SyncSendCommandToDeviceDeviceName Method execution failed"); } } diff --git a/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/sendcommandtodevice/SyncSendCommandToDeviceNoSubfolder.java b/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/sendcommandtodevice/SyncSendCommandToDeviceNoSubfolder.java index c81f7b8a..e1d1a014 100644 --- a/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/sendcommandtodevice/SyncSendCommandToDeviceNoSubfolder.java +++ b/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/sendcommandtodevice/SyncSendCommandToDeviceNoSubfolder.java @@ -4,8 +4,6 @@ import java.util.logging.Logger; import com.clearblade.cloud.iot.v1.DeviceManagerClient; -import com.clearblade.cloud.iot.v1.SendCommandToDeviceRequest; -import com.clearblade.cloud.iot.v1.SendCommandToDeviceResponse; import com.clearblade.cloud.iot.v1.utils.ByteString; public class SyncSendCommandToDeviceNoSubfolder { @@ -16,7 +14,6 @@ public static void main(String[] args) { public static void syncSendCommandToDeviceNoSubfolder() { DeviceManagerClient deviceManagerClient = new DeviceManagerClient(); - String msg = ""; String name = "Rashmi_Device_Test"; SendCommandToDeviceRequest request = SendCommandToDeviceRequest.Builder.newBuilder().setDeviceName(name) .setBinaryDataByte(ByteString.EMPTY).build(); @@ -24,15 +21,12 @@ public static void syncSendCommandToDeviceNoSubfolder() { if (response != null) { response.processRequest(request); if(response.getHttpStatusResponse().equals("OK")) { - msg = "SyncSendCommandToDeviceNoSubfolder Method worked successfully :: " + response.getHttpStatusResponse(); - log.log(Level.INFO, msg); + log.log(Level.INFO, "SyncSendCommandToDeviceNoSubfolder Method worked successfully :: {0}",response.getHttpStatusResponse()); }else { - msg = "SyncSendCommandToDeviceNoSubfolder Method execution failed :: " + response.getHttpStatusResponse(); - log.log(Level.SEVERE, msg); + log.log(Level.SEVERE, "SyncSendCommandToDeviceNoSubfolder Method execution failed :: {0}",response.getHttpStatusResponse()); } }else { - msg = "SyncSendCommandToDeviceNoSubfolder Method execution failed"; - log.log(Level.SEVERE, msg); + log.log(Level.SEVERE, "SyncSendCommandToDeviceNoSubfolder Method execution failed"); } } diff --git a/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/unbinddevicefromgateway/AsyncUnbindDeviceFromGateway.java b/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/unbinddevicefromgateway/AsyncUnbindDeviceFromGateway.java new file mode 100644 index 00000000..69204e1e --- /dev/null +++ b/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/unbinddevicefromgateway/AsyncUnbindDeviceFromGateway.java @@ -0,0 +1,36 @@ +package com.clearblade.cloud.iot.v1.unbinddevicefromgateway; + +import java.util.logging.Level; +import java.util.logging.Logger; + +import com.clearblade.cloud.iot.v1.DeviceManagerClient; + +public class AsyncUnbindDeviceFromGateway { + static Logger log = Logger.getLogger(AsyncUnbindDeviceFromGateway.class.getName()); + + public static void main(String[] args) { + asyncUnbindDeviceFromGateway(); + } + + public static void asyncUnbindDeviceFromGateway() { + DeviceManagerClient deviceManagerClient = new DeviceManagerClient(); + String parent = "Rashmi_Device_Test"; + String gateway = "Rashmi_Gateway_Test"; + String device = "Rashmi_Device_Test"; + + UnbindDeviceFromGatewayRequest request = UnbindDeviceFromGatewayRequest.Builder.newBuilder().setParent(parent).setGateway(gateway).setDevice(device).build(); + UnbindDeviceFromGatewayResponse response = deviceManagerClient.unbindDeviceFromGateway(request); + + if (response != null) { + response.processRequest(request); + if(response.getHttpStatusResponse().equals("OK")) { + log.log(Level.INFO, "AsyncUnbindDeviceFromGateway Method worked successfully :: {0}",response.getHttpStatusResponse()); + }else { + log.log(Level.SEVERE, "AsyncUnbindDeviceFromGateway Method execution failed :: {0}",response.getHttpStatusResponse()); + } + }else { + log.log(Level.SEVERE, "AsyncUnbindDeviceFromGateway Method execution failed"); + } + + } +} diff --git a/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/unbinddevicefromgateway/SyncUnbindDeviceFromGateway.java b/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/unbinddevicefromgateway/SyncUnbindDeviceFromGateway.java new file mode 100644 index 00000000..8b3c088e --- /dev/null +++ b/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/unbinddevicefromgateway/SyncUnbindDeviceFromGateway.java @@ -0,0 +1,36 @@ +package com.clearblade.cloud.iot.v1.unbinddevicefromgateway; + +import java.util.logging.Level; +import java.util.logging.Logger; + +import com.clearblade.cloud.iot.v1.DeviceManagerClient; + +public class SyncUnbindDeviceFromGateway { + static Logger log = Logger.getLogger(SyncUnbindDeviceFromGateway.class.getName()); + + public static void main(String[] args) { + syncUnbindDeviceFromGateway(); + } + + public static void syncUnbindDeviceFromGateway() { + DeviceManagerClient deviceManagerClient = new DeviceManagerClient(); + String parent = "Rashmi_Device_Test"; + String gateway = "Rashmi_Gateway_Test"; + String device = "Rashmi_Device_Test"; + + UnbindDeviceFromGatewayRequest request = UnbindDeviceFromGatewayRequest.Builder.newBuilder().setParent(parent).setGateway(gateway).setDevice(device).build(); + UnbindDeviceFromGatewayResponse response = deviceManagerClient.unbindDeviceFromGateway(request); + + if (response != null) { + response.processRequest(request); + if(response.getHttpStatusResponse().equals("OK")) { + log.log(Level.INFO, "SyncUnbindDeviceFromGateway Method worked successfully :: {0}",response.getHttpStatusResponse()); + }else { + log.log(Level.SEVERE, "SyncUnbindDeviceFromGateway Method execution failed :: {0}",response.getHttpStatusResponse()); + } + }else { + log.log(Level.SEVERE, "SyncUnbindDeviceFromGateway Method execution failed"); + } + + } +} diff --git a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/DeviceManagerClient.java b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/DeviceManagerClient.java index 9e9bc272..5be3471d 100644 --- a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/DeviceManagerClient.java +++ b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/DeviceManagerClient.java @@ -1,12 +1,44 @@ package com.clearblade.cloud.iot.v1; -import com.clearblade.cloud.iot.v1.utils.ByteString; +import com.clearblade.cloud.iot.v1.binddevicetogateway.BindDeviceToGatewayRequest; +import com.clearblade.cloud.iot.v1.binddevicetogateway.BindDeviceToGatewayResponse; +import com.clearblade.cloud.iot.v1.createdevice.CreateDeviceRequest; +import com.clearblade.cloud.iot.v1.createdevice.CreateDeviceResponse; +import com.clearblade.cloud.iot.v1.deletedevice.DeleteDeviceRequest; +import com.clearblade.cloud.iot.v1.deletedevice.DeleteDeviceResponse; +import com.clearblade.cloud.iot.v1.deviceconfigversionslist.DeviceConfigVersionsListRequest; +import com.clearblade.cloud.iot.v1.deviceconfigversionslist.DeviceConfigVersionsListResponse; +import com.clearblade.cloud.iot.v1.devicepatch.DevicePatchRequest; +import com.clearblade.cloud.iot.v1.devicepatch.DevicePatchResponse; +import com.clearblade.cloud.iot.v1.deviceslist.DevicesListRequest; +import com.clearblade.cloud.iot.v1.deviceslist.DevicesListResponse; +import com.clearblade.cloud.iot.v1.devicestateslist.DeviceStatesListRequest; +import com.clearblade.cloud.iot.v1.devicestateslist.DeviceStatesListResponse; +import com.clearblade.cloud.iot.v1.getdevice.GetDeviceRequest; +import com.clearblade.cloud.iot.v1.getdevice.GetDeviceResponse; +import com.clearblade.cloud.iot.v1.modifycloudtodeviceconfig.ModifyCloudToDeviceConfigRequest; +import com.clearblade.cloud.iot.v1.modifycloudtodeviceconfig.ModifyCloudToDeviceConfigResponse; +import com.clearblade.cloud.iot.v1.sendcommandtodevice.SendCommandToDeviceRequest; +import com.clearblade.cloud.iot.v1.sendcommandtodevice.SendCommandToDeviceResponse; +import com.clearblade.cloud.iot.v1.unbinddevicefromgateway.UnbindDeviceFromGatewayRequest; +import com.clearblade.cloud.iot.v1.unbinddevicefromgateway.UnbindDeviceFromGatewayResponse; import com.clearblade.cloud.iot.v1.utils.Device; import com.clearblade.cloud.iot.v1.utils.DeviceName; import com.clearblade.cloud.iot.v1.utils.RegistryName; public class DeviceManagerClient { + + /** + * Print the response for sendCommandToDevice + * + * @param request + * @return Response object + */ + public SendCommandToDeviceResponse sendCommandToDeviceAsync(SendCommandToDeviceRequest request) { + return (SendCommandToDeviceResponse.Builder.newBuilder().setSendCommandToDeviceRequest(request).build()); + } + /** * SendCommandToDevice method * @@ -17,7 +49,6 @@ public void sendCommandToDevice(DeviceName name, com.clearblade.cloud.iot.v1.uti String subfolder) { SendCommandToDeviceRequest request = SendCommandToDeviceRequest.Builder.newBuilder().setName(name) .setBinaryData(binaryData).setSubfolder(subfolder).build(); - this.sendCommandToDevice(request); SendCommandToDeviceResponse response = this.sendCommandToDevice(request); response.processRequest(request); } @@ -132,49 +163,107 @@ public DeviceStatesListResponse deviceStatesList(DeviceStatesListRequest request } /** - * DeviceSetStates method + * ModifyCloudToDeviceConfig method * - * @param name, method + * @param device object + * @param versionToUpdate * @param binaryData */ - public void devicesSetStates(String name, ByteString binaryData) { - DeviceSetStatesRequest request = DeviceSetStatesRequest.Builder.newBuilder().setDeviceName(name) - .setBinaryData(binaryData).build(); - this.deviceSetStates(request); - DeviceSetStatesResponse response = this.deviceSetStates(request); + public void modifyCloudToDeviceConfig(Device device, com.clearblade.cloud.iot.v1.utils.ByteString binaryData, String versionToUpdate) { + ModifyCloudToDeviceConfigRequest request = ModifyCloudToDeviceConfigRequest.Builder.newBuilder().setDevice(device) + .setBinaryData(binaryData).setVersionToUpdate(versionToUpdate).build(); + ModifyCloudToDeviceConfigResponse response = this.modifyCloudToDeviceConfig(request); response.processRequest(request); } /** - * Print the response for DeviceSetStatesRequest + * Print the response for ModifyCloudToDeviceConfig * * @param request * @return Response object */ - public DeviceSetStatesResponse deviceSetStates(DeviceSetStatesRequest request) { - return (DeviceSetStatesResponse.Builder.newBuilder().setDeviceSetStatesRequest(request).build()); + public ModifyCloudToDeviceConfigResponse modifyCloudToDeviceConfig(ModifyCloudToDeviceConfigRequest request) { + return (ModifyCloudToDeviceConfigResponse.Builder.newBuilder().setModifyCloudToDeviceConfigRequest(request).build()); } + /** - * Method used to call getDeviceConfig api - * @param name - * @return Device Config - binary Data and version + * Method used to call DeviceConfigVersionsList api + * @param name and numVersions */ - public void getDeviceConfig(DeviceName name,String localVersion) { - GetDeviceConfigRequest request = GetDeviceConfigRequest.Builder.newBuilder().setDeviceName(name == null ? null : name.toString()).setLocalVersion(localVersion).build(); - getDeviceConfig(request); + public void deviceConfigVersionsList(String name, String numVersions) { + DeviceConfigVersionsListRequest request = DeviceConfigVersionsListRequest.Builder.newBuilder().setName(name).setNumVersions(numVersions).build(); + deviceConfigVersionsList(request); } /** - * Print the response for getDeviceConfig - * + * Print the response for deviceConfigVersionsList + * * @param request * @return Response object */ - public GetDeviceConfigResponse getDeviceConfig(GetDeviceConfigRequest request) { - return (GetDeviceConfigResponse.Builder.newBuilder().setGetDeviceConfigRequest(request).build()); + public DeviceConfigVersionsListResponse deviceConfigVersionsList(DeviceConfigVersionsListRequest request) { + return (DeviceConfigVersionsListResponse.Builder.newBuilder().setDeviceConfigVersionsListRequest(request).build()); } + /** + * bindDeviceToGateway method + * @param parent + * @param gatewayId + * @param deviceId + */ + public void bindDeviceToGateway(String parent, String gatewayId, String deviceId) { + BindDeviceToGatewayRequest request = BindDeviceToGatewayRequest.Builder.newBuilder().setParent(parent).setGateway(gatewayId).setDevice(deviceId).build(); + BindDeviceToGatewayResponse response = this.bindDeviceToGateway(request); + response.processRequest(request); + } + /** + * Print the response for bindDeviceToGateway + * + * @param request + * @return Response object + */ + public BindDeviceToGatewayResponse bindDeviceToGateway(BindDeviceToGatewayRequest request) { + return (BindDeviceToGatewayResponse.Builder.newBuilder().setBindDeviceToGatewayRequest(request).build()); + } + /** + * unbindDeviceFromGateway method + * @param parent + * @param gatewayId + * @param deviceId + */ + public void unbindDeviceFromGateway(String parent, String gatewayId, String deviceId) { + UnbindDeviceFromGatewayRequest request = UnbindDeviceFromGatewayRequest.Builder.newBuilder().setParent(parent).setGateway(gatewayId).setDevice(deviceId).build(); + UnbindDeviceFromGatewayResponse response = this.unbindDeviceFromGateway(request); + response.processRequest(request); + } + /** + * Print the response for unbindDeviceFromGateway + * @param request + * @return Response object + */ + public UnbindDeviceFromGatewayResponse unbindDeviceFromGateway(UnbindDeviceFromGatewayRequest request) { + return (UnbindDeviceFromGatewayResponse.Builder.newBuilder().setUnbindDeviceFromGatewayRequest(request).build()); + } + /** + * devicePatch method + * @param name + * @param updateMask + * @param device object - id, name, logLevel, blocked + */ + public void devicePatch(String name, String updateMask, Device device) { + DevicePatchRequest request = DevicePatchRequest.Builder.newBuilder().setName(name).setUpdateMask(updateMask).setDevice(device).build(); + DevicePatchResponse response = this.devicePatch(request); + response.processRequest(request); + } + /** + * Print the response for devicePatch + * @param request + * @return Response object + */ + public DevicePatchResponse devicePatch(DevicePatchRequest request) { + return (DevicePatchResponse.Builder.newBuilder().setDevicePatchRequest(request).build()); + } } diff --git a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/GetDeviceConfigRequest.java b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/GetDeviceConfigRequest.java deleted file mode 100644 index 5e9d2b94..00000000 --- a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/GetDeviceConfigRequest.java +++ /dev/null @@ -1,65 +0,0 @@ -package com.clearblade.cloud.iot.v1; - -import org.json.simple.JSONObject; - -public class GetDeviceConfigRequest { - - private final String deviceName; - private final String localVersion; - JSONObject requestParams = new JSONObject(); - - private GetDeviceConfigRequest(Builder builder) { - this.deviceName = builder.deviceName; - this.localVersion = builder.localVersion; - } - - // Static class Builder - public static class Builder { - - /// instance fields - private String deviceName; - private String localVersion; - - public static Builder newBuilder() { - return new Builder(); - } - - private Builder() { - } - - // Setter methods - public Builder setDeviceName(String deviceName) { - this.deviceName = deviceName; - return this; - } - public Builder setLocalVersion(String localVersion) { - this.localVersion = localVersion; - return this; - } - - // build method to deal with outer class - // to return outer instance - public GetDeviceConfigRequest build() { - return new GetDeviceConfigRequest(this); - } - } - - @Override - public String toString() { - requestParams = new JSONObject(); - requestParams.put("name", this.deviceName); - requestParams.put("localVersion", this.localVersion); - this.setRequestParams(requestParams); - return "name="+this.deviceName+"localVersion="+this.localVersion; - } - - public JSONObject getRequestParams() { - return requestParams; - } - - public void setRequestParams(JSONObject requestParams) { - this.requestParams = requestParams; - } - - -} diff --git a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/ProcessRequest.java b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/ProcessRequest.java index 7f5ec31f..b8a1a99f 100644 --- a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/ProcessRequest.java +++ b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/ProcessRequest.java @@ -7,28 +7,92 @@ import java.io.OutputStream; import java.net.ProtocolException; import java.net.URL; +import java.util.concurrent.CompletableFuture; +import java.util.concurrent.ExecutionException; +import java.util.concurrent.Future; +import java.util.concurrent.TimeUnit; +import java.util.concurrent.TimeoutException; +import java.util.logging.Level; +import java.util.logging.Logger; import javax.net.ssl.HttpsURLConnection; import org.json.simple.JSONObject; +import org.json.simple.parser.JSONParser; +import org.json.simple.parser.ParseException; +import com.clearblade.cloud.iot.v1.auth.AdminAccess; +import com.clearblade.cloud.iot.v1.auth.SystemAccess; +import com.clearblade.cloud.iot.v1.getregistrycredentials.GetRegistryCredentialsRequest; +import com.clearblade.cloud.iot.v1.getregistrycredentials.GetRegistryCredentialsResponse; +import com.clearblade.cloud.iot.v1.sendcommandtodevice.SendCommandToDeviceRequest; +import com.clearblade.cloud.iot.v1.utils.AuthParams; import com.clearblade.cloud.iot.v1.utils.ConfigParameters; import com.clearblade.cloud.iot.v1.utils.Constants; import com.clearblade.cloud.iot.v1.utils.SetHttpConnection; public class ProcessRequest { + static Logger log = Logger.getLogger(ProcessRequest.class.getName()); URL obj; HttpsURLConnection con; String responseMessage; JSONObject bodyJSONObj; + JSONObject requestJSONObj; int responseCode; ConfigParameters configParameters; SetHttpConnection setCon; String emptyStr; + SystemAccess systemAccess; + AuthParams authParams; + + public void getRegistryCredentials() { + + String msg = ""; + + GetRegistryCredentialsRequest request = GetRegistryCredentialsRequest.Builder.newBuilder().build(); + GetRegistryCredentialsResponse response = GetRegistryCredentialsResponse.Builder.newBuilder().setGetRegistryCredentialsRequest(request).build(); + + if (response != null) { + log.log(Level.INFO,"Request is processed for {0}",request); + JSONObject requestParams = new JSONObject(); + JSONObject bodyParams = new JSONObject(); + if(request.getBodyParams()!= null) { + bodyParams = (JSONObject) request.getBodyParams().clone(); + } + try { + responseMessage = processRequestGetRegistryCredential(Constants.GET_REGISTRY_CREDENTIALS, requestParams, bodyParams); + } catch (Exception e) { + e.printStackTrace(); + } + response.setHttpStatusResponse(responseMessage); + if (responseMessage.equals("OK")) { + response.setHttpStatusCode(200); + msg = "Request processed for GetRegistryCredentialsRequest method"; + + log.log(Level.INFO, msg); + } else { + response.setHttpStatusCode(0); + msg = "Request for GetRegistryCredentialsRequest failed \n" .concat(responseMessage); + log.log(Level.SEVERE, msg); + } + if (response.getHttpStatusResponse().equals("OK")) { + msg = "AsyncGetRegistryCredentials Method worked successfully :: " + response.getHttpStatusResponse(); + log.log(Level.INFO, msg); + } else { + msg = "AsyncGetRegistryCredentials Method execution failed :: " + response.getHttpStatusResponse(); + log.log(Level.SEVERE, msg); + } + } else { + msg = "AsyncGetRegistryCredentials Method execution failed"; + log.log(Level.SEVERE, msg); + } + } + // Empty Constructor public ProcessRequest() { + emptyStr = ""; configParameters = new ConfigParameters(); obj = null; @@ -36,75 +100,60 @@ public ProcessRequest() { setCon = null; responseCode = 0; responseMessage = null; + systemAccess = new SystemAccess(); + AdminAccess adminAccess = new AdminAccess(); + if(adminAccess.getAuthParams() == null) { + authParams =adminAccess.getSystemCredentials(); + }else { + authParams = adminAccess.getAuthParams(); + } + this.setAuthParams(authParams); + if(systemAccess.getApiBaseURL() == null) { + getRegistryCredentials(); + } + } + + /** + * Method used to getRegistryCredentials and + * set user system access + * @param methodName + * @param requestParams + * @param bodyParams + * @return String value of response object + */ + public String processRequestGetRegistryCredential(String methodName, JSONObject requestParams, JSONObject bodyParams) { + String finalURL = emptyStr; + try { + if (bodyParams != null && bodyParams.size() > 0) { + this.setBodyJSONObj(bodyParams); + } + finalURL = generateURL(methodName, requestParams); + obj = new URL(finalURL); + setCon = new SetHttpConnection(); + con = setCon.getConnection(obj); + responseMessage = setConnectionMethods(con, methodName); + } catch (Exception e) { + e.printStackTrace(); + } + return responseMessage; } /** * Method used to get process the request when inputString and connection object * are inputs ResponseCode - integer value is sent as return value - * * @param methodName * @return String - response message */ public String processRequestForMethod(String methodName, JSONObject requestParams, JSONObject bodyParams) { - - String finalURL = emptyStr; - String name; - String deviceNumIds; - String subfolder; - String parent; - String numStates; - - - // Setting partial URL - String urlPartial = Constants.HTTPS_URL_PREFIX.concat(configParameters.getEndPoint()) - .concat(configParameters.getBaseURL()).concat(configParameters.getSystemKey()) - .concat(configParameters.getDevicesURLExtension()); - - if (bodyParams != null && bodyParams.size() > 0) { - this.setBodyJSONObj(bodyParams); - } - if (methodName.equals(Constants.SEND_COMMAND_TO_DEVICE) && requestParams != null && requestParams.size() > 0) { - name = requestParams.get("name").toString(); - finalURL = urlPartial.concat("?name=" + name + "&method=" + methodName); - } else if (methodName.equals(Constants.CREATE_DEVICE) && requestParams != null && requestParams.size() > 0) { - deviceNumIds = requestParams.get("deviceNumIds").toString(); - subfolder = requestParams.get("subfolder").toString(); - finalURL = urlPartial.concat("?deviceNumIds=" + deviceNumIds + "&subfolder=" + subfolder); - } else if (((methodName.equals(Constants.DELETE_DEVICE)) || (methodName.equals(Constants.GET_DEVICE))) - && (requestParams != null && requestParams.size() > 0)) { - name = requestParams.get("name").toString(); - finalURL = urlPartial.concat("?name=" + name); - } else if (methodName.equals(Constants.DEVICES_LIST) && (requestParams != null && requestParams.size() > 0)) { - parent = requestParams.get("parent").toString(); - finalURL = urlPartial.concat("?parent=" + parent); - }else if (methodName.equals(Constants.DEVICE_STATES_LIST) && (requestParams != null && requestParams.size() > 0)) { - urlPartial = Constants.HTTPS_URL_PREFIX.concat(configParameters.getEndPoint()) - .concat(configParameters.getBaseURL()).concat(configParameters.getSystemKey()) - .concat(configParameters.getDevicesStatesURLExtension()); - name = requestParams.get("name").toString(); - numStates = requestParams.get("numStates").toString(); - finalURL = urlPartial.concat("?name=" + name+"&numStates="+Integer.parseInt(numStates)); - }else if (methodName.equals(Constants.DEVICE_SET_STATES) && requestParams != null && requestParams.size() > 0) { - urlPartial = Constants.HTTPS_URL_PREFIX.concat(configParameters.getEndPoint()) - .concat(configParameters.getBaseURL()).concat(configParameters.getSystemKey()) - .concat(configParameters.getCloudiotdevicesURLExtension()); - name = requestParams.get("name").toString(); - method = requestParams.get("method").toString(); - finalURL = urlPartial.concat("?name=" + name + "&method=" + method); - } else if (methodName.equals(Constants.DEVICE_GET_CONFIG) && requestParams != null && requestParams.size() > 0) { - urlPartial = Constants.HTTPS_URL_PREFIX.concat(configParameters.getEndPoint()) - .concat(configParameters.getBaseURL()).concat(configParameters.getSystemKey()) - .concat(configParameters.getCloudiotdevicesURLExtension()); - name = requestParams.get("name").toString(); - localVersion = requestParams.get("localVersion").toString(); - finalURL = urlPartial.concat("?name=" + name + "&localVersion=" + localVersion); - } - try { + if (bodyParams != null && bodyParams.size() > 0) { + this.setBodyJSONObj(bodyParams); + } + String finalURL = generateURL(methodName, requestParams); + log.log(Level.INFO,finalURL); obj = new URL(finalURL); setCon = new SetHttpConnection(); con = setCon.getConnection(obj); - // Calling setConnectionMethod responseMessage = setConnectionMethods(con, methodName); } catch (Exception e) { e.printStackTrace(); @@ -114,29 +163,28 @@ public String processRequestForMethod(String methodName, JSONObject requestParam /** * Set connection methods - * * @param con * @returning response message */ public String setConnectionMethods(HttpsURLConnection con, String methodName) { if (con != null) { - con.setRequestProperty(Constants.HTTP_REQUEST_PROPERTY_TOKEN_KEY, configParameters.getToken()); + if (methodName.equals(Constants.GET_REGISTRY_CREDENTIALS)) { + con.setRequestProperty(Constants.HTTP_REQUEST_PROPERTY_TOKEN_KEY, authParams.getAdminToken()); + }else { + con.setRequestProperty(Constants.HTTP_REQUEST_PROPERTY_TOKEN_KEY, systemAccess.getUserSystemToken()); + } con.setRequestProperty(Constants.HTTP_REQUEST_PROPERTY_CONTENT_TYPE_KEY, Constants.HTTP_REQUEST_PROPERTY_CONTENT_TYPE_ACCEPT_VALUE); con.addRequestProperty(Constants.HTTP_REQUEST_PROPERTY_ACCEPT_KEY, Constants.HTTP_REQUEST_PROPERTY_CONTENT_TYPE_ACCEPT_VALUE); - String methodType = ""; - if ((methodName.equals(Constants.SEND_COMMAND_TO_DEVICE) || methodName.equals(Constants.CREATE_DEVICE)) || (methodName.equals(Constants.DEVICE_SET_STATES))) { - methodType = Constants.HTTP_REQUEST_METHOD_TYPE_POST; - } else if (methodName.equals(Constants.DELETE_DEVICE)) { - methodType = Constants.HTTP_REQUEST_METHOD_TYPE_DELETE; - } else if ((methodName.equals(Constants.GET_DEVICE)) || (methodName.equals(Constants.DEVICES_LIST)) || (methodName.equals(Constants.DEVICE_STATES_LIST)) || (methodName.equals(Constants.DEVICE_GET_CONFIG))) { - methodType = Constants.HTTP_REQUEST_METHOD_TYPE_GET; - } + String methodType = setMethodType(methodName); try { con.setRequestMethod(methodType); + if (methodName.equals(Constants.DEVICE_PATCH)) { + con.setRequestProperty("X-HTTP-Method-Override", Constants.HTTP_REQUEST_METHOD_TYPE_PATCH); + } } catch (ProtocolException e) { e.printStackTrace(); } @@ -145,18 +193,22 @@ public String setConnectionMethods(HttpsURLConnection con, String methodName) { con.setDoOutput(true); // Get responseCode from Connection - if (methodName.equals(Constants.SEND_COMMAND_TO_DEVICE) || methodName.equals(Constants.CREATE_DEVICE) || methodName.equals(Constants.DEVICE_SET_STATES)) { + if (methodName.equals(Constants.SEND_COMMAND_TO_DEVICE) || methodName.equals(Constants.CREATE_DEVICE) + || methodName.equals(Constants.DEVICE_SET_STATES) + || methodName.equals(Constants.MODIFY_CLOUD_TO_DEVICE_CONFIG) + || methodName.equals(Constants.BIND_DEVICE_TO_GATEWAY) + || methodName.equals(Constants.UNBIND_DEVICE_FROM_GATEWAY)) { responseMessage = getResponseForPostMethod(con); } else if (methodName.equals(Constants.DELETE_DEVICE)) { responseMessage = getResponseForDeleteDevice(con); - } else if (methodName.equals(Constants.GET_DEVICE)) { - responseMessage = getResponseForGetRequest(con); - }else if (methodName.equals(Constants.DEVICES_LIST)) { - responseMessage = getResponseForGetRequest(con); - }else if (methodName.equals(Constants.DEVICE_STATES_LIST)) { - responseMessage = getResponseForGetRequest(con); - }else if (methodName.equals(Constants.DEVICE_GET_CONFIG)) { + } else if (methodName.equals(Constants.GET_DEVICE) || methodName.equals(Constants.DEVICES_LIST) + || methodName.equals(Constants.DEVICE_STATES_LIST) || methodName.equals(Constants.DEVICE_GET_CONFIG) + || methodName.equals(Constants.DEVICE_CONFIG_VERSIONS_LIST)) { responseMessage = getResponseForGetRequest(con); + } else if (methodName.equals(Constants.DEVICE_PATCH)) { + responseMessage = getResponseForPostMethod(con); + } else if (methodName.equals(Constants.GET_REGISTRY_CREDENTIALS)) { + responseMessage = getResponseForRegsitryCredentialsMethod(con); } } return responseMessage; @@ -196,7 +248,7 @@ public String getResponseForGetRequest(HttpsURLConnection con) { if (con.getInputStream() != null) { in = new BufferedReader(new InputStreamReader(con.getInputStream())); } - if(in != null) { + if (in != null) { while ((inputLine = in.readLine()) != null) { response.append(inputLine); splitResponse = splitResponse.concat(inputLine); @@ -217,25 +269,71 @@ public String getResponseForPostMethod(HttpsURLConnection con) { StringBuilder response = new StringBuilder(); try (OutputStream os = con.getOutputStream()) { JSONObject js = this.getBodyJSONObj(); - byte[] input = js.toString().getBytes("utf-8"); + byte[] input = js.toString().getBytes(Constants.UTF8); os.write(input, 0, input.length); os.flush(); responseCode = con.getResponseCode(); + BufferedReader in = null; + if (con.getErrorStream() != null) { + in = new BufferedReader(new InputStreamReader(con.getErrorStream())); + } else if (con.getInputStream() != null) { + in = new BufferedReader(new InputStreamReader(con.getInputStream())); + } + String inputLine; + if (in != null) { + while ((inputLine = in.readLine()) != null) { + response.append(inputLine); + } + } if (responseCode != 200) { - BufferedReader in = null; - if (con.getErrorStream() != null) { - in = new BufferedReader(new InputStreamReader(con.getErrorStream())); - } else if (con.getInputStream() != null) { - in = new BufferedReader(new InputStreamReader(con.getInputStream())); + responseMessage = response.toString(); + } else if (responseCode == 200) { + responseMessage = "OK"; + } + } catch (IOException e1) { + e1.printStackTrace(); + } + return responseMessage; + } + + public String getResponseForRegsitryCredentialsMethod(HttpsURLConnection con) { + StringBuilder response = new StringBuilder(); + try (OutputStream os = con.getOutputStream()) { + JSONObject js = this.getBodyJSONObj(); + byte[] input = js.toString().getBytes(Constants.UTF8); + os.write(input, 0, input.length); + os.flush(); + responseCode = con.getResponseCode(); + BufferedReader in = null; + if (con.getErrorStream() != null) { + in = new BufferedReader(new InputStreamReader(con.getErrorStream())); + } else if (con.getInputStream() != null) { + in = new BufferedReader(new InputStreamReader(con.getInputStream())); + } + JSONObject responseJSONObject = new JSONObject(); + JSONParser responseParser = new JSONParser(); + String inputLine; + if (in != null) { + while ((inputLine = in.readLine()) != null) { + response.append(inputLine); } - String inputLine; - if (in != null) { - while ((inputLine = in.readLine()) != null) { - response.append(inputLine); + responseMessage = response.toString(); + } + if (responseCode == 200) { + try { + if(responseMessage != null && responseMessage.length() > 0) { + Object responseObj = responseParser.parse(responseMessage); + if(responseObj != null) { + responseJSONObject = (JSONObject) responseObj; + systemAccess.setUserSystemKey(responseJSONObject.get(Constants.USER_SYSTEM_KEY).toString()); + systemAccess.setUserSystemToken(responseJSONObject.get(Constants.USER_TOKEN).toString()); + systemAccess.setApiBaseURL(responseJSONObject.get(Constants.API_BASE_URL).toString()); + this.setSystemAccess(systemAccess); + } } + } catch (ParseException e) { + e.printStackTrace(); } - responseMessage = response.toString(); - } else if (responseCode == 200) { responseMessage = "OK"; } } catch (IOException e1) { @@ -247,6 +345,74 @@ public String getResponseForPostMethod(HttpsURLConnection con) { public String getResponseForDeleteDevice(HttpsURLConnection con) { StringBuilder response = new StringBuilder(); try { + responseCode = con.getResponseCode(); + BufferedReader in = null; + if (con.getErrorStream() != null) { + in = new BufferedReader(new InputStreamReader(con.getErrorStream())); + } else if (con.getInputStream() != null) { + in = new BufferedReader(new InputStreamReader(con.getInputStream())); + } + String inputLine; + if (in != null) { + while ((inputLine = in.readLine()) != null) { + response.append(inputLine); + } + } + if (responseCode != 200) { + responseMessage = response.toString(); + } else if (responseCode == 200) { + responseMessage = "OK"; + } + } catch (IOException e) { + e.printStackTrace(); + } + return responseMessage; + } + + public String asyncCallSendCommandToDevice(SendCommandToDeviceRequest request) throws InterruptedException { + this.setBodyJSONObj(request.bodyParams); + this.setRequestJSONObj(request.requestParams); + Future future = getObjectAsync(); + try { + future.get(15000, TimeUnit.MILLISECONDS); + } catch (InterruptedException | ExecutionException | TimeoutException e) { + e.printStackTrace(); + Thread.currentThread().interrupt(); + } + return responseMessage; + } + + public Future getObjectAsync() { + return CompletableFuture.supplyAsync(this::doHttpCall); + } + + public Object doHttpCall() { + StringBuilder response = new StringBuilder(); + try { + + // Generate URL for this api call + String finalURL = generateURL(Constants.SEND_COMMAND_TO_DEVICE, this.getRequestJSONObj()); + + obj = new URL(finalURL); + setCon = new SetHttpConnection(); + con = setCon.getConnection(obj); // Calling setConnectionMethod + con.setRequestProperty(Constants.HTTP_REQUEST_PROPERTY_TOKEN_KEY, systemAccess.getUserSystemToken()); + con.setRequestProperty(Constants.HTTP_REQUEST_PROPERTY_CONTENT_TYPE_KEY, + Constants.HTTP_REQUEST_PROPERTY_CONTENT_TYPE_ACCEPT_VALUE); + con.addRequestProperty(Constants.HTTP_REQUEST_PROPERTY_ACCEPT_KEY, + Constants.HTTP_REQUEST_PROPERTY_CONTENT_TYPE_ACCEPT_VALUE); + + String methodType = Constants.HTTP_REQUEST_METHOD_TYPE_POST; + con.setRequestMethod(methodType); + + // SetOutput to connection + con.setDoOutput(true); + + OutputStream os = con.getOutputStream(); + JSONObject js = this.getBodyJSONObj(); + byte[] input = js.toString().getBytes(Constants.UTF8); + os.write(input, 0, input.length); + os.flush(); responseCode = con.getResponseCode(); if (responseCode != 200) { BufferedReader in = null; @@ -265,12 +431,128 @@ public String getResponseForDeleteDevice(HttpsURLConnection con) { } else if (responseCode == 200) { responseMessage = "OK"; } - } catch (IOException e) { - e.printStackTrace(); + } catch (IOException e1) { + e1.printStackTrace(); } return responseMessage; } + public String generateURL(String methodName, JSONObject requestParams) { + + String finalURL = emptyStr; + + + // Global Call + if (requestParams.size() == 0) { + if (methodName.equals(Constants.GET_REGISTRY_CREDENTIALS)) { + String partialURL = authParams.getBaseURL() + .concat(configParameters.getGetSystemCredentialsExtension()) + .concat(authParams.getAdminSystemKey()) + .concat("/" + methodName); + finalURL = finalURL.concat(partialURL); + } + }else { + + // Regional Call + String urlPartial = this.getSystemAccess().getApiBaseURL() + .concat(configParameters.getEndpointPort()) + .concat(configParameters.getBaseURL()) + .concat(this.getSystemAccess().getUserSystemKey()); + + String urlDevicesPartial = urlPartial.concat(configParameters.getDevicesURLExtension()); + String urlDevicesStatesPartial = urlPartial.concat(configParameters.getDevicesStatesURLExtension()); + String urlCloudiotdevicesPartial = urlPartial.concat(configParameters.getCloudiotdevicesURLExtension()); + String urlCloudiotURLPartial = urlPartial.concat(configParameters.getCloudiotURLExtension()); + + + if (methodName.equals(Constants.SEND_COMMAND_TO_DEVICE) || methodName.equals(Constants.MODIFY_CLOUD_TO_DEVICE_CONFIG)) { + + String name = requestParams.get("name").toString(); + finalURL = urlDevicesPartial.concat(Constants.NAME + name + "&method=" + methodName); + + } else if (methodName.equals(Constants.CREATE_DEVICE)) { + + String deviceNumIds = requestParams.get("deviceNumIds").toString(); + String subfolder = requestParams.get("subfolder").toString(); + finalURL = urlDevicesPartial.concat("?deviceNumIds=" + deviceNumIds + "&subfolder=" + subfolder); + + } else if (methodName.equals(Constants.DELETE_DEVICE) || methodName.equals(Constants.GET_DEVICE)) { + + String name = requestParams.get("name").toString(); + finalURL = urlDevicesPartial.concat(Constants.NAME + name); + + } else if (methodName.equals(Constants.DEVICES_LIST)) { + + String parent = requestParams.get("parent").toString(); + finalURL = urlDevicesPartial.concat("?parent=" + parent); + + } else if (methodName.equals(Constants.DEVICE_STATES_LIST)) { + + String name = requestParams.get("name").toString(); + String numStates = requestParams.get("numStates").toString(); + finalURL = urlDevicesStatesPartial.concat(Constants.NAME + name + "&numStates=" + Integer.parseInt(numStates)); + + } else if (methodName.equals(Constants.DEVICE_CONFIG_VERSIONS_LIST)) { + + String name = requestParams.get("name").toString(); + String numVersions = requestParams.get("numVersions").toString(); + finalURL = urlCloudiotdevicesPartial.concat(Constants.NAME + name + "&numVersions=" + numVersions); + + } else if (methodName.equals(Constants.UNBIND_DEVICE_FROM_GATEWAY) || methodName.equals(Constants.BIND_DEVICE_TO_GATEWAY)) { + + String method = requestParams.get("method").toString(); + String parent = requestParams.get("parent").toString(); + finalURL = urlCloudiotURLPartial.concat("?method=" + method + "&parent=" + parent); + + } else if (methodName.equals(Constants.DEVICE_PATCH)) { + + String name = requestParams.get("name").toString(); + String updateMask = requestParams.get("updateMask").toString(); + finalURL = urlDevicesPartial.concat(Constants.NAME + name + "&updateMask=" + updateMask); + } + } + + return finalURL; + } + + /** + * Method used to set method type on connection depending upon method name + * @param methodName + * @return methodType to be set for e.g. post, patch, delete etc + */ + public String setMethodType(String methodName) { + String methodType = emptyStr; + + if ((methodName.equals(Constants.SEND_COMMAND_TO_DEVICE) || methodName.equals(Constants.CREATE_DEVICE)) + || methodName.equals(Constants.DEVICE_SET_STATES) + || methodName.equals(Constants.MODIFY_CLOUD_TO_DEVICE_CONFIG) + || methodName.equals(Constants.BIND_DEVICE_TO_GATEWAY) + || methodName.equals(Constants.UNBIND_DEVICE_FROM_GATEWAY) + || methodName.equals(Constants.GET_REGISTRY_CREDENTIALS)) { + + methodType = Constants.HTTP_REQUEST_METHOD_TYPE_POST; + + } else if (methodName.equals(Constants.DELETE_DEVICE)) { + + methodType = Constants.HTTP_REQUEST_METHOD_TYPE_DELETE; + + } else if ((methodName.equals(Constants.GET_DEVICE)) || methodName.equals(Constants.DEVICES_LIST) + || methodName.equals(Constants.DEVICE_STATES_LIST) + || methodName.equals(Constants.DEVICE_GET_CONFIG) + || methodName.equals(Constants.DEVICE_CONFIG_VERSIONS_LIST)) { + + methodType = Constants.HTTP_REQUEST_METHOD_TYPE_GET; + + } else if (methodName.equals(Constants.DEVICE_PATCH)) { + + methodType = Constants.HTTP_REQUEST_METHOD_TYPE_POST; + + } + + return methodType; + + } + public JSONObject getBodyJSONObj() { return bodyJSONObj; } @@ -279,4 +561,27 @@ public void setBodyJSONObj(JSONObject bodyJSONObj) { this.bodyJSONObj = bodyJSONObj; } + public JSONObject getRequestJSONObj() { + return requestJSONObj; + } + + public void setRequestJSONObj(JSONObject requestJSONObj) { + this.requestJSONObj = requestJSONObj; + } + + public SystemAccess getSystemAccess() { + return systemAccess; + } + + public void setSystemAccess(SystemAccess systemAccess) { + this.systemAccess = systemAccess; + } + + public AuthParams getAuthParams() { + return authParams; + } + + public void setAuthParams(AuthParams authParams) { + this.authParams = authParams; + } } \ No newline at end of file diff --git a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/auth/AdminAccess.java b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/auth/AdminAccess.java new file mode 100644 index 00000000..6e8a7b4e --- /dev/null +++ b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/auth/AdminAccess.java @@ -0,0 +1,71 @@ +package com.clearblade.cloud.iot.v1.auth; + +import java.io.FileNotFoundException; +import java.io.FileReader; +import java.io.IOException; +import java.util.logging.Level; +import java.util.logging.Logger; + +import org.json.simple.JSONObject; +import org.json.simple.parser.JSONParser; +import org.json.simple.parser.ParseException; + +import com.clearblade.cloud.iot.v1.utils.AuthParams; +import com.clearblade.cloud.iot.v1.utils.Constants; + +public class AdminAccess { + + static Logger log = Logger.getLogger(AdminAccess.class.getName()); + + static AuthParams authParams; + + public AuthParams getSystemCredentials() { + + String pathToAuthFile = System.getenv(Constants.AUTH_ACCESS); + + JSONParser jsonParser = new JSONParser(); + try (FileReader authReader = new FileReader(pathToAuthFile)) { + // Read JSON file + Object obj = jsonParser.parse(authReader); + JSONObject authJSONObject = (JSONObject) obj; + if (authJSONObject != null) { + + authParams = new AuthParams(); + + String adminSystemKey = (authJSONObject.get(Constants.ADMIN_SYSTEM_KEY)).toString(); + authParams.setAdminSystemKey(adminSystemKey); + + String adminToken = (authJSONObject.get(Constants.ADMIN_TOKEN)).toString(); + authParams.setAdminToken(adminToken); + + String baseURL = (authJSONObject.get(Constants.BASE_URL)).toString(); + authParams.setBaseURL(baseURL); + + String projectName = (authJSONObject.get(Constants.PROJECT_NAME)).toString(); + authParams.setProject(projectName); + + this.setAuthParams(authParams); + } + + } catch (FileNotFoundException e) { + log.log(Level.SEVERE, "Configuration file missing."); + e.printStackTrace(); + } catch (IOException e) { + log.log(Level.SEVERE, "Error occurred while reading configuration from file."); + e.printStackTrace(); + } catch (ParseException e) { + log.log(Level.SEVERE, "Can not parse configuration objects from file."); + e.printStackTrace(); + } + return authParams; + } + + public AuthParams getAuthParams() { + return authParams; + } + + public void setAuthParams(AuthParams setAuthParams) { + authParams = setAuthParams; + } + +} diff --git a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/auth/SystemAccess.java b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/auth/SystemAccess.java new file mode 100644 index 00000000..f1153c26 --- /dev/null +++ b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/auth/SystemAccess.java @@ -0,0 +1,27 @@ +package com.clearblade.cloud.iot.v1.auth; + +public class SystemAccess { + + private String userSystemKey; + private String userSystemToken; + private String apiBaseURL; + + public String getUserSystemKey() { + return userSystemKey; + } + public void setUserSystemKey(String userSystemKey) { + this.userSystemKey = userSystemKey; + } + public String getUserSystemToken() { + return userSystemToken; + } + public void setUserSystemToken(String userSystemToken) { + this.userSystemToken = userSystemToken; + } + public String getApiBaseURL() { + return apiBaseURL; + } + public void setApiBaseURL(String apiBaseURL) { + this.apiBaseURL = apiBaseURL; + } +} diff --git a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/binddevicetogateway/BindDeviceToGatewayRequest.java b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/binddevicetogateway/BindDeviceToGatewayRequest.java new file mode 100644 index 00000000..fbe6b496 --- /dev/null +++ b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/binddevicetogateway/BindDeviceToGatewayRequest.java @@ -0,0 +1,91 @@ +package com.clearblade.cloud.iot.v1.binddevicetogateway; + +import org.json.simple.JSONObject; + +import com.clearblade.cloud.iot.v1.utils.Constants; + +public class BindDeviceToGatewayRequest { + private final String parent; + private final String gateway; + private final String device; + JSONObject requestParams; + JSONObject bodyParams; + + private BindDeviceToGatewayRequest(Builder builder) { + this.parent = builder.parent; + this.gateway = builder.gateway; + this.device = builder.device; + } + + // Static class Builder + public static class Builder { + + /// instance fields + private String parent; + private String gateway; + private String device; + + public static Builder newBuilder() { + return new Builder(); + } + + private Builder() { + } + + // Setter methods + public Builder setParent(String parent) { + this.parent = parent; + return this; + } + + public Builder setGateway(String gateway) { + this.gateway = gateway; + return this; + } + + public Builder setDevice(String device) { + this.device = device; + return this; + } + + // build method to deal with outer class + // to return outer instance + public BindDeviceToGatewayRequest build() { + return new BindDeviceToGatewayRequest(this); + } + } + + public JSONObject getRequestParams() { + return requestParams; + } + + public void setRequestParams(JSONObject requestParams) { + this.requestParams = requestParams; + } + + public JSONObject getBodyParams() { + return bodyParams; + } + + public void setBodyParams(JSONObject bodyParams) { + this.bodyParams = bodyParams; + } + @SuppressWarnings("unchecked") + @Override + public String toString() { + requestParams = new JSONObject(); + bodyParams = new JSONObject(); + String method = Constants.BIND_DEVICE_TO_GATEWAY; + requestParams.put("method", method); + requestParams.put("parent", this.parent); + + bodyParams.put("gatewayId", this.gateway); + bodyParams.put("deviceId", this.device); + + this.setRequestParams(requestParams); + this.setBodyParams(bodyParams); + + return "parent=" + this.parent + ",gateway=" + this.gateway+", device= "+this.device; + } + +} diff --git a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/binddevicetogateway/BindDeviceToGatewayResponse.java b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/binddevicetogateway/BindDeviceToGatewayResponse.java new file mode 100644 index 00000000..223fe4cf --- /dev/null +++ b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/binddevicetogateway/BindDeviceToGatewayResponse.java @@ -0,0 +1,102 @@ +package com.clearblade.cloud.iot.v1.binddevicetogateway; + +import java.util.logging.Level; +import java.util.logging.Logger; + +import org.json.simple.JSONObject; + +import com.clearblade.cloud.iot.v1.ProcessRequest; +import com.clearblade.cloud.iot.v1.utils.Constants; + +public class BindDeviceToGatewayResponse { + + static Logger log = Logger.getLogger(BindDeviceToGatewayResponse.class.getName()); + private final BindDeviceToGatewayRequest request; + private int httpStatusCode; + private String httpStatusResponse; + + protected BindDeviceToGatewayResponse(Builder builder) { + this.request = builder.request; + } + + public int getHttpStatusCode() { + return httpStatusCode; + } + + public void setHttpStatusCode(int httpStatusCode) { + this.httpStatusCode = httpStatusCode; + } + + public String getHttpStatusResponse() { + return httpStatusResponse; + } + + public void setHttpStatusResponse(String httpStatusResponse) { + this.httpStatusResponse = httpStatusResponse; + } + + // Static class Builder + public static class Builder { + + /// instance fields + private BindDeviceToGatewayRequest request; + + public static Builder newBuilder() { + return new Builder(); + } + + private Builder() { + } + + // Setter methods + public Builder setBindDeviceToGatewayRequest(BindDeviceToGatewayRequest request) { + this.request = request; + return this; + } + + // build method to deal with outer class + // to return outer instance + public BindDeviceToGatewayResponse build() { + return new BindDeviceToGatewayResponse(this); + } + } + + /** + * Mehtod used to process the request Calling processRequestForMethod - + * BindDeviceToGateway + */ + public void processRequest(BindDeviceToGatewayRequest request) { + String msg = ""; + JSONObject requestParams = new JSONObject(); + JSONObject bodyParams = new JSONObject(); + ProcessRequest processRequest = new ProcessRequest(); + if(request != null) { + String logMsg = "Bind Device To Gateway Request :: "+request.toString(); + log.log(Level.INFO,logMsg); + requestParams = (JSONObject) request.requestParams.clone(); + bodyParams = (JSONObject) request.bodyParams.clone(); + } + String responseMessage = processRequest.processRequestForMethod(Constants.BIND_DEVICE_TO_GATEWAY,requestParams,bodyParams); + this.setHttpStatusResponse(responseMessage); + if (responseMessage.equals("OK")) { + this.setHttpStatusCode(200); + msg = "Request processed for BIND_DEVICE_TO_GATEWAY method"; + log.log(Level.INFO, msg); + } else { + this.setHttpStatusCode(0); + msg = "Request for BIND_DEVICE_TO_GATEWAY failed \n" .concat(responseMessage); + log.log(Level.SEVERE, msg); + } + } + + @Override + public String toString() { + return "Http Status Code :: " + this.getHttpStatusCode() + " Http Status Response :: " + + this.getHttpStatusResponse(); + } + + public BindDeviceToGatewayRequest getRequest() { + return request; + } + +} diff --git a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/CreateDeviceRequest.java b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/createdevice/CreateDeviceRequest.java similarity index 98% rename from clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/CreateDeviceRequest.java rename to clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/createdevice/CreateDeviceRequest.java index 4feb53e2..657d72ea 100644 --- a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/CreateDeviceRequest.java +++ b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/createdevice/CreateDeviceRequest.java @@ -1,4 +1,4 @@ -package com.clearblade.cloud.iot.v1; +package com.clearblade.cloud.iot.v1.createdevice; import java.util.Collections; diff --git a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/CreateDeviceResponse.java b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/createdevice/CreateDeviceResponse.java similarity index 96% rename from clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/CreateDeviceResponse.java rename to clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/createdevice/CreateDeviceResponse.java index 46fbe0e2..12785de7 100644 --- a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/CreateDeviceResponse.java +++ b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/createdevice/CreateDeviceResponse.java @@ -1,10 +1,12 @@ -package com.clearblade.cloud.iot.v1; +package com.clearblade.cloud.iot.v1.createdevice; import java.util.logging.Level; import java.util.logging.Logger; import org.json.simple.JSONObject; +import com.clearblade.cloud.iot.v1.ProcessRequest; + public class CreateDeviceResponse { static Logger log = Logger.getLogger(CreateDeviceResponse.class.getName()); diff --git a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/DeleteDeviceRequest.java b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/deletedevice/DeleteDeviceRequest.java similarity index 93% rename from clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/DeleteDeviceRequest.java rename to clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/deletedevice/DeleteDeviceRequest.java index 8c1284b4..fcfcd75c 100644 --- a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/DeleteDeviceRequest.java +++ b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/deletedevice/DeleteDeviceRequest.java @@ -1,4 +1,4 @@ -package com.clearblade.cloud.iot.v1; +package com.clearblade.cloud.iot.v1.deletedevice; public class DeleteDeviceRequest { private final String deviceName; diff --git a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/DeleteDeviceResponse.java b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/deletedevice/DeleteDeviceResponse.java similarity index 95% rename from clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/DeleteDeviceResponse.java rename to clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/deletedevice/DeleteDeviceResponse.java index fe127dc5..a4657a66 100644 --- a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/DeleteDeviceResponse.java +++ b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/deletedevice/DeleteDeviceResponse.java @@ -1,10 +1,12 @@ -package com.clearblade.cloud.iot.v1; +package com.clearblade.cloud.iot.v1.deletedevice; import java.util.logging.Level; import java.util.logging.Logger; import org.json.simple.JSONObject; +import com.clearblade.cloud.iot.v1.ProcessRequest; + public class DeleteDeviceResponse { static Logger log = Logger.getLogger(DeleteDeviceResponse.class.getName()); diff --git a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/deviceconfigversionslist/DeviceConfigVersionsListRequest.java b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/deviceconfigversionslist/DeviceConfigVersionsListRequest.java new file mode 100644 index 00000000..13ee9038 --- /dev/null +++ b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/deviceconfigversionslist/DeviceConfigVersionsListRequest.java @@ -0,0 +1,66 @@ +package com.clearblade.cloud.iot.v1.deviceconfigversionslist; + +import org.json.simple.JSONObject; + +public class DeviceConfigVersionsListRequest { + private final String name; + private final String numVersions; + JSONObject requestParams; + + private DeviceConfigVersionsListRequest(Builder builder) { + this.name = builder.name; + this.numVersions = builder.numVersions; + } + + // Static class Builder + public static class Builder { + + /// instance fields + private String name; + private String numVersions; + + public static Builder newBuilder() { + return new Builder(); + } + + private Builder() { + } + + // Setter methods + public Builder setName(String name) { + this.name = name; + return this; + } + + public Builder setNumVersions(String numVersions) { + this.numVersions = numVersions; + return this; + } + + // build method to deal with outer class + // to return outer instance + public DeviceConfigVersionsListRequest build() { + return new DeviceConfigVersionsListRequest(this); + } + + } + + public JSONObject getRequestParams() { + return requestParams; + } + + public void setRequestParams(JSONObject requestParams) { + this.requestParams = requestParams; + } + + @SuppressWarnings("unchecked") + @Override + public String toString() { + requestParams = new JSONObject(); + requestParams.put("name", this.name); + requestParams.put("numVersions", this.numVersions); + this.setRequestParams(requestParams); + return "name=" + this.name + ",numVersions=" + this.numVersions; + } + +} diff --git a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/DeviceSetStatesResponse.java b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/deviceconfigversionslist/DeviceConfigVersionsListResponse.java similarity index 69% rename from clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/DeviceSetStatesResponse.java rename to clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/deviceconfigversionslist/DeviceConfigVersionsListResponse.java index 3565173c..0f15bf68 100644 --- a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/DeviceSetStatesResponse.java +++ b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/deviceconfigversionslist/DeviceConfigVersionsListResponse.java @@ -1,18 +1,21 @@ -package com.clearblade.cloud.iot.v1; +package com.clearblade.cloud.iot.v1.deviceconfigversionslist; import java.util.logging.Level; import java.util.logging.Logger; import org.json.simple.JSONObject; -public class DeviceSetStatesResponse { +import com.clearblade.cloud.iot.v1.ProcessRequest; +import com.clearblade.cloud.iot.v1.utils.Constants; - static Logger log = Logger.getLogger(DeviceSetStatesResponse.class.getName()); - private final DeviceSetStatesRequest request; +public class DeviceConfigVersionsListResponse { + + static Logger log = Logger.getLogger(DeviceConfigVersionsListResponse.class.getName()); + private final DeviceConfigVersionsListRequest request; private int httpStatusCode; private String httpStatusResponse; - protected DeviceSetStatesResponse(Builder builder) { + protected DeviceConfigVersionsListResponse(Builder builder) { this.request = builder.request; } @@ -36,7 +39,7 @@ public void setHttpStatusResponse(String httpStatusResponse) { public static class Builder { /// instance fields - private DeviceSetStatesRequest request; + private DeviceConfigVersionsListRequest request; public static Builder newBuilder() { return new Builder(); @@ -46,48 +49,51 @@ private Builder() { } // Setter methods - public Builder setDeviceSetStatesRequest(DeviceSetStatesRequest request) { + public Builder setDeviceConfigVersionsListRequest(DeviceConfigVersionsListRequest request) { this.request = request; return this; } // build method to deal with outer class // to return outer instance - public DeviceSetStatesResponse build() { - return new DeviceSetStatesResponse(this); + public DeviceConfigVersionsListResponse build() { + return new DeviceConfigVersionsListResponse(this); } } /** * Mehtod used to process the request - * Calling processRequestForMethod - sendCommandToDevice + * Calling processRequestForMethod - deviceConfigVersionsList */ - public void processRequest(DeviceSetStatesRequest request) { + public void processRequest(DeviceConfigVersionsListRequest request) { String msg = ""; JSONObject requestParams = new JSONObject(); JSONObject bodyParams = new JSONObject(); ProcessRequest processRequest = new ProcessRequest(); if(request != null) { - String logMsg = "Setting states request on device :: "+request.toString(); + String logMsg = "Config versions list for device :: "+request.toString(); log.log(Level.INFO,logMsg); requestParams = (JSONObject) request.requestParams.clone(); - bodyParams = (JSONObject) request.bodyParams.clone(); } - String responseMessage = processRequest.processRequestForMethod("setState",requestParams,bodyParams); + String responseMessage = processRequest.processRequestForMethod(Constants.DEVICE_CONFIG_VERSIONS_LIST,requestParams,bodyParams); this.setHttpStatusResponse(responseMessage); if (responseMessage.equals("OK")) { - msg = "Request processed successfully for DeviceSetStates method"; + msg = "Request processed successfully for DeviceConfigVersionsList method"; log.log(Level.INFO, msg); } else { - msg = "POST request not worked for DeviceSetStates Method \n".concat(responseMessage); + msg = "POST request not worked for DeviceConfigVersionsList Method \n".concat(responseMessage); log.log(Level.SEVERE, msg); } } - + + public DeviceConfigVersionsListRequest getRequest() { + return request; + } + /** * Mehtod used to process the request * Calling processRequestForMethod - DeviceSetStatesRequest diff --git a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/devicepatch/DevicePatchRequest.java b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/devicepatch/DevicePatchRequest.java new file mode 100644 index 00000000..063e9cf2 --- /dev/null +++ b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/devicepatch/DevicePatchRequest.java @@ -0,0 +1,92 @@ +package com.clearblade.cloud.iot.v1.devicepatch; + +import org.json.simple.JSONObject; + +import com.clearblade.cloud.iot.v1.utils.Device; + +public class DevicePatchRequest { + private final String name; + private final Device device; + private final String updateMask; + JSONObject requestParams; + JSONObject bodyParams; + + private DevicePatchRequest(Builder builder) { + this.name = builder.name; + this.updateMask = builder.updateMask; + this.device = builder.device; + } + + // Static class Builder + public static class Builder { + + /// instance fields + private String name; + private Device device; + private String updateMask; + + public static Builder newBuilder() { + return new Builder(); + } + + private Builder() { + } + + // Setter methods + public Builder setName(String name) { + this.name = name; + return this; + } + + public Builder setDevice(Device device) { + this.device = device; + return this; + } + + public Builder setUpdateMask(String updateMask) { + this.updateMask = updateMask; + return this; + } + + // build method to deal with outer class + // to return outer instance + public DevicePatchRequest build() { + return new DevicePatchRequest(this); + } + } + + public JSONObject getRequestParams() { + return requestParams; + } + + public void setRequestParams(JSONObject requestParams) { + this.requestParams = requestParams; + } + + public JSONObject getBodyParams() { + return bodyParams; + } + + public void setBodyParams(JSONObject bodyParams) { + this.bodyParams = bodyParams; + } + @SuppressWarnings("unchecked") + @Override + public String toString() { + requestParams = new JSONObject(); + bodyParams = new JSONObject(); + requestParams.put("name", this.name); + requestParams.put("updateMask", this.updateMask); + + bodyParams.put("id", this.device.toBuilder().getId()); + bodyParams.put("name", this.device.toBuilder().getName()); + bodyParams.put("logLevel", this.device.toBuilder().getLogLevel()); + bodyParams.put("blocked", this.device.toBuilder().isBlocked()); + + this.setRequestParams(requestParams); + this.setBodyParams(bodyParams); + + return "name=" + this.name + ",updateMask=" + this.updateMask+", logLevel= "+this.device.toBuilder().getLogLevel(); + } + +} diff --git a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/GetDeviceConfigResponse.java b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/devicepatch/DevicePatchResponse.java similarity index 60% rename from clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/GetDeviceConfigResponse.java rename to clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/devicepatch/DevicePatchResponse.java index 09948627..3367d51d 100644 --- a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/GetDeviceConfigResponse.java +++ b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/devicepatch/DevicePatchResponse.java @@ -1,22 +1,21 @@ -package com.clearblade.cloud.iot.v1; +package com.clearblade.cloud.iot.v1.devicepatch; import java.util.logging.Level; import java.util.logging.Logger; import org.json.simple.JSONObject; -import com.clearblade.cloud.iot.v1.utils.Device; +import com.clearblade.cloud.iot.v1.ProcessRequest; +import com.clearblade.cloud.iot.v1.utils.Constants; -public class GetDeviceConfigResponse { - - static Logger log = Logger.getLogger(GetDeviceConfigResponse.class.getName()); - - private final GetDeviceConfigRequest request; +public class DevicePatchResponse { + + static Logger log = Logger.getLogger(DevicePatchResponse.class.getName()); + private final DevicePatchRequest request; private int httpStatusCode; private String httpStatusResponse; - private Device device; - protected GetDeviceConfigResponse(Builder builder) { + protected DevicePatchResponse(Builder builder) { this.request = builder.request; } @@ -40,7 +39,7 @@ public void setHttpStatusResponse(String httpStatusResponse) { public static class Builder { /// instance fields - private GetDeviceConfigRequest request; + private DevicePatchRequest request; public static Builder newBuilder() { return new Builder(); @@ -50,43 +49,42 @@ private Builder() { } // Setter methods - public Builder setGetDeviceConfigRequest(GetDeviceConfigRequest request) { + public Builder setDevicePatchRequest(DevicePatchRequest request) { this.request = request; return this; } // build method to deal with outer class // to return outer instance - public GetDeviceConfigResponse build() { - return new GetDeviceConfigResponse(this); + public DevicePatchResponse build() { + return new DevicePatchResponse(this); } } /** * Mehtod used to process the request Calling processRequestForMethod - - * GetDevice + * DevicePatch */ - @SuppressWarnings("unchecked") - public void processRequest(GetDeviceConfigRequest request) { + public void processRequest(DevicePatchRequest request) { String msg = ""; - ProcessRequest processRequest = new ProcessRequest(); JSONObject requestParams = new JSONObject(); JSONObject bodyParams = new JSONObject(); + ProcessRequest processRequest = new ProcessRequest(); if(request != null) { - String logMsg = "Calling get device config:: "+request.toString(); + String logMsg = "Device Patch Request :: "+request.toString(); log.log(Level.INFO,logMsg); requestParams = (JSONObject) request.requestParams.clone(); - } - String responseMessage = processRequest.processRequestForMethod("deviceGetConfig", requestParams, bodyParams); - this.setHttpStatusResponse(responseMessage); + bodyParams = (JSONObject) request.bodyParams.clone(); + } + String responseMessage = processRequest.processRequestForMethod(Constants.DEVICE_PATCH,requestParams,bodyParams); + this.setHttpStatusResponse(responseMessage); if (responseMessage.equals("OK")) { this.setHttpStatusCode(200); - msg = "Request processed for GetDeviceConfig method"; - + msg = "Request processed for Device patch method"; log.log(Level.INFO, msg); } else { this.setHttpStatusCode(0); - msg = "Request for GetDeviceConfig failed \n" .concat(responseMessage); + msg = "Request for Device patch failed \n" .concat(responseMessage); log.log(Level.SEVERE, msg); } } @@ -97,16 +95,8 @@ public String toString() { + this.getHttpStatusResponse(); } - public GetDeviceConfigRequest getRequest() { + public DevicePatchRequest getRequest() { return request; } - public Device getDevice() { - return device; - } - - public void setDevice(Device device) { - this.device = device; - } - } diff --git a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/DevicesListRequest.java b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/deviceslist/DevicesListRequest.java similarity index 94% rename from clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/DevicesListRequest.java rename to clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/deviceslist/DevicesListRequest.java index 514f62a8..77d5e1a0 100644 --- a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/DevicesListRequest.java +++ b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/deviceslist/DevicesListRequest.java @@ -1,4 +1,4 @@ -package com.clearblade.cloud.iot.v1; +package com.clearblade.cloud.iot.v1.deviceslist; import com.clearblade.cloud.iot.v1.utils.RegistryName; diff --git a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/DevicesListResponse.java b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/deviceslist/DevicesListResponse.java similarity index 96% rename from clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/DevicesListResponse.java rename to clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/deviceslist/DevicesListResponse.java index 7de25144..6bdb0f70 100644 --- a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/DevicesListResponse.java +++ b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/deviceslist/DevicesListResponse.java @@ -1,4 +1,4 @@ -package com.clearblade.cloud.iot.v1; +package com.clearblade.cloud.iot.v1.deviceslist; import java.util.List; import java.util.logging.Level; @@ -6,6 +6,7 @@ import org.json.simple.JSONObject; +import com.clearblade.cloud.iot.v1.ProcessRequest; import com.clearblade.cloud.iot.v1.utils.Device; public class DevicesListResponse { diff --git a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/DeviceStatesListRequest.java b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/devicestateslist/DeviceStatesListRequest.java similarity index 92% rename from clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/DeviceStatesListRequest.java rename to clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/devicestateslist/DeviceStatesListRequest.java index 0ae39828..6ae58549 100644 --- a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/DeviceStatesListRequest.java +++ b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/devicestateslist/DeviceStatesListRequest.java @@ -1,4 +1,4 @@ -package com.clearblade.cloud.iot.v1; +package com.clearblade.cloud.iot.v1.devicestateslist; import org.json.simple.JSONObject; @@ -60,7 +60,7 @@ public void setRequestParams(JSONObject requestParams) { public String toString() { requestParams = new JSONObject(); requestParams.put("name", this.name); - requestParams.put("numStates", this.numStates.toString()); + requestParams.put("numStates", this.numStates); this.setRequestParams(requestParams); return "name="+this.name+",numStates="+this.numStates; } diff --git a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/DeviceStatesListResponse.java b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/devicestateslist/DeviceStatesListResponse.java similarity index 96% rename from clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/DeviceStatesListResponse.java rename to clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/devicestateslist/DeviceStatesListResponse.java index 28ec3924..2e576a74 100644 --- a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/DeviceStatesListResponse.java +++ b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/devicestateslist/DeviceStatesListResponse.java @@ -1,12 +1,12 @@ -package com.clearblade.cloud.iot.v1; +package com.clearblade.cloud.iot.v1.devicestateslist; import java.util.List; -import java.util.Map; import java.util.logging.Level; import java.util.logging.Logger; import org.json.simple.JSONObject; +import com.clearblade.cloud.iot.v1.ProcessRequest; import com.clearblade.cloud.iot.v1.utils.DeviceState; public class DeviceStatesListResponse { @@ -67,7 +67,6 @@ public DeviceStatesListResponse build() { * Mehtod used to process the request Calling processRequestForMethod - * DevicesList */ - @SuppressWarnings("unchecked") public void processRequest(DeviceStatesListRequest request) { String msg = ""; ProcessRequest processRequest = new ProcessRequest(); diff --git a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/GetDeviceRequest.java b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/getdevice/GetDeviceRequest.java similarity index 93% rename from clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/GetDeviceRequest.java rename to clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/getdevice/GetDeviceRequest.java index 9da62644..3c234992 100644 --- a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/GetDeviceRequest.java +++ b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/getdevice/GetDeviceRequest.java @@ -1,4 +1,4 @@ -package com.clearblade.cloud.iot.v1; +package com.clearblade.cloud.iot.v1.getdevice; public class GetDeviceRequest { diff --git a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/GetDeviceResponse.java b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/getdevice/GetDeviceResponse.java similarity index 96% rename from clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/GetDeviceResponse.java rename to clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/getdevice/GetDeviceResponse.java index 609eb37a..22f539d6 100644 --- a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/GetDeviceResponse.java +++ b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/getdevice/GetDeviceResponse.java @@ -1,10 +1,11 @@ -package com.clearblade.cloud.iot.v1; +package com.clearblade.cloud.iot.v1.getdevice; import java.util.logging.Level; import java.util.logging.Logger; import org.json.simple.JSONObject; +import com.clearblade.cloud.iot.v1.ProcessRequest; import com.clearblade.cloud.iot.v1.utils.Device; public class GetDeviceResponse { diff --git a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/getregistrycredentials/GetRegistryCredentialsRequest.java b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/getregistrycredentials/GetRegistryCredentialsRequest.java new file mode 100644 index 00000000..d5ee7858 --- /dev/null +++ b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/getregistrycredentials/GetRegistryCredentialsRequest.java @@ -0,0 +1,61 @@ +package com.clearblade.cloud.iot.v1.getregistrycredentials; + +import org.json.simple.JSONObject; + +import com.clearblade.cloud.iot.v1.auth.AdminAccess; +import com.clearblade.cloud.iot.v1.utils.AuthParams; +import com.clearblade.cloud.iot.v1.utils.ConfigParameters; +import com.clearblade.cloud.iot.v1.utils.Constants; + +public class GetRegistryCredentialsRequest { + + JSONObject bodyParams; + + private GetRegistryCredentialsRequest(Builder builder) { + } + + // Static class Builder + public static class Builder { + + public static Builder newBuilder() { + return new Builder(); + } + + private Builder() { + } + + // build method to deal with outer class + // to return outer instance + public GetRegistryCredentialsRequest build() { + return new GetRegistryCredentialsRequest(this); + } + } + + @SuppressWarnings("unchecked") + @Override + public String toString() { + + ConfigParameters configParams = new ConfigParameters(); + AdminAccess adminAccess = new AdminAccess(); + AuthParams authParams = adminAccess.getAuthParams(); + String regionName = configParams.getRegion(); + String projectName = authParams.getProject(); + String registryName = configParams.getRegistry(); + bodyParams = new JSONObject(); + bodyParams.put(Constants.REGION,regionName); + bodyParams.put(Constants.REGISTRY,registryName); + bodyParams.put("project", projectName); + this.setBodyParams(bodyParams); + return "region="+regionName+"registry="+registryName+"project="+projectName; + } + + public JSONObject getBodyParams() { + return bodyParams; + } + + public void setBodyParams(JSONObject bodyParams) { + this.bodyParams = bodyParams; + } + + +} diff --git a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/getregistrycredentials/GetRegistryCredentialsResponse.java b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/getregistrycredentials/GetRegistryCredentialsResponse.java new file mode 100644 index 00000000..37077a5c --- /dev/null +++ b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/getregistrycredentials/GetRegistryCredentialsResponse.java @@ -0,0 +1,69 @@ +package com.clearblade.cloud.iot.v1.getregistrycredentials; + +import java.util.logging.Logger; + +public class GetRegistryCredentialsResponse { + + static Logger log = Logger.getLogger(GetRegistryCredentialsResponse.class.getName()); + + private final GetRegistryCredentialsRequest request; + private int httpStatusCode; + private String httpStatusResponse; + + protected GetRegistryCredentialsResponse(Builder builder) { + this.request = builder.request; + } + + public int getHttpStatusCode() { + return httpStatusCode; + } + + public void setHttpStatusCode(int httpStatusCode) { + this.httpStatusCode = httpStatusCode; + } + + public String getHttpStatusResponse() { + return httpStatusResponse; + } + + public void setHttpStatusResponse(String httpStatusResponse) { + this.httpStatusResponse = httpStatusResponse; + } + + // Static class Builder + public static class Builder { + + /// instance fields + private GetRegistryCredentialsRequest request; + + public static Builder newBuilder() { + return new Builder(); + } + + private Builder() { + } + + // Setter methods + public Builder setGetRegistryCredentialsRequest(GetRegistryCredentialsRequest request) { + this.request = request; + return this; + } + + // build method to deal with outer class + // to return outer instance + public GetRegistryCredentialsResponse build() { + return new GetRegistryCredentialsResponse(this); + } + } + + @Override + public String toString() { + return "Http Status Code :: " + this.getHttpStatusCode() + " Http Status Response :: " + + this.getHttpStatusResponse(); + } + + public GetRegistryCredentialsRequest getRequest() { + return request; + } + +} diff --git a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/DeviceSetStatesRequest.java b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/modifycloudtodeviceconfig/ModifyCloudToDeviceConfigRequest.java similarity index 51% rename from clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/DeviceSetStatesRequest.java rename to clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/modifycloudtodeviceconfig/ModifyCloudToDeviceConfigRequest.java index 1c9f7b27..f5f9ebea 100644 --- a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/DeviceSetStatesRequest.java +++ b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/modifycloudtodeviceconfig/ModifyCloudToDeviceConfigRequest.java @@ -1,36 +1,38 @@ -package com.clearblade.cloud.iot.v1; +package com.clearblade.cloud.iot.v1.modifycloudtodeviceconfig; import java.util.Arrays; import org.json.simple.JSONObject; import com.clearblade.cloud.iot.v1.utils.ByteString; +import com.clearblade.cloud.iot.v1.utils.Constants; +import com.clearblade.cloud.iot.v1.utils.Device; -public class DeviceSetStatesRequest { - +public class ModifyCloudToDeviceConfigRequest { + + private final Device device; + private final String versionToUpdate; private final ByteString binaryData; private final byte[] binaryDataByte; - private final String deviceName; - private final String method; public JSONObject requestParams; public JSONObject bodyParams; - private DeviceSetStatesRequest(Builder builder) { + private ModifyCloudToDeviceConfigRequest(Builder builder) { + this.device = builder.device; + this.versionToUpdate = builder.versionToUpdate; this.binaryData = builder.binaryData; this.binaryDataByte = builder.binaryDataByte; - this.deviceName = builder.deviceName; - this.method = builder.method; } // Static class Builder public static class Builder { /// instance fields + private Device device; + private String versionToUpdate; private ByteString binaryData; private byte[] binaryDataByte; - private String deviceName; - private String method; - + public static Builder newBuilder() { return new Builder(); } @@ -39,32 +41,48 @@ private Builder() { } // Setter methods - public Builder setBinaryData(ByteString binaryData) { - this.binaryData = binaryData; + public Builder setDevice(Device device) { + this.device = device; return this; } - public Builder setBinaryDataByte(byte[] binaryDataByte) { - this.binaryDataByte = binaryDataByte; + public Builder setVersionToUpdate(String versionToUpdate) { + this.versionToUpdate = versionToUpdate; return this; } - - public Builder setDeviceName(String deviceName) { - this.deviceName = deviceName; + + public Builder setBinaryData(ByteString binaryData) { + this.binaryData = binaryData; return this; } - public Builder setMethod(String method) { - this.method = method; + public Builder setBinaryDataByte(byte[] binaryDataByte) { + this.binaryDataByte = binaryDataByte; return this; } - + // build method to deal with outer class // to return outer instance - public DeviceSetStatesRequest build() { - return new DeviceSetStatesRequest(this); + public ModifyCloudToDeviceConfigRequest build() { + return new ModifyCloudToDeviceConfigRequest(this); } - } + } + + public JSONObject getRequestParams() { + return requestParams; + } + + public void setRequestParams(JSONObject requestParams) { + this.requestParams = requestParams; + } + + public JSONObject getBodyParams() { + return bodyParams; + } + + public void setBodyParams(JSONObject bodyParams) { + this.bodyParams = bodyParams; + } @SuppressWarnings("unchecked") @Override @@ -74,13 +92,10 @@ public String toString() { String dName = ""; String bData = null; - String method = ""; + String versionToUpdateStr = "1"; - if(this.deviceName != null) { - dName = this.deviceName; - } - if(this.method != null) { - method = this.method; + if(this.device != null) { + dName = this.device.toBuilder().getName(); } if(this.binaryData != null) { bData = new String(this.binaryData.getBinaryDataArray()); @@ -91,12 +106,17 @@ public String toString() { bData = Arrays.toString(this.binaryDataByte); } } + if(this.versionToUpdate != null) { + versionToUpdateStr = this.versionToUpdate; + } + String method = Constants.MODIFY_CLOUD_TO_DEVICE_CONFIG; requestParams.put("name", dName); requestParams.put("method", method); bodyParams.put("binaryData", bData); + bodyParams.put("versionToUpdate", versionToUpdateStr); - return "name = "+dName+", binaryData = "+bData+", method = "+method; - - } + return "name = "+dName+", binaryData = "+bData+", versionToUpdate = "+versionToUpdate; + } + } diff --git a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/modifycloudtodeviceconfig/ModifyCloudToDeviceConfigResponse.java b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/modifycloudtodeviceconfig/ModifyCloudToDeviceConfigResponse.java new file mode 100644 index 00000000..2cb931a1 --- /dev/null +++ b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/modifycloudtodeviceconfig/ModifyCloudToDeviceConfigResponse.java @@ -0,0 +1,102 @@ +package com.clearblade.cloud.iot.v1.modifycloudtodeviceconfig; + +import java.util.logging.Level; +import java.util.logging.Logger; + +import org.json.simple.JSONObject; + +import com.clearblade.cloud.iot.v1.ProcessRequest; +import com.clearblade.cloud.iot.v1.utils.Constants; + +public class ModifyCloudToDeviceConfigResponse { + + static Logger log = Logger.getLogger(ModifyCloudToDeviceConfigResponse.class.getName()); + private final ModifyCloudToDeviceConfigRequest request; + private int httpStatusCode; + private String httpStatusResponse; + + protected ModifyCloudToDeviceConfigResponse(Builder builder) { + this.request = builder.request; + } + + public int getHttpStatusCode() { + return httpStatusCode; + } + + public void setHttpStatusCode(int httpStatusCode) { + this.httpStatusCode = httpStatusCode; + } + + public String getHttpStatusResponse() { + return httpStatusResponse; + } + + public void setHttpStatusResponse(String httpStatusResponse) { + this.httpStatusResponse = httpStatusResponse; + } + + // Static class Builder + public static class Builder { + + /// instance fields + private ModifyCloudToDeviceConfigRequest request; + + public static Builder newBuilder() { + return new Builder(); + } + + private Builder() { + } + + // Setter methods + public Builder setModifyCloudToDeviceConfigRequest(ModifyCloudToDeviceConfigRequest request) { + this.request = request; + return this; + } + + // build method to deal with outer class + // to return outer instance + public ModifyCloudToDeviceConfigResponse build() { + return new ModifyCloudToDeviceConfigResponse(this); + } + } + + /** + * Mehtod used to process the request Calling processRequestForMethod - + * ModifyCloudToDeviceConfig + */ + public void processRequest(ModifyCloudToDeviceConfigRequest request) { + String msg = ""; + JSONObject requestParams = new JSONObject(); + JSONObject bodyParams = new JSONObject(); + ProcessRequest processRequest = new ProcessRequest(); + if(request != null) { + String logMsg = "Modify Cloud To Device Config Request :: "+request.toString(); + log.log(Level.INFO,logMsg); + requestParams = (JSONObject) request.requestParams.clone(); + bodyParams = (JSONObject) request.bodyParams.clone(); + } + String responseMessage = processRequest.processRequestForMethod(Constants.MODIFY_CLOUD_TO_DEVICE_CONFIG,requestParams,bodyParams); + this.setHttpStatusResponse(responseMessage); + if (responseMessage.equals("OK")) { + this.setHttpStatusCode(200); + msg = "Request processed for MODIFY_CLOUD_TO_DEVICE_CONFIG method"; + log.log(Level.INFO, msg); + } else { + this.setHttpStatusCode(0); + msg = "Request for MODIFY_CLOUD_TO_DEVICE_CONFIG failed \n" .concat(responseMessage); + log.log(Level.SEVERE, msg); + } + } + + @Override + public String toString() { + return "Http Status Code :: " + this.getHttpStatusCode() + " Http Status Response :: " + + this.getHttpStatusResponse(); + } + + public ModifyCloudToDeviceConfigRequest getRequest() { + return request; + } + +} diff --git a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/SendCommandToDeviceRequest.java b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/sendcommandtodevice/SendCommandToDeviceRequest.java similarity index 97% rename from clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/SendCommandToDeviceRequest.java rename to clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/sendcommandtodevice/SendCommandToDeviceRequest.java index a00b1baa..ed4e51f1 100644 --- a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/SendCommandToDeviceRequest.java +++ b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/sendcommandtodevice/SendCommandToDeviceRequest.java @@ -1,4 +1,4 @@ -package com.clearblade.cloud.iot.v1; +package com.clearblade.cloud.iot.v1.sendcommandtodevice; import java.util.Arrays; diff --git a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/SendCommandToDeviceResponse.java b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/sendcommandtodevice/SendCommandToDeviceResponse.java similarity index 71% rename from clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/SendCommandToDeviceResponse.java rename to clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/sendcommandtodevice/SendCommandToDeviceResponse.java index 66ffb519..c9452d29 100644 --- a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/SendCommandToDeviceResponse.java +++ b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/sendcommandtodevice/SendCommandToDeviceResponse.java @@ -1,10 +1,12 @@ -package com.clearblade.cloud.iot.v1; +package com.clearblade.cloud.iot.v1.sendcommandtodevice; import java.util.logging.Level; import java.util.logging.Logger; import org.json.simple.JSONObject; +import com.clearblade.cloud.iot.v1.ProcessRequest; + public class SendCommandToDeviceResponse { static Logger log = Logger.getLogger(SendCommandToDeviceResponse.class.getName()); @@ -88,6 +90,36 @@ public void processRequest(SendCommandToDeviceRequest request) { } + /** + * Mehtod used to process the request + * Calling processRequestForMethod - sendCommandToDevice + */ + + public String processRequestAsync(SendCommandToDeviceRequest request) { + String msg = ""; + ProcessRequest processRequest = new ProcessRequest(); + if(request != null) { + String logMsg = "Sending request to device :: "+request.toString(); + log.log(Level.INFO,logMsg); + } + String responseMessage =""; + try { + responseMessage = processRequest.asyncCallSendCommandToDevice(request); + this.setHttpStatusResponse(responseMessage); + if (responseMessage.equals("OK")) { + msg = "Request processed successfully for SendCommandToDevice method"; + log.log(Level.INFO, msg); + } else { + msg = "POST request not worked for sendCommandToDevice Method \n".concat(responseMessage); + log.log(Level.SEVERE, msg); + } + } catch (Exception e) { + e.printStackTrace(); + } + return responseMessage; + + } + @Override public String toString() { return "Http Status Code :: " + this.getHttpStatusCode() + " Http Status Response :: " diff --git a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/test/DeviceManagerClientTest.java b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/test/DeviceManagerClientTest.java index d066d8d0..12c04ffb 100644 --- a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/test/DeviceManagerClientTest.java +++ b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/test/DeviceManagerClientTest.java @@ -5,11 +5,11 @@ import org.junit.Assert; import org.junit.Test; -import com.clearblade.cloud.iot.v1.CreateDeviceRequest; -import com.clearblade.cloud.iot.v1.CreateDeviceResponse; import com.clearblade.cloud.iot.v1.DeviceManagerClient; -import com.clearblade.cloud.iot.v1.SendCommandToDeviceRequest; -import com.clearblade.cloud.iot.v1.SendCommandToDeviceResponse; +import com.clearblade.cloud.iot.v1.createdevice.CreateDeviceRequest; +import com.clearblade.cloud.iot.v1.createdevice.CreateDeviceResponse; +import com.clearblade.cloud.iot.v1.sendcommandtodevice.SendCommandToDeviceRequest; +import com.clearblade.cloud.iot.v1.sendcommandtodevice.SendCommandToDeviceResponse; import com.clearblade.cloud.iot.v1.utils.ByteString; import com.clearblade.cloud.iot.v1.utils.Device; import com.clearblade.cloud.iot.v1.utils.DeviceName; diff --git a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/unbinddevicefromgateway/UnbindDeviceFromGatewayRequest.java b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/unbinddevicefromgateway/UnbindDeviceFromGatewayRequest.java new file mode 100644 index 00000000..81ee7577 --- /dev/null +++ b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/unbinddevicefromgateway/UnbindDeviceFromGatewayRequest.java @@ -0,0 +1,91 @@ +package com.clearblade.cloud.iot.v1.unbinddevicefromgateway; + +import org.json.simple.JSONObject; + +import com.clearblade.cloud.iot.v1.utils.Constants; + +public class UnbindDeviceFromGatewayRequest { + private final String parent; + private final String gateway; + private final String device; + JSONObject requestParams; + JSONObject bodyParams; + + private UnbindDeviceFromGatewayRequest(Builder builder) { + this.parent = builder.parent; + this.gateway = builder.gateway; + this.device = builder.device; + } + + // Static class Builder + public static class Builder { + + /// instance fields + private String parent; + private String gateway; + private String device; + + public static Builder newBuilder() { + return new Builder(); + } + + private Builder() { + } + + // Setter methods + public Builder setParent(String parent) { + this.parent = parent; + return this; + } + + public Builder setGateway(String gateway) { + this.gateway = gateway; + return this; + } + + public Builder setDevice(String device) { + this.device = device; + return this; + } + + // build method to deal with outer class + // to return outer instance + public UnbindDeviceFromGatewayRequest build() { + return new UnbindDeviceFromGatewayRequest(this); + } + } + + public JSONObject getRequestParams() { + return requestParams; + } + + public void setRequestParams(JSONObject requestParams) { + this.requestParams = requestParams; + } + + public JSONObject getBodyParams() { + return bodyParams; + } + + public void setBodyParams(JSONObject bodyParams) { + this.bodyParams = bodyParams; + } + @SuppressWarnings("unchecked") + @Override + public String toString() { + requestParams = new JSONObject(); + bodyParams = new JSONObject(); + String method = Constants.UNBIND_DEVICE_FROM_GATEWAY; + requestParams.put("method", method); + requestParams.put("parent", this.parent); + + bodyParams.put("gatewayId", this.gateway); + bodyParams.put("deviceId", this.device); + + this.setRequestParams(requestParams); + this.setBodyParams(bodyParams); + + return "parent=" + this.parent + ",gateway=" + this.gateway+", device= "+this.device; + } + +} diff --git a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/unbinddevicefromgateway/UnbindDeviceFromGatewayResponse.java b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/unbinddevicefromgateway/UnbindDeviceFromGatewayResponse.java new file mode 100644 index 00000000..afbf4704 --- /dev/null +++ b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/unbinddevicefromgateway/UnbindDeviceFromGatewayResponse.java @@ -0,0 +1,102 @@ +package com.clearblade.cloud.iot.v1.unbinddevicefromgateway; + +import java.util.logging.Level; +import java.util.logging.Logger; + +import org.json.simple.JSONObject; + +import com.clearblade.cloud.iot.v1.ProcessRequest; +import com.clearblade.cloud.iot.v1.utils.Constants; + +public class UnbindDeviceFromGatewayResponse { + + static Logger log = Logger.getLogger(UnbindDeviceFromGatewayResponse.class.getName()); + private final UnbindDeviceFromGatewayRequest request; + private int httpStatusCode; + private String httpStatusResponse; + + protected UnbindDeviceFromGatewayResponse(Builder builder) { + this.request = builder.request; + } + + public int getHttpStatusCode() { + return httpStatusCode; + } + + public void setHttpStatusCode(int httpStatusCode) { + this.httpStatusCode = httpStatusCode; + } + + public String getHttpStatusResponse() { + return httpStatusResponse; + } + + public void setHttpStatusResponse(String httpStatusResponse) { + this.httpStatusResponse = httpStatusResponse; + } + + // Static class Builder + public static class Builder { + + /// instance fields + private UnbindDeviceFromGatewayRequest request; + + public static Builder newBuilder() { + return new Builder(); + } + + private Builder() { + } + + // Setter methods + public Builder setUnbindDeviceFromGatewayRequest(UnbindDeviceFromGatewayRequest request) { + this.request = request; + return this; + } + + // build method to deal with outer class + // to return outer instance + public UnbindDeviceFromGatewayResponse build() { + return new UnbindDeviceFromGatewayResponse(this); + } + } + + /** + * Mehtod used to process the request Calling processRequestForMethod - + * UnbindDeviceFromGatewayRequest + */ + public void processRequest(UnbindDeviceFromGatewayRequest request) { + String msg = ""; + JSONObject requestParams = new JSONObject(); + JSONObject bodyParams = new JSONObject(); + ProcessRequest processRequest = new ProcessRequest(); + if(request != null) { + String logMsg = "Unbind Device To Gateway Request :: "+request.toString(); + log.log(Level.INFO,logMsg); + requestParams = (JSONObject) request.requestParams.clone(); + bodyParams = (JSONObject) request.bodyParams.clone(); + } + String responseMessage = processRequest.processRequestForMethod(Constants.UNBIND_DEVICE_FROM_GATEWAY,requestParams,bodyParams); + this.setHttpStatusResponse(responseMessage); + if (responseMessage.equals("OK")) { + this.setHttpStatusCode(200); + msg = "Request processed for UNBIND_DEVICE_TO_GATEWAY method"; + log.log(Level.INFO, msg); + } else { + this.setHttpStatusCode(0); + msg = "Request for UNBIND_DEVICE_TO_GATEWAY failed \n" .concat(responseMessage); + log.log(Level.SEVERE, msg); + } + } + + @Override + public String toString() { + return "Http Status Code :: " + this.getHttpStatusCode() + " Http Status Response :: " + + this.getHttpStatusResponse(); + } + + public UnbindDeviceFromGatewayRequest getRequest() { + return request; + } + +} diff --git a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/utils/AuthParams.java b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/utils/AuthParams.java new file mode 100644 index 00000000..6822e4ac --- /dev/null +++ b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/utils/AuthParams.java @@ -0,0 +1,37 @@ +package com.clearblade.cloud.iot.v1.utils; + +public class AuthParams { + + private String adminSystemKey; + private String project; + private String baseURL; + private String adminToken; + + public String getAdminSystemKey() { + return adminSystemKey; + } + public void setAdminSystemKey(String adminSystemKey) { + this.adminSystemKey = adminSystemKey; + } + public String getProject() { + return project; + } + public void setProject(String project) { + this.project = project; + } + public String getBaseURL() { + return baseURL; + } + public void setBaseURL(String baseURL) { + this.baseURL = baseURL; + } + public String getAdminToken() { + return adminToken; + } + public void setAdminToken(String adminToken) { + this.adminToken = adminToken; + } + + + +} diff --git a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/utils/ConfigParameters.java b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/utils/ConfigParameters.java index a849111f..58491b06 100644 --- a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/utils/ConfigParameters.java +++ b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/utils/ConfigParameters.java @@ -5,17 +5,22 @@ import java.util.Properties; public class ConfigParameters { + // Fields used to set values from properties file - private String endPoint; - private String systemKey; - private String token; + + private String project; + private String region; + private String registry; + private String endpointPort; + + private String getSystemCredentialsExtension; + private String baseURL; + private String cloudiotURLExtension; private String devicesURLExtension; private String devicesStatesURLExtension; private String cloudiotdevicesURLExtension; - private String project; - private String location; - private String registry; + private String cloudiotDeviceConfigURLExtension; // Fields used to fetch values from Properties file Properties properties; @@ -56,48 +61,25 @@ public void getConfigurations() { public void setValues() { // get Configurations uploaded from config.properties file getConfigurations(); - this.setEndPoint(properties.getProperty("endPoint")); - this.setSystemKey(properties.getProperty("systemKey")); - this.setToken(properties.getProperty("token")); this.setBaseURL(properties.getProperty("baseURL")); + this.setCloudiotURLExtension(properties.getProperty("cloudiotURLExtension")); this.setDevicesURLExtension(properties.getProperty("devicesURLExtension")); this.setCloudiotdevicesURLExtension(properties.getProperty("cloudiotdevicesURLExtension")); this.setDevicesStatesURLExtension(properties.getProperty("devicesStatesURLExtension")); + this.setCloudiotdevicesURLExtension(properties.getProperty("cloudiotDeviceConfigURLExtension")); this.setProject(properties.getProperty("project")); - this.setLocation(properties.getProperty("location")); + this.setRegion(properties.getProperty("region")); this.setRegistry(properties.getProperty("registry")); + this.setGetSystemCredentialsExtension(properties.getProperty("getSystemCredentialsExtension")); + this.setEndpointPort(properties.getProperty("endPointPort")); } - public String getEndPoint() { - return endPoint; - } - - public void setEndPoint(String endPoint) { - this.endPoint = endPoint; - } - - public String getSystemKey() { - return systemKey; + public String getCloudiotURLExtension() { + return cloudiotURLExtension; } - public void setSystemKey(String systemKey) { - this.systemKey = systemKey; - } - - public String getToken() { - return token; - } - - public void setToken(String token) { - this.token = token; - } - - public String getBaseURL() { - return baseURL; - } - - public void setBaseURL(String baseURL) { - this.baseURL = baseURL; + public void setCloudiotURLExtension(String cloudiotURLExtension) { + this.cloudiotURLExtension = cloudiotURLExtension; } public String getDevicesURLExtension() { @@ -123,7 +105,16 @@ public String getCloudiotdevicesURLExtension() { public void setCloudiotdevicesURLExtension(String cloudiotdevicesURLExtension) { this.cloudiotdevicesURLExtension = cloudiotdevicesURLExtension; } + + + public String getCloudiotDeviceConfigURLExtension() { + return cloudiotDeviceConfigURLExtension; + } + public void setCloudiotDeviceConfigURLExtension(String cloudiotDeviceConfigURLExtension) { + this.cloudiotDeviceConfigURLExtension = cloudiotDeviceConfigURLExtension; + } + public String getProject() { return project; } @@ -132,12 +123,12 @@ public void setProject(String project) { this.project = project; } - public String getLocation() { - return location; + public String getRegion() { + return region; } - public void setLocation(String location) { - this.location = location; + public void setRegion(String region) { + this.region = region; } public String getRegistry() { @@ -148,4 +139,28 @@ public void setRegistry(String registry) { this.registry = registry; } + public String getGetSystemCredentialsExtension() { + return getSystemCredentialsExtension; + } + + public void setGetSystemCredentialsExtension(String getSystemCredentialsExtension) { + this.getSystemCredentialsExtension = getSystemCredentialsExtension; + } + + public String getEndpointPort() { + return endpointPort; + } + + public void setEndpointPort(String endpointPort) { + this.endpointPort = endpointPort; + } + + public String getBaseURL() { + return baseURL; + } + + public void setBaseURL(String baseURL) { + this.baseURL = baseURL; + } + } diff --git a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/utils/Constants.java b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/utils/Constants.java index 32c14f5a..99a10dab 100644 --- a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/utils/Constants.java +++ b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/utils/Constants.java @@ -4,6 +4,17 @@ public class Constants { private Constants() {} + public static final String AUTH_ACCESS = "CLEARBLADE_CONFIGURATION"; + public static final String ADMIN_SYSTEM_KEY = "systemKey"; + public static final String ADMIN_TOKEN = "token"; + public static final String BASE_URL = "url"; + public static final String PROJECT_NAME = "project"; + public static final String REGION = "region"; + public static final String REGISTRY ="registry"; + public static final String USER_SYSTEM_KEY = "systemKey"; + public static final String USER_TOKEN = "serviceAccountToken"; + public static final String API_BASE_URL = "url"; + public static final String SEND_COMMAND_TO_DEVICE = "sendCommandToDevice"; public static final String CREATE_DEVICE = "createDevice"; public static final String DELETE_DEVICE = "deleteDevice"; @@ -12,12 +23,19 @@ private Constants() {} public static final String DEVICE_STATES_LIST = "deviceStatesList"; public static final String DEVICE_SET_STATES = "setState"; public static final String DEVICE_GET_CONFIG = "deviceGetConfig"; - + public static final String MODIFY_CLOUD_TO_DEVICE_CONFIG = "modifyCloudToDeviceConfig"; + public static final String DEVICE_CONFIG_VERSIONS_LIST = "deviceConfigVersionsList"; + public static final String BIND_DEVICE_TO_GATEWAY = "bindDeviceToGateway"; + public static final String UNBIND_DEVICE_FROM_GATEWAY = "unbindDeviceFromGateway"; + public static final String DEVICE_PATCH = "devicePatch"; + public static final String GET_REGISTRY_CREDENTIALS="getRegistryCredentials"; + // Constants used for setting up http connection - for common use public static final String HTTPS_URL_PREFIX = "https://"; public static final String HTTP_REQUEST_METHOD_TYPE_POST = "POST"; public static final String HTTP_REQUEST_METHOD_TYPE_DELETE = "DELETE"; public static final String HTTP_REQUEST_METHOD_TYPE_GET = "GET"; + public static final String HTTP_REQUEST_METHOD_TYPE_PATCH = "PATCH"; public static final String HTTP_REQUEST_PROPERTY_TOKEN_KEY = "ClearBlade-UserToken"; public static final String HTTP_REQUEST_PROPERTY_CONTENT_TYPE_KEY = "Content-Type"; public static final String HTTP_REQUEST_PROPERTY_ACCEPT_KEY = "Accept"; @@ -25,6 +43,8 @@ private Constants() {} //Commonly used String literal public static final String SUBFOLDER = "subfolder"; + public static final String NAME = "?name="; + public static final String UTF8 = "utf-8"; } diff --git a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/utils/Device.java b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/utils/Device.java index 2d46d101..eed73fae 100644 --- a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/utils/Device.java +++ b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/utils/Device.java @@ -20,7 +20,7 @@ public class Device { private final List lastErrorStatus; private final List config; private final List state; - private final int logLevel; + private final String logLevel; private final List metadata; private final List gatewayConfig; @@ -39,7 +39,7 @@ public Device() { lastErrorStatus = new ArrayList<>(); config = new ArrayList<>(); state = new ArrayList<>(); - logLevel = 0; + logLevel = "NONE"; metadata = new ArrayList<>(); gatewayConfig = new ArrayList<>(); } @@ -73,11 +73,14 @@ public Builder toBuilder() { return new Builder(this); } - public static Device of(String id, String name, int numId, List credentials, List lastErrorStatus,List config, List state, int logLevel, List metadata, List gatewayConfig) { + public static Device of(String id, String name, int numId, List credentials, List lastErrorStatus,List config, List state, String logLevel, List metadata, List gatewayConfig) { return newBuilder().setId(id).setName(name).setNumId(numId).setCredentials(credentials).setLastErrorStatus(lastErrorStatus).setConfig(config).setState(state).setLogLevel(logLevel).setMetadata(metadata).setGatewayConfig(gatewayConfig).build(); } - public static String format(String id, String name, int numId, List credentials, List lastErrorStatus,List config, List state, int logLevel, List metadata, List gatewayConfig) { + public static Device patch(String id, String name, String logLevel, boolean blocked) { + return newBuilder().setId(id).setName(name).setLogLevel(logLevel).setBlocked(blocked).build(); + } + public static String format(String id, String name, int numId, List credentials, List lastErrorStatus,List config, List state, String logLevel, List metadata, List gatewayConfig) { return newBuilder().setId(id).setName(name).setNumId(numId).setCredentials(credentials).setLastErrorStatus(lastErrorStatus).setConfig(config).setState(state).setLogLevel(logLevel).setMetadata(metadata).setGatewayConfig(gatewayConfig).build() .toString(); } @@ -101,7 +104,7 @@ public static class Builder { private List lastErrorStatus; private List config; private List state; - private int logLevel; + private String logLevel; private List metadata; private List gatewayConfig; @@ -174,7 +177,7 @@ public List getGatewayConfig() { return gatewayConfig; } - public int getLogLevel() { + public String getLogLevel() { return logLevel; } @@ -212,7 +215,7 @@ public Builder setConfig(List config) { return this; } - public Builder setLogLevel(int logLevel) { + public Builder setLogLevel(String logLevel) { this.logLevel = logLevel; return this; } @@ -231,6 +234,42 @@ public Builder setGatewayConfig(List gatewayConfig) { this.gatewayConfig = gatewayConfig; return this; } + + public Builder setBlocked(boolean blocked) { + this.blocked = blocked; + return this; + } + + public Builder setLastHeartbeatTime(Timestamp lastHeartbeatTime) { + this.lastHeartbeatTime = lastHeartbeatTime; + return this; + } + + public Builder setLastEventTime(Timestamp lastEventTime) { + this.lastEventTime = lastEventTime; + return this; + } + + public Builder setLastStateTime(Timestamp lastStateTime) { + this.lastStateTime = lastStateTime; + return this; + } + + public Builder setLastConfigAckTime(Timestamp lastConfigAckTime) { + this.lastConfigAckTime = lastConfigAckTime; + return this; + } + + public Builder setLastConfigSendTime(Timestamp lastConfigSendTime) { + this.lastConfigSendTime = lastConfigSendTime; + return this; + } + + public Builder setLastErrorTime(Timestamp lastErrorTime) { + this.lastErrorTime = lastErrorTime; + return this; + } + private Builder(Device device) { this.id = device.id; this.name = device.name; diff --git a/clearblade-cloud-iot/src/config.properties b/clearblade-cloud-iot/src/config.properties index 6ef354af..749a425d 100644 --- a/clearblade-cloud-iot/src/config.properties +++ b/clearblade-cloud-iot/src/config.properties @@ -1,14 +1,14 @@ -endPoint=iot-sandbox.clearblade.com:443 -systemKey=fedbc9b40cde90befbd9b2dfde9d01 -token=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1aWQiOiI4NmRjYzliNDBjOWVkMmI4YWFmZmMwOWRhMmNkMDEiLCJzaWQiOiJmZTdkNWIyMy1hODg4LTQ2NGUtOGE4MC01ZWM1NTYwOTBjZTIiLCJ1dCI6MiwidHQiOjEsImV4cCI6LTEsImlhdCI6MTY2NTc0MjU5NX0.osrsmcqunC6IMfgLfZis0UlC4s7W4mmKe73mq_SSJ8Q -project=ingressdevelopmentenv -location=us-central1 +region=us-central1 registry=Rashmi_Registry_Test -#deviceName=Rashmi_Device_Test +endPointPort=:443 baseURL=/api/v/4/webhook/execute/ devicesURLExtension=/cloudiot_devices - +cloudiotURLExtension=/cloudiot devicesStatesURLExtension=/cloudiot_devices_states cloudiotdevicesURLExtension=/cloudiotdevice_devices +cloudiotDeviceConfigURLExtension=/cloudiot_devices_configVersions + + +getSystemCredentialsExtension=/api/v/1/code/ From 7eb3a3115f4c220618af04d00439bd20cb4d8cf1 Mon Sep 17 00:00:00 2001 From: RashmiK14 Date: Mon, 21 Nov 2022 19:42:39 +0530 Subject: [PATCH 013/151] Committing changes for Devices Api after refactoring Changes after refactoring - devices apis --- .../AsyncBindDeviceToGateway.java | 28 +- .../SyncBindDeviceToGateway.java | 24 +- .../v1/createdevice/AsyncCreateDevice.java | 42 +- .../iot/v1/createdevice/SyncCreateDevice.java | 41 +- .../v1/deletedevice/AsyncDeleteDevice.java | 22 +- .../iot/v1/deletedevice/SyncDeleteDevice.java | 18 +- .../iot/v1/devicepatch/AsyncDevicePatch.java | 38 -- .../iot/v1/devicepatch/SyncDevicePatch.java | 38 -- .../iot/v1/deviceslist/AsyncDevicesList.java | 32 +- .../iot/v1/deviceslist/SyncDevicesList.java | 32 +- .../AsyncDeviceStatesList.java | 26 +- .../SyncDeviceStatesList.java | 21 +- .../iot/v1/getdevice/AsyncGetDevice.java | 26 +- .../cloud/iot/v1/getdevice/SyncGetDevice.java | 21 +- .../AsyncGetDeviceRegistry.java | 25 + .../SyncGetDeviceRegistry.java | 26 + .../AsyncModifyCloudToDeviceConfig.java | 26 +- .../SyncModifyCloudToDeviceConfig.java | 26 +- .../AsyncSendCommandToDevice.java | 29 +- .../SyncSendCommandToDevice.java | 25 +- .../SyncSendCommandToDeviceDataEmpty.java | 34 -- .../SyncSendCommandToDeviceDeviceName.java | 38 -- .../SyncSendCommandToDeviceNoSubfolder.java | 33 -- .../AsyncUnbindDeviceFromGateway.java | 29 +- .../SyncUnbindDeviceFromGateway.java | 24 +- .../v1/updatedevice/AsyncUpdateDevice.java | 28 + .../iot/v1/updatedevice/SyncUpdateDevice.java | 26 + .../clearblade/cloud/iot/v1/AsyncClient.java | 493 ++++++++++++++++++ .../cloud/iot/v1/ClearBladeDeviceManager.java | 318 +++++++++++ .../iot/v1/ClearBladeRegistryManager.java | 253 +++++++++ .../iot/v1/DeviceManagerAsyncClient.java | 129 +++++ .../cloud/iot/v1/DeviceManagerClient.java | 275 +++------- .../clearblade/cloud/iot/v1/SyncClient.java | 284 ++++++++++ .../BindDeviceToGatewayRequest.java | 28 +- .../v1/createdevice/CreateDeviceRequest.java | 98 +--- .../v1/createdevice/CreateDeviceResponse.java | 28 - .../v1/deletedevice/DeleteDeviceRequest.java | 33 +- .../v1/deviceslist/DevicesListRequest.java | 92 +++- .../v1/deviceslist/DevicesListResponse.java | 109 ++-- ...uest.java => ListDeviceStatesRequest.java} | 27 +- .../ListDeviceStatesResponse.java | 80 +++ .../iot/v1/getdevice/GetDeviceRequest.java | 37 +- .../GetDeviceRegistryRequest.java | 42 ++ .../GetDeviceRegistryResponse.java} | 59 +-- .../ModifyCloudToDeviceConfigRequest.java | 83 +-- .../ModifyCloudToDeviceConfigResponse.java | 27 - .../SendCommandToDeviceRequest.java | 61 ++- .../iot/v1/test/DeviceManagerClientTest.java | 123 ----- .../UnbindDeviceFromGatewayRequest.java | 28 +- .../UpdateDeviceRequest.java} | 62 ++- .../UpdateDeviceResponse.java} | 24 +- .../cloud/iot/v1/utils/AuthParams.java | 152 +++++- .../cloud/iot/v1/utils/Constants.java | 6 +- .../clearblade/cloud/iot/v1/utils/Device.java | 447 ++++++++++++---- .../cloud/iot/v1/utils/DeviceConfig.java | 154 ++++++ .../cloud/iot/v1/utils/DeviceCredential.java | 74 +++ .../cloud/iot/v1/utils/DeviceName.java | 6 + .../cloud/iot/v1/utils/DeviceRegistry.java | 252 +++++++++ .../cloud/iot/v1/utils/DeviceState.java | 56 +- .../iot/v1/utils/EventNotificationConfig.java | 75 +++ .../cloud/iot/v1/utils/FieldMask.java | 52 ++ .../cloud/iot/v1/utils/GatewayAuthMethod.java | 63 +++ .../cloud/iot/v1/utils/GatewayConfig.java | 109 ++++ .../iot/v1/utils/GatewayListOptions.java | 84 +++ .../cloud/iot/v1/utils/GatewayType.java | 60 +++ .../cloud/iot/v1/utils/HttpConfig.java | 60 +++ .../cloud/iot/v1/utils/HttpState.java | 57 ++ .../cloud/iot/v1/utils/LogLevel.java | 58 +++ .../cloud/iot/v1/utils/MqttConfig.java | 58 +++ .../cloud/iot/v1/utils/MqttState.java | 57 ++ .../iot/v1/utils/PublicKeyCertificate.java | 32 ++ .../v1/utils/PublicKeyCertificateFormat.java | 49 ++ .../iot/v1/utils/PublicKeyCredential.java | 67 +++ .../cloud/iot/v1/utils/PublicKeyFormat.java | 58 +++ .../iot/v1/utils/RegistryCredential.java | 58 +++ .../cloud/iot/v1/utils/RegistryName.java | 4 + .../iot/v1/utils/StateNotificationConfig.java | 57 ++ .../clearblade/cloud/iot/v1/utils/Status.java | 117 +++++ .../iot/v1/utils/X509CertificateDetails.java | 57 ++ 79 files changed, 4607 insertions(+), 1343 deletions(-) delete mode 100644 clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/devicepatch/AsyncDevicePatch.java delete mode 100644 clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/devicepatch/SyncDevicePatch.java create mode 100644 clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/getdeviceregistry/AsyncGetDeviceRegistry.java create mode 100644 clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/getdeviceregistry/SyncGetDeviceRegistry.java delete mode 100644 clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/sendcommandtodevice/SyncSendCommandToDeviceDataEmpty.java delete mode 100644 clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/sendcommandtodevice/SyncSendCommandToDeviceDeviceName.java delete mode 100644 clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/sendcommandtodevice/SyncSendCommandToDeviceNoSubfolder.java create mode 100644 clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/updatedevice/AsyncUpdateDevice.java create mode 100644 clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/updatedevice/SyncUpdateDevice.java create mode 100644 clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/AsyncClient.java create mode 100644 clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/ClearBladeDeviceManager.java create mode 100644 clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/ClearBladeRegistryManager.java create mode 100644 clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/DeviceManagerAsyncClient.java create mode 100644 clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/SyncClient.java rename clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/devicestateslist/{DeviceStatesListRequest.java => ListDeviceStatesRequest.java} (74%) create mode 100644 clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/devicestateslist/ListDeviceStatesResponse.java create mode 100644 clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/getdeviceregistry/GetDeviceRegistryRequest.java rename clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/{devicestateslist/DeviceStatesListResponse.java => getdeviceregistry/GetDeviceRegistryResponse.java} (56%) delete mode 100644 clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/test/DeviceManagerClientTest.java rename clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/{devicepatch/DevicePatchRequest.java => updatedevice/UpdateDeviceRequest.java} (71%) rename clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/{devicepatch/DevicePatchResponse.java => updatedevice/UpdateDeviceResponse.java} (77%) create mode 100644 clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/utils/DeviceConfig.java create mode 100644 clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/utils/DeviceCredential.java create mode 100644 clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/utils/DeviceRegistry.java create mode 100644 clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/utils/EventNotificationConfig.java create mode 100644 clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/utils/FieldMask.java create mode 100644 clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/utils/GatewayAuthMethod.java create mode 100644 clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/utils/GatewayConfig.java create mode 100644 clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/utils/GatewayListOptions.java create mode 100644 clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/utils/GatewayType.java create mode 100644 clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/utils/HttpConfig.java create mode 100644 clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/utils/HttpState.java create mode 100644 clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/utils/LogLevel.java create mode 100644 clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/utils/MqttConfig.java create mode 100644 clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/utils/MqttState.java create mode 100644 clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/utils/PublicKeyCertificate.java create mode 100644 clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/utils/PublicKeyCertificateFormat.java create mode 100644 clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/utils/PublicKeyCredential.java create mode 100644 clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/utils/PublicKeyFormat.java create mode 100644 clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/utils/RegistryCredential.java create mode 100644 clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/utils/StateNotificationConfig.java create mode 100644 clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/utils/Status.java create mode 100644 clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/utils/X509CertificateDetails.java diff --git a/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/binddevicetogateway/AsyncBindDeviceToGateway.java b/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/binddevicetogateway/AsyncBindDeviceToGateway.java index 80fc8669..ba7fe7d4 100644 --- a/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/binddevicetogateway/AsyncBindDeviceToGateway.java +++ b/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/binddevicetogateway/AsyncBindDeviceToGateway.java @@ -1,9 +1,9 @@ package com.clearblade.cloud.iot.v1.binddevicetogateway; -import java.util.logging.Level; import java.util.logging.Logger; -import com.clearblade.cloud.iot.v1.DeviceManagerClient; +import com.clearblade.cloud.iot.v1.DeviceManagerAsyncClient; +import com.clearblade.cloud.iot.v1.utils.RegistryName; public class AsyncBindDeviceToGateway { static Logger log = Logger.getLogger(AsyncBindDeviceToGateway.class.getName()); @@ -13,24 +13,12 @@ public static void main(String[] args) { } public static void asyncBindDeviceToGateway() { - DeviceManagerClient deviceManagerClient = new DeviceManagerClient(); - String parent = "Rashmi_Device_Test"; - String gateway = "Rashmi_Gateway_Test"; - String device = "Rashmi_Device_Test"; - - BindDeviceToGatewayRequest request = BindDeviceToGatewayRequest.Builder.newBuilder().setParent(parent).setGateway(gateway).setDevice(device).build(); - BindDeviceToGatewayResponse response = deviceManagerClient.bindDeviceToGateway(request); - - if (response != null) { - response.processRequest(request); - if(response.getHttpStatusResponse().equals("OK")) { - log.log(Level.INFO, "AsyncBindDeviceToGateway Method worked successfully :: {0}",response.getHttpStatusResponse()); - }else { - log.log(Level.SEVERE, "AsyncBindDeviceToGateway Method execution failed :: {0}",response.getHttpStatusResponse()); - } - }else { - log.log(Level.SEVERE, "AsyncBindDeviceToGateway Method execution failed"); - } + DeviceManagerAsyncClient deviceManagerAsyncClient = new DeviceManagerAsyncClient(); + BindDeviceToGatewayRequest request = BindDeviceToGatewayRequest.Builder.newBuilder() + .setParent(RegistryName.of("ingressdevelopmentenv", "us-central1", "Rashmi_Registry_Test").toString()) + .setGateway("Rashmi_Gateway_Test").setDevice("myOldDevice").build(); + BindDeviceToGatewayResponse response = deviceManagerAsyncClient.bindDeviceToGateway(request); + System.out.println(response.toString()); } } diff --git a/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/binddevicetogateway/SyncBindDeviceToGateway.java b/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/binddevicetogateway/SyncBindDeviceToGateway.java index ff183f21..a99ce00d 100644 --- a/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/binddevicetogateway/SyncBindDeviceToGateway.java +++ b/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/binddevicetogateway/SyncBindDeviceToGateway.java @@ -1,9 +1,9 @@ package com.clearblade.cloud.iot.v1.binddevicetogateway; -import java.util.logging.Level; import java.util.logging.Logger; import com.clearblade.cloud.iot.v1.DeviceManagerClient; +import com.clearblade.cloud.iot.v1.utils.RegistryName; public class SyncBindDeviceToGateway { static Logger log = Logger.getLogger(SyncBindDeviceToGateway.class.getName()); @@ -14,24 +14,10 @@ public static void main(String[] args) { public static void syncBindDeviceToGateway() { DeviceManagerClient deviceManagerClient = new DeviceManagerClient(); - String parent = "Rashmi_Device_Test"; - String gateway = "Rashmi_Gateway_Test"; - String device = "Rashmi_Device_Test"; - - BindDeviceToGatewayRequest request = BindDeviceToGatewayRequest.Builder.newBuilder().setParent(parent) - .setGateway(gateway).setDevice(device).build(); + BindDeviceToGatewayRequest request = BindDeviceToGatewayRequest.Builder.newBuilder() + .setParent(RegistryName.of("ingressdevelopmentenv", "us-central1", "Rashmi_Registry_Test").toString()) + .setGateway("Rashmi_Gateway_Test").setDevice("Rashmi_Device_Test").build(); BindDeviceToGatewayResponse response = deviceManagerClient.bindDeviceToGateway(request); - - if (response != null) { - response.processRequest(request); - if (response.getHttpStatusResponse().equals("OK")) { - log.log(Level.INFO, "SyncBindDeviceToGateway Method worked successfully :: {0}", response.getHttpStatusResponse()); - } else { - log.log(Level.SEVERE, "SyncBindDeviceToGateway Method execution failed :: {0}", response.getHttpStatusResponse()); - } - } else { - log.log(Level.SEVERE, "SyncBindDeviceToGateway Method execution failed"); - } - + System.out.println(response.toString()); } } diff --git a/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/createdevice/AsyncCreateDevice.java b/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/createdevice/AsyncCreateDevice.java index 82c3eefd..fafd749d 100644 --- a/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/createdevice/AsyncCreateDevice.java +++ b/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/createdevice/AsyncCreateDevice.java @@ -1,11 +1,19 @@ package com.clearblade.cloud.iot.v1.createdevice; +import java.util.ArrayList; +import java.util.HashMap; import java.util.logging.Level; import java.util.logging.Logger; +import com.clearblade.cloud.iot.v1.DeviceManagerAsyncClient; import com.clearblade.cloud.iot.v1.DeviceManagerClient; import com.clearblade.cloud.iot.v1.utils.Device; +import com.clearblade.cloud.iot.v1.utils.DeviceConfig; +import com.clearblade.cloud.iot.v1.utils.GatewayConfig; +import com.clearblade.cloud.iot.v1.utils.GatewayType; +import com.clearblade.cloud.iot.v1.utils.LogLevel; import com.clearblade.cloud.iot.v1.utils.RegistryName; +import com.clearblade.cloud.iot.v1.utils.Status; public class AsyncCreateDevice { static Logger log = Logger.getLogger(AsyncCreateDevice.class.getName()); @@ -15,22 +23,22 @@ public static void main(String[] args) { } public static void asyncCreateDevice() { - DeviceManagerClient deviceManagerClient = new DeviceManagerClient(); - String registryName = "Rashmi_Registry_Test"; - RegistryName registryNm = RegistryName.newBuilder().setRegistry(registryName).build(); - CreateDeviceRequest request = CreateDeviceRequest.Builder.newBuilder().setParent(registryNm) - .setDevice(Device.newBuilder().setId("AsyncDeviceTest2").setName("AsyncDeviceTest2").setNumId(11112).build()) - .setDeviceNumIds(new String[]{"133,134"}).setSubfolder("784").build(); - CreateDeviceResponse response = deviceManagerClient.createDevice(request); - if (response != null) { - response.processRequest(request); - if(response.getHttpStatusResponse().equals("OK")) { - log.log(Level.INFO, "AsyncCreateDevice Method worked successfully :: {0}",response.getHttpStatusResponse()); - }else { - log.log(Level.INFO, "AsyncCreateDevice Method execution failed :: {0}",response.getHttpStatusResponse()); - } - }else { - log.log(Level.SEVERE, "AsyncCreateDevice Method execution failed"); - } + DeviceManagerAsyncClient deviceManagerAsyncClient = new DeviceManagerAsyncClient(); + RegistryName parent = RegistryName.of("ingressdevelopmentenv", "us-central1", "Rashmi_Registry_Test"); + GatewayConfig gatewayCfg = new GatewayConfig(); + gatewayCfg.setGatewayType(GatewayType.NON_GATEWAY); + Device device = Device.newBuilder() + .setId("AsyncTest22").setName("AsyncTest22") + .setNumId("2315").setBlocked(false) + .setGatewayConfig(gatewayCfg) + .setLogLevel(LogLevel.ERROR) + .setCredentials(new ArrayList<>()) + .setLastErrorStatus(new Status()) + .setConfig(new DeviceConfig()) + .setMetadata(new HashMap<>()) + .build(); + CreateDeviceRequest request = CreateDeviceRequest.Builder.newBuilder().setParent(parent).setDevice(device).build(); + Device response = deviceManagerAsyncClient.createDevice(request); + System.out.println(response.toBuilder().getName()); } } diff --git a/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/createdevice/SyncCreateDevice.java b/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/createdevice/SyncCreateDevice.java index 9b40a921..f08195e2 100644 --- a/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/createdevice/SyncCreateDevice.java +++ b/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/createdevice/SyncCreateDevice.java @@ -1,11 +1,17 @@ package com.clearblade.cloud.iot.v1.createdevice; -import java.util.logging.Level; +import java.util.ArrayList; +import java.util.HashMap; import java.util.logging.Logger; import com.clearblade.cloud.iot.v1.DeviceManagerClient; import com.clearblade.cloud.iot.v1.utils.Device; +import com.clearblade.cloud.iot.v1.utils.DeviceConfig; +import com.clearblade.cloud.iot.v1.utils.GatewayConfig; +import com.clearblade.cloud.iot.v1.utils.GatewayType; +import com.clearblade.cloud.iot.v1.utils.LogLevel; import com.clearblade.cloud.iot.v1.utils.RegistryName; +import com.clearblade.cloud.iot.v1.utils.Status; public class SyncCreateDevice { static Logger log = Logger.getLogger(SyncCreateDevice.class.getName()); @@ -17,21 +23,22 @@ public static void main(String[] args) { public static void syncCreateDevice() { DeviceManagerClient deviceManagerClient = new DeviceManagerClient(); - String registryName = "Rashmi_Registry_Test"; - RegistryName registryNm = RegistryName.newBuilder().setRegistry(registryName).build(); - CreateDeviceRequest request = CreateDeviceRequest.Builder.newBuilder().setParent(registryNm) - .setDevice(Device.newBuilder().setId("SyncDeviceTest2").setName("SyncDeviceTest2").setNumId(49998).build()) - .setDeviceNumIds(new String[]{"226,556"}).setSubfolder("758").build(); - CreateDeviceResponse response = deviceManagerClient.createDevice(request); - if (response != null) { - response.processRequest(request); - if(response.getHttpStatusResponse().equals("OK")) { - log.log(Level.INFO, "SyncCreateDevice Method worked successfully :: {0}",response.getHttpStatusResponse()); - }else { - log.log(Level.INFO, "SyncCreateDevice Method execution failed :: {0}",response.getHttpStatusResponse()); - } - }else { - log.log(Level.SEVERE, "SyncCreateDevice Method execution failed"); - } + RegistryName parent = RegistryName.of("ingressdevelopmentenv", "us-central1", "Rashmi_Registry_Test"); + GatewayConfig gatewayCfg = new GatewayConfig(); + gatewayCfg.setGatewayType(GatewayType.NON_GATEWAY); + Device device = Device.newBuilder() + .setId("SyncTest22").setName("SyncTest22") + .setNumId("2314").setBlocked(false) + .setGatewayConfig(gatewayCfg) + .setLogLevel(LogLevel.DEBUG) + .setCredentials(new ArrayList<>()) + .setLastErrorStatus(new Status()) + .setConfig(new DeviceConfig()) + .setMetadata(new HashMap<>()) + .build(); + CreateDeviceRequest request = CreateDeviceRequest.Builder.newBuilder().setParent(parent).setDevice(device).build(); + Device response = deviceManagerClient.createDevice(request); + System.out.println(response.toBuilder().getName()); + } } diff --git a/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/deletedevice/AsyncDeleteDevice.java b/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/deletedevice/AsyncDeleteDevice.java index b77e52b1..36c71e19 100644 --- a/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/deletedevice/AsyncDeleteDevice.java +++ b/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/deletedevice/AsyncDeleteDevice.java @@ -1,9 +1,9 @@ package com.clearblade.cloud.iot.v1.deletedevice; -import java.util.logging.Level; import java.util.logging.Logger; -import com.clearblade.cloud.iot.v1.DeviceManagerClient; +import com.clearblade.cloud.iot.v1.DeviceManagerAsyncClient; +import com.clearblade.cloud.iot.v1.utils.DeviceName; public class AsyncDeleteDevice { static Logger log = Logger.getLogger(AsyncDeleteDevice.class.getName()); @@ -13,20 +13,10 @@ public static void main(String[] args) { } public static void asyncDeleteDevice() { - DeviceManagerClient deviceManagerClient = new DeviceManagerClient(); - String deviceName = "AsyncDeviceTest2"; - DeleteDeviceRequest request = DeleteDeviceRequest.Builder.newBuilder().setDeviceName(deviceName).build(); - DeleteDeviceResponse response = deviceManagerClient.deleteDevice(request); - if (response != null) { - response.processRequest(request); - if (response.getHttpStatusResponse().equals("OK")) { - log.log(Level.INFO, "AsyncDeleteDevice Method worked successfully :: {0} ",response.getHttpStatusResponse()); - } else { - log.log(Level.SEVERE, "AsyncDeleteDevice Method execution failed :: {0}",response.getHttpStatusResponse()); - } - } else { - log.log(Level.SEVERE, "AsyncDeleteDevice Method execution failed"); - } + DeviceManagerAsyncClient deviceManagerAsyncClient = new DeviceManagerAsyncClient(); + DeviceName deviceName = DeviceName.of("ingressdevelopmentenv", "us-central1", "Rashmi_Registry_Test", "AsyncTest22"); + DeleteDeviceRequest request = DeleteDeviceRequest.Builder.newBuilder().setName(deviceName).build(); + deviceManagerAsyncClient.deleteDevice(request); } } diff --git a/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/deletedevice/SyncDeleteDevice.java b/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/deletedevice/SyncDeleteDevice.java index 4796600f..b744139d 100644 --- a/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/deletedevice/SyncDeleteDevice.java +++ b/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/deletedevice/SyncDeleteDevice.java @@ -1,9 +1,9 @@ package com.clearblade.cloud.iot.v1.deletedevice; -import java.util.logging.Level; import java.util.logging.Logger; import com.clearblade.cloud.iot.v1.DeviceManagerClient; +import com.clearblade.cloud.iot.v1.utils.DeviceName; public class SyncDeleteDevice { static Logger log = Logger.getLogger(SyncDeleteDevice.class.getName()); @@ -14,19 +14,9 @@ public static void main(String[] args) { public static void syncDeleteDevice() { DeviceManagerClient deviceManagerClient = new DeviceManagerClient(); - String deviceName = "SyncDeviceTest2"; - DeleteDeviceRequest request = DeleteDeviceRequest.Builder.newBuilder().setDeviceName(deviceName).build(); - DeleteDeviceResponse response = deviceManagerClient.deleteDevice(request); - if (response != null) { - response.processRequest(request); - if (response.getHttpStatusResponse().equals("OK")) { - log.log(Level.INFO, "SyncDeleteDevice Method worked successfully :: {0}",response.getHttpStatusResponse()); - } else { - log.log(Level.SEVERE, "SyncDeleteDevice Method execution failed :: {0}", response.getHttpStatusResponse()); - } - } else { - log.log(Level.SEVERE, "SyncDeleteDevice Method execution failed"); - } + DeviceName deviceName = DeviceName.of("ingressdevelopmentenv", "us-central1", "Rashmi_Registry_Test", "SyncTest22"); + DeleteDeviceRequest request = DeleteDeviceRequest.Builder.newBuilder().setName(deviceName).build(); + deviceManagerClient.deleteDevice(request); } } diff --git a/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/devicepatch/AsyncDevicePatch.java b/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/devicepatch/AsyncDevicePatch.java deleted file mode 100644 index f184321b..00000000 --- a/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/devicepatch/AsyncDevicePatch.java +++ /dev/null @@ -1,38 +0,0 @@ -package com.clearblade.cloud.iot.v1.devicepatch; - -import java.util.logging.Level; -import java.util.logging.Logger; - -import com.clearblade.cloud.iot.v1.DeviceManagerClient; -import com.clearblade.cloud.iot.v1.utils.Device; - -public class AsyncDevicePatch { - static Logger log = Logger.getLogger(AsyncDevicePatch.class.getName()); - - public static void main(String[] args) { - asyncDevicePatch(); - } - - public static void asyncDevicePatch() { - DeviceManagerClient deviceManagerClient = new DeviceManagerClient(); - String name = "Rashmi_Device_Test"; - - Device device = Device.patch(name,name,"NONE",true); - String updateMask = "logLevel"; - - DevicePatchRequest request = DevicePatchRequest.Builder.newBuilder().setName(name).setDevice(device).setUpdateMask(updateMask).build(); - DevicePatchResponse response = deviceManagerClient.devicePatch(request); - - if (response != null) { - response.processRequest(request); - if(response.getHttpStatusResponse().equals("OK")) { - log.log(Level.INFO, "AsyncDevicePatch Method worked successfully :: {0}",response.getHttpStatusResponse()); - }else { - log.log(Level.SEVERE, "AsyncDevicePatch Method execution failed :: {0}",response.getHttpStatusResponse()); - } - }else { - log.log(Level.SEVERE, "AsyncDevicePatch Method execution failed"); - } - - } -} diff --git a/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/devicepatch/SyncDevicePatch.java b/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/devicepatch/SyncDevicePatch.java deleted file mode 100644 index e618caf5..00000000 --- a/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/devicepatch/SyncDevicePatch.java +++ /dev/null @@ -1,38 +0,0 @@ -package com.clearblade.cloud.iot.v1.devicepatch; - -import java.util.logging.Level; -import java.util.logging.Logger; - -import com.clearblade.cloud.iot.v1.DeviceManagerClient; -import com.clearblade.cloud.iot.v1.utils.Device; - -public class SyncDevicePatch { - static Logger log = Logger.getLogger(SyncDevicePatch.class.getName()); - - public static void main(String[] args) { - syncDevicePatch(); - } - - public static void syncDevicePatch() { - DeviceManagerClient deviceManagerClient = new DeviceManagerClient(); - String name = "Rashmi_Device_Test"; - - Device device = Device.patch(name,name,"ERROR",true); - String updateMask = "logLevel"; - - DevicePatchRequest request = DevicePatchRequest.Builder.newBuilder().setName(name).setDevice(device).setUpdateMask(updateMask).build(); - DevicePatchResponse response = deviceManagerClient.devicePatch(request); - - if (response != null) { - response.processRequest(request); - if(response.getHttpStatusResponse().equals("OK")) { - log.log(Level.INFO, "SyncDevicePatch Method worked successfully :: {0}",response.getHttpStatusResponse()); - }else { - log.log(Level.SEVERE, "SyncDevicePatch Method execution failed :: {0}",response.getHttpStatusResponse()); - } - }else { - log.log(Level.SEVERE, "SyncDevicePatch Method execution failed"); - } - - } -} diff --git a/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/deviceslist/AsyncDevicesList.java b/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/deviceslist/AsyncDevicesList.java index 779df6a0..79b079db 100644 --- a/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/deviceslist/AsyncDevicesList.java +++ b/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/deviceslist/AsyncDevicesList.java @@ -1,9 +1,11 @@ package com.clearblade.cloud.iot.v1.deviceslist; -import java.util.logging.Level; import java.util.logging.Logger; -import com.clearblade.cloud.iot.v1.DeviceManagerClient; +import com.clearblade.cloud.iot.v1.DeviceManagerAsyncClient; +import com.clearblade.cloud.iot.v1.utils.Device; +import com.clearblade.cloud.iot.v1.utils.GatewayListOptions; +import com.clearblade.cloud.iot.v1.utils.GatewayType; import com.clearblade.cloud.iot.v1.utils.RegistryName; public class AsyncDevicesList { @@ -15,20 +17,18 @@ public static void main(String[] args){ } public static void asyncDevicesList(){ - DeviceManagerClient deviceManagerClient = new DeviceManagerClient(); - RegistryName parent = RegistryName.of("ingressdevelopmentenv","us-central1","Rashmi_Registry_Test"); - DevicesListRequest request = DevicesListRequest.Builder.newBuilder().setParent(parent).build(); - DevicesListResponse response = deviceManagerClient.devicesList(request); - if (response != null) { - response.processRequest(request); - if (response.getHttpStatusResponse().equals("OK")) { - log.log(Level.INFO, "AsyncDevicesList Method worked successfully :: {0}",response.getHttpStatusResponse()); - } else { - log.log(Level.SEVERE, "AsyncDevicesList Method execution failed :: {0}",response.getHttpStatusResponse()); - } - } else { - log.log(Level.SEVERE, "AsyncDevicesList Method execution failed"); - } + DeviceManagerAsyncClient deviceManagerAsyncClient = new DeviceManagerAsyncClient(); + RegistryName parent = RegistryName.of("ingressdevelopmentenv", "us-central1", "MandarTest1"); + DevicesListRequest request = DevicesListRequest.Builder.newBuilder().setParent(parent.toString()) + .setGatewayListOptions(GatewayListOptions.newBuilder().setGatewayType(GatewayType.NON_GATEWAY).build()) + .setPageSize(2) + .build(); + DevicesListResponse response = deviceManagerAsyncClient.listDevices(request); + + for (Device element : response.getDevicesList()) { + System.out.println(element.toBuilder().getName()); + } + System.out.println(response.getNextPageToken()); } } diff --git a/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/deviceslist/SyncDevicesList.java b/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/deviceslist/SyncDevicesList.java index d95b1041..7b1f0b45 100644 --- a/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/deviceslist/SyncDevicesList.java +++ b/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/deviceslist/SyncDevicesList.java @@ -1,34 +1,34 @@ package com.clearblade.cloud.iot.v1.deviceslist; -import java.util.logging.Level; import java.util.logging.Logger; import com.clearblade.cloud.iot.v1.DeviceManagerClient; +import com.clearblade.cloud.iot.v1.utils.Device; +import com.clearblade.cloud.iot.v1.utils.GatewayListOptions; +import com.clearblade.cloud.iot.v1.utils.GatewayType; import com.clearblade.cloud.iot.v1.utils.RegistryName; public class SyncDevicesList { static Logger log = Logger.getLogger(SyncDevicesList.class.getName()); - public static void main(String[] args){ + public static void main(String[] args) { syncDevicesList(); } - public static void syncDevicesList(){ + public static void syncDevicesList() { DeviceManagerClient deviceManagerClient = new DeviceManagerClient(); - RegistryName parent = RegistryName.of("ingressdevelopmentenv","us-central1","Rashmi_Registry_Test"); - DevicesListRequest request = DevicesListRequest.Builder.newBuilder().setParent(parent).build(); - DevicesListResponse response = deviceManagerClient.devicesList(request); - if (response != null) { - response.processRequest(request); - if (response.getHttpStatusResponse().equals("OK")) { - log.log(Level.INFO, "SyncDevicesList Method worked successfully :: {0}",response.getHttpStatusResponse()); - } else { - log.log(Level.SEVERE, "SyncDevicesList Method execution failed :: {0}", response.getHttpStatusResponse()); - } - } else { - log.log(Level.SEVERE, "SyncDevicesList Method execution failed"); + RegistryName parent = RegistryName.of("ingressdevelopmentenv", "us-central1", "MandarTest1"); + DevicesListRequest request = DevicesListRequest.Builder.newBuilder().setParent(parent.toString()) + .setGatewayListOptions(GatewayListOptions.newBuilder().setGatewayType(GatewayType.NON_GATEWAY).build()) + .setPageSize(2) + .build(); + DevicesListResponse response = deviceManagerClient.listDevices(request); + + for (Device element : response.getDevicesList()) { + System.out.println(element.toBuilder().getName()); + } - + System.out.println(response.getNextPageToken()); } } diff --git a/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/devicestateslist/AsyncDeviceStatesList.java b/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/devicestateslist/AsyncDeviceStatesList.java index 5b827d02..a72e31cb 100644 --- a/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/devicestateslist/AsyncDeviceStatesList.java +++ b/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/devicestateslist/AsyncDeviceStatesList.java @@ -3,7 +3,10 @@ import java.util.logging.Level; import java.util.logging.Logger; +import com.clearblade.cloud.iot.v1.DeviceManagerAsyncClient; import com.clearblade.cloud.iot.v1.DeviceManagerClient; +import com.clearblade.cloud.iot.v1.utils.DeviceName; +import com.clearblade.cloud.iot.v1.utils.DeviceState; public class AsyncDeviceStatesList { @@ -14,20 +17,15 @@ public static void main(String[] args) { } public static void asyncDeviceStatesList() { - String name = "Rashmi_Device_Test"; - DeviceManagerClient deviceManagerClient = new DeviceManagerClient(); - - DeviceStatesListRequest request = DeviceStatesListRequest.Builder.newBuilder().setName(name).setNumStates(1643330779).build(); - DeviceStatesListResponse response = deviceManagerClient.deviceStatesList(request); - if (response != null) { - response.processRequest(request); - if (response.getHttpStatusResponse().equals("OK")) { - log.log(Level.INFO, "AsyncDeviceStatesList Method worked successfully :: {0}",response.getHttpStatusResponse()); - } else { - log.log(Level.SEVERE, "AsyncDeviceStatesList Method execution failed :: {0} ",response.getHttpStatusResponse()); - } - } else { - log.log(Level.SEVERE, "AsyncDeviceStatesList Method execution failed"); + DeviceManagerAsyncClient deviceManagerClient = new DeviceManagerAsyncClient(); + + ListDeviceStatesRequest request = ListDeviceStatesRequest.Builder.newBuilder().setName(DeviceName + .of("ingressdevelopmentenv", "us-central1", "Rashmi_Registry_Test", "Rashmi_Device_Test") + .toString()).setNumStates(1643330779).build(); + ListDeviceStatesResponse response = deviceManagerClient.listDeviceStates(request); + + for (DeviceState element : response.getDeviceStatesList()) { + System.out.println(element.toString()); } } diff --git a/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/devicestateslist/SyncDeviceStatesList.java b/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/devicestateslist/SyncDeviceStatesList.java index 737e835c..36697838 100644 --- a/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/devicestateslist/SyncDeviceStatesList.java +++ b/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/devicestateslist/SyncDeviceStatesList.java @@ -4,6 +4,8 @@ import java.util.logging.Logger; import com.clearblade.cloud.iot.v1.DeviceManagerClient; +import com.clearblade.cloud.iot.v1.utils.DeviceName; +import com.clearblade.cloud.iot.v1.utils.DeviceState; public class SyncDeviceStatesList { static Logger log = Logger.getLogger(SyncDeviceStatesList.class.getName()); @@ -13,20 +15,15 @@ public static void main(String[] args) { } public static void syncDeviceStatesList() { - String name = "Rashmi_Device_Test"; DeviceManagerClient deviceManagerClient = new DeviceManagerClient(); - DeviceStatesListRequest request = DeviceStatesListRequest.Builder.newBuilder().setName(name).setNumStates(1643330779).build(); - DeviceStatesListResponse response = deviceManagerClient.deviceStatesList(request); - if (response != null) { - response.processRequest(request); - if (response.getHttpStatusResponse().equals("OK")) { - log.log(Level.INFO, "SyncDeviceStatesList Method worked successfully ::{0} ",response.getHttpStatusResponse()); - } else { - log.log(Level.SEVERE, "SyncDeviceStatesList Method execution failed :: {0}", response.getHttpStatusResponse()); - } - } else { - log.log(Level.SEVERE, "SyncDeviceStatesList Method execution failed"); + ListDeviceStatesRequest request = ListDeviceStatesRequest.Builder.newBuilder().setName(DeviceName + .of("ingressdevelopmentenv", "us-central1", "Rashmi_Registry_Test", "Rashmi_Device_Test") + .toString()).setNumStates(1643330779).build(); + ListDeviceStatesResponse response = deviceManagerClient.listDeviceStates(request); + + for (DeviceState element : response.getDeviceStatesList()) { + System.out.println(element.toString()); } } diff --git a/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/getdevice/AsyncGetDevice.java b/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/getdevice/AsyncGetDevice.java index 796b9d19..e757b4d4 100644 --- a/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/getdevice/AsyncGetDevice.java +++ b/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/getdevice/AsyncGetDevice.java @@ -1,9 +1,11 @@ package com.clearblade.cloud.iot.v1.getdevice; -import java.util.logging.Level; import java.util.logging.Logger; -import com.clearblade.cloud.iot.v1.DeviceManagerClient; +import com.clearblade.cloud.iot.v1.DeviceManagerAsyncClient; +import com.clearblade.cloud.iot.v1.utils.Device; +import com.clearblade.cloud.iot.v1.utils.DeviceName; +import com.clearblade.cloud.iot.v1.utils.FieldMask; public class AsyncGetDevice { static Logger log = Logger.getLogger(AsyncGetDevice.class.getName()); @@ -13,21 +15,11 @@ public static void main(String[] args) { } public static void asyncGetDevice() { - String msg = ""; - DeviceManagerClient deviceManagerClient = new DeviceManagerClient(); - String deviceName = "myOldDevice"; - GetDeviceRequest request = GetDeviceRequest.Builder.newBuilder().setDeviceName(deviceName).build(); - GetDeviceResponse response = deviceManagerClient.getDevice(request); - if (response != null) { - response.processRequest(request); - if (response.getHttpStatusResponse().equals("OK")) { - log.log(Level.INFO, "AsyncGetDevice Method worked successfully :: {0}",response.getHttpStatusResponse()); - } else { - log.log(Level.SEVERE, "AsyncGetDevice Method execution failed :: {0}",response.getHttpStatusResponse()); - } - } else { - log.log(Level.SEVERE, "AsyncGetDevice Method execution failed"); - } + DeviceManagerAsyncClient deviceManagerAsyncClient = new DeviceManagerAsyncClient(); + DeviceName name = DeviceName.of("ingressdevelopmentenv", "us-central1", "Rashmi_Registry_Test", "Rashmi_Device_Test"); + GetDeviceRequest request = GetDeviceRequest.Builder.newBuilder().setName(name).setFieldMask(FieldMask.newBuilder().build()).build(); + Device response = deviceManagerAsyncClient.getDevice(request); + System.out.println(response.toBuilder().getName()); } } diff --git a/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/getdevice/SyncGetDevice.java b/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/getdevice/SyncGetDevice.java index 94aaedb8..aa86d115 100644 --- a/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/getdevice/SyncGetDevice.java +++ b/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/getdevice/SyncGetDevice.java @@ -1,9 +1,11 @@ package com.clearblade.cloud.iot.v1.getdevice; -import java.util.logging.Level; import java.util.logging.Logger; import com.clearblade.cloud.iot.v1.DeviceManagerClient; +import com.clearblade.cloud.iot.v1.utils.Device; +import com.clearblade.cloud.iot.v1.utils.DeviceName; +import com.clearblade.cloud.iot.v1.utils.FieldMask; public class SyncGetDevice { static Logger log = Logger.getLogger(SyncGetDevice.class.getName()); @@ -14,19 +16,10 @@ public static void main(String[] args) { public static void syncGetDevice() { DeviceManagerClient deviceManagerClient = new DeviceManagerClient(); - String deviceName = "Rashmi_Device_Test"; - GetDeviceRequest request = GetDeviceRequest.Builder.newBuilder().setDeviceName(deviceName).build(); - GetDeviceResponse response = deviceManagerClient.getDevice(request); - if (response != null) { - response.processRequest(request); - if (response.getHttpStatusResponse().equals("OK")) { - log.log(Level.INFO, "SyncGetDevice Method worked successfully :: {0}",response.getHttpStatusResponse()); - } else { - log.log(Level.SEVERE, "SyncGetDevice Method execution failed :: {0}",response.getHttpStatusResponse()); - } - } else { - log.log(Level.SEVERE, "SyncGetDevice Method execution failed"); - } + DeviceName name = DeviceName.of("ingressdevelopmentenv", "us-central1", "Rashmi_Registry_Test", "Rashmi_Device_Test"); + GetDeviceRequest request = GetDeviceRequest.Builder.newBuilder().setName(name).setFieldMask(FieldMask.newBuilder().build()).build(); + Device response = deviceManagerClient.getDevice(request); + System.out.println(response.toBuilder().getName()); } diff --git a/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/getdeviceregistry/AsyncGetDeviceRegistry.java b/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/getdeviceregistry/AsyncGetDeviceRegistry.java new file mode 100644 index 00000000..f14ba310 --- /dev/null +++ b/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/getdeviceregistry/AsyncGetDeviceRegistry.java @@ -0,0 +1,25 @@ +package com.clearblade.cloud.iot.v1.getdeviceregistry; + +import java.util.logging.Logger; + +import com.clearblade.cloud.iot.v1.DeviceManagerClient; +import com.clearblade.cloud.iot.v1.utils.DeviceRegistry; +import com.clearblade.cloud.iot.v1.utils.RegistryName; + +public class AsyncGetDeviceRegistry { + static Logger log = Logger.getLogger(AsyncGetDeviceRegistry.class.getName()); + + public static void main(String[] args) { + asyncGetDeviceRegistry(); + } + + public static void asyncGetDeviceRegistry() { + DeviceManagerClient deviceManagerClient = new DeviceManagerClient(); + GetDeviceRegistryRequest request = GetDeviceRegistryRequest.Builder.newBuilder() + .setName(RegistryName.of("ingressdevelopmentenv", "us-central1", "Rashmi_Registry_Test").getRegistryFullName()) + .build(); + DeviceRegistry response = deviceManagerClient.getDeviceRegistry(request); + System.out.println(response.toString()); + } + +} diff --git a/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/getdeviceregistry/SyncGetDeviceRegistry.java b/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/getdeviceregistry/SyncGetDeviceRegistry.java new file mode 100644 index 00000000..8ba5b8a3 --- /dev/null +++ b/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/getdeviceregistry/SyncGetDeviceRegistry.java @@ -0,0 +1,26 @@ +package com.clearblade.cloud.iot.v1.getdeviceregistry; + +import java.util.logging.Logger; + +import com.clearblade.cloud.iot.v1.DeviceManagerAsyncClient; +import com.clearblade.cloud.iot.v1.DeviceManagerClient; +import com.clearblade.cloud.iot.v1.utils.DeviceRegistry; +import com.clearblade.cloud.iot.v1.utils.RegistryName; + +public class SyncGetDeviceRegistry { + static Logger log = Logger.getLogger(SyncGetDeviceRegistry.class.getName()); + + public static void main(String[] args) { + syncGetDeviceRegistry(); + } + + public static void syncGetDeviceRegistry() { + DeviceManagerAsyncClient deviceManagerAsyncClient = new DeviceManagerAsyncClient(); + GetDeviceRegistryRequest request = GetDeviceRegistryRequest.Builder.newBuilder() + .setName(RegistryName.of("ingressdevelopmentenv", "us-central1", "Rashmi_Registry_Test").getRegistryFullName()) + .build(); + DeviceRegistry response = deviceManagerAsyncClient.getDeviceRegistry(request); + System.out.println(response.toString()); + } + +} diff --git a/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/modifycloudtodeviceconfig/AsyncModifyCloudToDeviceConfig.java b/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/modifycloudtodeviceconfig/AsyncModifyCloudToDeviceConfig.java index dc453f58..8647322e 100644 --- a/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/modifycloudtodeviceconfig/AsyncModifyCloudToDeviceConfig.java +++ b/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/modifycloudtodeviceconfig/AsyncModifyCloudToDeviceConfig.java @@ -3,9 +3,12 @@ import java.util.logging.Level; import java.util.logging.Logger; +import com.clearblade.cloud.iot.v1.DeviceManagerAsyncClient; import com.clearblade.cloud.iot.v1.DeviceManagerClient; import com.clearblade.cloud.iot.v1.utils.ByteString; import com.clearblade.cloud.iot.v1.utils.Device; +import com.clearblade.cloud.iot.v1.utils.DeviceConfig; +import com.clearblade.cloud.iot.v1.utils.DeviceName; public class AsyncModifyCloudToDeviceConfig { static Logger log = Logger.getLogger(AsyncModifyCloudToDeviceConfig.class.getName()); @@ -15,22 +18,13 @@ public static void main(String[] args) { } public static void asyncModifyCloudToDeviceConfig() { - DeviceManagerClient deviceManagerClient = new DeviceManagerClient(); - String deviceName = "Rashmi_Device_Test"; + DeviceManagerAsyncClient deviceManagerClient = new DeviceManagerAsyncClient(); ModifyCloudToDeviceConfigRequest request = ModifyCloudToDeviceConfigRequest.Builder.newBuilder() - .setDevice(Device.newBuilder().setId(deviceName).setName(deviceName).setNumId(11111).build()) - .setVersionToUpdate("3").setBinaryDataByte(ByteString.EMPTY).build(); - ModifyCloudToDeviceConfigResponse response = deviceManagerClient.modifyCloudToDeviceConfig(request); - if (response != null) { - response.processRequest(request); - if(response.getHttpStatusResponse().equals("OK")) { - log.log(Level.INFO, "ModifyCloudToDeviceConfig Method worked successfully :: {0}",response.getHttpStatusResponse()); - }else { - log.log(Level.SEVERE, "ModifyCloudToDeviceConfig Method execution failed :: {0}",response.getHttpStatusResponse()); - } - }else { - log.log(Level.SEVERE, "ModifyCloudToDeviceConfig Method execution failed"); - } - + .setName(DeviceName + .of("ingressdevelopmentenv", "us-central1", "MandarTest1", "mandar_device") + .toString()) + .setBinaryData(new ByteString("WWV0QW5vdGhlck1lc3NhZ2U=")).setVersionToUpdate("3").build(); + DeviceConfig response = deviceManagerClient.modifyCloudToDeviceConfig(request); + System.out.println(response.toString()); } } diff --git a/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/modifycloudtodeviceconfig/SyncModifyCloudToDeviceConfig.java b/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/modifycloudtodeviceconfig/SyncModifyCloudToDeviceConfig.java index 1ba35242..fb28aa94 100644 --- a/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/modifycloudtodeviceconfig/SyncModifyCloudToDeviceConfig.java +++ b/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/modifycloudtodeviceconfig/SyncModifyCloudToDeviceConfig.java @@ -3,9 +3,13 @@ import java.util.logging.Level; import java.util.logging.Logger; +import javax.print.DocFlavor.BYTE_ARRAY; + import com.clearblade.cloud.iot.v1.DeviceManagerClient; import com.clearblade.cloud.iot.v1.utils.ByteString; import com.clearblade.cloud.iot.v1.utils.Device; +import com.clearblade.cloud.iot.v1.utils.DeviceConfig; +import com.clearblade.cloud.iot.v1.utils.DeviceName; public class SyncModifyCloudToDeviceConfig { static Logger log = Logger.getLogger(SyncModifyCloudToDeviceConfig.class.getName()); @@ -15,22 +19,14 @@ public static void main(String[] args) { } public static void syncModifyCloudToDeviceConfig() { + DeviceManagerClient deviceManagerClient = new DeviceManagerClient(); - String deviceName = "Rashmi_Device_Test"; ModifyCloudToDeviceConfigRequest request = ModifyCloudToDeviceConfigRequest.Builder.newBuilder() - .setDevice(Device.newBuilder().setId(deviceName).setName(deviceName).setNumId(11111).build()) - .setVersionToUpdate("4").setBinaryDataByte(ByteString.EMPTY).build(); - ModifyCloudToDeviceConfigResponse response = deviceManagerClient.modifyCloudToDeviceConfig(request); - if (response != null) { - response.processRequest(request); - if(response.getHttpStatusResponse().equals("OK")) { - log.log(Level.INFO, "ModifyCloudToDeviceConfig Method worked successfully ::{0}",response.getHttpStatusResponse()); - }else { - log.log(Level.SEVERE, "ModifyCloudToDeviceConfig Method execution failed :: {0}",response.getHttpStatusResponse()); - } - }else { - log.log(Level.SEVERE, "ModifyCloudToDeviceConfig Method execution failed"); - } - + .setName(DeviceName + .of("ingressdevelopmentenv", "us-central1", "MandarTest1", "mandar_device") + .toString()) + .setBinaryData(new ByteString("bmV3TWVzc2FnZUZvckNvbmZpZw==")).setVersionToUpdate("2").build(); + DeviceConfig response = deviceManagerClient.modifyCloudToDeviceConfig(request); + System.out.println(response.toString()); } } diff --git a/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/sendcommandtodevice/AsyncSendCommandToDevice.java b/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/sendcommandtodevice/AsyncSendCommandToDevice.java index 06700a47..e3ec576c 100644 --- a/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/sendcommandtodevice/AsyncSendCommandToDevice.java +++ b/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/sendcommandtodevice/AsyncSendCommandToDevice.java @@ -1,10 +1,10 @@ package com.clearblade.cloud.iot.v1.sendcommandtodevice; -import java.util.logging.Level; import java.util.logging.Logger; -import com.clearblade.cloud.iot.v1.DeviceManagerClient; +import com.clearblade.cloud.iot.v1.DeviceManagerAsyncClient; import com.clearblade.cloud.iot.v1.utils.ByteString; +import com.clearblade.cloud.iot.v1.utils.DeviceName; public class AsyncSendCommandToDevice { @@ -15,23 +15,14 @@ public static void main(String[] args) { } public static void asyncSendCommandToDevice() { - DeviceManagerClient deviceManagerClient = new DeviceManagerClient(); - String name = "AsyncDeviceTest1"; - - SendCommandToDeviceRequest request = SendCommandToDeviceRequest.Builder.newBuilder().setDeviceName(name) - .setBinaryDataByte(ByteString.EMPTY).setSubfolder("subfolder1").build(); - - SendCommandToDeviceResponse response = deviceManagerClient.sendCommandToDeviceAsync(request); - if (response != null) { - response.processRequestAsync(request); - if (response.getHttpStatusResponse().equals("OK")) { - log.log(Level.INFO, "AsyncSendCommandToDevice Method worked successfully :: {0}",response.getHttpStatusResponse()); - } else { - log.log(Level.SEVERE, "AsyncSendCommandToDevice Method execution failed :: {0}",response.getHttpStatusResponse()); - } - } else { - log.log(Level.SEVERE, "AsyncSendCommandToDevice Method execution failed"); - } + DeviceManagerAsyncClient deviceManagerAsyncClient = new DeviceManagerAsyncClient(); + SendCommandToDeviceRequest request = SendCommandToDeviceRequest.Builder.newBuilder() + .setName(DeviceName + .of("ingressdevelopmentenv", "us-central1", "MandarTest1", "mandar_device") + .toString()) + .setBinaryData(new ByteString("c2VuZEZ1bm55TWVzc2FnZVRvRGV2aWNl")).setSubfolder("testdata").build(); + SendCommandToDeviceResponse response = deviceManagerAsyncClient.sendCommandToDevice(request); + System.out.println(response.toString()); } } diff --git a/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/sendcommandtodevice/SyncSendCommandToDevice.java b/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/sendcommandtodevice/SyncSendCommandToDevice.java index 9eb7dcfe..c6646baa 100644 --- a/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/sendcommandtodevice/SyncSendCommandToDevice.java +++ b/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/sendcommandtodevice/SyncSendCommandToDevice.java @@ -1,34 +1,27 @@ package com.clearblade.cloud.iot.v1.sendcommandtodevice; - -import java.util.logging.Level; import java.util.logging.Logger; import com.clearblade.cloud.iot.v1.DeviceManagerClient; import com.clearblade.cloud.iot.v1.utils.ByteString; +import com.clearblade.cloud.iot.v1.utils.DeviceName; public class SyncSendCommandToDevice { - static Logger log = Logger.getLogger(SyncSendCommandToDevice.class.getName()); + static Logger log = Logger.getLogger(SyncSendCommandToDevice.class.getName()); + public static void main(String[] args) { syncSendCommandToDevice(); } public static void syncSendCommandToDevice() { DeviceManagerClient deviceManagerClient = new DeviceManagerClient(); - String name = "SyncDeviceTest1"; - SendCommandToDeviceRequest request = SendCommandToDeviceRequest.Builder.newBuilder().setDeviceName(name) - .setBinaryData(new ByteString("c2VuZEZ1bm55TWVzc2FnZVRvRGV2aWNl")).setSubfolder("subfolder1").build(); + SendCommandToDeviceRequest request = SendCommandToDeviceRequest.Builder.newBuilder() + .setName(DeviceName + .of("ingressdevelopmentenv", "us-central1", "MandarTest1", "mandar_device") + .toString()) + .setBinaryData(new ByteString("c2VuZEZ1bm55TWVzc2FnZVRvRGV2aWNl")).setSubfolder("testdata").build(); SendCommandToDeviceResponse response = deviceManagerClient.sendCommandToDevice(request); - if (response != null) { - response.processRequest(request); - if(response.getHttpStatusResponse().equals("OK")) { - log.log(Level.INFO, "SyncSendCommandToDevice Method worked successfully :: {0}",response.getHttpStatusResponse()); - }else { - log.log(Level.SEVERE, "SyncSendCommandToDevice Method execution failed :: {0}",response.getHttpStatusResponse()); - } - }else { - log.log(Level.SEVERE, "SyncSendCommandToDevice Method execution failed"); - } + System.out.println(response.toString()); } } diff --git a/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/sendcommandtodevice/SyncSendCommandToDeviceDataEmpty.java b/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/sendcommandtodevice/SyncSendCommandToDeviceDataEmpty.java deleted file mode 100644 index 034657b5..00000000 --- a/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/sendcommandtodevice/SyncSendCommandToDeviceDataEmpty.java +++ /dev/null @@ -1,34 +0,0 @@ -package com.clearblade.cloud.iot.v1.sendcommandtodevice; - -import java.util.logging.Level; -import java.util.logging.Logger; - -import com.clearblade.cloud.iot.v1.DeviceManagerClient; -import com.clearblade.cloud.iot.v1.utils.ByteString; - -public class SyncSendCommandToDeviceDataEmpty { - - static Logger log = Logger.getLogger(SyncSendCommandToDeviceDataEmpty.class.getName()); - public static void main(String[] args) { - syncSendCommandToDeviceDataEmpty(); - } - - public static void syncSendCommandToDeviceDataEmpty() { - DeviceManagerClient deviceManagerClient = new DeviceManagerClient(); - String name = "Rashmi_Device_Test"; - SendCommandToDeviceRequest request = SendCommandToDeviceRequest.Builder.newBuilder().setDeviceName(name) - .setBinaryDataByte(ByteString.EMPTY).setSubfolder("subfolder1").build(); - SendCommandToDeviceResponse response = deviceManagerClient.sendCommandToDevice(request); - if (response != null) { - response.processRequest(request); - if(response.getHttpStatusResponse().equals("OK")) { - log.log(Level.INFO, "SyncSendCommandToDeviceDataEmpty Method worked successfully ::{0}",response.getHttpStatusResponse()); - }else { - log.log(Level.SEVERE, "SyncSendCommandToDeviceDataEmpty Method execution failed :: {0}",response.getHttpStatusResponse()); - } - }else { - log.log(Level.SEVERE, "SyncSendCommandToDeviceDataEmpty Method execution failed"); - } - } - -} diff --git a/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/sendcommandtodevice/SyncSendCommandToDeviceDeviceName.java b/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/sendcommandtodevice/SyncSendCommandToDeviceDeviceName.java deleted file mode 100644 index b4db4d55..00000000 --- a/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/sendcommandtodevice/SyncSendCommandToDeviceDeviceName.java +++ /dev/null @@ -1,38 +0,0 @@ -package com.clearblade.cloud.iot.v1.sendcommandtodevice; - -import java.util.logging.Level; -import java.util.logging.Logger; - -import com.clearblade.cloud.iot.v1.DeviceManagerClient; -import com.clearblade.cloud.iot.v1.utils.ByteString; -import com.clearblade.cloud.iot.v1.utils.DeviceName; - -public class SyncSendCommandToDeviceDeviceName { - static Logger log = Logger.getLogger(SyncSendCommandToDeviceDeviceName.class.getName()); - public static void main(String[] args) { - syncSendCommandToDeviceDeviceName(); - } - - public static void syncSendCommandToDeviceDeviceName() { - DeviceManagerClient deviceManagerClient = new DeviceManagerClient(); - String project = "ingressdevelopmentenv"; - String location = "central1"; - String registry = "Rashmi_Registry_Test"; - String name = "Rashmi_Device_Test"; - DeviceName deviceName = DeviceName.of(project, location, registry, name); - SendCommandToDeviceRequest request = SendCommandToDeviceRequest.Builder.newBuilder().setName(deviceName) - .setBinaryData(new ByteString("c2VuZEZ1bm55TWVzc2FnZVRvRGV2aWNl")).setSubfolder("subfolder1").build(); - SendCommandToDeviceResponse response = deviceManagerClient.sendCommandToDevice(request); - if (response != null) { - response.processRequest(request); - if(response.getHttpStatusResponse().equals("OK")) { - log.log(Level.INFO, "SyncSendCommandToDeviceDeviceName Method worked successfully :: {0}",response.getHttpStatusResponse()); - }else { - log.log(Level.SEVERE, "SyncSendCommandToDeviceDeviceName Method execution failed :: {0}",response.getHttpStatusResponse()); - } - }else { - log.log(Level.SEVERE, "SyncSendCommandToDeviceDeviceName Method execution failed"); - } - } - -} diff --git a/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/sendcommandtodevice/SyncSendCommandToDeviceNoSubfolder.java b/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/sendcommandtodevice/SyncSendCommandToDeviceNoSubfolder.java deleted file mode 100644 index e1d1a014..00000000 --- a/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/sendcommandtodevice/SyncSendCommandToDeviceNoSubfolder.java +++ /dev/null @@ -1,33 +0,0 @@ -package com.clearblade.cloud.iot.v1.sendcommandtodevice; - -import java.util.logging.Level; -import java.util.logging.Logger; - -import com.clearblade.cloud.iot.v1.DeviceManagerClient; -import com.clearblade.cloud.iot.v1.utils.ByteString; - -public class SyncSendCommandToDeviceNoSubfolder { - static Logger log = Logger.getLogger(SyncSendCommandToDeviceNoSubfolder.class.getName()); - public static void main(String[] args) { - syncSendCommandToDeviceNoSubfolder(); - } - - public static void syncSendCommandToDeviceNoSubfolder() { - DeviceManagerClient deviceManagerClient = new DeviceManagerClient(); - String name = "Rashmi_Device_Test"; - SendCommandToDeviceRequest request = SendCommandToDeviceRequest.Builder.newBuilder().setDeviceName(name) - .setBinaryDataByte(ByteString.EMPTY).build(); - SendCommandToDeviceResponse response = deviceManagerClient.sendCommandToDevice(request); - if (response != null) { - response.processRequest(request); - if(response.getHttpStatusResponse().equals("OK")) { - log.log(Level.INFO, "SyncSendCommandToDeviceNoSubfolder Method worked successfully :: {0}",response.getHttpStatusResponse()); - }else { - log.log(Level.SEVERE, "SyncSendCommandToDeviceNoSubfolder Method execution failed :: {0}",response.getHttpStatusResponse()); - } - }else { - log.log(Level.SEVERE, "SyncSendCommandToDeviceNoSubfolder Method execution failed"); - } - } - -} diff --git a/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/unbinddevicefromgateway/AsyncUnbindDeviceFromGateway.java b/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/unbinddevicefromgateway/AsyncUnbindDeviceFromGateway.java index 69204e1e..80717888 100644 --- a/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/unbinddevicefromgateway/AsyncUnbindDeviceFromGateway.java +++ b/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/unbinddevicefromgateway/AsyncUnbindDeviceFromGateway.java @@ -1,9 +1,9 @@ package com.clearblade.cloud.iot.v1.unbinddevicefromgateway; -import java.util.logging.Level; import java.util.logging.Logger; -import com.clearblade.cloud.iot.v1.DeviceManagerClient; +import com.clearblade.cloud.iot.v1.DeviceManagerAsyncClient; +import com.clearblade.cloud.iot.v1.utils.RegistryName; public class AsyncUnbindDeviceFromGateway { static Logger log = Logger.getLogger(AsyncUnbindDeviceFromGateway.class.getName()); @@ -13,24 +13,13 @@ public static void main(String[] args) { } public static void asyncUnbindDeviceFromGateway() { - DeviceManagerClient deviceManagerClient = new DeviceManagerClient(); - String parent = "Rashmi_Device_Test"; - String gateway = "Rashmi_Gateway_Test"; - String device = "Rashmi_Device_Test"; - - UnbindDeviceFromGatewayRequest request = UnbindDeviceFromGatewayRequest.Builder.newBuilder().setParent(parent).setGateway(gateway).setDevice(device).build(); - UnbindDeviceFromGatewayResponse response = deviceManagerClient.unbindDeviceFromGateway(request); - - if (response != null) { - response.processRequest(request); - if(response.getHttpStatusResponse().equals("OK")) { - log.log(Level.INFO, "AsyncUnbindDeviceFromGateway Method worked successfully :: {0}",response.getHttpStatusResponse()); - }else { - log.log(Level.SEVERE, "AsyncUnbindDeviceFromGateway Method execution failed :: {0}",response.getHttpStatusResponse()); - } - }else { - log.log(Level.SEVERE, "AsyncUnbindDeviceFromGateway Method execution failed"); - } + DeviceManagerAsyncClient deviceManagerAsyncClient = new DeviceManagerAsyncClient(); + UnbindDeviceFromGatewayRequest request = UnbindDeviceFromGatewayRequest.Builder.newBuilder() + .setParent(RegistryName.of("ingressdevelopmentenv", "us-central1", "Rashmi_Registry_Test").toString()) + .setGateway("Rashmi_Gateway_Test").setDevice("myOldDevice").build(); + + UnbindDeviceFromGatewayResponse response = deviceManagerAsyncClient.unbindDeviceFromGateway(request); + System.out.println(response.toString()); } } diff --git a/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/unbinddevicefromgateway/SyncUnbindDeviceFromGateway.java b/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/unbinddevicefromgateway/SyncUnbindDeviceFromGateway.java index 8b3c088e..0926c3de 100644 --- a/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/unbinddevicefromgateway/SyncUnbindDeviceFromGateway.java +++ b/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/unbinddevicefromgateway/SyncUnbindDeviceFromGateway.java @@ -1,9 +1,9 @@ package com.clearblade.cloud.iot.v1.unbinddevicefromgateway; -import java.util.logging.Level; import java.util.logging.Logger; import com.clearblade.cloud.iot.v1.DeviceManagerClient; +import com.clearblade.cloud.iot.v1.utils.RegistryName; public class SyncUnbindDeviceFromGateway { static Logger log = Logger.getLogger(SyncUnbindDeviceFromGateway.class.getName()); @@ -14,23 +14,11 @@ public static void main(String[] args) { public static void syncUnbindDeviceFromGateway() { DeviceManagerClient deviceManagerClient = new DeviceManagerClient(); - String parent = "Rashmi_Device_Test"; - String gateway = "Rashmi_Gateway_Test"; - String device = "Rashmi_Device_Test"; - - UnbindDeviceFromGatewayRequest request = UnbindDeviceFromGatewayRequest.Builder.newBuilder().setParent(parent).setGateway(gateway).setDevice(device).build(); + UnbindDeviceFromGatewayRequest request = UnbindDeviceFromGatewayRequest.Builder.newBuilder() + .setParent(RegistryName.of("ingressdevelopmentenv", "us-central1", "Rashmi_Registry_Test").toString()) + .setGateway("Rashmi_Gateway_Test").setDevice("Rashmi_Device_Test").build(); + UnbindDeviceFromGatewayResponse response = deviceManagerClient.unbindDeviceFromGateway(request); - - if (response != null) { - response.processRequest(request); - if(response.getHttpStatusResponse().equals("OK")) { - log.log(Level.INFO, "SyncUnbindDeviceFromGateway Method worked successfully :: {0}",response.getHttpStatusResponse()); - }else { - log.log(Level.SEVERE, "SyncUnbindDeviceFromGateway Method execution failed :: {0}",response.getHttpStatusResponse()); - } - }else { - log.log(Level.SEVERE, "SyncUnbindDeviceFromGateway Method execution failed"); - } - + System.out.println(response.toString()); } } diff --git a/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/updatedevice/AsyncUpdateDevice.java b/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/updatedevice/AsyncUpdateDevice.java new file mode 100644 index 00000000..674f4fc1 --- /dev/null +++ b/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/updatedevice/AsyncUpdateDevice.java @@ -0,0 +1,28 @@ +package com.clearblade.cloud.iot.v1.updatedevice; + +import java.util.logging.Level; +import java.util.logging.Logger; + +import com.clearblade.cloud.iot.v1.DeviceManagerAsyncClient; +import com.clearblade.cloud.iot.v1.DeviceManagerClient; +import com.clearblade.cloud.iot.v1.utils.Device; +import com.clearblade.cloud.iot.v1.utils.LogLevel; + +public class AsyncUpdateDevice { + static Logger log = Logger.getLogger(AsyncUpdateDevice.class.getName()); + + public static void main(String[] args) { + asyncUpdateDevice(); + } + + public static void asyncUpdateDevice() { + DeviceManagerAsyncClient deviceManagerAsyncClient = new DeviceManagerAsyncClient(); + Device device = Device.patch("myOldDevice","myOldDevice",LogLevel.ERROR,true); + String updateMask = "logLevel"; + + UpdateDeviceRequest request = UpdateDeviceRequest.Builder.newBuilder().setName("myOldDevice").setDevice(device).setUpdateMask(updateMask).build(); + Device response = deviceManagerAsyncClient.updateDevice(request); + System.out.println(response.toBuilder().getName()+"::"+response.toBuilder().getLogLevel().name()); + + } +} diff --git a/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/updatedevice/SyncUpdateDevice.java b/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/updatedevice/SyncUpdateDevice.java new file mode 100644 index 00000000..a48de2a2 --- /dev/null +++ b/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/updatedevice/SyncUpdateDevice.java @@ -0,0 +1,26 @@ +package com.clearblade.cloud.iot.v1.updatedevice; + +import java.util.logging.Logger; + +import com.clearblade.cloud.iot.v1.DeviceManagerClient; +import com.clearblade.cloud.iot.v1.utils.Device; +import com.clearblade.cloud.iot.v1.utils.LogLevel; + +public class SyncUpdateDevice { + static Logger log = Logger.getLogger(SyncUpdateDevice.class.getName()); + + public static void main(String[] args) { + syncUpdateDevice(); + } + + public static void syncUpdateDevice() { + DeviceManagerClient deviceManagerClient = new DeviceManagerClient(); + + Device device = Device.patch("myOldDevice","myOldDevice",LogLevel.DEBUG,true); + String updateMask = "logLevel"; + + UpdateDeviceRequest request = UpdateDeviceRequest.Builder.newBuilder().setName("myOldDevice").setDevice(device).setUpdateMask(updateMask).build(); + Device response = deviceManagerClient.updateDevice(request); + System.out.println(response.toBuilder().getName()+"::"+response.toBuilder().getLogLevel().name()); + } +} diff --git a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/AsyncClient.java b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/AsyncClient.java new file mode 100644 index 00000000..a8c14e6e --- /dev/null +++ b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/AsyncClient.java @@ -0,0 +1,493 @@ +package com.clearblade.cloud.iot.v1; + +import java.io.BufferedReader; +import java.io.InputStreamReader; +import java.io.OutputStream; +import java.net.URL; +import java.util.concurrent.CompletableFuture; +import java.util.concurrent.ExecutionException; +import java.util.concurrent.Future; +import java.util.concurrent.TimeUnit; +import java.util.concurrent.TimeoutException; + +import javax.net.ssl.HttpsURLConnection; + +import com.clearblade.cloud.iot.v1.utils.AuthParams; +import com.clearblade.cloud.iot.v1.utils.ConfigParameters; +import com.clearblade.cloud.iot.v1.utils.Constants; +import com.clearblade.cloud.iot.v1.utils.SetHttpConnection; + +public class AsyncClient { + + private ConfigParameters configParameters = new ConfigParameters(); + private String[] responseArray = new String[3]; + private String apiName; + private String params; + private String body; + + /** + * Method used to generate URL for apicall + * @param apiName - path to api + * @param params - parameters to be attached to request + * @return URL formed and to be used + */ + private String generateURL(String apiName, String params) { + + return AuthParams.getApiBaseURL() + .concat(configParameters.getEndpointPort()) + .concat(configParameters.getBaseURL()) + .concat(AuthParams.getUserSystemKey()) + .concat(apiName) + .concat("?" + params); + } + + /** + * Method used to Calls HTTP Get request + * @param apiName + * @param params + * @return String[] containing responseCode, responseMessage and response object + */ + private Object get() { + AuthParams.setRegistryCredentials(); + try { + String finalURL = generateURL(apiName, params); + System.out.println(finalURL); + URL obj = new URL(finalURL); + SetHttpConnection setCon = new SetHttpConnection(); + HttpsURLConnection con = setCon.getConnection(obj); + con.setRequestProperty(Constants.HTTP_REQUEST_PROPERTY_TOKEN_KEY, AuthParams.getUserToken()); + con.setRequestProperty(Constants.HTTP_REQUEST_PROPERTY_CONTENT_TYPE_KEY, + Constants.HTTP_REQUEST_PROPERTY_CONTENT_TYPE_ACCEPT_VALUE); + con.addRequestProperty(Constants.HTTP_REQUEST_PROPERTY_ACCEPT_KEY, + Constants.HTTP_REQUEST_PROPERTY_CONTENT_TYPE_ACCEPT_VALUE); + con.setRequestMethod(Constants.HTTP_REQUEST_METHOD_TYPE_GET); + StringBuilder response = new StringBuilder(); + responseArray[0] = String.valueOf(con.getResponseCode()); + responseArray[1] = con.getResponseMessage(); + BufferedReader in = null; + if (con.getErrorStream() != null) { + in = new BufferedReader(new InputStreamReader(con.getErrorStream())); + } else if (con.getInputStream() != null) { + in = new BufferedReader(new InputStreamReader(con.getInputStream())); + } + String inputLine; + String responseMessage = ""; + if (in != null) { + while ((inputLine = in.readLine()) != null) { + response.append(inputLine); + } + responseMessage = response.toString(); + responseArray[2] = responseMessage; + } + } catch (Exception e) { + e.printStackTrace(); + } + + return responseArray; + } + + + /** + * Method used to call HTTP Post request + * @param apiName + * @param params + * @param body + * @return String[] containing responseCode, responseMessage and response object + */ + public Object post() { + AuthParams.setRegistryCredentials(); + + try { + String finalURL = generateURL(apiName, params); + System.out.println(finalURL); + URL obj = new URL(finalURL); + SetHttpConnection setCon = new SetHttpConnection(); + HttpsURLConnection con = setCon.getConnection(obj); + con.setRequestProperty(Constants.HTTP_REQUEST_PROPERTY_TOKEN_KEY, AuthParams.getUserToken()); + con.setRequestProperty(Constants.HTTP_REQUEST_PROPERTY_CONTENT_TYPE_KEY, + Constants.HTTP_REQUEST_PROPERTY_CONTENT_TYPE_ACCEPT_VALUE); + con.addRequestProperty(Constants.HTTP_REQUEST_PROPERTY_ACCEPT_KEY, + Constants.HTTP_REQUEST_PROPERTY_CONTENT_TYPE_ACCEPT_VALUE); + con.setRequestMethod(Constants.HTTP_REQUEST_METHOD_TYPE_POST); + con.setDoOutput(true); + StringBuilder response = new StringBuilder(); + OutputStream os = con.getOutputStream(); + byte[] input = body.getBytes(Constants.UTF8); + os.write(input, 0, input.length); + os.flush(); + responseArray[0] = String.valueOf(con.getResponseCode()); + responseArray[1] = con.getResponseMessage(); + BufferedReader in = null; + if (con.getErrorStream() != null) { + in = new BufferedReader(new InputStreamReader(con.getErrorStream())); + } else if (con.getInputStream() != null) { + in = new BufferedReader(new InputStreamReader(con.getInputStream())); + } + String inputLine; + String responseMessage = ""; + if (in != null) { + while ((inputLine = in.readLine()) != null) { + response.append(inputLine); + } + responseMessage = response.toString(); + responseArray[2] = responseMessage; + } + } catch (Exception e) { + e.printStackTrace(); + } + + return responseArray; + } + + + /** + * Method used to call HTTP delete request + * @param apiName + * @param params + * @return String[] containing responseCode, responseMessage and response object + */ + public Object delete() { + AuthParams.setRegistryCredentials(); + try { + String finalURL = generateURL(apiName, params); + System.out.println(finalURL); + URL obj = new URL(finalURL); + SetHttpConnection setCon = new SetHttpConnection(); + HttpsURLConnection con = setCon.getConnection(obj); + con.setRequestProperty(Constants.HTTP_REQUEST_PROPERTY_TOKEN_KEY, AuthParams.getUserToken()); + con.setRequestProperty(Constants.HTTP_REQUEST_PROPERTY_CONTENT_TYPE_KEY, + Constants.HTTP_REQUEST_PROPERTY_CONTENT_TYPE_ACCEPT_VALUE); + con.addRequestProperty(Constants.HTTP_REQUEST_PROPERTY_ACCEPT_KEY, + Constants.HTTP_REQUEST_PROPERTY_CONTENT_TYPE_ACCEPT_VALUE); + con.setRequestMethod(Constants.HTTP_REQUEST_METHOD_TYPE_DELETE); + StringBuilder response = new StringBuilder(); + responseArray[0] = String.valueOf(con.getResponseCode()); + responseArray[1] = con.getResponseMessage(); + BufferedReader in = null; + if (con.getErrorStream() != null) { + in = new BufferedReader(new InputStreamReader(con.getErrorStream())); + } else if (con.getInputStream() != null) { + in = new BufferedReader(new InputStreamReader(con.getInputStream())); + } + String inputLine; + String responseMessage = ""; + if (in != null) { + while ((inputLine = in.readLine()) != null) { + response.append(inputLine); + } + responseMessage = response.toString(); + responseArray[2] = responseMessage; + } + } catch (Exception e) { + e.printStackTrace(); + } + + return responseArray; + } + + /** + * Method used to call HTTP Patch request + * @param apiName + * @param params + * @param body + * @return String[] Object containing responseCode, responseMessage and response object + */ + public Object update() { + AuthParams.setRegistryCredentials(); + + try { + String finalURL = generateURL(apiName, params); + System.out.println(finalURL); + URL obj = new URL(finalURL); + SetHttpConnection setCon = new SetHttpConnection(); + HttpsURLConnection con = setCon.getConnection(obj); + con.setRequestProperty(Constants.HTTP_REQUEST_PROPERTY_TOKEN_KEY, AuthParams.getUserToken()); + con.setRequestProperty(Constants.HTTP_REQUEST_PROPERTY_CONTENT_TYPE_KEY, + Constants.HTTP_REQUEST_PROPERTY_CONTENT_TYPE_ACCEPT_VALUE); + con.addRequestProperty(Constants.HTTP_REQUEST_PROPERTY_ACCEPT_KEY, + Constants.HTTP_REQUEST_PROPERTY_CONTENT_TYPE_ACCEPT_VALUE); + con.setRequestMethod(Constants.HTTP_REQUEST_METHOD_TYPE_POST); + con.setRequestProperty("X-HTTP-Method-Override", Constants.HTTP_REQUEST_METHOD_TYPE_PATCH); + con.setDoOutput(true); + StringBuilder response = new StringBuilder(); + OutputStream os = con.getOutputStream(); + byte[] input = body.getBytes(Constants.UTF8); + os.write(input, 0, input.length); + os.flush(); + responseArray[0] = String.valueOf(con.getResponseCode()); + responseArray[1] = con.getResponseMessage(); + BufferedReader in = null; + if (con.getErrorStream() != null) { + in = new BufferedReader(new InputStreamReader(con.getErrorStream())); + } else if (con.getInputStream() != null) { + in = new BufferedReader(new InputStreamReader(con.getInputStream())); + } + String inputLine; + String responseMessage = ""; + if (in != null) { + while ((inputLine = in.readLine()) != null) { + response.append(inputLine); + } + responseMessage = response.toString(); + responseArray[2] = responseMessage; + } + } catch (Exception e) { + e.printStackTrace(); + } + + return responseArray; + } + private Future getObjectAsync() { + return CompletableFuture.supplyAsync(this::get); + } + + public String[] asyncGet(String apiName,String params) throws InterruptedException { + this.apiName = apiName; + this.params = params; + Future future = getObjectAsync(); + try { + future.get(15000, TimeUnit.MILLISECONDS); + } catch (InterruptedException | ExecutionException | TimeoutException e) { + e.printStackTrace(); + Thread.currentThread().interrupt(); + } + return responseArray; + } + + private Future createObjectAsync() { + return CompletableFuture.supplyAsync(this::post); + } + + public String[] asyncCreate(String apiName,String params,String body) throws InterruptedException { + this.apiName = apiName; + this.params = params; + this.body = body; + Future future = createObjectAsync(); + try { + future.get(15000, TimeUnit.MILLISECONDS); + } catch (InterruptedException | ExecutionException | TimeoutException e) { + e.printStackTrace(); + Thread.currentThread().interrupt(); + } + return responseArray; + } + + private Future bindDeviceToGatewayObjectAsync() { + return CompletableFuture.supplyAsync(this::post); + } + + public String[] asyncBindDeviceToGateway(String apiName,String params,String body) throws InterruptedException { + this.apiName = apiName; + this.params = params; + this.body = body; + Future future = bindDeviceToGatewayObjectAsync(); + try { + future.get(15000, TimeUnit.MILLISECONDS); + } catch (InterruptedException | ExecutionException | TimeoutException e) { + e.printStackTrace(); + Thread.currentThread().interrupt(); + } + return responseArray; + } + + private Future unBindDeviceFromGatewayObjectAsync() { + return CompletableFuture.supplyAsync(this::post); + } + + public String[] asyncUnbindDeviceFromGateway(String apiName, String params, String body) + throws InterruptedException { + this.apiName = apiName; + this.params = params; + this.body = body; + Future future = unBindDeviceFromGatewayObjectAsync(); + try { + future.get(15000, TimeUnit.MILLISECONDS); + } catch (InterruptedException | ExecutionException | TimeoutException e) { + e.printStackTrace(); + Thread.currentThread().interrupt(); + } + return responseArray; + } + + private Future sendCommandToDeviceAsync() { + return CompletableFuture.supplyAsync(this::post); + } + + public String[] asyncSendCommandToDevice(String apiName, String params, String body) throws InterruptedException { + this.apiName = apiName; + this.params = params; + this.body = body; + Future future = sendCommandToDeviceAsync(); + try { + future.get(15000, TimeUnit.MILLISECONDS); + } catch (InterruptedException | ExecutionException | TimeoutException e) { + e.printStackTrace(); + Thread.currentThread().interrupt(); + } + return responseArray; + } + + private Future modifyCloudToDeviceConfigAsync() { + return CompletableFuture.supplyAsync(this::post); + } + + public String[] asyncModifyCloudToDeviceConfig(String apiName, String params, String body) + throws InterruptedException { + this.apiName = apiName; + this.params = params; + this.body = body; + Future future = modifyCloudToDeviceConfigAsync(); + try { + future.get(15000, TimeUnit.MILLISECONDS); + } catch (InterruptedException | ExecutionException | TimeoutException e) { + e.printStackTrace(); + Thread.currentThread().interrupt(); + } + return responseArray; + } + + private Future listDeviceStatesAsync() { + return CompletableFuture.supplyAsync(this::get); + } + + public String[] asyncListDeviceStates(String apiName, String params) + throws InterruptedException { + this.apiName = apiName; + this.params = params; + Future future = listDeviceStatesAsync(); + try { + future.get(15000, TimeUnit.MILLISECONDS); + } catch (InterruptedException | ExecutionException | TimeoutException e) { + e.printStackTrace(); + Thread.currentThread().interrupt(); + } + return responseArray; + } + private Future deleteObjectAsync() { + return CompletableFuture.supplyAsync(this::delete); + } + + public String[] asyncDelete(String apiName,String params) throws InterruptedException { + this.apiName = apiName; + this.params = params; + Future future = deleteObjectAsync(); + try { + future.get(15000, TimeUnit.MILLISECONDS); + } catch (InterruptedException | ExecutionException | TimeoutException e) { + e.printStackTrace(); + Thread.currentThread().interrupt(); + } + return responseArray; + } + + private Future updateObjectAsync() { + return CompletableFuture.supplyAsync(this::update); + } + + public String[] asyncUpdate(String apiName,String params,String body) throws InterruptedException { + this.apiName = apiName; + this.params = params; + this.body = body; + Future future = updateObjectAsync(); + try { + future.get(15000, TimeUnit.MILLISECONDS); + } catch (InterruptedException | ExecutionException | TimeoutException e) { + e.printStackTrace(); + Thread.currentThread().interrupt(); + } + return responseArray; + } + private Future listObjectAsync() { + return CompletableFuture.supplyAsync(this::get); + } + + public String[] asyncListDevices(String apiName,String params) throws InterruptedException { + this.apiName = apiName; + this.params = params; + Future future = listObjectAsync(); + try { + future.get(15000, TimeUnit.MILLISECONDS); + } catch (InterruptedException | ExecutionException | TimeoutException e) { + e.printStackTrace(); + Thread.currentThread().interrupt(); + } + return responseArray; + } + +//Registry Apis + /** + * Method used to generate URL for apicall + * @param apiName - path to api + * @param params - parameters to be attached to request + * @return URL formed and to be used + */ + private String generateAdminURL(String apiName, String params) { + + return AuthParams.getBaseURL() + .concat(configParameters.getBaseURL()) + .concat(AuthParams.getUserSystemKey()) + .concat(apiName) + .concat("?"+params); + } + /** + * Method used to Calls HTTP Get request + * @param apiName + * @param params + * @return String[] containing responseCode, responseMessage and response object + */ + public Object getRegistry() { + AuthParams.setRegistryCredentials(); + try { + String finalURL = generateAdminURL(apiName, params); + System.out.println(finalURL); + URL obj = new URL(finalURL); + SetHttpConnection setCon = new SetHttpConnection(); + HttpsURLConnection con = setCon.getConnection(obj); + con.setRequestProperty(Constants.HTTP_REQUEST_PROPERTY_TOKEN_KEY, AuthParams.getUserToken()); + con.setRequestProperty(Constants.HTTP_REQUEST_PROPERTY_CONTENT_TYPE_KEY, Constants.HTTP_REQUEST_PROPERTY_CONTENT_TYPE_ACCEPT_VALUE); + con.addRequestProperty(Constants.HTTP_REQUEST_PROPERTY_ACCEPT_KEY, Constants.HTTP_REQUEST_PROPERTY_CONTENT_TYPE_ACCEPT_VALUE); + con.setRequestMethod(Constants.HTTP_REQUEST_METHOD_TYPE_GET); + StringBuilder response = new StringBuilder(); + responseArray[0] = String.valueOf(con.getResponseCode()); + responseArray[1] = con.getResponseMessage(); + BufferedReader in = null; + if (con.getErrorStream() != null) { + in = new BufferedReader(new InputStreamReader(con.getErrorStream())); + } else if (con.getInputStream() != null) { + in = new BufferedReader(new InputStreamReader(con.getInputStream())); + } + String inputLine; + String responseMessage = ""; + if (in != null) { + while ((inputLine = in.readLine()) != null) { + response.append(inputLine); + } + responseMessage = response.toString(); + responseArray[2] = responseMessage; + } + }catch(Exception e) { + e.printStackTrace(); + } + + return responseArray; + } + + private Future getRegistryAsync() { + return CompletableFuture.supplyAsync(this::getRegistry); + } + + public String[] asyncGetRegistry(String apiName,String params) throws InterruptedException { + this.apiName = apiName; + this.params = params; + Future future = getRegistryAsync(); + try { + future.get(15000, TimeUnit.MILLISECONDS); + } catch (InterruptedException | ExecutionException | TimeoutException e) { + e.printStackTrace(); + Thread.currentThread().interrupt(); + } + return responseArray; + } + + +} diff --git a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/ClearBladeDeviceManager.java b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/ClearBladeDeviceManager.java new file mode 100644 index 00000000..649e6a08 --- /dev/null +++ b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/ClearBladeDeviceManager.java @@ -0,0 +1,318 @@ +package com.clearblade.cloud.iot.v1; + +import com.clearblade.cloud.iot.v1.binddevicetogateway.BindDeviceToGatewayRequest; +import com.clearblade.cloud.iot.v1.binddevicetogateway.BindDeviceToGatewayResponse; +import com.clearblade.cloud.iot.v1.createdevice.CreateDeviceRequest; +import com.clearblade.cloud.iot.v1.deletedevice.DeleteDeviceRequest; +import com.clearblade.cloud.iot.v1.deviceslist.DevicesListRequest; +import com.clearblade.cloud.iot.v1.deviceslist.DevicesListResponse; +import com.clearblade.cloud.iot.v1.devicestateslist.ListDeviceStatesRequest; +import com.clearblade.cloud.iot.v1.devicestateslist.ListDeviceStatesResponse; +import com.clearblade.cloud.iot.v1.getdevice.GetDeviceRequest; +import com.clearblade.cloud.iot.v1.modifycloudtodeviceconfig.ModifyCloudToDeviceConfigRequest; +import com.clearblade.cloud.iot.v1.sendcommandtodevice.SendCommandToDeviceRequest; +import com.clearblade.cloud.iot.v1.sendcommandtodevice.SendCommandToDeviceResponse; +import com.clearblade.cloud.iot.v1.unbinddevicefromgateway.UnbindDeviceFromGatewayRequest; +import com.clearblade.cloud.iot.v1.unbinddevicefromgateway.UnbindDeviceFromGatewayResponse; +import com.clearblade.cloud.iot.v1.updatedevice.UpdateDeviceRequest; +import com.clearblade.cloud.iot.v1.utils.ConfigParameters; +import com.clearblade.cloud.iot.v1.utils.Device; +import com.clearblade.cloud.iot.v1.utils.DeviceConfig; + +public class ClearBladeDeviceManager { + ConfigParameters configParameters = new ConfigParameters(); + + + public Device getDevice(GetDeviceRequest request) { + SyncClient syncClient = new SyncClient(); + String[] responseArray = syncClient.get(configParameters.getDevicesURLExtension(), request.toString()); + int responseCode = Integer.parseInt(responseArray[0]); + if(responseCode == 200) { + Device device = Device.newBuilder().build(); + device.loadFromString(responseArray[2]); + return device; + } + return null; + } + + public Device asyncGetDevice(GetDeviceRequest request) { + try { + AsyncClient asyncClient = new AsyncClient(); + String[] responseArray = asyncClient.asyncGet(configParameters.getDevicesURLExtension(), + request.toString()); + int responseCode = Integer.parseInt(responseArray[0]); + if(responseCode == 200) { + Device device = Device.newBuilder().build(); + device.loadFromString(responseArray[2]); + return device; + } + }catch(Exception e) { + e.printStackTrace(); + } + return null; + } + + public Device createDevice(CreateDeviceRequest request) { + SyncClient syncClient = new SyncClient(); + String[] params = request.getParams(); + String reqParams = params[0]; + String body = params[1]; + String[] responseArray = syncClient.post(configParameters.getDevicesURLExtension(), reqParams, body); + int responseCode = Integer.parseInt(responseArray[0]); + if (responseCode == 200) { + Device deviceObj = Device.newBuilder().build(); + deviceObj.loadFromString(responseArray[2]); + return deviceObj; + } + return null; + } + + public Device asyncCreateDevice(CreateDeviceRequest request) { + try { + AsyncClient asyncClient = new AsyncClient(); + String[] params = request.getParams(); + String reqParams = params[0]; + String body = params[1]; + String[] responseArray = asyncClient.asyncCreate(configParameters.getDevicesURLExtension(), reqParams, + body); + int responseCode = Integer.parseInt(responseArray[0]); + if (responseCode == 200) { + Device deviceObj = Device.newBuilder().build(); + deviceObj.loadFromString(responseArray[2]); + return deviceObj; + } + }catch(Exception e) { + e.printStackTrace(); + } + return null; + } + + public void deleteDevice(DeleteDeviceRequest request) { + SyncClient syncClient = new SyncClient(); + String[] responseArray = syncClient.delete(configParameters.getDevicesURLExtension(), request.toString()); + System.out.println( + "Response for delete is " + responseArray[0] + "::" + responseArray[1] + "::" + responseArray[2]); + } + + public void asyncDeleteDevice(DeleteDeviceRequest request) { + try { + AsyncClient asyncClient = new AsyncClient(); + String[] responseArray = asyncClient.asyncDelete(configParameters.getDevicesURLExtension(), + request.toString()); + System.out.println( + "Response for delete is " + responseArray[0] + "::" + responseArray[1] + "::" + responseArray[2]); + } catch (Exception e) { + e.printStackTrace(); + } + } + + public Device updateDevice(UpdateDeviceRequest request) { + SyncClient syncClient = new SyncClient(); + String[] params = request.getBodyAndParams(); + String reqParams = params[0]; + String body = params[1]; + String[] responseArray = syncClient.patch(configParameters.getDevicesURLExtension(), reqParams, body); + int responseCode = Integer.parseInt(responseArray[0]); + if (responseCode == 200) { + Device deviceObj = Device.newBuilder().build(); + deviceObj.loadFromString(responseArray[2]); + return deviceObj; + } + return null; + } + public Device asyncUpdateDevice(UpdateDeviceRequest request) { + try { + AsyncClient asyncClient = new AsyncClient(); + String[] params = request.getBodyAndParams(); + String reqParams = params[0]; + String body = params[1]; + String[] responseArray = asyncClient.asyncUpdate(configParameters.getDevicesURLExtension(), reqParams, + body); + int responseCode = Integer.parseInt(responseArray[0]); + if (responseCode == 200) { + Device deviceObj = Device.newBuilder().build(); + deviceObj.loadFromString(responseArray[2]); + return deviceObj; + } + }catch(Exception e) { + e.printStackTrace(); + } + return null; + } + public BindDeviceToGatewayResponse bindDeviceToGateway(BindDeviceToGatewayRequest request) { + SyncClient syncClient = new SyncClient(); + String[] paramBody = request.getBodyAndParams(); + String[] responseArray = syncClient.post(configParameters.getCloudiotURLExtension(), paramBody[0], + paramBody[1]); + BindDeviceToGatewayResponse response = BindDeviceToGatewayResponse.Builder.newBuilder().build(); + response.setHttpStatusCode(Integer.parseInt(responseArray[0])); + response.setHttpStatusResponse(responseArray[1]); + return response; + } + + public BindDeviceToGatewayResponse asyncBindDeviceToGateway(BindDeviceToGatewayRequest request) { + try { + AsyncClient asyncClient = new AsyncClient(); + String[] paramBody = request.getBodyAndParams(); + String[] responseArray = asyncClient.asyncBindDeviceToGateway(configParameters.getCloudiotURLExtension(), + paramBody[0], paramBody[1]); + BindDeviceToGatewayResponse response = BindDeviceToGatewayResponse.Builder.newBuilder().build(); + response.setHttpStatusCode(Integer.parseInt(responseArray[0])); + response.setHttpStatusResponse(responseArray[1]); + return response; + }catch(Exception e) { + e.printStackTrace(); + } + return null; + } + + public UnbindDeviceFromGatewayResponse unbindDeviceFromGateway(UnbindDeviceFromGatewayRequest request) { + SyncClient syncClinet = new SyncClient(); + String[] paramBody = request.getBodyAndParams(); + String[] responseArray = syncClinet.post(configParameters.getCloudiotURLExtension(), paramBody[0], + paramBody[1]); + UnbindDeviceFromGatewayResponse response = UnbindDeviceFromGatewayResponse.Builder.newBuilder().build(); + response.setHttpStatusCode(Integer.parseInt(responseArray[0])); + response.setHttpStatusResponse(responseArray[1]); + return response; + } + + public UnbindDeviceFromGatewayResponse asyncUnbindDeviceFromGateway(UnbindDeviceFromGatewayRequest request) { + try { + AsyncClient asyncClinet = new AsyncClient(); + String[] paramBody = request.getBodyAndParams(); + String[] responseArray = asyncClinet.asyncUnbindDeviceFromGateway( + configParameters.getCloudiotURLExtension(), paramBody[0], paramBody[1]); + UnbindDeviceFromGatewayResponse response = UnbindDeviceFromGatewayResponse.Builder.newBuilder().build(); + response.setHttpStatusCode(Integer.parseInt(responseArray[0])); + response.setHttpStatusResponse(responseArray[1]); + return response; + }catch(Exception e) { + e.printStackTrace(); + } + return null; + } + + public SendCommandToDeviceResponse sendCommandToDevice(SendCommandToDeviceRequest request) { + SyncClient syncClient = new SyncClient(); + String[] paramBody = request.getBodyAndParams(); + String[] responseArray = syncClient.post(configParameters.getDevicesURLExtension(), paramBody[0], + paramBody[1]); + System.out.println(responseArray[2]); + SendCommandToDeviceResponse response = SendCommandToDeviceResponse.Builder.newBuilder().build(); + response.setHttpStatusCode(Integer.parseInt(responseArray[0])); + response.setHttpStatusResponse(responseArray[1]); + return response; + } + + public SendCommandToDeviceResponse asyncSendCommandToDevice(SendCommandToDeviceRequest request) { + try { + AsyncClient asyncClient = new AsyncClient(); + String[] paramBody = request.getBodyAndParams(); + String[] responseArray = asyncClient.asyncSendCommandToDevice(configParameters.getDevicesURLExtension(), + paramBody[0], + paramBody[1]); + System.out.println(responseArray[2]); + SendCommandToDeviceResponse response = SendCommandToDeviceResponse.Builder.newBuilder().build(); + response.setHttpStatusCode(Integer.parseInt(responseArray[0])); + response.setHttpStatusResponse(responseArray[1]); + return response; + } catch (Exception e) { + e.printStackTrace(); + } + return null; + } + + public DevicesListResponse listDevices(DevicesListRequest request) { + SyncClient syncClient = new SyncClient(); + String[] responseArray = syncClient.get(configParameters.getDevicesURLExtension(), request.getParamsForList()); + int responseCode = Integer.parseInt(responseArray[0]); + if (responseCode == 200) { + DevicesListResponse devicesListResponse = DevicesListResponse.Builder.newBuilder() + .buildResponse(responseArray[2]).build(); + // deviceObj.loadFromString(responseArray[2]); + return devicesListResponse; + } + return null; + } + + public DevicesListResponse asyncListDevices(DevicesListRequest request) { + try { + AsyncClient asyncClient = new AsyncClient(); + String[] responseArray = asyncClient.asyncListDevices(configParameters.getDevicesURLExtension(), request.getParamsForList()); + int responseCode = Integer.parseInt(responseArray[0]); + if (responseCode == 200) { + DevicesListResponse devicesListResponse = DevicesListResponse.Builder.newBuilder() + .buildResponse(responseArray[2]).build(); + // deviceObj.loadFromString(responseArray[2]); + return devicesListResponse; + } + }catch(Exception e) { + e.printStackTrace(); + } + return null; + } + + public DeviceConfig modifyCloudToDeviceConfig(ModifyCloudToDeviceConfigRequest request) { + SyncClient syncClient = new SyncClient(); + String[] paramBody = request.getBodyAndParams(); + String[] responseArray = syncClient.post(configParameters.getDevicesURLExtension(), paramBody[0], + paramBody[1]); + System.out.println(responseArray[2]); + DeviceConfig deviceConfig = DeviceConfig.newBuilder().build(); + if (Integer.parseInt(responseArray[0]) == 200) + deviceConfig.loadFromString(responseArray[2]); + return deviceConfig; + } + + public DeviceConfig asyncModifyCloudToDeviceConfig(ModifyCloudToDeviceConfigRequest request) { + try { + AsyncClient asyncClient = new AsyncClient(); + String[] paramBody = request.getBodyAndParams(); + String[] responseArray = asyncClient.asyncModifyCloudToDeviceConfig( + configParameters.getDevicesURLExtension(), paramBody[0], + paramBody[1]); + System.out.println(responseArray[2]); + DeviceConfig deviceConfig = DeviceConfig.newBuilder().build(); + if (Integer.parseInt(responseArray[0]) == 200) + deviceConfig.loadFromString(responseArray[2]); + return deviceConfig; + } catch (Exception e) { + e.printStackTrace(); + } + return null; + } + + public ListDeviceStatesResponse listDeviceStates(ListDeviceStatesRequest request) { + SyncClient syncClient = new SyncClient(); + String[] responseArray = syncClient.get(configParameters.getDevicesStatesURLExtension(), + request.getParamsForList()); + int responseCode = Integer.parseInt(responseArray[0]); + if (responseCode == 200) { + ListDeviceStatesResponse listDeviceStatesResponse = ListDeviceStatesResponse.Builder.newBuilder() + .buildResponse(responseArray[2]).build(); + // deviceObj.loadFromString(responseArray[2]); + return listDeviceStatesResponse; + } + return null; + } + + public ListDeviceStatesResponse asyncListDeviceStates(ListDeviceStatesRequest request) { + try { + AsyncClient asyncClient = new AsyncClient(); + String[] responseArray = asyncClient.asyncListDeviceStates(configParameters.getDevicesStatesURLExtension(), + request.getParamsForList()); + int responseCode = Integer.parseInt(responseArray[0]); + if (responseCode == 200) { + ListDeviceStatesResponse listDeviceStatesResponse = ListDeviceStatesResponse.Builder.newBuilder() + .buildResponse(responseArray[2]).build(); + // deviceObj.loadFromString(responseArray[2]); + return listDeviceStatesResponse; + } + } catch (Exception e) { + e.printStackTrace(); + } + return null; + } + +} diff --git a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/ClearBladeRegistryManager.java b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/ClearBladeRegistryManager.java new file mode 100644 index 00000000..fe0b8fd5 --- /dev/null +++ b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/ClearBladeRegistryManager.java @@ -0,0 +1,253 @@ +package com.clearblade.cloud.iot.v1; + +import com.clearblade.cloud.iot.v1.binddevicetogateway.BindDeviceToGatewayRequest; +import com.clearblade.cloud.iot.v1.binddevicetogateway.BindDeviceToGatewayResponse; +import com.clearblade.cloud.iot.v1.createdevice.CreateDeviceRequest; +import com.clearblade.cloud.iot.v1.deletedevice.DeleteDeviceRequest; +import com.clearblade.cloud.iot.v1.deviceslist.DevicesListRequest; +import com.clearblade.cloud.iot.v1.deviceslist.DevicesListResponse; +import com.clearblade.cloud.iot.v1.getdevice.GetDeviceRequest; +import com.clearblade.cloud.iot.v1.getdeviceregistry.GetDeviceRegistryRequest; +import com.clearblade.cloud.iot.v1.sendcommandtodevice.SendCommandToDeviceRequest; +import com.clearblade.cloud.iot.v1.sendcommandtodevice.SendCommandToDeviceResponse; +import com.clearblade.cloud.iot.v1.unbinddevicefromgateway.UnbindDeviceFromGatewayRequest; +import com.clearblade.cloud.iot.v1.unbinddevicefromgateway.UnbindDeviceFromGatewayResponse; +import com.clearblade.cloud.iot.v1.updatedevice.UpdateDeviceRequest; +import com.clearblade.cloud.iot.v1.utils.ConfigParameters; +import com.clearblade.cloud.iot.v1.utils.Device; +import com.clearblade.cloud.iot.v1.utils.DeviceRegistry; + +public class ClearBladeRegistryManager { + ConfigParameters configParameters = new ConfigParameters(); + + + public DeviceRegistry getRegistry(GetDeviceRegistryRequest request) { + SyncClient syncClient = new SyncClient(); + String[] responseArray = syncClient.getRegistry(configParameters.getCloudiotURLExtension(), request.toString()); + int responseCode = Integer.parseInt(responseArray[0]); + if(responseCode == 200) { + DeviceRegistry deviceRegistry = DeviceRegistry.newBuilder().build(); + deviceRegistry.loadFromString(responseArray[2]); + return deviceRegistry; + } + return null; + } + + public DeviceRegistry asyncGetDeviceRegistry(GetDeviceRegistryRequest request) { + try { + AsyncClient asyncClient = new AsyncClient(); + String[] responseArray = asyncClient.asyncGetRegistry(configParameters.getCloudiotURLExtension(), + request.toString()); + int responseCode = Integer.parseInt(responseArray[0]); + if(responseCode == 200) { + DeviceRegistry deviceRegistry = DeviceRegistry.newBuilder().build(); + deviceRegistry.loadFromString(responseArray[2]); + return deviceRegistry; + } + }catch(Exception e) { + e.printStackTrace(); + } + return null; + } + + public Device createDevice(CreateDeviceRequest request) { + SyncClient syncClient = new SyncClient(); + String[] params = request.getParams(); + String reqParams = params[0]; + String body = params[1]; + String[] responseArray = syncClient.post(configParameters.getDevicesURLExtension(), reqParams, body); + int responseCode = Integer.parseInt(responseArray[0]); + if (responseCode == 200) { + Device deviceObj = Device.newBuilder().build(); + deviceObj.loadFromString(responseArray[2]); + return deviceObj; + } + return null; + } + + public Device asyncCreateDevice(CreateDeviceRequest request) { + try { + AsyncClient asyncClient = new AsyncClient(); + String[] params = request.getParams(); + String reqParams = params[0]; + String body = params[1]; + String[] responseArray = asyncClient.asyncCreate(configParameters.getDevicesURLExtension(), reqParams, + body); + int responseCode = Integer.parseInt(responseArray[0]); + if (responseCode == 200) { + Device deviceObj = Device.newBuilder().build(); + deviceObj.loadFromString(responseArray[2]); + return deviceObj; + } + }catch(Exception e) { + e.printStackTrace(); + } + return null; + } + + public void deleteDevice(DeleteDeviceRequest request) { + SyncClient syncClient = new SyncClient(); + String[] responseArray = syncClient.delete(configParameters.getDevicesURLExtension(), request.toString()); + System.out.println( + "Response for delete is " + responseArray[0] + "::" + responseArray[1] + "::" + responseArray[2]); + } + + public void asyncDeleteDevice(DeleteDeviceRequest request) { + try { + AsyncClient asyncClient = new AsyncClient(); + String[] responseArray = asyncClient.asyncDelete(configParameters.getDevicesURLExtension(), + request.toString()); + System.out.println( + "Response for delete is " + responseArray[0] + "::" + responseArray[1] + "::" + responseArray[2]); + } catch (Exception e) { + e.printStackTrace(); + } + } + + public Device updateDevice(UpdateDeviceRequest request) { + SyncClient syncClient = new SyncClient(); + String[] params = request.getBodyAndParams(); + String reqParams = params[0]; + String body = params[1]; + String[] responseArray = syncClient.patch(configParameters.getDevicesURLExtension(), reqParams, body); + int responseCode = Integer.parseInt(responseArray[0]); + if (responseCode == 200) { + Device deviceObj = Device.newBuilder().build(); + deviceObj.loadFromString(responseArray[2]); + return deviceObj; + } + return null; + } + public Device asyncUpdateDevice(UpdateDeviceRequest request) { + try { + AsyncClient asyncClient = new AsyncClient(); + String[] params = request.getBodyAndParams(); + String reqParams = params[0]; + String body = params[1]; + String[] responseArray = asyncClient.asyncUpdate(configParameters.getDevicesURLExtension(), reqParams, + body); + int responseCode = Integer.parseInt(responseArray[0]); + if (responseCode == 200) { + Device deviceObj = Device.newBuilder().build(); + deviceObj.loadFromString(responseArray[2]); + return deviceObj; + } + }catch(Exception e) { + e.printStackTrace(); + } + return null; + } + public BindDeviceToGatewayResponse bindDeviceToGateway(BindDeviceToGatewayRequest request) { + SyncClient syncClient = new SyncClient(); + String[] paramBody = request.getBodyAndParams(); + String[] responseArray = syncClient.post(configParameters.getCloudiotURLExtension(), paramBody[0], + paramBody[1]); + BindDeviceToGatewayResponse response = BindDeviceToGatewayResponse.Builder.newBuilder().build(); + response.setHttpStatusCode(Integer.parseInt(responseArray[0])); + response.setHttpStatusResponse(responseArray[1]); + return response; + } + + public BindDeviceToGatewayResponse asyncBindDeviceToGateway(BindDeviceToGatewayRequest request) { + try { + AsyncClient asyncClient = new AsyncClient(); + String[] paramBody = request.getBodyAndParams(); + String[] responseArray = asyncClient.asyncBindDeviceToGateway(configParameters.getCloudiotURLExtension(), + paramBody[0], paramBody[1]); + BindDeviceToGatewayResponse response = BindDeviceToGatewayResponse.Builder.newBuilder().build(); + response.setHttpStatusCode(Integer.parseInt(responseArray[0])); + response.setHttpStatusResponse(responseArray[1]); + return response; + }catch(Exception e) { + e.printStackTrace(); + } + return null; + } + + public UnbindDeviceFromGatewayResponse unbindDeviceFromGateway(UnbindDeviceFromGatewayRequest request) { + SyncClient syncClinet = new SyncClient(); + String[] paramBody = request.getBodyAndParams(); + String[] responseArray = syncClinet.post(configParameters.getCloudiotURLExtension(), paramBody[0], + paramBody[1]); + UnbindDeviceFromGatewayResponse response = UnbindDeviceFromGatewayResponse.Builder.newBuilder().build(); + response.setHttpStatusCode(Integer.parseInt(responseArray[0])); + response.setHttpStatusResponse(responseArray[1]); + return response; + } + + public UnbindDeviceFromGatewayResponse asyncUnbindDeviceFromGateway(UnbindDeviceFromGatewayRequest request) { + try { + AsyncClient asyncClinet = new AsyncClient(); + String[] paramBody = request.getBodyAndParams(); + String[] responseArray = asyncClinet.asyncUnbindDeviceFromGateway( + configParameters.getCloudiotURLExtension(), paramBody[0], paramBody[1]); + UnbindDeviceFromGatewayResponse response = UnbindDeviceFromGatewayResponse.Builder.newBuilder().build(); + response.setHttpStatusCode(Integer.parseInt(responseArray[0])); + response.setHttpStatusResponse(responseArray[1]); + return response; + }catch(Exception e) { + e.printStackTrace(); + } + return null; + } + + public SendCommandToDeviceResponse sendCommandToDevice(SendCommandToDeviceRequest request) { + SyncClient syncClient = new SyncClient(); + String[] paramBody = request.getBodyAndParams(); + String[] responseArray = syncClient.post(configParameters.getDevicesURLExtension(), paramBody[0], + paramBody[1]); + System.out.println(responseArray[2]); + SendCommandToDeviceResponse response = SendCommandToDeviceResponse.Builder.newBuilder().build(); + response.setHttpStatusCode(Integer.parseInt(responseArray[0])); + response.setHttpStatusResponse(responseArray[1]); + return response; + } + + public SendCommandToDeviceResponse asyncSendCommandToDevice(SendCommandToDeviceRequest request) { + try { + AsyncClient asyncClient = new AsyncClient(); + String[] paramBody = request.getBodyAndParams(); + String[] responseArray = asyncClient.asyncSendCommandToDevice(configParameters.getDevicesURLExtension(), + paramBody[0], + paramBody[1]); + System.out.println(responseArray[2]); + SendCommandToDeviceResponse response = SendCommandToDeviceResponse.Builder.newBuilder().build(); + response.setHttpStatusCode(Integer.parseInt(responseArray[0])); + response.setHttpStatusResponse(responseArray[1]); + return response; + } catch (Exception e) { + e.printStackTrace(); + } + return null; + } + + public DevicesListResponse listDevices(DevicesListRequest request) { + SyncClient syncClient = new SyncClient(); + String[] responseArray = syncClient.get(configParameters.getDevicesURLExtension(), request.getParamsForList()); + int responseCode = Integer.parseInt(responseArray[0]); + if (responseCode == 200) { + DevicesListResponse devicesListResponse = DevicesListResponse.Builder.newBuilder() + .buildResponse(responseArray[2]).build(); + // deviceObj.loadFromString(responseArray[2]); + return devicesListResponse; + } + return null; + } + public DevicesListResponse asyncListDevices(DevicesListRequest request) { + try { + AsyncClient asyncClient = new AsyncClient(); + String[] responseArray = asyncClient.asyncListDevices(configParameters.getDevicesURLExtension(), request.getParamsForList()); + int responseCode = Integer.parseInt(responseArray[0]); + if (responseCode == 200) { + DevicesListResponse devicesListResponse = DevicesListResponse.Builder.newBuilder() + .buildResponse(responseArray[2]).build(); + // deviceObj.loadFromString(responseArray[2]); + return devicesListResponse; + } + }catch(Exception e) { + e.printStackTrace(); + } + return null; + } + +} diff --git a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/DeviceManagerAsyncClient.java b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/DeviceManagerAsyncClient.java new file mode 100644 index 00000000..19799070 --- /dev/null +++ b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/DeviceManagerAsyncClient.java @@ -0,0 +1,129 @@ +package com.clearblade.cloud.iot.v1; + +import java.util.logging.Logger; + +import com.clearblade.cloud.iot.v1.binddevicetogateway.BindDeviceToGatewayRequest; +import com.clearblade.cloud.iot.v1.binddevicetogateway.BindDeviceToGatewayResponse; +import com.clearblade.cloud.iot.v1.createdevice.CreateDeviceRequest; +import com.clearblade.cloud.iot.v1.deletedevice.DeleteDeviceRequest; +import com.clearblade.cloud.iot.v1.deviceslist.DevicesListRequest; +import com.clearblade.cloud.iot.v1.deviceslist.DevicesListResponse; +import com.clearblade.cloud.iot.v1.devicestateslist.ListDeviceStatesRequest; +import com.clearblade.cloud.iot.v1.devicestateslist.ListDeviceStatesResponse; +import com.clearblade.cloud.iot.v1.getdevice.GetDeviceRequest; +import com.clearblade.cloud.iot.v1.getdeviceregistry.GetDeviceRegistryRequest; +import com.clearblade.cloud.iot.v1.modifycloudtodeviceconfig.ModifyCloudToDeviceConfigRequest; +import com.clearblade.cloud.iot.v1.sendcommandtodevice.SendCommandToDeviceRequest; +import com.clearblade.cloud.iot.v1.sendcommandtodevice.SendCommandToDeviceResponse; +import com.clearblade.cloud.iot.v1.unbinddevicefromgateway.UnbindDeviceFromGatewayRequest; +import com.clearblade.cloud.iot.v1.unbinddevicefromgateway.UnbindDeviceFromGatewayResponse; +import com.clearblade.cloud.iot.v1.updatedevice.UpdateDeviceRequest; +import com.clearblade.cloud.iot.v1.utils.Device; +import com.clearblade.cloud.iot.v1.utils.DeviceConfig; +import com.clearblade.cloud.iot.v1.utils.DeviceRegistry; + +public class DeviceManagerAsyncClient { + + static Logger log = Logger.getLogger(DeviceManagerAsyncClient.class.getName()); + + /** + * Calling getDevice api + * + * @param request + * @return Device object + */ + + public Device getDevice(GetDeviceRequest request) { + ClearBladeDeviceManager cbManager = new ClearBladeDeviceManager(); + return cbManager.asyncGetDevice(request); + } + + /** + * Calling createDevice api + * + * @param request + * @return Device object + */ + public Device createDevice(CreateDeviceRequest request) { + ClearBladeDeviceManager cbManager = new ClearBladeDeviceManager(); + return cbManager.asyncCreateDevice(request); + } + + /** + * Calling deleteDevice api + * + * @param request + */ + public void deleteDevice(DeleteDeviceRequest request) { + ClearBladeDeviceManager cbManager = new ClearBladeDeviceManager(); + cbManager.asyncDeleteDevice(request); + } + + /** + * Calling updateDevice api + * @param request + * @return Device object + */ + public Device updateDevice(UpdateDeviceRequest request) { + ClearBladeDeviceManager cbManager = new ClearBladeDeviceManager(); + return cbManager.asyncUpdateDevice(request); + } + + /** + * Calling bindDeviceToGateway api + * + * @param request + * @return + */ + public BindDeviceToGatewayResponse bindDeviceToGateway(BindDeviceToGatewayRequest request) { + ClearBladeDeviceManager cbManager = new ClearBladeDeviceManager(); + return cbManager.asyncBindDeviceToGateway(request); + } + + /** + * Calling unbindDeviceFromGateway api + * + * @param request + * @return + */ + public UnbindDeviceFromGatewayResponse unbindDeviceFromGateway(UnbindDeviceFromGatewayRequest request) { + ClearBladeDeviceManager cbManager = new ClearBladeDeviceManager(); + return cbManager.asyncUnbindDeviceFromGateway(request); + } + + public SendCommandToDeviceResponse sendCommandToDevice(SendCommandToDeviceRequest request) { + ClearBladeDeviceManager cbManager = new ClearBladeDeviceManager(); + return cbManager.asyncSendCommandToDevice(request); + + } + + public DeviceConfig modifyCloudToDeviceConfig(ModifyCloudToDeviceConfigRequest request) { + ClearBladeDeviceManager cbManager = new ClearBladeDeviceManager(); + return cbManager.asyncModifyCloudToDeviceConfig(request); + } + + public DevicesListResponse listDevices(DevicesListRequest request) { + ClearBladeDeviceManager cbManager = new ClearBladeDeviceManager(); + return cbManager.asyncListDevices(request); + } + + public ListDeviceStatesResponse listDeviceStates(ListDeviceStatesRequest request) { + ClearBladeDeviceManager cbManager = new ClearBladeDeviceManager(); + return cbManager.asyncListDeviceStates(request); + } + + //Registry Apis + /** + * Calling getDevice api + * + * @param request + * @return Device object + */ + + public DeviceRegistry getDeviceRegistry(GetDeviceRegistryRequest request) { + ClearBladeRegistryManager cbManager = new ClearBladeRegistryManager(); + return cbManager.asyncGetDeviceRegistry(request); + } + + +} diff --git a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/DeviceManagerClient.java b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/DeviceManagerClient.java index 5be3471d..c7687436 100644 --- a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/DeviceManagerClient.java +++ b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/DeviceManagerClient.java @@ -1,269 +1,130 @@ package com.clearblade.cloud.iot.v1; +import java.util.logging.Logger; + import com.clearblade.cloud.iot.v1.binddevicetogateway.BindDeviceToGatewayRequest; import com.clearblade.cloud.iot.v1.binddevicetogateway.BindDeviceToGatewayResponse; import com.clearblade.cloud.iot.v1.createdevice.CreateDeviceRequest; -import com.clearblade.cloud.iot.v1.createdevice.CreateDeviceResponse; +import com.clearblade.cloud.iot.v1.createdeviceregistry.CreateDeviceRegistryRequest; +import com.clearblade.cloud.iot.v1.createdeviceregistry.CreateDeviceRegistryResponse; import com.clearblade.cloud.iot.v1.deletedevice.DeleteDeviceRequest; -import com.clearblade.cloud.iot.v1.deletedevice.DeleteDeviceResponse; -import com.clearblade.cloud.iot.v1.deviceconfigversionslist.DeviceConfigVersionsListRequest; -import com.clearblade.cloud.iot.v1.deviceconfigversionslist.DeviceConfigVersionsListResponse; -import com.clearblade.cloud.iot.v1.devicepatch.DevicePatchRequest; -import com.clearblade.cloud.iot.v1.devicepatch.DevicePatchResponse; import com.clearblade.cloud.iot.v1.deviceslist.DevicesListRequest; import com.clearblade.cloud.iot.v1.deviceslist.DevicesListResponse; -import com.clearblade.cloud.iot.v1.devicestateslist.DeviceStatesListRequest; -import com.clearblade.cloud.iot.v1.devicestateslist.DeviceStatesListResponse; +import com.clearblade.cloud.iot.v1.devicestateslist.ListDeviceStatesRequest; +import com.clearblade.cloud.iot.v1.devicestateslist.ListDeviceStatesResponse; import com.clearblade.cloud.iot.v1.getdevice.GetDeviceRequest; -import com.clearblade.cloud.iot.v1.getdevice.GetDeviceResponse; +import com.clearblade.cloud.iot.v1.getdeviceregistry.GetDeviceRegistryRequest; import com.clearblade.cloud.iot.v1.modifycloudtodeviceconfig.ModifyCloudToDeviceConfigRequest; -import com.clearblade.cloud.iot.v1.modifycloudtodeviceconfig.ModifyCloudToDeviceConfigResponse; import com.clearblade.cloud.iot.v1.sendcommandtodevice.SendCommandToDeviceRequest; import com.clearblade.cloud.iot.v1.sendcommandtodevice.SendCommandToDeviceResponse; import com.clearblade.cloud.iot.v1.unbinddevicefromgateway.UnbindDeviceFromGatewayRequest; import com.clearblade.cloud.iot.v1.unbinddevicefromgateway.UnbindDeviceFromGatewayResponse; +import com.clearblade.cloud.iot.v1.updatedevice.UpdateDeviceRequest; +import com.clearblade.cloud.iot.v1.updatedeviceregistry.UpdateDeviceRegistryRequest; +import com.clearblade.cloud.iot.v1.updatedeviceregistry.UpdateDeviceRegistryResponse; import com.clearblade.cloud.iot.v1.utils.Device; -import com.clearblade.cloud.iot.v1.utils.DeviceName; +import com.clearblade.cloud.iot.v1.utils.DeviceConfig; +import com.clearblade.cloud.iot.v1.utils.DeviceRegistry; import com.clearblade.cloud.iot.v1.utils.RegistryName; public class DeviceManagerClient { + static Logger log = Logger.getLogger(DeviceManagerClient.class.getName()); - /** - * Print the response for sendCommandToDevice - * - * @param request - * @return Response object - */ - public SendCommandToDeviceResponse sendCommandToDeviceAsync(SendCommandToDeviceRequest request) { - return (SendCommandToDeviceResponse.Builder.newBuilder().setSendCommandToDeviceRequest(request).build()); - } /** - * SendCommandToDevice method - * - * @param name - * @param binaryData - */ - public void sendCommandToDevice(DeviceName name, com.clearblade.cloud.iot.v1.utils.ByteString binaryData, - String subfolder) { - SendCommandToDeviceRequest request = SendCommandToDeviceRequest.Builder.newBuilder().setName(name) - .setBinaryData(binaryData).setSubfolder(subfolder).build(); - SendCommandToDeviceResponse response = this.sendCommandToDevice(request); - response.processRequest(request); - } - /** - * Print the response for sendCommandToDevice - * + * Calling getDevice api * @param request - * @return Response object - */ - public SendCommandToDeviceResponse sendCommandToDevice(SendCommandToDeviceRequest request) { - return (SendCommandToDeviceResponse.Builder.newBuilder().setSendCommandToDeviceRequest(request).build()); - } - - /** - * Method used to call createDevice api call - * - * @param parent - * @param device * @return Device object */ - public void createDevice(RegistryName parent, Device device) { - CreateDeviceRequest request = CreateDeviceRequest.Builder.newBuilder() - .setParent(parent == null ? null : parent).setDevice(device).build(); - CreateDeviceResponse response = this.createDevice(request); - response.processRequest(request); - } - - /** - * Method used to call deleteDevice api - * - * @param request - * @return Response Object - */ - public CreateDeviceResponse createDevice(CreateDeviceRequest request) { - return (CreateDeviceResponse.Builder.newBuilder().setCreateDeviceRequest(request).build()); - } - - public final void deleteDevice(DeviceName name) { - DeleteDeviceRequest request = DeleteDeviceRequest.Builder.newBuilder().setDeviceName(name == null ? null : name.toString()) - .build(); - deleteDevice(request); - } + + public Device getDevice(GetDeviceRequest request) { + ClearBladeDeviceManager cbManager = new ClearBladeDeviceManager(); + return cbManager.getDevice(request); + } /** - * Print the response for deleteDevice - * + * Calling createDevice api * @param request - * @return Response object - */ - public DeleteDeviceResponse deleteDevice(DeleteDeviceRequest request) { - return (DeleteDeviceResponse.Builder.newBuilder().setDeleteDeviceRequest(request).build()); - } - - /** - * Method used to call getDevice api - * @param name * @return Device object - */ - public void getDevice(DeviceName name) { - GetDeviceRequest request = GetDeviceRequest.Builder.newBuilder().setDeviceName(name == null ? null : name.toString()).build(); - getDevice(request); - } + */ + public Device createDevice(CreateDeviceRequest request) { + ClearBladeDeviceManager cbManager = new ClearBladeDeviceManager(); + return cbManager.createDevice(request); + } /** - * Print the response for getDevice - * + * Calling bindDeviceToGateway api * @param request - * @return Response object + * @return */ - public GetDeviceResponse getDevice(GetDeviceRequest request) { - return (GetDeviceResponse.Builder.newBuilder().setGetDeviceRequest(request).build()); + public BindDeviceToGatewayResponse bindDeviceToGateway(BindDeviceToGatewayRequest request) { + ClearBladeDeviceManager cbManager = new ClearBladeDeviceManager(); + return cbManager.bindDeviceToGateway(request); } /** - * Method used to call devicesList api - * @param parent - * @return Device object + * Calling unbindDeviceFromGateway api + * @param request + * @return */ - public void devicesList(RegistryName parent) { - DevicesListRequest request = DevicesListRequest.Builder.newBuilder().setParent(parent).build(); - devicesList(request); + public UnbindDeviceFromGatewayResponse unbindDeviceFromGateway(UnbindDeviceFromGatewayRequest request) { + ClearBladeDeviceManager cbManager = new ClearBladeDeviceManager(); + return cbManager.unbindDeviceFromGateway(request); } /** - * Print the response for deviceList - * + * Calling deleteDevice api * @param request - * @return Response object */ - public DevicesListResponse devicesList(DevicesListRequest request) { - return (DevicesListResponse.Builder.newBuilder().setDevicesListRequest(request).build()); + public void deleteDevice(DeleteDeviceRequest request) { + ClearBladeDeviceManager cbManager = new ClearBladeDeviceManager(); + cbManager.deleteDevice(request); } /** - * Method used to call deviceStatesList api - * @param parent + * Calling updateDevice api + * @param request * @return Device object - */ - public void deviceStatesList(String name, int numStates) { - DeviceStatesListRequest request = DeviceStatesListRequest.Builder.newBuilder().setName(name).setNumStates(numStates).build(); - deviceStatesList(request); - } + */ + public Device updateDevice(UpdateDeviceRequest request) { + ClearBladeDeviceManager cbManager = new ClearBladeDeviceManager(); + return cbManager.updateDevice(request); + } - /** - * Print the response for deviceStatesList - * - * @param request - * @return Response object - */ - public DeviceStatesListResponse deviceStatesList(DeviceStatesListRequest request) { - return (DeviceStatesListResponse.Builder.newBuilder().setDeviceStatesListRequest(request).build()); - } + public SendCommandToDeviceResponse sendCommandToDevice(SendCommandToDeviceRequest request) { + ClearBladeDeviceManager cbManager = new ClearBladeDeviceManager(); + return cbManager.sendCommandToDevice(request); - /** - * ModifyCloudToDeviceConfig method - * - * @param device object - * @param versionToUpdate - * @param binaryData - */ - public void modifyCloudToDeviceConfig(Device device, com.clearblade.cloud.iot.v1.utils.ByteString binaryData, String versionToUpdate) { - ModifyCloudToDeviceConfigRequest request = ModifyCloudToDeviceConfigRequest.Builder.newBuilder().setDevice(device) - .setBinaryData(binaryData).setVersionToUpdate(versionToUpdate).build(); - ModifyCloudToDeviceConfigResponse response = this.modifyCloudToDeviceConfig(request); - response.processRequest(request); - } - /** - * Print the response for ModifyCloudToDeviceConfig - * - * @param request - * @return Response object - */ - public ModifyCloudToDeviceConfigResponse modifyCloudToDeviceConfig(ModifyCloudToDeviceConfigRequest request) { - return (ModifyCloudToDeviceConfigResponse.Builder.newBuilder().setModifyCloudToDeviceConfigRequest(request).build()); } + public DevicesListResponse listDevices(DevicesListRequest request) { + ClearBladeDeviceManager cbManager = new ClearBladeDeviceManager(); + return cbManager.listDevices(request); - /** - * Method used to call DeviceConfigVersionsList api - * @param name and numVersions - */ - public void deviceConfigVersionsList(String name, String numVersions) { - DeviceConfigVersionsListRequest request = DeviceConfigVersionsListRequest.Builder.newBuilder().setName(name).setNumVersions(numVersions).build(); - deviceConfigVersionsList(request); } - /** - * Print the response for deviceConfigVersionsList - * - * @param request - * @return Response object - */ - public DeviceConfigVersionsListResponse deviceConfigVersionsList(DeviceConfigVersionsListRequest request) { - return (DeviceConfigVersionsListResponse.Builder.newBuilder().setDeviceConfigVersionsListRequest(request).build()); + public DeviceConfig modifyCloudToDeviceConfig(ModifyCloudToDeviceConfigRequest request) { + ClearBladeDeviceManager cbManager = new ClearBladeDeviceManager(); + return cbManager.modifyCloudToDeviceConfig(request); } - /** - * bindDeviceToGateway method - * @param parent - * @param gatewayId - * @param deviceId - */ - public void bindDeviceToGateway(String parent, String gatewayId, String deviceId) { - BindDeviceToGatewayRequest request = BindDeviceToGatewayRequest.Builder.newBuilder().setParent(parent).setGateway(gatewayId).setDevice(deviceId).build(); - BindDeviceToGatewayResponse response = this.bindDeviceToGateway(request); - response.processRequest(request); - } - /** - * Print the response for bindDeviceToGateway - * - * @param request - * @return Response object - */ - public BindDeviceToGatewayResponse bindDeviceToGateway(BindDeviceToGatewayRequest request) { - return (BindDeviceToGatewayResponse.Builder.newBuilder().setBindDeviceToGatewayRequest(request).build()); - } + public ListDeviceStatesResponse listDeviceStates(ListDeviceStatesRequest request) { + ClearBladeDeviceManager cbManager = new ClearBladeDeviceManager(); + return cbManager.listDeviceStates(request); - /** - * unbindDeviceFromGateway method - * @param parent - * @param gatewayId - * @param deviceId - */ - public void unbindDeviceFromGateway(String parent, String gatewayId, String deviceId) { - UnbindDeviceFromGatewayRequest request = UnbindDeviceFromGatewayRequest.Builder.newBuilder().setParent(parent).setGateway(gatewayId).setDevice(deviceId).build(); - UnbindDeviceFromGatewayResponse response = this.unbindDeviceFromGateway(request); - response.processRequest(request); - } - /** - * Print the response for unbindDeviceFromGateway - * @param request - * @return Response object - */ - public UnbindDeviceFromGatewayResponse unbindDeviceFromGateway(UnbindDeviceFromGatewayRequest request) { - return (UnbindDeviceFromGatewayResponse.Builder.newBuilder().setUnbindDeviceFromGatewayRequest(request).build()); } + //Registry Apis /** - * devicePatch method - * @param name - * @param updateMask - * @param device object - id, name, logLevel, blocked - */ - public void devicePatch(String name, String updateMask, Device device) { - DevicePatchRequest request = DevicePatchRequest.Builder.newBuilder().setName(name).setUpdateMask(updateMask).setDevice(device).build(); - DevicePatchResponse response = this.devicePatch(request); - response.processRequest(request); - } - /** - * Print the response for devicePatch + * Calling getDeviceRegistry api * @param request - * @return Response object + * @return DeviceRegistry object */ - public DevicePatchResponse devicePatch(DevicePatchRequest request) { - return (DevicePatchResponse.Builder.newBuilder().setDevicePatchRequest(request).build()); - } -} + public DeviceRegistry getDeviceRegistry(GetDeviceRegistryRequest request) { + ClearBladeRegistryManager cbManager = new ClearBladeRegistryManager(); + return cbManager.getRegistry(request); + } + +} diff --git a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/SyncClient.java b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/SyncClient.java new file mode 100644 index 00000000..c817ad20 --- /dev/null +++ b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/SyncClient.java @@ -0,0 +1,284 @@ +package com.clearblade.cloud.iot.v1; + +import java.io.BufferedReader; +import java.io.InputStreamReader; +import java.io.OutputStream; +import java.net.URL; + +import javax.net.ssl.HttpsURLConnection; + +import com.clearblade.cloud.iot.v1.utils.AuthParams; +import com.clearblade.cloud.iot.v1.utils.ConfigParameters; +import com.clearblade.cloud.iot.v1.utils.Constants; +import com.clearblade.cloud.iot.v1.utils.SetHttpConnection; + +public class SyncClient { + + private ConfigParameters configParameters = new ConfigParameters(); + + + /** + * Method used to generate URL for apicall + * @param apiName - path to api + * @param params - parameters to be attached to request + * @return URL formed and to be used + */ + private String generateURL(String apiName, String params) { + + return AuthParams.getApiBaseURL() + .concat(configParameters.getEndpointPort()) + .concat(configParameters.getBaseURL()) + .concat(AuthParams.getUserSystemKey()) + .concat(apiName) + .concat("?"+params); + } + + /** + * Method used to Calls HTTP Get request + * @param apiName + * @param params + * @return String[] containing responseCode, responseMessage and response object + */ + public String[] get(String apiName,String params) { + String[] responseArray = new String[3]; + AuthParams.setRegistryCredentials(); + try { + String finalURL = generateURL(apiName, params); + System.out.println(finalURL); + URL obj = new URL(finalURL); + SetHttpConnection setCon = new SetHttpConnection(); + HttpsURLConnection con = setCon.getConnection(obj); + con.setRequestProperty(Constants.HTTP_REQUEST_PROPERTY_TOKEN_KEY, AuthParams.getUserToken()); + con.setRequestProperty(Constants.HTTP_REQUEST_PROPERTY_CONTENT_TYPE_KEY, Constants.HTTP_REQUEST_PROPERTY_CONTENT_TYPE_ACCEPT_VALUE); + con.addRequestProperty(Constants.HTTP_REQUEST_PROPERTY_ACCEPT_KEY, Constants.HTTP_REQUEST_PROPERTY_CONTENT_TYPE_ACCEPT_VALUE); + con.setRequestMethod(Constants.HTTP_REQUEST_METHOD_TYPE_GET); + StringBuilder response = new StringBuilder(); + responseArray[0] = String.valueOf(con.getResponseCode()); + responseArray[1] = con.getResponseMessage(); + BufferedReader in = null; + if (con.getErrorStream() != null) { + in = new BufferedReader(new InputStreamReader(con.getErrorStream())); + } else if (con.getInputStream() != null) { + in = new BufferedReader(new InputStreamReader(con.getInputStream())); + } + String inputLine; + String responseMessage = ""; + if (in != null) { + while ((inputLine = in.readLine()) != null) { + response.append(inputLine); + } + responseMessage = response.toString(); + responseArray[2] = responseMessage; + } + }catch(Exception e) { + e.printStackTrace(); + } + + return responseArray; + } + + /** + * Method used to call HTTP Post request + * @param apiName + * @param params + * @param body + * @return String[] containing responseCode, responseMessage and response object + */ + public String[] post(String apiName,String params,String body) { + String[] responseArray = new String[3]; + AuthParams.setRegistryCredentials(); + + try { + String finalURL = generateURL(apiName, params); + System.out.println(finalURL); + URL obj = new URL(finalURL); + SetHttpConnection setCon = new SetHttpConnection(); + HttpsURLConnection con = setCon.getConnection(obj); + con.setRequestProperty(Constants.HTTP_REQUEST_PROPERTY_TOKEN_KEY, AuthParams.getUserToken()); + con.setRequestProperty(Constants.HTTP_REQUEST_PROPERTY_CONTENT_TYPE_KEY, Constants.HTTP_REQUEST_PROPERTY_CONTENT_TYPE_ACCEPT_VALUE); + con.addRequestProperty(Constants.HTTP_REQUEST_PROPERTY_ACCEPT_KEY, Constants.HTTP_REQUEST_PROPERTY_CONTENT_TYPE_ACCEPT_VALUE); + con.setRequestMethod(Constants.HTTP_REQUEST_METHOD_TYPE_POST); + con.setDoOutput(true); + StringBuilder response = new StringBuilder(); + OutputStream os = con.getOutputStream(); + byte[] input = body.getBytes(Constants.UTF8); + os.write(input, 0, input.length); + os.flush(); + responseArray[0] = String.valueOf(con.getResponseCode()); + responseArray[1] = con.getResponseMessage(); + BufferedReader in = null; + if (con.getErrorStream() != null) { + in = new BufferedReader(new InputStreamReader(con.getErrorStream())); + } else if (con.getInputStream() != null) { + in = new BufferedReader(new InputStreamReader(con.getInputStream())); + } + String inputLine; + String responseMessage = ""; + if (in != null) { + while ((inputLine = in.readLine()) != null) { + response.append(inputLine); + } + responseMessage = response.toString(); + responseArray[2] = responseMessage; + } + }catch(Exception e) { + e.printStackTrace(); + } + + return responseArray; + } + + /** + * Method used to call HTTP delete request + * @param apiName + * @param params + * @return String[] containing responseCode, responseMessage and response object + */ + public String[] delete(String apiName,String params) { + String[] responseArray = new String[3]; + AuthParams.setRegistryCredentials(); + try { + String finalURL = generateURL(apiName, params); + System.out.println(finalURL); + URL obj = new URL(finalURL); + SetHttpConnection setCon = new SetHttpConnection(); + HttpsURLConnection con = setCon.getConnection(obj); + con.setRequestProperty(Constants.HTTP_REQUEST_PROPERTY_TOKEN_KEY, AuthParams.getUserToken()); + con.setRequestProperty(Constants.HTTP_REQUEST_PROPERTY_CONTENT_TYPE_KEY, Constants.HTTP_REQUEST_PROPERTY_CONTENT_TYPE_ACCEPT_VALUE); + con.addRequestProperty(Constants.HTTP_REQUEST_PROPERTY_ACCEPT_KEY, Constants.HTTP_REQUEST_PROPERTY_CONTENT_TYPE_ACCEPT_VALUE); + con.setRequestMethod(Constants.HTTP_REQUEST_METHOD_TYPE_DELETE); + StringBuilder response = new StringBuilder(); + responseArray[0] = String.valueOf(con.getResponseCode()); + responseArray[1] = con.getResponseMessage(); + BufferedReader in = null; + if (con.getErrorStream() != null) { + in = new BufferedReader(new InputStreamReader(con.getErrorStream())); + } else if (con.getInputStream() != null) { + in = new BufferedReader(new InputStreamReader(con.getInputStream())); + } + String inputLine; + String responseMessage = ""; + if (in != null) { + while ((inputLine = in.readLine()) != null) { + response.append(inputLine); + } + responseMessage = response.toString(); + responseArray[2] = responseMessage; + } + }catch(Exception e) { + e.printStackTrace(); + } + + return responseArray; + } + + /** + * Method used to call HTTP Patch request + * @param apiName + * @param params + * @param body + * @return String[] containing responseCode, responseMessage and response object + */ + public String[] patch(String apiName,String params,String body) { + String[] responseArray = new String[3]; + AuthParams.setRegistryCredentials(); + + try { + String finalURL = generateURL(apiName, params); + System.out.println(finalURL); + URL obj = new URL(finalURL); + SetHttpConnection setCon = new SetHttpConnection(); + HttpsURLConnection con = setCon.getConnection(obj); + con.setRequestProperty(Constants.HTTP_REQUEST_PROPERTY_TOKEN_KEY, AuthParams.getUserToken()); + con.setRequestProperty(Constants.HTTP_REQUEST_PROPERTY_CONTENT_TYPE_KEY, Constants.HTTP_REQUEST_PROPERTY_CONTENT_TYPE_ACCEPT_VALUE); + con.addRequestProperty(Constants.HTTP_REQUEST_PROPERTY_ACCEPT_KEY, Constants.HTTP_REQUEST_PROPERTY_CONTENT_TYPE_ACCEPT_VALUE); + con.setRequestMethod(Constants.HTTP_REQUEST_METHOD_TYPE_POST); + con.setRequestProperty("X-HTTP-Method-Override", Constants.HTTP_REQUEST_METHOD_TYPE_PATCH); + con.setDoOutput(true); + StringBuilder response = new StringBuilder(); + OutputStream os = con.getOutputStream(); + byte[] input = body.getBytes(Constants.UTF8); + os.write(input, 0, input.length); + os.flush(); + responseArray[0] = String.valueOf(con.getResponseCode()); + responseArray[1] = con.getResponseMessage(); + BufferedReader in = null; + if (con.getErrorStream() != null) { + in = new BufferedReader(new InputStreamReader(con.getErrorStream())); + } else if (con.getInputStream() != null) { + in = new BufferedReader(new InputStreamReader(con.getInputStream())); + } + String inputLine; + String responseMessage = ""; + if (in != null) { + while ((inputLine = in.readLine()) != null) { + response.append(inputLine); + } + responseMessage = response.toString(); + responseArray[2] = responseMessage; + } + }catch(Exception e) { + e.printStackTrace(); + } + + return responseArray; + } + + /** + * Method used to generate URL for apicall + * @param apiName - path to api + * @param params - parameters to be attached to request + * @return URL formed and to be used + */ + private String generateAdminURL(String apiName, String params) { + + return AuthParams.getBaseURL() + .concat(configParameters.getBaseURL()) + .concat(AuthParams.getUserSystemKey()) + .concat(apiName) + .concat("?"+params); + } + /** + * Method used to Calls HTTP Get request + * @param apiName + * @param params + * @return String[] containing responseCode, responseMessage and response object + */ + public String[] getRegistry(String apiName,String params) { + String[] responseArray = new String[3]; + AuthParams.setRegistryCredentials(); + try { + String finalURL = generateAdminURL(apiName, params); + System.out.println(finalURL); + URL obj = new URL(finalURL); + SetHttpConnection setCon = new SetHttpConnection(); + HttpsURLConnection con = setCon.getConnection(obj); + con.setRequestProperty(Constants.HTTP_REQUEST_PROPERTY_TOKEN_KEY, AuthParams.getUserToken()); + con.setRequestProperty(Constants.HTTP_REQUEST_PROPERTY_CONTENT_TYPE_KEY, Constants.HTTP_REQUEST_PROPERTY_CONTENT_TYPE_ACCEPT_VALUE); + con.addRequestProperty(Constants.HTTP_REQUEST_PROPERTY_ACCEPT_KEY, Constants.HTTP_REQUEST_PROPERTY_CONTENT_TYPE_ACCEPT_VALUE); + con.setRequestMethod(Constants.HTTP_REQUEST_METHOD_TYPE_GET); + StringBuilder response = new StringBuilder(); + responseArray[0] = String.valueOf(con.getResponseCode()); + responseArray[1] = con.getResponseMessage(); + BufferedReader in = null; + if (con.getErrorStream() != null) { + in = new BufferedReader(new InputStreamReader(con.getErrorStream())); + } else if (con.getInputStream() != null) { + in = new BufferedReader(new InputStreamReader(con.getInputStream())); + } + String inputLine; + String responseMessage = ""; + if (in != null) { + while ((inputLine = in.readLine()) != null) { + response.append(inputLine); + } + responseMessage = response.toString(); + responseArray[2] = responseMessage; + } + }catch(Exception e) { + e.printStackTrace(); + } + + return responseArray; + } +} diff --git a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/binddevicetogateway/BindDeviceToGatewayRequest.java b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/binddevicetogateway/BindDeviceToGatewayRequest.java index fbe6b496..2e979ab3 100644 --- a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/binddevicetogateway/BindDeviceToGatewayRequest.java +++ b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/binddevicetogateway/BindDeviceToGatewayRequest.java @@ -37,7 +37,7 @@ public Builder setParent(String parent) { this.parent = parent; return this; } - + public Builder setGateway(String gateway) { this.gateway = gateway; return this; @@ -47,7 +47,7 @@ public Builder setDevice(String device) { this.device = device; return this; } - + // build method to deal with outer class // to return outer instance public BindDeviceToGatewayRequest build() { @@ -62,7 +62,7 @@ public JSONObject getRequestParams() { public void setRequestParams(JSONObject requestParams) { this.requestParams = requestParams; } - + public JSONObject getBodyParams() { return bodyParams; } @@ -70,6 +70,7 @@ public JSONObject getBodyParams() { public void setBodyParams(JSONObject bodyParams) { this.bodyParams = bodyParams; } + @SuppressWarnings("unchecked") @Override public String toString() { @@ -78,14 +79,27 @@ public String toString() { String method = Constants.BIND_DEVICE_TO_GATEWAY; requestParams.put("method", method); requestParams.put("parent", this.parent); - + bodyParams.put("gatewayId", this.gateway); bodyParams.put("deviceId", this.device); - + this.setRequestParams(requestParams); this.setBodyParams(bodyParams); - - return "parent=" + this.parent + ",gateway=" + this.gateway+", device= "+this.device; + + return "parent=" + this.parent + ",gateway=" + this.gateway + ", device= " + this.device; + } + + @SuppressWarnings("unchecked") + public String[] getBodyAndParams() { + String[] output = new String[2]; + String params = "parent=" + this.parent + "&method=" + Constants.BIND_DEVICE_TO_GATEWAY; + bodyParams = new JSONObject(); + bodyParams.put("gatewayId", this.gateway); + bodyParams.put("deviceId", this.device); + + output[0] = params; + output[1] = bodyParams.toJSONString(); + return output; } } diff --git a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/createdevice/CreateDeviceRequest.java b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/createdevice/CreateDeviceRequest.java index 657d72ea..f8c09404 100644 --- a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/createdevice/CreateDeviceRequest.java +++ b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/createdevice/CreateDeviceRequest.java @@ -1,25 +1,15 @@ package com.clearblade.cloud.iot.v1.createdevice; -import java.util.Collections; - -import org.json.simple.JSONObject; - import com.clearblade.cloud.iot.v1.utils.Device; import com.clearblade.cloud.iot.v1.utils.RegistryName; public class CreateDeviceRequest { private final RegistryName parent; private final Device device; - private final String subfolder; - private final String[] deviceNumIds; - public JSONObject requestParams; - public JSONObject bodyParams; private CreateDeviceRequest(Builder builder) { this.parent = builder.parent; this.device = builder.device; - this.deviceNumIds = builder.deviceNumIds; - this.subfolder = builder.subfolder; } // Static class Builder @@ -28,8 +18,6 @@ public static class Builder { /// instance fields private RegistryName parent; private Device device; - private String subfolder; - private String[] deviceNumIds; public static Builder newBuilder() { return new Builder(); @@ -49,16 +37,6 @@ public Builder setDevice(Device device) { return this; } - public Builder setDeviceNumIds(String[] numIds) { - this.deviceNumIds = numIds; - return this; - } - - public Builder setSubfolder(String subfolder) { - this.subfolder = subfolder; - return this; - } - // build method to deal with outer class // to return outer instance public CreateDeviceRequest build() { @@ -66,76 +44,10 @@ public CreateDeviceRequest build() { } } - public JSONObject getRequestParams() { - return requestParams; - } - - public void setRequestParams(JSONObject requestParams) { - this.requestParams = requestParams; + public String[] getParams() { + String[] params = new String[2]; + params[0] = "parent="+this.parent.getRegistryFullName(); + params[1] = this.device.createDeviceJSONObject(); + return params; } - - public JSONObject getBodyParams() { - return bodyParams; - } - - public void setBodyParams(JSONObject bodyParams) { - this.bodyParams = bodyParams; - } - - @SuppressWarnings("unchecked") - @Override - public String toString() { - requestParams = new JSONObject(); - bodyParams = new JSONObject(); - String emptyStr = "EMPTY"; - - // if(this.parent != null) { bodyParams.put("parent",parent.getRegistry()); } - - if (this.device != null) { - - bodyParams.put("id", this.device.toBuilder().getId()); - bodyParams.put("name", this.device.toBuilder().getName()); - bodyParams.put("numId", this.device.toBuilder().getNumId()); - - bodyParams.put("credentials", Collections.emptyList()); - bodyParams.put("lastErrorStatus", this.device.toBuilder().getLastErrorStatus()); - bodyParams.put("config", this.device.toBuilder().getConfig()); - bodyParams.put("state", this.device.toBuilder().getState()); - bodyParams.put("logLevel", this.device.toBuilder().getLogLevel()); - bodyParams.put("metadata", this.device.toBuilder().getMetadata()); - bodyParams.put("gatewayConfig", this.device.toBuilder().getGatewayConfig()); - - } else { - bodyParams.put("device", emptyStr); - } - - String numIdStr = ""; - if (this.deviceNumIds != null) { - for (int i = 0; i < deviceNumIds.length; i++) { - if (i == 0) { - numIdStr = numIdStr.concat(deviceNumIds[i]); - } - if (i > 0) { - numIdStr = numIdStr.concat("," + deviceNumIds[i]); - } - } - } - requestParams.put("deviceNumIds", numIdStr); - String subfolderStr = ""; - if (this.subfolder != null) { - subfolderStr = subfolderStr.concat(subfolder); - } else { - subfolderStr = subfolderStr.concat(emptyStr); - } - requestParams.put("subfolder", subfolderStr); - - this.setBodyParams(bodyParams); - this.setRequestParams(requestParams); - if (this.device != null) { - return this.parent + ", " + this.device.toString(); - } else { - return emptyStr; - } - } - } diff --git a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/createdevice/CreateDeviceResponse.java b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/createdevice/CreateDeviceResponse.java index 12785de7..4d31aa37 100644 --- a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/createdevice/CreateDeviceResponse.java +++ b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/createdevice/CreateDeviceResponse.java @@ -60,34 +60,6 @@ public CreateDeviceResponse build() { } } - /** - * Mehtod used to process the request Calling processRequestForMethod - - * CreateDevice - */ - public void processRequest(CreateDeviceRequest request) { - String msg = ""; - JSONObject requestParams = new JSONObject(); - JSONObject bodyParams = new JSONObject(); - ProcessRequest processRequest = new ProcessRequest(); - if(request != null) { - String logMsg = "Sending request to device :: "+request.toString(); - log.log(Level.INFO,logMsg); - requestParams = (JSONObject) request.requestParams.clone(); - bodyParams = (JSONObject) request.bodyParams.clone(); - } - String responseMessage = processRequest.processRequestForMethod("createDevice",requestParams,bodyParams); - this.setHttpStatusResponse(responseMessage); - if (responseMessage.equals("OK")) { - this.setHttpStatusCode(200); - msg = "Request processed for CreateDevice method"; - log.log(Level.INFO, msg); - } else { - this.setHttpStatusCode(0); - msg = "Request for CreateDevice failed \n" .concat(responseMessage); - log.log(Level.SEVERE, msg); - } - } - @Override public String toString() { return "Http Status Code :: " + this.getHttpStatusCode() + " Http Status Response :: " diff --git a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/deletedevice/DeleteDeviceRequest.java b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/deletedevice/DeleteDeviceRequest.java index fcfcd75c..f02f6c10 100644 --- a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/deletedevice/DeleteDeviceRequest.java +++ b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/deletedevice/DeleteDeviceRequest.java @@ -1,17 +1,28 @@ package com.clearblade.cloud.iot.v1.deletedevice; +import com.clearblade.cloud.iot.v1.utils.DeviceName; + public class DeleteDeviceRequest { - private final String deviceName; + private DeviceName name; private DeleteDeviceRequest(Builder builder) { - this.deviceName = builder.deviceName; + this.name = builder.name; + } + + + public DeviceName getName() { + return name; + } + + public void setName(DeviceName name) { + this.name = name; } // Static class Builder public static class Builder { /// instance fields - private String deviceName; + private DeviceName name; public static Builder newBuilder() { return new Builder(); @@ -20,22 +31,24 @@ public static Builder newBuilder() { private Builder() { } - // Setter methods - public Builder setDeviceName(String deviceName) { - this.deviceName = deviceName; - return this; - } - // build method to deal with outer class // to return outer instance public DeleteDeviceRequest build() { return new DeleteDeviceRequest(this); } + + // Setter methods + public Builder setName(DeviceName name) { + this.name = name; + return this; + } } @Override public String toString() { - return this.deviceName; + String params = ""; + params = "name="+this.name.toString(); + return params; } } diff --git a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/deviceslist/DevicesListRequest.java b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/deviceslist/DevicesListRequest.java index 77d5e1a0..884b1cb0 100644 --- a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/deviceslist/DevicesListRequest.java +++ b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/deviceslist/DevicesListRequest.java @@ -1,20 +1,39 @@ package com.clearblade.cloud.iot.v1.deviceslist; -import com.clearblade.cloud.iot.v1.utils.RegistryName; +import com.clearblade.cloud.iot.v1.utils.GatewayListOptions; public class DevicesListRequest { - - private final RegistryName parent; - + + private String parent; + private String deviceNumIds; + private String deviceIds; + private String fieldMask; + private int pageSize = -1; + private String pageToken; + private GatewayListOptions gatewayListOptions; + private DevicesListRequest(Builder builder) { this.parent = builder.parent; + this.deviceNumIds = builder.deviceNumIds; + this.deviceIds = builder.deviceIds; + this.fieldMask = builder.fieldMask; + this.pageSize = builder.pageSize; + this.pageToken = builder.pageToken; + this.gatewayListOptions = builder.gatewayListOptions; } // Static class Builder public static class Builder { /// instance fields - private RegistryName parent; + private String parent; + private String deviceNumIds; + private String deviceIds; + private String fieldMask; + private int pageSize; + private String pageToken; + private GatewayListOptions gatewayListOptions; + public static Builder newBuilder() { return new Builder(); } @@ -23,17 +42,47 @@ private Builder() { } // Setter methods - public Builder setParent(RegistryName parent) { + public Builder setParent(String parent) { this.parent = parent; return this; } + public Builder setDeviceNumIds(String deviceNumIds) { + this.deviceNumIds = deviceNumIds; + return this; + } + + public Builder setDeviceIds(String deviceIds) { + this.deviceIds = deviceIds; + return this; + } + + public Builder setFieldMask(String fieldMask) { + this.fieldMask = fieldMask; + return this; + } + + public Builder setPageSize(int pageSize) { + this.pageSize = pageSize; + return this; + } + + public Builder setPageToken(String pageToken) { + this.pageToken = pageToken; + return this; + } + + public Builder setGatewayListOptions(GatewayListOptions gatewayListOptions) { + this.gatewayListOptions = gatewayListOptions; + return this; + } + // build method to deal with outer class // to return outer instance public DevicesListRequest build() { return new DevicesListRequest(this); } - + } @Override @@ -41,4 +90,33 @@ public String toString() { return this.parent.toString(); } + public String getParamsForList() { + String params = ""; + params = "parent=" + this.parent; + if (this.deviceNumIds != null) + params += "&deviceNumIds=" + this.deviceNumIds; + if (this.deviceIds != null) + params += "&deviceIds=" + this.deviceIds; + if (this.fieldMask != null) + params += "&fieldMask=" + this.fieldMask; + if (this.pageSize > 0) + params += "&pageSize=" + String.valueOf(this.pageSize); + if (this.pageToken != null) + params += "&pageToken=" + this.pageToken; + if (this.gatewayListOptions != null) { + if (this.gatewayListOptions.getGatewayType() != null) { + params += "&gatewayListOptions.gatewayType=" + this.gatewayListOptions.getGatewayType().name(); + } else if (this.gatewayListOptions.getAssociationsDeviceId() != null) { + params += "&gatewayListOptions.associationsDeviceId=" + + this.gatewayListOptions.getAssociationsDeviceId(); + } else if (this.gatewayListOptions.getAssociationsGatewayId() != null) { + params += "&gatewayListOptions.associationsGatewayId=" + + this.gatewayListOptions.getAssociationsGatewayId(); + } + + } + + return params; + } + } diff --git a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/deviceslist/DevicesListResponse.java b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/deviceslist/DevicesListResponse.java index 6bdb0f70..8c9c326c 100644 --- a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/deviceslist/DevicesListResponse.java +++ b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/deviceslist/DevicesListResponse.java @@ -1,59 +1,83 @@ package com.clearblade.cloud.iot.v1.deviceslist; +import java.util.ArrayList; +import java.util.Iterator; import java.util.List; import java.util.logging.Level; import java.util.logging.Logger; +import org.json.simple.JSONArray; import org.json.simple.JSONObject; +import org.json.simple.parser.JSONParser; import com.clearblade.cloud.iot.v1.ProcessRequest; import com.clearblade.cloud.iot.v1.utils.Device; public class DevicesListResponse { - + static Logger log = Logger.getLogger(DevicesListResponse.class.getName()); - - private final DevicesListRequest request; - private int httpStatusCode; - private String httpStatusResponse; + + private String nextPageToken; private List devicesList; protected DevicesListResponse(Builder builder) { - this.request = builder.request; + this.devicesList = builder.devicesList; + this.nextPageToken = builder.nextPageToken; } - public int getHttpStatusCode() { - return httpStatusCode; + public String getNextPageToken() { + return nextPageToken; } - public void setHttpStatusCode(int httpStatusCode) { - this.httpStatusCode = httpStatusCode; + public void setNextPageToken(String nextPageToken) { + this.nextPageToken = nextPageToken; } - public String getHttpStatusResponse() { - return httpStatusResponse; + public List getDevicesList() { + return devicesList; } - public void setHttpStatusResponse(String httpStatusResponse) { - this.httpStatusResponse = httpStatusResponse; + public void setDevicesList(List devicesList) { + this.devicesList = devicesList; } - + // Static class Builder public static class Builder { /// instance fields - private DevicesListRequest request; + private String nextPageToken; + private List devicesList = new ArrayList<>(); public static Builder newBuilder() { return new Builder(); } - + private Builder() { } // Setter methods - public Builder setDevicesListRequest(DevicesListRequest request) { - this.request = request; + public Builder buildResponse(String jsonString) { + try { + JSONObject jsonObj = new JSONObject(); + JSONParser jsonParser = new JSONParser(); + jsonObj = (JSONObject) (jsonParser.parse(jsonString)); + + JSONArray devicesArray = (JSONArray) jsonObj.get("devices"); + @SuppressWarnings("rawtypes") + Iterator deviceIterate = devicesArray.iterator(); + while (deviceIterate.hasNext()) { + JSONObject deviceJson = (JSONObject) deviceIterate.next(); + Device deviceObj = Device.newBuilder().build(); + deviceObj.loadFromString(deviceJson.toString()); + devicesList.add(deviceObj); + } + + if (jsonObj.containsKey("nextPageToken")) + nextPageToken = (String) jsonObj.get("nextPageToken"); + + } catch (Exception e) { + e.printStackTrace(); + } return this; } @@ -64,49 +88,4 @@ public DevicesListResponse build() { } } - /** - * Mehtod used to process the request Calling processRequestForMethod - - * DevicesList - */ - @SuppressWarnings("unchecked") - public void processRequest(DevicesListRequest request) { - String msg = ""; - ProcessRequest processRequest = new ProcessRequest(); - JSONObject requestParams = new JSONObject(); - JSONObject bodyParams = new JSONObject(); - if(request != null) { - requestParams.put("parent", request.toString()); - requestParams.put("fieldMask", "EMPTY"); - } - String responseMessage = processRequest.processRequestForMethod("devicesList", requestParams, bodyParams); - this.setHttpStatusResponse(responseMessage); - if (responseMessage.equals("OK")) { - this.setHttpStatusCode(200); - msg = "Request processed for DevicesList method"; - - log.log(Level.INFO, msg); - } else { - this.setHttpStatusCode(0); - msg = "Request for DevicesList failed \n" .concat(responseMessage); - log.log(Level.SEVERE, msg); - } - } - - @Override - public String toString() { - return "Http Status Code :: " + this.getHttpStatusCode() + " Http Status Response :: " - + this.getHttpStatusResponse(); - } - - public DevicesListRequest getRequest() { - return request; - } - - public List getDevicesList() { - return devicesList; - } - - public void setDevicesList(List devicesList) { - this.devicesList = devicesList; - } -} +} \ No newline at end of file diff --git a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/devicestateslist/DeviceStatesListRequest.java b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/devicestateslist/ListDeviceStatesRequest.java similarity index 74% rename from clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/devicestateslist/DeviceStatesListRequest.java rename to clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/devicestateslist/ListDeviceStatesRequest.java index 6ae58549..1f602ab5 100644 --- a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/devicestateslist/DeviceStatesListRequest.java +++ b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/devicestateslist/ListDeviceStatesRequest.java @@ -2,14 +2,13 @@ import org.json.simple.JSONObject; -public class DeviceStatesListRequest { +public class ListDeviceStatesRequest { private final String name; private final String numStates; JSONObject requestParams; - - private DeviceStatesListRequest(Builder builder) { + private ListDeviceStatesRequest(Builder builder) { this.name = builder.name; this.numStates = builder.numStates; } @@ -20,7 +19,7 @@ public static class Builder { /// instance fields private String name; private String numStates; - + public static Builder newBuilder() { return new Builder(); } @@ -41,20 +40,20 @@ public Builder setNumStates(int numStates) { // build method to deal with outer class // to return outer instance - public DeviceStatesListRequest build() { - return new DeviceStatesListRequest(this); + public ListDeviceStatesRequest build() { + return new ListDeviceStatesRequest(this); } - + } public JSONObject getRequestParams() { return requestParams; } - + public void setRequestParams(JSONObject requestParams) { this.requestParams = requestParams; } - + @SuppressWarnings("unchecked") @Override public String toString() { @@ -62,6 +61,14 @@ public String toString() { requestParams.put("name", this.name); requestParams.put("numStates", this.numStates); this.setRequestParams(requestParams); - return "name="+this.name+",numStates="+this.numStates; + return "name=" + this.name + ",numStates=" + this.numStates; + } + + public String getParamsForList() { + String params = ""; + params = "name=" + this.name; + params += "&numStates=" + this.numStates; + + return params; } } diff --git a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/devicestateslist/ListDeviceStatesResponse.java b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/devicestateslist/ListDeviceStatesResponse.java new file mode 100644 index 00000000..6fdf2b4a --- /dev/null +++ b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/devicestateslist/ListDeviceStatesResponse.java @@ -0,0 +1,80 @@ +package com.clearblade.cloud.iot.v1.devicestateslist; + +import java.util.List; +import java.util.logging.Logger; +import java.util.ArrayList; +import java.util.Iterator; + +import org.json.simple.JSONArray; +import org.json.simple.JSONObject; +import org.json.simple.parser.JSONParser; + +import com.clearblade.cloud.iot.v1.utils.DeviceState; + +public class ListDeviceStatesResponse { + + static Logger log = Logger.getLogger(ListDeviceStatesResponse.class.getName()); + + private List deviceStatesList = new ArrayList<>(); + + protected ListDeviceStatesResponse(Builder builder) { + this.deviceStatesList = builder.deviceStatesList; + } + + // Static class Builder + public static class Builder { + + private List deviceStatesList = new ArrayList<>(); + + public static Builder newBuilder() { + return new Builder(); + } + + private Builder() { + } + + // build method to deal with outer class + // to return outer instance + public ListDeviceStatesResponse build() { + return new ListDeviceStatesResponse(this); + } + + public Builder buildResponse(String stateList) { + try { + JSONObject jsonObj = new JSONObject(); + JSONParser jsonParser = new JSONParser(); + jsonObj = (JSONObject) (jsonParser.parse(stateList)); + + JSONArray stateArray = (JSONArray) jsonObj.get("deviceStates"); + @SuppressWarnings("rawtypes") + Iterator stateIterator = stateArray.iterator(); + while (stateIterator.hasNext()) { + JSONObject stateJson = (JSONObject) stateIterator.next(); + DeviceState stateObj = DeviceState.newBuilder().setBinaryData((String) stateJson.get("binaryData")) + .setUpdateTime((String) stateJson.get("updateTime")) + .build(); + deviceStatesList.add(stateObj); + } + + } catch (Exception e) { + e.printStackTrace(); + } + return this; + + } + + } + + @Override + public String toString() { + return ""; + } + + public List getDeviceStatesList() { + return deviceStatesList; + } + + public void setDeviceStatesList(List deviceStatesList) { + this.deviceStatesList = deviceStatesList; + } +} diff --git a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/getdevice/GetDeviceRequest.java b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/getdevice/GetDeviceRequest.java index 3c234992..738864a9 100644 --- a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/getdevice/GetDeviceRequest.java +++ b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/getdevice/GetDeviceRequest.java @@ -1,18 +1,24 @@ package com.clearblade.cloud.iot.v1.getdevice; +import com.clearblade.cloud.iot.v1.utils.DeviceName; +import com.clearblade.cloud.iot.v1.utils.FieldMask; + public class GetDeviceRequest { - private final String deviceName; - + private final DeviceName name; + private final FieldMask fieldMask; + private GetDeviceRequest(Builder builder) { - this.deviceName = builder.deviceName; + this.name = builder.name; + this.fieldMask = builder.fieldMask; } // Static class Builder public static class Builder { /// instance fields - private String deviceName; + private DeviceName name; + private FieldMask fieldMask; public static Builder newBuilder() { return new Builder(); @@ -22,8 +28,20 @@ private Builder() { } // Setter methods - public Builder setDeviceName(String deviceName) { - this.deviceName = deviceName; + public FieldMask getFieldMask() { + return fieldMask; + } + + public Builder setFieldMask(FieldMask fieldMask) { + this.fieldMask = fieldMask; + return this; + } + public DeviceName getName() { + return name; + } + + public Builder setName(DeviceName name) { + this.name = name; return this; } @@ -36,7 +54,12 @@ public GetDeviceRequest build() { @Override public String toString() { - return this.deviceName; + String params = ""; + params = "name="+this.name.toString(); + if(this.fieldMask.toString() != "") { + params+= "&fieldMask="+this.fieldMask.toString(); + } + return params; } diff --git a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/getdeviceregistry/GetDeviceRegistryRequest.java b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/getdeviceregistry/GetDeviceRegistryRequest.java new file mode 100644 index 00000000..62fc56d7 --- /dev/null +++ b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/getdeviceregistry/GetDeviceRegistryRequest.java @@ -0,0 +1,42 @@ +package com.clearblade.cloud.iot.v1.getdeviceregistry; + +public class GetDeviceRegistryRequest { + + private final String name; + + private GetDeviceRegistryRequest(Builder builder) { + this.name = builder.name; + } + + // Static class Builder + public static class Builder { + + /// instance fields + private String name; + + public static Builder newBuilder() { + return new Builder(); + } + + private Builder() { + } + + // Setter methods + public Builder setName(String name) { + this.name = name; + return this; + } + + // build method to deal with outer class + // to return outer instance + public GetDeviceRegistryRequest build() { + return new GetDeviceRegistryRequest(this); + } + } + + @Override + public String toString() { + return "name="+this.name; + } + +} diff --git a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/devicestateslist/DeviceStatesListResponse.java b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/getdeviceregistry/GetDeviceRegistryResponse.java similarity index 56% rename from clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/devicestateslist/DeviceStatesListResponse.java rename to clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/getdeviceregistry/GetDeviceRegistryResponse.java index 2e576a74..ba15cd30 100644 --- a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/devicestateslist/DeviceStatesListResponse.java +++ b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/getdeviceregistry/GetDeviceRegistryResponse.java @@ -1,24 +1,24 @@ -package com.clearblade.cloud.iot.v1.devicestateslist; +package com.clearblade.cloud.iot.v1.getdeviceregistry; -import java.util.List; import java.util.logging.Level; import java.util.logging.Logger; import org.json.simple.JSONObject; import com.clearblade.cloud.iot.v1.ProcessRequest; -import com.clearblade.cloud.iot.v1.utils.DeviceState; +import com.clearblade.cloud.iot.v1.utils.Constants; +import com.clearblade.cloud.iot.v1.utils.RegistryName; -public class DeviceStatesListResponse { +public class GetDeviceRegistryResponse { - static Logger log = Logger.getLogger(DeviceStatesListResponse.class.getName()); + static Logger log = Logger.getLogger(GetDeviceRegistryResponse.class.getName()); - private final DeviceStatesListRequest request; + private final GetDeviceRegistryRequest request; private int httpStatusCode; private String httpStatusResponse; - private List deviceStatesList; - - protected DeviceStatesListResponse(Builder builder) { + private RegistryName registry; + + protected GetDeviceRegistryResponse(Builder builder) { this.request = builder.request; } @@ -37,12 +37,12 @@ public String getHttpStatusResponse() { public void setHttpStatusResponse(String httpStatusResponse) { this.httpStatusResponse = httpStatusResponse; } - + // Static class Builder public static class Builder { /// instance fields - private DeviceStatesListRequest request; + private GetDeviceRegistryRequest request; public static Builder newBuilder() { return new Builder(); @@ -52,60 +52,61 @@ private Builder() { } // Setter methods - public Builder setDeviceStatesListRequest(DeviceStatesListRequest request) { + public Builder setGetDeviceRegistryRequest(GetDeviceRegistryRequest request) { this.request = request; return this; } // build method to deal with outer class // to return outer instance - public DeviceStatesListResponse build() { - return new DeviceStatesListResponse(this); + public GetDeviceRegistryResponse build() { + return new GetDeviceRegistryResponse(this); } } + /** * Mehtod used to process the request Calling processRequestForMethod - - * DevicesList + * GetDeviceRegistry */ - public void processRequest(DeviceStatesListRequest request) { + @SuppressWarnings("unchecked") + public void processRequest(GetDeviceRegistryRequest request) { String msg = ""; ProcessRequest processRequest = new ProcessRequest(); JSONObject requestParams = new JSONObject(); - JSONObject bodyParams = new JSONObject(); + JSONObject bodyParams = new JSONObject(); if(request != null) { - log.log(Level.INFO,request.toString()); - requestParams = (JSONObject) request.requestParams.clone(); + requestParams.put("name", request.toString()); } - String responseMessage = processRequest.processRequestForMethod("deviceStatesList", requestParams, bodyParams); + String responseMessage = processRequest.processRequestForMethod(Constants.GET_DEVICE_REGISTRY, requestParams, bodyParams); this.setHttpStatusResponse(responseMessage); if (responseMessage.equals("OK")) { this.setHttpStatusCode(200); - msg = "Request processed for DeviceStatesList method"; + msg = "Request processed for GET_DEVICE_REGISTRY method"; log.log(Level.INFO, msg); } else { this.setHttpStatusCode(0); - msg = "Request for DeviceStatesList failed \n" .concat(responseMessage); + msg = "Request for GET_DEVICE_REGISTRY failed \n" .concat(responseMessage); log.log(Level.SEVERE, msg); } } - + @Override public String toString() { return "Http Status Code :: " + this.getHttpStatusCode() + " Http Status Response :: " + this.getHttpStatusResponse(); } - - public DeviceStatesListRequest getRequest() { + + public GetDeviceRegistryRequest getRequest() { return request; } - public List getDeviceStatesList() { - return deviceStatesList; + public RegistryName getRegistry() { + return registry; } - public void setDeviceStatesList(List deviceStatesList) { - this.deviceStatesList = deviceStatesList; + public void setRegistryName(RegistryName registryName) { + this.registry = registryName; } } diff --git a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/modifycloudtodeviceconfig/ModifyCloudToDeviceConfigRequest.java b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/modifycloudtodeviceconfig/ModifyCloudToDeviceConfigRequest.java index f5f9ebea..b44c8b83 100644 --- a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/modifycloudtodeviceconfig/ModifyCloudToDeviceConfigRequest.java +++ b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/modifycloudtodeviceconfig/ModifyCloudToDeviceConfigRequest.java @@ -6,19 +6,16 @@ import com.clearblade.cloud.iot.v1.utils.ByteString; import com.clearblade.cloud.iot.v1.utils.Constants; -import com.clearblade.cloud.iot.v1.utils.Device; public class ModifyCloudToDeviceConfigRequest { - - private final Device device; - private final String versionToUpdate; - private final ByteString binaryData; - private final byte[] binaryDataByte; - public JSONObject requestParams; - public JSONObject bodyParams; + + private String deviceName; + private String versionToUpdate; + private ByteString binaryData; + private byte[] binaryDataByte; private ModifyCloudToDeviceConfigRequest(Builder builder) { - this.device = builder.device; + this.deviceName = builder.deviceName; this.versionToUpdate = builder.versionToUpdate; this.binaryData = builder.binaryData; this.binaryDataByte = builder.binaryDataByte; @@ -28,11 +25,11 @@ private ModifyCloudToDeviceConfigRequest(Builder builder) { public static class Builder { /// instance fields - private Device device; + private String deviceName; private String versionToUpdate; private ByteString binaryData; private byte[] binaryDataByte; - + public static Builder newBuilder() { return new Builder(); } @@ -41,8 +38,8 @@ private Builder() { } // Setter methods - public Builder setDevice(Device device) { - this.device = device; + public Builder setName(String deviceName) { + this.deviceName = deviceName; return this; } @@ -56,7 +53,7 @@ public Builder setBinaryData(ByteString binaryData) { return this; } - public Builder setBinaryDataByte(byte[] binaryDataByte) { + public Builder setBinaryData(byte[] binaryDataByte) { this.binaryDataByte = binaryDataByte; return this; } @@ -68,55 +65,31 @@ public ModifyCloudToDeviceConfigRequest build() { } } - public JSONObject getRequestParams() { - return requestParams; - } - - public void setRequestParams(JSONObject requestParams) { - this.requestParams = requestParams; - } - - public JSONObject getBodyParams() { - return bodyParams; - } - - public void setBodyParams(JSONObject bodyParams) { - this.bodyParams = bodyParams; + @Override + public String toString() { + return "name = " + this.deviceName + ", versionToUpdate = " + this.versionToUpdate; } @SuppressWarnings("unchecked") - @Override - public String toString() { - requestParams = new JSONObject(); - bodyParams = new JSONObject(); - - String dName = ""; - String bData = null; - String versionToUpdateStr = "1"; - - if(this.device != null) { - dName = this.device.toBuilder().getName(); - } - if(this.binaryData != null) { + public String[] getBodyAndParams() { + String[] output = new String[2]; + String params = "name=" + this.deviceName + "&method=" + Constants.MODIFY_CLOUD_TO_DEVICE_CONFIG; + String bData = "EMPTY"; + if (this.binaryData != null) { bData = new String(this.binaryData.getBinaryDataArray()); - }else if(this.binaryDataByte != null) { - if(this.binaryDataByte.length == 0){ + } else if (this.binaryDataByte != null) { + if (this.binaryDataByte.length == 0) { bData = "EMPTY"; - }else { + } else { bData = Arrays.toString(this.binaryDataByte); } } - if(this.versionToUpdate != null) { - versionToUpdateStr = this.versionToUpdate; - } - String method = Constants.MODIFY_CLOUD_TO_DEVICE_CONFIG; - - requestParams.put("name", dName); - requestParams.put("method", method); + JSONObject bodyParams = new JSONObject(); bodyParams.put("binaryData", bData); - bodyParams.put("versionToUpdate", versionToUpdateStr); - - return "name = "+dName+", binaryData = "+bData+", versionToUpdate = "+versionToUpdate; - } + bodyParams.put("versionToUpdate", this.versionToUpdate); + output[0] = params; + output[1] = bodyParams.toJSONString(); + return output; + } } diff --git a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/modifycloudtodeviceconfig/ModifyCloudToDeviceConfigResponse.java b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/modifycloudtodeviceconfig/ModifyCloudToDeviceConfigResponse.java index 2cb931a1..9bdd2149 100644 --- a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/modifycloudtodeviceconfig/ModifyCloudToDeviceConfigResponse.java +++ b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/modifycloudtodeviceconfig/ModifyCloudToDeviceConfigResponse.java @@ -61,33 +61,6 @@ public ModifyCloudToDeviceConfigResponse build() { } } - /** - * Mehtod used to process the request Calling processRequestForMethod - - * ModifyCloudToDeviceConfig - */ - public void processRequest(ModifyCloudToDeviceConfigRequest request) { - String msg = ""; - JSONObject requestParams = new JSONObject(); - JSONObject bodyParams = new JSONObject(); - ProcessRequest processRequest = new ProcessRequest(); - if(request != null) { - String logMsg = "Modify Cloud To Device Config Request :: "+request.toString(); - log.log(Level.INFO,logMsg); - requestParams = (JSONObject) request.requestParams.clone(); - bodyParams = (JSONObject) request.bodyParams.clone(); - } - String responseMessage = processRequest.processRequestForMethod(Constants.MODIFY_CLOUD_TO_DEVICE_CONFIG,requestParams,bodyParams); - this.setHttpStatusResponse(responseMessage); - if (responseMessage.equals("OK")) { - this.setHttpStatusCode(200); - msg = "Request processed for MODIFY_CLOUD_TO_DEVICE_CONFIG method"; - log.log(Level.INFO, msg); - } else { - this.setHttpStatusCode(0); - msg = "Request for MODIFY_CLOUD_TO_DEVICE_CONFIG failed \n" .concat(responseMessage); - log.log(Level.SEVERE, msg); - } - } @Override public String toString() { diff --git a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/sendcommandtodevice/SendCommandToDeviceRequest.java b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/sendcommandtodevice/SendCommandToDeviceRequest.java index ed4e51f1..fedd7303 100644 --- a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/sendcommandtodevice/SendCommandToDeviceRequest.java +++ b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/sendcommandtodevice/SendCommandToDeviceRequest.java @@ -5,6 +5,7 @@ import org.json.simple.JSONObject; import com.clearblade.cloud.iot.v1.utils.ByteString; +import com.clearblade.cloud.iot.v1.utils.Constants; import com.clearblade.cloud.iot.v1.utils.DeviceName; public class SendCommandToDeviceRequest { @@ -18,7 +19,7 @@ public class SendCommandToDeviceRequest { public JSONObject bodyParams; private SendCommandToDeviceRequest(Builder builder) { - this.name = builder.name; + this.name = builder.name; this.binaryData = builder.binaryData; this.subfolder = builder.subfolder; this.binaryDataByte = builder.binaryDataByte; @@ -57,56 +58,78 @@ public Builder setBinaryDataByte(byte[] binaryDataByte) { this.binaryDataByte = binaryDataByte; return this; } - + public Builder setSubfolder(String subfolder) { this.subfolder = subfolder; return this; } - public Builder setDeviceName(String deviceName) { + public Builder setName(String deviceName) { this.deviceName = deviceName; return this; } - + // build method to deal with outer class // to return outer instance public SendCommandToDeviceRequest build() { return new SendCommandToDeviceRequest(this); } - } + } @SuppressWarnings("unchecked") @Override public String toString() { requestParams = new JSONObject(); bodyParams = new JSONObject(); - + String dName = ""; String bData = null; - - if(this.name != null) { + + if (this.name != null) { dName = this.name.getDevice(); - }else if(this.deviceName != null) { + } else if (this.deviceName != null) { dName = this.deviceName; } - if(this.binaryData != null) { + if (this.binaryData != null) { bData = new String(this.binaryData.getBinaryDataArray()); - }else if(this.binaryDataByte != null) { - if(this.binaryDataByte.length == 0){ + } else if (this.binaryDataByte != null) { + if (this.binaryDataByte.length == 0) { bData = "EMPTY"; - }else { + } else { bData = Arrays.toString(this.binaryDataByte); } } - + requestParams.put("name", dName); bodyParams.put("binaryData", bData); bodyParams.put("subfolder", subfolder); - - return "name = "+dName+", binaryData = "+bData+", subfolder = "+subfolder; - + + return "name = " + dName + ", binaryData = " + bData + ", subfolder = " + subfolder; + } - - + @SuppressWarnings("unchecked") + public String[] getBodyAndParams() { + String[] output = new String[2]; + String params = "name=" + this.deviceName + "&method=" + Constants.SEND_COMMAND_TO_DEVICE; + String bData = null; + if (this.binaryData != null) { + bData = new String(this.binaryData.getBinaryDataArray()); + } else if (this.binaryDataByte != null) { + if (this.binaryDataByte.length == 0) { + bData = "EMPTY"; + } else { + bData = Arrays.toString(this.binaryDataByte); + } + } + bodyParams = new JSONObject(); + bodyParams.put("binaryData", bData); + if (this.subfolder != null) { + bodyParams.put("subfolder", this.subfolder); + } + + output[0] = params; + output[1] = bodyParams.toJSONString(); + return output; + } } diff --git a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/test/DeviceManagerClientTest.java b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/test/DeviceManagerClientTest.java deleted file mode 100644 index 12c04ffb..00000000 --- a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/test/DeviceManagerClientTest.java +++ /dev/null @@ -1,123 +0,0 @@ -package com.clearblade.cloud.iot.v1.test; - -import java.util.logging.Logger; - -import org.junit.Assert; -import org.junit.Test; - -import com.clearblade.cloud.iot.v1.DeviceManagerClient; -import com.clearblade.cloud.iot.v1.createdevice.CreateDeviceRequest; -import com.clearblade.cloud.iot.v1.createdevice.CreateDeviceResponse; -import com.clearblade.cloud.iot.v1.sendcommandtodevice.SendCommandToDeviceRequest; -import com.clearblade.cloud.iot.v1.sendcommandtodevice.SendCommandToDeviceResponse; -import com.clearblade.cloud.iot.v1.utils.ByteString; -import com.clearblade.cloud.iot.v1.utils.Device; -import com.clearblade.cloud.iot.v1.utils.DeviceName; -import com.clearblade.cloud.iot.v1.utils.RegistryName; - -class DeviceManagerClientTest { - - static Logger log = Logger.getLogger(DeviceManagerClientTest.class.getName()); - DeviceManagerClient client = null; - String project; - String location; - String registry; - String name; - String bData; - - public void setUP() { - project = "ingressdevelopmentenv"; - location = "central1"; - registry = "Rashmi_Registry_Test"; - name = "Rashmi_Device_Test"; - bData = "c2VuZEZ1bm55TWVzc2FnZVRvRGV2aWNl"; - } - - - @Test - public void sendCommandToDeviceTestFail() { - setUP(); - client = new DeviceManagerClient(); - - DeviceName deviceName = DeviceName.of(project, location, registry, name); - ByteString binaryData = new ByteString(bData); - - SendCommandToDeviceRequest expectedRequest = SendCommandToDeviceRequest.Builder.newBuilder().setDeviceName(name) - .setBinaryData(binaryData).setSubfolder("").build(); - - SendCommandToDeviceResponse expectedResponse = SendCommandToDeviceResponse.Builder.newBuilder() - .setSendCommandToDeviceRequest(expectedRequest).build(); - - expectedResponse.setHttpStatusCode(200); - expectedResponse.setHttpStatusResponse("OK"); - - SendCommandToDeviceResponse actualResponse; - DeviceName actualDeviceName = DeviceName.of(project, location, registry, "Rashmi_Device"); - ByteString actualBinaryData = new ByteString(""); - SendCommandToDeviceRequest actualRequest = SendCommandToDeviceRequest.Builder.newBuilder() - .setName(actualDeviceName).setBinaryData(actualBinaryData).setSubfolder("").build(); - actualResponse = client.sendCommandToDevice(actualRequest); - actualResponse.processRequest(actualRequest); - - Assert.assertEquals(deviceName.getDevice(), actualDeviceName.getDevice()); - Assert.assertEquals(binaryData.getBinaryDataArray(), actualBinaryData.getBinaryDataArray()); - Assert.assertTrue((actualResponse.getHttpStatusResponse()).equals(expectedResponse.getHttpStatusResponse())); - } - - @Test - public void sendCommandToDeviceTestPass() { - DeviceName deviceName = DeviceName.of(project, location, registry, name); - ByteString binaryData = new ByteString(bData); - - SendCommandToDeviceRequest expectedRequest = SendCommandToDeviceRequest.Builder.newBuilder().setDeviceName(name) - .setBinaryData(binaryData).setSubfolder("").build(); - - SendCommandToDeviceResponse expectedResponse = SendCommandToDeviceResponse.Builder.newBuilder() - .setSendCommandToDeviceRequest(expectedRequest).build(); - - expectedResponse.setHttpStatusCode(200); - expectedResponse.setHttpStatusResponse("OK"); - - SendCommandToDeviceResponse actualResponse = SendCommandToDeviceResponse.Builder.newBuilder().build(); - DeviceName actualDeviceName = DeviceName.of(project, location, registry, name); - ByteString actualBinaryData = binaryData; - SendCommandToDeviceRequest actualRequest = SendCommandToDeviceRequest.Builder.newBuilder() - .setName(actualDeviceName).setBinaryData(actualBinaryData).setSubfolder("").build(); - actualResponse.processRequest(actualRequest); - - Assert.assertEquals(deviceName.getDevice(), actualDeviceName.getDevice()); - Assert.assertEquals(binaryData.getBinaryDataArray(), actualBinaryData.getBinaryDataArray()); - Assert.assertTrue((actualResponse.getHttpStatusResponse()).equals(expectedResponse.getHttpStatusResponse())); - } - - @Test - public void createDeviceTest() { - setUP(); - RegistryName expectedParent = RegistryName.of(project, location, "Rashmi_Registry"); - Device expectedDevice = - Device.newBuilder() - .setId("id3355") - .setName(DeviceName.of(project, location, registry, name).toString()) - .setNumId(-1034366860) - .build(); - CreateDeviceRequest expectedRequest = CreateDeviceRequest.Builder.newBuilder().setParent(expectedParent).setDevice(expectedDevice).build(); - CreateDeviceResponse expectedResponse = client.createDevice(expectedRequest); - - RegistryName parent = RegistryName.of(project, location, registry); - - Device device = Device.newBuilder().build(); - CreateDeviceRequest actualRequest = CreateDeviceRequest.Builder.newBuilder() - .setParent(parent).setDevice(device).build(); - CreateDeviceResponse actualResponse = client.createDevice(actualRequest); - - Assert.assertEquals(expectedResponse.getHttpStatusResponse(), actualResponse.getHttpStatusResponse()); - - Assert.assertEquals(expectedParent.getRegistry(), parent.getRegistry()); - Assert.assertEquals(expectedDevice, device); - Assert.assertTrue(actualResponse.getHttpStatusResponse().equals(expectedResponse.getHttpStatusResponse())); - } - - -} - - diff --git a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/unbinddevicefromgateway/UnbindDeviceFromGatewayRequest.java b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/unbinddevicefromgateway/UnbindDeviceFromGatewayRequest.java index 81ee7577..ac5abf6f 100644 --- a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/unbinddevicefromgateway/UnbindDeviceFromGatewayRequest.java +++ b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/unbinddevicefromgateway/UnbindDeviceFromGatewayRequest.java @@ -37,7 +37,7 @@ public Builder setParent(String parent) { this.parent = parent; return this; } - + public Builder setGateway(String gateway) { this.gateway = gateway; return this; @@ -47,7 +47,7 @@ public Builder setDevice(String device) { this.device = device; return this; } - + // build method to deal with outer class // to return outer instance public UnbindDeviceFromGatewayRequest build() { @@ -62,7 +62,7 @@ public JSONObject getRequestParams() { public void setRequestParams(JSONObject requestParams) { this.requestParams = requestParams; } - + public JSONObject getBodyParams() { return bodyParams; } @@ -70,6 +70,7 @@ public JSONObject getBodyParams() { public void setBodyParams(JSONObject bodyParams) { this.bodyParams = bodyParams; } + @SuppressWarnings("unchecked") @Override public String toString() { @@ -78,14 +79,27 @@ public String toString() { String method = Constants.UNBIND_DEVICE_FROM_GATEWAY; requestParams.put("method", method); requestParams.put("parent", this.parent); - + bodyParams.put("gatewayId", this.gateway); bodyParams.put("deviceId", this.device); - + this.setRequestParams(requestParams); this.setBodyParams(bodyParams); - - return "parent=" + this.parent + ",gateway=" + this.gateway+", device= "+this.device; + + return "parent=" + this.parent + ",gateway=" + this.gateway + ", device= " + this.device; + } + + @SuppressWarnings("unchecked") + public String[] getBodyAndParams() { + String[] output = new String[2]; + String params = "parent=" + this.parent + "&method=" + Constants.UNBIND_DEVICE_FROM_GATEWAY; + bodyParams = new JSONObject(); + bodyParams.put("gatewayId", this.gateway); + bodyParams.put("deviceId", this.device); + + output[0] = params; + output[1] = bodyParams.toJSONString(); + return output; } } diff --git a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/devicepatch/DevicePatchRequest.java b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/updatedevice/UpdateDeviceRequest.java similarity index 71% rename from clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/devicepatch/DevicePatchRequest.java rename to clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/updatedevice/UpdateDeviceRequest.java index 063e9cf2..ae7bf979 100644 --- a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/devicepatch/DevicePatchRequest.java +++ b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/updatedevice/UpdateDeviceRequest.java @@ -1,21 +1,36 @@ -package com.clearblade.cloud.iot.v1.devicepatch; +package com.clearblade.cloud.iot.v1.updatedevice; import org.json.simple.JSONObject; import com.clearblade.cloud.iot.v1.utils.Device; -public class DevicePatchRequest { +public class UpdateDeviceRequest { private final String name; private final Device device; private final String updateMask; JSONObject requestParams; JSONObject bodyParams; - private DevicePatchRequest(Builder builder) { + private UpdateDeviceRequest(Builder builder) { this.name = builder.name; this.updateMask = builder.updateMask; this.device = builder.device; } + public JSONObject getRequestParams() { + return requestParams; + } + + public void setRequestParams(JSONObject requestParams) { + this.requestParams = requestParams; + } + + public JSONObject getBodyParams() { + return bodyParams; + } + + public void setBodyParams(JSONObject bodyParams) { + this.bodyParams = bodyParams; + } // Static class Builder public static class Builder { @@ -50,31 +65,14 @@ public Builder setUpdateMask(String updateMask) { // build method to deal with outer class // to return outer instance - public DevicePatchRequest build() { - return new DevicePatchRequest(this); + public UpdateDeviceRequest build() { + return new UpdateDeviceRequest(this); } } - public JSONObject getRequestParams() { - return requestParams; - } - - public void setRequestParams(JSONObject requestParams) { - this.requestParams = requestParams; - } - - public JSONObject getBodyParams() { - return bodyParams; - } - - public void setBodyParams(JSONObject bodyParams) { - this.bodyParams = bodyParams; - } @SuppressWarnings("unchecked") @Override public String toString() { - requestParams = new JSONObject(); - bodyParams = new JSONObject(); requestParams.put("name", this.name); requestParams.put("updateMask", this.updateMask); @@ -83,10 +81,24 @@ public String toString() { bodyParams.put("logLevel", this.device.toBuilder().getLogLevel()); bodyParams.put("blocked", this.device.toBuilder().isBlocked()); - this.setRequestParams(requestParams); - this.setBodyParams(bodyParams); - return "name=" + this.name + ",updateMask=" + this.updateMask+", logLevel= "+this.device.toBuilder().getLogLevel(); } + + @SuppressWarnings("unchecked") + public String[] getBodyAndParams() { + String[] output = new String[2]; + + String params = "name="+this.name+"&updateMask="+this.updateMask; + bodyParams = new JSONObject(); + + bodyParams.put("id", this.device.toBuilder().getId()); + bodyParams.put("name", this.device.toBuilder().getName()); + bodyParams.put("logLevel", this.device.toBuilder().getLogLevel().toString()); + bodyParams.put("blocked", this.device.toBuilder().isBlocked()); + + output[0] = params; + output[1] = bodyParams.toString(); + return output; + } } diff --git a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/devicepatch/DevicePatchResponse.java b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/updatedevice/UpdateDeviceResponse.java similarity index 77% rename from clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/devicepatch/DevicePatchResponse.java rename to clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/updatedevice/UpdateDeviceResponse.java index 3367d51d..8ca7ca74 100644 --- a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/devicepatch/DevicePatchResponse.java +++ b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/updatedevice/UpdateDeviceResponse.java @@ -1,4 +1,4 @@ -package com.clearblade.cloud.iot.v1.devicepatch; +package com.clearblade.cloud.iot.v1.updatedevice; import java.util.logging.Level; import java.util.logging.Logger; @@ -8,14 +8,14 @@ import com.clearblade.cloud.iot.v1.ProcessRequest; import com.clearblade.cloud.iot.v1.utils.Constants; -public class DevicePatchResponse { +public class UpdateDeviceResponse { - static Logger log = Logger.getLogger(DevicePatchResponse.class.getName()); - private final DevicePatchRequest request; + static Logger log = Logger.getLogger(UpdateDeviceResponse.class.getName()); + private final UpdateDeviceRequest request; private int httpStatusCode; private String httpStatusResponse; - protected DevicePatchResponse(Builder builder) { + protected UpdateDeviceResponse(Builder builder) { this.request = builder.request; } @@ -39,7 +39,7 @@ public void setHttpStatusResponse(String httpStatusResponse) { public static class Builder { /// instance fields - private DevicePatchRequest request; + private UpdateDeviceRequest request; public static Builder newBuilder() { return new Builder(); @@ -49,15 +49,15 @@ private Builder() { } // Setter methods - public Builder setDevicePatchRequest(DevicePatchRequest request) { + public Builder setUpdateDeviceRequest(UpdateDeviceRequest request) { this.request = request; return this; } // build method to deal with outer class // to return outer instance - public DevicePatchResponse build() { - return new DevicePatchResponse(this); + public UpdateDeviceResponse build() { + return new UpdateDeviceResponse(this); } } @@ -65,7 +65,7 @@ public DevicePatchResponse build() { * Mehtod used to process the request Calling processRequestForMethod - * DevicePatch */ - public void processRequest(DevicePatchRequest request) { + public void processRequest(UpdateDeviceRequest request) { String msg = ""; JSONObject requestParams = new JSONObject(); JSONObject bodyParams = new JSONObject(); @@ -76,7 +76,7 @@ public void processRequest(DevicePatchRequest request) { requestParams = (JSONObject) request.requestParams.clone(); bodyParams = (JSONObject) request.bodyParams.clone(); } - String responseMessage = processRequest.processRequestForMethod(Constants.DEVICE_PATCH,requestParams,bodyParams); + String responseMessage = processRequest.processRequestForMethod(Constants.UPDATE_DEVICE,requestParams,bodyParams); this.setHttpStatusResponse(responseMessage); if (responseMessage.equals("OK")) { this.setHttpStatusCode(200); @@ -95,7 +95,7 @@ public String toString() { + this.getHttpStatusResponse(); } - public DevicePatchRequest getRequest() { + public UpdateDeviceRequest getRequest() { return request; } diff --git a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/utils/AuthParams.java b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/utils/AuthParams.java index 6822e4ac..8d585b00 100644 --- a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/utils/AuthParams.java +++ b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/utils/AuthParams.java @@ -1,37 +1,149 @@ package com.clearblade.cloud.iot.v1.utils; +import java.io.BufferedReader; +import java.io.FileReader; +import java.io.InputStreamReader; +import java.io.OutputStream; +import java.net.URL; +import java.util.logging.Level; +import java.util.logging.Logger; + +import javax.net.ssl.HttpsURLConnection; + +import org.json.simple.JSONObject; +import org.json.simple.parser.JSONParser; + public class AuthParams { + static Logger log = Logger.getLogger(AuthParams.class.getName()); - private String adminSystemKey; - private String project; - private String baseURL; - private String adminToken; - - public String getAdminSystemKey() { + private static String adminSystemKey = null; + private static String project = null; + private static String baseURL = null; + private static String adminToken = null; + private static String userSystemKey = null; + private static String userToken = null; + private static String apiBaseURL = null; + + public static String getAdminSystemKey() { return adminSystemKey; } - public void setAdminSystemKey(String adminSystemKey) { - this.adminSystemKey = adminSystemKey; - } - public String getProject() { + + public static String getProject() { return project; } - public void setProject(String project) { - this.project = project; - } - public String getBaseURL() { + + public static String getBaseURL() { return baseURL; } - public void setBaseURL(String baseURL) { - this.baseURL = baseURL; - } - public String getAdminToken() { + + public static String getAdminToken() { return adminToken; } - public void setAdminToken(String adminToken) { - this.adminToken = adminToken; + + public static String getUserSystemKey() { + return userSystemKey; + } + + public static String getUserToken() { + return userToken; + } + + public static String getApiBaseURL() { + return apiBaseURL; + } + + public static void setAdminCredentials() { + + if(adminSystemKey != null) { + return; + } + String pathToAuthFile = System.getenv(Constants.AUTH_ACCESS); + + JSONParser jsonParser = new JSONParser(); + try (FileReader authReader = new FileReader(pathToAuthFile)) { + // Read JSON file + Object obj = jsonParser.parse(authReader); + JSONObject authJSONObject = (JSONObject) obj; + if (authJSONObject != null) { + + adminSystemKey = (authJSONObject.get(Constants.ADMIN_SYSTEM_KEY)).toString(); + adminToken = (authJSONObject.get(Constants.ADMIN_TOKEN)).toString(); + baseURL = (authJSONObject.get(Constants.BASE_URL)).toString(); + project = (authJSONObject.get(Constants.PROJECT_NAME)).toString(); + } + + } catch (Exception e) { + log.log(Level.SEVERE, "Access Denied - ClearBlade Configuration variable is not set."); + e.printStackTrace(); + } + System.out.println(adminSystemKey); } + @SuppressWarnings("unchecked") + public static void setRegistryCredentials() { + if(userSystemKey != null) { + return; + } + try { + setAdminCredentials(); + ConfigParameters configParameters = new ConfigParameters(); + String finalURL = baseURL .concat(configParameters.getGetSystemCredentialsExtension()) + .concat(adminSystemKey) + .concat("/"+Constants.GET_REGISTRY_CREDENTIALS); + URL obj = new URL(finalURL); + SetHttpConnection setCon = new SetHttpConnection(); + HttpsURLConnection con = setCon.getConnection(obj); + con.setRequestProperty(Constants.HTTP_REQUEST_PROPERTY_TOKEN_KEY, adminToken); + con.setRequestProperty(Constants.HTTP_REQUEST_PROPERTY_CONTENT_TYPE_KEY, Constants.HTTP_REQUEST_PROPERTY_CONTENT_TYPE_ACCEPT_VALUE); + con.addRequestProperty(Constants.HTTP_REQUEST_PROPERTY_ACCEPT_KEY, Constants.HTTP_REQUEST_PROPERTY_CONTENT_TYPE_ACCEPT_VALUE); + con.setRequestMethod(Constants.HTTP_REQUEST_METHOD_TYPE_POST); + con.setDoOutput(true); + StringBuilder response = new StringBuilder(); + try (OutputStream os = con.getOutputStream()) { + JSONObject js = new JSONObject(); + js.put("region", configParameters.getRegion()); + js.put("registry", configParameters.getRegistry()); + js.put("project", project); + + byte[] input = js.toString().getBytes(Constants.UTF8); + os.write(input, 0, input.length); + os.flush(); + int responseCode = con.getResponseCode(); + BufferedReader in = null; + if (con.getErrorStream() != null) { + in = new BufferedReader(new InputStreamReader(con.getErrorStream())); + } else if (con.getInputStream() != null) { + in = new BufferedReader(new InputStreamReader(con.getInputStream())); + } + JSONObject responseJSONObject = new JSONObject(); + JSONParser responseParser = new JSONParser(); + String inputLine; + String responseMessage = ""; + if (in != null) { + while ((inputLine = in.readLine()) != null) { + response.append(inputLine); + } + responseMessage = response.toString(); + System.out.println(responseMessage); + } + if (responseCode == 200) { + if(responseMessage != null && responseMessage.length() > 0) { + Object responseObj = responseParser.parse(responseMessage); + if(responseObj != null) { + responseJSONObject = (JSONObject) responseObj; + userSystemKey = responseJSONObject.get(Constants.USER_SYSTEM_KEY).toString(); + userToken = responseJSONObject.get(Constants.USER_TOKEN).toString(); + apiBaseURL = responseJSONObject.get(Constants.API_BASE_URL).toString(); + } + } + } + } catch (Exception e) { + e.printStackTrace(); + } + } catch (Exception e) { + e.printStackTrace(); + } + } } diff --git a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/utils/Constants.java b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/utils/Constants.java index 99a10dab..0f0c0f55 100644 --- a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/utils/Constants.java +++ b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/utils/Constants.java @@ -27,8 +27,11 @@ private Constants() {} public static final String DEVICE_CONFIG_VERSIONS_LIST = "deviceConfigVersionsList"; public static final String BIND_DEVICE_TO_GATEWAY = "bindDeviceToGateway"; public static final String UNBIND_DEVICE_FROM_GATEWAY = "unbindDeviceFromGateway"; - public static final String DEVICE_PATCH = "devicePatch"; + public static final String UPDATE_DEVICE = "updateDevice"; public static final String GET_REGISTRY_CREDENTIALS="getRegistryCredentials"; + public static final String GET_DEVICE_REGISTRY = "getDeviceRegistry"; + public static final String UPDATE_DEVICE_REGISTRY = "updateDeviceRegistry"; + public static final String CREATE_DEVICE_REGISTRY = "createDeviceRegistry"; // Constants used for setting up http connection - for common use public static final String HTTPS_URL_PREFIX = "https://"; @@ -44,6 +47,7 @@ private Constants() {} //Commonly used String literal public static final String SUBFOLDER = "subfolder"; public static final String NAME = "?name="; + public static final String PARENT = "?parent="; public static final String UTF8 = "utf-8"; diff --git a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/utils/Device.java b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/utils/Device.java index eed73fae..db8fe6ca 100644 --- a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/utils/Device.java +++ b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/utils/Device.java @@ -1,55 +1,73 @@ package com.clearblade.cloud.iot.v1.utils; -import java.sql.Timestamp; import java.util.ArrayList; +import java.util.HashMap; +import java.util.Iterator; import java.util.List; +import java.util.Map; +import java.util.Set; + +import org.json.simple.JSONObject; +import org.json.simple.parser.JSONParser; public class Device { - - private final String id; - private final String name; - private final int numId; - private final List credentials; - private final Timestamp lastHeartbeatTime; - private final Timestamp lastEventTime; - private final Timestamp lastStateTime; - private final Timestamp lastConfigAckTime; - private final Timestamp lastConfigSendTime; - private final boolean blocked; - private final Timestamp lastErrorTime; - private final List lastErrorStatus; - private final List config; - private final List state; - private final String logLevel; - private final List metadata; - private final List gatewayConfig; - + + private String id; + private String name; + private String numId; + private List credentials; + private String lastHeartbeatTime; + private String lastEventTime; + private String lastStateTime; + private String lastConfigAckTime; + private String lastConfigSendTime; + private boolean blocked; + private String lastErrorTime; + private Status lastErrorStatus; + private DeviceConfig config; + private DeviceState state; + private LogLevel logLevel; + private Map metadata; + private GatewayConfig gatewayConfig; + public Device() { - id = ""; - name = ""; - numId = 0; + id = null; + name = null; + numId = null; credentials = new ArrayList<>(); - lastHeartbeatTime = new Timestamp(0); - lastEventTime = new Timestamp(0); - lastStateTime = new Timestamp(0); - lastConfigAckTime = new Timestamp(0); - lastConfigSendTime = new Timestamp(0); + lastHeartbeatTime = null; + lastEventTime = null; + lastStateTime = null; + lastConfigAckTime = null; + lastConfigSendTime = null; blocked = false; - lastErrorTime = new Timestamp(0); - lastErrorStatus = new ArrayList<>(); - config = new ArrayList<>(); - state = new ArrayList<>(); - logLevel = "NONE"; - metadata = new ArrayList<>(); - gatewayConfig = new ArrayList<>(); + lastErrorTime = null; + lastErrorStatus = new Status(); + lastErrorStatus.setCode(0); + lastErrorStatus.setMessage(""); + config = new DeviceConfig(); + config.setCloudUpdateTime(""); + config.setBinaryData(""); + config.setDeviceAckTime(""); + config.setVersion(""); + state = new DeviceState(); + state.setBinaryData(""); + state.setUpdateTime(""); + logLevel = LogLevel.NONE; + metadata = new HashMap<>(); + gatewayConfig = new GatewayConfig(); + gatewayConfig.setGatewayAuthMethod(GatewayAuthMethod.UNRECOGNIZED); + gatewayConfig.setGatewayType(GatewayType.NON_GATEWAY); + gatewayConfig.setLastAccessedGatewayId(""); + gatewayConfig.setLastAccessedGatewayTime(""); } - + private Device(Builder builder) { id = builder.getId(); name = builder.getName(); numId = builder.getNumId(); credentials = builder.getCredentials(); - lastHeartbeatTime = builder.getLastHeartbeatTime(); + lastHeartbeatTime = builder.getLastHeartbeatTime(); lastEventTime = builder.getLastEventTime(); lastStateTime = builder.getLastStateTime(); lastConfigAckTime = builder.getLastConfigAckTime(); @@ -63,7 +81,6 @@ private Device(Builder builder) { metadata = builder.getMetadata(); gatewayConfig = builder.getGatewayConfig(); } - public static Builder newBuilder() { return new Builder(); @@ -73,46 +90,68 @@ public Builder toBuilder() { return new Builder(this); } - public static Device of(String id, String name, int numId, List credentials, List lastErrorStatus,List config, List state, String logLevel, List metadata, List gatewayConfig) { - return newBuilder().setId(id).setName(name).setNumId(numId).setCredentials(credentials).setLastErrorStatus(lastErrorStatus).setConfig(config).setState(state).setLogLevel(logLevel).setMetadata(metadata).setGatewayConfig(gatewayConfig).build(); + public static Device of(String id, String name, String numId, List credentials, + String lastHeartbeatTime, String lastEventTime, + String lastStateTime, String lastConfigAckTime, String lastConfigSendTime, boolean blocked, + String lastErrorTime, + Status lastErrorStatus, DeviceConfig config, DeviceState state, LogLevel logLevel, + Map metadata, GatewayConfig gatewayConfig) { + + return newBuilder().setId(id).setName(name).setNumId(numId).setCredentials(credentials) + .setLastHeartbeatTime(lastHeartbeatTime).setLastEventTime(lastEventTime) + .setLastStateTime(lastStateTime).setLastConfigAckTime(lastConfigAckTime) + .setLastConfigSendTime(lastConfigSendTime).setBlocked(blocked).setLastErrorTime(lastErrorTime) + .setLastErrorStatus(lastErrorStatus).setConfig(config).setState(state).setLogLevel(logLevel) + .setMetadata(metadata).setGatewayConfig(gatewayConfig) + .build(); } - - public static Device patch(String id, String name, String logLevel, boolean blocked) { + + public static Device patch(String id, String name, LogLevel logLevel, boolean blocked) { return newBuilder().setId(id).setName(name).setLogLevel(logLevel).setBlocked(blocked).build(); } - public static String format(String id, String name, int numId, List credentials, List lastErrorStatus,List config, List state, String logLevel, List metadata, List gatewayConfig) { - return newBuilder().setId(id).setName(name).setNumId(numId).setCredentials(credentials).setLastErrorStatus(lastErrorStatus).setConfig(config).setState(state).setLogLevel(logLevel).setMetadata(metadata).setGatewayConfig(gatewayConfig).build() - .toString(); + + public static String format(String id, String name, String numId, List credentials, + String lastHeartbeatTime, String lastEventTime, + String lastStateTime, String lastConfigAckTime, String lastConfigSendTime, boolean blocked, + String lastErrorTime, + Status lastErrorStatus, DeviceConfig config, DeviceState state, LogLevel logLevel, + Map metadata, GatewayConfig gatewayConfig) { + + return newBuilder().setId(id).setName(name).setNumId(numId).setCredentials(credentials) + .setLastHeartbeatTime(lastHeartbeatTime).setLastEventTime(lastEventTime) + .setLastStateTime(lastStateTime).setLastConfigAckTime(lastConfigAckTime) + .setLastConfigSendTime(lastConfigSendTime).setBlocked(blocked).setLastErrorTime(lastErrorTime) + .setLastErrorStatus(lastErrorStatus).setConfig(config).setState(state).setLogLevel(logLevel) + .setMetadata(metadata).setGatewayConfig(gatewayConfig) + .build().toString(); } /** - * Builder for setting - * Device - id, name, credentials and logLevel + * Builder for setting Device - id, name, credentials and logLevel */ public static class Builder { private String id; private String name; - private int numId; - private List credentials; - private Timestamp lastHeartbeatTime; - private Timestamp lastEventTime; - private Timestamp lastStateTime; - private Timestamp lastConfigAckTime; - private Timestamp lastConfigSendTime; + private String numId; + private List credentials; + private String lastHeartbeatTime; + private String lastEventTime; + private String lastStateTime; + private String lastConfigAckTime; + private String lastConfigSendTime; private boolean blocked; - private Timestamp lastErrorTime; - private List lastErrorStatus; - private List config; - private List state; - private String logLevel; - private List metadata; - private List gatewayConfig; + private String lastErrorTime; + private Status lastErrorStatus; + private DeviceConfig config; + private DeviceState state; + private LogLevel logLevel; + private Map metadata; + private GatewayConfig gatewayConfig; - protected Builder() { - + } - + public String getId() { return id; } @@ -121,31 +160,31 @@ public String getName() { return name; } - public int getNumId() { + public String getNumId() { return numId; } - public List getCredentials() { + public List getCredentials() { return credentials; - } - - public Timestamp getLastHeartbeatTime() { + } + + public String getLastHeartbeatTime() { return lastHeartbeatTime; } - public Timestamp getLastEventTime() { + public String getLastEventTime() { return lastEventTime; } - public Timestamp getLastStateTime() { + public String getLastStateTime() { return lastStateTime; } - public Timestamp getLastConfigAckTime() { + public String getLastConfigAckTime() { return lastConfigAckTime; } - public Timestamp getLastConfigSendTime() { + public String getLastConfigSendTime() { return lastConfigSendTime; } @@ -153,34 +192,34 @@ public boolean isBlocked() { return blocked; } - public Timestamp getLastErrorTime() { + public String getLastErrorTime() { return lastErrorTime; } - public List getLastErrorStatus() { + public Status getLastErrorStatus() { return lastErrorStatus; } - public List getConfig() { + public DeviceConfig getConfig() { return config; } - public List getState() { + public DeviceState getState() { return state; } - public List getMetadata() { + public Map getMetadata() { return metadata; } - public List getGatewayConfig() { + public GatewayConfig getGatewayConfig() { return gatewayConfig; } - public String getLogLevel() { + public LogLevel getLogLevel() { return logLevel; } - + public static Builder newBuilder() { return newBuilder(); } @@ -195,81 +234,83 @@ public Builder setName(String name) { return this; } - public Builder setNumId(int numId) { + public Builder setNumId(String numId) { this.numId = numId; return this; } - - public Builder setCredentials(List credentials) { + + public Builder setCredentials(List credentials) { this.credentials = credentials; return this; } - public Builder setLastErrorStatus(List lastErrorStatus) { + public Builder setLastErrorStatus(Status lastErrorStatus) { this.lastErrorStatus = lastErrorStatus; return this; } - public Builder setConfig(List config) { + public Builder setConfig(DeviceConfig config) { this.config = config; return this; } - public Builder setLogLevel(String logLevel) { + public Builder setLogLevel(LogLevel logLevel) { this.logLevel = logLevel; return this; } - public Builder setState(List state) { + public Builder setState(DeviceState state) { this.state = state; return this; } - public Builder setMetadata(List metadata) { + public Builder setMetadata(Map metadata) { this.metadata = metadata; return this; } - - public Builder setGatewayConfig(List gatewayConfig) { + + public Builder setGatewayConfig(GatewayConfig gatewayConfig) { this.gatewayConfig = gatewayConfig; return this; } - + public Builder setBlocked(boolean blocked) { this.blocked = blocked; return this; } - - public Builder setLastHeartbeatTime(Timestamp lastHeartbeatTime) { + + public Builder setLastHeartbeatTime(String lastHeartbeatTime) { this.lastHeartbeatTime = lastHeartbeatTime; return this; } - public Builder setLastEventTime(Timestamp lastEventTime) { + public Builder setLastEventTime(String lastEventTime) { this.lastEventTime = lastEventTime; return this; } - public Builder setLastStateTime(Timestamp lastStateTime) { + public Builder setLastStateTime(String lastStateTime) { this.lastStateTime = lastStateTime; return this; } - public Builder setLastConfigAckTime(Timestamp lastConfigAckTime) { + public Builder setLastConfigAckTime(String lastConfigAckTime) { this.lastConfigAckTime = lastConfigAckTime; return this; } - public Builder setLastConfigSendTime(Timestamp lastConfigSendTime) { + public Builder setLastConfigSendTime(String lastConfigSendTime) { this.lastConfigSendTime = lastConfigSendTime; return this; } - public Builder setLastErrorTime(Timestamp lastErrorTime) { + public Builder setLastErrorTime(String lastErrorTime) { this.lastErrorTime = lastErrorTime; return this; } + + private Builder(Device device) { this.id = device.id; this.name = device.name; @@ -281,7 +322,7 @@ private Builder(Device device) { this.lastConfigAckTime = device.lastConfigAckTime; this.lastConfigSendTime = device.lastConfigSendTime; this.blocked = device.blocked; - this.lastErrorTime = device.lastErrorTime; + this.lastErrorTime = device.lastErrorTime; this.lastErrorStatus = device.lastErrorStatus; this.config = device.config; this.state = device.state; @@ -294,17 +335,205 @@ public Device build() { return new Device(this); } } + @Override public String toString() { - String deviceStr =""; - deviceStr = deviceStr.concat("id="+this.id+",name="+this.name+",numId="+this.numId+",credentials="+this.credentials - +",lastHeartbeatTime="+this.lastHeartbeatTime+",lastEventTime="+this.lastEventTime - +",lastStateTime="+this.lastStateTime+",lastConfigAckTime="+this.lastConfigAckTime - +",lastConfigSendTime="+this.lastConfigSendTime+",blocked="+this.blocked - +",lastErrorTime="+this.lastErrorTime - + ",lastErrorStatus="+this.lastErrorStatus+",config="+this.config - +",state="+this.state+",logLevel="+this.logLevel+",metadata="+this.metadata - +",gatewayConfig="+this.gatewayConfig); + String deviceStr = ""; + deviceStr = deviceStr.concat("id=" + this.id + ",name=" + this.name + ",numId=" + this.numId + ",credentials=" + + this.credentials + ",lastHeartbeatTime=" + this.lastHeartbeatTime + ",lastEventTime=" + + this.lastEventTime + ",lastStateTime=" + this.lastStateTime + ",lastConfigAckTime=" + + this.lastConfigAckTime + ",lastConfigSendTime=" + this.lastConfigSendTime + ",blocked=" + this.blocked + + ",lastErrorTime=" + this.lastErrorTime + ",lastErrorStatus=" + this.lastErrorStatus + ",config=" + + this.config + ",state=" + this.state + ",logLevel=" + this.logLevel + ",metadata=" + this.metadata + + ",gatewayConfig=" + this.gatewayConfig); return deviceStr; } + + + @SuppressWarnings("unchecked") + public String createDeviceJSONObject() { + String bodyStr = ""; + JSONObject deviceObj = new JSONObject(); + deviceObj.put("id", this.id); + deviceObj.put("name", this.name); + deviceObj.put("numId", this.numId); + List credentialList = new ArrayList<>(); + if(this.credentials.size() > 0) { + DeviceCredential credentialObj = this.credentials.get(0); + credentialList.add(credentialObj); + } + deviceObj.put("credentials",credentialList); + deviceObj.put("gatewayConfig", this.gatewayConfig.toString()); + deviceObj.put("logLevel", this.logLevel.name()); + deviceObj.put("lastHeartbeatTime",this.lastHeartbeatTime); + deviceObj.put("lastEventTime",this.lastEventTime); + deviceObj.put("lastStateTime",this.lastStateTime); + deviceObj.put("lastConfigAckTime",this.lastConfigAckTime); + deviceObj.put("lastConfigSendTime",this.lastConfigSendTime); + deviceObj.put("blocked",false); + deviceObj.put("lastErrorTime", this.lastErrorTime); + String metaStr = ""; + if(this.metadata != null) { + Set metaSet = this.metadata.keySet(); + Iterator itr = metaSet.iterator(); + int setSize = metaSet.size(); + int i = 0; + while(itr.hasNext()) { + String key = (String) itr.next(); + String value = this.metadata.get(key).toString(); + if(i >= 0 && i < setSize) { + metaStr += "{\""+key+"\":"+"\""+value+"\","; + }else if(i == setSize){ + metaStr += "{\""+key+"\":"+"\""+value+"\"}"; + }else { + metaStr += "{\""+key+"\":"+"\""+value+"\""; + } + i++; + } + } + deviceObj.put("metadata", metaStr); + String errorStatusStr = ""; + if(this.lastErrorStatus != null) { + errorStatusStr+= this.lastErrorStatus.toString(); + } + deviceObj.put("lastErrorStatus", errorStatusStr); + String configStr = ""; + if(this.config != null) { + configStr += this.config.toString(); + } + deviceObj.put("config", configStr); + String stateStr = ""; + if(this.state != null) { + stateStr += this.state.toString(); + } + deviceObj.put("state", stateStr); + bodyStr = deviceObj.toString(); + return bodyStr; + } + + public void loadFromString(String inputStr) { + try { + JSONParser parser = new JSONParser(); + JSONObject deviceObj = (JSONObject) parser.parse(inputStr); + + if (deviceObj != null && deviceObj.size() > 0) { + + Set deviceSet = deviceObj.keySet(); + Iterator itr = deviceSet.iterator(); + while (itr.hasNext()) { + String key = (String) itr.next(); + Object value = deviceObj.get(key); + + if (key.equals("id")) { + this.id = value.toString(); + } + if (key.equals("name")) { + this.name = value.toString(); + } + if (key.equals("numId")) { + this.numId = value.toString(); + } + if (key.equals("lastHeartbeatTime")) { + this.lastHeartbeatTime = value.toString(); + } + if (key.equals("lastEventTime")) { + this.lastEventTime = value.toString(); + } + if (key.equals("lastStateTime")) { + this.lastStateTime = value.toString(); + } + if (key.equals("lastConfigAckTime")) { + this.lastConfigAckTime = value.toString(); + } + if (key.equals("lastConfigSendTime")) { + this.lastConfigSendTime = value.toString(); + } + if (key.equals("blocked")) { + this.blocked = Boolean.valueOf(value.toString()); + } + if (key.equals("lastErrorTime")) { + this.lastErrorTime = value.toString(); + } + if (key.equals("lastErrorStatus")) { + JSONObject errorStatus = (JSONObject) value; + Status status = new Status(); + if (errorStatus.containsKey("code")) + status.setCode(errorStatus.get("code")); + if (errorStatus.containsKey("message")) + status.setMessage((String) errorStatus.get("message")); + this.lastErrorStatus = status; + } + + if (key.equals("config")) { + JSONObject configJsonObject = (JSONObject) value; + DeviceConfig deviceCfg = new DeviceConfig(); + if (configJsonObject.containsKey("version")) + deviceCfg.setVersion((String) configJsonObject.get("version")); + if (configJsonObject.containsKey("cloudUpdateTime")) + deviceCfg.setCloudUpdateTime((String) configJsonObject.get("cloudUpdateTime")); + if (configJsonObject.containsKey("deviceAckTime")) + deviceCfg.setDeviceAckTime((String) configJsonObject.get("deviceAckTime")); + if (configJsonObject.containsKey("binaryData")) + deviceCfg.setBinaryData((String) configJsonObject.get("binaryData")); + this.config = deviceCfg; + } + + if (key.equals("state")) { + JSONObject stateJsonObject = (JSONObject) value; + DeviceState deviceState = new DeviceState(); + if (stateJsonObject.containsKey("binaryData")) + deviceState.setBinaryData((String) stateJsonObject.get("binaryData")); + if (stateJsonObject.containsKey("updateTime")) + deviceState.setUpdateTime((String) stateJsonObject.get("updateTime")); + this.state = deviceState; + } + + if (key.equals("logLevel")) { + if (value != null) { + this.logLevel = LogLevel.valueOf(value.toString()); + } + } + + if (key.equals("metadata")) { + JSONObject metadataJsonObject = (JSONObject) value; + + Map metadataMap = new HashMap<>(); + Set metadataSet = metadataJsonObject.keySet(); + if (metadataSet.size() > 0) { + Iterator metadIterator = metadataSet.iterator(); + while (metadIterator.hasNext()) { + String metadataKey = (String) metadIterator.next(); + String metatdataValue = (String) metadataJsonObject.get(metadataKey); + metadataMap.put(metadataKey, metatdataValue); + } + } + + this.metadata = metadataMap; + } + if (key.equals("gatewayConfig")) { + JSONObject gatewayConfigJsonObject = (JSONObject) value; + GatewayConfig gatewayConfig = new GatewayConfig(); + if (gatewayConfigJsonObject.containsKey("gatewayType")) + gatewayConfig.setGatewayType( + GatewayType.valueOf((String) gatewayConfigJsonObject.get("gatewayType"))); + if (gatewayConfigJsonObject.containsKey("gatewayAuthMethod")) + gatewayConfig.setGatewayAuthMethod(GatewayAuthMethod + .valueOf((String) gatewayConfigJsonObject.get("gatewayAuthMethod"))); + if (gatewayConfigJsonObject.containsKey("lastAccessedGatewayId")) + gatewayConfig.setLastAccessedGatewayId( + (String) gatewayConfigJsonObject.get("lastAccessedGatewayId")); + if (gatewayConfigJsonObject.containsKey("lastAccessedGatewayTime")) + gatewayConfig.setLastAccessedGatewayTime( + (String) gatewayConfigJsonObject.get("lastAccessedGatewayTime")); + + this.gatewayConfig = gatewayConfig; + } + } + } + + } catch (Exception e) { + e.printStackTrace(); + } + } + } diff --git a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/utils/DeviceConfig.java b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/utils/DeviceConfig.java new file mode 100644 index 00000000..435d753d --- /dev/null +++ b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/utils/DeviceConfig.java @@ -0,0 +1,154 @@ +package com.clearblade.cloud.iot.v1.utils; + +import javax.swing.JSeparator; + +import org.json.simple.JSONObject; +import org.json.simple.parser.JSONParser; + +public class DeviceConfig { + private String version; + private String cloudUpdateTime; + private String deviceAckTime; + private String binaryData; + + public DeviceConfig() { + } + + private DeviceConfig(Builder builder) { + version = builder.version; + cloudUpdateTime = builder.cloudUpdateTime; + deviceAckTime = builder.deviceAckTime; + binaryData = builder.binaryData; + } + + + public void setVersion(String version) { + this.version = version; + } + + public void setCloudUpdateTime(String cloudUpdateTime) { + this.cloudUpdateTime = cloudUpdateTime; + } + + public void setDeviceAckTime(String deviceAckTime) { + this.deviceAckTime = deviceAckTime; + } + + public void setBinaryData(String binaryData) { + this.binaryData = binaryData; + } + + public String getVersion() { + return version; + } + + public String getCloudUpdateTime() { + return cloudUpdateTime; + } + + public String getDeviceAckTime() { + return deviceAckTime; + } + + public String getBinaryData() { + return binaryData; + } + + public static Builder newBuilder() { + return new Builder(); + } + + public Builder toBuilder() { + return new Builder(this); + } + + public static class Builder { + private String version; + private String cloudUpdateTime; + private String deviceAckTime; + private String binaryData; + + protected Builder() { + + } + + + public String getVersion() { + return version; + } + public Builder setVersion(String version) { + this.version = version; + return this; + } + public String getCloudUpdateTime() { + return cloudUpdateTime; + } + public Builder setCloudUpdateTime(String cloudUpdateTime) { + this.cloudUpdateTime = cloudUpdateTime; + return this; + } + public String getDeviceAckTime() { + return deviceAckTime; + } + public Builder setDeviceAckTime(String deviceAckTime) { + this.deviceAckTime = deviceAckTime; + return this; + } + public String getBinaryData() { + return binaryData; + } + public Builder setBinaryData(String binaryData) { + this.binaryData = binaryData; + return this; + } + private Builder(DeviceConfig deviceConfig) { + this.version = deviceConfig.version; + this.cloudUpdateTime = deviceConfig.cloudUpdateTime; + this.deviceAckTime = deviceConfig.deviceAckTime; + this.binaryData = deviceConfig.binaryData; + } + + public DeviceConfig build() { + return new DeviceConfig(this); + } + } + + @Override + public String toString() { + String configStr = ""; + if(this.getVersion() != null) { + configStr+= "{\"version\":\""+this.getBinaryData()+"\","; + }else { + configStr+= "{\"version\":\"\","; + } + if(this.getCloudUpdateTime() != null) { + configStr+= "\"cloudUpdateTime\":\""+this.getCloudUpdateTime()+"\","; + }else { + configStr+= "\"cloudUpdateTime\":\"\","; + } + if(this.getDeviceAckTime() != null) { + configStr+= "\"deviceAckTime\":\""+this.getDeviceAckTime()+"\","; + }else { + configStr+= "\"deviceAckTime\":\"\","; + } + if(this.getBinaryData() != null) { + configStr+= "\"binaryData\":\""+this.getBinaryData()+"\"}"; + }else { + configStr+= "\"binaryData\":\"\"}"; + } + return configStr; + } + + public void loadFromString(String jsonString) { + try { + JSONParser jsonParser = new JSONParser(); + JSONObject jsonObj = (JSONObject) jsonParser.parse(jsonString); + this.version = (String) jsonObj.get("version"); + this.cloudUpdateTime = (String) jsonObj.get("cloudUpdateTime"); + this.deviceAckTime = (String) jsonObj.get("deviceAckTime"); + this.binaryData = (String) jsonObj.get("binaryData"); + } catch (Exception e) { + e.printStackTrace(); + } + } +} diff --git a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/utils/DeviceCredential.java b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/utils/DeviceCredential.java new file mode 100644 index 00000000..78df96b8 --- /dev/null +++ b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/utils/DeviceCredential.java @@ -0,0 +1,74 @@ +package com.clearblade.cloud.iot.v1.utils; + +public class DeviceCredential { + + private String expirationTime; + private PublicKeyCredential publicKey; + + public DeviceCredential() { + } + + private DeviceCredential(Builder builder) { + expirationTime = builder.expirationTime; + publicKey = builder.publicKey; + } + public static Builder newBuilder() { + return new Builder(); + } + + public Builder toBuilder() { + return new Builder(this); + } + + public static class Builder { + private String expirationTime; + private PublicKeyCredential publicKey; + + protected Builder() { + + } + + + public String getExpirationTime() { + return expirationTime; + } + + + public Builder setExpirationTime(String expirationTime) { + this.expirationTime = expirationTime; + return this; + } + + + public PublicKeyCredential getPublicKey() { + return publicKey; + } + + + public Builder setPublicKey(PublicKeyCredential publicKey) { + this.publicKey = publicKey; + return this; + } + + + private Builder(DeviceCredential deviceCredential) { + this.expirationTime = deviceCredential.expirationTime; + this.publicKey = deviceCredential.publicKey; + } + public DeviceCredential build() { + return new DeviceCredential(this); + } + } + + public void setExpirationTime(String expirationTime) { + this.expirationTime = expirationTime; + } + + public void setPublicKey(PublicKeyCredential publicKey) { + this.publicKey = publicKey; + } + + + + +} diff --git a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/utils/DeviceName.java b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/utils/DeviceName.java index ca088206..0f3916aa 100644 --- a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/utils/DeviceName.java +++ b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/utils/DeviceName.java @@ -114,4 +114,10 @@ public DeviceName build() { return new DeviceName(this); } } + @Override + public String toString() { + + return this.device; + + } } diff --git a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/utils/DeviceRegistry.java b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/utils/DeviceRegistry.java new file mode 100644 index 00000000..f7e4ce35 --- /dev/null +++ b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/utils/DeviceRegistry.java @@ -0,0 +1,252 @@ +package com.clearblade.cloud.iot.v1.utils; + +import java.util.ArrayList; +import java.util.Iterator; +import java.util.List; +import java.util.Set; + +import org.json.simple.JSONObject; +import org.json.simple.parser.JSONParser; +//https://cloud.google.com/iot/docs/reference/cloudiot/rest/v1/projects.locations.registries#DeviceRegistry +public class DeviceRegistry { + + private String id; + private String name; + private List eventNotificationConfigs; + private StateNotificationConfig stateNotificationConfig; + private MqttConfig mqttConfig; + private HttpConfig httpConfig; + private LogLevel logLevel; + private List credentials; + + + public DeviceRegistry() { + id = ""; + name = ""; + eventNotificationConfigs = new ArrayList<>(); + stateNotificationConfig = null; + mqttConfig = MqttConfig.newBuilder().build(); + httpConfig = null; + logLevel = null; + credentials = new ArrayList<>(); + } + + private DeviceRegistry(Builder builder) { + id = builder.getId(); + name = builder.getName(); + eventNotificationConfigs = builder.getEventNotificationConfigs(); + stateNotificationConfig = builder.getStateNotificationConfig(); + mqttConfig = builder.getMqttConfig(); + httpConfig = builder.getHttpConfig(); + logLevel = builder.getLogLevel(); + credentials = builder.getCredentials(); + } + + + public static Builder newBuilder() { + return new Builder(); + } + + public Builder toBuilder() { + return new Builder(this); + } + + public static DeviceRegistry of(String id, String name, List eventNotificationConfigs,StateNotificationConfig stateNotificationConfig,MqttConfig mqttConfig,HttpConfig httpConfig,LogLevel logLevel,List credentials) { + return newBuilder().setId(id).setName(name).setEventNotificationConfigs(eventNotificationConfigs).setStateNotificationConfig(stateNotificationConfig).setMqttConfig(mqttConfig).setHttpConfig(httpConfig).setLogLevel(logLevel).setCredentials(credentials).build(); + } + + public static String format(String id, String name, List eventNotificationConfigs,StateNotificationConfig stateNotificationConfig,MqttConfig mqttConfig,HttpConfig httpConfig,LogLevel logLevel,List credentials) { + return newBuilder().setId(id).setName(name).setEventNotificationConfigs(eventNotificationConfigs).setStateNotificationConfig(stateNotificationConfig).setMqttConfig(mqttConfig).setHttpConfig(httpConfig).setLogLevel(logLevel).setCredentials(credentials).build() + .toString(); + } + + /** + * Builder for setting + * Registry - attributes + */ + public static class Builder { + private String id; + private String name; + private List eventNotificationConfigs; + private StateNotificationConfig stateNotificationConfig; + private MqttConfig mqttConfig; + private HttpConfig httpConfig; + private LogLevel logLevel; + private List credentials; + + + protected Builder() { + + } + + public static Builder newBuilder() { + return newBuilder(); + } + + public String getId() { + return id; + } + + public String getName() { + return name; + } + + public List getEventNotificationConfigs() { + return eventNotificationConfigs; + } + + public StateNotificationConfig getStateNotificationConfig() { + return stateNotificationConfig; + } + + public MqttConfig getMqttConfig() { + return mqttConfig; + } + + public HttpConfig getHttpConfig() { + return httpConfig; + } + + public LogLevel getLogLevel() { + return logLevel; + } + + public List getCredentials() { + return credentials; + } + + public Builder setId(String id) { + this.id = id; + return this; + } + + public Builder setName(String name) { + this.name = name; + return this; + } + + public Builder setEventNotificationConfigs(List eventNotificationConfigs) { + this.eventNotificationConfigs = eventNotificationConfigs; + return this; + } + public Builder setStateNotificationConfig(StateNotificationConfig stateNotificationConfig) { + this.stateNotificationConfig = stateNotificationConfig; + return this; + } + + public Builder setMqttConfig(MqttConfig mqttConfig) { + this.mqttConfig = mqttConfig; + return this; + } + public Builder setHttpConfig(HttpConfig httpConfig) { + this.httpConfig = httpConfig; + return this; + } + public Builder setLogLevel(LogLevel logLevel) { + this.logLevel = logLevel; + return this; + } + public Builder setCredentials(List credentials) { + this.credentials = credentials; + return this; + } + + + private Builder(DeviceRegistry registry) { + this.id = registry.id; + this.name = registry.name; + this.eventNotificationConfigs = registry.eventNotificationConfigs; + this.stateNotificationConfig = registry.stateNotificationConfig; + this.mqttConfig = registry.mqttConfig; + this.httpConfig = registry.httpConfig; + this.logLevel = registry.logLevel; + this.credentials = registry.credentials; + } + + public DeviceRegistry build() { + return new DeviceRegistry(this); + } + } + @Override + public String toString() { + return ("id="+this.id+",name="+this.name + +",eventNotificationConfigs="+this.eventNotificationConfigs + +",stateNotificationConfig="+this.stateNotificationConfig + +"mqttConfig="+this.mqttConfig.toBuilder().build() + +",httpConfig="+this.httpConfig + +",logLevel="+this.logLevel + +",credentials="+this.credentials); + } + + public void loadFromString(String inputStr) { + try { + JSONParser parser = new JSONParser(); + JSONObject deviceObj = (JSONObject) parser.parse(inputStr); + + if (deviceObj != null && deviceObj.size() > 0) { + + Set deviceSet = deviceObj.keySet(); + Iterator itr = deviceSet.iterator(); + while (itr.hasNext()) { + String key = (String) itr.next(); + Object value = deviceObj.get(key); + if (key.equals("id")) { + this.id = value.toString(); + } + if (key.equals("name")) { + this.name = value.toString(); + } + if (key.equals("credentials")) { + List credentialList = new ArrayList<>(); + RegistryCredential credentialObj = new RegistryCredential(); + credentialList.add(credentialObj); + this.credentials = credentialList; + } + if(key.equals("eventNotificationConfigs")) { + JSONArray eventJsonArray = value; + + List eventNotificationCfgs = new ArrayList<>(); + //list implementation pending + EventNotificationConfig eventNotificationCfg = new EventNotificationConfig(); + if (eventJsonObject.containsKey("subfolderMatches")) + eventNotificationCfg.setPubsubTopicName((String) eventJsonObject.get("subfolderMatches")); + if (eventJsonObject.containsKey("pubsubTopicName")) + eventNotificationCfg.setPubsubTopicName((String) eventJsonObject.get("pubsubTopicName")); + eventNotificationCfgs.add(eventNotificationCfg); + + this.eventNotificationConfigs = eventNotificationCfgs; + } + if(key.equals("stateNotificationConfig")) { + JSONObject stateJsonObject = (JSONObject) value; + StateNotificationConfig stateNotificationCfg = new StateNotificationConfig(); + if (stateJsonObject.containsKey("pubsubTopicName")) + stateNotificationCfg.setPubsubTopicName((String) stateJsonObject.get("pubsubTopicName")); + this.stateNotificationConfig = stateNotificationCfg; + } + if(key.equals("mqttConfig")) { + JSONObject mqttJsonObject = (JSONObject) value; + MqttConfig mqttCfg = new MqttConfig(); + if (mqttJsonObject.containsKey("mqttEnabledState")) + mqttCfg.setMqttEnabledState(MqttState.valueOf((String) mqttJsonObject.get("mqttEnabledState"))); + this.mqttConfig = mqttCfg; + } + if(key.equals("httpConfig")) { + JSONObject httpJsonObject = (JSONObject) value; + HttpConfig httpCfg = new HttpConfig(); + if (httpJsonObject.containsKey("httpEnabledState")) + httpCfg.setHttpEnabledState(HttpState.valueOf((String) httpJsonObject.get("httpEnabledState"))); + this.httpConfig = httpCfg; + } + if (key.equals("logLevel")) { + if (value != null) { + this.logLevel = LogLevel.valueOf(value.toString()); + } + } + } + } + } catch (Exception e) { + e.printStackTrace(); + } + } + +} diff --git a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/utils/DeviceState.java b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/utils/DeviceState.java index 81041c01..bd604f9f 100644 --- a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/utils/DeviceState.java +++ b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/utils/DeviceState.java @@ -1,16 +1,34 @@ package com.clearblade.cloud.iot.v1.utils; public class DeviceState { - private final ByteString binaryData; + private String updateTime; + private String binaryData; public DeviceState(Builder builder) { + updateTime = builder.updateTime; binaryData = builder.getBinaryData(); } - public ByteString getBinaryData() { + public DeviceState() { + + } + public String getBinaryData() { return binaryData; } + + public String getUpdateTime() { + return updateTime; + } + + public void setUpdateTime(String updateTime) { + this.updateTime = updateTime; + } + + public void setBinaryData(String binaryData) { + this.binaryData = binaryData; + } + public static Builder newBuilder() { return new Builder(); } @@ -20,20 +38,33 @@ public Builder toBuilder() { } public static class Builder { - private ByteString binaryData; + private String binaryData; + private String updateTime; protected Builder() { } - public ByteString getBinaryData() { + + public String getUpdateTime() { + return updateTime; + } + + + public Builder setUpdateTime(String updateTime) { + this.updateTime = updateTime; + return this; + } + + public String getBinaryData() { return binaryData; } - public Builder setBinaryData(ByteString binaryData) { + public Builder setBinaryData(String binaryData) { this.binaryData = binaryData; return this; } private Builder(DeviceState deviceState) { + this.updateTime = deviceState.updateTime; this.binaryData = deviceState.binaryData; } @@ -42,4 +73,19 @@ public DeviceState build() { } } + @Override + public String toString() { + String stateStr = ""; + if(this.getUpdateTime() != null) { + stateStr+= "{\"updateTime\":\""+this.getUpdateTime()+"\","; + }else { + stateStr+= "{\"updateTime\":\"\","; + } + if(this.getBinaryData() != null) { + stateStr+= "\"binaryData\":\""+this.getBinaryData()+"\"}"; + }else { + stateStr+= "\"binaryData\":\"\"}"; + } + return stateStr; + } } diff --git a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/utils/EventNotificationConfig.java b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/utils/EventNotificationConfig.java new file mode 100644 index 00000000..38dffab2 --- /dev/null +++ b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/utils/EventNotificationConfig.java @@ -0,0 +1,75 @@ +package com.clearblade.cloud.iot.v1.utils; + +public class EventNotificationConfig { + + private String subfolderMatches; + private String pubsubTopicName; + + public EventNotificationConfig() { + subfolderMatches = ""; + pubsubTopicName = ""; + } + private EventNotificationConfig(Builder builder) { + subfolderMatches = builder.getSubfolderMatches(); + pubsubTopicName = builder.getPubsubTopicName(); + } + + public String getSubfolderMatches() { + return subfolderMatches; + } + public void setSubfolderMatches(String subfolderMatches) { + this.subfolderMatches = subfolderMatches; + } + public String getPubsubTopicName() { + return pubsubTopicName; + } + public void setPubsubTopicName(String pubsubTopicName) { + this.pubsubTopicName = pubsubTopicName; + } + public static Builder newBuilder() { + return new Builder(); + } + + public Builder toBuilder() { + return new Builder(this); + } + + /** + * Builder for setting + * EventNotificationConfig - subfolderMatches , pubsubTopicName + */ + public static class Builder { + private String subfolderMatches; + private String pubsubTopicName; + + protected Builder() { + + } + private Builder(EventNotificationConfig eventNotificationConfig) { + this.subfolderMatches = eventNotificationConfig.subfolderMatches; + this.pubsubTopicName = eventNotificationConfig.pubsubTopicName; + } + public EventNotificationConfig build() { + return new EventNotificationConfig(this); + } + public String getSubfolderMatches() { + return subfolderMatches; + } + public Builder setSubfolderMatches(String subfolderMatches) { + this.subfolderMatches = subfolderMatches; + return this; + } + public String getPubsubTopicName() { + return pubsubTopicName; + } + public Builder setPubsubTopicName(String pubsubTopicName) { + this.pubsubTopicName = pubsubTopicName; + return this; + } + + } + @Override + public String toString() { + return "subfolderMatches= "+this.subfolderMatches+",pubsubTopicName="+this.pubsubTopicName; + } +} diff --git a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/utils/FieldMask.java b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/utils/FieldMask.java new file mode 100644 index 00000000..879a7c00 --- /dev/null +++ b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/utils/FieldMask.java @@ -0,0 +1,52 @@ +package com.clearblade.cloud.iot.v1.utils; + +public class FieldMask { + + private final String name; + + public FieldMask() { + name = ""; + } + + private FieldMask(Builder builder) { + name = builder.getFieldmask(); + } + public static Builder newBuilder() { + return new Builder(); + } + + public Builder toBuilder() { + return new Builder(this); + } + + public static class Builder { + private String name; + + protected Builder() { + + } + + public String getFieldmask() { + return name; + } + + public Builder setFieldmask(String fieldmask) { + this.name = fieldmask; + return this; + } + + private Builder(FieldMask fieldMask) { + this.name = fieldMask.name; + } + public FieldMask build() { + return new FieldMask(this); + } + } + @Override + public String toString() { + if(this.name != null) + return this.name; + else + return ""; + } +} diff --git a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/utils/GatewayAuthMethod.java b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/utils/GatewayAuthMethod.java new file mode 100644 index 00000000..1a55cdb8 --- /dev/null +++ b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/utils/GatewayAuthMethod.java @@ -0,0 +1,63 @@ +package com.clearblade.cloud.iot.v1.utils; + +public enum GatewayAuthMethod { + + GATEWAY_AUTH_METHOD_UNSPECIFIED(0), + ASSOCIATION_ONLY(1), + DEVICE_AUTH_TOKEN_ONLY(2), + ASSOCIATION_AND_DEVICE_AUTH_TOKEN(3), + UNRECOGNIZED(-1), + ; + + public static final int GATEWAY_AUTH_METHOD_UNSPECIFIED_VALUE = 0; + public static final int ASSOCIATION_ONLY_VALUE = 1; + public static final int DEVICE_AUTH_TOKEN_ONLY_VALUE = 2; + public static final int ASSOCIATION_AND_DEVICE_AUTH_TOKEN_VALUE = 3; + + + public final int getNumber() { + if (this == UNRECOGNIZED) { + throw new java.lang.IllegalArgumentException( + "Can't get the number of an unknown enum value."); + } + return value; + } + + /** + * @param value The numeric wire value of the corresponding enum entry. + * @return The enum associated with the given numeric wire value. + */ + public static GatewayAuthMethod valueOf(int value) { + return forNumber(value); + } + + /** + * @param value The numeric wire value of the corresponding enum entry. + * @return The enum associated with the given numeric wire value. + */ + public static GatewayAuthMethod forNumber(int value) { + switch (value) { + case 0: + return GATEWAY_AUTH_METHOD_UNSPECIFIED; + case 1: + return ASSOCIATION_ONLY; + case 2: + return DEVICE_AUTH_TOKEN_ONLY; + case 3: + return ASSOCIATION_AND_DEVICE_AUTH_TOKEN; + default: + return null; + } + } + + public GatewayAuthMethod findValueByNumber(int number) { + return GatewayAuthMethod.forNumber(number); + } + + private final int value; + + private GatewayAuthMethod(int value) { + this.value = value; + } + +} diff --git a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/utils/GatewayConfig.java b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/utils/GatewayConfig.java new file mode 100644 index 00000000..3eddbe3a --- /dev/null +++ b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/utils/GatewayConfig.java @@ -0,0 +1,109 @@ +package com.clearblade.cloud.iot.v1.utils; + +public class GatewayConfig { + + private GatewayType gatewayType; + private GatewayAuthMethod gatewayAuthMethod; + private String lastAccessedGatewayId; + private String lastAccessedGatewayTime; + + public GatewayConfig() { + } + + + + public GatewayType getGatewayType() { + return gatewayType; + } + + public GatewayAuthMethod getGatewayAuthMethod() { + return gatewayAuthMethod; + } + + public String getLastAccessedGatewayId() { + return lastAccessedGatewayId; + } + + public String getLastAccessedGatewayTime() { + return lastAccessedGatewayTime; + } + + public void setGatewayType(GatewayType gatewayType) { + this.gatewayType = gatewayType; + } + + public void setGatewayAuthMethod(GatewayAuthMethod gatewayAuthMethod) { + this.gatewayAuthMethod = gatewayAuthMethod; + } + + public void setLastAccessedGatewayId(String lastAccessedGatewayId) { + this.lastAccessedGatewayId = lastAccessedGatewayId; + } + + public void setLastAccessedGatewayTime(String lastAccessedGatewayTime) { + this.lastAccessedGatewayTime = lastAccessedGatewayTime; + } + + private GatewayConfig(Builder builder) { + gatewayType = builder.gatewayType; + gatewayAuthMethod = builder.gatewayAuthMethod; + lastAccessedGatewayId = builder.lastAccessedGatewayId; + lastAccessedGatewayTime = builder.lastAccessedGatewayTime; + } + public static Builder newBuilder() { + return new Builder(); + } + + public Builder toBuilder() { + return new Builder(this); + } + + public static class Builder { + private GatewayType gatewayType; + private GatewayAuthMethod gatewayAuthMethod; + private String lastAccessedGatewayId; + private String lastAccessedGatewayTime; + + protected Builder() { + } + + + private Builder(GatewayConfig gatewayConfig) { + this.gatewayType = gatewayConfig.gatewayType; + this.gatewayAuthMethod = gatewayConfig.gatewayAuthMethod; + this.lastAccessedGatewayId = gatewayConfig.lastAccessedGatewayId; + this.lastAccessedGatewayTime = gatewayConfig.lastAccessedGatewayTime; + } + public GatewayConfig build() { + return new GatewayConfig(this); + } + } + @Override + public String toString() { + String gatewayCfgStr = ""; + + if(this.getGatewayAuthMethod() != null) { + gatewayCfgStr+= "{\"gatewayAuthMethod\":\""+this.getGatewayAuthMethod().name()+"\","; + }else { + gatewayCfgStr+= "{\"gatewayAuthMethod\":\""+GatewayAuthMethod.GATEWAY_AUTH_METHOD_UNSPECIFIED+"\","; + } + if(this.getGatewayType() != null) { + gatewayCfgStr+= "\"gatewayType\":\""+this.getGatewayType().name()+"\","; + }else { + gatewayCfgStr+= "\"gatewayType\":\""+GatewayType.valueOf(GatewayType.NON_GATEWAY_VALUE)+"\","; + } + if(this.getLastAccessedGatewayId() != null) { + gatewayCfgStr+= "\"lastAccessedGatewayId\":\""+this.getLastAccessedGatewayId()+"\","; + }else { + gatewayCfgStr+= "\"lastAccessedGatewayId\":\"\","; + } + if(this.getLastAccessedGatewayTime() != null) { + gatewayCfgStr+= "\"lastAccessedGatewayTime\":\""+this.getLastAccessedGatewayTime()+"\"}"; + }else { + gatewayCfgStr+= "\"lastAccessedGatewayTime\":\"\"}"; + } + return gatewayCfgStr; + + } + +} diff --git a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/utils/GatewayListOptions.java b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/utils/GatewayListOptions.java new file mode 100644 index 00000000..9a21bab2 --- /dev/null +++ b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/utils/GatewayListOptions.java @@ -0,0 +1,84 @@ +package com.clearblade.cloud.iot.v1.utils; + +public class GatewayListOptions { + + private GatewayType gatewayType; + private String associationsGatewayId; + private String associationsDeviceId; + + public GatewayListOptions() { + } + + public GatewayType getGatewayType() { + return gatewayType; + } + + public String getAssociationsGatewayId() { + return associationsGatewayId; + } + + public String getAssociationsDeviceId() { + return associationsDeviceId; + } + + public void setGatewayType(GatewayType gatewayType) { + this.gatewayType = gatewayType; + } + + public void setAssociationsGatewayId(String associationsGatewayId) { + this.associationsGatewayId = associationsGatewayId; + } + + public void setAssociationsDeviceId(String associationsDeviceId) { + this.associationsDeviceId = associationsDeviceId; + } + + private GatewayListOptions(Builder builder) { + gatewayType = builder.gatewayType; + associationsDeviceId = builder.associationsDeviceId; + associationsGatewayId = builder.associationsGatewayId; + } + + public static Builder newBuilder() { + return new Builder(); + } + + public Builder toBuilder() { + return new Builder(this); + } + + public static class Builder { + private GatewayType gatewayType; + private String associationsGatewayId; + private String associationsDeviceId; + + protected Builder() { + } + + private Builder(GatewayListOptions gatewayListOptions) { + this.gatewayType = gatewayListOptions.gatewayType; + this.associationsDeviceId = gatewayListOptions.associationsDeviceId; + this.associationsGatewayId = gatewayListOptions.associationsGatewayId; + } + + public Builder setGatewayType(GatewayType gatewayType) { + this.gatewayType = gatewayType; + return this; + } + + public Builder setAssociationsGatewayId(String associationsGatewayId) { + this.associationsGatewayId = associationsGatewayId; + return this; + } + + public Builder setAssociationsDeviceId(String associationsDeviceId) { + this.associationsDeviceId = associationsDeviceId; + return this; + } + + public GatewayListOptions build() { + return new GatewayListOptions(this); + } + } + +} diff --git a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/utils/GatewayType.java b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/utils/GatewayType.java new file mode 100644 index 00000000..ccc9473f --- /dev/null +++ b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/utils/GatewayType.java @@ -0,0 +1,60 @@ +package com.clearblade.cloud.iot.v1.utils; + +public enum GatewayType { + + GATEWAY_TYPE_UNSPECIFIED(0), + GATEWAY(1), + NON_GATEWAY(2), + UNRECOGNIZED(-1), + ; + + public static final int GATEWAY_TYPE_UNSPECIFIED_VALUE = 0; + public static final int GATEWAY_VALUE = 1; + public static final int NON_GATEWAY_VALUE = 2; + + + public final int getNumber() { + if (this == UNRECOGNIZED) { + throw new java.lang.IllegalArgumentException( + "Can't get the number of an unknown enum value."); + } + return value; + } + + /** + * @param value The numeric wire value of the corresponding enum entry. + * @return The enum associated with the given numeric wire value. + */ + public static GatewayType valueOf(int value) { + return forNumber(value); + } + + /** + * @param value The numeric wire value of the corresponding enum entry. + * @return The enum associated with the given numeric wire value. + */ + public static GatewayType forNumber(int value) { + switch (value) { + case 0: + return GATEWAY_TYPE_UNSPECIFIED; + case 1: + return GATEWAY; + case 2: + return NON_GATEWAY; + default: + return null; + } + } + + public GatewayType findValueByNumber(int number) { + return GatewayType.forNumber(number); + } + + private final int value; + + private GatewayType(int value) { + this.value = value; + } + + +} diff --git a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/utils/HttpConfig.java b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/utils/HttpConfig.java new file mode 100644 index 00000000..0bd6257c --- /dev/null +++ b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/utils/HttpConfig.java @@ -0,0 +1,60 @@ +package com.clearblade.cloud.iot.v1.utils; + +public class HttpConfig { + + private HttpState httpEnabledState; + + public HttpConfig() { + httpEnabledState = HttpState.HTTP_ENABLED; + } + private HttpConfig(Builder builder) { + this.httpEnabledState = builder.getHttpState(); + } + + + public HttpState getHttpEnabledState() { + return httpEnabledState; + } + + + public void setHttpEnabledState(HttpState httpEnabledState) { + this.httpEnabledState = httpEnabledState; + } + public static Builder newBuilder() { + return new Builder(); + } + + public Builder toBuilder() { + return new Builder(this); + } + + /** + * Builder for setting + * HttpConfig - httpConfig + */ + public static class Builder { + private HttpState httpState; + + protected Builder() { + + } + private Builder(HttpConfig config) { + this.httpState = config.httpEnabledState; + } + public HttpConfig build() { + return new HttpConfig(this); + } + public HttpState getHttpState() { + return httpState; + } + public Builder setHttpState(HttpState state) { + this.httpState = state; + return this; + } + + } + @Override + public String toString() { + return "HttpState="+this.httpEnabledState; + } +} diff --git a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/utils/HttpState.java b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/utils/HttpState.java new file mode 100644 index 00000000..d5b55ebd --- /dev/null +++ b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/utils/HttpState.java @@ -0,0 +1,57 @@ +package com.clearblade.cloud.iot.v1.utils; + +public enum HttpState { + HTTP_STATE_UNSPECIFIED(0), + HTTP_ENABLED(1), + HTTP_DISABLED(2), + UNRECOGNIZED(-1), + ; + + public static final int HTTP_STATE_UNSPECIFIED_VALUE = 0; + public static final int HTTP_ENABLED_VALUE = 1; + public static final int HTTP_DISABLED_VALUE = 2; + + public final int getNumber() { + if (this == UNRECOGNIZED) { + throw new java.lang.IllegalArgumentException( + "Can't get the number of an unknown enum value."); + } + return value; + } + + /** + * @param value The numeric wire value of the corresponding enum entry. + * @return The enum associated with the given numeric wire value. + */ + public static HttpState valueOf(int value) { + return forNumber(value); + } + + /** + * @param value The numeric wire value of the corresponding enum entry. + * @return The enum associated with the given numeric wire value. + */ + public static HttpState forNumber(int value) { + switch (value) { + case 0: + return HTTP_STATE_UNSPECIFIED; + case 1: + return HTTP_ENABLED; + case 2: + return HTTP_DISABLED; + default: + return null; + } + } + + public HttpState findValueByNumber(int number) { + return HttpState.forNumber(number); + } + + private final int value; + + private HttpState(int value) { + this.value = value; + } + + } diff --git a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/utils/LogLevel.java b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/utils/LogLevel.java new file mode 100644 index 00000000..e630eaf0 --- /dev/null +++ b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/utils/LogLevel.java @@ -0,0 +1,58 @@ +package com.clearblade.cloud.iot.v1.utils; + +public enum LogLevel { + LOG_LEVEL_UNSPECIFIED(0), NONE(10), ERROR(20), INFO(30), DEBUG(40), UNRECOGNIZED(-1),; + + public static final int LOG_LEVEL_UNSPECIFIED_VALUE = 0; + public static final int NONE_VALUE = 10; + public static final int ERROR_VALUE = 20; + public static final int INFO_VALUE = 30; + public static final int DEBUG_VALUE = 40; + + public final int getNumber() { + if (this == UNRECOGNIZED) { + throw new java.lang.IllegalArgumentException("Can't get the number of an unknown enum value."); + } + return value; + } + + /** + * @param value The numeric wire value of the corresponding enum entry. + * @return The enum associated with the given numeric wire value. + */ + public static LogLevel valueOf(int value) { + return forNumber(value); + } + + /** + * @param value The numeric wire value of the corresponding enum entry. + * @return The enum associated with the given numeric wire value. + */ + public static LogLevel forNumber(int value) { + switch (value) { + case 0: + return LOG_LEVEL_UNSPECIFIED; + case 10: + return NONE; + case 20: + return ERROR; + case 30: + return INFO; + case 40: + return DEBUG; + default: + return null; + } + } + + public LogLevel findValueByNumber(int number) { + return LogLevel.forNumber(number); + } + + private final int value; + + private LogLevel(int value) { + this.value = value; + } + +} diff --git a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/utils/MqttConfig.java b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/utils/MqttConfig.java new file mode 100644 index 00000000..e8138a16 --- /dev/null +++ b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/utils/MqttConfig.java @@ -0,0 +1,58 @@ +package com.clearblade.cloud.iot.v1.utils; + +public class MqttConfig { + + private MqttState mqttEnabledState; + + public MqttConfig() { + mqttEnabledState = MqttState.MQTT_ENABLED; + } + private MqttConfig(Builder builder) { + this.mqttEnabledState = builder.mqttEnabledState; + } + + + public MqttState getMqttEnabledState() { + return mqttEnabledState; + } + public void setMqttEnabledState(MqttState mqttEnabledState) { + this.mqttEnabledState = mqttEnabledState; + } + public static Builder newBuilder() { + return new Builder(); + } + + public Builder toBuilder() { + return new Builder(this); + } + + /** + * Builder for setting + * MqttState - mqttEnabledState + */ + public static class Builder { + private MqttState mqttEnabledState; + + protected Builder() { + + } + private Builder(MqttConfig config) { + this.mqttEnabledState = config.mqttEnabledState; + } + public MqttConfig build() { + return new MqttConfig(this); + } + public MqttState getMqttEnabledState() { + return mqttEnabledState; + } + public Builder setMqttEnabledState(MqttState mqttEnabledState) { + this.mqttEnabledState = mqttEnabledState; + return this; + } + + } + @Override + public String toString() { + return this.mqttEnabledState.toString(); + } +} diff --git a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/utils/MqttState.java b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/utils/MqttState.java new file mode 100644 index 00000000..94355c15 --- /dev/null +++ b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/utils/MqttState.java @@ -0,0 +1,57 @@ +package com.clearblade.cloud.iot.v1.utils; + +public enum MqttState { + MQTT_STATE_UNSPECIFIED(0), + MQTT_ENABLED(1), + MQTT_DISABLED(2), + UNRECOGNIZED(-1), + ; + + public static final int MQTT_STATE_UNSPECIFIED_VALUE = 0; + public static final int MQTT_ENABLED_VALUE = 1; + public static final int MQTT_DISABLED_VALUE = 2; + + public final int getNumber() { + if (this == UNRECOGNIZED) { + throw new java.lang.IllegalArgumentException( + "Can't get the number of an unknown enum value."); + } + return value; + } + + /** + * @param value The numeric wire value of the corresponding enum entry. + * @return The enum associated with the given numeric wire value. + */ + public static MqttState valueOf(int value) { + return forNumber(value); + } + + /** + * @param value The numeric wire value of the corresponding enum entry. + * @return The enum associated with the given numeric wire value. + */ + public static MqttState forNumber(int value) { + switch (value) { + case 0: + return MQTT_STATE_UNSPECIFIED; + case 1: + return MQTT_ENABLED; + case 2: + return MQTT_DISABLED; + default: + return null; + } + } + + public MqttState findValueByNumber(int number) { + return MqttState.forNumber(number); + } + + private final int value; + + private MqttState(int value) { + this.value = value; + } + + } diff --git a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/utils/PublicKeyCertificate.java b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/utils/PublicKeyCertificate.java new file mode 100644 index 00000000..aa88c6a7 --- /dev/null +++ b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/utils/PublicKeyCertificate.java @@ -0,0 +1,32 @@ +package com.clearblade.cloud.iot.v1.utils; + +public class PublicKeyCertificate { + + private PublicKeyCertificateFormat format; + private String certificate; + private X509CertificateDetails x509Details; + + public PublicKeyCertificateFormat getFormat() { + return format; + } + public void setFormat(PublicKeyCertificateFormat format) { + this.format = format; + } + public String getCertificate() { + return certificate; + } + public void setCertificate(String certificate) { + this.certificate = certificate; + } + public X509CertificateDetails getX509Details() { + return x509Details; + } + public void setX509Details(X509CertificateDetails x509Details) { + this.x509Details = x509Details; + } + @Override + public String toString() { + return "PublicKeyCertificateFormat="+this.format.toString()+",Certificate="+certificate+",X509CertificateDetails="+this.x509Details.toString(); + } + +} diff --git a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/utils/PublicKeyCertificateFormat.java b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/utils/PublicKeyCertificateFormat.java new file mode 100644 index 00000000..e62daba7 --- /dev/null +++ b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/utils/PublicKeyCertificateFormat.java @@ -0,0 +1,49 @@ +package com.clearblade.cloud.iot.v1.utils; + +public enum PublicKeyCertificateFormat { + UNSPECIFIED_PUBLIC_KEY_CERTIFICATE_FORMAT(0), X509_CERTIFICATE_PEM(1), UNRECOGNIZED(-1),; + + public static final int UNSPECIFIED_PUBLIC_KEY_CERTIFICATE_FORMAT_VALUE = 0; + public static final int X509_CERTIFICATE_PEM_VALUE = 1; + + public final int getNumber() { + if (this == UNRECOGNIZED) { + throw new java.lang.IllegalArgumentException("Can't get the number of an unknown enum value."); + } + return value; + } + + /** + * @param value The numeric wire value of the corresponding enum entry. + * @return The enum associated with the given numeric wire value. + */ + public static PublicKeyCertificateFormat valueOf(int value) { + return forNumber(value); + } + + /** + * @param value The numeric wire value of the corresponding enum entry. + * @return The enum associated with the given numeric wire value. + */ + public static PublicKeyCertificateFormat forNumber(int value) { + switch (value) { + case 0: + return UNSPECIFIED_PUBLIC_KEY_CERTIFICATE_FORMAT; + case 1: + return X509_CERTIFICATE_PEM; + default: + return null; + } + } + + public PublicKeyCertificateFormat findValueByNumber(int number) { + return PublicKeyCertificateFormat.forNumber(number); + } + + private final int value; + + private PublicKeyCertificateFormat(int value) { + this.value = value; + } + +} diff --git a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/utils/PublicKeyCredential.java b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/utils/PublicKeyCredential.java new file mode 100644 index 00000000..aa76a081 --- /dev/null +++ b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/utils/PublicKeyCredential.java @@ -0,0 +1,67 @@ +package com.clearblade.cloud.iot.v1.utils; + +public class PublicKeyCredential { + + private PublicKeyFormat format; + private String key; + + public PublicKeyCredential() { + } + + public void setFormat(PublicKeyFormat format) { + this.format = format; + } + + public void setKey(String key) { + this.key = key; + } + + private PublicKeyCredential(Builder builder) { + format = builder.format; + key = builder.key; + } + public static Builder newBuilder() { + return new Builder(); + } + + public Builder toBuilder() { + return new Builder(this); + } + + public static class Builder { + private PublicKeyFormat format; + private String key; + + protected Builder() { + + } + + public PublicKeyFormat getFormat() { + return format; + } + + public Builder setFormat(PublicKeyFormat format) { + this.format = format; + return this; + } + + public String getKey() { + return key; + } + + public Builder setKey(String key) { + this.key = key; + return this; + } + + private Builder(PublicKeyCredential publicKeyCredential) { + this.format = publicKeyCredential.format; + this.key = publicKeyCredential.key; + } + public PublicKeyCredential build() { + return new PublicKeyCredential(this); + } + } + + +} diff --git a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/utils/PublicKeyFormat.java b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/utils/PublicKeyFormat.java new file mode 100644 index 00000000..327ecf89 --- /dev/null +++ b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/utils/PublicKeyFormat.java @@ -0,0 +1,58 @@ +package com.clearblade.cloud.iot.v1.utils; + +public enum PublicKeyFormat { + UNSPECIFIED_PUBLIC_KEY_FORMAT(0), RSA_PEM(3), RSA_X509_PEM(1), ES256_PEM(2), ES256_X509_PEM(4), UNRECOGNIZED(-1),; + + public static final int UNSPECIFIED_PUBLIC_KEY_FORMAT_VALUE = 0; + public static final int RSA_PEM_VALUE = 3; + public static final int RSA_X509_PEM_VALUE = 1; + public static final int ES256_PEM_VALUE = 2; + public static final int ES256_X509_PEM_VALUE = 4; + + public final int getNumber() { + if (this == UNRECOGNIZED) { + throw new java.lang.IllegalArgumentException("Can't get the number of an unknown enum value."); + } + return value; + } + + /** + * @param value The numeric wire value of the corresponding enum entry. + * @return The enum associated with the given numeric wire value. + */ + public static PublicKeyFormat valueOf(int value) { + return forNumber(value); + } + + /** + * @param value The numeric wire value of the corresponding enum entry. + * @return The enum associated with the given numeric wire value. + */ + public static PublicKeyFormat forNumber(int value) { + switch (value) { + case 0: + return UNSPECIFIED_PUBLIC_KEY_FORMAT; + case 3: + return RSA_PEM; + case 1: + return RSA_X509_PEM; + case 2: + return ES256_PEM; + case 4: + return ES256_X509_PEM; + default: + return null; + } + } + + public PublicKeyFormat findValueByNumber(int number) { + return PublicKeyFormat.forNumber(number); + } + + private final int value; + + private PublicKeyFormat(int value) { + this.value = value; + } + +} diff --git a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/utils/RegistryCredential.java b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/utils/RegistryCredential.java new file mode 100644 index 00000000..468bc96f --- /dev/null +++ b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/utils/RegistryCredential.java @@ -0,0 +1,58 @@ +package com.clearblade.cloud.iot.v1.utils; + +public class RegistryCredential { + + private final PublicKeyCertificate publicKeyCertificate; + public RegistryCredential() { + publicKeyCertificate = null; + } + private RegistryCredential(Builder builder) { + publicKeyCertificate = builder.getPublicKeyCertificate(); + } + + public static Builder newBuilder() { + return new Builder(); + } + + public Builder toBuilder() { + return new Builder(this); + } + /** + * Builder for setting + * RegistryCredential + */ + public static class Builder { + private PublicKeyCertificate publicKeyCertificate; + + protected Builder() { + + } + + public PublicKeyCertificate getPublicKeyCertificate() { + return publicKeyCertificate; + } + + public Builder setPublicKeyCertificate(PublicKeyCertificate publicKeyCertificate) { + this.publicKeyCertificate = publicKeyCertificate; + return this; + } + + private Builder(RegistryCredential registryCredential) { + this.publicKeyCertificate = registryCredential.publicKeyCertificate; + } + + public RegistryCredential build() { + return new RegistryCredential(this); + } + } + + @Override + public String toString() { + return "PublicKeyCertificate="+this.publicKeyCertificate; + } + + + + + +} diff --git a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/utils/RegistryName.java b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/utils/RegistryName.java index ea886db7..26508b89 100644 --- a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/utils/RegistryName.java +++ b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/utils/RegistryName.java @@ -100,4 +100,8 @@ public RegistryName build() { public String toString() { return "projects/"+this.getProject()+"/locations/"+this.getLocation(); } + + public String getRegistryFullName() { + return "projects/"+this.getProject()+"/locations/"+this.getLocation()+"/registries/"+this.getRegistry(); + } } diff --git a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/utils/StateNotificationConfig.java b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/utils/StateNotificationConfig.java new file mode 100644 index 00000000..89e579c2 --- /dev/null +++ b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/utils/StateNotificationConfig.java @@ -0,0 +1,57 @@ +package com.clearblade.cloud.iot.v1.utils; + +public class StateNotificationConfig { + + private String pubsubTopicName; + + public StateNotificationConfig() { + pubsubTopicName = ""; + } + private StateNotificationConfig(Builder builder) { + pubsubTopicName = builder.getPubsubTopicName(); + } + + public String getPubsubTopicName() { + return pubsubTopicName; + } + public void setPubsubTopicName(String pubsubTopicName) { + this.pubsubTopicName = pubsubTopicName; + } + public static Builder newBuilder() { + return new Builder(); + } + + public Builder toBuilder() { + return new Builder(this); + } + + /** + * Builder for setting + * StateNotificationConfig - pubsubTopicName + */ + public static class Builder { + private String pubsubTopicName; + + protected Builder() { + + } + private Builder(StateNotificationConfig stateNotificationConfig) { + this.pubsubTopicName = stateNotificationConfig.pubsubTopicName; + } + public StateNotificationConfig build() { + return new StateNotificationConfig(this); + } + public String getPubsubTopicName() { + return pubsubTopicName; + } + public Builder setPubsubTopicName(String pubsubTopicName) { + this.pubsubTopicName = pubsubTopicName; + return this; + } + + } + @Override + public String toString() { + return "pubsubTopicName="+this.pubsubTopicName; + } +} diff --git a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/utils/Status.java b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/utils/Status.java new file mode 100644 index 00000000..aa52069c --- /dev/null +++ b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/utils/Status.java @@ -0,0 +1,117 @@ +package com.clearblade.cloud.iot.v1.utils; + +import java.util.List; + +public class Status { + private int code; + private String message; + private List details; + + public Status() { + } + + private Status(Builder builder) { + code = builder.code; + message = builder.message; + details = builder.details; + } + + public void setCode(Object code) { + if (code != null) + this.code = Integer.parseInt(code.toString()); + } + + public void setMessage(String message) { + this.message = message; + } + + public void setDetails(List details) { + this.details = details; + } + + public int getCode() { + return code; + } + + public String getMessage() { + return message; + } + + public List getDetails() { + return details; + } + + public static Builder newBuilder() { + return new Builder(); + } + + public Builder toBuilder() { + return new Builder(this); + } + + public static class Builder { + private int code; + private String message; + private List details; + + protected Builder() { + } + + + public int getCode() { + return code; + } + + public Builder setCode(int code) { + this.code = code; + return this; + } + + + public String getMessage() { + return message; + } + + + public Builder setMessage(String message) { + this.message = message; + return this; + } + + + public List getDetails() { + return details; + } + + public Builder setDetails(List details) { + this.details = details; + return this; + } + + + private Builder(Status status) { + this.code = status.code; + this.message = status.message; + this.details = status.details; + } + public Status build() { + return new Status(this); + } + } + + @Override + public String toString() { + String statuStr = ""; + if(this.getCode() != 0) { + statuStr+= "{\"code\":\""+this.getCode()+"\","; + }else { + statuStr+= "{\"code\":\"0\","; + } + if(this.getMessage() != null) { + statuStr+= "\"message\":\""+this.getMessage()+"\"}"; + }else { + statuStr+= "\"message\":\"\"}"; + } + return statuStr; + } +} diff --git a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/utils/X509CertificateDetails.java b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/utils/X509CertificateDetails.java new file mode 100644 index 00000000..5b3c7202 --- /dev/null +++ b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/utils/X509CertificateDetails.java @@ -0,0 +1,57 @@ +package com.clearblade.cloud.iot.v1.utils; + +import java.sql.Timestamp; + +public class X509CertificateDetails { + + private String issuer; + private String subject; + private Timestamp startTime; + private Timestamp expiryTime; + private String signatureAlgorithm; + private String publicKeyType; + + + public String getIssuer() { + return issuer; + } + public void setIssuer(String issuer) { + this.issuer = issuer; + } + public String getSubject() { + return subject; + } + public void setSubject(String subject) { + this.subject = subject; + } + public Timestamp getStartTime() { + return startTime; + } + public void setStartTime(Timestamp startTime) { + this.startTime = startTime; + } + public Timestamp getExpiryTime() { + return expiryTime; + } + public void setExpiryTime(Timestamp expiryTime) { + this.expiryTime = expiryTime; + } + public String getSignatureAlgorithm() { + return signatureAlgorithm; + } + public void setSignatureAlgorithm(String signatureAlgorithm) { + this.signatureAlgorithm = signatureAlgorithm; + } + public String getPublicKeyType() { + return publicKeyType; + } + public void setPublicKeyType(String publicKeyType) { + this.publicKeyType = publicKeyType; + } + + @Override + public String toString() { + return "Issuer= "+this.issuer+",Subject="+this.subject+",startTime="+this.startTime+",expiryTime="+this.expiryTime+",signatureAlgorithm="+this.signatureAlgorithm+",publicKeyType="+this.publicKeyType; + } + +} From 0fabc2bbdaac47085ffee7e6087db10b15fa3e8c Mon Sep 17 00:00:00 2001 From: RashmiK14 Date: Mon, 21 Nov 2022 21:14:40 +0530 Subject: [PATCH 014/151] Committing changes related to deviceConfigVersionList --- .../AsyncDevicesConfigVersionsList.java | 37 ----- .../SyncDevicesConfigVersionsList.java | 37 ----- .../AsyncDeviceStatesList.java | 2 - .../SyncDeviceStatesList.java | 1 - .../AsyncListDeviceConfigVersions.java | 28 ++++ .../SyncListDeviceConfigVersions.java | 28 ++++ .../clearblade/cloud/iot/v1/AsyncClient.java | 20 ++- .../cloud/iot/v1/ClearBladeDeviceManager.java | 35 +++++ .../iot/v1/DeviceManagerAsyncClient.java | 7 + .../cloud/iot/v1/DeviceManagerClient.java | 14 +- .../DeviceConfigVersionsListResponse.java | 130 ------------------ .../ListDeviceConfigVersionsRequest.java} | 21 ++- .../ListDeviceConfigVersionsResponse.java | 84 +++++++++++ .../cloud/iot/v1/utils/ConfigParameters.java | 10 ++ .../cloud/iot/v1/utils/DeviceRegistry.java | 20 +-- clearblade-cloud-iot/src/config.properties | 2 +- 16 files changed, 244 insertions(+), 232 deletions(-) delete mode 100644 clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/devicesconfigversionslist/AsyncDevicesConfigVersionsList.java delete mode 100644 clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/devicesconfigversionslist/SyncDevicesConfigVersionsList.java create mode 100644 clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/listdeviceconfigversions/AsyncListDeviceConfigVersions.java create mode 100644 clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/listdeviceconfigversions/SyncListDeviceConfigVersions.java delete mode 100644 clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/deviceconfigversionslist/DeviceConfigVersionsListResponse.java rename clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/{deviceconfigversionslist/DeviceConfigVersionsListRequest.java => listdeviceconfigversions/ListDeviceConfigVersionsRequest.java} (67%) create mode 100644 clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/listdeviceconfigversions/ListDeviceConfigVersionsResponse.java diff --git a/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/devicesconfigversionslist/AsyncDevicesConfigVersionsList.java b/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/devicesconfigversionslist/AsyncDevicesConfigVersionsList.java deleted file mode 100644 index 7b286e73..00000000 --- a/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/devicesconfigversionslist/AsyncDevicesConfigVersionsList.java +++ /dev/null @@ -1,37 +0,0 @@ -package com.clearblade.cloud.iot.v1.devicesconfigversionslist; - -import java.util.logging.Level; -import java.util.logging.Logger; - -import com.clearblade.cloud.iot.v1.DeviceManagerClient; -import com.clearblade.cloud.iot.v1.deviceconfigversionslist.DeviceConfigVersionsListRequest; -import com.clearblade.cloud.iot.v1.deviceconfigversionslist.DeviceConfigVersionsListResponse; - -public class AsyncDevicesConfigVersionsList { - - static Logger log = Logger.getLogger(AsyncDevicesConfigVersionsList.class.getName()); - - public static void main(String[] args) { - asyncDevicesConfigVersionsList(); - } - - public static void asyncDevicesConfigVersionsList() { - String msg = ""; - String name = "Rashmi_Device_Test"; - DeviceManagerClient deviceManagerClient = new DeviceManagerClient(); - - DeviceConfigVersionsListRequest request = DeviceConfigVersionsListRequest.Builder.newBuilder().setName(name).setNumVersions("2").build(); - DeviceConfigVersionsListResponse response = deviceManagerClient.deviceConfigVersionsList(request); - if (response != null) { - response.processRequest(request); - if (response.getHttpStatusResponse().equals("OK")) { - log.log(Level.INFO, "AsyncDevicesConfigVersionsList Method worked successfully :: {0}",response.getHttpStatusResponse()); - } else { - log.log(Level.SEVERE, "AsyncDevicesConfigVersionsList Method execution failed :: {0}",response.getHttpStatusResponse()); - } - } else { - log.log(Level.SEVERE, "AsyncDevicesConfigVersionsList Method execution failed"); - } - } - -} diff --git a/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/devicesconfigversionslist/SyncDevicesConfigVersionsList.java b/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/devicesconfigversionslist/SyncDevicesConfigVersionsList.java deleted file mode 100644 index 7c0d9b61..00000000 --- a/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/devicesconfigversionslist/SyncDevicesConfigVersionsList.java +++ /dev/null @@ -1,37 +0,0 @@ -package com.clearblade.cloud.iot.v1.devicesconfigversionslist; - -import java.util.logging.Level; -import java.util.logging.Logger; - -import com.clearblade.cloud.iot.v1.DeviceManagerClient; -import com.clearblade.cloud.iot.v1.deviceconfigversionslist.DeviceConfigVersionsListRequest; -import com.clearblade.cloud.iot.v1.deviceconfigversionslist.DeviceConfigVersionsListResponse; - -public class SyncDevicesConfigVersionsList { - - static Logger log = Logger.getLogger(SyncDevicesConfigVersionsList.class.getName()); - - public static void main(String[] args) { - syncDevicesConfigVersionsList(); - } - - public static void syncDevicesConfigVersionsList() { - String msg = ""; - String name = "Rashmi_Device_Test"; - DeviceManagerClient deviceManagerClient = new DeviceManagerClient(); - - DeviceConfigVersionsListRequest request = DeviceConfigVersionsListRequest.Builder.newBuilder().setName(name).setNumVersions("2").build(); - DeviceConfigVersionsListResponse response = deviceManagerClient.deviceConfigVersionsList(request); - if (response != null) { - response.processRequest(request); - if (response.getHttpStatusResponse().equals("OK")) { - log.log(Level.INFO, "SyncDevicesConfigVersionsList Method worked successfully :: {0}",response.getHttpStatusResponse()); - } else { - log.log(Level.SEVERE, "SyncDevicesConfigVersionsList Method execution failed :: {0}",response.getHttpStatusResponse()); - } - } else { - log.log(Level.SEVERE, "SyncDevicesConfigVersionsList Method execution failed"); - } - } - -} diff --git a/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/devicestateslist/AsyncDeviceStatesList.java b/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/devicestateslist/AsyncDeviceStatesList.java index a72e31cb..793391e2 100644 --- a/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/devicestateslist/AsyncDeviceStatesList.java +++ b/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/devicestateslist/AsyncDeviceStatesList.java @@ -1,10 +1,8 @@ package com.clearblade.cloud.iot.v1.devicestateslist; -import java.util.logging.Level; import java.util.logging.Logger; import com.clearblade.cloud.iot.v1.DeviceManagerAsyncClient; -import com.clearblade.cloud.iot.v1.DeviceManagerClient; import com.clearblade.cloud.iot.v1.utils.DeviceName; import com.clearblade.cloud.iot.v1.utils.DeviceState; diff --git a/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/devicestateslist/SyncDeviceStatesList.java b/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/devicestateslist/SyncDeviceStatesList.java index 36697838..19696f66 100644 --- a/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/devicestateslist/SyncDeviceStatesList.java +++ b/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/devicestateslist/SyncDeviceStatesList.java @@ -1,6 +1,5 @@ package com.clearblade.cloud.iot.v1.devicestateslist; -import java.util.logging.Level; import java.util.logging.Logger; import com.clearblade.cloud.iot.v1.DeviceManagerClient; diff --git a/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/listdeviceconfigversions/AsyncListDeviceConfigVersions.java b/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/listdeviceconfigversions/AsyncListDeviceConfigVersions.java new file mode 100644 index 00000000..eef34596 --- /dev/null +++ b/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/listdeviceconfigversions/AsyncListDeviceConfigVersions.java @@ -0,0 +1,28 @@ +package com.clearblade.cloud.iot.v1.listdeviceconfigversions; + +import java.util.logging.Logger; + +import com.clearblade.cloud.iot.v1.DeviceManagerAsyncClient; +import com.clearblade.cloud.iot.v1.utils.DeviceConfig; +import com.clearblade.cloud.iot.v1.utils.DeviceName; + +public class AsyncListDeviceConfigVersions { + + static Logger log = Logger.getLogger(AsyncListDeviceConfigVersions.class.getName()); + + public static void main(String[] args) { + asyncDevicesConfigVersionsList(); + } + + public static void asyncDevicesConfigVersionsList() { + DeviceManagerAsyncClient deviceManagerAsyncClient = new DeviceManagerAsyncClient(); + ListDeviceConfigVersionsRequest request = ListDeviceConfigVersionsRequest.Builder.newBuilder().setName(DeviceName + .of("ingressdevelopmentenv", "us-central1", "Rashmi_Registry_Test", "Rashmi_Device_Test") + .toString()).setNumVersions(2).build(); + ListDeviceConfigVersionsResponse response = deviceManagerAsyncClient.listDeviceConfigVersions(request); + for (DeviceConfig element : response.getDeviceConfigList()) { + System.out.println(element.toString()); + } + } + +} diff --git a/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/listdeviceconfigversions/SyncListDeviceConfigVersions.java b/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/listdeviceconfigversions/SyncListDeviceConfigVersions.java new file mode 100644 index 00000000..0fdaf9ea --- /dev/null +++ b/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/listdeviceconfigversions/SyncListDeviceConfigVersions.java @@ -0,0 +1,28 @@ +package com.clearblade.cloud.iot.v1.listdeviceconfigversions; + +import java.util.logging.Logger; + +import com.clearblade.cloud.iot.v1.DeviceManagerClient; +import com.clearblade.cloud.iot.v1.utils.DeviceConfig; +import com.clearblade.cloud.iot.v1.utils.DeviceName; + +public class SyncListDeviceConfigVersions { + + static Logger log = Logger.getLogger(SyncListDeviceConfigVersions.class.getName()); + + public static void main(String[] args) { + syncDevicesConfigVersionsList(); + } + + public static void syncDevicesConfigVersionsList() { + DeviceManagerClient deviceManagerClient = new DeviceManagerClient(); + ListDeviceConfigVersionsRequest request = ListDeviceConfigVersionsRequest.Builder.newBuilder().setName(DeviceName + .of("ingressdevelopmentenv", "us-central1", "Rashmi_Registry_Test", "Rashmi_Device_Test") + .toString()).setNumVersions(2).build(); + ListDeviceConfigVersionsResponse response = deviceManagerClient.listDeviceConfigVersions(request); + for (DeviceConfig element : response.getDeviceConfigList()) { + System.out.println(element.toString()); + } + } + +} diff --git a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/AsyncClient.java b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/AsyncClient.java index a8c14e6e..a8edfdfc 100644 --- a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/AsyncClient.java +++ b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/AsyncClient.java @@ -414,7 +414,25 @@ public String[] asyncListDevices(String apiName,String params) throws Interrupte return responseArray; } -//Registry Apis + private Future listDeviceConfigVersionsAsync() { + return CompletableFuture.supplyAsync(this::get); + } + + public String[] asyncListDeviceConfigVersions(String apiName, String params) + throws InterruptedException { + this.apiName = apiName; + this.params = params; + Future future = listDeviceConfigVersionsAsync(); + try { + future.get(15000, TimeUnit.MILLISECONDS); + } catch (InterruptedException | ExecutionException | TimeoutException e) { + e.printStackTrace(); + Thread.currentThread().interrupt(); + } + return responseArray; + } + + //Registry Apis /** * Method used to generate URL for apicall * @param apiName - path to api diff --git a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/ClearBladeDeviceManager.java b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/ClearBladeDeviceManager.java index 649e6a08..3de81d30 100644 --- a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/ClearBladeDeviceManager.java +++ b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/ClearBladeDeviceManager.java @@ -9,6 +9,8 @@ import com.clearblade.cloud.iot.v1.devicestateslist.ListDeviceStatesRequest; import com.clearblade.cloud.iot.v1.devicestateslist.ListDeviceStatesResponse; import com.clearblade.cloud.iot.v1.getdevice.GetDeviceRequest; +import com.clearblade.cloud.iot.v1.listdeviceconfigversions.ListDeviceConfigVersionsRequest; +import com.clearblade.cloud.iot.v1.listdeviceconfigversions.ListDeviceConfigVersionsResponse; import com.clearblade.cloud.iot.v1.modifycloudtodeviceconfig.ModifyCloudToDeviceConfigRequest; import com.clearblade.cloud.iot.v1.sendcommandtodevice.SendCommandToDeviceRequest; import com.clearblade.cloud.iot.v1.sendcommandtodevice.SendCommandToDeviceResponse; @@ -315,4 +317,37 @@ public ListDeviceStatesResponse asyncListDeviceStates(ListDeviceStatesRequest re return null; } + public ListDeviceConfigVersionsResponse listDeviceConfigVersions(ListDeviceConfigVersionsRequest request) { + SyncClient syncClient = new SyncClient(); + String[] responseArray = syncClient.get(configParameters.getCloudiotConfigURLExtension(), + request.getParamsForList()); + int responseCode = Integer.parseInt(responseArray[0]); + if (responseCode == 200) { + ListDeviceConfigVersionsResponse listDeviceConfigVersionsResponse = ListDeviceConfigVersionsResponse.Builder.newBuilder() + .buildResponse(responseArray[2]).build(); + // deviceObj.loadFromString(responseArray[2]); + return listDeviceConfigVersionsResponse; + } + return null; + } + + public ListDeviceConfigVersionsResponse asyncListDeviceConfigVersions(ListDeviceConfigVersionsRequest request) { + try { + AsyncClient asyncClient = new AsyncClient(); + String[] responseArray = asyncClient.asyncListDeviceConfigVersions(configParameters.getCloudiotConfigURLExtension(), + request.getParamsForList()); + int responseCode = Integer.parseInt(responseArray[0]); + if (responseCode == 200) { + ListDeviceConfigVersionsResponse listDeviceConfigVersionsResponse = ListDeviceConfigVersionsResponse.Builder.newBuilder() + .buildResponse(responseArray[2]).build(); + // deviceObj.loadFromString(responseArray[2]); + return listDeviceConfigVersionsResponse; + } + }catch(Exception e) { + e.printStackTrace(); + } + return null; + } + + } diff --git a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/DeviceManagerAsyncClient.java b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/DeviceManagerAsyncClient.java index 19799070..15409963 100644 --- a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/DeviceManagerAsyncClient.java +++ b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/DeviceManagerAsyncClient.java @@ -12,6 +12,8 @@ import com.clearblade.cloud.iot.v1.devicestateslist.ListDeviceStatesResponse; import com.clearblade.cloud.iot.v1.getdevice.GetDeviceRequest; import com.clearblade.cloud.iot.v1.getdeviceregistry.GetDeviceRegistryRequest; +import com.clearblade.cloud.iot.v1.listdeviceconfigversions.ListDeviceConfigVersionsRequest; +import com.clearblade.cloud.iot.v1.listdeviceconfigversions.ListDeviceConfigVersionsResponse; import com.clearblade.cloud.iot.v1.modifycloudtodeviceconfig.ModifyCloudToDeviceConfigRequest; import com.clearblade.cloud.iot.v1.sendcommandtodevice.SendCommandToDeviceRequest; import com.clearblade.cloud.iot.v1.sendcommandtodevice.SendCommandToDeviceResponse; @@ -111,6 +113,11 @@ public ListDeviceStatesResponse listDeviceStates(ListDeviceStatesRequest request ClearBladeDeviceManager cbManager = new ClearBladeDeviceManager(); return cbManager.asyncListDeviceStates(request); } + + public ListDeviceConfigVersionsResponse listDeviceConfigVersions(ListDeviceConfigVersionsRequest request) { + ClearBladeDeviceManager cbManager = new ClearBladeDeviceManager(); + return cbManager.asyncListDeviceConfigVersions(request); + } //Registry Apis /** diff --git a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/DeviceManagerClient.java b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/DeviceManagerClient.java index c7687436..1e01482a 100644 --- a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/DeviceManagerClient.java +++ b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/DeviceManagerClient.java @@ -5,8 +5,6 @@ import com.clearblade.cloud.iot.v1.binddevicetogateway.BindDeviceToGatewayRequest; import com.clearblade.cloud.iot.v1.binddevicetogateway.BindDeviceToGatewayResponse; import com.clearblade.cloud.iot.v1.createdevice.CreateDeviceRequest; -import com.clearblade.cloud.iot.v1.createdeviceregistry.CreateDeviceRegistryRequest; -import com.clearblade.cloud.iot.v1.createdeviceregistry.CreateDeviceRegistryResponse; import com.clearblade.cloud.iot.v1.deletedevice.DeleteDeviceRequest; import com.clearblade.cloud.iot.v1.deviceslist.DevicesListRequest; import com.clearblade.cloud.iot.v1.deviceslist.DevicesListResponse; @@ -14,24 +12,22 @@ import com.clearblade.cloud.iot.v1.devicestateslist.ListDeviceStatesResponse; import com.clearblade.cloud.iot.v1.getdevice.GetDeviceRequest; import com.clearblade.cloud.iot.v1.getdeviceregistry.GetDeviceRegistryRequest; +import com.clearblade.cloud.iot.v1.listdeviceconfigversions.ListDeviceConfigVersionsRequest; +import com.clearblade.cloud.iot.v1.listdeviceconfigversions.ListDeviceConfigVersionsResponse; import com.clearblade.cloud.iot.v1.modifycloudtodeviceconfig.ModifyCloudToDeviceConfigRequest; import com.clearblade.cloud.iot.v1.sendcommandtodevice.SendCommandToDeviceRequest; import com.clearblade.cloud.iot.v1.sendcommandtodevice.SendCommandToDeviceResponse; import com.clearblade.cloud.iot.v1.unbinddevicefromgateway.UnbindDeviceFromGatewayRequest; import com.clearblade.cloud.iot.v1.unbinddevicefromgateway.UnbindDeviceFromGatewayResponse; import com.clearblade.cloud.iot.v1.updatedevice.UpdateDeviceRequest; -import com.clearblade.cloud.iot.v1.updatedeviceregistry.UpdateDeviceRegistryRequest; -import com.clearblade.cloud.iot.v1.updatedeviceregistry.UpdateDeviceRegistryResponse; import com.clearblade.cloud.iot.v1.utils.Device; import com.clearblade.cloud.iot.v1.utils.DeviceConfig; import com.clearblade.cloud.iot.v1.utils.DeviceRegistry; -import com.clearblade.cloud.iot.v1.utils.RegistryName; public class DeviceManagerClient { static Logger log = Logger.getLogger(DeviceManagerClient.class.getName()); - /** * Calling getDevice api * @param request @@ -115,6 +111,12 @@ public ListDeviceStatesResponse listDeviceStates(ListDeviceStatesRequest request } + public ListDeviceConfigVersionsResponse listDeviceConfigVersions(ListDeviceConfigVersionsRequest request) { + ClearBladeDeviceManager cbManager = new ClearBladeDeviceManager(); + return cbManager.listDeviceConfigVersions(request); + + } + //Registry Apis /** * Calling getDeviceRegistry api diff --git a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/deviceconfigversionslist/DeviceConfigVersionsListResponse.java b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/deviceconfigversionslist/DeviceConfigVersionsListResponse.java deleted file mode 100644 index 0f15bf68..00000000 --- a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/deviceconfigversionslist/DeviceConfigVersionsListResponse.java +++ /dev/null @@ -1,130 +0,0 @@ -package com.clearblade.cloud.iot.v1.deviceconfigversionslist; - -import java.util.logging.Level; -import java.util.logging.Logger; - -import org.json.simple.JSONObject; - -import com.clearblade.cloud.iot.v1.ProcessRequest; -import com.clearblade.cloud.iot.v1.utils.Constants; - -public class DeviceConfigVersionsListResponse { - - static Logger log = Logger.getLogger(DeviceConfigVersionsListResponse.class.getName()); - private final DeviceConfigVersionsListRequest request; - private int httpStatusCode; - private String httpStatusResponse; - - protected DeviceConfigVersionsListResponse(Builder builder) { - this.request = builder.request; - } - - public int getHttpStatusCode() { - return httpStatusCode; - } - - public void setHttpStatusCode(int httpStatusCode) { - this.httpStatusCode = httpStatusCode; - } - - public String getHttpStatusResponse() { - return httpStatusResponse; - } - - public void setHttpStatusResponse(String httpStatusResponse) { - this.httpStatusResponse = httpStatusResponse; - } - - // Static class Builder - public static class Builder { - - /// instance fields - private DeviceConfigVersionsListRequest request; - - public static Builder newBuilder() { - return new Builder(); - } - - private Builder() { - } - - // Setter methods - public Builder setDeviceConfigVersionsListRequest(DeviceConfigVersionsListRequest request) { - this.request = request; - return this; - } - - // build method to deal with outer class - // to return outer instance - public DeviceConfigVersionsListResponse build() { - return new DeviceConfigVersionsListResponse(this); - } - } - - /** - * Mehtod used to process the request - * Calling processRequestForMethod - deviceConfigVersionsList - */ - - public void processRequest(DeviceConfigVersionsListRequest request) { - String msg = ""; - JSONObject requestParams = new JSONObject(); - JSONObject bodyParams = new JSONObject(); - ProcessRequest processRequest = new ProcessRequest(); - - if(request != null) { - String logMsg = "Config versions list for device :: "+request.toString(); - log.log(Level.INFO,logMsg); - requestParams = (JSONObject) request.requestParams.clone(); - } - - String responseMessage = processRequest.processRequestForMethod(Constants.DEVICE_CONFIG_VERSIONS_LIST,requestParams,bodyParams); - this.setHttpStatusResponse(responseMessage); - if (responseMessage.equals("OK")) { - msg = "Request processed successfully for DeviceConfigVersionsList method"; - log.log(Level.INFO, msg); - } else { - msg = "POST request not worked for DeviceConfigVersionsList Method \n".concat(responseMessage); - log.log(Level.SEVERE, msg); - } - - } - - public DeviceConfigVersionsListRequest getRequest() { - return request; - } - - /** - * Mehtod used to process the request - * Calling processRequestForMethod - DeviceSetStatesRequest - */ - - /* - * public String processRequestAsync(SendCommandToDeviceRequest request) { - * String msg = ""; JSONObject requestParams = new JSONObject(); JSONObject - * bodyParams = new JSONObject(); ProcessRequest processRequest = new - * ProcessRequest(); - * - * if(request != null) { String logMsg = - * "Sending request to device :: "+request.toString(); - * log.log(Level.INFO,logMsg); requestParams = (JSONObject) - * request.requestParams.clone(); bodyParams = (JSONObject) - * request.bodyParams.clone(); } - * - * String responseMessage = - * processRequest.asyncCallSendCommandToDevice(request); - * this.setHttpStatusResponse(responseMessage); if - * (responseMessage.equals("OK")) { msg = - * "Request processed successfully for SendCommandToDevice method"; - * log.log(Level.INFO, msg); } else { msg = - * "POST request not worked for sendCommandToDevice Method \n".concat( - * responseMessage); log.log(Level.SEVERE, msg); } return responseMessage; - * - * } - * - * @Override public String toString() { return "Http Status Code :: " + - * this.getHttpStatusCode() + " Http Status Response :: " + - * this.getHttpStatusResponse(); } - * - * public SendCommandToDeviceRequest getRequest() { return request; } - */} diff --git a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/deviceconfigversionslist/DeviceConfigVersionsListRequest.java b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/listdeviceconfigversions/ListDeviceConfigVersionsRequest.java similarity index 67% rename from clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/deviceconfigversionslist/DeviceConfigVersionsListRequest.java rename to clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/listdeviceconfigversions/ListDeviceConfigVersionsRequest.java index 13ee9038..4062dd35 100644 --- a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/deviceconfigversionslist/DeviceConfigVersionsListRequest.java +++ b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/listdeviceconfigversions/ListDeviceConfigVersionsRequest.java @@ -1,13 +1,13 @@ -package com.clearblade.cloud.iot.v1.deviceconfigversionslist; +package com.clearblade.cloud.iot.v1.listdeviceconfigversions; import org.json.simple.JSONObject; -public class DeviceConfigVersionsListRequest { +public class ListDeviceConfigVersionsRequest { private final String name; private final String numVersions; JSONObject requestParams; - private DeviceConfigVersionsListRequest(Builder builder) { + private ListDeviceConfigVersionsRequest(Builder builder) { this.name = builder.name; this.numVersions = builder.numVersions; } @@ -32,15 +32,15 @@ public Builder setName(String name) { return this; } - public Builder setNumVersions(String numVersions) { - this.numVersions = numVersions; + public Builder setNumVersions(int numVersions) { + this.numVersions = String.valueOf(numVersions); return this; } // build method to deal with outer class // to return outer instance - public DeviceConfigVersionsListRequest build() { - return new DeviceConfigVersionsListRequest(this); + public ListDeviceConfigVersionsRequest build() { + return new ListDeviceConfigVersionsRequest(this); } } @@ -63,4 +63,11 @@ public String toString() { return "name=" + this.name + ",numVersions=" + this.numVersions; } + public String getParamsForList() { + String params = ""; + params = "name=" + this.name; + params += "&numVersions=" + this.numVersions; + + return params; + } } diff --git a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/listdeviceconfigversions/ListDeviceConfigVersionsResponse.java b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/listdeviceconfigversions/ListDeviceConfigVersionsResponse.java new file mode 100644 index 00000000..88c8e3cf --- /dev/null +++ b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/listdeviceconfigversions/ListDeviceConfigVersionsResponse.java @@ -0,0 +1,84 @@ +package com.clearblade.cloud.iot.v1.listdeviceconfigversions; + +import java.util.ArrayList; +import java.util.Iterator; +import java.util.List; +import java.util.logging.Logger; + +import org.json.simple.JSONArray; +import org.json.simple.JSONObject; +import org.json.simple.parser.JSONParser; + +import com.clearblade.cloud.iot.v1.utils.DeviceConfig; + +public class ListDeviceConfigVersionsResponse { + + static Logger log = Logger.getLogger(ListDeviceConfigVersionsResponse.class.getName()); + private List deviceConfigList = new ArrayList<>(); + + protected ListDeviceConfigVersionsResponse(Builder builder) { + this.deviceConfigList = builder.deviceConfigList; + } + + + // Static class Builder + public static class Builder { + + /// instance fields + private List deviceConfigList = new ArrayList<>(); + + public static Builder newBuilder() { + return new Builder(); + } + + private Builder() { + } + + // Setter methods + public Builder setDeviceConfigVersionsListRequest(ListDeviceConfigVersionsRequest request) { + return this; + } + public Builder buildResponse(String configList) { + try { + JSONObject jsonObj = new JSONObject(); + JSONParser jsonParser = new JSONParser(); + jsonObj = (JSONObject) (jsonParser.parse(configList)); + + JSONArray configArray = (JSONArray) jsonObj.get("deviceConfigs"); + @SuppressWarnings("rawtypes") + Iterator configIterator = configArray.iterator(); + while (configIterator.hasNext()) { + JSONObject configJson = (JSONObject) configIterator.next(); + DeviceConfig configObj = DeviceConfig.newBuilder().setBinaryData((String) configJson.get("binaryData")) + .setCloudUpdateTime((String) configJson.get("cloudUpdateTime")) + .setDeviceAckTime((String) configJson.get("deviceAckTime")) + .setVersion((String) configJson.get("version")) + .build(); + deviceConfigList.add(configObj); + } + + } catch (Exception e) { + e.printStackTrace(); + } + return this; + } + + // build method to deal with outer class + // to return outer instance + public ListDeviceConfigVersionsResponse build() { + return new ListDeviceConfigVersionsResponse(this); + } + } + + + public List getDeviceConfigList() { + return deviceConfigList; + } + + + public void setDeviceConfigList(List deviceConfigList) { + this.deviceConfigList = deviceConfigList; + } + + +} \ No newline at end of file diff --git a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/utils/ConfigParameters.java b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/utils/ConfigParameters.java index 58491b06..26c28f7b 100644 --- a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/utils/ConfigParameters.java +++ b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/utils/ConfigParameters.java @@ -21,6 +21,7 @@ public class ConfigParameters { private String devicesStatesURLExtension; private String cloudiotdevicesURLExtension; private String cloudiotDeviceConfigURLExtension; + private String cloudiotConfigURLExtension; // Fields used to fetch values from Properties file Properties properties; @@ -67,6 +68,7 @@ public void setValues() { this.setCloudiotdevicesURLExtension(properties.getProperty("cloudiotdevicesURLExtension")); this.setDevicesStatesURLExtension(properties.getProperty("devicesStatesURLExtension")); this.setCloudiotdevicesURLExtension(properties.getProperty("cloudiotDeviceConfigURLExtension")); + this.setCloudiotConfigURLExtension(properties.getProperty("cloudiotConfigURLExtension")); this.setProject(properties.getProperty("project")); this.setRegion(properties.getProperty("region")); this.setRegistry(properties.getProperty("registry")); @@ -163,4 +165,12 @@ public void setBaseURL(String baseURL) { this.baseURL = baseURL; } + public String getCloudiotConfigURLExtension() { + return cloudiotConfigURLExtension; + } + + public void setCloudiotConfigURLExtension(String cloudiotConfigURLExtension) { + this.cloudiotConfigURLExtension = cloudiotConfigURLExtension; + } + } diff --git a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/utils/DeviceRegistry.java b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/utils/DeviceRegistry.java index f7e4ce35..2513442d 100644 --- a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/utils/DeviceRegistry.java +++ b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/utils/DeviceRegistry.java @@ -5,6 +5,7 @@ import java.util.List; import java.util.Set; +import org.json.simple.JSONArray; import org.json.simple.JSONObject; import org.json.simple.parser.JSONParser; //https://cloud.google.com/iot/docs/reference/cloudiot/rest/v1/projects.locations.registries#DeviceRegistry @@ -203,17 +204,16 @@ public void loadFromString(String inputStr) { this.credentials = credentialList; } if(key.equals("eventNotificationConfigs")) { - JSONArray eventJsonArray = value; - + JSONArray eventJsonArray = (JSONArray) value; List eventNotificationCfgs = new ArrayList<>(); - //list implementation pending - EventNotificationConfig eventNotificationCfg = new EventNotificationConfig(); - if (eventJsonObject.containsKey("subfolderMatches")) - eventNotificationCfg.setPubsubTopicName((String) eventJsonObject.get("subfolderMatches")); - if (eventJsonObject.containsKey("pubsubTopicName")) - eventNotificationCfg.setPubsubTopicName((String) eventJsonObject.get("pubsubTopicName")); - eventNotificationCfgs.add(eventNotificationCfg); - + Iterator eventIterator = eventJsonArray.iterator(); + while (eventIterator.hasNext()) { + JSONObject eventJson = (JSONObject) eventIterator.next(); + EventNotificationConfig eventObj = EventNotificationConfig.newBuilder().setSubfolderMatches((String)eventJson.get("subfolderMatches")) + .setPubsubTopicName((String)eventJson.get("pubsubTopicName")) + .build(); + eventNotificationCfgs.add(eventObj); + } this.eventNotificationConfigs = eventNotificationCfgs; } if(key.equals("stateNotificationConfig")) { diff --git a/clearblade-cloud-iot/src/config.properties b/clearblade-cloud-iot/src/config.properties index 749a425d..078e5901 100644 --- a/clearblade-cloud-iot/src/config.properties +++ b/clearblade-cloud-iot/src/config.properties @@ -8,7 +8,7 @@ devicesURLExtension=/cloudiot_devices cloudiotURLExtension=/cloudiot devicesStatesURLExtension=/cloudiot_devices_states cloudiotdevicesURLExtension=/cloudiotdevice_devices -cloudiotDeviceConfigURLExtension=/cloudiot_devices_configVersions +cloudiotConfigURLExtension=/cloudiot_devices_configVersions getSystemCredentialsExtension=/api/v/1/code/ From 3377ac97c88874dc24c8daa7c4fc68cf5884708b Mon Sep 17 00:00:00 2001 From: RashmiK14 Date: Wed, 23 Nov 2022 00:28:35 +0530 Subject: [PATCH 015/151] Committing Registry Apis -get, create, delete, update, list --- clearblade-cloud-iot/pom.xml | 96 +-- .../v1/createdevice/AsyncCreateDevice.java | 2 - .../AsyncCreateDeviceRegistry.java | 24 + .../SyncCreateDeviceRegistry.java | 24 + .../AsyncDeleteDeviceRegistry.java | 22 + .../SyncDeleteDeviceRegistry.java | 21 + .../SyncGetDeviceRegistry.java | 5 +- .../AsyncListDeviceRegistries.java | 26 + .../SyncListDeviceRegistries.java | 25 + .../AsyncModifyCloudToDeviceConfig.java | 3 - .../SyncModifyCloudToDeviceConfig.java | 8 +- .../v1/updatedevice/AsyncUpdateDevice.java | 2 - .../AsyncUpdateDeviceRegistry.java | 29 + .../SyncUpdateDeviceRegistry.java | 31 + .../clearblade/cloud/iot/v1/AsyncClient.java | 204 ++++-- .../cloud/iot/v1/ClearBladeDeviceManager.java | 62 +- .../iot/v1/ClearBladeRegistryManager.java | 235 ++----- .../iot/v1/DeviceManagerAsyncClient.java | 24 + .../cloud/iot/v1/DeviceManagerClient.java | 82 ++- .../cloud/iot/v1/ProcessRequest.java | 587 ------------------ .../clearblade/cloud/iot/v1/SyncClient.java | 371 ++++++----- .../cloud/iot/v1/auth/AdminAccess.java | 71 --- .../cloud/iot/v1/auth/SystemAccess.java | 27 - .../BindDeviceToGatewayResponse.java | 34 - .../v1/createdevice/CreateDeviceResponse.java | 5 - .../CreateDeviceRegistryRequest.java | 52 ++ .../v1/deletedevice/DeleteDeviceResponse.java | 32 - .../DeleteDeviceRegistryRequest.java | 41 ++ .../v1/deviceslist/DevicesListResponse.java | 2 - .../iot/v1/getdevice/GetDeviceResponse.java | 32 - .../GetDeviceRegistryResponse.java | 34 +- .../GetRegistryCredentialsRequest.java | 61 -- .../GetRegistryCredentialsResponse.java | 69 -- .../ListDeviceRegistriesRequest.java | 71 +++ .../ListDeviceRegistriesResponse.java | 88 +++ .../ModifyCloudToDeviceConfigResponse.java | 6 - .../SendCommandToDeviceResponse.java | 64 -- .../UnbindDeviceFromGatewayResponse.java | 34 - .../v1/updatedevice/UpdateDeviceResponse.java | 102 --- .../UpdateDeviceRegistryRequest.java | 98 +++ .../cloud/iot/v1/utils/AuthParams.java | 7 +- .../cloud/iot/v1/utils/ConfigParameters.java | 2 +- .../clearblade/cloud/iot/v1/utils/Device.java | 61 +- .../cloud/iot/v1/utils/DeviceConfig.java | 2 - .../cloud/iot/v1/utils/DeviceRegistry.java | 110 +++- .../iot/v1/utils/EventNotificationConfig.java | 12 + .../cloud/iot/v1/utils/HttpConfig.java | 13 +- .../cloud/iot/v1/utils/LocationName.java | 90 +++ .../cloud/iot/v1/utils/MqttConfig.java | 13 +- .../iot/v1/utils/PublicKeyCertificate.java | 2 +- .../iot/v1/utils/RegistryCredential.java | 76 ++- .../iot/v1/utils/StateNotificationConfig.java | 13 +- .../iot/v1/utils/X509CertificateDetails.java | 22 +- 53 files changed, 1470 insertions(+), 1759 deletions(-) create mode 100644 clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/createdeviceregistry/AsyncCreateDeviceRegistry.java create mode 100644 clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/createdeviceregistry/SyncCreateDeviceRegistry.java create mode 100644 clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/deletedeviceregistry/AsyncDeleteDeviceRegistry.java create mode 100644 clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/deletedeviceregistry/SyncDeleteDeviceRegistry.java create mode 100644 clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/listdeviceregistries/AsyncListDeviceRegistries.java create mode 100644 clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/listdeviceregistries/SyncListDeviceRegistries.java create mode 100644 clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/updatedeviceregistry/AsyncUpdateDeviceRegistry.java create mode 100644 clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/updatedeviceregistry/SyncUpdateDeviceRegistry.java delete mode 100644 clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/ProcessRequest.java delete mode 100644 clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/auth/AdminAccess.java delete mode 100644 clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/auth/SystemAccess.java create mode 100644 clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/createdeviceregistry/CreateDeviceRegistryRequest.java create mode 100644 clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/deletedeviceregistry/DeleteDeviceRegistryRequest.java delete mode 100644 clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/getregistrycredentials/GetRegistryCredentialsRequest.java delete mode 100644 clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/getregistrycredentials/GetRegistryCredentialsResponse.java create mode 100644 clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/listdeviceregistries/ListDeviceRegistriesRequest.java create mode 100644 clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/listdeviceregistries/ListDeviceRegistriesResponse.java delete mode 100644 clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/updatedevice/UpdateDeviceResponse.java create mode 100644 clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/updatedeviceregistry/UpdateDeviceRegistryRequest.java create mode 100644 clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/utils/LocationName.java diff --git a/clearblade-cloud-iot/pom.xml b/clearblade-cloud-iot/pom.xml index 33467c54..42f44a87 100644 --- a/clearblade-cloud-iot/pom.xml +++ b/clearblade-cloud-iot/pom.xml @@ -1,45 +1,63 @@ - 4.0.0 - clearblade-cloud-iot - clearblade-cloud-iot - 0.0.1-SNAPSHOT - - src - - - maven-compiler-plugin - 3.8.1 - - 17 - - - - - - - - com.googlecode.json-simple - json-simple - 1.1.1 - - - - org.junit.jupiter - junit-jupiter-api - 5.9.1 - test - - - - com.google.code.findbugs - jsr305 - 3.0.2 - - + + com.googlecode.json-simple + json-simple + 1.1.1 + + + + org.junit.jupiter + junit-jupiter-api + 5.9.1 + test + + + + com.google.code.findbugs + jsr305 + 3.0.2 + + - - + + \ No newline at end of file diff --git a/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/createdevice/AsyncCreateDevice.java b/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/createdevice/AsyncCreateDevice.java index fafd749d..64fa59c0 100644 --- a/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/createdevice/AsyncCreateDevice.java +++ b/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/createdevice/AsyncCreateDevice.java @@ -2,11 +2,9 @@ import java.util.ArrayList; import java.util.HashMap; -import java.util.logging.Level; import java.util.logging.Logger; import com.clearblade.cloud.iot.v1.DeviceManagerAsyncClient; -import com.clearblade.cloud.iot.v1.DeviceManagerClient; import com.clearblade.cloud.iot.v1.utils.Device; import com.clearblade.cloud.iot.v1.utils.DeviceConfig; import com.clearblade.cloud.iot.v1.utils.GatewayConfig; diff --git a/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/createdeviceregistry/AsyncCreateDeviceRegistry.java b/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/createdeviceregistry/AsyncCreateDeviceRegistry.java new file mode 100644 index 00000000..301ec4a9 --- /dev/null +++ b/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/createdeviceregistry/AsyncCreateDeviceRegistry.java @@ -0,0 +1,24 @@ +package com.clearblade.cloud.iot.v1.createdeviceregistry; + +import com.clearblade.cloud.iot.v1.DeviceManagerAsyncClient; +import com.clearblade.cloud.iot.v1.utils.DeviceRegistry; +import com.clearblade.cloud.iot.v1.utils.LocationName; + +public class AsyncCreateDeviceRegistry { + public static void main(String[] args) { + asyncCreateDeviceRegistry(); + } + + public static void asyncCreateDeviceRegistry() { + DeviceManagerAsyncClient deviceManagerClient = new DeviceManagerAsyncClient(); + CreateDeviceRegistryRequest request = CreateDeviceRegistryRequest.Builder.newBuilder() + .setParent(LocationName.of("ingressdevelopmentenv", "us-central1").toString()) + .setDeviceRegistry( + DeviceRegistry.newBuilder().setId("testCreate_reg3").build()) + .build(); + DeviceRegistry response = deviceManagerClient.createDeviceRegistry(request); + System.out.println(response.toBuilder().getId()); + + } + +} diff --git a/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/createdeviceregistry/SyncCreateDeviceRegistry.java b/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/createdeviceregistry/SyncCreateDeviceRegistry.java new file mode 100644 index 00000000..c862972c --- /dev/null +++ b/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/createdeviceregistry/SyncCreateDeviceRegistry.java @@ -0,0 +1,24 @@ +package com.clearblade.cloud.iot.v1.createdeviceregistry; + +import com.clearblade.cloud.iot.v1.DeviceManagerClient; +import com.clearblade.cloud.iot.v1.utils.DeviceRegistry; +import com.clearblade.cloud.iot.v1.utils.LocationName; + +public class SyncCreateDeviceRegistry { + + public static void main(String[] args) { + syncCreateDeviceRegistry(); + } + + public static void syncCreateDeviceRegistry() { + DeviceManagerClient deviceManagerClient = new DeviceManagerClient(); + CreateDeviceRegistryRequest request = CreateDeviceRegistryRequest.Builder.newBuilder() + .setParent(LocationName.of("ingressdevelopmentenv", "us-central1").toString()) + .setDeviceRegistry( + DeviceRegistry.newBuilder().setId("testCreate_reg5").build()) + .build(); + DeviceRegistry response = deviceManagerClient.createDeviceRegistry(request); + System.out.println(response.toBuilder().getId()); + + } +} diff --git a/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/deletedeviceregistry/AsyncDeleteDeviceRegistry.java b/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/deletedeviceregistry/AsyncDeleteDeviceRegistry.java new file mode 100644 index 00000000..aa124323 --- /dev/null +++ b/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/deletedeviceregistry/AsyncDeleteDeviceRegistry.java @@ -0,0 +1,22 @@ +package com.clearblade.cloud.iot.v1.deletedeviceregistry; + +import com.clearblade.cloud.iot.v1.DeviceManagerAsyncClient; +import com.clearblade.cloud.iot.v1.utils.RegistryName; + +public class AsyncDeleteDeviceRegistry { + + public static void main(String[] args) throws Exception { + asyncDeleteDeviceRegistry(); + } + + public static void asyncDeleteDeviceRegistry() throws Exception { + + DeviceManagerAsyncClient deviceManagerClient = new DeviceManagerAsyncClient(); + DeleteDeviceRegistryRequest request = DeleteDeviceRegistryRequest.Builder.newBuilder() + .setName(RegistryName.of("ingressdevelopmentenv", "us-central1", "testCreate_reg2").getRegistryFullName()) + .build(); + deviceManagerClient.deleteDeviceRegistry(request); + + } + +} \ No newline at end of file diff --git a/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/deletedeviceregistry/SyncDeleteDeviceRegistry.java b/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/deletedeviceregistry/SyncDeleteDeviceRegistry.java new file mode 100644 index 00000000..795fa8e3 --- /dev/null +++ b/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/deletedeviceregistry/SyncDeleteDeviceRegistry.java @@ -0,0 +1,21 @@ +package com.clearblade.cloud.iot.v1.deletedeviceregistry; + +import com.clearblade.cloud.iot.v1.DeviceManagerClient; +import com.clearblade.cloud.iot.v1.utils.RegistryName; + +public class SyncDeleteDeviceRegistry { + + public static void main(String[] args) throws Exception { + syncDeleteDeviceRegistry(); + } + + public static void syncDeleteDeviceRegistry() throws Exception { + DeviceManagerClient deviceManagerClient = new DeviceManagerClient(); + DeleteDeviceRegistryRequest request = DeleteDeviceRegistryRequest.Builder.newBuilder() + .setName(RegistryName.of("ingressdevelopmentenv", "us-central1", "testCreate_reg3").getRegistryFullName()) + .build(); + deviceManagerClient.deleteDeviceRegistry(request); + } + +} + diff --git a/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/getdeviceregistry/SyncGetDeviceRegistry.java b/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/getdeviceregistry/SyncGetDeviceRegistry.java index 8ba5b8a3..3506071e 100644 --- a/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/getdeviceregistry/SyncGetDeviceRegistry.java +++ b/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/getdeviceregistry/SyncGetDeviceRegistry.java @@ -3,7 +3,6 @@ import java.util.logging.Logger; import com.clearblade.cloud.iot.v1.DeviceManagerAsyncClient; -import com.clearblade.cloud.iot.v1.DeviceManagerClient; import com.clearblade.cloud.iot.v1.utils.DeviceRegistry; import com.clearblade.cloud.iot.v1.utils.RegistryName; @@ -17,10 +16,10 @@ public static void main(String[] args) { public static void syncGetDeviceRegistry() { DeviceManagerAsyncClient deviceManagerAsyncClient = new DeviceManagerAsyncClient(); GetDeviceRegistryRequest request = GetDeviceRegistryRequest.Builder.newBuilder() - .setName(RegistryName.of("ingressdevelopmentenv", "us-central1", "Rashmi_Registry_Test").getRegistryFullName()) + .setName(RegistryName.of("ingressdevelopmentenv", "us-central1", "MandarTest1").getRegistryFullName()) .build(); DeviceRegistry response = deviceManagerAsyncClient.getDeviceRegistry(request); - System.out.println(response.toString()); + System.out.println(response.createDeviceJSONObject("")); } } diff --git a/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/listdeviceregistries/AsyncListDeviceRegistries.java b/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/listdeviceregistries/AsyncListDeviceRegistries.java new file mode 100644 index 00000000..d7048148 --- /dev/null +++ b/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/listdeviceregistries/AsyncListDeviceRegistries.java @@ -0,0 +1,26 @@ +package com.clearblade.cloud.iot.v1.listdeviceregistries; + +import com.clearblade.cloud.iot.v1.DeviceManagerAsyncClient; +import com.clearblade.cloud.iot.v1.utils.DeviceRegistry; +import com.clearblade.cloud.iot.v1.utils.LocationName; + +public class AsyncListDeviceRegistries { + public static void main(String[] args) throws Exception { + asyncListDeviceRegistries(); + } + + public static void asyncListDeviceRegistries() throws Exception { + DeviceManagerAsyncClient deviceManagerClient = new DeviceManagerAsyncClient(); + ListDeviceRegistriesRequest request = ListDeviceRegistriesRequest.Builder.newBuilder() + .setParent(LocationName.of("ingressdevelopmentenv", "us-central1").getLocationFullName()) + .build(); + ListDeviceRegistriesResponse response = deviceManagerClient.listDeviceRegistries(request); + + for (DeviceRegistry element : response.getDeviceRegistriesList()) { + System.out.println(element.toBuilder().getName()); + + } + System.out.println(response.getNextPageToken()); + } + +} diff --git a/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/listdeviceregistries/SyncListDeviceRegistries.java b/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/listdeviceregistries/SyncListDeviceRegistries.java new file mode 100644 index 00000000..dccb2f9b --- /dev/null +++ b/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/listdeviceregistries/SyncListDeviceRegistries.java @@ -0,0 +1,25 @@ +package com.clearblade.cloud.iot.v1.listdeviceregistries; + +import com.clearblade.cloud.iot.v1.DeviceManagerClient; +import com.clearblade.cloud.iot.v1.utils.DeviceRegistry; +import com.clearblade.cloud.iot.v1.utils.LocationName; + +public class SyncListDeviceRegistries { + public static void main(String[] args) throws Exception { + syncListDeviceRegistries(); + } + + public static void syncListDeviceRegistries() throws Exception { + DeviceManagerClient deviceManagerClient = new DeviceManagerClient(); + ListDeviceRegistriesRequest request = ListDeviceRegistriesRequest.Builder.newBuilder() + .setParent(LocationName.of("ingressdevelopmentenv", "us-central1").getLocationFullName()) + .build(); + ListDeviceRegistriesResponse response = deviceManagerClient.listDeviceRegistries(request); + + for (DeviceRegistry element : response.getDeviceRegistriesList()) { + System.out.println(element.toBuilder().getName()); + + } + System.out.println(response.getNextPageToken()); + } +} diff --git a/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/modifycloudtodeviceconfig/AsyncModifyCloudToDeviceConfig.java b/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/modifycloudtodeviceconfig/AsyncModifyCloudToDeviceConfig.java index 8647322e..09f36671 100644 --- a/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/modifycloudtodeviceconfig/AsyncModifyCloudToDeviceConfig.java +++ b/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/modifycloudtodeviceconfig/AsyncModifyCloudToDeviceConfig.java @@ -1,12 +1,9 @@ package com.clearblade.cloud.iot.v1.modifycloudtodeviceconfig; -import java.util.logging.Level; import java.util.logging.Logger; import com.clearblade.cloud.iot.v1.DeviceManagerAsyncClient; -import com.clearblade.cloud.iot.v1.DeviceManagerClient; import com.clearblade.cloud.iot.v1.utils.ByteString; -import com.clearblade.cloud.iot.v1.utils.Device; import com.clearblade.cloud.iot.v1.utils.DeviceConfig; import com.clearblade.cloud.iot.v1.utils.DeviceName; diff --git a/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/modifycloudtodeviceconfig/SyncModifyCloudToDeviceConfig.java b/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/modifycloudtodeviceconfig/SyncModifyCloudToDeviceConfig.java index fb28aa94..36bea517 100644 --- a/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/modifycloudtodeviceconfig/SyncModifyCloudToDeviceConfig.java +++ b/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/modifycloudtodeviceconfig/SyncModifyCloudToDeviceConfig.java @@ -1,13 +1,9 @@ package com.clearblade.cloud.iot.v1.modifycloudtodeviceconfig; -import java.util.logging.Level; import java.util.logging.Logger; -import javax.print.DocFlavor.BYTE_ARRAY; - import com.clearblade.cloud.iot.v1.DeviceManagerClient; import com.clearblade.cloud.iot.v1.utils.ByteString; -import com.clearblade.cloud.iot.v1.utils.Device; import com.clearblade.cloud.iot.v1.utils.DeviceConfig; import com.clearblade.cloud.iot.v1.utils.DeviceName; @@ -23,9 +19,9 @@ public static void syncModifyCloudToDeviceConfig() { DeviceManagerClient deviceManagerClient = new DeviceManagerClient(); ModifyCloudToDeviceConfigRequest request = ModifyCloudToDeviceConfigRequest.Builder.newBuilder() .setName(DeviceName - .of("ingressdevelopmentenv", "us-central1", "MandarTest1", "mandar_device") + .of("ingressdevelopmentenv", "us-central1", "Rashmi_Registry_Test", "Rashmi_Device_Test") .toString()) - .setBinaryData(new ByteString("bmV3TWVzc2FnZUZvckNvbmZpZw==")).setVersionToUpdate("2").build(); + .setBinaryData(new ByteString("bmV3TWVzc2FnZUZvckNvbmZpZw==")).setVersionToUpdate("6").build(); DeviceConfig response = deviceManagerClient.modifyCloudToDeviceConfig(request); System.out.println(response.toString()); } diff --git a/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/updatedevice/AsyncUpdateDevice.java b/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/updatedevice/AsyncUpdateDevice.java index 674f4fc1..8e308927 100644 --- a/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/updatedevice/AsyncUpdateDevice.java +++ b/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/updatedevice/AsyncUpdateDevice.java @@ -1,10 +1,8 @@ package com.clearblade.cloud.iot.v1.updatedevice; -import java.util.logging.Level; import java.util.logging.Logger; import com.clearblade.cloud.iot.v1.DeviceManagerAsyncClient; -import com.clearblade.cloud.iot.v1.DeviceManagerClient; import com.clearblade.cloud.iot.v1.utils.Device; import com.clearblade.cloud.iot.v1.utils.LogLevel; diff --git a/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/updatedeviceregistry/AsyncUpdateDeviceRegistry.java b/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/updatedeviceregistry/AsyncUpdateDeviceRegistry.java new file mode 100644 index 00000000..796b2885 --- /dev/null +++ b/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/updatedeviceregistry/AsyncUpdateDeviceRegistry.java @@ -0,0 +1,29 @@ +package com.clearblade.cloud.iot.v1.updatedeviceregistry; + +import com.clearblade.cloud.iot.v1.DeviceManagerAsyncClient; +import com.clearblade.cloud.iot.v1.utils.DeviceRegistry; +import com.clearblade.cloud.iot.v1.utils.LogLevel; +import com.clearblade.cloud.iot.v1.utils.RegistryName; + +public class AsyncUpdateDeviceRegistry { + public static void main(String[] args) throws Exception { + asyncUpdateDeviceRegistry(); + } + + public static void asyncUpdateDeviceRegistry() throws Exception { + DeviceManagerAsyncClient deviceManagerClient = new DeviceManagerAsyncClient(); + RegistryName name = RegistryName.of("ingressdevelopmentenv", "us-central1", "Registry_Test1"); + UpdateDeviceRegistryRequest request = UpdateDeviceRegistryRequest.Builder.newBuilder() + .setDeviceRegistry(DeviceRegistry.newBuilder().setId("Rashmi_Registry_Test") + .setName(name.getRegistryFullName()) + .setLogLevel(LogLevel.DEBUG) + .build()) + .setName(name.getRegistryFullName()).setUpdateMask("logLevel").build(); + + DeviceRegistry response = deviceManagerClient.updateDeviceRegistry(request); + if(response != null) { + System.out.println(response.toBuilder().getName() + "::" + response.toBuilder().getLogLevel()); + } + } + +} diff --git a/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/updatedeviceregistry/SyncUpdateDeviceRegistry.java b/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/updatedeviceregistry/SyncUpdateDeviceRegistry.java new file mode 100644 index 00000000..da711fa5 --- /dev/null +++ b/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/updatedeviceregistry/SyncUpdateDeviceRegistry.java @@ -0,0 +1,31 @@ +package com.clearblade.cloud.iot.v1.updatedeviceregistry; + +import com.clearblade.cloud.iot.v1.DeviceManagerClient; +import com.clearblade.cloud.iot.v1.utils.DeviceRegistry; +import com.clearblade.cloud.iot.v1.utils.LogLevel; +import com.clearblade.cloud.iot.v1.utils.RegistryName; + +public class SyncUpdateDeviceRegistry { + + public static void main(String[] args) throws Exception { + syncUpdateDeviceRegistry(); + } + + public static void syncUpdateDeviceRegistry() throws Exception { + DeviceManagerClient deviceManagerClient = new DeviceManagerClient(); + RegistryName name = RegistryName.of("ingressdevelopmentenv", "us-central1", "Rashmi_Registry_Test"); + + + UpdateDeviceRegistryRequest request = UpdateDeviceRegistryRequest.Builder.newBuilder() + .setDeviceRegistry(DeviceRegistry.newBuilder().setId("Rashmi_Registry_Test") + .setName(name.getRegistryFullName()) + .setLogLevel(LogLevel.DEBUG) + .build()) + .setName(name.getRegistryFullName()).setUpdateMask("logLevel").build(); + + DeviceRegistry response = deviceManagerClient.updateDeviceRegistry(request); + if(response != null) { + System.out.println(response.toBuilder().getName() + "::" + response.toBuilder().getLogLevel()); + } + } +} diff --git a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/AsyncClient.java b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/AsyncClient.java index a8edfdfc..58b86da4 100644 --- a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/AsyncClient.java +++ b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/AsyncClient.java @@ -18,13 +18,14 @@ import com.clearblade.cloud.iot.v1.utils.SetHttpConnection; public class AsyncClient { - + private ConfigParameters configParameters = new ConfigParameters(); private String[] responseArray = new String[3]; private String apiName; private String params; private String body; - + private boolean isAdmin = false; + /** * Method used to generate URL for apicall * @param apiName - path to api @@ -41,6 +42,22 @@ private String generateURL(String apiName, String params) { .concat("?" + params); } + /** + * Method used to generate URL for apicall + * + * @param apiName - path to api + * @param params - parameters to be attached to request + * @return URL formed and to be used + */ + private String generateAdminURL(String apiName, String params) { + + return AuthParams.getBaseURL() + .concat(configParameters.getBaseURL()) + .concat(AuthParams.getAdminSystemKey()) + .concat(apiName) + .concat("?" + params); + } + /** * Method used to Calls HTTP Get request * @param apiName @@ -48,14 +65,23 @@ private String generateURL(String apiName, String params) { * @return String[] containing responseCode, responseMessage and response object */ private Object get() { - AuthParams.setRegistryCredentials(); + String finalURL = ""; + if (isAdmin) { + AuthParams.setAdminCredentials(); + finalURL = generateAdminURL(apiName, params); + } else { + AuthParams.setRegistryCredentials(); + finalURL = generateURL(apiName, params); + } try { - String finalURL = generateURL(apiName, params); System.out.println(finalURL); URL obj = new URL(finalURL); SetHttpConnection setCon = new SetHttpConnection(); HttpsURLConnection con = setCon.getConnection(obj); - con.setRequestProperty(Constants.HTTP_REQUEST_PROPERTY_TOKEN_KEY, AuthParams.getUserToken()); + if(isAdmin) + con.setRequestProperty(Constants.HTTP_REQUEST_PROPERTY_TOKEN_KEY, AuthParams.getAdminToken()); + else + con.setRequestProperty(Constants.HTTP_REQUEST_PROPERTY_TOKEN_KEY, AuthParams.getUserToken()); con.setRequestProperty(Constants.HTTP_REQUEST_PROPERTY_CONTENT_TYPE_KEY, Constants.HTTP_REQUEST_PROPERTY_CONTENT_TYPE_ACCEPT_VALUE); con.addRequestProperty(Constants.HTTP_REQUEST_PROPERTY_ACCEPT_KEY, @@ -95,15 +121,26 @@ private Object get() { * @return String[] containing responseCode, responseMessage and response object */ public Object post() { - AuthParams.setRegistryCredentials(); + String finalURL = ""; + if (isAdmin) { + AuthParams.setAdminCredentials(); + finalURL = generateAdminURL(apiName, params); + } else { + AuthParams.setRegistryCredentials(); + finalURL = generateURL(apiName, params); + } try { - String finalURL = generateURL(apiName, params); System.out.println(finalURL); URL obj = new URL(finalURL); SetHttpConnection setCon = new SetHttpConnection(); HttpsURLConnection con = setCon.getConnection(obj); - con.setRequestProperty(Constants.HTTP_REQUEST_PROPERTY_TOKEN_KEY, AuthParams.getUserToken()); + if (isAdmin) + con.setRequestProperty(Constants.HTTP_REQUEST_PROPERTY_TOKEN_KEY, + AuthParams.getAdminToken()); + else + con.setRequestProperty(Constants.HTTP_REQUEST_PROPERTY_TOKEN_KEY, + AuthParams.getUserToken()); con.setRequestProperty(Constants.HTTP_REQUEST_PROPERTY_CONTENT_TYPE_KEY, Constants.HTTP_REQUEST_PROPERTY_CONTENT_TYPE_ACCEPT_VALUE); con.addRequestProperty(Constants.HTTP_REQUEST_PROPERTY_ACCEPT_KEY, @@ -147,14 +184,25 @@ public Object post() { * @return String[] containing responseCode, responseMessage and response object */ public Object delete() { - AuthParams.setRegistryCredentials(); + String finalURL = ""; + if (isAdmin) { + AuthParams.setAdminCredentials(); + finalURL = generateAdminURL(apiName, params); + } else { + AuthParams.setRegistryCredentials(); + finalURL = generateURL(apiName, params); + } try { - String finalURL = generateURL(apiName, params); System.out.println(finalURL); URL obj = new URL(finalURL); SetHttpConnection setCon = new SetHttpConnection(); HttpsURLConnection con = setCon.getConnection(obj); - con.setRequestProperty(Constants.HTTP_REQUEST_PROPERTY_TOKEN_KEY, AuthParams.getUserToken()); + if (isAdmin) + con.setRequestProperty(Constants.HTTP_REQUEST_PROPERTY_TOKEN_KEY, + AuthParams.getAdminToken()); + else + con.setRequestProperty(Constants.HTTP_REQUEST_PROPERTY_TOKEN_KEY, + AuthParams.getUserToken()); con.setRequestProperty(Constants.HTTP_REQUEST_PROPERTY_CONTENT_TYPE_KEY, Constants.HTTP_REQUEST_PROPERTY_CONTENT_TYPE_ACCEPT_VALUE); con.addRequestProperty(Constants.HTTP_REQUEST_PROPERTY_ACCEPT_KEY, @@ -194,14 +242,14 @@ public Object delete() { */ public Object update() { AuthParams.setRegistryCredentials(); - + String finalURL = generateURL(apiName, params); try { - String finalURL = generateURL(apiName, params); System.out.println(finalURL); URL obj = new URL(finalURL); SetHttpConnection setCon = new SetHttpConnection(); HttpsURLConnection con = setCon.getConnection(obj); - con.setRequestProperty(Constants.HTTP_REQUEST_PROPERTY_TOKEN_KEY, AuthParams.getUserToken()); + con.setRequestProperty(Constants.HTTP_REQUEST_PROPERTY_TOKEN_KEY, + AuthParams.getUserToken()); con.setRequestProperty(Constants.HTTP_REQUEST_PROPERTY_CONTENT_TYPE_KEY, Constants.HTTP_REQUEST_PROPERTY_CONTENT_TYPE_ACCEPT_VALUE); con.addRequestProperty(Constants.HTTP_REQUEST_PROPERTY_ACCEPT_KEY, @@ -432,72 +480,55 @@ public String[] asyncListDeviceConfigVersions(String apiName, String params) return responseArray; } - //Registry Apis - /** - * Method used to generate URL for apicall - * @param apiName - path to api - * @param params - parameters to be attached to request - * @return URL formed and to be used - */ - private String generateAdminURL(String apiName, String params) { + // Registry Apis - return AuthParams.getBaseURL() - .concat(configParameters.getBaseURL()) - .concat(AuthParams.getUserSystemKey()) - .concat(apiName) - .concat("?"+params); + private Future getRegistryAsync() { + return CompletableFuture.supplyAsync(this::get); } - /** - * Method used to Calls HTTP Get request - * @param apiName - * @param params - * @return String[] containing responseCode, responseMessage and response object - */ - public Object getRegistry() { - AuthParams.setRegistryCredentials(); + + public String[] asyncGetRegistry(String apiName,String params) throws InterruptedException { + this.apiName = apiName; + this.params = params; + Future future = getRegistryAsync(); try { - String finalURL = generateAdminURL(apiName, params); - System.out.println(finalURL); - URL obj = new URL(finalURL); - SetHttpConnection setCon = new SetHttpConnection(); - HttpsURLConnection con = setCon.getConnection(obj); - con.setRequestProperty(Constants.HTTP_REQUEST_PROPERTY_TOKEN_KEY, AuthParams.getUserToken()); - con.setRequestProperty(Constants.HTTP_REQUEST_PROPERTY_CONTENT_TYPE_KEY, Constants.HTTP_REQUEST_PROPERTY_CONTENT_TYPE_ACCEPT_VALUE); - con.addRequestProperty(Constants.HTTP_REQUEST_PROPERTY_ACCEPT_KEY, Constants.HTTP_REQUEST_PROPERTY_CONTENT_TYPE_ACCEPT_VALUE); - con.setRequestMethod(Constants.HTTP_REQUEST_METHOD_TYPE_GET); - StringBuilder response = new StringBuilder(); - responseArray[0] = String.valueOf(con.getResponseCode()); - responseArray[1] = con.getResponseMessage(); - BufferedReader in = null; - if (con.getErrorStream() != null) { - in = new BufferedReader(new InputStreamReader(con.getErrorStream())); - } else if (con.getInputStream() != null) { - in = new BufferedReader(new InputStreamReader(con.getInputStream())); - } - String inputLine; - String responseMessage = ""; - if (in != null) { - while ((inputLine = in.readLine()) != null) { - response.append(inputLine); - } - responseMessage = response.toString(); - responseArray[2] = responseMessage; + future.get(15000, TimeUnit.MILLISECONDS); + } catch (InterruptedException | ExecutionException | TimeoutException e) { + e.printStackTrace(); + Thread.currentThread().interrupt(); } - }catch(Exception e) { + return responseArray; + } + + private Future createRegistryAsync() { + return CompletableFuture.supplyAsync(this::post); + } + + public String[] asyncCreateDeviceRegistry(String apiName, String params, String body, boolean isAdmin) + throws InterruptedException { + this.apiName = apiName; + this.params = params; + this.body = body; + this.isAdmin = isAdmin; + Future future = createRegistryAsync(); + try { + future.get(15000, TimeUnit.MILLISECONDS); + } catch (InterruptedException | ExecutionException | TimeoutException e) { e.printStackTrace(); + Thread.currentThread().interrupt(); } - return responseArray; } - - private Future getRegistryAsync() { - return CompletableFuture.supplyAsync(this::getRegistry); + + private Future updateRegistryAsync() { + return CompletableFuture.supplyAsync(this::update); } - public String[] asyncGetRegistry(String apiName,String params) throws InterruptedException { + public String[] asyncUpdateDeviceRegistry(String apiName, String params, String body) + throws InterruptedException { this.apiName = apiName; this.params = params; - Future future = getRegistryAsync(); + this.body = body; + Future future = updateRegistryAsync(); try { future.get(15000, TimeUnit.MILLISECONDS); } catch (InterruptedException | ExecutionException | TimeoutException e) { @@ -507,5 +538,42 @@ public String[] asyncGetRegistry(String apiName,String params) throws Interrupte return responseArray; } + private Future deleteRegistryAsync() { + return CompletableFuture.supplyAsync(this::delete); + } + + public String[] asyncDeleteDeviceRegistry(String apiName, String params, String body, boolean isAdmin) + throws InterruptedException { + this.apiName = apiName; + this.params = params; + this.body = body; + this.isAdmin = isAdmin; + Future future = deleteRegistryAsync(); + try { + future.get(15000, TimeUnit.MILLISECONDS); + } catch (InterruptedException | ExecutionException | TimeoutException e) { + e.printStackTrace(); + Thread.currentThread().interrupt(); + } + return responseArray; + } + private Future listDeviceRegistriesAsync() { + return CompletableFuture.supplyAsync(this::get); + } + public String[] asyncListDeviceRegistries(String apiName, String params,boolean isAdmin) + throws InterruptedException { + this.apiName = apiName; + this.params = params; + this.isAdmin = isAdmin; + Future future = listDeviceRegistriesAsync(); + try { + future.get(15000, TimeUnit.MILLISECONDS); + } catch (InterruptedException | ExecutionException | TimeoutException e) { + e.printStackTrace(); + Thread.currentThread().interrupt(); + } + return responseArray; + } + } diff --git a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/ClearBladeDeviceManager.java b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/ClearBladeDeviceManager.java index 3de81d30..576e3155 100644 --- a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/ClearBladeDeviceManager.java +++ b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/ClearBladeDeviceManager.java @@ -11,6 +11,8 @@ import com.clearblade.cloud.iot.v1.getdevice.GetDeviceRequest; import com.clearblade.cloud.iot.v1.listdeviceconfigversions.ListDeviceConfigVersionsRequest; import com.clearblade.cloud.iot.v1.listdeviceconfigversions.ListDeviceConfigVersionsResponse; +import com.clearblade.cloud.iot.v1.listdeviceregistries.ListDeviceRegistriesRequest; +import com.clearblade.cloud.iot.v1.listdeviceregistries.ListDeviceRegistriesResponse; import com.clearblade.cloud.iot.v1.modifycloudtodeviceconfig.ModifyCloudToDeviceConfigRequest; import com.clearblade.cloud.iot.v1.sendcommandtodevice.SendCommandToDeviceRequest; import com.clearblade.cloud.iot.v1.sendcommandtodevice.SendCommandToDeviceResponse; @@ -27,7 +29,7 @@ public class ClearBladeDeviceManager { public Device getDevice(GetDeviceRequest request) { SyncClient syncClient = new SyncClient(); - String[] responseArray = syncClient.get(configParameters.getDevicesURLExtension(), request.toString()); + String[] responseArray = syncClient.get(configParameters.getDevicesURLExtension(), request.toString(),false); int responseCode = Integer.parseInt(responseArray[0]); if(responseCode == 200) { Device device = Device.newBuilder().build(); @@ -59,7 +61,7 @@ public Device createDevice(CreateDeviceRequest request) { String[] params = request.getParams(); String reqParams = params[0]; String body = params[1]; - String[] responseArray = syncClient.post(configParameters.getDevicesURLExtension(), reqParams, body); + String[] responseArray = syncClient.post(configParameters.getDevicesURLExtension(), reqParams, body, false); int responseCode = Integer.parseInt(responseArray[0]); if (responseCode == 200) { Device deviceObj = Device.newBuilder().build(); @@ -91,7 +93,7 @@ public Device asyncCreateDevice(CreateDeviceRequest request) { public void deleteDevice(DeleteDeviceRequest request) { SyncClient syncClient = new SyncClient(); - String[] responseArray = syncClient.delete(configParameters.getDevicesURLExtension(), request.toString()); + String[] responseArray = syncClient.delete(configParameters.getDevicesURLExtension(), request.toString(),false); System.out.println( "Response for delete is " + responseArray[0] + "::" + responseArray[1] + "::" + responseArray[2]); } @@ -113,7 +115,7 @@ public Device updateDevice(UpdateDeviceRequest request) { String[] params = request.getBodyAndParams(); String reqParams = params[0]; String body = params[1]; - String[] responseArray = syncClient.patch(configParameters.getDevicesURLExtension(), reqParams, body); + String[] responseArray = syncClient.update(configParameters.getDevicesURLExtension(), reqParams, body); int responseCode = Integer.parseInt(responseArray[0]); if (responseCode == 200) { Device deviceObj = Device.newBuilder().build(); @@ -145,7 +147,7 @@ public BindDeviceToGatewayResponse bindDeviceToGateway(BindDeviceToGatewayReques SyncClient syncClient = new SyncClient(); String[] paramBody = request.getBodyAndParams(); String[] responseArray = syncClient.post(configParameters.getCloudiotURLExtension(), paramBody[0], - paramBody[1]); + paramBody[1], false); BindDeviceToGatewayResponse response = BindDeviceToGatewayResponse.Builder.newBuilder().build(); response.setHttpStatusCode(Integer.parseInt(responseArray[0])); response.setHttpStatusResponse(responseArray[1]); @@ -172,7 +174,7 @@ public UnbindDeviceFromGatewayResponse unbindDeviceFromGateway(UnbindDeviceFromG SyncClient syncClinet = new SyncClient(); String[] paramBody = request.getBodyAndParams(); String[] responseArray = syncClinet.post(configParameters.getCloudiotURLExtension(), paramBody[0], - paramBody[1]); + paramBody[1], false); UnbindDeviceFromGatewayResponse response = UnbindDeviceFromGatewayResponse.Builder.newBuilder().build(); response.setHttpStatusCode(Integer.parseInt(responseArray[0])); response.setHttpStatusResponse(responseArray[1]); @@ -199,7 +201,7 @@ public SendCommandToDeviceResponse sendCommandToDevice(SendCommandToDeviceReques SyncClient syncClient = new SyncClient(); String[] paramBody = request.getBodyAndParams(); String[] responseArray = syncClient.post(configParameters.getDevicesURLExtension(), paramBody[0], - paramBody[1]); + paramBody[1], false); System.out.println(responseArray[2]); SendCommandToDeviceResponse response = SendCommandToDeviceResponse.Builder.newBuilder().build(); response.setHttpStatusCode(Integer.parseInt(responseArray[0])); @@ -227,7 +229,7 @@ public SendCommandToDeviceResponse asyncSendCommandToDevice(SendCommandToDeviceR public DevicesListResponse listDevices(DevicesListRequest request) { SyncClient syncClient = new SyncClient(); - String[] responseArray = syncClient.get(configParameters.getDevicesURLExtension(), request.getParamsForList()); + String[] responseArray = syncClient.get(configParameters.getDevicesURLExtension(), request.getParamsForList(),false); int responseCode = Integer.parseInt(responseArray[0]); if (responseCode == 200) { DevicesListResponse devicesListResponse = DevicesListResponse.Builder.newBuilder() @@ -241,7 +243,8 @@ public DevicesListResponse listDevices(DevicesListRequest request) { public DevicesListResponse asyncListDevices(DevicesListRequest request) { try { AsyncClient asyncClient = new AsyncClient(); - String[] responseArray = asyncClient.asyncListDevices(configParameters.getDevicesURLExtension(), request.getParamsForList()); + String[] responseArray = asyncClient.asyncListDevices(configParameters.getDevicesURLExtension(), + request.getParamsForList()); int responseCode = Integer.parseInt(responseArray[0]); if (responseCode == 200) { DevicesListResponse devicesListResponse = DevicesListResponse.Builder.newBuilder() @@ -259,7 +262,7 @@ public DeviceConfig modifyCloudToDeviceConfig(ModifyCloudToDeviceConfigRequest r SyncClient syncClient = new SyncClient(); String[] paramBody = request.getBodyAndParams(); String[] responseArray = syncClient.post(configParameters.getDevicesURLExtension(), paramBody[0], - paramBody[1]); + paramBody[1], false); System.out.println(responseArray[2]); DeviceConfig deviceConfig = DeviceConfig.newBuilder().build(); if (Integer.parseInt(responseArray[0]) == 200) @@ -288,7 +291,7 @@ public DeviceConfig asyncModifyCloudToDeviceConfig(ModifyCloudToDeviceConfigRequ public ListDeviceStatesResponse listDeviceStates(ListDeviceStatesRequest request) { SyncClient syncClient = new SyncClient(); String[] responseArray = syncClient.get(configParameters.getDevicesStatesURLExtension(), - request.getParamsForList()); + request.getParamsForList(),false); int responseCode = Integer.parseInt(responseArray[0]); if (responseCode == 200) { ListDeviceStatesResponse listDeviceStatesResponse = ListDeviceStatesResponse.Builder.newBuilder() @@ -320,10 +323,11 @@ public ListDeviceStatesResponse asyncListDeviceStates(ListDeviceStatesRequest re public ListDeviceConfigVersionsResponse listDeviceConfigVersions(ListDeviceConfigVersionsRequest request) { SyncClient syncClient = new SyncClient(); String[] responseArray = syncClient.get(configParameters.getCloudiotConfigURLExtension(), - request.getParamsForList()); + request.getParamsForList(),false); int responseCode = Integer.parseInt(responseArray[0]); if (responseCode == 200) { - ListDeviceConfigVersionsResponse listDeviceConfigVersionsResponse = ListDeviceConfigVersionsResponse.Builder.newBuilder() + ListDeviceConfigVersionsResponse listDeviceConfigVersionsResponse = ListDeviceConfigVersionsResponse.Builder + .newBuilder() .buildResponse(responseArray[2]).build(); // deviceObj.loadFromString(responseArray[2]); return listDeviceConfigVersionsResponse; @@ -334,11 +338,13 @@ public ListDeviceConfigVersionsResponse listDeviceConfigVersions(ListDeviceConfi public ListDeviceConfigVersionsResponse asyncListDeviceConfigVersions(ListDeviceConfigVersionsRequest request) { try { AsyncClient asyncClient = new AsyncClient(); - String[] responseArray = asyncClient.asyncListDeviceConfigVersions(configParameters.getCloudiotConfigURLExtension(), + String[] responseArray = asyncClient.asyncListDeviceConfigVersions( + configParameters.getCloudiotConfigURLExtension(), request.getParamsForList()); int responseCode = Integer.parseInt(responseArray[0]); if (responseCode == 200) { - ListDeviceConfigVersionsResponse listDeviceConfigVersionsResponse = ListDeviceConfigVersionsResponse.Builder.newBuilder() + ListDeviceConfigVersionsResponse listDeviceConfigVersionsResponse = ListDeviceConfigVersionsResponse.Builder + .newBuilder() .buildResponse(responseArray[2]).build(); // deviceObj.loadFromString(responseArray[2]); return listDeviceConfigVersionsResponse; @@ -349,5 +355,31 @@ public ListDeviceConfigVersionsResponse asyncListDeviceConfigVersions(ListDevice return null; } + public ListDeviceRegistriesResponse listDeviceRegistries(ListDeviceRegistriesRequest request) { + SyncClient syncClient = new SyncClient(); + String[] responseArray = syncClient.get(configParameters.getCloudiotURLExtension(), request.getParamsForList(),true); + int responseCode = Integer.parseInt(responseArray[0]); + if (responseCode == 200) { + ListDeviceRegistriesResponse deviceRegistriesListResponse = ListDeviceRegistriesResponse.Builder.newBuilder() + .buildResponse(responseArray[2]).build(); + return deviceRegistriesListResponse; + } + return null; + } + public ListDeviceRegistriesResponse asyncListDeviceRegistries(ListDeviceRegistriesRequest request) { + try { + AsyncClient asyncClient = new AsyncClient(); + String[] responseArray = asyncClient.asyncListDeviceRegistries(configParameters.getCloudiotURLExtension(), request.getParamsForList(),true); + int responseCode = Integer.parseInt(responseArray[0]); + if (responseCode == 200) { + ListDeviceRegistriesResponse deviceRegistriesListResponse = ListDeviceRegistriesResponse.Builder.newBuilder() + .buildResponse(responseArray[2]).build(); + return deviceRegistriesListResponse; + } + }catch(Exception e) { + e.printStackTrace(); + } + return null; + } } diff --git a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/ClearBladeRegistryManager.java b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/ClearBladeRegistryManager.java index fe0b8fd5..b3d975e6 100644 --- a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/ClearBladeRegistryManager.java +++ b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/ClearBladeRegistryManager.java @@ -1,20 +1,10 @@ package com.clearblade.cloud.iot.v1; -import com.clearblade.cloud.iot.v1.binddevicetogateway.BindDeviceToGatewayRequest; -import com.clearblade.cloud.iot.v1.binddevicetogateway.BindDeviceToGatewayResponse; -import com.clearblade.cloud.iot.v1.createdevice.CreateDeviceRequest; -import com.clearblade.cloud.iot.v1.deletedevice.DeleteDeviceRequest; -import com.clearblade.cloud.iot.v1.deviceslist.DevicesListRequest; -import com.clearblade.cloud.iot.v1.deviceslist.DevicesListResponse; -import com.clearblade.cloud.iot.v1.getdevice.GetDeviceRequest; +import com.clearblade.cloud.iot.v1.createdeviceregistry.CreateDeviceRegistryRequest; +import com.clearblade.cloud.iot.v1.deletedeviceregistry.DeleteDeviceRegistryRequest; import com.clearblade.cloud.iot.v1.getdeviceregistry.GetDeviceRegistryRequest; -import com.clearblade.cloud.iot.v1.sendcommandtodevice.SendCommandToDeviceRequest; -import com.clearblade.cloud.iot.v1.sendcommandtodevice.SendCommandToDeviceResponse; -import com.clearblade.cloud.iot.v1.unbinddevicefromgateway.UnbindDeviceFromGatewayRequest; -import com.clearblade.cloud.iot.v1.unbinddevicefromgateway.UnbindDeviceFromGatewayResponse; -import com.clearblade.cloud.iot.v1.updatedevice.UpdateDeviceRequest; +import com.clearblade.cloud.iot.v1.updatedeviceregistry.UpdateDeviceRegistryRequest; import com.clearblade.cloud.iot.v1.utils.ConfigParameters; -import com.clearblade.cloud.iot.v1.utils.Device; import com.clearblade.cloud.iot.v1.utils.DeviceRegistry; public class ClearBladeRegistryManager { @@ -23,7 +13,7 @@ public class ClearBladeRegistryManager { public DeviceRegistry getRegistry(GetDeviceRegistryRequest request) { SyncClient syncClient = new SyncClient(); - String[] responseArray = syncClient.getRegistry(configParameters.getCloudiotURLExtension(), request.toString()); + String[] responseArray = syncClient.get(configParameters.getCloudiotURLExtension(), request.toString(),false); int responseCode = Integer.parseInt(responseArray[0]); if(responseCode == 200) { DeviceRegistry deviceRegistry = DeviceRegistry.newBuilder().build(); @@ -50,204 +40,109 @@ public DeviceRegistry asyncGetDeviceRegistry(GetDeviceRegistryRequest request) { return null; } - public Device createDevice(CreateDeviceRequest request) { + public DeviceRegistry createDeviceRegistry(CreateDeviceRegistryRequest request) { SyncClient syncClient = new SyncClient(); - String[] params = request.getParams(); - String reqParams = params[0]; - String body = params[1]; - String[] responseArray = syncClient.post(configParameters.getDevicesURLExtension(), reqParams, body); + String[] bodyParams = request.getBodyAndParams(); + System.out.println(bodyParams[0]); + System.out.println(bodyParams[1]); + + String[] responseArray = syncClient.post(configParameters.getCloudiotURLExtension(), bodyParams[0], + bodyParams[1], true); int responseCode = Integer.parseInt(responseArray[0]); if (responseCode == 200) { - Device deviceObj = Device.newBuilder().build(); - deviceObj.loadFromString(responseArray[2]); - return deviceObj; + DeviceRegistry deviceRegistry = DeviceRegistry.newBuilder().build(); + deviceRegistry.loadFromString(responseArray[2]); + return deviceRegistry; } return null; } - public Device asyncCreateDevice(CreateDeviceRequest request) { + public DeviceRegistry asyncCreateDeviceRegistry(CreateDeviceRegistryRequest request) { try { AsyncClient asyncClient = new AsyncClient(); - String[] params = request.getParams(); - String reqParams = params[0]; - String body = params[1]; - String[] responseArray = asyncClient.asyncCreate(configParameters.getDevicesURLExtension(), reqParams, - body); + String[] bodyParams = request.getBodyAndParams(); + System.out.println(bodyParams[0]); + System.out.println(bodyParams[1]); + + String[] responseArray = asyncClient.asyncCreateDeviceRegistry(configParameters.getCloudiotURLExtension(), + bodyParams[0], + bodyParams[1], true); int responseCode = Integer.parseInt(responseArray[0]); if (responseCode == 200) { - Device deviceObj = Device.newBuilder().build(); - deviceObj.loadFromString(responseArray[2]); - return deviceObj; + DeviceRegistry deviceRegistry = DeviceRegistry.newBuilder().build(); + deviceRegistry.loadFromString(responseArray[2]); + return deviceRegistry; } }catch(Exception e) { e.printStackTrace(); } return null; } - - public void deleteDevice(DeleteDeviceRequest request) { - SyncClient syncClient = new SyncClient(); - String[] responseArray = syncClient.delete(configParameters.getDevicesURLExtension(), request.toString()); - System.out.println( - "Response for delete is " + responseArray[0] + "::" + responseArray[1] + "::" + responseArray[2]); - } - public void asyncDeleteDevice(DeleteDeviceRequest request) { - try { - AsyncClient asyncClient = new AsyncClient(); - String[] responseArray = asyncClient.asyncDelete(configParameters.getDevicesURLExtension(), - request.toString()); - System.out.println( - "Response for delete is " + responseArray[0] + "::" + responseArray[1] + "::" + responseArray[2]); - } catch (Exception e) { - e.printStackTrace(); - } - } - - public Device updateDevice(UpdateDeviceRequest request) { + public DeviceRegistry updateDeviceRegistry(UpdateDeviceRegistryRequest request) { SyncClient syncClient = new SyncClient(); - String[] params = request.getBodyAndParams(); - String reqParams = params[0]; - String body = params[1]; - String[] responseArray = syncClient.patch(configParameters.getDevicesURLExtension(), reqParams, body); + String[] bodyParams = request.getBodyAndParams(); + System.out.println(bodyParams[0]); + System.out.println(bodyParams[1]); + + String[] responseArray = syncClient.update(configParameters.getCloudiotURLExtension(), bodyParams[0], + bodyParams[1]); int responseCode = Integer.parseInt(responseArray[0]); if (responseCode == 200) { - Device deviceObj = Device.newBuilder().build(); - deviceObj.loadFromString(responseArray[2]); - return deviceObj; + DeviceRegistry deviceRegistry = DeviceRegistry.newBuilder().build(); + deviceRegistry.loadFromString(responseArray[2]); + return deviceRegistry; + }else { + System.out.println("Registry doesn't get updated::"+responseArray[2]); } return null; } - public Device asyncUpdateDevice(UpdateDeviceRequest request) { + + public DeviceRegistry asyncUpdateDeviceRegistry(UpdateDeviceRegistryRequest request) { try { AsyncClient asyncClient = new AsyncClient(); - String[] params = request.getBodyAndParams(); - String reqParams = params[0]; - String body = params[1]; - String[] responseArray = asyncClient.asyncUpdate(configParameters.getDevicesURLExtension(), reqParams, - body); + String[] bodyParams = request.getBodyAndParams(); + System.out.println(bodyParams[0]); + System.out.println(bodyParams[1]); + + String[] responseArray = asyncClient.asyncUpdateDeviceRegistry(configParameters.getCloudiotURLExtension(), bodyParams[0], + bodyParams[1]); int responseCode = Integer.parseInt(responseArray[0]); if (responseCode == 200) { - Device deviceObj = Device.newBuilder().build(); - deviceObj.loadFromString(responseArray[2]); - return deviceObj; + DeviceRegistry deviceRegistry = DeviceRegistry.newBuilder().build(); + deviceRegistry.loadFromString(responseArray[2]); + return deviceRegistry; + }else { + System.out.println("Registry doesn't get updated::"+responseArray[2]); } }catch(Exception e) { e.printStackTrace(); } return null; } - public BindDeviceToGatewayResponse bindDeviceToGateway(BindDeviceToGatewayRequest request) { + + public void deleteDeviceRegistry(DeleteDeviceRegistryRequest request) { SyncClient syncClient = new SyncClient(); - String[] paramBody = request.getBodyAndParams(); - String[] responseArray = syncClient.post(configParameters.getCloudiotURLExtension(), paramBody[0], - paramBody[1]); - BindDeviceToGatewayResponse response = BindDeviceToGatewayResponse.Builder.newBuilder().build(); - response.setHttpStatusCode(Integer.parseInt(responseArray[0])); - response.setHttpStatusResponse(responseArray[1]); - return response; - } + String bodyParams = request.getParams(); + System.out.println(bodyParams); - public BindDeviceToGatewayResponse asyncBindDeviceToGateway(BindDeviceToGatewayRequest request) { - try { - AsyncClient asyncClient = new AsyncClient(); - String[] paramBody = request.getBodyAndParams(); - String[] responseArray = asyncClient.asyncBindDeviceToGateway(configParameters.getCloudiotURLExtension(), - paramBody[0], paramBody[1]); - BindDeviceToGatewayResponse response = BindDeviceToGatewayResponse.Builder.newBuilder().build(); - response.setHttpStatusCode(Integer.parseInt(responseArray[0])); - response.setHttpStatusResponse(responseArray[1]); - return response; - }catch(Exception e) { - e.printStackTrace(); - } - return null; - } - - public UnbindDeviceFromGatewayResponse unbindDeviceFromGateway(UnbindDeviceFromGatewayRequest request) { - SyncClient syncClinet = new SyncClient(); - String[] paramBody = request.getBodyAndParams(); - String[] responseArray = syncClinet.post(configParameters.getCloudiotURLExtension(), paramBody[0], - paramBody[1]); - UnbindDeviceFromGatewayResponse response = UnbindDeviceFromGatewayResponse.Builder.newBuilder().build(); - response.setHttpStatusCode(Integer.parseInt(responseArray[0])); - response.setHttpStatusResponse(responseArray[1]); - return response; - } - - public UnbindDeviceFromGatewayResponse asyncUnbindDeviceFromGateway(UnbindDeviceFromGatewayRequest request) { - try { - AsyncClient asyncClinet = new AsyncClient(); - String[] paramBody = request.getBodyAndParams(); - String[] responseArray = asyncClinet.asyncUnbindDeviceFromGateway( - configParameters.getCloudiotURLExtension(), paramBody[0], paramBody[1]); - UnbindDeviceFromGatewayResponse response = UnbindDeviceFromGatewayResponse.Builder.newBuilder().build(); - response.setHttpStatusCode(Integer.parseInt(responseArray[0])); - response.setHttpStatusResponse(responseArray[1]); - return response; - }catch(Exception e) { - e.printStackTrace(); - } - return null; - } - - public SendCommandToDeviceResponse sendCommandToDevice(SendCommandToDeviceRequest request) { - SyncClient syncClient = new SyncClient(); - String[] paramBody = request.getBodyAndParams(); - String[] responseArray = syncClient.post(configParameters.getDevicesURLExtension(), paramBody[0], - paramBody[1]); - System.out.println(responseArray[2]); - SendCommandToDeviceResponse response = SendCommandToDeviceResponse.Builder.newBuilder().build(); - response.setHttpStatusCode(Integer.parseInt(responseArray[0])); - response.setHttpStatusResponse(responseArray[1]); - return response; + String[] responseArray = syncClient.delete(configParameters.getCloudiotURLExtension(), bodyParams, true); + System.out.println( + "Response for delete is " + responseArray[0] + "::" + responseArray[1] + "::" + responseArray[2]); } - public SendCommandToDeviceResponse asyncSendCommandToDevice(SendCommandToDeviceRequest request) { + public void asyncDeleteDeviceRegistry(DeleteDeviceRegistryRequest request) { try { AsyncClient asyncClient = new AsyncClient(); - String[] paramBody = request.getBodyAndParams(); - String[] responseArray = asyncClient.asyncSendCommandToDevice(configParameters.getDevicesURLExtension(), - paramBody[0], - paramBody[1]); - System.out.println(responseArray[2]); - SendCommandToDeviceResponse response = SendCommandToDeviceResponse.Builder.newBuilder().build(); - response.setHttpStatusCode(Integer.parseInt(responseArray[0])); - response.setHttpStatusResponse(responseArray[1]); - return response; - } catch (Exception e) { - e.printStackTrace(); - } - return null; - } - - public DevicesListResponse listDevices(DevicesListRequest request) { - SyncClient syncClient = new SyncClient(); - String[] responseArray = syncClient.get(configParameters.getDevicesURLExtension(), request.getParamsForList()); - int responseCode = Integer.parseInt(responseArray[0]); - if (responseCode == 200) { - DevicesListResponse devicesListResponse = DevicesListResponse.Builder.newBuilder() - .buildResponse(responseArray[2]).build(); - // deviceObj.loadFromString(responseArray[2]); - return devicesListResponse; - } - return null; - } - public DevicesListResponse asyncListDevices(DevicesListRequest request) { - try { - AsyncClient asyncClient = new AsyncClient(); - String[] responseArray = asyncClient.asyncListDevices(configParameters.getDevicesURLExtension(), request.getParamsForList()); - int responseCode = Integer.parseInt(responseArray[0]); - if (responseCode == 200) { - DevicesListResponse devicesListResponse = DevicesListResponse.Builder.newBuilder() - .buildResponse(responseArray[2]).build(); - // deviceObj.loadFromString(responseArray[2]); - return devicesListResponse; - } + String bodyParams = request.getParams(); + System.out.println(bodyParams); + + String[] responseArray = asyncClient.asyncDeleteDeviceRegistry(configParameters.getCloudiotURLExtension(), bodyParams, + "", true); + System.out.println( + "Response for delete is " + responseArray[0] + "::" + responseArray[1] + "::" + responseArray[2]); }catch(Exception e) { e.printStackTrace(); } - return null; } - } diff --git a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/DeviceManagerAsyncClient.java b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/DeviceManagerAsyncClient.java index 15409963..e3fd511a 100644 --- a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/DeviceManagerAsyncClient.java +++ b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/DeviceManagerAsyncClient.java @@ -5,7 +5,9 @@ import com.clearblade.cloud.iot.v1.binddevicetogateway.BindDeviceToGatewayRequest; import com.clearblade.cloud.iot.v1.binddevicetogateway.BindDeviceToGatewayResponse; import com.clearblade.cloud.iot.v1.createdevice.CreateDeviceRequest; +import com.clearblade.cloud.iot.v1.createdeviceregistry.CreateDeviceRegistryRequest; import com.clearblade.cloud.iot.v1.deletedevice.DeleteDeviceRequest; +import com.clearblade.cloud.iot.v1.deletedeviceregistry.DeleteDeviceRegistryRequest; import com.clearblade.cloud.iot.v1.deviceslist.DevicesListRequest; import com.clearblade.cloud.iot.v1.deviceslist.DevicesListResponse; import com.clearblade.cloud.iot.v1.devicestateslist.ListDeviceStatesRequest; @@ -14,12 +16,15 @@ import com.clearblade.cloud.iot.v1.getdeviceregistry.GetDeviceRegistryRequest; import com.clearblade.cloud.iot.v1.listdeviceconfigversions.ListDeviceConfigVersionsRequest; import com.clearblade.cloud.iot.v1.listdeviceconfigversions.ListDeviceConfigVersionsResponse; +import com.clearblade.cloud.iot.v1.listdeviceregistries.ListDeviceRegistriesRequest; +import com.clearblade.cloud.iot.v1.listdeviceregistries.ListDeviceRegistriesResponse; import com.clearblade.cloud.iot.v1.modifycloudtodeviceconfig.ModifyCloudToDeviceConfigRequest; import com.clearblade.cloud.iot.v1.sendcommandtodevice.SendCommandToDeviceRequest; import com.clearblade.cloud.iot.v1.sendcommandtodevice.SendCommandToDeviceResponse; import com.clearblade.cloud.iot.v1.unbinddevicefromgateway.UnbindDeviceFromGatewayRequest; import com.clearblade.cloud.iot.v1.unbinddevicefromgateway.UnbindDeviceFromGatewayResponse; import com.clearblade.cloud.iot.v1.updatedevice.UpdateDeviceRequest; +import com.clearblade.cloud.iot.v1.updatedeviceregistry.UpdateDeviceRegistryRequest; import com.clearblade.cloud.iot.v1.utils.Device; import com.clearblade.cloud.iot.v1.utils.DeviceConfig; import com.clearblade.cloud.iot.v1.utils.DeviceRegistry; @@ -132,5 +137,24 @@ public DeviceRegistry getDeviceRegistry(GetDeviceRegistryRequest request) { return cbManager.asyncGetDeviceRegistry(request); } + public DeviceRegistry createDeviceRegistry(CreateDeviceRegistryRequest request) { + ClearBladeRegistryManager cbManager = new ClearBladeRegistryManager(); + return cbManager.asyncCreateDeviceRegistry(request); + } + + public DeviceRegistry updateDeviceRegistry(UpdateDeviceRegistryRequest request) { + ClearBladeRegistryManager cbManager = new ClearBladeRegistryManager(); + return cbManager.asyncUpdateDeviceRegistry(request); + } + + public void deleteDeviceRegistry(DeleteDeviceRegistryRequest request) { + ClearBladeRegistryManager cbManager = new ClearBladeRegistryManager(); + cbManager.asyncDeleteDeviceRegistry(request); + } + + public ListDeviceRegistriesResponse listDeviceRegistries(ListDeviceRegistriesRequest request) { + ClearBladeDeviceManager cbManager = new ClearBladeDeviceManager(); + return cbManager.asyncListDeviceRegistries(request); + } } diff --git a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/DeviceManagerClient.java b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/DeviceManagerClient.java index 1e01482a..5a61075a 100644 --- a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/DeviceManagerClient.java +++ b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/DeviceManagerClient.java @@ -5,7 +5,9 @@ import com.clearblade.cloud.iot.v1.binddevicetogateway.BindDeviceToGatewayRequest; import com.clearblade.cloud.iot.v1.binddevicetogateway.BindDeviceToGatewayResponse; import com.clearblade.cloud.iot.v1.createdevice.CreateDeviceRequest; +import com.clearblade.cloud.iot.v1.createdeviceregistry.CreateDeviceRegistryRequest; import com.clearblade.cloud.iot.v1.deletedevice.DeleteDeviceRequest; +import com.clearblade.cloud.iot.v1.deletedeviceregistry.DeleteDeviceRegistryRequest; import com.clearblade.cloud.iot.v1.deviceslist.DevicesListRequest; import com.clearblade.cloud.iot.v1.deviceslist.DevicesListResponse; import com.clearblade.cloud.iot.v1.devicestateslist.ListDeviceStatesRequest; @@ -14,12 +16,15 @@ import com.clearblade.cloud.iot.v1.getdeviceregistry.GetDeviceRegistryRequest; import com.clearblade.cloud.iot.v1.listdeviceconfigversions.ListDeviceConfigVersionsRequest; import com.clearblade.cloud.iot.v1.listdeviceconfigversions.ListDeviceConfigVersionsResponse; +import com.clearblade.cloud.iot.v1.listdeviceregistries.ListDeviceRegistriesRequest; +import com.clearblade.cloud.iot.v1.listdeviceregistries.ListDeviceRegistriesResponse; import com.clearblade.cloud.iot.v1.modifycloudtodeviceconfig.ModifyCloudToDeviceConfigRequest; import com.clearblade.cloud.iot.v1.sendcommandtodevice.SendCommandToDeviceRequest; import com.clearblade.cloud.iot.v1.sendcommandtodevice.SendCommandToDeviceResponse; import com.clearblade.cloud.iot.v1.unbinddevicefromgateway.UnbindDeviceFromGatewayRequest; import com.clearblade.cloud.iot.v1.unbinddevicefromgateway.UnbindDeviceFromGatewayResponse; import com.clearblade.cloud.iot.v1.updatedevice.UpdateDeviceRequest; +import com.clearblade.cloud.iot.v1.updatedeviceregistry.UpdateDeviceRegistryRequest; import com.clearblade.cloud.iot.v1.utils.Device; import com.clearblade.cloud.iot.v1.utils.DeviceConfig; import com.clearblade.cloud.iot.v1.utils.DeviceRegistry; @@ -29,28 +34,31 @@ public class DeviceManagerClient { static Logger log = Logger.getLogger(DeviceManagerClient.class.getName()); /** - * Calling getDevice api + * Calling getDevice api + * * @param request * @return Device object */ - - public Device getDevice(GetDeviceRequest request) { - ClearBladeDeviceManager cbManager = new ClearBladeDeviceManager(); - return cbManager.getDevice(request); - } + + public Device getDevice(GetDeviceRequest request) { + ClearBladeDeviceManager cbManager = new ClearBladeDeviceManager(); + return cbManager.getDevice(request); + } /** - * Calling createDevice api + * Calling createDevice api + * * @param request * @return Device object - */ - public Device createDevice(CreateDeviceRequest request) { - ClearBladeDeviceManager cbManager = new ClearBladeDeviceManager(); - return cbManager.createDevice(request); - } + */ + public Device createDevice(CreateDeviceRequest request) { + ClearBladeDeviceManager cbManager = new ClearBladeDeviceManager(); + return cbManager.createDevice(request); + } /** * Calling bindDeviceToGateway api + * * @param request * @return */ @@ -61,6 +69,7 @@ public BindDeviceToGatewayResponse bindDeviceToGateway(BindDeviceToGatewayReques /** * Calling unbindDeviceFromGateway api + * * @param request * @return */ @@ -71,22 +80,24 @@ public UnbindDeviceFromGatewayResponse unbindDeviceFromGateway(UnbindDeviceFromG /** * Calling deleteDevice api + * * @param request */ public void deleteDevice(DeleteDeviceRequest request) { ClearBladeDeviceManager cbManager = new ClearBladeDeviceManager(); - cbManager.deleteDevice(request); + cbManager.deleteDevice(request); } /** - * Calling updateDevice api + * Calling updateDevice api + * * @param request * @return Device object - */ - public Device updateDevice(UpdateDeviceRequest request) { - ClearBladeDeviceManager cbManager = new ClearBladeDeviceManager(); - return cbManager.updateDevice(request); - } + */ + public Device updateDevice(UpdateDeviceRequest request) { + ClearBladeDeviceManager cbManager = new ClearBladeDeviceManager(); + return cbManager.updateDevice(request); + } public SendCommandToDeviceResponse sendCommandToDevice(SendCommandToDeviceRequest request) { ClearBladeDeviceManager cbManager = new ClearBladeDeviceManager(); @@ -97,7 +108,6 @@ public SendCommandToDeviceResponse sendCommandToDevice(SendCommandToDeviceReques public DevicesListResponse listDevices(DevicesListRequest request) { ClearBladeDeviceManager cbManager = new ClearBladeDeviceManager(); return cbManager.listDevices(request); - } public DeviceConfig modifyCloudToDeviceConfig(ModifyCloudToDeviceConfigRequest request) { @@ -117,16 +127,36 @@ public ListDeviceConfigVersionsResponse listDeviceConfigVersions(ListDeviceConfi } - //Registry Apis + // Registry Apis /** - * Calling getDeviceRegistry api + * Calling getDeviceRegistry api + * * @param request * @return DeviceRegistry object */ - public DeviceRegistry getDeviceRegistry(GetDeviceRegistryRequest request) { - ClearBladeRegistryManager cbManager = new ClearBladeRegistryManager(); - return cbManager.getRegistry(request); - } + public DeviceRegistry getDeviceRegistry(GetDeviceRegistryRequest request) { + ClearBladeRegistryManager cbManager = new ClearBladeRegistryManager(); + return cbManager.getRegistry(request); + } + + public DeviceRegistry createDeviceRegistry(CreateDeviceRegistryRequest request) { + ClearBladeRegistryManager cbManager = new ClearBladeRegistryManager(); + return cbManager.createDeviceRegistry(request); + } + + public DeviceRegistry updateDeviceRegistry(UpdateDeviceRegistryRequest request) { + ClearBladeRegistryManager cbManager = new ClearBladeRegistryManager(); + return cbManager.updateDeviceRegistry(request); + } + public void deleteDeviceRegistry(DeleteDeviceRegistryRequest request) { + ClearBladeRegistryManager cbManager = new ClearBladeRegistryManager(); + cbManager.deleteDeviceRegistry(request); + } + + public ListDeviceRegistriesResponse listDeviceRegistries(ListDeviceRegistriesRequest request) { + ClearBladeDeviceManager cbManager = new ClearBladeDeviceManager(); + return cbManager.listDeviceRegistries(request); + } } diff --git a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/ProcessRequest.java b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/ProcessRequest.java deleted file mode 100644 index b8a1a99f..00000000 --- a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/ProcessRequest.java +++ /dev/null @@ -1,587 +0,0 @@ -package com.clearblade.cloud.iot.v1; - -import java.io.BufferedReader; -import java.io.IOException; -import java.io.InputStream; -import java.io.InputStreamReader; -import java.io.OutputStream; -import java.net.ProtocolException; -import java.net.URL; -import java.util.concurrent.CompletableFuture; -import java.util.concurrent.ExecutionException; -import java.util.concurrent.Future; -import java.util.concurrent.TimeUnit; -import java.util.concurrent.TimeoutException; -import java.util.logging.Level; -import java.util.logging.Logger; - -import javax.net.ssl.HttpsURLConnection; - -import org.json.simple.JSONObject; -import org.json.simple.parser.JSONParser; -import org.json.simple.parser.ParseException; - -import com.clearblade.cloud.iot.v1.auth.AdminAccess; -import com.clearblade.cloud.iot.v1.auth.SystemAccess; -import com.clearblade.cloud.iot.v1.getregistrycredentials.GetRegistryCredentialsRequest; -import com.clearblade.cloud.iot.v1.getregistrycredentials.GetRegistryCredentialsResponse; -import com.clearblade.cloud.iot.v1.sendcommandtodevice.SendCommandToDeviceRequest; -import com.clearblade.cloud.iot.v1.utils.AuthParams; -import com.clearblade.cloud.iot.v1.utils.ConfigParameters; -import com.clearblade.cloud.iot.v1.utils.Constants; -import com.clearblade.cloud.iot.v1.utils.SetHttpConnection; - -public class ProcessRequest { - - static Logger log = Logger.getLogger(ProcessRequest.class.getName()); - URL obj; - HttpsURLConnection con; - String responseMessage; - JSONObject bodyJSONObj; - JSONObject requestJSONObj; - int responseCode; - ConfigParameters configParameters; - SetHttpConnection setCon; - String emptyStr; - SystemAccess systemAccess; - AuthParams authParams; - - - public void getRegistryCredentials() { - - String msg = ""; - - GetRegistryCredentialsRequest request = GetRegistryCredentialsRequest.Builder.newBuilder().build(); - GetRegistryCredentialsResponse response = GetRegistryCredentialsResponse.Builder.newBuilder().setGetRegistryCredentialsRequest(request).build(); - - if (response != null) { - log.log(Level.INFO,"Request is processed for {0}",request); - JSONObject requestParams = new JSONObject(); - JSONObject bodyParams = new JSONObject(); - if(request.getBodyParams()!= null) { - bodyParams = (JSONObject) request.getBodyParams().clone(); - } - try { - responseMessage = processRequestGetRegistryCredential(Constants.GET_REGISTRY_CREDENTIALS, requestParams, bodyParams); - } catch (Exception e) { - e.printStackTrace(); - } - response.setHttpStatusResponse(responseMessage); - if (responseMessage.equals("OK")) { - response.setHttpStatusCode(200); - msg = "Request processed for GetRegistryCredentialsRequest method"; - - log.log(Level.INFO, msg); - } else { - response.setHttpStatusCode(0); - msg = "Request for GetRegistryCredentialsRequest failed \n" .concat(responseMessage); - log.log(Level.SEVERE, msg); - } - if (response.getHttpStatusResponse().equals("OK")) { - msg = "AsyncGetRegistryCredentials Method worked successfully :: " + response.getHttpStatusResponse(); - log.log(Level.INFO, msg); - } else { - msg = "AsyncGetRegistryCredentials Method execution failed :: " + response.getHttpStatusResponse(); - log.log(Level.SEVERE, msg); - } - } else { - msg = "AsyncGetRegistryCredentials Method execution failed"; - log.log(Level.SEVERE, msg); - } - } - - // Empty Constructor - public ProcessRequest() { - - emptyStr = ""; - configParameters = new ConfigParameters(); - obj = null; - con = null; - setCon = null; - responseCode = 0; - responseMessage = null; - systemAccess = new SystemAccess(); - AdminAccess adminAccess = new AdminAccess(); - if(adminAccess.getAuthParams() == null) { - authParams =adminAccess.getSystemCredentials(); - }else { - authParams = adminAccess.getAuthParams(); - } - this.setAuthParams(authParams); - if(systemAccess.getApiBaseURL() == null) { - getRegistryCredentials(); - } - } - - /** - * Method used to getRegistryCredentials and - * set user system access - * @param methodName - * @param requestParams - * @param bodyParams - * @return String value of response object - */ - public String processRequestGetRegistryCredential(String methodName, JSONObject requestParams, JSONObject bodyParams) { - String finalURL = emptyStr; - try { - if (bodyParams != null && bodyParams.size() > 0) { - this.setBodyJSONObj(bodyParams); - } - finalURL = generateURL(methodName, requestParams); - obj = new URL(finalURL); - setCon = new SetHttpConnection(); - con = setCon.getConnection(obj); - responseMessage = setConnectionMethods(con, methodName); - } catch (Exception e) { - e.printStackTrace(); - } - return responseMessage; - } - - /** - * Method used to get process the request when inputString and connection object - * are inputs ResponseCode - integer value is sent as return value - * @param methodName - * @return String - response message - */ - public String processRequestForMethod(String methodName, JSONObject requestParams, JSONObject bodyParams) { - try { - if (bodyParams != null && bodyParams.size() > 0) { - this.setBodyJSONObj(bodyParams); - } - String finalURL = generateURL(methodName, requestParams); - log.log(Level.INFO,finalURL); - obj = new URL(finalURL); - setCon = new SetHttpConnection(); - con = setCon.getConnection(obj); - responseMessage = setConnectionMethods(con, methodName); - } catch (Exception e) { - e.printStackTrace(); - } - return responseMessage; - } - - /** - * Set connection methods - * @param con - * @returning response message - */ - public String setConnectionMethods(HttpsURLConnection con, String methodName) { - - if (con != null) { - if (methodName.equals(Constants.GET_REGISTRY_CREDENTIALS)) { - con.setRequestProperty(Constants.HTTP_REQUEST_PROPERTY_TOKEN_KEY, authParams.getAdminToken()); - }else { - con.setRequestProperty(Constants.HTTP_REQUEST_PROPERTY_TOKEN_KEY, systemAccess.getUserSystemToken()); - } - con.setRequestProperty(Constants.HTTP_REQUEST_PROPERTY_CONTENT_TYPE_KEY, - Constants.HTTP_REQUEST_PROPERTY_CONTENT_TYPE_ACCEPT_VALUE); - con.addRequestProperty(Constants.HTTP_REQUEST_PROPERTY_ACCEPT_KEY, - Constants.HTTP_REQUEST_PROPERTY_CONTENT_TYPE_ACCEPT_VALUE); - - String methodType = setMethodType(methodName); - try { - con.setRequestMethod(methodType); - if (methodName.equals(Constants.DEVICE_PATCH)) { - con.setRequestProperty("X-HTTP-Method-Override", Constants.HTTP_REQUEST_METHOD_TYPE_PATCH); - } - } catch (ProtocolException e) { - e.printStackTrace(); - } - - // SetOutput to connection - con.setDoOutput(true); - - // Get responseCode from Connection - if (methodName.equals(Constants.SEND_COMMAND_TO_DEVICE) || methodName.equals(Constants.CREATE_DEVICE) - || methodName.equals(Constants.DEVICE_SET_STATES) - || methodName.equals(Constants.MODIFY_CLOUD_TO_DEVICE_CONFIG) - || methodName.equals(Constants.BIND_DEVICE_TO_GATEWAY) - || methodName.equals(Constants.UNBIND_DEVICE_FROM_GATEWAY)) { - responseMessage = getResponseForPostMethod(con); - } else if (methodName.equals(Constants.DELETE_DEVICE)) { - responseMessage = getResponseForDeleteDevice(con); - } else if (methodName.equals(Constants.GET_DEVICE) || methodName.equals(Constants.DEVICES_LIST) - || methodName.equals(Constants.DEVICE_STATES_LIST) || methodName.equals(Constants.DEVICE_GET_CONFIG) - || methodName.equals(Constants.DEVICE_CONFIG_VERSIONS_LIST)) { - responseMessage = getResponseForGetRequest(con); - } else if (methodName.equals(Constants.DEVICE_PATCH)) { - responseMessage = getResponseForPostMethod(con); - } else if (methodName.equals(Constants.GET_REGISTRY_CREDENTIALS)) { - responseMessage = getResponseForRegsitryCredentialsMethod(con); - } - } - return responseMessage; - } - - /** - * Method used to get Response when inputString and connection object are inputs - * ResponseMessage - String value is sent as return value - * - * @param con - * @param inputString - * @return responseMessage - */ - public String getResponseForGetRequest(HttpsURLConnection con) { - StringBuilder response = new StringBuilder(); - InputStream inStr = null; - BufferedReader in = null; - try { - responseCode = con.getResponseCode(); - if (responseCode != 200) { - if (con.getErrorStream() != null) { - inStr = con.getErrorStream(); - } else if (con.getInputStream() != null) { - inStr = con.getInputStream(); - } - in = new BufferedReader(new InputStreamReader(inStr)); - String inputLine; - while ((inputLine = in.readLine()) != null) { - response.append(inputLine); - } - in.close(); - responseMessage = response.toString(); - } else if (responseCode == 200) { - - String splitResponse = ""; - String inputLine = ""; - if (con.getInputStream() != null) { - in = new BufferedReader(new InputStreamReader(con.getInputStream())); - } - if (in != null) { - while ((inputLine = in.readLine()) != null) { - response.append(inputLine); - splitResponse = splitResponse.concat(inputLine); - } - System.out.println(splitResponse); - in.close(); - } - responseMessage = "OK"; - } - - } catch (IOException e) { - e.printStackTrace(); - } - return responseMessage; - } - - public String getResponseForPostMethod(HttpsURLConnection con) { - StringBuilder response = new StringBuilder(); - try (OutputStream os = con.getOutputStream()) { - JSONObject js = this.getBodyJSONObj(); - byte[] input = js.toString().getBytes(Constants.UTF8); - os.write(input, 0, input.length); - os.flush(); - responseCode = con.getResponseCode(); - BufferedReader in = null; - if (con.getErrorStream() != null) { - in = new BufferedReader(new InputStreamReader(con.getErrorStream())); - } else if (con.getInputStream() != null) { - in = new BufferedReader(new InputStreamReader(con.getInputStream())); - } - String inputLine; - if (in != null) { - while ((inputLine = in.readLine()) != null) { - response.append(inputLine); - } - } - if (responseCode != 200) { - responseMessage = response.toString(); - } else if (responseCode == 200) { - responseMessage = "OK"; - } - } catch (IOException e1) { - e1.printStackTrace(); - } - return responseMessage; - } - - public String getResponseForRegsitryCredentialsMethod(HttpsURLConnection con) { - StringBuilder response = new StringBuilder(); - try (OutputStream os = con.getOutputStream()) { - JSONObject js = this.getBodyJSONObj(); - byte[] input = js.toString().getBytes(Constants.UTF8); - os.write(input, 0, input.length); - os.flush(); - responseCode = con.getResponseCode(); - BufferedReader in = null; - if (con.getErrorStream() != null) { - in = new BufferedReader(new InputStreamReader(con.getErrorStream())); - } else if (con.getInputStream() != null) { - in = new BufferedReader(new InputStreamReader(con.getInputStream())); - } - JSONObject responseJSONObject = new JSONObject(); - JSONParser responseParser = new JSONParser(); - String inputLine; - if (in != null) { - while ((inputLine = in.readLine()) != null) { - response.append(inputLine); - } - responseMessage = response.toString(); - } - if (responseCode == 200) { - try { - if(responseMessage != null && responseMessage.length() > 0) { - Object responseObj = responseParser.parse(responseMessage); - if(responseObj != null) { - responseJSONObject = (JSONObject) responseObj; - systemAccess.setUserSystemKey(responseJSONObject.get(Constants.USER_SYSTEM_KEY).toString()); - systemAccess.setUserSystemToken(responseJSONObject.get(Constants.USER_TOKEN).toString()); - systemAccess.setApiBaseURL(responseJSONObject.get(Constants.API_BASE_URL).toString()); - this.setSystemAccess(systemAccess); - } - } - } catch (ParseException e) { - e.printStackTrace(); - } - responseMessage = "OK"; - } - } catch (IOException e1) { - e1.printStackTrace(); - } - return responseMessage; - } - - public String getResponseForDeleteDevice(HttpsURLConnection con) { - StringBuilder response = new StringBuilder(); - try { - responseCode = con.getResponseCode(); - BufferedReader in = null; - if (con.getErrorStream() != null) { - in = new BufferedReader(new InputStreamReader(con.getErrorStream())); - } else if (con.getInputStream() != null) { - in = new BufferedReader(new InputStreamReader(con.getInputStream())); - } - String inputLine; - if (in != null) { - while ((inputLine = in.readLine()) != null) { - response.append(inputLine); - } - } - if (responseCode != 200) { - responseMessage = response.toString(); - } else if (responseCode == 200) { - responseMessage = "OK"; - } - } catch (IOException e) { - e.printStackTrace(); - } - return responseMessage; - } - - public String asyncCallSendCommandToDevice(SendCommandToDeviceRequest request) throws InterruptedException { - this.setBodyJSONObj(request.bodyParams); - this.setRequestJSONObj(request.requestParams); - Future future = getObjectAsync(); - try { - future.get(15000, TimeUnit.MILLISECONDS); - } catch (InterruptedException | ExecutionException | TimeoutException e) { - e.printStackTrace(); - Thread.currentThread().interrupt(); - } - return responseMessage; - } - - public Future getObjectAsync() { - return CompletableFuture.supplyAsync(this::doHttpCall); - } - - public Object doHttpCall() { - StringBuilder response = new StringBuilder(); - try { - - // Generate URL for this api call - String finalURL = generateURL(Constants.SEND_COMMAND_TO_DEVICE, this.getRequestJSONObj()); - - obj = new URL(finalURL); - setCon = new SetHttpConnection(); - con = setCon.getConnection(obj); // Calling setConnectionMethod - con.setRequestProperty(Constants.HTTP_REQUEST_PROPERTY_TOKEN_KEY, systemAccess.getUserSystemToken()); - con.setRequestProperty(Constants.HTTP_REQUEST_PROPERTY_CONTENT_TYPE_KEY, - Constants.HTTP_REQUEST_PROPERTY_CONTENT_TYPE_ACCEPT_VALUE); - con.addRequestProperty(Constants.HTTP_REQUEST_PROPERTY_ACCEPT_KEY, - Constants.HTTP_REQUEST_PROPERTY_CONTENT_TYPE_ACCEPT_VALUE); - - String methodType = Constants.HTTP_REQUEST_METHOD_TYPE_POST; - con.setRequestMethod(methodType); - - // SetOutput to connection - con.setDoOutput(true); - - OutputStream os = con.getOutputStream(); - JSONObject js = this.getBodyJSONObj(); - byte[] input = js.toString().getBytes(Constants.UTF8); - os.write(input, 0, input.length); - os.flush(); - responseCode = con.getResponseCode(); - if (responseCode != 200) { - BufferedReader in = null; - if (con.getErrorStream() != null) { - in = new BufferedReader(new InputStreamReader(con.getErrorStream())); - } else if (con.getInputStream() != null) { - in = new BufferedReader(new InputStreamReader(con.getInputStream())); - } - String inputLine; - if (in != null) { - while ((inputLine = in.readLine()) != null) { - response.append(inputLine); - } - } - responseMessage = response.toString(); - } else if (responseCode == 200) { - responseMessage = "OK"; - } - } catch (IOException e1) { - e1.printStackTrace(); - } - return responseMessage; - } - - public String generateURL(String methodName, JSONObject requestParams) { - - String finalURL = emptyStr; - - - // Global Call - if (requestParams.size() == 0) { - if (methodName.equals(Constants.GET_REGISTRY_CREDENTIALS)) { - String partialURL = authParams.getBaseURL() - .concat(configParameters.getGetSystemCredentialsExtension()) - .concat(authParams.getAdminSystemKey()) - .concat("/" + methodName); - finalURL = finalURL.concat(partialURL); - } - }else { - - // Regional Call - String urlPartial = this.getSystemAccess().getApiBaseURL() - .concat(configParameters.getEndpointPort()) - .concat(configParameters.getBaseURL()) - .concat(this.getSystemAccess().getUserSystemKey()); - - String urlDevicesPartial = urlPartial.concat(configParameters.getDevicesURLExtension()); - String urlDevicesStatesPartial = urlPartial.concat(configParameters.getDevicesStatesURLExtension()); - String urlCloudiotdevicesPartial = urlPartial.concat(configParameters.getCloudiotdevicesURLExtension()); - String urlCloudiotURLPartial = urlPartial.concat(configParameters.getCloudiotURLExtension()); - - - if (methodName.equals(Constants.SEND_COMMAND_TO_DEVICE) || methodName.equals(Constants.MODIFY_CLOUD_TO_DEVICE_CONFIG)) { - - String name = requestParams.get("name").toString(); - finalURL = urlDevicesPartial.concat(Constants.NAME + name + "&method=" + methodName); - - } else if (methodName.equals(Constants.CREATE_DEVICE)) { - - String deviceNumIds = requestParams.get("deviceNumIds").toString(); - String subfolder = requestParams.get("subfolder").toString(); - finalURL = urlDevicesPartial.concat("?deviceNumIds=" + deviceNumIds + "&subfolder=" + subfolder); - - } else if (methodName.equals(Constants.DELETE_DEVICE) || methodName.equals(Constants.GET_DEVICE)) { - - String name = requestParams.get("name").toString(); - finalURL = urlDevicesPartial.concat(Constants.NAME + name); - - } else if (methodName.equals(Constants.DEVICES_LIST)) { - - String parent = requestParams.get("parent").toString(); - finalURL = urlDevicesPartial.concat("?parent=" + parent); - - } else if (methodName.equals(Constants.DEVICE_STATES_LIST)) { - - String name = requestParams.get("name").toString(); - String numStates = requestParams.get("numStates").toString(); - finalURL = urlDevicesStatesPartial.concat(Constants.NAME + name + "&numStates=" + Integer.parseInt(numStates)); - - } else if (methodName.equals(Constants.DEVICE_CONFIG_VERSIONS_LIST)) { - - String name = requestParams.get("name").toString(); - String numVersions = requestParams.get("numVersions").toString(); - finalURL = urlCloudiotdevicesPartial.concat(Constants.NAME + name + "&numVersions=" + numVersions); - - } else if (methodName.equals(Constants.UNBIND_DEVICE_FROM_GATEWAY) || methodName.equals(Constants.BIND_DEVICE_TO_GATEWAY)) { - - String method = requestParams.get("method").toString(); - String parent = requestParams.get("parent").toString(); - finalURL = urlCloudiotURLPartial.concat("?method=" + method + "&parent=" + parent); - - } else if (methodName.equals(Constants.DEVICE_PATCH)) { - - String name = requestParams.get("name").toString(); - String updateMask = requestParams.get("updateMask").toString(); - finalURL = urlDevicesPartial.concat(Constants.NAME + name + "&updateMask=" + updateMask); - } - } - - return finalURL; - } - - /** - * Method used to set method type on connection depending upon method name - * @param methodName - * @return methodType to be set for e.g. post, patch, delete etc - */ - public String setMethodType(String methodName) { - String methodType = emptyStr; - - if ((methodName.equals(Constants.SEND_COMMAND_TO_DEVICE) || methodName.equals(Constants.CREATE_DEVICE)) - || methodName.equals(Constants.DEVICE_SET_STATES) - || methodName.equals(Constants.MODIFY_CLOUD_TO_DEVICE_CONFIG) - || methodName.equals(Constants.BIND_DEVICE_TO_GATEWAY) - || methodName.equals(Constants.UNBIND_DEVICE_FROM_GATEWAY) - || methodName.equals(Constants.GET_REGISTRY_CREDENTIALS)) { - - methodType = Constants.HTTP_REQUEST_METHOD_TYPE_POST; - - } else if (methodName.equals(Constants.DELETE_DEVICE)) { - - methodType = Constants.HTTP_REQUEST_METHOD_TYPE_DELETE; - - } else if ((methodName.equals(Constants.GET_DEVICE)) || methodName.equals(Constants.DEVICES_LIST) - || methodName.equals(Constants.DEVICE_STATES_LIST) - || methodName.equals(Constants.DEVICE_GET_CONFIG) - || methodName.equals(Constants.DEVICE_CONFIG_VERSIONS_LIST)) { - - methodType = Constants.HTTP_REQUEST_METHOD_TYPE_GET; - - } else if (methodName.equals(Constants.DEVICE_PATCH)) { - - methodType = Constants.HTTP_REQUEST_METHOD_TYPE_POST; - - } - - return methodType; - - } - - public JSONObject getBodyJSONObj() { - return bodyJSONObj; - } - - public void setBodyJSONObj(JSONObject bodyJSONObj) { - this.bodyJSONObj = bodyJSONObj; - } - - public JSONObject getRequestJSONObj() { - return requestJSONObj; - } - - public void setRequestJSONObj(JSONObject requestJSONObj) { - this.requestJSONObj = requestJSONObj; - } - - public SystemAccess getSystemAccess() { - return systemAccess; - } - - public void setSystemAccess(SystemAccess systemAccess) { - this.systemAccess = systemAccess; - } - - public AuthParams getAuthParams() { - return authParams; - } - - public void setAuthParams(AuthParams authParams) { - this.authParams = authParams; - } -} \ No newline at end of file diff --git a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/SyncClient.java b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/SyncClient.java index c817ad20..5155bf3d 100644 --- a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/SyncClient.java +++ b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/SyncClient.java @@ -33,44 +33,72 @@ private String generateURL(String apiName, String params) { .concat("?"+params); } + /** + * Method used to generate URL for apicall + * + * @param apiName - path to api + * @param params - parameters to be attached to request + * @return URL formed and to be used + */ + private String generateAdminURL(String apiName, String params) { + + return AuthParams.getBaseURL() + .concat(configParameters.getBaseURL()) + .concat(AuthParams.getAdminSystemKey()) + .concat(apiName) + .concat("?" + params); + } + /** * Method used to Calls HTTP Get request * @param apiName * @param params * @return String[] containing responseCode, responseMessage and response object */ - public String[] get(String apiName,String params) { + public String[] get(String apiName,String params,boolean isAdmin) { String[] responseArray = new String[3]; - AuthParams.setRegistryCredentials(); - try { - String finalURL = generateURL(apiName, params); - System.out.println(finalURL); - URL obj = new URL(finalURL); - SetHttpConnection setCon = new SetHttpConnection(); - HttpsURLConnection con = setCon.getConnection(obj); - con.setRequestProperty(Constants.HTTP_REQUEST_PROPERTY_TOKEN_KEY, AuthParams.getUserToken()); - con.setRequestProperty(Constants.HTTP_REQUEST_PROPERTY_CONTENT_TYPE_KEY, Constants.HTTP_REQUEST_PROPERTY_CONTENT_TYPE_ACCEPT_VALUE); - con.addRequestProperty(Constants.HTTP_REQUEST_PROPERTY_ACCEPT_KEY, Constants.HTTP_REQUEST_PROPERTY_CONTENT_TYPE_ACCEPT_VALUE); - con.setRequestMethod(Constants.HTTP_REQUEST_METHOD_TYPE_GET); - StringBuilder response = new StringBuilder(); - responseArray[0] = String.valueOf(con.getResponseCode()); - responseArray[1] = con.getResponseMessage(); - BufferedReader in = null; - if (con.getErrorStream() != null) { - in = new BufferedReader(new InputStreamReader(con.getErrorStream())); - } else if (con.getInputStream() != null) { - in = new BufferedReader(new InputStreamReader(con.getInputStream())); + String finalURL = ""; + if (isAdmin) { + AuthParams.setAdminCredentials(); + finalURL = generateAdminURL(apiName, params); + } else { + AuthParams.setRegistryCredentials(); + finalURL = generateURL(apiName, params); } - String inputLine; - String responseMessage = ""; - if (in != null) { - while ((inputLine = in.readLine()) != null) { - response.append(inputLine); + try { + System.out.println(finalURL); + URL obj = new URL(finalURL); + SetHttpConnection setCon = new SetHttpConnection(); + HttpsURLConnection con = setCon.getConnection(obj); + if(isAdmin) + con.setRequestProperty(Constants.HTTP_REQUEST_PROPERTY_TOKEN_KEY, AuthParams.getAdminToken()); + else + con.setRequestProperty(Constants.HTTP_REQUEST_PROPERTY_TOKEN_KEY, AuthParams.getUserToken()); + + con.setRequestProperty(Constants.HTTP_REQUEST_PROPERTY_CONTENT_TYPE_KEY, + Constants.HTTP_REQUEST_PROPERTY_CONTENT_TYPE_ACCEPT_VALUE); + con.addRequestProperty(Constants.HTTP_REQUEST_PROPERTY_ACCEPT_KEY, + Constants.HTTP_REQUEST_PROPERTY_CONTENT_TYPE_ACCEPT_VALUE); + con.setRequestMethod(Constants.HTTP_REQUEST_METHOD_TYPE_GET); + StringBuilder response = new StringBuilder(); + responseArray[0] = String.valueOf(con.getResponseCode()); + responseArray[1] = con.getResponseMessage(); + BufferedReader in = null; + if (con.getErrorStream() != null) { + in = new BufferedReader(new InputStreamReader(con.getErrorStream())); + } else if (con.getInputStream() != null) { + in = new BufferedReader(new InputStreamReader(con.getInputStream())); } - responseMessage = response.toString(); - responseArray[2] = responseMessage; - } - }catch(Exception e) { + String inputLine; + String responseMessage = ""; + if (in != null) { + while ((inputLine = in.readLine()) != null) { + response.append(inputLine); + } + responseMessage = response.toString(); + responseArray[2] = responseMessage; + } + } catch (Exception e) { e.printStackTrace(); } @@ -84,44 +112,59 @@ public String[] get(String apiName,String params) { * @param body * @return String[] containing responseCode, responseMessage and response object */ - public String[] post(String apiName,String params,String body) { + public String[] post(String apiName, String params, String body, boolean isAdmin) { String[] responseArray = new String[3]; - AuthParams.setRegistryCredentials(); - - try { - String finalURL = generateURL(apiName, params); - System.out.println(finalURL); - URL obj = new URL(finalURL); - SetHttpConnection setCon = new SetHttpConnection(); - HttpsURLConnection con = setCon.getConnection(obj); - con.setRequestProperty(Constants.HTTP_REQUEST_PROPERTY_TOKEN_KEY, AuthParams.getUserToken()); - con.setRequestProperty(Constants.HTTP_REQUEST_PROPERTY_CONTENT_TYPE_KEY, Constants.HTTP_REQUEST_PROPERTY_CONTENT_TYPE_ACCEPT_VALUE); - con.addRequestProperty(Constants.HTTP_REQUEST_PROPERTY_ACCEPT_KEY, Constants.HTTP_REQUEST_PROPERTY_CONTENT_TYPE_ACCEPT_VALUE); - con.setRequestMethod(Constants.HTTP_REQUEST_METHOD_TYPE_POST); - con.setDoOutput(true); - StringBuilder response = new StringBuilder(); - OutputStream os = con.getOutputStream(); - byte[] input = body.getBytes(Constants.UTF8); - os.write(input, 0, input.length); - os.flush(); - responseArray[0] = String.valueOf(con.getResponseCode()); - responseArray[1] = con.getResponseMessage(); - BufferedReader in = null; - if (con.getErrorStream() != null) { - in = new BufferedReader(new InputStreamReader(con.getErrorStream())); - } else if (con.getInputStream() != null) { - in = new BufferedReader(new InputStreamReader(con.getInputStream())); + String finalURL = ""; + if (isAdmin) { + AuthParams.setAdminCredentials(); + finalURL = generateAdminURL(apiName, params); + } else { + AuthParams.setRegistryCredentials(); + finalURL = generateURL(apiName, params); } - String inputLine; - String responseMessage = ""; - if (in != null) { - while ((inputLine = in.readLine()) != null) { - response.append(inputLine); + try { + + System.out.println(finalURL); + + URL obj = new URL(finalURL); + SetHttpConnection setCon = new SetHttpConnection(); + HttpsURLConnection con = setCon.getConnection(obj); + if (isAdmin) + con.setRequestProperty(Constants.HTTP_REQUEST_PROPERTY_TOKEN_KEY, + AuthParams.getAdminToken()); + else + con.setRequestProperty(Constants.HTTP_REQUEST_PROPERTY_TOKEN_KEY, + AuthParams.getUserToken()); + con.setRequestProperty(Constants.HTTP_REQUEST_PROPERTY_CONTENT_TYPE_KEY, + Constants.HTTP_REQUEST_PROPERTY_CONTENT_TYPE_ACCEPT_VALUE); + con.addRequestProperty(Constants.HTTP_REQUEST_PROPERTY_ACCEPT_KEY, + Constants.HTTP_REQUEST_PROPERTY_CONTENT_TYPE_ACCEPT_VALUE); + con.setRequestMethod(Constants.HTTP_REQUEST_METHOD_TYPE_POST); + con.setDoOutput(true); + StringBuilder response = new StringBuilder(); + OutputStream os = con.getOutputStream(); + byte[] input = body.getBytes(Constants.UTF8); + os.write(input, 0, input.length); + os.flush(); + responseArray[0] = String.valueOf(con.getResponseCode()); + responseArray[1] = con.getResponseMessage(); + BufferedReader in = null; + if (con.getErrorStream() != null) { + in = new BufferedReader(new InputStreamReader(con.getErrorStream())); + } else if (con.getInputStream() != null) { + in = new BufferedReader(new InputStreamReader(con.getInputStream())); } - responseMessage = response.toString(); - responseArray[2] = responseMessage; - } - }catch(Exception e) { + String inputLine; + String responseMessage = ""; + if (in != null) { + while ((inputLine = in.readLine()) != null) { + response.append(inputLine); + } + responseMessage = response.toString(); + responseArray[2] = responseMessage; + } + + } catch (Exception e) { e.printStackTrace(); } @@ -134,38 +177,51 @@ public String[] post(String apiName,String params,String body) { * @param params * @return String[] containing responseCode, responseMessage and response object */ - public String[] delete(String apiName,String params) { + public String[] delete(String apiName,String params,boolean isAdmin) { String[] responseArray = new String[3]; - AuthParams.setRegistryCredentials(); - try { - String finalURL = generateURL(apiName, params); - System.out.println(finalURL); - URL obj = new URL(finalURL); - SetHttpConnection setCon = new SetHttpConnection(); - HttpsURLConnection con = setCon.getConnection(obj); - con.setRequestProperty(Constants.HTTP_REQUEST_PROPERTY_TOKEN_KEY, AuthParams.getUserToken()); - con.setRequestProperty(Constants.HTTP_REQUEST_PROPERTY_CONTENT_TYPE_KEY, Constants.HTTP_REQUEST_PROPERTY_CONTENT_TYPE_ACCEPT_VALUE); - con.addRequestProperty(Constants.HTTP_REQUEST_PROPERTY_ACCEPT_KEY, Constants.HTTP_REQUEST_PROPERTY_CONTENT_TYPE_ACCEPT_VALUE); - con.setRequestMethod(Constants.HTTP_REQUEST_METHOD_TYPE_DELETE); - StringBuilder response = new StringBuilder(); - responseArray[0] = String.valueOf(con.getResponseCode()); - responseArray[1] = con.getResponseMessage(); - BufferedReader in = null; - if (con.getErrorStream() != null) { - in = new BufferedReader(new InputStreamReader(con.getErrorStream())); - } else if (con.getInputStream() != null) { - in = new BufferedReader(new InputStreamReader(con.getInputStream())); + String finalURL = ""; + if (isAdmin) { + AuthParams.setAdminCredentials(); + finalURL = generateAdminURL(apiName, params); + } else { + AuthParams.setRegistryCredentials(); + finalURL = generateURL(apiName, params); } - String inputLine; - String responseMessage = ""; - if (in != null) { - while ((inputLine = in.readLine()) != null) { - response.append(inputLine); + try { + System.out.println(finalURL); + URL obj = new URL(finalURL); + SetHttpConnection setCon = new SetHttpConnection(); + HttpsURLConnection con = setCon.getConnection(obj); + if (isAdmin) + con.setRequestProperty(Constants.HTTP_REQUEST_PROPERTY_TOKEN_KEY, + AuthParams.getAdminToken()); + else + con.setRequestProperty(Constants.HTTP_REQUEST_PROPERTY_TOKEN_KEY, + AuthParams.getUserToken()); + con.setRequestProperty(Constants.HTTP_REQUEST_PROPERTY_CONTENT_TYPE_KEY, + Constants.HTTP_REQUEST_PROPERTY_CONTENT_TYPE_ACCEPT_VALUE); + con.addRequestProperty(Constants.HTTP_REQUEST_PROPERTY_ACCEPT_KEY, + Constants.HTTP_REQUEST_PROPERTY_CONTENT_TYPE_ACCEPT_VALUE); + con.setRequestMethod(Constants.HTTP_REQUEST_METHOD_TYPE_DELETE); + StringBuilder response = new StringBuilder(); + responseArray[0] = String.valueOf(con.getResponseCode()); + responseArray[1] = con.getResponseMessage(); + BufferedReader in = null; + if (con.getErrorStream() != null) { + in = new BufferedReader(new InputStreamReader(con.getErrorStream())); + } else if (con.getInputStream() != null) { + in = new BufferedReader(new InputStreamReader(con.getInputStream())); } - responseMessage = response.toString(); - responseArray[2] = responseMessage; - } - }catch(Exception e) { + String inputLine; + String responseMessage = ""; + if (in != null) { + while ((inputLine = in.readLine()) != null) { + response.append(inputLine); + } + responseMessage = response.toString(); + responseArray[2] = responseMessage; + } + } catch (Exception e) { e.printStackTrace(); } @@ -179,106 +235,49 @@ public String[] delete(String apiName,String params) { * @param body * @return String[] containing responseCode, responseMessage and response object */ - public String[] patch(String apiName,String params,String body) { + public String[] update(String apiName,String params,String body) { String[] responseArray = new String[3]; AuthParams.setRegistryCredentials(); - - try { String finalURL = generateURL(apiName, params); - System.out.println(finalURL); - URL obj = new URL(finalURL); - SetHttpConnection setCon = new SetHttpConnection(); - HttpsURLConnection con = setCon.getConnection(obj); - con.setRequestProperty(Constants.HTTP_REQUEST_PROPERTY_TOKEN_KEY, AuthParams.getUserToken()); - con.setRequestProperty(Constants.HTTP_REQUEST_PROPERTY_CONTENT_TYPE_KEY, Constants.HTTP_REQUEST_PROPERTY_CONTENT_TYPE_ACCEPT_VALUE); - con.addRequestProperty(Constants.HTTP_REQUEST_PROPERTY_ACCEPT_KEY, Constants.HTTP_REQUEST_PROPERTY_CONTENT_TYPE_ACCEPT_VALUE); - con.setRequestMethod(Constants.HTTP_REQUEST_METHOD_TYPE_POST); - con.setRequestProperty("X-HTTP-Method-Override", Constants.HTTP_REQUEST_METHOD_TYPE_PATCH); - con.setDoOutput(true); - StringBuilder response = new StringBuilder(); - OutputStream os = con.getOutputStream(); - byte[] input = body.getBytes(Constants.UTF8); - os.write(input, 0, input.length); - os.flush(); - responseArray[0] = String.valueOf(con.getResponseCode()); - responseArray[1] = con.getResponseMessage(); - BufferedReader in = null; - if (con.getErrorStream() != null) { - in = new BufferedReader(new InputStreamReader(con.getErrorStream())); - } else if (con.getInputStream() != null) { - in = new BufferedReader(new InputStreamReader(con.getInputStream())); - } - String inputLine; - String responseMessage = ""; - if (in != null) { - while ((inputLine = in.readLine()) != null) { - response.append(inputLine); - } - responseMessage = response.toString(); - responseArray[2] = responseMessage; - } - }catch(Exception e) { - e.printStackTrace(); - } - - return responseArray; - } - - /** - * Method used to generate URL for apicall - * @param apiName - path to api - * @param params - parameters to be attached to request - * @return URL formed and to be used - */ - private String generateAdminURL(String apiName, String params) { - - return AuthParams.getBaseURL() - .concat(configParameters.getBaseURL()) - .concat(AuthParams.getUserSystemKey()) - .concat(apiName) - .concat("?"+params); - } - /** - * Method used to Calls HTTP Get request - * @param apiName - * @param params - * @return String[] containing responseCode, responseMessage and response object - */ - public String[] getRegistry(String apiName,String params) { - String[] responseArray = new String[3]; - AuthParams.setRegistryCredentials(); try { - String finalURL = generateAdminURL(apiName, params); - System.out.println(finalURL); - URL obj = new URL(finalURL); - SetHttpConnection setCon = new SetHttpConnection(); - HttpsURLConnection con = setCon.getConnection(obj); - con.setRequestProperty(Constants.HTTP_REQUEST_PROPERTY_TOKEN_KEY, AuthParams.getUserToken()); - con.setRequestProperty(Constants.HTTP_REQUEST_PROPERTY_CONTENT_TYPE_KEY, Constants.HTTP_REQUEST_PROPERTY_CONTENT_TYPE_ACCEPT_VALUE); - con.addRequestProperty(Constants.HTTP_REQUEST_PROPERTY_ACCEPT_KEY, Constants.HTTP_REQUEST_PROPERTY_CONTENT_TYPE_ACCEPT_VALUE); - con.setRequestMethod(Constants.HTTP_REQUEST_METHOD_TYPE_GET); - StringBuilder response = new StringBuilder(); - responseArray[0] = String.valueOf(con.getResponseCode()); - responseArray[1] = con.getResponseMessage(); - BufferedReader in = null; - if (con.getErrorStream() != null) { - in = new BufferedReader(new InputStreamReader(con.getErrorStream())); - } else if (con.getInputStream() != null) { - in = new BufferedReader(new InputStreamReader(con.getInputStream())); - } - String inputLine; - String responseMessage = ""; - if (in != null) { - while ((inputLine = in.readLine()) != null) { - response.append(inputLine); + System.out.println(finalURL); + URL obj = new URL(finalURL); + SetHttpConnection setCon = new SetHttpConnection(); + HttpsURLConnection con = setCon.getConnection(obj); + con.setRequestProperty(Constants.HTTP_REQUEST_PROPERTY_TOKEN_KEY, AuthParams.getUserToken()); + con.setRequestProperty(Constants.HTTP_REQUEST_PROPERTY_CONTENT_TYPE_KEY, + Constants.HTTP_REQUEST_PROPERTY_CONTENT_TYPE_ACCEPT_VALUE); + con.addRequestProperty(Constants.HTTP_REQUEST_PROPERTY_ACCEPT_KEY, + Constants.HTTP_REQUEST_PROPERTY_CONTENT_TYPE_ACCEPT_VALUE); + con.setRequestMethod(Constants.HTTP_REQUEST_METHOD_TYPE_POST); + con.setRequestProperty("X-HTTP-Method-Override", Constants.HTTP_REQUEST_METHOD_TYPE_PATCH); + con.setDoOutput(true); + StringBuilder response = new StringBuilder(); + OutputStream os = con.getOutputStream(); + byte[] input = body.getBytes(Constants.UTF8); + os.write(input, 0, input.length); + os.flush(); + responseArray[0] = String.valueOf(con.getResponseCode()); + responseArray[1] = con.getResponseMessage(); + BufferedReader in = null; + if (con.getErrorStream() != null) { + in = new BufferedReader(new InputStreamReader(con.getErrorStream())); + } else if (con.getInputStream() != null) { + in = new BufferedReader(new InputStreamReader(con.getInputStream())); } - responseMessage = response.toString(); - responseArray[2] = responseMessage; - } - }catch(Exception e) { + String inputLine; + String responseMessage = ""; + if (in != null) { + while ((inputLine = in.readLine()) != null) { + response.append(inputLine); + } + responseMessage = response.toString(); + responseArray[2] = responseMessage; + } + } catch (Exception e) { e.printStackTrace(); } - + return responseArray; } } diff --git a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/auth/AdminAccess.java b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/auth/AdminAccess.java deleted file mode 100644 index 6e8a7b4e..00000000 --- a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/auth/AdminAccess.java +++ /dev/null @@ -1,71 +0,0 @@ -package com.clearblade.cloud.iot.v1.auth; - -import java.io.FileNotFoundException; -import java.io.FileReader; -import java.io.IOException; -import java.util.logging.Level; -import java.util.logging.Logger; - -import org.json.simple.JSONObject; -import org.json.simple.parser.JSONParser; -import org.json.simple.parser.ParseException; - -import com.clearblade.cloud.iot.v1.utils.AuthParams; -import com.clearblade.cloud.iot.v1.utils.Constants; - -public class AdminAccess { - - static Logger log = Logger.getLogger(AdminAccess.class.getName()); - - static AuthParams authParams; - - public AuthParams getSystemCredentials() { - - String pathToAuthFile = System.getenv(Constants.AUTH_ACCESS); - - JSONParser jsonParser = new JSONParser(); - try (FileReader authReader = new FileReader(pathToAuthFile)) { - // Read JSON file - Object obj = jsonParser.parse(authReader); - JSONObject authJSONObject = (JSONObject) obj; - if (authJSONObject != null) { - - authParams = new AuthParams(); - - String adminSystemKey = (authJSONObject.get(Constants.ADMIN_SYSTEM_KEY)).toString(); - authParams.setAdminSystemKey(adminSystemKey); - - String adminToken = (authJSONObject.get(Constants.ADMIN_TOKEN)).toString(); - authParams.setAdminToken(adminToken); - - String baseURL = (authJSONObject.get(Constants.BASE_URL)).toString(); - authParams.setBaseURL(baseURL); - - String projectName = (authJSONObject.get(Constants.PROJECT_NAME)).toString(); - authParams.setProject(projectName); - - this.setAuthParams(authParams); - } - - } catch (FileNotFoundException e) { - log.log(Level.SEVERE, "Configuration file missing."); - e.printStackTrace(); - } catch (IOException e) { - log.log(Level.SEVERE, "Error occurred while reading configuration from file."); - e.printStackTrace(); - } catch (ParseException e) { - log.log(Level.SEVERE, "Can not parse configuration objects from file."); - e.printStackTrace(); - } - return authParams; - } - - public AuthParams getAuthParams() { - return authParams; - } - - public void setAuthParams(AuthParams setAuthParams) { - authParams = setAuthParams; - } - -} diff --git a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/auth/SystemAccess.java b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/auth/SystemAccess.java deleted file mode 100644 index f1153c26..00000000 --- a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/auth/SystemAccess.java +++ /dev/null @@ -1,27 +0,0 @@ -package com.clearblade.cloud.iot.v1.auth; - -public class SystemAccess { - - private String userSystemKey; - private String userSystemToken; - private String apiBaseURL; - - public String getUserSystemKey() { - return userSystemKey; - } - public void setUserSystemKey(String userSystemKey) { - this.userSystemKey = userSystemKey; - } - public String getUserSystemToken() { - return userSystemToken; - } - public void setUserSystemToken(String userSystemToken) { - this.userSystemToken = userSystemToken; - } - public String getApiBaseURL() { - return apiBaseURL; - } - public void setApiBaseURL(String apiBaseURL) { - this.apiBaseURL = apiBaseURL; - } -} diff --git a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/binddevicetogateway/BindDeviceToGatewayResponse.java b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/binddevicetogateway/BindDeviceToGatewayResponse.java index 223fe4cf..f6d3bedd 100644 --- a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/binddevicetogateway/BindDeviceToGatewayResponse.java +++ b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/binddevicetogateway/BindDeviceToGatewayResponse.java @@ -1,13 +1,7 @@ package com.clearblade.cloud.iot.v1.binddevicetogateway; -import java.util.logging.Level; import java.util.logging.Logger; -import org.json.simple.JSONObject; - -import com.clearblade.cloud.iot.v1.ProcessRequest; -import com.clearblade.cloud.iot.v1.utils.Constants; - public class BindDeviceToGatewayResponse { static Logger log = Logger.getLogger(BindDeviceToGatewayResponse.class.getName()); @@ -61,34 +55,6 @@ public BindDeviceToGatewayResponse build() { } } - /** - * Mehtod used to process the request Calling processRequestForMethod - - * BindDeviceToGateway - */ - public void processRequest(BindDeviceToGatewayRequest request) { - String msg = ""; - JSONObject requestParams = new JSONObject(); - JSONObject bodyParams = new JSONObject(); - ProcessRequest processRequest = new ProcessRequest(); - if(request != null) { - String logMsg = "Bind Device To Gateway Request :: "+request.toString(); - log.log(Level.INFO,logMsg); - requestParams = (JSONObject) request.requestParams.clone(); - bodyParams = (JSONObject) request.bodyParams.clone(); - } - String responseMessage = processRequest.processRequestForMethod(Constants.BIND_DEVICE_TO_GATEWAY,requestParams,bodyParams); - this.setHttpStatusResponse(responseMessage); - if (responseMessage.equals("OK")) { - this.setHttpStatusCode(200); - msg = "Request processed for BIND_DEVICE_TO_GATEWAY method"; - log.log(Level.INFO, msg); - } else { - this.setHttpStatusCode(0); - msg = "Request for BIND_DEVICE_TO_GATEWAY failed \n" .concat(responseMessage); - log.log(Level.SEVERE, msg); - } - } - @Override public String toString() { return "Http Status Code :: " + this.getHttpStatusCode() + " Http Status Response :: " diff --git a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/createdevice/CreateDeviceResponse.java b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/createdevice/CreateDeviceResponse.java index 4d31aa37..1f08ddb2 100644 --- a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/createdevice/CreateDeviceResponse.java +++ b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/createdevice/CreateDeviceResponse.java @@ -1,12 +1,7 @@ package com.clearblade.cloud.iot.v1.createdevice; -import java.util.logging.Level; import java.util.logging.Logger; -import org.json.simple.JSONObject; - -import com.clearblade.cloud.iot.v1.ProcessRequest; - public class CreateDeviceResponse { static Logger log = Logger.getLogger(CreateDeviceResponse.class.getName()); diff --git a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/createdeviceregistry/CreateDeviceRegistryRequest.java b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/createdeviceregistry/CreateDeviceRegistryRequest.java new file mode 100644 index 00000000..6873411c --- /dev/null +++ b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/createdeviceregistry/CreateDeviceRegistryRequest.java @@ -0,0 +1,52 @@ +package com.clearblade.cloud.iot.v1.createdeviceregistry; + +import com.clearblade.cloud.iot.v1.utils.DeviceRegistry; + +public class CreateDeviceRegistryRequest { + private String parent; + private DeviceRegistry deviceRegistry; + + private CreateDeviceRegistryRequest(Builder builder) { + this.parent = builder.parent; + this.deviceRegistry = builder.deviceRegistry; + } + + // Static class Builder + public static class Builder { + + /// instance fields + private String parent; + private DeviceRegistry deviceRegistry; + + public static Builder newBuilder() { + return new Builder(); + } + + private Builder() { + } + + // Setter methods + public Builder setParent(String parent) { + this.parent = parent; + return this; + } + + public Builder setDeviceRegistry(DeviceRegistry deviceRegistry) { + this.deviceRegistry = deviceRegistry; + return this; + } + + // build method to deal with outer class + // to return outer instance + public CreateDeviceRegistryRequest build() { + return new CreateDeviceRegistryRequest(this); + } + } + + public String[] getBodyAndParams() { + String[] output = new String[2]; + output[0] = "parent=" + this.parent; + output[1] = this.deviceRegistry.createDeviceJSONObject(parent); + return output; + } +} diff --git a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/deletedevice/DeleteDeviceResponse.java b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/deletedevice/DeleteDeviceResponse.java index a4657a66..6528b6d2 100644 --- a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/deletedevice/DeleteDeviceResponse.java +++ b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/deletedevice/DeleteDeviceResponse.java @@ -1,12 +1,7 @@ package com.clearblade.cloud.iot.v1.deletedevice; -import java.util.logging.Level; import java.util.logging.Logger; -import org.json.simple.JSONObject; - -import com.clearblade.cloud.iot.v1.ProcessRequest; - public class DeleteDeviceResponse { static Logger log = Logger.getLogger(DeleteDeviceResponse.class.getName()); @@ -60,33 +55,6 @@ public DeleteDeviceResponse build() { } } - /** - * Mehtod used to process the request Calling processRequestForMethod - - * DeleteDevice - */ - @SuppressWarnings("unchecked") - public void processRequest(DeleteDeviceRequest request) { - String msg = ""; - - ProcessRequest processRequest = new ProcessRequest(); - JSONObject requestParams = new JSONObject(); - JSONObject bodyParams = new JSONObject(); - if(request != null) { - requestParams.put("name", request.toString()); - } - String responseMessage = processRequest.processRequestForMethod("deleteDevice", requestParams, bodyParams); - this.setHttpStatusResponse(responseMessage); - if (responseMessage.equals("OK")) { - this.setHttpStatusCode(200); - msg = "Request processed for DeleteDevice method"; - log.log(Level.INFO, msg); - } else { - this.setHttpStatusCode(0); - msg = "Request for DeleteDevice failed \n".concat(responseMessage); - log.log(Level.SEVERE, msg); - } - } - @Override public String toString() { return "Http Status Code :: " + this.getHttpStatusCode() + " Http Status Response :: " diff --git a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/deletedeviceregistry/DeleteDeviceRegistryRequest.java b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/deletedeviceregistry/DeleteDeviceRegistryRequest.java new file mode 100644 index 00000000..3aa63151 --- /dev/null +++ b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/deletedeviceregistry/DeleteDeviceRegistryRequest.java @@ -0,0 +1,41 @@ +package com.clearblade.cloud.iot.v1.deletedeviceregistry; + +public class DeleteDeviceRegistryRequest { + private String name; + + private DeleteDeviceRegistryRequest(Builder builder) { + this.name = builder.name; + } + + // Static class Builder + public static class Builder { + + /// instance fields + private String name; + + public static Builder newBuilder() { + return new Builder(); + } + + private Builder() { + } + + // Setter methods + public Builder setName(String name) { + this.name = name; + return this; + } + + // build method to deal with outer class + // to return outer instance + public DeleteDeviceRegistryRequest build() { + return new DeleteDeviceRegistryRequest(this); + } + } + + public String getParams() { + return "name=" + this.name; + } + + +} diff --git a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/deviceslist/DevicesListResponse.java b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/deviceslist/DevicesListResponse.java index 8c9c326c..43fd5336 100644 --- a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/deviceslist/DevicesListResponse.java +++ b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/deviceslist/DevicesListResponse.java @@ -3,14 +3,12 @@ import java.util.ArrayList; import java.util.Iterator; import java.util.List; -import java.util.logging.Level; import java.util.logging.Logger; import org.json.simple.JSONArray; import org.json.simple.JSONObject; import org.json.simple.parser.JSONParser; -import com.clearblade.cloud.iot.v1.ProcessRequest; import com.clearblade.cloud.iot.v1.utils.Device; public class DevicesListResponse { diff --git a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/getdevice/GetDeviceResponse.java b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/getdevice/GetDeviceResponse.java index 22f539d6..40947d98 100644 --- a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/getdevice/GetDeviceResponse.java +++ b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/getdevice/GetDeviceResponse.java @@ -1,11 +1,7 @@ package com.clearblade.cloud.iot.v1.getdevice; -import java.util.logging.Level; import java.util.logging.Logger; -import org.json.simple.JSONObject; - -import com.clearblade.cloud.iot.v1.ProcessRequest; import com.clearblade.cloud.iot.v1.utils.Device; public class GetDeviceResponse { @@ -63,34 +59,6 @@ public GetDeviceResponse build() { } } - /** - * Mehtod used to process the request Calling processRequestForMethod - - * GetDevice - */ - @SuppressWarnings("unchecked") - public void processRequest(GetDeviceRequest request) { - String msg = ""; - ProcessRequest processRequest = new ProcessRequest(); - JSONObject requestParams = new JSONObject(); - JSONObject bodyParams = new JSONObject(); - if(request != null) { - requestParams.put("name", request.toString()); - requestParams.put("fieldMask", "EMPTY"); - } - String responseMessage = processRequest.processRequestForMethod("getDevice", requestParams, bodyParams); - this.setHttpStatusResponse(responseMessage); - if (responseMessage.equals("OK")) { - this.setHttpStatusCode(200); - msg = "Request processed for GetDevice method"; - - log.log(Level.INFO, msg); - } else { - this.setHttpStatusCode(0); - msg = "Request for GetDevice failed \n" .concat(responseMessage); - log.log(Level.SEVERE, msg); - } - } - @Override public String toString() { return "Http Status Code :: " + this.getHttpStatusCode() + " Http Status Response :: " diff --git a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/getdeviceregistry/GetDeviceRegistryResponse.java b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/getdeviceregistry/GetDeviceRegistryResponse.java index ba15cd30..8d82f0d3 100644 --- a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/getdeviceregistry/GetDeviceRegistryResponse.java +++ b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/getdeviceregistry/GetDeviceRegistryResponse.java @@ -1,12 +1,7 @@ package com.clearblade.cloud.iot.v1.getdeviceregistry; -import java.util.logging.Level; import java.util.logging.Logger; -import org.json.simple.JSONObject; - -import com.clearblade.cloud.iot.v1.ProcessRequest; -import com.clearblade.cloud.iot.v1.utils.Constants; import com.clearblade.cloud.iot.v1.utils.RegistryName; public class GetDeviceRegistryResponse { @@ -17,7 +12,7 @@ public class GetDeviceRegistryResponse { private int httpStatusCode; private String httpStatusResponse; private RegistryName registry; - +s protected GetDeviceRegistryResponse(Builder builder) { this.request = builder.request; } @@ -64,33 +59,6 @@ public GetDeviceRegistryResponse build() { } } - /** - * Mehtod used to process the request Calling processRequestForMethod - - * GetDeviceRegistry - */ - @SuppressWarnings("unchecked") - public void processRequest(GetDeviceRegistryRequest request) { - String msg = ""; - ProcessRequest processRequest = new ProcessRequest(); - JSONObject requestParams = new JSONObject(); - JSONObject bodyParams = new JSONObject(); - if(request != null) { - requestParams.put("name", request.toString()); - } - String responseMessage = processRequest.processRequestForMethod(Constants.GET_DEVICE_REGISTRY, requestParams, bodyParams); - this.setHttpStatusResponse(responseMessage); - if (responseMessage.equals("OK")) { - this.setHttpStatusCode(200); - msg = "Request processed for GET_DEVICE_REGISTRY method"; - - log.log(Level.INFO, msg); - } else { - this.setHttpStatusCode(0); - msg = "Request for GET_DEVICE_REGISTRY failed \n" .concat(responseMessage); - log.log(Level.SEVERE, msg); - } - } - @Override public String toString() { return "Http Status Code :: " + this.getHttpStatusCode() + " Http Status Response :: " diff --git a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/getregistrycredentials/GetRegistryCredentialsRequest.java b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/getregistrycredentials/GetRegistryCredentialsRequest.java deleted file mode 100644 index d5ee7858..00000000 --- a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/getregistrycredentials/GetRegistryCredentialsRequest.java +++ /dev/null @@ -1,61 +0,0 @@ -package com.clearblade.cloud.iot.v1.getregistrycredentials; - -import org.json.simple.JSONObject; - -import com.clearblade.cloud.iot.v1.auth.AdminAccess; -import com.clearblade.cloud.iot.v1.utils.AuthParams; -import com.clearblade.cloud.iot.v1.utils.ConfigParameters; -import com.clearblade.cloud.iot.v1.utils.Constants; - -public class GetRegistryCredentialsRequest { - - JSONObject bodyParams; - - private GetRegistryCredentialsRequest(Builder builder) { - } - - // Static class Builder - public static class Builder { - - public static Builder newBuilder() { - return new Builder(); - } - - private Builder() { - } - - // build method to deal with outer class - // to return outer instance - public GetRegistryCredentialsRequest build() { - return new GetRegistryCredentialsRequest(this); - } - } - - @SuppressWarnings("unchecked") - @Override - public String toString() { - - ConfigParameters configParams = new ConfigParameters(); - AdminAccess adminAccess = new AdminAccess(); - AuthParams authParams = adminAccess.getAuthParams(); - String regionName = configParams.getRegion(); - String projectName = authParams.getProject(); - String registryName = configParams.getRegistry(); - bodyParams = new JSONObject(); - bodyParams.put(Constants.REGION,regionName); - bodyParams.put(Constants.REGISTRY,registryName); - bodyParams.put("project", projectName); - this.setBodyParams(bodyParams); - return "region="+regionName+"registry="+registryName+"project="+projectName; - } - - public JSONObject getBodyParams() { - return bodyParams; - } - - public void setBodyParams(JSONObject bodyParams) { - this.bodyParams = bodyParams; - } - - -} diff --git a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/getregistrycredentials/GetRegistryCredentialsResponse.java b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/getregistrycredentials/GetRegistryCredentialsResponse.java deleted file mode 100644 index 37077a5c..00000000 --- a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/getregistrycredentials/GetRegistryCredentialsResponse.java +++ /dev/null @@ -1,69 +0,0 @@ -package com.clearblade.cloud.iot.v1.getregistrycredentials; - -import java.util.logging.Logger; - -public class GetRegistryCredentialsResponse { - - static Logger log = Logger.getLogger(GetRegistryCredentialsResponse.class.getName()); - - private final GetRegistryCredentialsRequest request; - private int httpStatusCode; - private String httpStatusResponse; - - protected GetRegistryCredentialsResponse(Builder builder) { - this.request = builder.request; - } - - public int getHttpStatusCode() { - return httpStatusCode; - } - - public void setHttpStatusCode(int httpStatusCode) { - this.httpStatusCode = httpStatusCode; - } - - public String getHttpStatusResponse() { - return httpStatusResponse; - } - - public void setHttpStatusResponse(String httpStatusResponse) { - this.httpStatusResponse = httpStatusResponse; - } - - // Static class Builder - public static class Builder { - - /// instance fields - private GetRegistryCredentialsRequest request; - - public static Builder newBuilder() { - return new Builder(); - } - - private Builder() { - } - - // Setter methods - public Builder setGetRegistryCredentialsRequest(GetRegistryCredentialsRequest request) { - this.request = request; - return this; - } - - // build method to deal with outer class - // to return outer instance - public GetRegistryCredentialsResponse build() { - return new GetRegistryCredentialsResponse(this); - } - } - - @Override - public String toString() { - return "Http Status Code :: " + this.getHttpStatusCode() + " Http Status Response :: " - + this.getHttpStatusResponse(); - } - - public GetRegistryCredentialsRequest getRequest() { - return request; - } - -} diff --git a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/listdeviceregistries/ListDeviceRegistriesRequest.java b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/listdeviceregistries/ListDeviceRegistriesRequest.java new file mode 100644 index 00000000..7ac1d092 --- /dev/null +++ b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/listdeviceregistries/ListDeviceRegistriesRequest.java @@ -0,0 +1,71 @@ +package com.clearblade.cloud.iot.v1.listdeviceregistries; + +public class ListDeviceRegistriesRequest { + + private String parent; + private int pageSize = -1; + private String pageToken; + + private ListDeviceRegistriesRequest(Builder builder) { + + this.parent = builder.parent; + this.pageSize = builder.pageSize; + this.pageToken = builder.pageToken; + } + + // Static class Builder + public static class Builder { + + /// instance fields + private String parent; + private int pageSize; + private String pageToken; + + public static Builder newBuilder() { + return new Builder(); + } + + private Builder() { + } + + // Setter methods + public Builder setParent(String parent) { + this.parent = parent; + return this; + } + + public Builder setPageSize(int pageSize) { + this.pageSize = pageSize; + return this; + } + + public Builder setPageToken(String pageToken) { + this.pageToken = pageToken; + return this; + } + + // build method to deal with outer class + // to return outer instance + public ListDeviceRegistriesRequest build() { + return new ListDeviceRegistriesRequest(this); + } + + } + + @Override + public String toString() { + return this.parent.toString(); + } + + public String getParamsForList() { + String params = ""; + params = "parent=" + this.parent; + if (this.pageSize > 0) + params += "&pageSize=" + String.valueOf(this.pageSize); + if (this.pageToken != null) + params += "&pageToken=" + this.pageToken; + return params; + } + + +} diff --git a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/listdeviceregistries/ListDeviceRegistriesResponse.java b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/listdeviceregistries/ListDeviceRegistriesResponse.java new file mode 100644 index 00000000..758ba8c9 --- /dev/null +++ b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/listdeviceregistries/ListDeviceRegistriesResponse.java @@ -0,0 +1,88 @@ +package com.clearblade.cloud.iot.v1.listdeviceregistries; + +import java.util.ArrayList; +import java.util.Iterator; +import java.util.List; +import java.util.logging.Logger; + +import org.json.simple.JSONArray; +import org.json.simple.JSONObject; +import org.json.simple.parser.JSONParser; + +import com.clearblade.cloud.iot.v1.utils.DeviceRegistry; + +public class ListDeviceRegistriesResponse { + static Logger log = Logger.getLogger(ListDeviceRegistriesResponse.class.getName()); + + private String nextPageToken; + private List deviceRegistriesList; + + protected ListDeviceRegistriesResponse(Builder builder) { + this.deviceRegistriesList = builder.deviceRegistriesList; + this.nextPageToken = builder.nextPageToken; + } + + public String getNextPageToken() { + return nextPageToken; + } + + public void setNextPageToken(String nextPageToken) { + this.nextPageToken = nextPageToken; + } + + public List getDeviceRegistriesList() { + return deviceRegistriesList; + } + + public void setDeviceRegistriesList(List deviceRegistriesList) { + this.deviceRegistriesList = deviceRegistriesList; + } + + // Static class Builder + public static class Builder { + + /// instance fields + private String nextPageToken; + private List deviceRegistriesList = new ArrayList<>(); + + public static Builder newBuilder() { + return new Builder(); + } + + private Builder() { + } + + // Setter methods + public Builder buildResponse(String jsonString) { + try { + JSONObject jsonObj = new JSONObject(); + JSONParser jsonParser = new JSONParser(); + jsonObj = (JSONObject) (jsonParser.parse(jsonString)); + + JSONArray deviceRegistriesArray = (JSONArray) jsonObj.get("deviceRegistries"); + @SuppressWarnings("rawtypes") + Iterator deviceRegistryIterate = deviceRegistriesArray.iterator(); + while (deviceRegistryIterate.hasNext()) { + JSONObject deviceRegistryJson = (JSONObject) deviceRegistryIterate.next(); + DeviceRegistry deviceRegistryObj = DeviceRegistry.newBuilder().build(); + deviceRegistryObj.loadFromString(deviceRegistryJson.toString()); + deviceRegistriesList.add(deviceRegistryObj); + } + + if (jsonObj.containsKey("nextPageToken")) + nextPageToken = jsonObj.get("nextPageToken").toString(); + + } catch (Exception e) { + e.printStackTrace(); + } + return this; + } + + // build method to deal with outer class + // to return outer instance + public ListDeviceRegistriesResponse build() { + return new ListDeviceRegistriesResponse(this); + } + } + +} diff --git a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/modifycloudtodeviceconfig/ModifyCloudToDeviceConfigResponse.java b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/modifycloudtodeviceconfig/ModifyCloudToDeviceConfigResponse.java index 9bdd2149..83cb7253 100644 --- a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/modifycloudtodeviceconfig/ModifyCloudToDeviceConfigResponse.java +++ b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/modifycloudtodeviceconfig/ModifyCloudToDeviceConfigResponse.java @@ -1,13 +1,7 @@ package com.clearblade.cloud.iot.v1.modifycloudtodeviceconfig; -import java.util.logging.Level; import java.util.logging.Logger; -import org.json.simple.JSONObject; - -import com.clearblade.cloud.iot.v1.ProcessRequest; -import com.clearblade.cloud.iot.v1.utils.Constants; - public class ModifyCloudToDeviceConfigResponse { static Logger log = Logger.getLogger(ModifyCloudToDeviceConfigResponse.class.getName()); diff --git a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/sendcommandtodevice/SendCommandToDeviceResponse.java b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/sendcommandtodevice/SendCommandToDeviceResponse.java index c9452d29..4e67f56e 100644 --- a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/sendcommandtodevice/SendCommandToDeviceResponse.java +++ b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/sendcommandtodevice/SendCommandToDeviceResponse.java @@ -1,11 +1,7 @@ package com.clearblade.cloud.iot.v1.sendcommandtodevice; -import java.util.logging.Level; import java.util.logging.Logger; -import org.json.simple.JSONObject; - -import com.clearblade.cloud.iot.v1.ProcessRequest; public class SendCommandToDeviceResponse { @@ -60,66 +56,6 @@ public SendCommandToDeviceResponse build() { } } - /** - * Mehtod used to process the request - * Calling processRequestForMethod - sendCommandToDevice - */ - - public void processRequest(SendCommandToDeviceRequest request) { - String msg = ""; - JSONObject requestParams = new JSONObject(); - JSONObject bodyParams = new JSONObject(); - ProcessRequest processRequest = new ProcessRequest(); - - if(request != null) { - String logMsg = "Sending request to device :: "+request.toString(); - log.log(Level.INFO,logMsg); - requestParams = (JSONObject) request.requestParams.clone(); - bodyParams = (JSONObject) request.bodyParams.clone(); - } - - String responseMessage = processRequest.processRequestForMethod("sendCommandToDevice",requestParams,bodyParams); - this.setHttpStatusResponse(responseMessage); - if (responseMessage.equals("OK")) { - msg = "Request processed successfully for SendCommandToDevice method"; - log.log(Level.INFO, msg); - } else { - msg = "POST request not worked for sendCommandToDevice Method \n".concat(responseMessage); - log.log(Level.SEVERE, msg); - } - - } - - /** - * Mehtod used to process the request - * Calling processRequestForMethod - sendCommandToDevice - */ - - public String processRequestAsync(SendCommandToDeviceRequest request) { - String msg = ""; - ProcessRequest processRequest = new ProcessRequest(); - if(request != null) { - String logMsg = "Sending request to device :: "+request.toString(); - log.log(Level.INFO,logMsg); - } - String responseMessage =""; - try { - responseMessage = processRequest.asyncCallSendCommandToDevice(request); - this.setHttpStatusResponse(responseMessage); - if (responseMessage.equals("OK")) { - msg = "Request processed successfully for SendCommandToDevice method"; - log.log(Level.INFO, msg); - } else { - msg = "POST request not worked for sendCommandToDevice Method \n".concat(responseMessage); - log.log(Level.SEVERE, msg); - } - } catch (Exception e) { - e.printStackTrace(); - } - return responseMessage; - - } - @Override public String toString() { return "Http Status Code :: " + this.getHttpStatusCode() + " Http Status Response :: " diff --git a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/unbinddevicefromgateway/UnbindDeviceFromGatewayResponse.java b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/unbinddevicefromgateway/UnbindDeviceFromGatewayResponse.java index afbf4704..6e558aa9 100644 --- a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/unbinddevicefromgateway/UnbindDeviceFromGatewayResponse.java +++ b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/unbinddevicefromgateway/UnbindDeviceFromGatewayResponse.java @@ -1,13 +1,7 @@ package com.clearblade.cloud.iot.v1.unbinddevicefromgateway; -import java.util.logging.Level; import java.util.logging.Logger; -import org.json.simple.JSONObject; - -import com.clearblade.cloud.iot.v1.ProcessRequest; -import com.clearblade.cloud.iot.v1.utils.Constants; - public class UnbindDeviceFromGatewayResponse { static Logger log = Logger.getLogger(UnbindDeviceFromGatewayResponse.class.getName()); @@ -61,34 +55,6 @@ public UnbindDeviceFromGatewayResponse build() { } } - /** - * Mehtod used to process the request Calling processRequestForMethod - - * UnbindDeviceFromGatewayRequest - */ - public void processRequest(UnbindDeviceFromGatewayRequest request) { - String msg = ""; - JSONObject requestParams = new JSONObject(); - JSONObject bodyParams = new JSONObject(); - ProcessRequest processRequest = new ProcessRequest(); - if(request != null) { - String logMsg = "Unbind Device To Gateway Request :: "+request.toString(); - log.log(Level.INFO,logMsg); - requestParams = (JSONObject) request.requestParams.clone(); - bodyParams = (JSONObject) request.bodyParams.clone(); - } - String responseMessage = processRequest.processRequestForMethod(Constants.UNBIND_DEVICE_FROM_GATEWAY,requestParams,bodyParams); - this.setHttpStatusResponse(responseMessage); - if (responseMessage.equals("OK")) { - this.setHttpStatusCode(200); - msg = "Request processed for UNBIND_DEVICE_TO_GATEWAY method"; - log.log(Level.INFO, msg); - } else { - this.setHttpStatusCode(0); - msg = "Request for UNBIND_DEVICE_TO_GATEWAY failed \n" .concat(responseMessage); - log.log(Level.SEVERE, msg); - } - } - @Override public String toString() { return "Http Status Code :: " + this.getHttpStatusCode() + " Http Status Response :: " diff --git a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/updatedevice/UpdateDeviceResponse.java b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/updatedevice/UpdateDeviceResponse.java deleted file mode 100644 index 8ca7ca74..00000000 --- a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/updatedevice/UpdateDeviceResponse.java +++ /dev/null @@ -1,102 +0,0 @@ -package com.clearblade.cloud.iot.v1.updatedevice; - -import java.util.logging.Level; -import java.util.logging.Logger; - -import org.json.simple.JSONObject; - -import com.clearblade.cloud.iot.v1.ProcessRequest; -import com.clearblade.cloud.iot.v1.utils.Constants; - -public class UpdateDeviceResponse { - - static Logger log = Logger.getLogger(UpdateDeviceResponse.class.getName()); - private final UpdateDeviceRequest request; - private int httpStatusCode; - private String httpStatusResponse; - - protected UpdateDeviceResponse(Builder builder) { - this.request = builder.request; - } - - public int getHttpStatusCode() { - return httpStatusCode; - } - - public void setHttpStatusCode(int httpStatusCode) { - this.httpStatusCode = httpStatusCode; - } - - public String getHttpStatusResponse() { - return httpStatusResponse; - } - - public void setHttpStatusResponse(String httpStatusResponse) { - this.httpStatusResponse = httpStatusResponse; - } - - // Static class Builder - public static class Builder { - - /// instance fields - private UpdateDeviceRequest request; - - public static Builder newBuilder() { - return new Builder(); - } - - private Builder() { - } - - // Setter methods - public Builder setUpdateDeviceRequest(UpdateDeviceRequest request) { - this.request = request; - return this; - } - - // build method to deal with outer class - // to return outer instance - public UpdateDeviceResponse build() { - return new UpdateDeviceResponse(this); - } - } - - /** - * Mehtod used to process the request Calling processRequestForMethod - - * DevicePatch - */ - public void processRequest(UpdateDeviceRequest request) { - String msg = ""; - JSONObject requestParams = new JSONObject(); - JSONObject bodyParams = new JSONObject(); - ProcessRequest processRequest = new ProcessRequest(); - if(request != null) { - String logMsg = "Device Patch Request :: "+request.toString(); - log.log(Level.INFO,logMsg); - requestParams = (JSONObject) request.requestParams.clone(); - bodyParams = (JSONObject) request.bodyParams.clone(); - } - String responseMessage = processRequest.processRequestForMethod(Constants.UPDATE_DEVICE,requestParams,bodyParams); - this.setHttpStatusResponse(responseMessage); - if (responseMessage.equals("OK")) { - this.setHttpStatusCode(200); - msg = "Request processed for Device patch method"; - log.log(Level.INFO, msg); - } else { - this.setHttpStatusCode(0); - msg = "Request for Device patch failed \n" .concat(responseMessage); - log.log(Level.SEVERE, msg); - } - } - - @Override - public String toString() { - return "Http Status Code :: " + this.getHttpStatusCode() + " Http Status Response :: " - + this.getHttpStatusResponse(); - } - - public UpdateDeviceRequest getRequest() { - return request; - } - -} diff --git a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/updatedeviceregistry/UpdateDeviceRegistryRequest.java b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/updatedeviceregistry/UpdateDeviceRegistryRequest.java new file mode 100644 index 00000000..0b7fb89e --- /dev/null +++ b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/updatedeviceregistry/UpdateDeviceRegistryRequest.java @@ -0,0 +1,98 @@ +package com.clearblade.cloud.iot.v1.updatedeviceregistry; + +import org.json.simple.JSONObject; + +import com.clearblade.cloud.iot.v1.utils.DeviceRegistry; + +public class UpdateDeviceRegistryRequest { + + private String name; + private String updateMask; + private DeviceRegistry deviceRegistry; + JSONObject requestParams; + JSONObject bodyParams; + + private UpdateDeviceRegistryRequest(Builder builder) { + this.name = builder.name; + this.updateMask = builder.updateMask; + this.deviceRegistry = builder.deviceRegistry; + } + public JSONObject getRequestParams() { + return requestParams; + } + + public void setRequestParams(JSONObject requestParams) { + this.requestParams = requestParams; + } + + public JSONObject getBodyParams() { + return bodyParams; + } + + public void setBodyParams(JSONObject bodyParams) { + this.bodyParams = bodyParams; + } + + // Static class Builder + public static class Builder { + + /// instance fields + private String name; + private String updateMask; + private DeviceRegistry deviceRegistry; + + public static Builder newBuilder() { + return new Builder(); + } + + private Builder() { + } + + // Setter methods + public Builder setName(String name) { + this.name = name; + return this; + } + + public Builder setDeviceRegistry(DeviceRegistry deviceRegistry) { + this.deviceRegistry = deviceRegistry; + return this; + } + + public Builder setUpdateMask(String updateMask) { + this.updateMask = updateMask; + return this; + } + + // build method to deal with outer class + // to return outer instance + public UpdateDeviceRegistryRequest build() { + return new UpdateDeviceRegistryRequest(this); + } + } + + @SuppressWarnings("unchecked") + @Override + public String toString() { + requestParams.put("name", this.name); + requestParams.put("updateMask", this.updateMask); + + bodyParams.put("id", this.deviceRegistry.toBuilder().getId()); + bodyParams.put("name", this.deviceRegistry.toBuilder().getName()); + bodyParams.put("logLevel", this.deviceRegistry.toBuilder().getLogLevel()); + + return "name=" + this.name + ",updateMask=" + this.updateMask+", logLevel= "+this.deviceRegistry.toBuilder().getLogLevel(); + } + + public String[] getBodyAndParams() { + String[] output = new String[2]; + + String params = "name="+this.name+"&updateMask="+this.updateMask; + + output[0] = params; + output[1] = this.deviceRegistry.createDeviceJSONObject(""); + return output; + } + + +} diff --git a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/utils/AuthParams.java b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/utils/AuthParams.java index 8d585b00..ab02bbd0 100644 --- a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/utils/AuthParams.java +++ b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/utils/AuthParams.java @@ -77,6 +77,7 @@ public static void setAdminCredentials() { e.printStackTrace(); } System.out.println(adminSystemKey); + System.out.println(adminToken); } @SuppressWarnings("unchecked") @@ -94,8 +95,10 @@ public static void setRegistryCredentials() { SetHttpConnection setCon = new SetHttpConnection(); HttpsURLConnection con = setCon.getConnection(obj); con.setRequestProperty(Constants.HTTP_REQUEST_PROPERTY_TOKEN_KEY, adminToken); - con.setRequestProperty(Constants.HTTP_REQUEST_PROPERTY_CONTENT_TYPE_KEY, Constants.HTTP_REQUEST_PROPERTY_CONTENT_TYPE_ACCEPT_VALUE); - con.addRequestProperty(Constants.HTTP_REQUEST_PROPERTY_ACCEPT_KEY, Constants.HTTP_REQUEST_PROPERTY_CONTENT_TYPE_ACCEPT_VALUE); + con.setRequestProperty(Constants.HTTP_REQUEST_PROPERTY_CONTENT_TYPE_KEY, + Constants.HTTP_REQUEST_PROPERTY_CONTENT_TYPE_ACCEPT_VALUE); + con.addRequestProperty(Constants.HTTP_REQUEST_PROPERTY_ACCEPT_KEY, + Constants.HTTP_REQUEST_PROPERTY_CONTENT_TYPE_ACCEPT_VALUE); con.setRequestMethod(Constants.HTTP_REQUEST_METHOD_TYPE_POST); con.setDoOutput(true); StringBuilder response = new StringBuilder(); diff --git a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/utils/ConfigParameters.java b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/utils/ConfigParameters.java index 26c28f7b..5fd50514 100644 --- a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/utils/ConfigParameters.java +++ b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/utils/ConfigParameters.java @@ -163,7 +163,7 @@ public String getBaseURL() { public void setBaseURL(String baseURL) { this.baseURL = baseURL; - } + } public String getCloudiotConfigURLExtension() { return cloudiotConfigURLExtension; diff --git a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/utils/Device.java b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/utils/Device.java index db8fe6ca..eb7c120e 100644 --- a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/utils/Device.java +++ b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/utils/Device.java @@ -349,8 +349,7 @@ public String toString() { return deviceStr; } - - @SuppressWarnings("unchecked") + @SuppressWarnings({ "unchecked", "rawtypes" }) public String createDeviceJSONObject() { String bodyStr = ""; JSONObject deviceObj = new JSONObject(); @@ -411,6 +410,7 @@ public String createDeviceJSONObject() { return bodyStr; } + @SuppressWarnings("rawtypes") public void loadFromString(String inputStr) { try { JSONParser parser = new JSONParser(); @@ -496,40 +496,43 @@ public void loadFromString(String inputStr) { if (key.equals("metadata")) { JSONObject metadataJsonObject = (JSONObject) value; - - Map metadataMap = new HashMap<>(); - Set metadataSet = metadataJsonObject.keySet(); - if (metadataSet.size() > 0) { - Iterator metadIterator = metadataSet.iterator(); - while (metadIterator.hasNext()) { - String metadataKey = (String) metadIterator.next(); - String metatdataValue = (String) metadataJsonObject.get(metadataKey); - metadataMap.put(metadataKey, metatdataValue); + if (metadataJsonObject != null) { + Map metadataMap = new HashMap<>(); + Set metadataSet = metadataJsonObject.keySet(); + if (metadataSet.size() > 0) { + Iterator metadIterator = metadataSet.iterator(); + while (metadIterator.hasNext()) { + String metadataKey = (String) metadIterator.next(); + String metatdataValue = (String) metadataJsonObject.get(metadataKey); + metadataMap.put(metadataKey, metatdataValue); + } } - } - this.metadata = metadataMap; + this.metadata = metadataMap; + } } if (key.equals("gatewayConfig")) { JSONObject gatewayConfigJsonObject = (JSONObject) value; - GatewayConfig gatewayConfig = new GatewayConfig(); - if (gatewayConfigJsonObject.containsKey("gatewayType")) - gatewayConfig.setGatewayType( - GatewayType.valueOf((String) gatewayConfigJsonObject.get("gatewayType"))); - if (gatewayConfigJsonObject.containsKey("gatewayAuthMethod")) - gatewayConfig.setGatewayAuthMethod(GatewayAuthMethod - .valueOf((String) gatewayConfigJsonObject.get("gatewayAuthMethod"))); - if (gatewayConfigJsonObject.containsKey("lastAccessedGatewayId")) - gatewayConfig.setLastAccessedGatewayId( - (String) gatewayConfigJsonObject.get("lastAccessedGatewayId")); - if (gatewayConfigJsonObject.containsKey("lastAccessedGatewayTime")) - gatewayConfig.setLastAccessedGatewayTime( - (String) gatewayConfigJsonObject.get("lastAccessedGatewayTime")); - - this.gatewayConfig = gatewayConfig; + if (gatewayConfigJsonObject != null) { + GatewayConfig gatewayConfig = new GatewayConfig(); + if (gatewayConfigJsonObject.containsKey("gatewayType")) + gatewayConfig.setGatewayType( + GatewayType.valueOf((String) gatewayConfigJsonObject.get("gatewayType"))); + if (gatewayConfigJsonObject.containsKey("gatewayAuthMethod")) + gatewayConfig.setGatewayAuthMethod(GatewayAuthMethod + .valueOf((String) gatewayConfigJsonObject.get("gatewayAuthMethod"))); + if (gatewayConfigJsonObject.containsKey("lastAccessedGatewayId")) + gatewayConfig.setLastAccessedGatewayId( + (String) gatewayConfigJsonObject.get("lastAccessedGatewayId")); + if (gatewayConfigJsonObject.containsKey("lastAccessedGatewayTime")) + gatewayConfig.setLastAccessedGatewayTime( + (String) gatewayConfigJsonObject.get("lastAccessedGatewayTime")); + + this.gatewayConfig = gatewayConfig; + } } } - } + } } catch (Exception e) { e.printStackTrace(); diff --git a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/utils/DeviceConfig.java b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/utils/DeviceConfig.java index 435d753d..08941ade 100644 --- a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/utils/DeviceConfig.java +++ b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/utils/DeviceConfig.java @@ -1,7 +1,5 @@ package com.clearblade.cloud.iot.v1.utils; -import javax.swing.JSeparator; - import org.json.simple.JSONObject; import org.json.simple.parser.JSONParser; diff --git a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/utils/DeviceRegistry.java b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/utils/DeviceRegistry.java index 2513442d..d573b765 100644 --- a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/utils/DeviceRegistry.java +++ b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/utils/DeviceRegistry.java @@ -52,12 +52,20 @@ public Builder toBuilder() { return new Builder(this); } - public static DeviceRegistry of(String id, String name, List eventNotificationConfigs,StateNotificationConfig stateNotificationConfig,MqttConfig mqttConfig,HttpConfig httpConfig,LogLevel logLevel,List credentials) { - return newBuilder().setId(id).setName(name).setEventNotificationConfigs(eventNotificationConfigs).setStateNotificationConfig(stateNotificationConfig).setMqttConfig(mqttConfig).setHttpConfig(httpConfig).setLogLevel(logLevel).setCredentials(credentials).build(); + public static DeviceRegistry of(String id, String name, List eventNotificationConfigs, + StateNotificationConfig stateNotificationConfig, MqttConfig mqttConfig, HttpConfig httpConfig, + LogLevel logLevel, List credentials) { + return newBuilder().setId(id).setName(name).setEventNotificationConfigs(eventNotificationConfigs) + .setStateNotificationConfig(stateNotificationConfig).setMqttConfig(mqttConfig).setHttpConfig(httpConfig) + .setLogLevel(logLevel).setCredentials(credentials).build(); } - public static String format(String id, String name, List eventNotificationConfigs,StateNotificationConfig stateNotificationConfig,MqttConfig mqttConfig,HttpConfig httpConfig,LogLevel logLevel,List credentials) { - return newBuilder().setId(id).setName(name).setEventNotificationConfigs(eventNotificationConfigs).setStateNotificationConfig(stateNotificationConfig).setMqttConfig(mqttConfig).setHttpConfig(httpConfig).setLogLevel(logLevel).setCredentials(credentials).build() + public static String format(String id, String name, List eventNotificationConfigs, + StateNotificationConfig stateNotificationConfig, MqttConfig mqttConfig, HttpConfig httpConfig, + LogLevel logLevel, List credentials) { + return newBuilder().setId(id).setName(name).setEventNotificationConfigs(eventNotificationConfigs) + .setStateNotificationConfig(stateNotificationConfig).setMqttConfig(mqttConfig).setHttpConfig(httpConfig) + .setLogLevel(logLevel).setCredentials(credentials).build() .toString(); } @@ -179,6 +187,62 @@ public String toString() { +",credentials="+this.credentials); } + @SuppressWarnings("unchecked") + public String createDeviceJSONObject(String parentLocation) { + JSONObject output = new JSONObject(); + + if (id != null) + output.put("id", id); + if (name != null) { + if (!name.startsWith("projects")) + name = parentLocation + "/registries/" + name; + output.put("name", name); + } + if (logLevel != null) + output.put("logLevel", logLevel.name()); + if (httpConfig != null) { + output.put("httpConfig", this.httpConfig.getJsonObject()); + } else { + JSONObject json = new JSONObject(); + json.put("httpEnabledState", "HTTP_ENABLED"); + output.put("httpConfig", json); + } + if (mqttConfig != null) { + output.put("mqttConfig", this.mqttConfig.getJsonObject()); + } else { + JSONObject json = new JSONObject(); + json.put("mqttEnabledState", "MQTT_ENABLED"); + output.put("mqttConfig", json); + } + if (stateNotificationConfig != null) { + output.put("stateNotificationConfig", this.stateNotificationConfig.getJsonObject()); + } else { + JSONObject json = new JSONObject(); + json.put("pubsubTopicName", ""); + output.put("stateNotificationConfig", json); + } + + if (eventNotificationConfigs != null) { + JSONArray eventsArray = new JSONArray(); + for (int i = 0; i < eventNotificationConfigs.size(); i++) { + eventsArray.add(eventNotificationConfigs.get(i).getJsonObject()); + } + output.put("eventNotificationConfigs", eventsArray); + } + + if (credentials != null) { + JSONArray credentialArray = new JSONArray(); + for (int i = 0; i < credentials.size(); i++) { + credentialArray.add(credentials.get(i).getJsonObject()); + } + + output.put("credentials", credentialArray); + } + + return output.toJSONString(); + } + + @SuppressWarnings("rawtypes") public void loadFromString(String inputStr) { try { JSONParser parser = new JSONParser(); @@ -197,20 +261,15 @@ public void loadFromString(String inputStr) { if (key.equals("name")) { this.name = value.toString(); } - if (key.equals("credentials")) { - List credentialList = new ArrayList<>(); - RegistryCredential credentialObj = new RegistryCredential(); - credentialList.add(credentialObj); - this.credentials = credentialList; - } - if(key.equals("eventNotificationConfigs")) { + if (key.equals("eventNotificationConfigs")) { JSONArray eventJsonArray = (JSONArray) value; List eventNotificationCfgs = new ArrayList<>(); Iterator eventIterator = eventJsonArray.iterator(); while (eventIterator.hasNext()) { JSONObject eventJson = (JSONObject) eventIterator.next(); - EventNotificationConfig eventObj = EventNotificationConfig.newBuilder().setSubfolderMatches((String)eventJson.get("subfolderMatches")) - .setPubsubTopicName((String)eventJson.get("pubsubTopicName")) + EventNotificationConfig eventObj = EventNotificationConfig.newBuilder() + .setSubfolderMatches((String) eventJson.get("subfolderMatches")) + .setPubsubTopicName((String) eventJson.get("pubsubTopicName")) .build(); eventNotificationCfgs.add(eventObj); } @@ -227,21 +286,38 @@ public void loadFromString(String inputStr) { JSONObject mqttJsonObject = (JSONObject) value; MqttConfig mqttCfg = new MqttConfig(); if (mqttJsonObject.containsKey("mqttEnabledState")) - mqttCfg.setMqttEnabledState(MqttState.valueOf((String) mqttJsonObject.get("mqttEnabledState"))); - this.mqttConfig = mqttCfg; + mqttCfg.setMqttEnabledState( + MqttState.valueOf((String) mqttJsonObject.get("mqttEnabledState"))); + this.mqttConfig = mqttCfg; } if(key.equals("httpConfig")) { JSONObject httpJsonObject = (JSONObject) value; HttpConfig httpCfg = new HttpConfig(); if (httpJsonObject.containsKey("httpEnabledState")) - httpCfg.setHttpEnabledState(HttpState.valueOf((String) httpJsonObject.get("httpEnabledState"))); - this.httpConfig = httpCfg; + httpCfg.setHttpEnabledState( + HttpState.valueOf((String) httpJsonObject.get("httpEnabledState"))); + this.httpConfig = httpCfg; } if (key.equals("logLevel")) { if (value != null) { this.logLevel = LogLevel.valueOf(value.toString()); } } + if (key.equals("credentials")) { + JSONArray credJsonArray = (JSONArray) value; + if (credJsonArray != null) { + List registryCredentialsArray = new ArrayList<>(); + Iterator credIterator = credJsonArray.iterator(); + while (credIterator.hasNext()) { + JSONObject credJson = (JSONObject) credIterator.next(); + RegistryCredential registryCredential = RegistryCredential.newBuilder().build(); + registryCredential.loadFromJson(credJson); + registryCredentialsArray.add(registryCredential); + } + credentials = registryCredentialsArray; + } + + } } } } catch (Exception e) { diff --git a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/utils/EventNotificationConfig.java b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/utils/EventNotificationConfig.java index 38dffab2..c8ac17b2 100644 --- a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/utils/EventNotificationConfig.java +++ b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/utils/EventNotificationConfig.java @@ -1,5 +1,7 @@ package com.clearblade.cloud.iot.v1.utils; +import org.json.simple.JSONObject; + public class EventNotificationConfig { private String subfolderMatches; @@ -72,4 +74,14 @@ public Builder setPubsubTopicName(String pubsubTopicName) { public String toString() { return "subfolderMatches= "+this.subfolderMatches+",pubsubTopicName="+this.pubsubTopicName; } + + @SuppressWarnings("unchecked") + public JSONObject getJsonObject() { + JSONObject json = new JSONObject(); + json.put("pubsubTopicName", this.pubsubTopicName); + if (this.subfolderMatches != null) { + json.put("subfolderMatches", this.subfolderMatches); + } + return json; + } } diff --git a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/utils/HttpConfig.java b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/utils/HttpConfig.java index 0bd6257c..5d4f5b7c 100644 --- a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/utils/HttpConfig.java +++ b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/utils/HttpConfig.java @@ -1,5 +1,7 @@ package com.clearblade.cloud.iot.v1.utils; +import org.json.simple.JSONObject; + public class HttpConfig { private HttpState httpEnabledState; @@ -55,6 +57,13 @@ public Builder setHttpState(HttpState state) { } @Override public String toString() { - return "HttpState="+this.httpEnabledState; - } + return "{'httpEnabledState':'" + this.httpEnabledState + "'}"; + } + + @SuppressWarnings("unchecked") + public JSONObject getJsonObject() { + JSONObject json = new JSONObject(); + json.put("httpEnabledState", this.httpEnabledState.toString()); + return json; + } } diff --git a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/utils/LocationName.java b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/utils/LocationName.java new file mode 100644 index 00000000..4dbfb654 --- /dev/null +++ b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/utils/LocationName.java @@ -0,0 +1,90 @@ +package com.clearblade.cloud.iot.v1.utils; + +public class LocationName { + + private final String project; + private final String location; + + protected LocationName() { + project = null; + location = null; + } + + private LocationName(Builder builder) { + project = builder.getProject(); + location = builder.getLocation(); + } + + public String getProject() { + return project; + } + + public String getLocation() { + return location; + } + + public static Builder newBuilder() { + return new Builder(); + } + + public Builder toBuilder() { + return new Builder(this); + } + + public static LocationName of(String project, String location) { + return newBuilder().setProject(project).setLocation(location).build(); + } + + public static String format(String project, String location) { + return newBuilder().setProject(project).setLocation(location).build() + .toString(); + } + + /** + * Builder for + * projects/{project}/locations/{location}/registries/{registry}. + */ + public static class Builder { + private String project; + private String location; + + protected Builder() { + } + + public String getProject() { + return project; + } + + public String getLocation() { + return location; + } + + public Builder setProject(String project) { + this.project = project; + return this; + } + + public Builder setLocation(String location) { + this.location = location; + return this; + } + + private Builder(LocationName locationName) { + this.project = locationName.project; + this.location = locationName.location; + } + + public LocationName build() { + return new LocationName(this); + } + } + + @Override + public String toString() { + return "projects/" + this.getProject() + "/locations/" + this.getLocation(); + } + + public String getLocationFullName() { + return "projects/" + this.getProject() + "/locations/" + this.getLocation(); + } +} diff --git a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/utils/MqttConfig.java b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/utils/MqttConfig.java index e8138a16..a2d203f1 100644 --- a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/utils/MqttConfig.java +++ b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/utils/MqttConfig.java @@ -1,5 +1,7 @@ package com.clearblade.cloud.iot.v1.utils; +import org.json.simple.JSONObject; + public class MqttConfig { private MqttState mqttEnabledState; @@ -53,6 +55,13 @@ public Builder setMqttEnabledState(MqttState mqttEnabledState) { } @Override public String toString() { - return this.mqttEnabledState.toString(); - } + return "{'mqttEnabledState':'" + this.mqttEnabledState + "'}"; + } + + @SuppressWarnings("unchecked") + public JSONObject getJsonObject() { + JSONObject json = new JSONObject(); + json.put("mqttEnabledState", this.mqttEnabledState.toString()); + return json; + } } diff --git a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/utils/PublicKeyCertificate.java b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/utils/PublicKeyCertificate.java index aa88c6a7..6cfbe596 100644 --- a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/utils/PublicKeyCertificate.java +++ b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/utils/PublicKeyCertificate.java @@ -26,7 +26,7 @@ public void setX509Details(X509CertificateDetails x509Details) { } @Override public String toString() { - return "PublicKeyCertificateFormat="+this.format.toString()+",Certificate="+certificate+",X509CertificateDetails="+this.x509Details.toString(); + return "PublicKeyCertificateFormat=" + this.format.toString() + ",Certificate=" + certificate; } } diff --git a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/utils/RegistryCredential.java b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/utils/RegistryCredential.java index 468bc96f..b48841ef 100644 --- a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/utils/RegistryCredential.java +++ b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/utils/RegistryCredential.java @@ -1,15 +1,19 @@ package com.clearblade.cloud.iot.v1.utils; +import org.json.simple.JSONObject; + public class RegistryCredential { - private final PublicKeyCertificate publicKeyCertificate; + private PublicKeyCertificate publicKeyCertificate; + public RegistryCredential() { publicKeyCertificate = null; } + private RegistryCredential(Builder builder) { publicKeyCertificate = builder.getPublicKeyCertificate(); } - + public static Builder newBuilder() { return new Builder(); } @@ -17,15 +21,16 @@ public static Builder newBuilder() { public Builder toBuilder() { return new Builder(this); } + /** - * Builder for setting + * Builder for setting * RegistryCredential */ public static class Builder { private PublicKeyCertificate publicKeyCertificate; - + protected Builder() { - + } public PublicKeyCertificate getPublicKeyCertificate() { @@ -36,23 +41,68 @@ public Builder setPublicKeyCertificate(PublicKeyCertificate publicKeyCertificate this.publicKeyCertificate = publicKeyCertificate; return this; } - + private Builder(RegistryCredential registryCredential) { this.publicKeyCertificate = registryCredential.publicKeyCertificate; } - + public RegistryCredential build() { return new RegistryCredential(this); } } - + @Override public String toString() { - return "PublicKeyCertificate="+this.publicKeyCertificate; + return "PublicKeyCertificate=" + this.publicKeyCertificate.toString(); + } + + public void loadFromJson(JSONObject jsonObject) { + if (jsonObject.containsKey("publicKeyCertificate")) { + PublicKeyCertificate publicKeyCertificateObj = new PublicKeyCertificate(); + JSONObject publicKeyCertificateJson = (JSONObject) jsonObject.get("publicKeyCertificate"); + if (publicKeyCertificateJson.containsKey("format")) + publicKeyCertificateObj + .setFormat(PublicKeyCertificateFormat.valueOf((String) publicKeyCertificateJson.get("format"))); + if (publicKeyCertificateJson.containsKey("certificate")) + publicKeyCertificateObj + .setCertificate((String) publicKeyCertificateJson.get("certificate")); + if (publicKeyCertificateJson.containsKey("x509Details")) { + JSONObject x509DJsonObject = (JSONObject) publicKeyCertificateJson.get("x509Details"); + X509CertificateDetails x509CertificateDetails = new X509CertificateDetails(); + x509CertificateDetails.setIssuer((String) x509DJsonObject.get("issuer")); + x509CertificateDetails.setSubject((String) x509DJsonObject.get("subject")); + x509CertificateDetails.setStartTime((String) x509DJsonObject.get("startTime")); + x509CertificateDetails.setExpiryTime((String) x509DJsonObject.get("expiryTime")); + x509CertificateDetails.setSignatureAlgorithm((String) x509DJsonObject.get("signatureAlgorithm")); + x509CertificateDetails.setPublicKeyType((String) x509DJsonObject.get("publicKeyType")); + publicKeyCertificateObj.setX509Details(x509CertificateDetails); + } + publicKeyCertificate = publicKeyCertificateObj; + } } - - - - + @SuppressWarnings("unchecked") + public JSONObject getJsonObject() { + JSONObject json = new JSONObject(); + + JSONObject publicKeyCertificateJson = new JSONObject(); + if (publicKeyCertificate.getFormat() != null) + publicKeyCertificateJson.put("format", publicKeyCertificate.getFormat().name()); + if (publicKeyCertificate.getCertificate() != null) + publicKeyCertificateJson.put("certificate", publicKeyCertificate.getCertificate()); + if (publicKeyCertificate.getX509Details() != null) { + X509CertificateDetails x509CertificateDetails = publicKeyCertificate.getX509Details(); + JSONObject x509DJsonObject = new JSONObject(); + x509DJsonObject.put("issuer", x509CertificateDetails.getIssuer()); + x509DJsonObject.put("subject", x509CertificateDetails.getSubject()); + x509DJsonObject.put("startTime", x509CertificateDetails.getStartTime()); + x509DJsonObject.put("expiryTime", x509CertificateDetails.getExpiryTime()); + x509DJsonObject.put("signatureAlgorithm", x509CertificateDetails.getSignatureAlgorithm()); + x509DJsonObject.put("publicKeyType", x509CertificateDetails.getPublicKeyType()); + publicKeyCertificateJson.put("x509Details", x509DJsonObject); + + } + json.put("publicKeyCertificate", publicKeyCertificateJson); + return json; + } } diff --git a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/utils/StateNotificationConfig.java b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/utils/StateNotificationConfig.java index 89e579c2..05ec1dd9 100644 --- a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/utils/StateNotificationConfig.java +++ b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/utils/StateNotificationConfig.java @@ -1,5 +1,7 @@ package com.clearblade.cloud.iot.v1.utils; +import org.json.simple.JSONObject; + public class StateNotificationConfig { private String pubsubTopicName; @@ -52,6 +54,13 @@ public Builder setPubsubTopicName(String pubsubTopicName) { } @Override public String toString() { - return "pubsubTopicName="+this.pubsubTopicName; - } + return "pubsubTopicName=" + this.pubsubTopicName; + } + + @SuppressWarnings("unchecked") + public JSONObject getJsonObject() { + JSONObject json = new JSONObject(); + json.put("pubsubTopicName", this.pubsubTopicName); + return json; + } } diff --git a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/utils/X509CertificateDetails.java b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/utils/X509CertificateDetails.java index 5b3c7202..24e7f862 100644 --- a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/utils/X509CertificateDetails.java +++ b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/utils/X509CertificateDetails.java @@ -1,13 +1,11 @@ package com.clearblade.cloud.iot.v1.utils; -import java.sql.Timestamp; - public class X509CertificateDetails { private String issuer; private String subject; - private Timestamp startTime; - private Timestamp expiryTime; + private String startTime; + private String expiryTime; private String signatureAlgorithm; private String publicKeyType; @@ -24,16 +22,20 @@ public String getSubject() { public void setSubject(String subject) { this.subject = subject; } - public Timestamp getStartTime() { + + public String getStartTime() { return startTime; } - public void setStartTime(Timestamp startTime) { + + public void setStartTime(String startTime) { this.startTime = startTime; } - public Timestamp getExpiryTime() { + + public String getExpiryTime() { return expiryTime; } - public void setExpiryTime(Timestamp expiryTime) { + + public void setExpiryTime(String expiryTime) { this.expiryTime = expiryTime; } public String getSignatureAlgorithm() { @@ -51,7 +53,9 @@ public void setPublicKeyType(String publicKeyType) { @Override public String toString() { - return "Issuer= "+this.issuer+",Subject="+this.subject+",startTime="+this.startTime+",expiryTime="+this.expiryTime+",signatureAlgorithm="+this.signatureAlgorithm+",publicKeyType="+this.publicKeyType; + return "Issuer= " + this.issuer + ",Subject=" + this.subject + ",startTime=" + this.startTime + ",expiryTime=" + + this.expiryTime + ",signatureAlgorithm=" + this.signatureAlgorithm + ",publicKeyType=" + + this.publicKeyType; } } From 6b91091a79e4d831271c46594ac215f7c4e45176 Mon Sep 17 00:00:00 2001 From: RashmiK14 Date: Wed, 23 Nov 2022 10:48:26 +0530 Subject: [PATCH 016/151] Removed Non-required classes --- .../v1/createdevice/CreateDeviceResponse.java | 68 ---------------- .../v1/deletedevice/DeleteDeviceResponse.java | 68 ---------------- .../iot/v1/getdevice/GetDeviceResponse.java | 80 ------------------- .../GetDeviceRegistryResponse.java | 80 ------------------- .../ModifyCloudToDeviceConfigResponse.java | 69 ---------------- 5 files changed, 365 deletions(-) delete mode 100644 clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/createdevice/CreateDeviceResponse.java delete mode 100644 clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/deletedevice/DeleteDeviceResponse.java delete mode 100644 clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/getdevice/GetDeviceResponse.java delete mode 100644 clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/getdeviceregistry/GetDeviceRegistryResponse.java delete mode 100644 clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/modifycloudtodeviceconfig/ModifyCloudToDeviceConfigResponse.java diff --git a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/createdevice/CreateDeviceResponse.java b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/createdevice/CreateDeviceResponse.java deleted file mode 100644 index 1f08ddb2..00000000 --- a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/createdevice/CreateDeviceResponse.java +++ /dev/null @@ -1,68 +0,0 @@ -package com.clearblade.cloud.iot.v1.createdevice; - -import java.util.logging.Logger; - -public class CreateDeviceResponse { - - static Logger log = Logger.getLogger(CreateDeviceResponse.class.getName()); - private final CreateDeviceRequest request; - private int httpStatusCode; - private String httpStatusResponse; - - protected CreateDeviceResponse(Builder builder) { - this.request = builder.request; - } - - public int getHttpStatusCode() { - return httpStatusCode; - } - - public void setHttpStatusCode(int httpStatusCode) { - this.httpStatusCode = httpStatusCode; - } - - public String getHttpStatusResponse() { - return httpStatusResponse; - } - - public void setHttpStatusResponse(String httpStatusResponse) { - this.httpStatusResponse = httpStatusResponse; - } - - // Static class Builder - public static class Builder { - - /// instance fields - private CreateDeviceRequest request; - - public static Builder newBuilder() { - return new Builder(); - } - - private Builder() { - } - - // Setter methods - public Builder setCreateDeviceRequest(CreateDeviceRequest request) { - this.request = request; - return this; - } - - // build method to deal with outer class - // to return outer instance - public CreateDeviceResponse build() { - return new CreateDeviceResponse(this); - } - } - - @Override - public String toString() { - return "Http Status Code :: " + this.getHttpStatusCode() + " Http Status Response :: " - + this.getHttpStatusResponse(); - } - - public CreateDeviceRequest getRequest() { - return request; - } - -} diff --git a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/deletedevice/DeleteDeviceResponse.java b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/deletedevice/DeleteDeviceResponse.java deleted file mode 100644 index 6528b6d2..00000000 --- a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/deletedevice/DeleteDeviceResponse.java +++ /dev/null @@ -1,68 +0,0 @@ -package com.clearblade.cloud.iot.v1.deletedevice; - -import java.util.logging.Logger; - -public class DeleteDeviceResponse { - - static Logger log = Logger.getLogger(DeleteDeviceResponse.class.getName()); - private final DeleteDeviceRequest request; - private int httpStatusCode; - private String httpStatusResponse; - - protected DeleteDeviceResponse(Builder builder) { - this.request = builder.request; - } - - public int getHttpStatusCode() { - return httpStatusCode; - } - - public void setHttpStatusCode(int httpStatusCode) { - this.httpStatusCode = httpStatusCode; - } - - public String getHttpStatusResponse() { - return httpStatusResponse; - } - - public void setHttpStatusResponse(String httpStatusResponse) { - this.httpStatusResponse = httpStatusResponse; - } - - // Static class Builder - public static class Builder { - - /// instance fields - private DeleteDeviceRequest request; - - public static Builder newBuilder() { - return new Builder(); - } - - private Builder() { - } - - // Setter methods - public Builder setDeleteDeviceRequest(DeleteDeviceRequest request) { - this.request = request; - return this; - } - - // build method to deal with outer class - // to return outer instance - public DeleteDeviceResponse build() { - return new DeleteDeviceResponse(this); - } - } - - @Override - public String toString() { - return "Http Status Code :: " + this.getHttpStatusCode() + " Http Status Response :: " - + this.getHttpStatusResponse(); - } - - public DeleteDeviceRequest getRequest() { - return request; - } - -} diff --git a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/getdevice/GetDeviceResponse.java b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/getdevice/GetDeviceResponse.java deleted file mode 100644 index 40947d98..00000000 --- a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/getdevice/GetDeviceResponse.java +++ /dev/null @@ -1,80 +0,0 @@ -package com.clearblade.cloud.iot.v1.getdevice; - -import java.util.logging.Logger; - -import com.clearblade.cloud.iot.v1.utils.Device; - -public class GetDeviceResponse { - - static Logger log = Logger.getLogger(GetDeviceResponse.class.getName()); - - private final GetDeviceRequest request; - private int httpStatusCode; - private String httpStatusResponse; - private Device device; - - protected GetDeviceResponse(Builder builder) { - this.request = builder.request; - } - - public int getHttpStatusCode() { - return httpStatusCode; - } - - public void setHttpStatusCode(int httpStatusCode) { - this.httpStatusCode = httpStatusCode; - } - - public String getHttpStatusResponse() { - return httpStatusResponse; - } - - public void setHttpStatusResponse(String httpStatusResponse) { - this.httpStatusResponse = httpStatusResponse; - } - - // Static class Builder - public static class Builder { - - /// instance fields - private GetDeviceRequest request; - - public static Builder newBuilder() { - return new Builder(); - } - - private Builder() { - } - - // Setter methods - public Builder setGetDeviceRequest(GetDeviceRequest request) { - this.request = request; - return this; - } - - // build method to deal with outer class - // to return outer instance - public GetDeviceResponse build() { - return new GetDeviceResponse(this); - } - } - - @Override - public String toString() { - return "Http Status Code :: " + this.getHttpStatusCode() + " Http Status Response :: " - + this.getHttpStatusResponse(); - } - - public GetDeviceRequest getRequest() { - return request; - } - - public Device getDevice() { - return device; - } - - public void setDevice(Device device) { - this.device = device; - } - -} diff --git a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/getdeviceregistry/GetDeviceRegistryResponse.java b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/getdeviceregistry/GetDeviceRegistryResponse.java deleted file mode 100644 index 8d82f0d3..00000000 --- a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/getdeviceregistry/GetDeviceRegistryResponse.java +++ /dev/null @@ -1,80 +0,0 @@ -package com.clearblade.cloud.iot.v1.getdeviceregistry; - -import java.util.logging.Logger; - -import com.clearblade.cloud.iot.v1.utils.RegistryName; - -public class GetDeviceRegistryResponse { - - static Logger log = Logger.getLogger(GetDeviceRegistryResponse.class.getName()); - - private final GetDeviceRegistryRequest request; - private int httpStatusCode; - private String httpStatusResponse; - private RegistryName registry; -s - protected GetDeviceRegistryResponse(Builder builder) { - this.request = builder.request; - } - - public int getHttpStatusCode() { - return httpStatusCode; - } - - public void setHttpStatusCode(int httpStatusCode) { - this.httpStatusCode = httpStatusCode; - } - - public String getHttpStatusResponse() { - return httpStatusResponse; - } - - public void setHttpStatusResponse(String httpStatusResponse) { - this.httpStatusResponse = httpStatusResponse; - } - - // Static class Builder - public static class Builder { - - /// instance fields - private GetDeviceRegistryRequest request; - - public static Builder newBuilder() { - return new Builder(); - } - - private Builder() { - } - - // Setter methods - public Builder setGetDeviceRegistryRequest(GetDeviceRegistryRequest request) { - this.request = request; - return this; - } - - // build method to deal with outer class - // to return outer instance - public GetDeviceRegistryResponse build() { - return new GetDeviceRegistryResponse(this); - } - } - - @Override - public String toString() { - return "Http Status Code :: " + this.getHttpStatusCode() + " Http Status Response :: " - + this.getHttpStatusResponse(); - } - - public GetDeviceRegistryRequest getRequest() { - return request; - } - - public RegistryName getRegistry() { - return registry; - } - - public void setRegistryName(RegistryName registryName) { - this.registry = registryName; - } - -} diff --git a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/modifycloudtodeviceconfig/ModifyCloudToDeviceConfigResponse.java b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/modifycloudtodeviceconfig/ModifyCloudToDeviceConfigResponse.java deleted file mode 100644 index 83cb7253..00000000 --- a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/modifycloudtodeviceconfig/ModifyCloudToDeviceConfigResponse.java +++ /dev/null @@ -1,69 +0,0 @@ -package com.clearblade.cloud.iot.v1.modifycloudtodeviceconfig; - -import java.util.logging.Logger; - -public class ModifyCloudToDeviceConfigResponse { - - static Logger log = Logger.getLogger(ModifyCloudToDeviceConfigResponse.class.getName()); - private final ModifyCloudToDeviceConfigRequest request; - private int httpStatusCode; - private String httpStatusResponse; - - protected ModifyCloudToDeviceConfigResponse(Builder builder) { - this.request = builder.request; - } - - public int getHttpStatusCode() { - return httpStatusCode; - } - - public void setHttpStatusCode(int httpStatusCode) { - this.httpStatusCode = httpStatusCode; - } - - public String getHttpStatusResponse() { - return httpStatusResponse; - } - - public void setHttpStatusResponse(String httpStatusResponse) { - this.httpStatusResponse = httpStatusResponse; - } - - // Static class Builder - public static class Builder { - - /// instance fields - private ModifyCloudToDeviceConfigRequest request; - - public static Builder newBuilder() { - return new Builder(); - } - - private Builder() { - } - - // Setter methods - public Builder setModifyCloudToDeviceConfigRequest(ModifyCloudToDeviceConfigRequest request) { - this.request = request; - return this; - } - - // build method to deal with outer class - // to return outer instance - public ModifyCloudToDeviceConfigResponse build() { - return new ModifyCloudToDeviceConfigResponse(this); - } - } - - - @Override - public String toString() { - return "Http Status Code :: " + this.getHttpStatusCode() + " Http Status Response :: " - + this.getHttpStatusResponse(); - } - - public ModifyCloudToDeviceConfigRequest getRequest() { - return request; - } - -} From eaf666db3fd7adad84aaa68272d9368672875cc9 Mon Sep 17 00:00:00 2001 From: RashmiK14 Date: Wed, 23 Nov 2022 16:07:11 +0530 Subject: [PATCH 017/151] Code refactoring , exception handling for auth params and restruturing of files done --- .../AsyncBindDeviceToGateway.java | 8 +- .../SyncBindDeviceToGateway.java | 6 +- .../createdevice/AsyncCreateDevice.java | 36 +- .../createdevice/SyncCreateDevice.java | 38 ++- .../AsyncCreateDeviceRegistry.java | 7 +- .../SyncCreateDeviceRegistry.java | 7 +- .../deletedevice/AsyncDeleteDevice.java | 10 +- .../deletedevice/SyncDeleteDevice.java | 8 +- .../AsyncDeleteDeviceRegistry.java | 14 +- .../SyncDeleteDeviceRegistry.java | 11 +- .../deviceslist/AsyncDevicesList.java | 18 +- .../deviceslist/SyncDevicesList.java | 12 +- .../AsyncDeviceStatesList.java | 8 +- .../SyncDeviceStatesList.java | 8 +- .../getdevice/AsyncGetDevice.java | 15 +- .../getdevice/SyncGetDevice.java | 16 +- .../AsyncGetDeviceRegistry.java | 12 +- .../SyncGetDeviceRegistry.java | 9 +- .../AsyncListDeviceConfigVersions.java | 16 +- .../SyncListDeviceConfigVersions.java | 16 +- .../AsyncListDeviceRegistries.java | 8 +- .../SyncListDeviceRegistries.java | 8 +- .../AsyncModifyCloudToDeviceConfig.java | 7 +- .../SyncModifyCloudToDeviceConfig.java | 7 +- .../AsyncSendCommandToDevice.java | 6 +- .../SyncSendCommandToDevice.java | 6 +- .../AsyncUnbindDeviceFromGateway.java | 8 +- .../SyncUnbindDeviceFromGateway.java | 6 +- .../updatedevice/AsyncUpdateDevice.java | 16 +- .../updatedevice/SyncUpdateDevice.java | 16 +- .../AsyncUpdateDeviceRegistry.java | 17 +- .../SyncUpdateDeviceRegistry.java | 22 +- .../clearblade/cloud/iot/v1/AsyncClient.java | 173 ++++++---- .../cloud/iot/v1/ClearBladeDeviceManager.java | 322 ++++++++++-------- .../iot/v1/ClearBladeRegistryManager.java | 135 ++++---- .../iot/v1/DeviceManagerAsyncClient.java | 11 +- .../cloud/iot/v1/DeviceManagerClient.java | 20 +- .../clearblade/cloud/iot/v1/SyncClient.java | 122 ++++--- .../BindDeviceToGatewayRequest.java | 7 +- .../v1/createdevice/CreateDeviceRequest.java | 6 +- .../CreateDeviceRegistryRequest.java | 2 +- .../v1/deletedevice/DeleteDeviceRequest.java | 2 +- .../v1/deviceslist/DevicesListRequest.java | 2 +- .../v1/deviceslist/DevicesListResponse.java | 5 +- .../ListDeviceStatesResponse.java | 5 +- .../iot/v1/{utils => devicetypes}/Device.java | 67 ++-- .../{utils => devicetypes}/DeviceConfig.java | 64 ++-- .../DeviceCredential.java | 22 +- .../v1/{utils => devicetypes}/DeviceName.java | 7 +- .../{utils => devicetypes}/DeviceState.java | 33 +- .../v1/{utils => devicetypes}/FieldMask.java | 17 +- .../iot/v1/devicetypes/GatewayAuthMethod.java | 62 ++++ .../{utils => devicetypes}/GatewayConfig.java | 54 +-- .../GatewayListOptions.java | 2 +- .../cloud/iot/v1/devicetypes/GatewayType.java | 58 ++++ .../iot/v1/{utils => devicetypes}/Status.java | 36 +- .../v1/exception/ApplicationException.java | 7 + .../iot/v1/getdevice/GetDeviceRequest.java | 20 +- .../ListDeviceConfigVersionsResponse.java | 15 +- .../ListDeviceRegistriesResponse.java | 5 +- .../ModifyCloudToDeviceConfigRequest.java | 3 +- .../DeviceRegistry.java | 59 ++-- .../EventNotificationConfig.java | 28 +- .../{utils => registrytypes}/HttpConfig.java | 27 +- .../cloud/iot/v1/registrytypes/HttpState.java | 57 ++++ .../LocationName.java | 2 +- .../{utils => registrytypes}/MqttConfig.java | 23 +- .../cloud/iot/v1/registrytypes/MqttState.java | 57 ++++ .../PublicKeyCertificate.java | 14 +- .../PublicKeyCertificateFormat.java | 14 +- .../PublicKeyCredential.java | 17 +- .../PublicKeyFormat.java | 26 +- .../RegistryCredential.java | 2 +- .../RegistryName.java | 14 +- .../StateNotificationConfig.java | 22 +- .../X509CertificateDetails.java | 16 +- .../SendCommandToDeviceRequest.java | 2 +- .../UnbindDeviceFromGatewayRequest.java | 8 +- .../v1/updatedevice/UpdateDeviceRequest.java | 22 +- .../UpdateDeviceRegistryRequest.java | 31 +- .../cloud/iot/v1/utils/AuthParams.java | 174 +++++----- .../cloud/iot/v1/utils/ConfigParameters.java | 22 +- .../cloud/iot/v1/utils/Constants.java | 21 -- .../cloud/iot/v1/utils/GatewayAuthMethod.java | 63 ---- .../cloud/iot/v1/utils/GatewayType.java | 60 ---- .../cloud/iot/v1/utils/HttpState.java | 57 ---- .../cloud/iot/v1/utils/MqttState.java | 57 ---- .../cloud/iot/v1/utils/SetHttpConnection.java | 9 +- 88 files changed, 1417 insertions(+), 1173 deletions(-) rename clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/{ => samples}/binddevicetogateway/AsyncBindDeviceToGateway.java (73%) rename clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/{ => samples}/binddevicetogateway/SyncBindDeviceToGateway.java (73%) rename clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/{ => samples}/createdevice/AsyncCreateDevice.java (52%) rename clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/{ => samples}/createdevice/SyncCreateDevice.java (51%) rename clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/{ => samples}/createdeviceregistry/AsyncCreateDeviceRegistry.java (74%) rename clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/{ => samples}/createdeviceregistry/SyncCreateDeviceRegistry.java (74%) rename clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/{ => samples}/deletedevice/AsyncDeleteDevice.java (71%) rename clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/{ => samples}/deletedevice/SyncDeleteDevice.java (70%) rename clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/{ => samples}/deletedeviceregistry/AsyncDeleteDeviceRegistry.java (58%) rename clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/{ => samples}/deletedeviceregistry/SyncDeleteDeviceRegistry.java (57%) rename clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/{ => samples}/deviceslist/AsyncDevicesList.java (63%) rename clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/{ => samples}/deviceslist/SyncDevicesList.java (68%) rename clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/{ => samples}/devicestateslist/AsyncDeviceStatesList.java (71%) rename clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/{ => samples}/devicestateslist/SyncDeviceStatesList.java (71%) rename clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/{ => samples}/getdevice/AsyncGetDevice.java (60%) rename clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/{ => samples}/getdevice/SyncGetDevice.java (58%) rename clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/{ => samples}/getdeviceregistry/AsyncGetDeviceRegistry.java (66%) rename clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/{ => samples}/getdeviceregistry/SyncGetDeviceRegistry.java (72%) rename clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/{ => samples}/listdeviceconfigversions/AsyncListDeviceConfigVersions.java (56%) rename clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/{ => samples}/listdeviceconfigversions/SyncListDeviceConfigVersions.java (55%) rename clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/{ => samples}/listdeviceregistries/AsyncListDeviceRegistries.java (69%) rename clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/{ => samples}/listdeviceregistries/SyncListDeviceRegistries.java (68%) rename clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/{ => samples}/modifycloudtodeviceconfig/AsyncModifyCloudToDeviceConfig.java (76%) rename clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/{ => samples}/modifycloudtodeviceconfig/SyncModifyCloudToDeviceConfig.java (76%) rename clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/{ => samples}/sendcommandtodevice/AsyncSendCommandToDevice.java (76%) rename clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/{ => samples}/sendcommandtodevice/SyncSendCommandToDevice.java (75%) rename clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/{ => samples}/unbinddevicefromgateway/AsyncUnbindDeviceFromGateway.java (73%) rename clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/{ => samples}/unbinddevicefromgateway/SyncUnbindDeviceFromGateway.java (73%) rename clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/{ => samples}/updatedevice/AsyncUpdateDevice.java (57%) rename clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/{ => samples}/updatedevice/SyncUpdateDevice.java (56%) rename clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/{ => samples}/updatedeviceregistry/AsyncUpdateDeviceRegistry.java (69%) rename clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/{ => samples}/updatedeviceregistry/SyncUpdateDeviceRegistry.java (69%) rename clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/{utils => devicetypes}/Device.java (91%) rename clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/{utils => devicetypes}/DeviceConfig.java (76%) rename clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/{utils => devicetypes}/DeviceCredential.java (91%) rename clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/{utils => devicetypes}/DeviceName.java (97%) rename clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/{utils => devicetypes}/DeviceState.java (79%) rename clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/{utils => devicetypes}/FieldMask.java (90%) create mode 100644 clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/devicetypes/GatewayAuthMethod.java rename clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/{utils => devicetypes}/GatewayConfig.java (68%) rename clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/{utils => devicetypes}/GatewayListOptions.java (97%) create mode 100644 clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/devicetypes/GatewayType.java rename clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/{utils => devicetypes}/Status.java (83%) create mode 100644 clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/exception/ApplicationException.java rename clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/{utils => registrytypes}/DeviceRegistry.java (91%) rename clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/{utils => registrytypes}/EventNotificationConfig.java (91%) rename clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/{utils => registrytypes}/HttpConfig.java (90%) create mode 100644 clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/registrytypes/HttpState.java rename clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/{utils => registrytypes}/LocationName.java (97%) rename clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/{utils => registrytypes}/MqttConfig.java (94%) create mode 100644 clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/registrytypes/MqttState.java rename clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/{utils => registrytypes}/PublicKeyCertificate.java (92%) rename clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/{utils => registrytypes}/PublicKeyCertificateFormat.java (86%) rename clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/{utils => registrytypes}/PublicKeyCredential.java (95%) rename clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/{utils => registrytypes}/PublicKeyFormat.java (82%) rename clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/{utils => registrytypes}/RegistryCredential.java (98%) rename clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/{utils => registrytypes}/RegistryName.java (88%) rename clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/{utils => registrytypes}/StateNotificationConfig.java (94%) rename clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/{utils => registrytypes}/X509CertificateDetails.java (95%) delete mode 100644 clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/utils/GatewayAuthMethod.java delete mode 100644 clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/utils/GatewayType.java delete mode 100644 clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/utils/HttpState.java delete mode 100644 clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/utils/MqttState.java diff --git a/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/binddevicetogateway/AsyncBindDeviceToGateway.java b/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/binddevicetogateway/AsyncBindDeviceToGateway.java similarity index 73% rename from clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/binddevicetogateway/AsyncBindDeviceToGateway.java rename to clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/binddevicetogateway/AsyncBindDeviceToGateway.java index ba7fe7d4..a4802088 100644 --- a/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/binddevicetogateway/AsyncBindDeviceToGateway.java +++ b/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/binddevicetogateway/AsyncBindDeviceToGateway.java @@ -1,9 +1,11 @@ -package com.clearblade.cloud.iot.v1.binddevicetogateway; +package com.clearblade.cloud.iot.v1.samples.binddevicetogateway; import java.util.logging.Logger; import com.clearblade.cloud.iot.v1.DeviceManagerAsyncClient; -import com.clearblade.cloud.iot.v1.utils.RegistryName; +import com.clearblade.cloud.iot.v1.binddevicetogateway.BindDeviceToGatewayRequest; +import com.clearblade.cloud.iot.v1.binddevicetogateway.BindDeviceToGatewayResponse; +import com.clearblade.cloud.iot.v1.registrytypes.RegistryName; public class AsyncBindDeviceToGateway { static Logger log = Logger.getLogger(AsyncBindDeviceToGateway.class.getName()); @@ -19,6 +21,6 @@ public static void asyncBindDeviceToGateway() { .setGateway("Rashmi_Gateway_Test").setDevice("myOldDevice").build(); BindDeviceToGatewayResponse response = deviceManagerAsyncClient.bindDeviceToGateway(request); System.out.println(response.toString()); - + } } diff --git a/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/binddevicetogateway/SyncBindDeviceToGateway.java b/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/binddevicetogateway/SyncBindDeviceToGateway.java similarity index 73% rename from clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/binddevicetogateway/SyncBindDeviceToGateway.java rename to clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/binddevicetogateway/SyncBindDeviceToGateway.java index a99ce00d..39c973bb 100644 --- a/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/binddevicetogateway/SyncBindDeviceToGateway.java +++ b/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/binddevicetogateway/SyncBindDeviceToGateway.java @@ -1,9 +1,11 @@ -package com.clearblade.cloud.iot.v1.binddevicetogateway; +package com.clearblade.cloud.iot.v1.samples.binddevicetogateway; import java.util.logging.Logger; import com.clearblade.cloud.iot.v1.DeviceManagerClient; -import com.clearblade.cloud.iot.v1.utils.RegistryName; +import com.clearblade.cloud.iot.v1.binddevicetogateway.BindDeviceToGatewayRequest; +import com.clearblade.cloud.iot.v1.binddevicetogateway.BindDeviceToGatewayResponse; +import com.clearblade.cloud.iot.v1.registrytypes.RegistryName; public class SyncBindDeviceToGateway { static Logger log = Logger.getLogger(SyncBindDeviceToGateway.class.getName()); diff --git a/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/createdevice/AsyncCreateDevice.java b/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/createdevice/AsyncCreateDevice.java similarity index 52% rename from clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/createdevice/AsyncCreateDevice.java rename to clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/createdevice/AsyncCreateDevice.java index 64fa59c0..8dff5eae 100644 --- a/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/createdevice/AsyncCreateDevice.java +++ b/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/createdevice/AsyncCreateDevice.java @@ -1,17 +1,18 @@ -package com.clearblade.cloud.iot.v1.createdevice; +package com.clearblade.cloud.iot.v1.samples.createdevice; import java.util.ArrayList; import java.util.HashMap; import java.util.logging.Logger; import com.clearblade.cloud.iot.v1.DeviceManagerAsyncClient; -import com.clearblade.cloud.iot.v1.utils.Device; -import com.clearblade.cloud.iot.v1.utils.DeviceConfig; -import com.clearblade.cloud.iot.v1.utils.GatewayConfig; -import com.clearblade.cloud.iot.v1.utils.GatewayType; +import com.clearblade.cloud.iot.v1.createdevice.CreateDeviceRequest; +import com.clearblade.cloud.iot.v1.devicetypes.Device; +import com.clearblade.cloud.iot.v1.devicetypes.DeviceConfig; +import com.clearblade.cloud.iot.v1.devicetypes.GatewayConfig; +import com.clearblade.cloud.iot.v1.devicetypes.GatewayType; +import com.clearblade.cloud.iot.v1.devicetypes.Status; +import com.clearblade.cloud.iot.v1.registrytypes.RegistryName; import com.clearblade.cloud.iot.v1.utils.LogLevel; -import com.clearblade.cloud.iot.v1.utils.RegistryName; -import com.clearblade.cloud.iot.v1.utils.Status; public class AsyncCreateDevice { static Logger log = Logger.getLogger(AsyncCreateDevice.class.getName()); @@ -26,16 +27,17 @@ public static void asyncCreateDevice() { GatewayConfig gatewayCfg = new GatewayConfig(); gatewayCfg.setGatewayType(GatewayType.NON_GATEWAY); Device device = Device.newBuilder() - .setId("AsyncTest22").setName("AsyncTest22") - .setNumId("2315").setBlocked(false) - .setGatewayConfig(gatewayCfg) - .setLogLevel(LogLevel.ERROR) - .setCredentials(new ArrayList<>()) - .setLastErrorStatus(new Status()) - .setConfig(new DeviceConfig()) - .setMetadata(new HashMap<>()) - .build(); - CreateDeviceRequest request = CreateDeviceRequest.Builder.newBuilder().setParent(parent).setDevice(device).build(); + .setId("AsyncTest22").setName("AsyncTest22") + .setNumId("2315").setBlocked(false) + .setGatewayConfig(gatewayCfg) + .setLogLevel(LogLevel.ERROR) + .setCredentials(new ArrayList<>()) + .setLastErrorStatus(new Status()) + .setConfig(new DeviceConfig()) + .setMetadata(new HashMap<>()) + .build(); + CreateDeviceRequest request = CreateDeviceRequest.Builder.newBuilder().setParent(parent).setDevice(device) + .build(); Device response = deviceManagerAsyncClient.createDevice(request); System.out.println(response.toBuilder().getName()); } diff --git a/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/createdevice/SyncCreateDevice.java b/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/createdevice/SyncCreateDevice.java similarity index 51% rename from clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/createdevice/SyncCreateDevice.java rename to clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/createdevice/SyncCreateDevice.java index f08195e2..19c10db3 100644 --- a/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/createdevice/SyncCreateDevice.java +++ b/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/createdevice/SyncCreateDevice.java @@ -1,17 +1,18 @@ -package com.clearblade.cloud.iot.v1.createdevice; +package com.clearblade.cloud.iot.v1.samples.createdevice; import java.util.ArrayList; import java.util.HashMap; import java.util.logging.Logger; import com.clearblade.cloud.iot.v1.DeviceManagerClient; -import com.clearblade.cloud.iot.v1.utils.Device; -import com.clearblade.cloud.iot.v1.utils.DeviceConfig; -import com.clearblade.cloud.iot.v1.utils.GatewayConfig; -import com.clearblade.cloud.iot.v1.utils.GatewayType; +import com.clearblade.cloud.iot.v1.createdevice.CreateDeviceRequest; +import com.clearblade.cloud.iot.v1.devicetypes.Device; +import com.clearblade.cloud.iot.v1.devicetypes.DeviceConfig; +import com.clearblade.cloud.iot.v1.devicetypes.GatewayConfig; +import com.clearblade.cloud.iot.v1.devicetypes.GatewayType; +import com.clearblade.cloud.iot.v1.devicetypes.Status; +import com.clearblade.cloud.iot.v1.registrytypes.RegistryName; import com.clearblade.cloud.iot.v1.utils.LogLevel; -import com.clearblade.cloud.iot.v1.utils.RegistryName; -import com.clearblade.cloud.iot.v1.utils.Status; public class SyncCreateDevice { static Logger log = Logger.getLogger(SyncCreateDevice.class.getName()); @@ -27,18 +28,19 @@ public static void syncCreateDevice() { GatewayConfig gatewayCfg = new GatewayConfig(); gatewayCfg.setGatewayType(GatewayType.NON_GATEWAY); Device device = Device.newBuilder() - .setId("SyncTest22").setName("SyncTest22") - .setNumId("2314").setBlocked(false) - .setGatewayConfig(gatewayCfg) - .setLogLevel(LogLevel.DEBUG) - .setCredentials(new ArrayList<>()) - .setLastErrorStatus(new Status()) - .setConfig(new DeviceConfig()) - .setMetadata(new HashMap<>()) - .build(); - CreateDeviceRequest request = CreateDeviceRequest.Builder.newBuilder().setParent(parent).setDevice(device).build(); + .setId("SyncTest22").setName("SyncTest22") + .setNumId("2314").setBlocked(false) + .setGatewayConfig(gatewayCfg) + .setLogLevel(LogLevel.DEBUG) + .setCredentials(new ArrayList<>()) + .setLastErrorStatus(new Status()) + .setConfig(new DeviceConfig()) + .setMetadata(new HashMap<>()) + .build(); + CreateDeviceRequest request = CreateDeviceRequest.Builder.newBuilder().setParent(parent).setDevice(device) + .build(); Device response = deviceManagerClient.createDevice(request); System.out.println(response.toBuilder().getName()); - + } } diff --git a/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/createdeviceregistry/AsyncCreateDeviceRegistry.java b/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/createdeviceregistry/AsyncCreateDeviceRegistry.java similarity index 74% rename from clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/createdeviceregistry/AsyncCreateDeviceRegistry.java rename to clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/createdeviceregistry/AsyncCreateDeviceRegistry.java index 301ec4a9..1f43889a 100644 --- a/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/createdeviceregistry/AsyncCreateDeviceRegistry.java +++ b/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/createdeviceregistry/AsyncCreateDeviceRegistry.java @@ -1,8 +1,9 @@ -package com.clearblade.cloud.iot.v1.createdeviceregistry; +package com.clearblade.cloud.iot.v1.samples.createdeviceregistry; import com.clearblade.cloud.iot.v1.DeviceManagerAsyncClient; -import com.clearblade.cloud.iot.v1.utils.DeviceRegistry; -import com.clearblade.cloud.iot.v1.utils.LocationName; +import com.clearblade.cloud.iot.v1.createdeviceregistry.CreateDeviceRegistryRequest; +import com.clearblade.cloud.iot.v1.registrytypes.DeviceRegistry; +import com.clearblade.cloud.iot.v1.registrytypes.LocationName; public class AsyncCreateDeviceRegistry { public static void main(String[] args) { diff --git a/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/createdeviceregistry/SyncCreateDeviceRegistry.java b/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/createdeviceregistry/SyncCreateDeviceRegistry.java similarity index 74% rename from clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/createdeviceregistry/SyncCreateDeviceRegistry.java rename to clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/createdeviceregistry/SyncCreateDeviceRegistry.java index c862972c..b9aaa78c 100644 --- a/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/createdeviceregistry/SyncCreateDeviceRegistry.java +++ b/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/createdeviceregistry/SyncCreateDeviceRegistry.java @@ -1,8 +1,9 @@ -package com.clearblade.cloud.iot.v1.createdeviceregistry; +package com.clearblade.cloud.iot.v1.samples.createdeviceregistry; import com.clearblade.cloud.iot.v1.DeviceManagerClient; -import com.clearblade.cloud.iot.v1.utils.DeviceRegistry; -import com.clearblade.cloud.iot.v1.utils.LocationName; +import com.clearblade.cloud.iot.v1.createdeviceregistry.CreateDeviceRegistryRequest; +import com.clearblade.cloud.iot.v1.registrytypes.DeviceRegistry; +import com.clearblade.cloud.iot.v1.registrytypes.LocationName; public class SyncCreateDeviceRegistry { diff --git a/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/deletedevice/AsyncDeleteDevice.java b/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/deletedevice/AsyncDeleteDevice.java similarity index 71% rename from clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/deletedevice/AsyncDeleteDevice.java rename to clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/deletedevice/AsyncDeleteDevice.java index 36c71e19..09244ed8 100644 --- a/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/deletedevice/AsyncDeleteDevice.java +++ b/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/deletedevice/AsyncDeleteDevice.java @@ -1,20 +1,22 @@ -package com.clearblade.cloud.iot.v1.deletedevice; +package com.clearblade.cloud.iot.v1.samples.deletedevice; import java.util.logging.Logger; import com.clearblade.cloud.iot.v1.DeviceManagerAsyncClient; -import com.clearblade.cloud.iot.v1.utils.DeviceName; +import com.clearblade.cloud.iot.v1.deletedevice.DeleteDeviceRequest; +import com.clearblade.cloud.iot.v1.devicetypes.DeviceName; public class AsyncDeleteDevice { static Logger log = Logger.getLogger(AsyncDeleteDevice.class.getName()); - + public static void main(String[] args) { asyncDeleteDevice(); } public static void asyncDeleteDevice() { DeviceManagerAsyncClient deviceManagerAsyncClient = new DeviceManagerAsyncClient(); - DeviceName deviceName = DeviceName.of("ingressdevelopmentenv", "us-central1", "Rashmi_Registry_Test", "AsyncTest22"); + DeviceName deviceName = DeviceName.of("ingressdevelopmentenv", "us-central1", "Rashmi_Registry_Test", + "AsyncTest22"); DeleteDeviceRequest request = DeleteDeviceRequest.Builder.newBuilder().setName(deviceName).build(); deviceManagerAsyncClient.deleteDevice(request); } diff --git a/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/deletedevice/SyncDeleteDevice.java b/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/deletedevice/SyncDeleteDevice.java similarity index 70% rename from clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/deletedevice/SyncDeleteDevice.java rename to clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/deletedevice/SyncDeleteDevice.java index b744139d..08825ac8 100644 --- a/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/deletedevice/SyncDeleteDevice.java +++ b/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/deletedevice/SyncDeleteDevice.java @@ -1,9 +1,10 @@ -package com.clearblade.cloud.iot.v1.deletedevice; +package com.clearblade.cloud.iot.v1.samples.deletedevice; import java.util.logging.Logger; import com.clearblade.cloud.iot.v1.DeviceManagerClient; -import com.clearblade.cloud.iot.v1.utils.DeviceName; +import com.clearblade.cloud.iot.v1.deletedevice.DeleteDeviceRequest; +import com.clearblade.cloud.iot.v1.devicetypes.DeviceName; public class SyncDeleteDevice { static Logger log = Logger.getLogger(SyncDeleteDevice.class.getName()); @@ -14,7 +15,8 @@ public static void main(String[] args) { public static void syncDeleteDevice() { DeviceManagerClient deviceManagerClient = new DeviceManagerClient(); - DeviceName deviceName = DeviceName.of("ingressdevelopmentenv", "us-central1", "Rashmi_Registry_Test", "SyncTest22"); + DeviceName deviceName = DeviceName.of("ingressdevelopmentenv", "us-central1", "Rashmi_Registry_Test", + "SyncTest22"); DeleteDeviceRequest request = DeleteDeviceRequest.Builder.newBuilder().setName(deviceName).build(); deviceManagerClient.deleteDevice(request); } diff --git a/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/deletedeviceregistry/AsyncDeleteDeviceRegistry.java b/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/deletedeviceregistry/AsyncDeleteDeviceRegistry.java similarity index 58% rename from clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/deletedeviceregistry/AsyncDeleteDeviceRegistry.java rename to clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/deletedeviceregistry/AsyncDeleteDeviceRegistry.java index aa124323..267c4e6c 100644 --- a/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/deletedeviceregistry/AsyncDeleteDeviceRegistry.java +++ b/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/deletedeviceregistry/AsyncDeleteDeviceRegistry.java @@ -1,20 +1,22 @@ -package com.clearblade.cloud.iot.v1.deletedeviceregistry; +package com.clearblade.cloud.iot.v1.samples.deletedeviceregistry; import com.clearblade.cloud.iot.v1.DeviceManagerAsyncClient; -import com.clearblade.cloud.iot.v1.utils.RegistryName; +import com.clearblade.cloud.iot.v1.deletedeviceregistry.DeleteDeviceRegistryRequest; +import com.clearblade.cloud.iot.v1.registrytypes.RegistryName; public class AsyncDeleteDeviceRegistry { - + public static void main(String[] args) throws Exception { asyncDeleteDeviceRegistry(); } public static void asyncDeleteDeviceRegistry() throws Exception { - + DeviceManagerAsyncClient deviceManagerClient = new DeviceManagerAsyncClient(); DeleteDeviceRegistryRequest request = DeleteDeviceRegistryRequest.Builder.newBuilder() - .setName(RegistryName.of("ingressdevelopmentenv", "us-central1", "testCreate_reg2").getRegistryFullName()) - .build(); + .setName(RegistryName.of("ingressdevelopmentenv", "us-central1", "testCreate_reg2") + .getRegistryFullName()) + .build(); deviceManagerClient.deleteDeviceRegistry(request); } diff --git a/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/deletedeviceregistry/SyncDeleteDeviceRegistry.java b/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/deletedeviceregistry/SyncDeleteDeviceRegistry.java similarity index 57% rename from clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/deletedeviceregistry/SyncDeleteDeviceRegistry.java rename to clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/deletedeviceregistry/SyncDeleteDeviceRegistry.java index 795fa8e3..cd5feea7 100644 --- a/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/deletedeviceregistry/SyncDeleteDeviceRegistry.java +++ b/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/deletedeviceregistry/SyncDeleteDeviceRegistry.java @@ -1,7 +1,8 @@ -package com.clearblade.cloud.iot.v1.deletedeviceregistry; +package com.clearblade.cloud.iot.v1.samples.deletedeviceregistry; import com.clearblade.cloud.iot.v1.DeviceManagerClient; -import com.clearblade.cloud.iot.v1.utils.RegistryName; +import com.clearblade.cloud.iot.v1.deletedeviceregistry.DeleteDeviceRegistryRequest; +import com.clearblade.cloud.iot.v1.registrytypes.RegistryName; public class SyncDeleteDeviceRegistry { @@ -12,10 +13,10 @@ public static void main(String[] args) throws Exception { public static void syncDeleteDeviceRegistry() throws Exception { DeviceManagerClient deviceManagerClient = new DeviceManagerClient(); DeleteDeviceRegistryRequest request = DeleteDeviceRegistryRequest.Builder.newBuilder() - .setName(RegistryName.of("ingressdevelopmentenv", "us-central1", "testCreate_reg3").getRegistryFullName()) - .build(); + .setName(RegistryName.of("ingressdevelopmentenv", "us-central1", "testCreate_reg3") + .getRegistryFullName()) + .build(); deviceManagerClient.deleteDeviceRegistry(request); } } - diff --git a/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/deviceslist/AsyncDevicesList.java b/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/deviceslist/AsyncDevicesList.java similarity index 63% rename from clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/deviceslist/AsyncDevicesList.java rename to clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/deviceslist/AsyncDevicesList.java index 79b079db..c194a4d8 100644 --- a/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/deviceslist/AsyncDevicesList.java +++ b/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/deviceslist/AsyncDevicesList.java @@ -1,22 +1,24 @@ -package com.clearblade.cloud.iot.v1.deviceslist; +package com.clearblade.cloud.iot.v1.samples.deviceslist; import java.util.logging.Logger; import com.clearblade.cloud.iot.v1.DeviceManagerAsyncClient; -import com.clearblade.cloud.iot.v1.utils.Device; -import com.clearblade.cloud.iot.v1.utils.GatewayListOptions; -import com.clearblade.cloud.iot.v1.utils.GatewayType; -import com.clearblade.cloud.iot.v1.utils.RegistryName; +import com.clearblade.cloud.iot.v1.deviceslist.DevicesListRequest; +import com.clearblade.cloud.iot.v1.deviceslist.DevicesListResponse; +import com.clearblade.cloud.iot.v1.devicetypes.Device; +import com.clearblade.cloud.iot.v1.devicetypes.GatewayListOptions; +import com.clearblade.cloud.iot.v1.devicetypes.GatewayType; +import com.clearblade.cloud.iot.v1.registrytypes.RegistryName; public class AsyncDevicesList { - + static Logger log = Logger.getLogger(AsyncDevicesList.class.getName()); - public static void main(String[] args){ + public static void main(String[] args) { asyncDevicesList(); } - public static void asyncDevicesList(){ + public static void asyncDevicesList() { DeviceManagerAsyncClient deviceManagerAsyncClient = new DeviceManagerAsyncClient(); RegistryName parent = RegistryName.of("ingressdevelopmentenv", "us-central1", "MandarTest1"); DevicesListRequest request = DevicesListRequest.Builder.newBuilder().setParent(parent.toString()) diff --git a/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/deviceslist/SyncDevicesList.java b/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/deviceslist/SyncDevicesList.java similarity index 68% rename from clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/deviceslist/SyncDevicesList.java rename to clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/deviceslist/SyncDevicesList.java index 7b1f0b45..14129da1 100644 --- a/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/deviceslist/SyncDevicesList.java +++ b/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/deviceslist/SyncDevicesList.java @@ -1,12 +1,14 @@ -package com.clearblade.cloud.iot.v1.deviceslist; +package com.clearblade.cloud.iot.v1.samples.deviceslist; import java.util.logging.Logger; import com.clearblade.cloud.iot.v1.DeviceManagerClient; -import com.clearblade.cloud.iot.v1.utils.Device; -import com.clearblade.cloud.iot.v1.utils.GatewayListOptions; -import com.clearblade.cloud.iot.v1.utils.GatewayType; -import com.clearblade.cloud.iot.v1.utils.RegistryName; +import com.clearblade.cloud.iot.v1.deviceslist.DevicesListRequest; +import com.clearblade.cloud.iot.v1.deviceslist.DevicesListResponse; +import com.clearblade.cloud.iot.v1.devicetypes.Device; +import com.clearblade.cloud.iot.v1.devicetypes.GatewayListOptions; +import com.clearblade.cloud.iot.v1.devicetypes.GatewayType; +import com.clearblade.cloud.iot.v1.registrytypes.RegistryName; public class SyncDevicesList { static Logger log = Logger.getLogger(SyncDevicesList.class.getName()); diff --git a/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/devicestateslist/AsyncDeviceStatesList.java b/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/devicestateslist/AsyncDeviceStatesList.java similarity index 71% rename from clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/devicestateslist/AsyncDeviceStatesList.java rename to clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/devicestateslist/AsyncDeviceStatesList.java index 793391e2..2081c9b6 100644 --- a/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/devicestateslist/AsyncDeviceStatesList.java +++ b/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/devicestateslist/AsyncDeviceStatesList.java @@ -1,10 +1,12 @@ -package com.clearblade.cloud.iot.v1.devicestateslist; +package com.clearblade.cloud.iot.v1.samples.devicestateslist; import java.util.logging.Logger; import com.clearblade.cloud.iot.v1.DeviceManagerAsyncClient; -import com.clearblade.cloud.iot.v1.utils.DeviceName; -import com.clearblade.cloud.iot.v1.utils.DeviceState; +import com.clearblade.cloud.iot.v1.devicestateslist.ListDeviceStatesRequest; +import com.clearblade.cloud.iot.v1.devicestateslist.ListDeviceStatesResponse; +import com.clearblade.cloud.iot.v1.devicetypes.DeviceName; +import com.clearblade.cloud.iot.v1.devicetypes.DeviceState; public class AsyncDeviceStatesList { diff --git a/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/devicestateslist/SyncDeviceStatesList.java b/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/devicestateslist/SyncDeviceStatesList.java similarity index 71% rename from clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/devicestateslist/SyncDeviceStatesList.java rename to clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/devicestateslist/SyncDeviceStatesList.java index 19696f66..5af92657 100644 --- a/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/devicestateslist/SyncDeviceStatesList.java +++ b/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/devicestateslist/SyncDeviceStatesList.java @@ -1,10 +1,12 @@ -package com.clearblade.cloud.iot.v1.devicestateslist; +package com.clearblade.cloud.iot.v1.samples.devicestateslist; import java.util.logging.Logger; import com.clearblade.cloud.iot.v1.DeviceManagerClient; -import com.clearblade.cloud.iot.v1.utils.DeviceName; -import com.clearblade.cloud.iot.v1.utils.DeviceState; +import com.clearblade.cloud.iot.v1.devicestateslist.ListDeviceStatesRequest; +import com.clearblade.cloud.iot.v1.devicestateslist.ListDeviceStatesResponse; +import com.clearblade.cloud.iot.v1.devicetypes.DeviceName; +import com.clearblade.cloud.iot.v1.devicetypes.DeviceState; public class SyncDeviceStatesList { static Logger log = Logger.getLogger(SyncDeviceStatesList.class.getName()); diff --git a/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/getdevice/AsyncGetDevice.java b/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/getdevice/AsyncGetDevice.java similarity index 60% rename from clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/getdevice/AsyncGetDevice.java rename to clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/getdevice/AsyncGetDevice.java index e757b4d4..2b0beab4 100644 --- a/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/getdevice/AsyncGetDevice.java +++ b/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/getdevice/AsyncGetDevice.java @@ -1,11 +1,12 @@ -package com.clearblade.cloud.iot.v1.getdevice; +package com.clearblade.cloud.iot.v1.samples.getdevice; import java.util.logging.Logger; import com.clearblade.cloud.iot.v1.DeviceManagerAsyncClient; -import com.clearblade.cloud.iot.v1.utils.Device; -import com.clearblade.cloud.iot.v1.utils.DeviceName; -import com.clearblade.cloud.iot.v1.utils.FieldMask; +import com.clearblade.cloud.iot.v1.devicetypes.Device; +import com.clearblade.cloud.iot.v1.devicetypes.DeviceName; +import com.clearblade.cloud.iot.v1.devicetypes.FieldMask; +import com.clearblade.cloud.iot.v1.getdevice.GetDeviceRequest; public class AsyncGetDevice { static Logger log = Logger.getLogger(AsyncGetDevice.class.getName()); @@ -16,8 +17,10 @@ public static void main(String[] args) { public static void asyncGetDevice() { DeviceManagerAsyncClient deviceManagerAsyncClient = new DeviceManagerAsyncClient(); - DeviceName name = DeviceName.of("ingressdevelopmentenv", "us-central1", "Rashmi_Registry_Test", "Rashmi_Device_Test"); - GetDeviceRequest request = GetDeviceRequest.Builder.newBuilder().setName(name).setFieldMask(FieldMask.newBuilder().build()).build(); + DeviceName name = DeviceName.of("ingressdevelopmentenv", "us-central1", "Rashmi_Registry_Test", + "Rashmi_Device_Test"); + GetDeviceRequest request = GetDeviceRequest.Builder.newBuilder().setName(name) + .setFieldMask(FieldMask.newBuilder().build()).build(); Device response = deviceManagerAsyncClient.getDevice(request); System.out.println(response.toBuilder().getName()); } diff --git a/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/getdevice/SyncGetDevice.java b/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/getdevice/SyncGetDevice.java similarity index 58% rename from clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/getdevice/SyncGetDevice.java rename to clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/getdevice/SyncGetDevice.java index aa86d115..06be3ff0 100644 --- a/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/getdevice/SyncGetDevice.java +++ b/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/getdevice/SyncGetDevice.java @@ -1,11 +1,12 @@ -package com.clearblade.cloud.iot.v1.getdevice; +package com.clearblade.cloud.iot.v1.samples.getdevice; import java.util.logging.Logger; import com.clearblade.cloud.iot.v1.DeviceManagerClient; -import com.clearblade.cloud.iot.v1.utils.Device; -import com.clearblade.cloud.iot.v1.utils.DeviceName; -import com.clearblade.cloud.iot.v1.utils.FieldMask; +import com.clearblade.cloud.iot.v1.devicetypes.Device; +import com.clearblade.cloud.iot.v1.devicetypes.DeviceName; +import com.clearblade.cloud.iot.v1.devicetypes.FieldMask; +import com.clearblade.cloud.iot.v1.getdevice.GetDeviceRequest; public class SyncGetDevice { static Logger log = Logger.getLogger(SyncGetDevice.class.getName()); @@ -16,11 +17,12 @@ public static void main(String[] args) { public static void syncGetDevice() { DeviceManagerClient deviceManagerClient = new DeviceManagerClient(); - DeviceName name = DeviceName.of("ingressdevelopmentenv", "us-central1", "Rashmi_Registry_Test", "Rashmi_Device_Test"); - GetDeviceRequest request = GetDeviceRequest.Builder.newBuilder().setName(name).setFieldMask(FieldMask.newBuilder().build()).build(); + DeviceName name = DeviceName.of("ingressdevelopmentenv", "us-central1", "Rashmi_Registry_Test", + "Rashmi_Device_Test"); + GetDeviceRequest request = GetDeviceRequest.Builder.newBuilder().setName(name) + .setFieldMask(FieldMask.newBuilder().build()).build(); Device response = deviceManagerClient.getDevice(request); System.out.println(response.toBuilder().getName()); } - } diff --git a/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/getdeviceregistry/AsyncGetDeviceRegistry.java b/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/getdeviceregistry/AsyncGetDeviceRegistry.java similarity index 66% rename from clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/getdeviceregistry/AsyncGetDeviceRegistry.java rename to clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/getdeviceregistry/AsyncGetDeviceRegistry.java index f14ba310..60e440b6 100644 --- a/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/getdeviceregistry/AsyncGetDeviceRegistry.java +++ b/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/getdeviceregistry/AsyncGetDeviceRegistry.java @@ -1,10 +1,11 @@ -package com.clearblade.cloud.iot.v1.getdeviceregistry; +package com.clearblade.cloud.iot.v1.samples.getdeviceregistry; import java.util.logging.Logger; import com.clearblade.cloud.iot.v1.DeviceManagerClient; -import com.clearblade.cloud.iot.v1.utils.DeviceRegistry; -import com.clearblade.cloud.iot.v1.utils.RegistryName; +import com.clearblade.cloud.iot.v1.getdeviceregistry.GetDeviceRegistryRequest; +import com.clearblade.cloud.iot.v1.registrytypes.DeviceRegistry; +import com.clearblade.cloud.iot.v1.registrytypes.RegistryName; public class AsyncGetDeviceRegistry { static Logger log = Logger.getLogger(AsyncGetDeviceRegistry.class.getName()); @@ -16,8 +17,9 @@ public static void main(String[] args) { public static void asyncGetDeviceRegistry() { DeviceManagerClient deviceManagerClient = new DeviceManagerClient(); GetDeviceRegistryRequest request = GetDeviceRegistryRequest.Builder.newBuilder() - .setName(RegistryName.of("ingressdevelopmentenv", "us-central1", "Rashmi_Registry_Test").getRegistryFullName()) - .build(); + .setName(RegistryName.of("ingressdevelopmentenv", "us-central1", "Rashmi_Registry_Test") + .getRegistryFullName()) + .build(); DeviceRegistry response = deviceManagerClient.getDeviceRegistry(request); System.out.println(response.toString()); } diff --git a/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/getdeviceregistry/SyncGetDeviceRegistry.java b/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/getdeviceregistry/SyncGetDeviceRegistry.java similarity index 72% rename from clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/getdeviceregistry/SyncGetDeviceRegistry.java rename to clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/getdeviceregistry/SyncGetDeviceRegistry.java index 3506071e..4e7f3827 100644 --- a/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/getdeviceregistry/SyncGetDeviceRegistry.java +++ b/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/getdeviceregistry/SyncGetDeviceRegistry.java @@ -1,10 +1,11 @@ -package com.clearblade.cloud.iot.v1.getdeviceregistry; +package com.clearblade.cloud.iot.v1.samples.getdeviceregistry; import java.util.logging.Logger; import com.clearblade.cloud.iot.v1.DeviceManagerAsyncClient; -import com.clearblade.cloud.iot.v1.utils.DeviceRegistry; -import com.clearblade.cloud.iot.v1.utils.RegistryName; +import com.clearblade.cloud.iot.v1.getdeviceregistry.GetDeviceRegistryRequest; +import com.clearblade.cloud.iot.v1.registrytypes.DeviceRegistry; +import com.clearblade.cloud.iot.v1.registrytypes.RegistryName; public class SyncGetDeviceRegistry { static Logger log = Logger.getLogger(SyncGetDeviceRegistry.class.getName()); @@ -17,7 +18,7 @@ public static void syncGetDeviceRegistry() { DeviceManagerAsyncClient deviceManagerAsyncClient = new DeviceManagerAsyncClient(); GetDeviceRegistryRequest request = GetDeviceRegistryRequest.Builder.newBuilder() .setName(RegistryName.of("ingressdevelopmentenv", "us-central1", "MandarTest1").getRegistryFullName()) - .build(); + .build(); DeviceRegistry response = deviceManagerAsyncClient.getDeviceRegistry(request); System.out.println(response.createDeviceJSONObject("")); } diff --git a/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/listdeviceconfigversions/AsyncListDeviceConfigVersions.java b/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/listdeviceconfigversions/AsyncListDeviceConfigVersions.java similarity index 56% rename from clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/listdeviceconfigversions/AsyncListDeviceConfigVersions.java rename to clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/listdeviceconfigversions/AsyncListDeviceConfigVersions.java index eef34596..93c6c149 100644 --- a/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/listdeviceconfigversions/AsyncListDeviceConfigVersions.java +++ b/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/listdeviceconfigversions/AsyncListDeviceConfigVersions.java @@ -1,10 +1,12 @@ -package com.clearblade.cloud.iot.v1.listdeviceconfigversions; +package com.clearblade.cloud.iot.v1.samples.listdeviceconfigversions; import java.util.logging.Logger; import com.clearblade.cloud.iot.v1.DeviceManagerAsyncClient; -import com.clearblade.cloud.iot.v1.utils.DeviceConfig; -import com.clearblade.cloud.iot.v1.utils.DeviceName; +import com.clearblade.cloud.iot.v1.devicetypes.DeviceConfig; +import com.clearblade.cloud.iot.v1.devicetypes.DeviceName; +import com.clearblade.cloud.iot.v1.listdeviceconfigversions.ListDeviceConfigVersionsRequest; +import com.clearblade.cloud.iot.v1.listdeviceconfigversions.ListDeviceConfigVersionsResponse; public class AsyncListDeviceConfigVersions { @@ -16,9 +18,11 @@ public static void main(String[] args) { public static void asyncDevicesConfigVersionsList() { DeviceManagerAsyncClient deviceManagerAsyncClient = new DeviceManagerAsyncClient(); - ListDeviceConfigVersionsRequest request = ListDeviceConfigVersionsRequest.Builder.newBuilder().setName(DeviceName - .of("ingressdevelopmentenv", "us-central1", "Rashmi_Registry_Test", "Rashmi_Device_Test") - .toString()).setNumVersions(2).build(); + ListDeviceConfigVersionsRequest request = ListDeviceConfigVersionsRequest.Builder.newBuilder() + .setName(DeviceName + .of("ingressdevelopmentenv", "us-central1", "Rashmi_Registry_Test", "Rashmi_Device_Test") + .toString()) + .setNumVersions(2).build(); ListDeviceConfigVersionsResponse response = deviceManagerAsyncClient.listDeviceConfigVersions(request); for (DeviceConfig element : response.getDeviceConfigList()) { System.out.println(element.toString()); diff --git a/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/listdeviceconfigversions/SyncListDeviceConfigVersions.java b/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/listdeviceconfigversions/SyncListDeviceConfigVersions.java similarity index 55% rename from clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/listdeviceconfigversions/SyncListDeviceConfigVersions.java rename to clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/listdeviceconfigversions/SyncListDeviceConfigVersions.java index 0fdaf9ea..e8751279 100644 --- a/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/listdeviceconfigversions/SyncListDeviceConfigVersions.java +++ b/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/listdeviceconfigversions/SyncListDeviceConfigVersions.java @@ -1,10 +1,12 @@ -package com.clearblade.cloud.iot.v1.listdeviceconfigversions; +package com.clearblade.cloud.iot.v1.samples.listdeviceconfigversions; import java.util.logging.Logger; import com.clearblade.cloud.iot.v1.DeviceManagerClient; -import com.clearblade.cloud.iot.v1.utils.DeviceConfig; -import com.clearblade.cloud.iot.v1.utils.DeviceName; +import com.clearblade.cloud.iot.v1.devicetypes.DeviceConfig; +import com.clearblade.cloud.iot.v1.devicetypes.DeviceName; +import com.clearblade.cloud.iot.v1.listdeviceconfigversions.ListDeviceConfigVersionsRequest; +import com.clearblade.cloud.iot.v1.listdeviceconfigversions.ListDeviceConfigVersionsResponse; public class SyncListDeviceConfigVersions { @@ -16,9 +18,11 @@ public static void main(String[] args) { public static void syncDevicesConfigVersionsList() { DeviceManagerClient deviceManagerClient = new DeviceManagerClient(); - ListDeviceConfigVersionsRequest request = ListDeviceConfigVersionsRequest.Builder.newBuilder().setName(DeviceName - .of("ingressdevelopmentenv", "us-central1", "Rashmi_Registry_Test", "Rashmi_Device_Test") - .toString()).setNumVersions(2).build(); + ListDeviceConfigVersionsRequest request = ListDeviceConfigVersionsRequest.Builder.newBuilder() + .setName(DeviceName + .of("ingressdevelopmentenv", "us-central1", "Rashmi_Registry_Test", "Rashmi_Device_Test") + .toString()) + .setNumVersions(2).build(); ListDeviceConfigVersionsResponse response = deviceManagerClient.listDeviceConfigVersions(request); for (DeviceConfig element : response.getDeviceConfigList()) { System.out.println(element.toString()); diff --git a/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/listdeviceregistries/AsyncListDeviceRegistries.java b/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/listdeviceregistries/AsyncListDeviceRegistries.java similarity index 69% rename from clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/listdeviceregistries/AsyncListDeviceRegistries.java rename to clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/listdeviceregistries/AsyncListDeviceRegistries.java index d7048148..1a811083 100644 --- a/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/listdeviceregistries/AsyncListDeviceRegistries.java +++ b/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/listdeviceregistries/AsyncListDeviceRegistries.java @@ -1,8 +1,10 @@ -package com.clearblade.cloud.iot.v1.listdeviceregistries; +package com.clearblade.cloud.iot.v1.samples.listdeviceregistries; import com.clearblade.cloud.iot.v1.DeviceManagerAsyncClient; -import com.clearblade.cloud.iot.v1.utils.DeviceRegistry; -import com.clearblade.cloud.iot.v1.utils.LocationName; +import com.clearblade.cloud.iot.v1.listdeviceregistries.ListDeviceRegistriesRequest; +import com.clearblade.cloud.iot.v1.listdeviceregistries.ListDeviceRegistriesResponse; +import com.clearblade.cloud.iot.v1.registrytypes.DeviceRegistry; +import com.clearblade.cloud.iot.v1.registrytypes.LocationName; public class AsyncListDeviceRegistries { public static void main(String[] args) throws Exception { diff --git a/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/listdeviceregistries/SyncListDeviceRegistries.java b/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/listdeviceregistries/SyncListDeviceRegistries.java similarity index 68% rename from clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/listdeviceregistries/SyncListDeviceRegistries.java rename to clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/listdeviceregistries/SyncListDeviceRegistries.java index dccb2f9b..dc42d7cd 100644 --- a/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/listdeviceregistries/SyncListDeviceRegistries.java +++ b/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/listdeviceregistries/SyncListDeviceRegistries.java @@ -1,8 +1,10 @@ -package com.clearblade.cloud.iot.v1.listdeviceregistries; +package com.clearblade.cloud.iot.v1.samples.listdeviceregistries; import com.clearblade.cloud.iot.v1.DeviceManagerClient; -import com.clearblade.cloud.iot.v1.utils.DeviceRegistry; -import com.clearblade.cloud.iot.v1.utils.LocationName; +import com.clearblade.cloud.iot.v1.listdeviceregistries.ListDeviceRegistriesRequest; +import com.clearblade.cloud.iot.v1.listdeviceregistries.ListDeviceRegistriesResponse; +import com.clearblade.cloud.iot.v1.registrytypes.DeviceRegistry; +import com.clearblade.cloud.iot.v1.registrytypes.LocationName; public class SyncListDeviceRegistries { public static void main(String[] args) throws Exception { diff --git a/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/modifycloudtodeviceconfig/AsyncModifyCloudToDeviceConfig.java b/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/modifycloudtodeviceconfig/AsyncModifyCloudToDeviceConfig.java similarity index 76% rename from clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/modifycloudtodeviceconfig/AsyncModifyCloudToDeviceConfig.java rename to clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/modifycloudtodeviceconfig/AsyncModifyCloudToDeviceConfig.java index 09f36671..07af37e7 100644 --- a/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/modifycloudtodeviceconfig/AsyncModifyCloudToDeviceConfig.java +++ b/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/modifycloudtodeviceconfig/AsyncModifyCloudToDeviceConfig.java @@ -1,11 +1,12 @@ -package com.clearblade.cloud.iot.v1.modifycloudtodeviceconfig; +package com.clearblade.cloud.iot.v1.samples.modifycloudtodeviceconfig; import java.util.logging.Logger; import com.clearblade.cloud.iot.v1.DeviceManagerAsyncClient; +import com.clearblade.cloud.iot.v1.devicetypes.DeviceConfig; +import com.clearblade.cloud.iot.v1.devicetypes.DeviceName; +import com.clearblade.cloud.iot.v1.modifycloudtodeviceconfig.ModifyCloudToDeviceConfigRequest; import com.clearblade.cloud.iot.v1.utils.ByteString; -import com.clearblade.cloud.iot.v1.utils.DeviceConfig; -import com.clearblade.cloud.iot.v1.utils.DeviceName; public class AsyncModifyCloudToDeviceConfig { static Logger log = Logger.getLogger(AsyncModifyCloudToDeviceConfig.class.getName()); diff --git a/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/modifycloudtodeviceconfig/SyncModifyCloudToDeviceConfig.java b/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/modifycloudtodeviceconfig/SyncModifyCloudToDeviceConfig.java similarity index 76% rename from clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/modifycloudtodeviceconfig/SyncModifyCloudToDeviceConfig.java rename to clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/modifycloudtodeviceconfig/SyncModifyCloudToDeviceConfig.java index 36bea517..d6a8fe3b 100644 --- a/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/modifycloudtodeviceconfig/SyncModifyCloudToDeviceConfig.java +++ b/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/modifycloudtodeviceconfig/SyncModifyCloudToDeviceConfig.java @@ -1,11 +1,12 @@ -package com.clearblade.cloud.iot.v1.modifycloudtodeviceconfig; +package com.clearblade.cloud.iot.v1.samples.modifycloudtodeviceconfig; import java.util.logging.Logger; import com.clearblade.cloud.iot.v1.DeviceManagerClient; +import com.clearblade.cloud.iot.v1.devicetypes.DeviceConfig; +import com.clearblade.cloud.iot.v1.devicetypes.DeviceName; +import com.clearblade.cloud.iot.v1.modifycloudtodeviceconfig.ModifyCloudToDeviceConfigRequest; import com.clearblade.cloud.iot.v1.utils.ByteString; -import com.clearblade.cloud.iot.v1.utils.DeviceConfig; -import com.clearblade.cloud.iot.v1.utils.DeviceName; public class SyncModifyCloudToDeviceConfig { static Logger log = Logger.getLogger(SyncModifyCloudToDeviceConfig.class.getName()); diff --git a/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/sendcommandtodevice/AsyncSendCommandToDevice.java b/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/sendcommandtodevice/AsyncSendCommandToDevice.java similarity index 76% rename from clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/sendcommandtodevice/AsyncSendCommandToDevice.java rename to clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/sendcommandtodevice/AsyncSendCommandToDevice.java index e3ec576c..9ebe3e5e 100644 --- a/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/sendcommandtodevice/AsyncSendCommandToDevice.java +++ b/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/sendcommandtodevice/AsyncSendCommandToDevice.java @@ -1,10 +1,12 @@ -package com.clearblade.cloud.iot.v1.sendcommandtodevice; +package com.clearblade.cloud.iot.v1.samples.sendcommandtodevice; import java.util.logging.Logger; import com.clearblade.cloud.iot.v1.DeviceManagerAsyncClient; +import com.clearblade.cloud.iot.v1.devicetypes.DeviceName; +import com.clearblade.cloud.iot.v1.sendcommandtodevice.SendCommandToDeviceRequest; +import com.clearblade.cloud.iot.v1.sendcommandtodevice.SendCommandToDeviceResponse; import com.clearblade.cloud.iot.v1.utils.ByteString; -import com.clearblade.cloud.iot.v1.utils.DeviceName; public class AsyncSendCommandToDevice { diff --git a/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/sendcommandtodevice/SyncSendCommandToDevice.java b/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/sendcommandtodevice/SyncSendCommandToDevice.java similarity index 75% rename from clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/sendcommandtodevice/SyncSendCommandToDevice.java rename to clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/sendcommandtodevice/SyncSendCommandToDevice.java index c6646baa..b8ec4239 100644 --- a/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/sendcommandtodevice/SyncSendCommandToDevice.java +++ b/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/sendcommandtodevice/SyncSendCommandToDevice.java @@ -1,10 +1,12 @@ -package com.clearblade.cloud.iot.v1.sendcommandtodevice; +package com.clearblade.cloud.iot.v1.samples.sendcommandtodevice; import java.util.logging.Logger; import com.clearblade.cloud.iot.v1.DeviceManagerClient; +import com.clearblade.cloud.iot.v1.devicetypes.DeviceName; +import com.clearblade.cloud.iot.v1.sendcommandtodevice.SendCommandToDeviceRequest; +import com.clearblade.cloud.iot.v1.sendcommandtodevice.SendCommandToDeviceResponse; import com.clearblade.cloud.iot.v1.utils.ByteString; -import com.clearblade.cloud.iot.v1.utils.DeviceName; public class SyncSendCommandToDevice { diff --git a/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/unbinddevicefromgateway/AsyncUnbindDeviceFromGateway.java b/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/unbinddevicefromgateway/AsyncUnbindDeviceFromGateway.java similarity index 73% rename from clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/unbinddevicefromgateway/AsyncUnbindDeviceFromGateway.java rename to clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/unbinddevicefromgateway/AsyncUnbindDeviceFromGateway.java index 80717888..3b80d731 100644 --- a/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/unbinddevicefromgateway/AsyncUnbindDeviceFromGateway.java +++ b/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/unbinddevicefromgateway/AsyncUnbindDeviceFromGateway.java @@ -1,9 +1,11 @@ -package com.clearblade.cloud.iot.v1.unbinddevicefromgateway; +package com.clearblade.cloud.iot.v1.samples.unbinddevicefromgateway; import java.util.logging.Logger; import com.clearblade.cloud.iot.v1.DeviceManagerAsyncClient; -import com.clearblade.cloud.iot.v1.utils.RegistryName; +import com.clearblade.cloud.iot.v1.registrytypes.RegistryName; +import com.clearblade.cloud.iot.v1.unbinddevicefromgateway.UnbindDeviceFromGatewayRequest; +import com.clearblade.cloud.iot.v1.unbinddevicefromgateway.UnbindDeviceFromGatewayResponse; public class AsyncUnbindDeviceFromGateway { static Logger log = Logger.getLogger(AsyncUnbindDeviceFromGateway.class.getName()); @@ -20,6 +22,6 @@ public static void asyncUnbindDeviceFromGateway() { UnbindDeviceFromGatewayResponse response = deviceManagerAsyncClient.unbindDeviceFromGateway(request); System.out.println(response.toString()); - + } } diff --git a/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/unbinddevicefromgateway/SyncUnbindDeviceFromGateway.java b/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/unbinddevicefromgateway/SyncUnbindDeviceFromGateway.java similarity index 73% rename from clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/unbinddevicefromgateway/SyncUnbindDeviceFromGateway.java rename to clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/unbinddevicefromgateway/SyncUnbindDeviceFromGateway.java index 0926c3de..31656594 100644 --- a/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/unbinddevicefromgateway/SyncUnbindDeviceFromGateway.java +++ b/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/unbinddevicefromgateway/SyncUnbindDeviceFromGateway.java @@ -1,9 +1,11 @@ -package com.clearblade.cloud.iot.v1.unbinddevicefromgateway; +package com.clearblade.cloud.iot.v1.samples.unbinddevicefromgateway; import java.util.logging.Logger; import com.clearblade.cloud.iot.v1.DeviceManagerClient; -import com.clearblade.cloud.iot.v1.utils.RegistryName; +import com.clearblade.cloud.iot.v1.registrytypes.RegistryName; +import com.clearblade.cloud.iot.v1.unbinddevicefromgateway.UnbindDeviceFromGatewayRequest; +import com.clearblade.cloud.iot.v1.unbinddevicefromgateway.UnbindDeviceFromGatewayResponse; public class SyncUnbindDeviceFromGateway { static Logger log = Logger.getLogger(SyncUnbindDeviceFromGateway.class.getName()); diff --git a/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/updatedevice/AsyncUpdateDevice.java b/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/updatedevice/AsyncUpdateDevice.java similarity index 57% rename from clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/updatedevice/AsyncUpdateDevice.java rename to clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/updatedevice/AsyncUpdateDevice.java index 8e308927..1f8a370e 100644 --- a/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/updatedevice/AsyncUpdateDevice.java +++ b/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/updatedevice/AsyncUpdateDevice.java @@ -1,9 +1,10 @@ -package com.clearblade.cloud.iot.v1.updatedevice; +package com.clearblade.cloud.iot.v1.samples.updatedevice; import java.util.logging.Logger; import com.clearblade.cloud.iot.v1.DeviceManagerAsyncClient; -import com.clearblade.cloud.iot.v1.utils.Device; +import com.clearblade.cloud.iot.v1.devicetypes.Device; +import com.clearblade.cloud.iot.v1.updatedevice.UpdateDeviceRequest; import com.clearblade.cloud.iot.v1.utils.LogLevel; public class AsyncUpdateDevice { @@ -15,12 +16,13 @@ public static void main(String[] args) { public static void asyncUpdateDevice() { DeviceManagerAsyncClient deviceManagerAsyncClient = new DeviceManagerAsyncClient(); - Device device = Device.patch("myOldDevice","myOldDevice",LogLevel.ERROR,true); + Device device = Device.patch("myOldDevice", "myOldDevice", LogLevel.ERROR, true); String updateMask = "logLevel"; - - UpdateDeviceRequest request = UpdateDeviceRequest.Builder.newBuilder().setName("myOldDevice").setDevice(device).setUpdateMask(updateMask).build(); + + UpdateDeviceRequest request = UpdateDeviceRequest.Builder.newBuilder().setName("myOldDevice").setDevice(device) + .setUpdateMask(updateMask).build(); Device response = deviceManagerAsyncClient.updateDevice(request); - System.out.println(response.toBuilder().getName()+"::"+response.toBuilder().getLogLevel().name()); - + System.out.println(response.toBuilder().getName() + "::" + response.toBuilder().getLogLevel().name()); + } } diff --git a/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/updatedevice/SyncUpdateDevice.java b/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/updatedevice/SyncUpdateDevice.java similarity index 56% rename from clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/updatedevice/SyncUpdateDevice.java rename to clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/updatedevice/SyncUpdateDevice.java index a48de2a2..48291a38 100644 --- a/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/updatedevice/SyncUpdateDevice.java +++ b/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/updatedevice/SyncUpdateDevice.java @@ -1,9 +1,10 @@ -package com.clearblade.cloud.iot.v1.updatedevice; +package com.clearblade.cloud.iot.v1.samples.updatedevice; import java.util.logging.Logger; import com.clearblade.cloud.iot.v1.DeviceManagerClient; -import com.clearblade.cloud.iot.v1.utils.Device; +import com.clearblade.cloud.iot.v1.devicetypes.Device; +import com.clearblade.cloud.iot.v1.updatedevice.UpdateDeviceRequest; import com.clearblade.cloud.iot.v1.utils.LogLevel; public class SyncUpdateDevice { @@ -15,12 +16,13 @@ public static void main(String[] args) { public static void syncUpdateDevice() { DeviceManagerClient deviceManagerClient = new DeviceManagerClient(); - - Device device = Device.patch("myOldDevice","myOldDevice",LogLevel.DEBUG,true); + + Device device = Device.patch("myOldDevice", "myOldDevice", LogLevel.DEBUG, true); String updateMask = "logLevel"; - - UpdateDeviceRequest request = UpdateDeviceRequest.Builder.newBuilder().setName("myOldDevice").setDevice(device).setUpdateMask(updateMask).build(); + + UpdateDeviceRequest request = UpdateDeviceRequest.Builder.newBuilder().setName("myOldDevice").setDevice(device) + .setUpdateMask(updateMask).build(); Device response = deviceManagerClient.updateDevice(request); - System.out.println(response.toBuilder().getName()+"::"+response.toBuilder().getLogLevel().name()); + System.out.println(response.toBuilder().getName() + "::" + response.toBuilder().getLogLevel().name()); } } diff --git a/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/updatedeviceregistry/AsyncUpdateDeviceRegistry.java b/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/updatedeviceregistry/AsyncUpdateDeviceRegistry.java similarity index 69% rename from clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/updatedeviceregistry/AsyncUpdateDeviceRegistry.java rename to clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/updatedeviceregistry/AsyncUpdateDeviceRegistry.java index 796b2885..db66276f 100644 --- a/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/updatedeviceregistry/AsyncUpdateDeviceRegistry.java +++ b/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/updatedeviceregistry/AsyncUpdateDeviceRegistry.java @@ -1,9 +1,10 @@ -package com.clearblade.cloud.iot.v1.updatedeviceregistry; +package com.clearblade.cloud.iot.v1.samples.updatedeviceregistry; import com.clearblade.cloud.iot.v1.DeviceManagerAsyncClient; -import com.clearblade.cloud.iot.v1.utils.DeviceRegistry; +import com.clearblade.cloud.iot.v1.registrytypes.DeviceRegistry; +import com.clearblade.cloud.iot.v1.registrytypes.RegistryName; +import com.clearblade.cloud.iot.v1.updatedeviceregistry.UpdateDeviceRegistryRequest; import com.clearblade.cloud.iot.v1.utils.LogLevel; -import com.clearblade.cloud.iot.v1.utils.RegistryName; public class AsyncUpdateDeviceRegistry { public static void main(String[] args) throws Exception { @@ -15,13 +16,13 @@ public static void asyncUpdateDeviceRegistry() throws Exception { RegistryName name = RegistryName.of("ingressdevelopmentenv", "us-central1", "Registry_Test1"); UpdateDeviceRegistryRequest request = UpdateDeviceRegistryRequest.Builder.newBuilder() .setDeviceRegistry(DeviceRegistry.newBuilder().setId("Rashmi_Registry_Test") - .setName(name.getRegistryFullName()) - .setLogLevel(LogLevel.DEBUG) - .build()) + .setName(name.getRegistryFullName()) + .setLogLevel(LogLevel.DEBUG) + .build()) .setName(name.getRegistryFullName()).setUpdateMask("logLevel").build(); - + DeviceRegistry response = deviceManagerClient.updateDeviceRegistry(request); - if(response != null) { + if (response != null) { System.out.println(response.toBuilder().getName() + "::" + response.toBuilder().getLogLevel()); } } diff --git a/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/updatedeviceregistry/SyncUpdateDeviceRegistry.java b/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/updatedeviceregistry/SyncUpdateDeviceRegistry.java similarity index 69% rename from clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/updatedeviceregistry/SyncUpdateDeviceRegistry.java rename to clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/updatedeviceregistry/SyncUpdateDeviceRegistry.java index da711fa5..98d63425 100644 --- a/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/updatedeviceregistry/SyncUpdateDeviceRegistry.java +++ b/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/updatedeviceregistry/SyncUpdateDeviceRegistry.java @@ -1,12 +1,13 @@ -package com.clearblade.cloud.iot.v1.updatedeviceregistry; +package com.clearblade.cloud.iot.v1.samples.updatedeviceregistry; import com.clearblade.cloud.iot.v1.DeviceManagerClient; -import com.clearblade.cloud.iot.v1.utils.DeviceRegistry; +import com.clearblade.cloud.iot.v1.registrytypes.DeviceRegistry; +import com.clearblade.cloud.iot.v1.registrytypes.RegistryName; +import com.clearblade.cloud.iot.v1.updatedeviceregistry.UpdateDeviceRegistryRequest; import com.clearblade.cloud.iot.v1.utils.LogLevel; -import com.clearblade.cloud.iot.v1.utils.RegistryName; public class SyncUpdateDeviceRegistry { - + public static void main(String[] args) throws Exception { syncUpdateDeviceRegistry(); } @@ -14,17 +15,16 @@ public static void main(String[] args) throws Exception { public static void syncUpdateDeviceRegistry() throws Exception { DeviceManagerClient deviceManagerClient = new DeviceManagerClient(); RegistryName name = RegistryName.of("ingressdevelopmentenv", "us-central1", "Rashmi_Registry_Test"); - - + UpdateDeviceRegistryRequest request = UpdateDeviceRegistryRequest.Builder.newBuilder() .setDeviceRegistry(DeviceRegistry.newBuilder().setId("Rashmi_Registry_Test") - .setName(name.getRegistryFullName()) - .setLogLevel(LogLevel.DEBUG) - .build()) + .setName(name.getRegistryFullName()) + .setLogLevel(LogLevel.DEBUG) + .build()) .setName(name.getRegistryFullName()).setUpdateMask("logLevel").build(); - + DeviceRegistry response = deviceManagerClient.updateDeviceRegistry(request); - if(response != null) { + if (response != null) { System.out.println(response.toBuilder().getName() + "::" + response.toBuilder().getLogLevel()); } } diff --git a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/AsyncClient.java b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/AsyncClient.java index 58b86da4..79613cc4 100644 --- a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/AsyncClient.java +++ b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/AsyncClient.java @@ -1,6 +1,7 @@ package com.clearblade.cloud.iot.v1; import java.io.BufferedReader; +import java.io.IOException; import java.io.InputStreamReader; import java.io.OutputStream; import java.net.URL; @@ -9,9 +10,12 @@ import java.util.concurrent.Future; import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeoutException; +import java.util.logging.Level; +import java.util.logging.Logger; import javax.net.ssl.HttpsURLConnection; +import com.clearblade.cloud.iot.v1.exception.ApplicationException; import com.clearblade.cloud.iot.v1.utils.AuthParams; import com.clearblade.cloud.iot.v1.utils.ConfigParameters; import com.clearblade.cloud.iot.v1.utils.Constants; @@ -19,6 +23,8 @@ public class AsyncClient { + static Logger log = Logger.getLogger(AsyncClient.class.getName()); + private ConfigParameters configParameters = new ConfigParameters(); private String[] responseArray = new String[3]; private String apiName; @@ -28,8 +34,9 @@ public class AsyncClient { /** * Method used to generate URL for apicall + * * @param apiName - path to api - * @param params - parameters to be attached to request + * @param params - parameters to be attached to request * @return URL formed and to be used */ private String generateURL(String apiName, String params) { @@ -60,25 +67,27 @@ private String generateAdminURL(String apiName, String params) { /** * Method used to Calls HTTP Get request + * * @param apiName * @param params * @return String[] containing responseCode, responseMessage and response object + * @throws IOException + * @throws ApplicationException */ private Object get() { String finalURL = ""; - if (isAdmin) { - AuthParams.setAdminCredentials(); - finalURL = generateAdminURL(apiName, params); - } else { - AuthParams.setRegistryCredentials(); - finalURL = generateURL(apiName, params); - } try { - System.out.println(finalURL); + if (isAdmin) { + AuthParams.setAdminCredentials(); + finalURL = generateAdminURL(apiName, params); + } else { + AuthParams.setRegistryCredentials(); + finalURL = generateURL(apiName, params); + } URL obj = new URL(finalURL); SetHttpConnection setCon = new SetHttpConnection(); HttpsURLConnection con = setCon.getConnection(obj); - if(isAdmin) + if (isAdmin) con.setRequestProperty(Constants.HTTP_REQUEST_PROPERTY_TOKEN_KEY, AuthParams.getAdminToken()); else con.setRequestProperty(Constants.HTTP_REQUEST_PROPERTY_TOKEN_KEY, AuthParams.getUserToken()); @@ -105,33 +114,38 @@ private Object get() { responseMessage = response.toString(); responseArray[2] = responseMessage; } - } catch (Exception e) { - e.printStackTrace(); + } catch (ApplicationException | IOException e) { + log.log(Level.SEVERE, e.getMessage()); } - + + catch (Exception e) { + log.log(Level.SEVERE, e.getMessage()); + } + return responseArray; } - /** * Method used to call HTTP Post request + * * @param apiName * @param params * @param body * @return String[] containing responseCode, responseMessage and response object + * @throws IOException + * @throws ApplicationException */ public Object post() { String finalURL = ""; - if (isAdmin) { - AuthParams.setAdminCredentials(); - finalURL = generateAdminURL(apiName, params); - } else { - AuthParams.setRegistryCredentials(); - finalURL = generateURL(apiName, params); - } - try { - System.out.println(finalURL); + if (isAdmin) { + AuthParams.setAdminCredentials(); + finalURL = generateAdminURL(apiName, params); + } else { + AuthParams.setRegistryCredentials(); + finalURL = generateURL(apiName, params); + } + URL obj = new URL(finalURL); SetHttpConnection setCon = new SetHttpConnection(); HttpsURLConnection con = setCon.getConnection(obj); @@ -169,31 +183,34 @@ public Object post() { responseMessage = response.toString(); responseArray[2] = responseMessage; } + } catch (ApplicationException | IOException e) { + log.log(Level.SEVERE, e.getMessage()); } catch (Exception e) { - e.printStackTrace(); + log.log(Level.SEVERE, e.getMessage()); } - + return responseArray; } - /** * Method used to call HTTP delete request + * * @param apiName * @param params * @return String[] containing responseCode, responseMessage and response object + * @throws IOException + * @throws ApplicationException */ public Object delete() { String finalURL = ""; - if (isAdmin) { - AuthParams.setAdminCredentials(); - finalURL = generateAdminURL(apiName, params); - } else { - AuthParams.setRegistryCredentials(); - finalURL = generateURL(apiName, params); - } try { - System.out.println(finalURL); + if (isAdmin) { + AuthParams.setAdminCredentials(); + finalURL = generateAdminURL(apiName, params); + } else { + AuthParams.setRegistryCredentials(); + finalURL = generateURL(apiName, params); + } URL obj = new URL(finalURL); SetHttpConnection setCon = new SetHttpConnection(); HttpsURLConnection con = setCon.getConnection(obj); @@ -226,25 +243,29 @@ public Object delete() { responseMessage = response.toString(); responseArray[2] = responseMessage; } + } catch (ApplicationException | IOException e) { + log.log(Level.SEVERE, e.getMessage()); } catch (Exception e) { - e.printStackTrace(); + log.log(Level.SEVERE, e.getMessage()); } - + return responseArray; } - + /** * Method used to call HTTP Patch request + * * @param apiName * @param params * @param body - * @return String[] Object containing responseCode, responseMessage and response object + * @return String[] Object containing responseCode, responseMessage and response + * object */ public Object update() { - AuthParams.setRegistryCredentials(); - String finalURL = generateURL(apiName, params); try { - System.out.println(finalURL); + AuthParams.setRegistryCredentials(); + String finalURL = generateURL(apiName, params); + URL obj = new URL(finalURL); SetHttpConnection setCon = new SetHttpConnection(); HttpsURLConnection con = setCon.getConnection(obj); @@ -279,34 +300,37 @@ public Object update() { responseMessage = response.toString(); responseArray[2] = responseMessage; } + } catch (ApplicationException | IOException e) { + log.log(Level.SEVERE, e.getMessage()); } catch (Exception e) { - e.printStackTrace(); + log.log(Level.SEVERE, e.getMessage()); } - + return responseArray; - } - private Future getObjectAsync() { + } + + private Future getDeviceAsync() { return CompletableFuture.supplyAsync(this::get); } - public String[] asyncGet(String apiName,String params) throws InterruptedException { + public String[] asyncGetDevice(String apiName, String params) throws InterruptedException { this.apiName = apiName; this.params = params; - Future future = getObjectAsync(); + Future future = getDeviceAsync(); try { future.get(15000, TimeUnit.MILLISECONDS); } catch (InterruptedException | ExecutionException | TimeoutException e) { - e.printStackTrace(); + log.log(Level.SEVERE, e.getMessage()); Thread.currentThread().interrupt(); } return responseArray; } - + private Future createObjectAsync() { return CompletableFuture.supplyAsync(this::post); } - public String[] asyncCreate(String apiName,String params,String body) throws InterruptedException { + public String[] asyncCreate(String apiName, String params, String body) throws InterruptedException { this.apiName = apiName; this.params = params; this.body = body; @@ -314,7 +338,7 @@ public String[] asyncCreate(String apiName,String params,String body) throws Int try { future.get(15000, TimeUnit.MILLISECONDS); } catch (InterruptedException | ExecutionException | TimeoutException e) { - e.printStackTrace(); + log.log(Level.SEVERE, e.getMessage()); Thread.currentThread().interrupt(); } return responseArray; @@ -324,7 +348,7 @@ private Future bindDeviceToGatewayObjectAsync() { return CompletableFuture.supplyAsync(this::post); } - public String[] asyncBindDeviceToGateway(String apiName,String params,String body) throws InterruptedException { + public String[] asyncBindDeviceToGateway(String apiName, String params, String body) throws InterruptedException { this.apiName = apiName; this.params = params; this.body = body; @@ -332,7 +356,7 @@ public String[] asyncBindDeviceToGateway(String apiName,String params,String bod try { future.get(15000, TimeUnit.MILLISECONDS); } catch (InterruptedException | ExecutionException | TimeoutException e) { - e.printStackTrace(); + log.log(Level.SEVERE, e.getMessage()); Thread.currentThread().interrupt(); } return responseArray; @@ -351,7 +375,7 @@ public String[] asyncUnbindDeviceFromGateway(String apiName, String params, Stri try { future.get(15000, TimeUnit.MILLISECONDS); } catch (InterruptedException | ExecutionException | TimeoutException e) { - e.printStackTrace(); + log.log(Level.SEVERE, e.getMessage()); Thread.currentThread().interrupt(); } return responseArray; @@ -369,7 +393,7 @@ public String[] asyncSendCommandToDevice(String apiName, String params, String b try { future.get(15000, TimeUnit.MILLISECONDS); } catch (InterruptedException | ExecutionException | TimeoutException e) { - e.printStackTrace(); + log.log(Level.SEVERE, e.getMessage()); Thread.currentThread().interrupt(); } return responseArray; @@ -388,7 +412,7 @@ public String[] asyncModifyCloudToDeviceConfig(String apiName, String params, St try { future.get(15000, TimeUnit.MILLISECONDS); } catch (InterruptedException | ExecutionException | TimeoutException e) { - e.printStackTrace(); + log.log(Level.SEVERE, e.getMessage()); Thread.currentThread().interrupt(); } return responseArray; @@ -406,33 +430,34 @@ public String[] asyncListDeviceStates(String apiName, String params) try { future.get(15000, TimeUnit.MILLISECONDS); } catch (InterruptedException | ExecutionException | TimeoutException e) { - e.printStackTrace(); + log.log(Level.SEVERE, e.getMessage()); Thread.currentThread().interrupt(); } return responseArray; } + private Future deleteObjectAsync() { return CompletableFuture.supplyAsync(this::delete); } - public String[] asyncDelete(String apiName,String params) throws InterruptedException { + public String[] asyncDelete(String apiName, String params) throws InterruptedException { this.apiName = apiName; this.params = params; Future future = deleteObjectAsync(); try { future.get(15000, TimeUnit.MILLISECONDS); } catch (InterruptedException | ExecutionException | TimeoutException e) { - e.printStackTrace(); + log.log(Level.SEVERE, e.getMessage()); Thread.currentThread().interrupt(); } return responseArray; } - + private Future updateObjectAsync() { return CompletableFuture.supplyAsync(this::update); } - public String[] asyncUpdate(String apiName,String params,String body) throws InterruptedException { + public String[] asyncUpdate(String apiName, String params, String body) throws InterruptedException { this.apiName = apiName; this.params = params; this.body = body; @@ -440,23 +465,24 @@ public String[] asyncUpdate(String apiName,String params,String body) throws Int try { future.get(15000, TimeUnit.MILLISECONDS); } catch (InterruptedException | ExecutionException | TimeoutException e) { - e.printStackTrace(); + log.log(Level.SEVERE, e.getMessage()); Thread.currentThread().interrupt(); } return responseArray; } + private Future listObjectAsync() { return CompletableFuture.supplyAsync(this::get); } - public String[] asyncListDevices(String apiName,String params) throws InterruptedException { + public String[] asyncListDevices(String apiName, String params) throws InterruptedException { this.apiName = apiName; this.params = params; Future future = listObjectAsync(); try { future.get(15000, TimeUnit.MILLISECONDS); } catch (InterruptedException | ExecutionException | TimeoutException e) { - e.printStackTrace(); + log.log(Level.SEVERE, e.getMessage()); Thread.currentThread().interrupt(); } return responseArray; @@ -474,7 +500,7 @@ public String[] asyncListDeviceConfigVersions(String apiName, String params) try { future.get(15000, TimeUnit.MILLISECONDS); } catch (InterruptedException | ExecutionException | TimeoutException e) { - e.printStackTrace(); + log.log(Level.SEVERE, e.getMessage()); Thread.currentThread().interrupt(); } return responseArray; @@ -486,14 +512,14 @@ private Future getRegistryAsync() { return CompletableFuture.supplyAsync(this::get); } - public String[] asyncGetRegistry(String apiName,String params) throws InterruptedException { + public String[] asyncGetRegistry(String apiName, String params) throws InterruptedException { this.apiName = apiName; this.params = params; Future future = getRegistryAsync(); try { future.get(15000, TimeUnit.MILLISECONDS); } catch (InterruptedException | ExecutionException | TimeoutException e) { - e.printStackTrace(); + log.log(Level.SEVERE, e.getMessage()); Thread.currentThread().interrupt(); } return responseArray; @@ -513,7 +539,7 @@ public String[] asyncCreateDeviceRegistry(String apiName, String params, String try { future.get(15000, TimeUnit.MILLISECONDS); } catch (InterruptedException | ExecutionException | TimeoutException e) { - e.printStackTrace(); + log.log(Level.SEVERE, e.getMessage()); Thread.currentThread().interrupt(); } return responseArray; @@ -532,7 +558,7 @@ public String[] asyncUpdateDeviceRegistry(String apiName, String params, String try { future.get(15000, TimeUnit.MILLISECONDS); } catch (InterruptedException | ExecutionException | TimeoutException e) { - e.printStackTrace(); + log.log(Level.SEVERE, e.getMessage()); Thread.currentThread().interrupt(); } return responseArray; @@ -552,16 +578,17 @@ public String[] asyncDeleteDeviceRegistry(String apiName, String params, String try { future.get(15000, TimeUnit.MILLISECONDS); } catch (InterruptedException | ExecutionException | TimeoutException e) { - e.printStackTrace(); + log.log(Level.SEVERE, e.getMessage()); Thread.currentThread().interrupt(); } return responseArray; } + private Future listDeviceRegistriesAsync() { return CompletableFuture.supplyAsync(this::get); } - public String[] asyncListDeviceRegistries(String apiName, String params,boolean isAdmin) + public String[] asyncListDeviceRegistries(String apiName, String params, boolean isAdmin) throws InterruptedException { this.apiName = apiName; this.params = params; @@ -570,10 +597,10 @@ public String[] asyncListDeviceRegistries(String apiName, String params,boolean try { future.get(15000, TimeUnit.MILLISECONDS); } catch (InterruptedException | ExecutionException | TimeoutException e) { - e.printStackTrace(); + log.log(Level.SEVERE, e.getMessage()); Thread.currentThread().interrupt(); } return responseArray; } - + } diff --git a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/ClearBladeDeviceManager.java b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/ClearBladeDeviceManager.java index 576e3155..5eaa883f 100644 --- a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/ClearBladeDeviceManager.java +++ b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/ClearBladeDeviceManager.java @@ -1,5 +1,8 @@ package com.clearblade.cloud.iot.v1; +import java.util.logging.Level; +import java.util.logging.Logger; + import com.clearblade.cloud.iot.v1.binddevicetogateway.BindDeviceToGatewayRequest; import com.clearblade.cloud.iot.v1.binddevicetogateway.BindDeviceToGatewayResponse; import com.clearblade.cloud.iot.v1.createdevice.CreateDeviceRequest; @@ -8,6 +11,8 @@ import com.clearblade.cloud.iot.v1.deviceslist.DevicesListResponse; import com.clearblade.cloud.iot.v1.devicestateslist.ListDeviceStatesRequest; import com.clearblade.cloud.iot.v1.devicestateslist.ListDeviceStatesResponse; +import com.clearblade.cloud.iot.v1.devicetypes.Device; +import com.clearblade.cloud.iot.v1.devicetypes.DeviceConfig; import com.clearblade.cloud.iot.v1.getdevice.GetDeviceRequest; import com.clearblade.cloud.iot.v1.listdeviceconfigversions.ListDeviceConfigVersionsRequest; import com.clearblade.cloud.iot.v1.listdeviceconfigversions.ListDeviceConfigVersionsResponse; @@ -20,21 +25,21 @@ import com.clearblade.cloud.iot.v1.unbinddevicefromgateway.UnbindDeviceFromGatewayResponse; import com.clearblade.cloud.iot.v1.updatedevice.UpdateDeviceRequest; import com.clearblade.cloud.iot.v1.utils.ConfigParameters; -import com.clearblade.cloud.iot.v1.utils.Device; -import com.clearblade.cloud.iot.v1.utils.DeviceConfig; public class ClearBladeDeviceManager { + static Logger log = Logger.getLogger(ClearBladeDeviceManager.class.getName()); ConfigParameters configParameters = new ConfigParameters(); - public Device getDevice(GetDeviceRequest request) { SyncClient syncClient = new SyncClient(); - String[] responseArray = syncClient.get(configParameters.getDevicesURLExtension(), request.toString(),false); - int responseCode = Integer.parseInt(responseArray[0]); - if(responseCode == 200) { - Device device = Device.newBuilder().build(); - device.loadFromString(responseArray[2]); - return device; + String[] responseArray = syncClient.get(configParameters.getDevicesURLExtension(), request.toString(), false); + if (responseArray[0] != null) { + int responseCode = Integer.parseInt(responseArray[0]); + if (responseCode == 200) { + Device device = Device.newBuilder().build(); + device.loadFromString(responseArray[2]); + return device; + } } return null; } @@ -42,16 +47,18 @@ public Device getDevice(GetDeviceRequest request) { public Device asyncGetDevice(GetDeviceRequest request) { try { AsyncClient asyncClient = new AsyncClient(); - String[] responseArray = asyncClient.asyncGet(configParameters.getDevicesURLExtension(), + String[] responseArray = asyncClient.asyncGetDevice(configParameters.getDevicesURLExtension(), request.toString()); - int responseCode = Integer.parseInt(responseArray[0]); - if(responseCode == 200) { - Device device = Device.newBuilder().build(); - device.loadFromString(responseArray[2]); - return device; + if (responseArray[0] != null) { + int responseCode = Integer.parseInt(responseArray[0]); + if (responseCode == 200) { + Device device = Device.newBuilder().build(); + device.loadFromString(responseArray[2]); + return device; + } } - }catch(Exception e) { - e.printStackTrace(); + } catch (Exception e) { + log.log(Level.SEVERE, e.getMessage()); } return null; } @@ -62,11 +69,13 @@ public Device createDevice(CreateDeviceRequest request) { String reqParams = params[0]; String body = params[1]; String[] responseArray = syncClient.post(configParameters.getDevicesURLExtension(), reqParams, body, false); - int responseCode = Integer.parseInt(responseArray[0]); - if (responseCode == 200) { - Device deviceObj = Device.newBuilder().build(); - deviceObj.loadFromString(responseArray[2]); - return deviceObj; + if (responseArray[0] != null) { + int responseCode = Integer.parseInt(responseArray[0]); + if (responseCode == 200) { + Device deviceObj = Device.newBuilder().build(); + deviceObj.loadFromString(responseArray[2]); + return deviceObj; + } } return null; } @@ -79,23 +88,27 @@ public Device asyncCreateDevice(CreateDeviceRequest request) { String body = params[1]; String[] responseArray = asyncClient.asyncCreate(configParameters.getDevicesURLExtension(), reqParams, body); - int responseCode = Integer.parseInt(responseArray[0]); - if (responseCode == 200) { - Device deviceObj = Device.newBuilder().build(); - deviceObj.loadFromString(responseArray[2]); - return deviceObj; + if (responseArray[0] != null) { + int responseCode = Integer.parseInt(responseArray[0]); + if (responseCode == 200) { + Device deviceObj = Device.newBuilder().build(); + deviceObj.loadFromString(responseArray[2]); + return deviceObj; + } } - }catch(Exception e) { - e.printStackTrace(); + } catch (Exception e) { + log.log(Level.SEVERE, e.getMessage()); } return null; } - + public void deleteDevice(DeleteDeviceRequest request) { SyncClient syncClient = new SyncClient(); - String[] responseArray = syncClient.delete(configParameters.getDevicesURLExtension(), request.toString(),false); - System.out.println( - "Response for delete is " + responseArray[0] + "::" + responseArray[1] + "::" + responseArray[2]); + String[] responseArray = syncClient.delete(configParameters.getDevicesURLExtension(), request.toString(), + false); + if (responseArray[0] != null) { + log.log(Level.INFO, "Response code " + responseArray[0] + " received with message" + responseArray[2]); + } } public void asyncDeleteDevice(DeleteDeviceRequest request) { @@ -103,10 +116,12 @@ public void asyncDeleteDevice(DeleteDeviceRequest request) { AsyncClient asyncClient = new AsyncClient(); String[] responseArray = asyncClient.asyncDelete(configParameters.getDevicesURLExtension(), request.toString()); - System.out.println( - "Response for delete is " + responseArray[0] + "::" + responseArray[1] + "::" + responseArray[2]); + if (responseArray[0] != null) { + log.log(Level.INFO, "Response code " + responseArray[0] + " received with message" + responseArray[2]); + } + } catch (Exception e) { - e.printStackTrace(); + log.log(Level.SEVERE, e.getMessage()); } } @@ -116,14 +131,17 @@ public Device updateDevice(UpdateDeviceRequest request) { String reqParams = params[0]; String body = params[1]; String[] responseArray = syncClient.update(configParameters.getDevicesURLExtension(), reqParams, body); - int responseCode = Integer.parseInt(responseArray[0]); - if (responseCode == 200) { - Device deviceObj = Device.newBuilder().build(); - deviceObj.loadFromString(responseArray[2]); - return deviceObj; + if (responseArray[0] != null) { + int responseCode = Integer.parseInt(responseArray[0]); + if (responseCode == 200) { + Device deviceObj = Device.newBuilder().build(); + deviceObj.loadFromString(responseArray[2]); + return deviceObj; + } } return null; } + public Device asyncUpdateDevice(UpdateDeviceRequest request) { try { AsyncClient asyncClient = new AsyncClient(); @@ -132,25 +150,30 @@ public Device asyncUpdateDevice(UpdateDeviceRequest request) { String body = params[1]; String[] responseArray = asyncClient.asyncUpdate(configParameters.getDevicesURLExtension(), reqParams, body); - int responseCode = Integer.parseInt(responseArray[0]); - if (responseCode == 200) { - Device deviceObj = Device.newBuilder().build(); - deviceObj.loadFromString(responseArray[2]); - return deviceObj; + if (responseArray[0] != null) { + int responseCode = Integer.parseInt(responseArray[0]); + if (responseCode == 200) { + Device deviceObj = Device.newBuilder().build(); + deviceObj.loadFromString(responseArray[2]); + return deviceObj; + } } - }catch(Exception e) { - e.printStackTrace(); + } catch (Exception e) { + log.log(Level.SEVERE, e.getMessage()); } return null; } + public BindDeviceToGatewayResponse bindDeviceToGateway(BindDeviceToGatewayRequest request) { SyncClient syncClient = new SyncClient(); String[] paramBody = request.getBodyAndParams(); String[] responseArray = syncClient.post(configParameters.getCloudiotURLExtension(), paramBody[0], paramBody[1], false); BindDeviceToGatewayResponse response = BindDeviceToGatewayResponse.Builder.newBuilder().build(); - response.setHttpStatusCode(Integer.parseInt(responseArray[0])); - response.setHttpStatusResponse(responseArray[1]); + if (responseArray[0] != null) { + response.setHttpStatusCode(Integer.parseInt(responseArray[0])); + response.setHttpStatusResponse(responseArray[1]); + } return response; } @@ -161,11 +184,13 @@ public BindDeviceToGatewayResponse asyncBindDeviceToGateway(BindDeviceToGatewayR String[] responseArray = asyncClient.asyncBindDeviceToGateway(configParameters.getCloudiotURLExtension(), paramBody[0], paramBody[1]); BindDeviceToGatewayResponse response = BindDeviceToGatewayResponse.Builder.newBuilder().build(); - response.setHttpStatusCode(Integer.parseInt(responseArray[0])); - response.setHttpStatusResponse(responseArray[1]); + if (responseArray[0] != null) { + response.setHttpStatusCode(Integer.parseInt(responseArray[0])); + response.setHttpStatusResponse(responseArray[1]); + } return response; - }catch(Exception e) { - e.printStackTrace(); + } catch (Exception e) { + log.log(Level.SEVERE, e.getMessage()); } return null; } @@ -176,8 +201,10 @@ public UnbindDeviceFromGatewayResponse unbindDeviceFromGateway(UnbindDeviceFromG String[] responseArray = syncClinet.post(configParameters.getCloudiotURLExtension(), paramBody[0], paramBody[1], false); UnbindDeviceFromGatewayResponse response = UnbindDeviceFromGatewayResponse.Builder.newBuilder().build(); - response.setHttpStatusCode(Integer.parseInt(responseArray[0])); - response.setHttpStatusResponse(responseArray[1]); + if (responseArray[0] != null) { + response.setHttpStatusCode(Integer.parseInt(responseArray[0])); + response.setHttpStatusResponse(responseArray[1]); + } return response; } @@ -188,11 +215,13 @@ public UnbindDeviceFromGatewayResponse asyncUnbindDeviceFromGateway(UnbindDevice String[] responseArray = asyncClinet.asyncUnbindDeviceFromGateway( configParameters.getCloudiotURLExtension(), paramBody[0], paramBody[1]); UnbindDeviceFromGatewayResponse response = UnbindDeviceFromGatewayResponse.Builder.newBuilder().build(); - response.setHttpStatusCode(Integer.parseInt(responseArray[0])); - response.setHttpStatusResponse(responseArray[1]); + if (responseArray[0] != null) { + response.setHttpStatusCode(Integer.parseInt(responseArray[0])); + response.setHttpStatusResponse(responseArray[1]); + } return response; - }catch(Exception e) { - e.printStackTrace(); + } catch (Exception e) { + log.log(Level.SEVERE, e.getMessage()); } return null; } @@ -202,10 +231,11 @@ public SendCommandToDeviceResponse sendCommandToDevice(SendCommandToDeviceReques String[] paramBody = request.getBodyAndParams(); String[] responseArray = syncClient.post(configParameters.getDevicesURLExtension(), paramBody[0], paramBody[1], false); - System.out.println(responseArray[2]); SendCommandToDeviceResponse response = SendCommandToDeviceResponse.Builder.newBuilder().build(); - response.setHttpStatusCode(Integer.parseInt(responseArray[0])); - response.setHttpStatusResponse(responseArray[1]); + if (responseArray[0] != null) { + response.setHttpStatusCode(Integer.parseInt(responseArray[0])); + response.setHttpStatusResponse(responseArray[1]); + } return response; } @@ -216,26 +246,30 @@ public SendCommandToDeviceResponse asyncSendCommandToDevice(SendCommandToDeviceR String[] responseArray = asyncClient.asyncSendCommandToDevice(configParameters.getDevicesURLExtension(), paramBody[0], paramBody[1]); - System.out.println(responseArray[2]); SendCommandToDeviceResponse response = SendCommandToDeviceResponse.Builder.newBuilder().build(); - response.setHttpStatusCode(Integer.parseInt(responseArray[0])); - response.setHttpStatusResponse(responseArray[1]); + if (responseArray[0] != null) { + response.setHttpStatusCode(Integer.parseInt(responseArray[0])); + response.setHttpStatusResponse(responseArray[1]); + } return response; } catch (Exception e) { - e.printStackTrace(); + log.log(Level.SEVERE, e.getMessage()); } return null; } public DevicesListResponse listDevices(DevicesListRequest request) { SyncClient syncClient = new SyncClient(); - String[] responseArray = syncClient.get(configParameters.getDevicesURLExtension(), request.getParamsForList(),false); - int responseCode = Integer.parseInt(responseArray[0]); - if (responseCode == 200) { - DevicesListResponse devicesListResponse = DevicesListResponse.Builder.newBuilder() - .buildResponse(responseArray[2]).build(); - // deviceObj.loadFromString(responseArray[2]); - return devicesListResponse; + String[] responseArray = syncClient.get(configParameters.getDevicesURLExtension(), request.getParamsForList(), + false); + if (responseArray[0] != null) { + int responseCode = Integer.parseInt(responseArray[0]); + if (responseCode == 200) { + DevicesListResponse devicesListResponse = DevicesListResponse.Builder.newBuilder() + .buildResponse(responseArray[2]).build(); + // deviceObj.loadFromString(responseArray[2]); + return devicesListResponse; + } } return null; } @@ -245,15 +279,17 @@ public DevicesListResponse asyncListDevices(DevicesListRequest request) { AsyncClient asyncClient = new AsyncClient(); String[] responseArray = asyncClient.asyncListDevices(configParameters.getDevicesURLExtension(), request.getParamsForList()); - int responseCode = Integer.parseInt(responseArray[0]); - if (responseCode == 200) { - DevicesListResponse devicesListResponse = DevicesListResponse.Builder.newBuilder() - .buildResponse(responseArray[2]).build(); - // deviceObj.loadFromString(responseArray[2]); - return devicesListResponse; + if (responseArray[0] != null) { + int responseCode = Integer.parseInt(responseArray[0]); + if (responseCode == 200) { + DevicesListResponse devicesListResponse = DevicesListResponse.Builder.newBuilder() + .buildResponse(responseArray[2]).build(); + // deviceObj.loadFromString(responseArray[2]); + return devicesListResponse; + } } - }catch(Exception e) { - e.printStackTrace(); + } catch (Exception e) { + log.log(Level.SEVERE, e.getMessage()); } return null; } @@ -263,10 +299,11 @@ public DeviceConfig modifyCloudToDeviceConfig(ModifyCloudToDeviceConfigRequest r String[] paramBody = request.getBodyAndParams(); String[] responseArray = syncClient.post(configParameters.getDevicesURLExtension(), paramBody[0], paramBody[1], false); - System.out.println(responseArray[2]); DeviceConfig deviceConfig = DeviceConfig.newBuilder().build(); - if (Integer.parseInt(responseArray[0]) == 200) - deviceConfig.loadFromString(responseArray[2]); + if (responseArray[0] != null) { + if (Integer.parseInt(responseArray[0]) == 200) + deviceConfig.loadFromString(responseArray[2]); + } return deviceConfig; } @@ -277,13 +314,14 @@ public DeviceConfig asyncModifyCloudToDeviceConfig(ModifyCloudToDeviceConfigRequ String[] responseArray = asyncClient.asyncModifyCloudToDeviceConfig( configParameters.getDevicesURLExtension(), paramBody[0], paramBody[1]); - System.out.println(responseArray[2]); DeviceConfig deviceConfig = DeviceConfig.newBuilder().build(); - if (Integer.parseInt(responseArray[0]) == 200) - deviceConfig.loadFromString(responseArray[2]); + if (responseArray[0] != null) { + if (Integer.parseInt(responseArray[0]) == 200) + deviceConfig.loadFromString(responseArray[2]); + } return deviceConfig; } catch (Exception e) { - e.printStackTrace(); + log.log(Level.SEVERE, e.getMessage()); } return null; } @@ -291,13 +329,15 @@ public DeviceConfig asyncModifyCloudToDeviceConfig(ModifyCloudToDeviceConfigRequ public ListDeviceStatesResponse listDeviceStates(ListDeviceStatesRequest request) { SyncClient syncClient = new SyncClient(); String[] responseArray = syncClient.get(configParameters.getDevicesStatesURLExtension(), - request.getParamsForList(),false); - int responseCode = Integer.parseInt(responseArray[0]); - if (responseCode == 200) { - ListDeviceStatesResponse listDeviceStatesResponse = ListDeviceStatesResponse.Builder.newBuilder() - .buildResponse(responseArray[2]).build(); - // deviceObj.loadFromString(responseArray[2]); - return listDeviceStatesResponse; + request.getParamsForList(), false); + if (responseArray[0] != null) { + int responseCode = Integer.parseInt(responseArray[0]); + if (responseCode == 200) { + ListDeviceStatesResponse listDeviceStatesResponse = ListDeviceStatesResponse.Builder.newBuilder() + .buildResponse(responseArray[2]).build(); + // deviceObj.loadFromString(responseArray[2]); + return listDeviceStatesResponse; + } } return null; } @@ -307,15 +347,17 @@ public ListDeviceStatesResponse asyncListDeviceStates(ListDeviceStatesRequest re AsyncClient asyncClient = new AsyncClient(); String[] responseArray = asyncClient.asyncListDeviceStates(configParameters.getDevicesStatesURLExtension(), request.getParamsForList()); - int responseCode = Integer.parseInt(responseArray[0]); - if (responseCode == 200) { - ListDeviceStatesResponse listDeviceStatesResponse = ListDeviceStatesResponse.Builder.newBuilder() - .buildResponse(responseArray[2]).build(); - // deviceObj.loadFromString(responseArray[2]); - return listDeviceStatesResponse; + if (responseArray[0] != null) { + int responseCode = Integer.parseInt(responseArray[0]); + if (responseCode == 200) { + ListDeviceStatesResponse listDeviceStatesResponse = ListDeviceStatesResponse.Builder.newBuilder() + .buildResponse(responseArray[2]).build(); + // deviceObj.loadFromString(responseArray[2]); + return listDeviceStatesResponse; + } } } catch (Exception e) { - e.printStackTrace(); + log.log(Level.SEVERE, e.getMessage()); } return null; } @@ -323,14 +365,16 @@ public ListDeviceStatesResponse asyncListDeviceStates(ListDeviceStatesRequest re public ListDeviceConfigVersionsResponse listDeviceConfigVersions(ListDeviceConfigVersionsRequest request) { SyncClient syncClient = new SyncClient(); String[] responseArray = syncClient.get(configParameters.getCloudiotConfigURLExtension(), - request.getParamsForList(),false); - int responseCode = Integer.parseInt(responseArray[0]); - if (responseCode == 200) { - ListDeviceConfigVersionsResponse listDeviceConfigVersionsResponse = ListDeviceConfigVersionsResponse.Builder - .newBuilder() - .buildResponse(responseArray[2]).build(); - // deviceObj.loadFromString(responseArray[2]); - return listDeviceConfigVersionsResponse; + request.getParamsForList(), false); + if (responseArray[0] != null) { + int responseCode = Integer.parseInt(responseArray[0]); + if (responseCode == 200) { + ListDeviceConfigVersionsResponse listDeviceConfigVersionsResponse = ListDeviceConfigVersionsResponse.Builder + .newBuilder() + .buildResponse(responseArray[2]).build(); + // deviceObj.loadFromString(responseArray[2]); + return listDeviceConfigVersionsResponse; + } } return null; } @@ -341,28 +385,34 @@ public ListDeviceConfigVersionsResponse asyncListDeviceConfigVersions(ListDevice String[] responseArray = asyncClient.asyncListDeviceConfigVersions( configParameters.getCloudiotConfigURLExtension(), request.getParamsForList()); - int responseCode = Integer.parseInt(responseArray[0]); - if (responseCode == 200) { - ListDeviceConfigVersionsResponse listDeviceConfigVersionsResponse = ListDeviceConfigVersionsResponse.Builder - .newBuilder() - .buildResponse(responseArray[2]).build(); - // deviceObj.loadFromString(responseArray[2]); - return listDeviceConfigVersionsResponse; + if (responseArray[0] != null) { + int responseCode = Integer.parseInt(responseArray[0]); + if (responseCode == 200) { + ListDeviceConfigVersionsResponse listDeviceConfigVersionsResponse = ListDeviceConfigVersionsResponse.Builder + .newBuilder() + .buildResponse(responseArray[2]).build(); + // deviceObj.loadFromString(responseArray[2]); + return listDeviceConfigVersionsResponse; + } } - }catch(Exception e) { - e.printStackTrace(); + } catch (Exception e) { + log.log(Level.SEVERE, e.getMessage()); } return null; } public ListDeviceRegistriesResponse listDeviceRegistries(ListDeviceRegistriesRequest request) { SyncClient syncClient = new SyncClient(); - String[] responseArray = syncClient.get(configParameters.getCloudiotURLExtension(), request.getParamsForList(),true); - int responseCode = Integer.parseInt(responseArray[0]); - if (responseCode == 200) { - ListDeviceRegistriesResponse deviceRegistriesListResponse = ListDeviceRegistriesResponse.Builder.newBuilder() - .buildResponse(responseArray[2]).build(); - return deviceRegistriesListResponse; + String[] responseArray = syncClient.get(configParameters.getCloudiotURLExtension(), request.getParamsForList(), + true); + if (responseArray[0] != null) { + int responseCode = Integer.parseInt(responseArray[0]); + if (responseCode == 200) { + ListDeviceRegistriesResponse deviceRegistriesListResponse = ListDeviceRegistriesResponse.Builder + .newBuilder() + .buildResponse(responseArray[2]).build(); + return deviceRegistriesListResponse; + } } return null; } @@ -370,15 +420,19 @@ public ListDeviceRegistriesResponse listDeviceRegistries(ListDeviceRegistriesReq public ListDeviceRegistriesResponse asyncListDeviceRegistries(ListDeviceRegistriesRequest request) { try { AsyncClient asyncClient = new AsyncClient(); - String[] responseArray = asyncClient.asyncListDeviceRegistries(configParameters.getCloudiotURLExtension(), request.getParamsForList(),true); - int responseCode = Integer.parseInt(responseArray[0]); - if (responseCode == 200) { - ListDeviceRegistriesResponse deviceRegistriesListResponse = ListDeviceRegistriesResponse.Builder.newBuilder() - .buildResponse(responseArray[2]).build(); - return deviceRegistriesListResponse; + String[] responseArray = asyncClient.asyncListDeviceRegistries(configParameters.getCloudiotURLExtension(), + request.getParamsForList(), true); + if (responseArray[0] != null) { + int responseCode = Integer.parseInt(responseArray[0]); + if (responseCode == 200) { + ListDeviceRegistriesResponse deviceRegistriesListResponse = ListDeviceRegistriesResponse.Builder + .newBuilder() + .buildResponse(responseArray[2]).build(); + return deviceRegistriesListResponse; + } } - }catch(Exception e) { - e.printStackTrace(); + } catch (Exception e) { + log.log(Level.SEVERE, e.getMessage()); } return null; } diff --git a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/ClearBladeRegistryManager.java b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/ClearBladeRegistryManager.java index b3d975e6..4945f89c 100644 --- a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/ClearBladeRegistryManager.java +++ b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/ClearBladeRegistryManager.java @@ -1,24 +1,29 @@ package com.clearblade.cloud.iot.v1; +import java.util.logging.Level; +import java.util.logging.Logger; + import com.clearblade.cloud.iot.v1.createdeviceregistry.CreateDeviceRegistryRequest; import com.clearblade.cloud.iot.v1.deletedeviceregistry.DeleteDeviceRegistryRequest; import com.clearblade.cloud.iot.v1.getdeviceregistry.GetDeviceRegistryRequest; +import com.clearblade.cloud.iot.v1.registrytypes.DeviceRegistry; import com.clearblade.cloud.iot.v1.updatedeviceregistry.UpdateDeviceRegistryRequest; import com.clearblade.cloud.iot.v1.utils.ConfigParameters; -import com.clearblade.cloud.iot.v1.utils.DeviceRegistry; public class ClearBladeRegistryManager { + static Logger log = Logger.getLogger(ClearBladeRegistryManager.class.getName()); ConfigParameters configParameters = new ConfigParameters(); - public DeviceRegistry getRegistry(GetDeviceRegistryRequest request) { SyncClient syncClient = new SyncClient(); - String[] responseArray = syncClient.get(configParameters.getCloudiotURLExtension(), request.toString(),false); - int responseCode = Integer.parseInt(responseArray[0]); - if(responseCode == 200) { - DeviceRegistry deviceRegistry = DeviceRegistry.newBuilder().build(); - deviceRegistry.loadFromString(responseArray[2]); - return deviceRegistry; + String[] responseArray = syncClient.get(configParameters.getCloudiotURLExtension(), request.toString(), false); + if (responseArray[0] != null) { + int responseCode = Integer.parseInt(responseArray[0]); + if (responseCode == 200) { + DeviceRegistry deviceRegistry = DeviceRegistry.newBuilder().build(); + deviceRegistry.loadFromString(responseArray[2]); + return deviceRegistry; + } } return null; } @@ -28,14 +33,16 @@ public DeviceRegistry asyncGetDeviceRegistry(GetDeviceRegistryRequest request) { AsyncClient asyncClient = new AsyncClient(); String[] responseArray = asyncClient.asyncGetRegistry(configParameters.getCloudiotURLExtension(), request.toString()); - int responseCode = Integer.parseInt(responseArray[0]); - if(responseCode == 200) { - DeviceRegistry deviceRegistry = DeviceRegistry.newBuilder().build(); - deviceRegistry.loadFromString(responseArray[2]); - return deviceRegistry; + if (responseArray[0] != null) { + int responseCode = Integer.parseInt(responseArray[0]); + if (responseCode == 200) { + DeviceRegistry deviceRegistry = DeviceRegistry.newBuilder().build(); + deviceRegistry.loadFromString(responseArray[2]); + return deviceRegistry; + } } - }catch(Exception e) { - e.printStackTrace(); + } catch (Exception e) { + log.log(Level.SEVERE, e.getMessage()); } return null; } @@ -43,16 +50,16 @@ public DeviceRegistry asyncGetDeviceRegistry(GetDeviceRegistryRequest request) { public DeviceRegistry createDeviceRegistry(CreateDeviceRegistryRequest request) { SyncClient syncClient = new SyncClient(); String[] bodyParams = request.getBodyAndParams(); - System.out.println(bodyParams[0]); - System.out.println(bodyParams[1]); String[] responseArray = syncClient.post(configParameters.getCloudiotURLExtension(), bodyParams[0], bodyParams[1], true); - int responseCode = Integer.parseInt(responseArray[0]); - if (responseCode == 200) { - DeviceRegistry deviceRegistry = DeviceRegistry.newBuilder().build(); - deviceRegistry.loadFromString(responseArray[2]); - return deviceRegistry; + if (responseArray[0] != null) { + int responseCode = Integer.parseInt(responseArray[0]); + if (responseCode == 200) { + DeviceRegistry deviceRegistry = DeviceRegistry.newBuilder().build(); + deviceRegistry.loadFromString(responseArray[2]); + return deviceRegistry; + } } return null; } @@ -61,20 +68,20 @@ public DeviceRegistry asyncCreateDeviceRegistry(CreateDeviceRegistryRequest requ try { AsyncClient asyncClient = new AsyncClient(); String[] bodyParams = request.getBodyAndParams(); - System.out.println(bodyParams[0]); - System.out.println(bodyParams[1]); String[] responseArray = asyncClient.asyncCreateDeviceRegistry(configParameters.getCloudiotURLExtension(), bodyParams[0], bodyParams[1], true); - int responseCode = Integer.parseInt(responseArray[0]); - if (responseCode == 200) { - DeviceRegistry deviceRegistry = DeviceRegistry.newBuilder().build(); - deviceRegistry.loadFromString(responseArray[2]); - return deviceRegistry; + if (responseArray[0] != null) { + int responseCode = Integer.parseInt(responseArray[0]); + if (responseCode == 200) { + DeviceRegistry deviceRegistry = DeviceRegistry.newBuilder().build(); + deviceRegistry.loadFromString(responseArray[2]); + return deviceRegistry; + } } - }catch(Exception e) { - e.printStackTrace(); + } catch (Exception e) { + log.log(Level.SEVERE, e.getMessage()); } return null; } @@ -82,18 +89,16 @@ public DeviceRegistry asyncCreateDeviceRegistry(CreateDeviceRegistryRequest requ public DeviceRegistry updateDeviceRegistry(UpdateDeviceRegistryRequest request) { SyncClient syncClient = new SyncClient(); String[] bodyParams = request.getBodyAndParams(); - System.out.println(bodyParams[0]); - System.out.println(bodyParams[1]); String[] responseArray = syncClient.update(configParameters.getCloudiotURLExtension(), bodyParams[0], bodyParams[1]); - int responseCode = Integer.parseInt(responseArray[0]); - if (responseCode == 200) { - DeviceRegistry deviceRegistry = DeviceRegistry.newBuilder().build(); - deviceRegistry.loadFromString(responseArray[2]); - return deviceRegistry; - }else { - System.out.println("Registry doesn't get updated::"+responseArray[2]); + if (responseArray[0] != null) { + int responseCode = Integer.parseInt(responseArray[0]); + if (responseCode == 200) { + DeviceRegistry deviceRegistry = DeviceRegistry.newBuilder().build(); + deviceRegistry.loadFromString(responseArray[2]); + return deviceRegistry; + } } return null; } @@ -102,47 +107,49 @@ public DeviceRegistry asyncUpdateDeviceRegistry(UpdateDeviceRegistryRequest requ try { AsyncClient asyncClient = new AsyncClient(); String[] bodyParams = request.getBodyAndParams(); - System.out.println(bodyParams[0]); - System.out.println(bodyParams[1]); - - String[] responseArray = asyncClient.asyncUpdateDeviceRegistry(configParameters.getCloudiotURLExtension(), bodyParams[0], + + String[] responseArray = asyncClient.asyncUpdateDeviceRegistry(configParameters.getCloudiotURLExtension(), + bodyParams[0], bodyParams[1]); - int responseCode = Integer.parseInt(responseArray[0]); - if (responseCode == 200) { - DeviceRegistry deviceRegistry = DeviceRegistry.newBuilder().build(); - deviceRegistry.loadFromString(responseArray[2]); - return deviceRegistry; - }else { - System.out.println("Registry doesn't get updated::"+responseArray[2]); + if (responseArray[0] != null) { + int responseCode = Integer.parseInt(responseArray[0]); + if (responseCode == 200) { + DeviceRegistry deviceRegistry = DeviceRegistry.newBuilder().build(); + deviceRegistry.loadFromString(responseArray[2]); + return deviceRegistry; + } } - }catch(Exception e) { - e.printStackTrace(); + } catch (Exception e) { + log.log(Level.SEVERE, e.getMessage()); } return null; } - + public void deleteDeviceRegistry(DeleteDeviceRegistryRequest request) { SyncClient syncClient = new SyncClient(); String bodyParams = request.getParams(); - System.out.println(bodyParams); String[] responseArray = syncClient.delete(configParameters.getCloudiotURLExtension(), bodyParams, true); - System.out.println( - "Response for delete is " + responseArray[0] + "::" + responseArray[1] + "::" + responseArray[2]); + if (responseArray[0] != null) { + log.log(Level.INFO, "Response code " + responseArray[0] + " received with message" + responseArray[2]); + } + } public void asyncDeleteDeviceRegistry(DeleteDeviceRegistryRequest request) { try { AsyncClient asyncClient = new AsyncClient(); String bodyParams = request.getParams(); - System.out.println(bodyParams); - - String[] responseArray = asyncClient.asyncDeleteDeviceRegistry(configParameters.getCloudiotURLExtension(), bodyParams, + + String[] responseArray = asyncClient.asyncDeleteDeviceRegistry(configParameters.getCloudiotURLExtension(), + bodyParams, "", true); - System.out.println( - "Response for delete is " + responseArray[0] + "::" + responseArray[1] + "::" + responseArray[2]); - }catch(Exception e) { - e.printStackTrace(); + if (responseArray[0] != null) { + log.log(Level.INFO, "Response code " + responseArray[0] + " received with message" + responseArray[2]); + } + + } catch (Exception e) { + log.log(Level.SEVERE, e.getMessage()); } } } diff --git a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/DeviceManagerAsyncClient.java b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/DeviceManagerAsyncClient.java index e3fd511a..ac7918ca 100644 --- a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/DeviceManagerAsyncClient.java +++ b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/DeviceManagerAsyncClient.java @@ -12,6 +12,8 @@ import com.clearblade.cloud.iot.v1.deviceslist.DevicesListResponse; import com.clearblade.cloud.iot.v1.devicestateslist.ListDeviceStatesRequest; import com.clearblade.cloud.iot.v1.devicestateslist.ListDeviceStatesResponse; +import com.clearblade.cloud.iot.v1.devicetypes.Device; +import com.clearblade.cloud.iot.v1.devicetypes.DeviceConfig; import com.clearblade.cloud.iot.v1.getdevice.GetDeviceRequest; import com.clearblade.cloud.iot.v1.getdeviceregistry.GetDeviceRegistryRequest; import com.clearblade.cloud.iot.v1.listdeviceconfigversions.ListDeviceConfigVersionsRequest; @@ -19,15 +21,13 @@ import com.clearblade.cloud.iot.v1.listdeviceregistries.ListDeviceRegistriesRequest; import com.clearblade.cloud.iot.v1.listdeviceregistries.ListDeviceRegistriesResponse; import com.clearblade.cloud.iot.v1.modifycloudtodeviceconfig.ModifyCloudToDeviceConfigRequest; +import com.clearblade.cloud.iot.v1.registrytypes.DeviceRegistry; import com.clearblade.cloud.iot.v1.sendcommandtodevice.SendCommandToDeviceRequest; import com.clearblade.cloud.iot.v1.sendcommandtodevice.SendCommandToDeviceResponse; import com.clearblade.cloud.iot.v1.unbinddevicefromgateway.UnbindDeviceFromGatewayRequest; import com.clearblade.cloud.iot.v1.unbinddevicefromgateway.UnbindDeviceFromGatewayResponse; import com.clearblade.cloud.iot.v1.updatedevice.UpdateDeviceRequest; import com.clearblade.cloud.iot.v1.updatedeviceregistry.UpdateDeviceRegistryRequest; -import com.clearblade.cloud.iot.v1.utils.Device; -import com.clearblade.cloud.iot.v1.utils.DeviceConfig; -import com.clearblade.cloud.iot.v1.utils.DeviceRegistry; public class DeviceManagerAsyncClient { @@ -68,6 +68,7 @@ public void deleteDevice(DeleteDeviceRequest request) { /** * Calling updateDevice api + * * @param request * @return Device object */ @@ -123,8 +124,8 @@ public ListDeviceConfigVersionsResponse listDeviceConfigVersions(ListDeviceConfi ClearBladeDeviceManager cbManager = new ClearBladeDeviceManager(); return cbManager.asyncListDeviceConfigVersions(request); } - - //Registry Apis + + // Registry Apis /** * Calling getDevice api * diff --git a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/DeviceManagerClient.java b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/DeviceManagerClient.java index 5a61075a..381e30c1 100644 --- a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/DeviceManagerClient.java +++ b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/DeviceManagerClient.java @@ -1,5 +1,6 @@ package com.clearblade.cloud.iot.v1; +import java.io.IOException; import java.util.logging.Logger; import com.clearblade.cloud.iot.v1.binddevicetogateway.BindDeviceToGatewayRequest; @@ -12,6 +13,9 @@ import com.clearblade.cloud.iot.v1.deviceslist.DevicesListResponse; import com.clearblade.cloud.iot.v1.devicestateslist.ListDeviceStatesRequest; import com.clearblade.cloud.iot.v1.devicestateslist.ListDeviceStatesResponse; +import com.clearblade.cloud.iot.v1.devicetypes.Device; +import com.clearblade.cloud.iot.v1.devicetypes.DeviceConfig; +import com.clearblade.cloud.iot.v1.exception.ApplicationException; import com.clearblade.cloud.iot.v1.getdevice.GetDeviceRequest; import com.clearblade.cloud.iot.v1.getdeviceregistry.GetDeviceRegistryRequest; import com.clearblade.cloud.iot.v1.listdeviceconfigversions.ListDeviceConfigVersionsRequest; @@ -19,15 +23,13 @@ import com.clearblade.cloud.iot.v1.listdeviceregistries.ListDeviceRegistriesRequest; import com.clearblade.cloud.iot.v1.listdeviceregistries.ListDeviceRegistriesResponse; import com.clearblade.cloud.iot.v1.modifycloudtodeviceconfig.ModifyCloudToDeviceConfigRequest; +import com.clearblade.cloud.iot.v1.registrytypes.DeviceRegistry; import com.clearblade.cloud.iot.v1.sendcommandtodevice.SendCommandToDeviceRequest; import com.clearblade.cloud.iot.v1.sendcommandtodevice.SendCommandToDeviceResponse; import com.clearblade.cloud.iot.v1.unbinddevicefromgateway.UnbindDeviceFromGatewayRequest; import com.clearblade.cloud.iot.v1.unbinddevicefromgateway.UnbindDeviceFromGatewayResponse; import com.clearblade.cloud.iot.v1.updatedevice.UpdateDeviceRequest; import com.clearblade.cloud.iot.v1.updatedeviceregistry.UpdateDeviceRegistryRequest; -import com.clearblade.cloud.iot.v1.utils.Device; -import com.clearblade.cloud.iot.v1.utils.DeviceConfig; -import com.clearblade.cloud.iot.v1.utils.DeviceRegistry; public class DeviceManagerClient { @@ -38,6 +40,8 @@ public class DeviceManagerClient { * * @param request * @return Device object + * @throws IOException + * @throws ApplicationException */ public Device getDevice(GetDeviceRequest request) { @@ -50,6 +54,8 @@ public Device getDevice(GetDeviceRequest request) { * * @param request * @return Device object + * @throws IOException + * @throws ApplicationException */ public Device createDevice(CreateDeviceRequest request) { ClearBladeDeviceManager cbManager = new ClearBladeDeviceManager(); @@ -61,6 +67,8 @@ public Device createDevice(CreateDeviceRequest request) { * * @param request * @return + * @throws IOException + * @throws ApplicationException */ public BindDeviceToGatewayResponse bindDeviceToGateway(BindDeviceToGatewayRequest request) { ClearBladeDeviceManager cbManager = new ClearBladeDeviceManager(); @@ -72,6 +80,8 @@ public BindDeviceToGatewayResponse bindDeviceToGateway(BindDeviceToGatewayReques * * @param request * @return + * @throws IOException + * @throws ApplicationException */ public UnbindDeviceFromGatewayResponse unbindDeviceFromGateway(UnbindDeviceFromGatewayRequest request) { ClearBladeDeviceManager cbManager = new ClearBladeDeviceManager(); @@ -82,6 +92,8 @@ public UnbindDeviceFromGatewayResponse unbindDeviceFromGateway(UnbindDeviceFromG * Calling deleteDevice api * * @param request + * @throws IOException + * @throws ApplicationException */ public void deleteDevice(DeleteDeviceRequest request) { ClearBladeDeviceManager cbManager = new ClearBladeDeviceManager(); @@ -133,6 +145,8 @@ public ListDeviceConfigVersionsResponse listDeviceConfigVersions(ListDeviceConfi * * @param request * @return DeviceRegistry object + * @throws IOException + * @throws ApplicationException */ public DeviceRegistry getDeviceRegistry(GetDeviceRegistryRequest request) { ClearBladeRegistryManager cbManager = new ClearBladeRegistryManager(); diff --git a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/SyncClient.java b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/SyncClient.java index 5155bf3d..1cc89ca6 100644 --- a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/SyncClient.java +++ b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/SyncClient.java @@ -1,36 +1,41 @@ package com.clearblade.cloud.iot.v1; import java.io.BufferedReader; +import java.io.IOException; import java.io.InputStreamReader; import java.io.OutputStream; import java.net.URL; +import java.util.logging.Level; +import java.util.logging.Logger; import javax.net.ssl.HttpsURLConnection; +import com.clearblade.cloud.iot.v1.exception.ApplicationException; import com.clearblade.cloud.iot.v1.utils.AuthParams; import com.clearblade.cloud.iot.v1.utils.ConfigParameters; import com.clearblade.cloud.iot.v1.utils.Constants; import com.clearblade.cloud.iot.v1.utils.SetHttpConnection; public class SyncClient { - + + static Logger log = Logger.getLogger(SyncClient.class.getName()); private ConfigParameters configParameters = new ConfigParameters(); - - + /** * Method used to generate URL for apicall + * * @param apiName - path to api - * @param params - parameters to be attached to request + * @param params - parameters to be attached to request * @return URL formed and to be used */ private String generateURL(String apiName, String params) { return AuthParams.getApiBaseURL() - .concat(configParameters.getEndpointPort()) - .concat(configParameters.getBaseURL()) - .concat(AuthParams.getUserSystemKey()) - .concat(apiName) - .concat("?"+params); + .concat(configParameters.getEndpointPort()) + .concat(configParameters.getBaseURL()) + .concat(AuthParams.getUserSystemKey()) + .concat(apiName) + .concat("?" + params); } /** @@ -51,26 +56,28 @@ private String generateAdminURL(String apiName, String params) { /** * Method used to Calls HTTP Get request + * * @param apiName * @param params * @return String[] containing responseCode, responseMessage and response object + * @throws IOException + * @throws ApplicationException */ - public String[] get(String apiName,String params,boolean isAdmin) { + public String[] get(String apiName, String params, boolean isAdmin) { String[] responseArray = new String[3]; String finalURL = ""; - if (isAdmin) { - AuthParams.setAdminCredentials(); - finalURL = generateAdminURL(apiName, params); - } else { - AuthParams.setRegistryCredentials(); - finalURL = generateURL(apiName, params); - } try { - System.out.println(finalURL); + if (isAdmin) { + AuthParams.setAdminCredentials(); + finalURL = generateAdminURL(apiName, params); + } else { + AuthParams.setRegistryCredentials(); + finalURL = generateURL(apiName, params); + } URL obj = new URL(finalURL); SetHttpConnection setCon = new SetHttpConnection(); HttpsURLConnection con = setCon.getConnection(obj); - if(isAdmin) + if (isAdmin) con.setRequestProperty(Constants.HTTP_REQUEST_PROPERTY_TOKEN_KEY, AuthParams.getAdminToken()); else con.setRequestProperty(Constants.HTTP_REQUEST_PROPERTY_TOKEN_KEY, AuthParams.getUserToken()); @@ -98,33 +105,38 @@ public String[] get(String apiName,String params,boolean isAdmin) { responseMessage = response.toString(); responseArray[2] = responseMessage; } - } catch (Exception e) { - e.printStackTrace(); + } catch (ApplicationException | IOException e) { + log.log(Level.SEVERE, e.getMessage()); + } + + catch (Exception e) { + log.log(Level.SEVERE, e.getMessage()); } - + return responseArray; } /** * Method used to call HTTP Post request + * * @param apiName * @param params * @param body * @return String[] containing responseCode, responseMessage and response object + * @throws IOException + * @throws ApplicationException */ public String[] post(String apiName, String params, String body, boolean isAdmin) { String[] responseArray = new String[3]; String finalURL = ""; - if (isAdmin) { - AuthParams.setAdminCredentials(); - finalURL = generateAdminURL(apiName, params); - } else { - AuthParams.setRegistryCredentials(); - finalURL = generateURL(apiName, params); - } try { - - System.out.println(finalURL); + if (isAdmin) { + AuthParams.setAdminCredentials(); + finalURL = generateAdminURL(apiName, params); + } else { + AuthParams.setRegistryCredentials(); + finalURL = generateURL(apiName, params); + } URL obj = new URL(finalURL); SetHttpConnection setCon = new SetHttpConnection(); @@ -164,31 +176,35 @@ public String[] post(String apiName, String params, String body, boolean isAdmin responseArray[2] = responseMessage; } + } catch (ApplicationException | IOException e) { + log.log(Level.SEVERE, e.getMessage()); } catch (Exception e) { - e.printStackTrace(); + log.log(Level.SEVERE, e.getMessage()); } - + return responseArray; } - + /** * Method used to call HTTP delete request + * * @param apiName * @param params * @return String[] containing responseCode, responseMessage and response object + * @throws IOException + * @throws ApplicationException */ - public String[] delete(String apiName,String params,boolean isAdmin) { + public String[] delete(String apiName, String params, boolean isAdmin) { String[] responseArray = new String[3]; String finalURL = ""; - if (isAdmin) { - AuthParams.setAdminCredentials(); - finalURL = generateAdminURL(apiName, params); - } else { - AuthParams.setRegistryCredentials(); - finalURL = generateURL(apiName, params); - } try { - System.out.println(finalURL); + if (isAdmin) { + AuthParams.setAdminCredentials(); + finalURL = generateAdminURL(apiName, params); + } else { + AuthParams.setRegistryCredentials(); + finalURL = generateURL(apiName, params); + } URL obj = new URL(finalURL); SetHttpConnection setCon = new SetHttpConnection(); HttpsURLConnection con = setCon.getConnection(obj); @@ -221,26 +237,28 @@ public String[] delete(String apiName,String params,boolean isAdmin) { responseMessage = response.toString(); responseArray[2] = responseMessage; } + } catch (ApplicationException | IOException e) { + log.log(Level.SEVERE, e.getMessage()); } catch (Exception e) { - e.printStackTrace(); + log.log(Level.SEVERE, e.getMessage()); } - + return responseArray; } - + /** * Method used to call HTTP Patch request + * * @param apiName * @param params * @param body * @return String[] containing responseCode, responseMessage and response object */ - public String[] update(String apiName,String params,String body) { + public String[] update(String apiName, String params, String body) { String[] responseArray = new String[3]; - AuthParams.setRegistryCredentials(); - String finalURL = generateURL(apiName, params); try { - System.out.println(finalURL); + AuthParams.setRegistryCredentials(); + String finalURL = generateURL(apiName, params); URL obj = new URL(finalURL); SetHttpConnection setCon = new SetHttpConnection(); HttpsURLConnection con = setCon.getConnection(obj); @@ -274,8 +292,10 @@ public String[] update(String apiName,String params,String body) { responseMessage = response.toString(); responseArray[2] = responseMessage; } + } catch (ApplicationException | IOException e) { + log.log(Level.SEVERE, e.getMessage()); } catch (Exception e) { - e.printStackTrace(); + log.log(Level.SEVERE, e.getMessage()); } return responseArray; diff --git a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/binddevicetogateway/BindDeviceToGatewayRequest.java b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/binddevicetogateway/BindDeviceToGatewayRequest.java index 2e979ab3..52b0fe6c 100644 --- a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/binddevicetogateway/BindDeviceToGatewayRequest.java +++ b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/binddevicetogateway/BindDeviceToGatewayRequest.java @@ -2,8 +2,6 @@ import org.json.simple.JSONObject; -import com.clearblade.cloud.iot.v1.utils.Constants; - public class BindDeviceToGatewayRequest { private final String parent; private final String gateway; @@ -76,7 +74,8 @@ public void setBodyParams(JSONObject bodyParams) { public String toString() { requestParams = new JSONObject(); bodyParams = new JSONObject(); - String method = Constants.BIND_DEVICE_TO_GATEWAY; + + String method = "bindDeviceToGateway"; requestParams.put("method", method); requestParams.put("parent", this.parent); @@ -92,7 +91,7 @@ public String toString() { @SuppressWarnings("unchecked") public String[] getBodyAndParams() { String[] output = new String[2]; - String params = "parent=" + this.parent + "&method=" + Constants.BIND_DEVICE_TO_GATEWAY; + String params = "parent=" + this.parent + "&method=" + "bindDeviceToGateway"; bodyParams = new JSONObject(); bodyParams.put("gatewayId", this.gateway); bodyParams.put("deviceId", this.device); diff --git a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/createdevice/CreateDeviceRequest.java b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/createdevice/CreateDeviceRequest.java index f8c09404..18ca56fc 100644 --- a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/createdevice/CreateDeviceRequest.java +++ b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/createdevice/CreateDeviceRequest.java @@ -1,7 +1,7 @@ package com.clearblade.cloud.iot.v1.createdevice; -import com.clearblade.cloud.iot.v1.utils.Device; -import com.clearblade.cloud.iot.v1.utils.RegistryName; +import com.clearblade.cloud.iot.v1.devicetypes.Device; +import com.clearblade.cloud.iot.v1.registrytypes.RegistryName; public class CreateDeviceRequest { private final RegistryName parent; @@ -46,7 +46,7 @@ public CreateDeviceRequest build() { public String[] getParams() { String[] params = new String[2]; - params[0] = "parent="+this.parent.getRegistryFullName(); + params[0] = "parent=" + this.parent.getRegistryFullName(); params[1] = this.device.createDeviceJSONObject(); return params; } diff --git a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/createdeviceregistry/CreateDeviceRegistryRequest.java b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/createdeviceregistry/CreateDeviceRegistryRequest.java index 6873411c..4b5a5885 100644 --- a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/createdeviceregistry/CreateDeviceRegistryRequest.java +++ b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/createdeviceregistry/CreateDeviceRegistryRequest.java @@ -1,6 +1,6 @@ package com.clearblade.cloud.iot.v1.createdeviceregistry; -import com.clearblade.cloud.iot.v1.utils.DeviceRegistry; +import com.clearblade.cloud.iot.v1.registrytypes.DeviceRegistry; public class CreateDeviceRegistryRequest { private String parent; diff --git a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/deletedevice/DeleteDeviceRequest.java b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/deletedevice/DeleteDeviceRequest.java index f02f6c10..38e039b7 100644 --- a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/deletedevice/DeleteDeviceRequest.java +++ b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/deletedevice/DeleteDeviceRequest.java @@ -1,6 +1,6 @@ package com.clearblade.cloud.iot.v1.deletedevice; -import com.clearblade.cloud.iot.v1.utils.DeviceName; +import com.clearblade.cloud.iot.v1.devicetypes.DeviceName; public class DeleteDeviceRequest { private DeviceName name; diff --git a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/deviceslist/DevicesListRequest.java b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/deviceslist/DevicesListRequest.java index 884b1cb0..cd2aab7e 100644 --- a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/deviceslist/DevicesListRequest.java +++ b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/deviceslist/DevicesListRequest.java @@ -1,6 +1,6 @@ package com.clearblade.cloud.iot.v1.deviceslist; -import com.clearblade.cloud.iot.v1.utils.GatewayListOptions; +import com.clearblade.cloud.iot.v1.devicetypes.GatewayListOptions; public class DevicesListRequest { diff --git a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/deviceslist/DevicesListResponse.java b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/deviceslist/DevicesListResponse.java index 43fd5336..8b1891dd 100644 --- a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/deviceslist/DevicesListResponse.java +++ b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/deviceslist/DevicesListResponse.java @@ -3,13 +3,14 @@ import java.util.ArrayList; import java.util.Iterator; import java.util.List; +import java.util.logging.Level; import java.util.logging.Logger; import org.json.simple.JSONArray; import org.json.simple.JSONObject; import org.json.simple.parser.JSONParser; -import com.clearblade.cloud.iot.v1.utils.Device; +import com.clearblade.cloud.iot.v1.devicetypes.Device; public class DevicesListResponse { @@ -74,7 +75,7 @@ public Builder buildResponse(String jsonString) { nextPageToken = (String) jsonObj.get("nextPageToken"); } catch (Exception e) { - e.printStackTrace(); + log.log(Level.SEVERE, e.getMessage()); } return this; } diff --git a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/devicestateslist/ListDeviceStatesResponse.java b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/devicestateslist/ListDeviceStatesResponse.java index 6fdf2b4a..77d7590a 100644 --- a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/devicestateslist/ListDeviceStatesResponse.java +++ b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/devicestateslist/ListDeviceStatesResponse.java @@ -1,6 +1,7 @@ package com.clearblade.cloud.iot.v1.devicestateslist; import java.util.List; +import java.util.logging.Level; import java.util.logging.Logger; import java.util.ArrayList; import java.util.Iterator; @@ -9,7 +10,7 @@ import org.json.simple.JSONObject; import org.json.simple.parser.JSONParser; -import com.clearblade.cloud.iot.v1.utils.DeviceState; +import com.clearblade.cloud.iot.v1.devicetypes.DeviceState; public class ListDeviceStatesResponse { @@ -57,7 +58,7 @@ public Builder buildResponse(String stateList) { } } catch (Exception e) { - e.printStackTrace(); + log.log(Level.SEVERE, e.getMessage()); } return this; diff --git a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/utils/Device.java b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/devicetypes/Device.java similarity index 91% rename from clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/utils/Device.java rename to clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/devicetypes/Device.java index eb7c120e..b596fa6d 100644 --- a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/utils/Device.java +++ b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/devicetypes/Device.java @@ -1,4 +1,4 @@ -package com.clearblade.cloud.iot.v1.utils; +package com.clearblade.cloud.iot.v1.devicetypes; import java.util.ArrayList; import java.util.HashMap; @@ -6,11 +6,16 @@ import java.util.List; import java.util.Map; import java.util.Set; +import java.util.logging.Level; +import java.util.logging.Logger; import org.json.simple.JSONObject; import org.json.simple.parser.JSONParser; +import com.clearblade.cloud.iot.v1.utils.LogLevel; + public class Device { + static Logger log = Logger.getLogger(Device.class.getName()); private String id; private String name; @@ -27,7 +32,7 @@ public class Device { private DeviceConfig config; private DeviceState state; private LogLevel logLevel; - private Map metadata; + private Map metadata; private GatewayConfig gatewayConfig; public Device() { @@ -105,7 +110,7 @@ public static Device of(String id, String name, String numId, List metadata; + private Map metadata; private GatewayConfig gatewayConfig; protected Builder() { @@ -208,7 +213,7 @@ public DeviceState getState() { return state; } - public Map getMetadata() { + public Map getMetadata() { return metadata; } @@ -309,8 +314,6 @@ public Builder setLastErrorTime(String lastErrorTime) { return this; } - - private Builder(Device device) { this.id = device.id; this.name = device.name; @@ -356,53 +359,53 @@ public String createDeviceJSONObject() { deviceObj.put("id", this.id); deviceObj.put("name", this.name); deviceObj.put("numId", this.numId); - List credentialList = new ArrayList<>(); - if(this.credentials.size() > 0) { - DeviceCredential credentialObj = this.credentials.get(0); - credentialList.add(credentialObj); - } - deviceObj.put("credentials",credentialList); + List credentialList = new ArrayList<>(); + if (this.credentials.size() > 0) { + DeviceCredential credentialObj = this.credentials.get(0); + credentialList.add(credentialObj); + } + deviceObj.put("credentials", credentialList); deviceObj.put("gatewayConfig", this.gatewayConfig.toString()); deviceObj.put("logLevel", this.logLevel.name()); - deviceObj.put("lastHeartbeatTime",this.lastHeartbeatTime); - deviceObj.put("lastEventTime",this.lastEventTime); - deviceObj.put("lastStateTime",this.lastStateTime); - deviceObj.put("lastConfigAckTime",this.lastConfigAckTime); - deviceObj.put("lastConfigSendTime",this.lastConfigSendTime); - deviceObj.put("blocked",false); + deviceObj.put("lastHeartbeatTime", this.lastHeartbeatTime); + deviceObj.put("lastEventTime", this.lastEventTime); + deviceObj.put("lastStateTime", this.lastStateTime); + deviceObj.put("lastConfigAckTime", this.lastConfigAckTime); + deviceObj.put("lastConfigSendTime", this.lastConfigSendTime); + deviceObj.put("blocked", false); deviceObj.put("lastErrorTime", this.lastErrorTime); String metaStr = ""; - if(this.metadata != null) { + if (this.metadata != null) { Set metaSet = this.metadata.keySet(); Iterator itr = metaSet.iterator(); int setSize = metaSet.size(); int i = 0; - while(itr.hasNext()) { + while (itr.hasNext()) { String key = (String) itr.next(); String value = this.metadata.get(key).toString(); - if(i >= 0 && i < setSize) { - metaStr += "{\""+key+"\":"+"\""+value+"\","; - }else if(i == setSize){ - metaStr += "{\""+key+"\":"+"\""+value+"\"}"; - }else { - metaStr += "{\""+key+"\":"+"\""+value+"\""; + if (i >= 0 && i < setSize) { + metaStr += "{\"" + key + "\":" + "\"" + value + "\","; + } else if (i == setSize) { + metaStr += "{\"" + key + "\":" + "\"" + value + "\"}"; + } else { + metaStr += "{\"" + key + "\":" + "\"" + value + "\""; } i++; } } deviceObj.put("metadata", metaStr); String errorStatusStr = ""; - if(this.lastErrorStatus != null) { - errorStatusStr+= this.lastErrorStatus.toString(); + if (this.lastErrorStatus != null) { + errorStatusStr += this.lastErrorStatus.toString(); } deviceObj.put("lastErrorStatus", errorStatusStr); String configStr = ""; - if(this.config != null) { + if (this.config != null) { configStr += this.config.toString(); } deviceObj.put("config", configStr); String stateStr = ""; - if(this.state != null) { + if (this.state != null) { stateStr += this.state.toString(); } deviceObj.put("state", stateStr); @@ -535,7 +538,7 @@ public void loadFromString(String inputStr) { } } catch (Exception e) { - e.printStackTrace(); + log.log(Level.SEVERE, e.getMessage()); } } diff --git a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/utils/DeviceConfig.java b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/devicetypes/DeviceConfig.java similarity index 76% rename from clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/utils/DeviceConfig.java rename to clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/devicetypes/DeviceConfig.java index 08941ade..da33eb8a 100644 --- a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/utils/DeviceConfig.java +++ b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/devicetypes/DeviceConfig.java @@ -1,25 +1,28 @@ -package com.clearblade.cloud.iot.v1.utils; +package com.clearblade.cloud.iot.v1.devicetypes; + +import java.util.logging.Level; +import java.util.logging.Logger; import org.json.simple.JSONObject; import org.json.simple.parser.JSONParser; public class DeviceConfig { + static Logger log = Logger.getLogger(DeviceConfig.class.getName()); private String version; private String cloudUpdateTime; private String deviceAckTime; private String binaryData; - + public DeviceConfig() { } - + private DeviceConfig(Builder builder) { version = builder.version; cloudUpdateTime = builder.cloudUpdateTime; deviceAckTime = builder.deviceAckTime; binaryData = builder.binaryData; } - - + public void setVersion(String version) { this.version = version; } @@ -59,7 +62,7 @@ public static Builder newBuilder() { public Builder toBuilder() { return new Builder(this); } - + public static class Builder { private String version; private String cloudUpdateTime; @@ -70,35 +73,42 @@ protected Builder() { } - public String getVersion() { return version; } + public Builder setVersion(String version) { this.version = version; return this; } + public String getCloudUpdateTime() { return cloudUpdateTime; } + public Builder setCloudUpdateTime(String cloudUpdateTime) { this.cloudUpdateTime = cloudUpdateTime; return this; } + public String getDeviceAckTime() { return deviceAckTime; } + public Builder setDeviceAckTime(String deviceAckTime) { this.deviceAckTime = deviceAckTime; return this; } + public String getBinaryData() { return binaryData; } + public Builder setBinaryData(String binaryData) { this.binaryData = binaryData; return this; } + private Builder(DeviceConfig deviceConfig) { this.version = deviceConfig.version; this.cloudUpdateTime = deviceConfig.cloudUpdateTime; @@ -114,25 +124,25 @@ public DeviceConfig build() { @Override public String toString() { String configStr = ""; - if(this.getVersion() != null) { - configStr+= "{\"version\":\""+this.getBinaryData()+"\","; - }else { - configStr+= "{\"version\":\"\","; - } - if(this.getCloudUpdateTime() != null) { - configStr+= "\"cloudUpdateTime\":\""+this.getCloudUpdateTime()+"\","; - }else { - configStr+= "\"cloudUpdateTime\":\"\","; - } - if(this.getDeviceAckTime() != null) { - configStr+= "\"deviceAckTime\":\""+this.getDeviceAckTime()+"\","; - }else { - configStr+= "\"deviceAckTime\":\"\","; - } - if(this.getBinaryData() != null) { - configStr+= "\"binaryData\":\""+this.getBinaryData()+"\"}"; - }else { - configStr+= "\"binaryData\":\"\"}"; + if (this.getVersion() != null) { + configStr += "{\"version\":\"" + this.getBinaryData() + "\","; + } else { + configStr += "{\"version\":\"\","; + } + if (this.getCloudUpdateTime() != null) { + configStr += "\"cloudUpdateTime\":\"" + this.getCloudUpdateTime() + "\","; + } else { + configStr += "\"cloudUpdateTime\":\"\","; + } + if (this.getDeviceAckTime() != null) { + configStr += "\"deviceAckTime\":\"" + this.getDeviceAckTime() + "\","; + } else { + configStr += "\"deviceAckTime\":\"\","; + } + if (this.getBinaryData() != null) { + configStr += "\"binaryData\":\"" + this.getBinaryData() + "\"}"; + } else { + configStr += "\"binaryData\":\"\"}"; } return configStr; } @@ -146,7 +156,7 @@ public void loadFromString(String jsonString) { this.deviceAckTime = (String) jsonObj.get("deviceAckTime"); this.binaryData = (String) jsonObj.get("binaryData"); } catch (Exception e) { - e.printStackTrace(); + log.log(Level.SEVERE, e.getMessage()); } } } diff --git a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/utils/DeviceCredential.java b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/devicetypes/DeviceCredential.java similarity index 91% rename from clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/utils/DeviceCredential.java rename to clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/devicetypes/DeviceCredential.java index 78df96b8..114188b1 100644 --- a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/utils/DeviceCredential.java +++ b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/devicetypes/DeviceCredential.java @@ -1,17 +1,20 @@ -package com.clearblade.cloud.iot.v1.utils; +package com.clearblade.cloud.iot.v1.devicetypes; + +import com.clearblade.cloud.iot.v1.registrytypes.PublicKeyCredential; public class DeviceCredential { - + private String expirationTime; private PublicKeyCredential publicKey; - + public DeviceCredential() { } - + private DeviceCredential(Builder builder) { expirationTime = builder.expirationTime; publicKey = builder.publicKey; } + public static Builder newBuilder() { return new Builder(); } @@ -19,7 +22,7 @@ public static Builder newBuilder() { public Builder toBuilder() { return new Builder(this); } - + public static class Builder { private String expirationTime; private PublicKeyCredential publicKey; @@ -28,33 +31,29 @@ protected Builder() { } - public String getExpirationTime() { return expirationTime; } - public Builder setExpirationTime(String expirationTime) { this.expirationTime = expirationTime; return this; } - public PublicKeyCredential getPublicKey() { return publicKey; } - public Builder setPublicKey(PublicKeyCredential publicKey) { this.publicKey = publicKey; return this; } - private Builder(DeviceCredential deviceCredential) { this.expirationTime = deviceCredential.expirationTime; this.publicKey = deviceCredential.publicKey; } + public DeviceCredential build() { return new DeviceCredential(this); } @@ -67,8 +66,5 @@ public void setExpirationTime(String expirationTime) { public void setPublicKey(PublicKeyCredential publicKey) { this.publicKey = publicKey; } - - - } diff --git a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/utils/DeviceName.java b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/devicetypes/DeviceName.java similarity index 97% rename from clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/utils/DeviceName.java rename to clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/devicetypes/DeviceName.java index 0f3916aa..02ec4a04 100644 --- a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/utils/DeviceName.java +++ b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/devicetypes/DeviceName.java @@ -1,4 +1,4 @@ -package com.clearblade.cloud.iot.v1.utils; +package com.clearblade.cloud.iot.v1.devicetypes; public class DeviceName { @@ -114,10 +114,11 @@ public DeviceName build() { return new DeviceName(this); } } + @Override public String toString() { - + return this.device; - + } } diff --git a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/utils/DeviceState.java b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/devicetypes/DeviceState.java similarity index 79% rename from clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/utils/DeviceState.java rename to clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/devicetypes/DeviceState.java index bd604f9f..b1a5ff34 100644 --- a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/utils/DeviceState.java +++ b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/devicetypes/DeviceState.java @@ -1,22 +1,22 @@ -package com.clearblade.cloud.iot.v1.utils; +package com.clearblade.cloud.iot.v1.devicetypes; public class DeviceState { private String updateTime; private String binaryData; - + public DeviceState(Builder builder) { updateTime = builder.updateTime; binaryData = builder.getBinaryData(); } - + public DeviceState() { - + } + public String getBinaryData() { return binaryData; } - - + public String getUpdateTime() { return updateTime; } @@ -44,12 +44,10 @@ public static class Builder { protected Builder() { } - public String getUpdateTime() { return updateTime; } - public Builder setUpdateTime(String updateTime) { this.updateTime = updateTime; return this; @@ -63,6 +61,7 @@ public Builder setBinaryData(String binaryData) { this.binaryData = binaryData; return this; } + private Builder(DeviceState deviceState) { this.updateTime = deviceState.updateTime; this.binaryData = deviceState.binaryData; @@ -76,15 +75,15 @@ public DeviceState build() { @Override public String toString() { String stateStr = ""; - if(this.getUpdateTime() != null) { - stateStr+= "{\"updateTime\":\""+this.getUpdateTime()+"\","; - }else { - stateStr+= "{\"updateTime\":\"\","; - } - if(this.getBinaryData() != null) { - stateStr+= "\"binaryData\":\""+this.getBinaryData()+"\"}"; - }else { - stateStr+= "\"binaryData\":\"\"}"; + if (this.getUpdateTime() != null) { + stateStr += "{\"updateTime\":\"" + this.getUpdateTime() + "\","; + } else { + stateStr += "{\"updateTime\":\"\","; + } + if (this.getBinaryData() != null) { + stateStr += "\"binaryData\":\"" + this.getBinaryData() + "\"}"; + } else { + stateStr += "\"binaryData\":\"\"}"; } return stateStr; } diff --git a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/utils/FieldMask.java b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/devicetypes/FieldMask.java similarity index 90% rename from clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/utils/FieldMask.java rename to clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/devicetypes/FieldMask.java index 879a7c00..19fe7ca0 100644 --- a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/utils/FieldMask.java +++ b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/devicetypes/FieldMask.java @@ -1,16 +1,17 @@ -package com.clearblade.cloud.iot.v1.utils; +package com.clearblade.cloud.iot.v1.devicetypes; public class FieldMask { - + private final String name; - + public FieldMask() { name = ""; } - + private FieldMask(Builder builder) { name = builder.getFieldmask(); } + public static Builder newBuilder() { return new Builder(); } @@ -23,7 +24,7 @@ public static class Builder { private String name; protected Builder() { - + } public String getFieldmask() { @@ -34,17 +35,19 @@ public Builder setFieldmask(String fieldmask) { this.name = fieldmask; return this; } - + private Builder(FieldMask fieldMask) { this.name = fieldMask.name; } + public FieldMask build() { return new FieldMask(this); } } + @Override public String toString() { - if(this.name != null) + if (this.name != null) return this.name; else return ""; diff --git a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/devicetypes/GatewayAuthMethod.java b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/devicetypes/GatewayAuthMethod.java new file mode 100644 index 00000000..96abc4d4 --- /dev/null +++ b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/devicetypes/GatewayAuthMethod.java @@ -0,0 +1,62 @@ +package com.clearblade.cloud.iot.v1.devicetypes; + +public enum GatewayAuthMethod { + + GATEWAY_AUTH_METHOD_UNSPECIFIED(0), + ASSOCIATION_ONLY(1), + DEVICE_AUTH_TOKEN_ONLY(2), + ASSOCIATION_AND_DEVICE_AUTH_TOKEN(3), + UNRECOGNIZED(-1), + ; + + public static final int GATEWAY_AUTH_METHOD_UNSPECIFIED_VALUE = 0; + public static final int ASSOCIATION_ONLY_VALUE = 1; + public static final int DEVICE_AUTH_TOKEN_ONLY_VALUE = 2; + public static final int ASSOCIATION_AND_DEVICE_AUTH_TOKEN_VALUE = 3; + + public final int getNumber() { + if (this == UNRECOGNIZED) { + throw new java.lang.IllegalArgumentException( + "Can't get the number of an unknown enum value."); + } + return value; + } + + /** + * @param value The numeric wire value of the corresponding enum entry. + * @return The enum associated with the given numeric wire value. + */ + public static GatewayAuthMethod valueOf(int value) { + return forNumber(value); + } + + /** + * @param value The numeric wire value of the corresponding enum entry. + * @return The enum associated with the given numeric wire value. + */ + public static GatewayAuthMethod forNumber(int value) { + switch (value) { + case 0: + return GATEWAY_AUTH_METHOD_UNSPECIFIED; + case 1: + return ASSOCIATION_ONLY; + case 2: + return DEVICE_AUTH_TOKEN_ONLY; + case 3: + return ASSOCIATION_AND_DEVICE_AUTH_TOKEN; + default: + return null; + } + } + + public GatewayAuthMethod findValueByNumber(int number) { + return GatewayAuthMethod.forNumber(number); + } + + private final int value; + + private GatewayAuthMethod(int value) { + this.value = value; + } + +} diff --git a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/utils/GatewayConfig.java b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/devicetypes/GatewayConfig.java similarity index 68% rename from clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/utils/GatewayConfig.java rename to clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/devicetypes/GatewayConfig.java index 3eddbe3a..4ec9c9ce 100644 --- a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/utils/GatewayConfig.java +++ b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/devicetypes/GatewayConfig.java @@ -1,4 +1,4 @@ -package com.clearblade.cloud.iot.v1.utils; +package com.clearblade.cloud.iot.v1.devicetypes; public class GatewayConfig { @@ -6,12 +6,10 @@ public class GatewayConfig { private GatewayAuthMethod gatewayAuthMethod; private String lastAccessedGatewayId; private String lastAccessedGatewayTime; - + public GatewayConfig() { } - - - + public GatewayType getGatewayType() { return gatewayType; } @@ -50,6 +48,7 @@ private GatewayConfig(Builder builder) { lastAccessedGatewayId = builder.lastAccessedGatewayId; lastAccessedGatewayTime = builder.lastAccessedGatewayTime; } + public static Builder newBuilder() { return new Builder(); } @@ -57,7 +56,7 @@ public static Builder newBuilder() { public Builder toBuilder() { return new Builder(this); } - + public static class Builder { private GatewayType gatewayType; private GatewayAuthMethod gatewayAuthMethod; @@ -67,43 +66,44 @@ public static class Builder { protected Builder() { } - private Builder(GatewayConfig gatewayConfig) { this.gatewayType = gatewayConfig.gatewayType; this.gatewayAuthMethod = gatewayConfig.gatewayAuthMethod; this.lastAccessedGatewayId = gatewayConfig.lastAccessedGatewayId; this.lastAccessedGatewayTime = gatewayConfig.lastAccessedGatewayTime; } + public GatewayConfig build() { return new GatewayConfig(this); } } + @Override public String toString() { String gatewayCfgStr = ""; - - if(this.getGatewayAuthMethod() != null) { - gatewayCfgStr+= "{\"gatewayAuthMethod\":\""+this.getGatewayAuthMethod().name()+"\","; - }else { - gatewayCfgStr+= "{\"gatewayAuthMethod\":\""+GatewayAuthMethod.GATEWAY_AUTH_METHOD_UNSPECIFIED+"\","; - } - if(this.getGatewayType() != null) { - gatewayCfgStr+= "\"gatewayType\":\""+this.getGatewayType().name()+"\","; - }else { - gatewayCfgStr+= "\"gatewayType\":\""+GatewayType.valueOf(GatewayType.NON_GATEWAY_VALUE)+"\","; + + if (this.getGatewayAuthMethod() != null) { + gatewayCfgStr += "{\"gatewayAuthMethod\":\"" + this.getGatewayAuthMethod().name() + "\","; + } else { + gatewayCfgStr += "{\"gatewayAuthMethod\":\"" + GatewayAuthMethod.GATEWAY_AUTH_METHOD_UNSPECIFIED + "\","; + } + if (this.getGatewayType() != null) { + gatewayCfgStr += "\"gatewayType\":\"" + this.getGatewayType().name() + "\","; + } else { + gatewayCfgStr += "\"gatewayType\":\"" + GatewayType.valueOf(GatewayType.NON_GATEWAY_VALUE) + "\","; } - if(this.getLastAccessedGatewayId() != null) { - gatewayCfgStr+= "\"lastAccessedGatewayId\":\""+this.getLastAccessedGatewayId()+"\","; - }else { - gatewayCfgStr+= "\"lastAccessedGatewayId\":\"\","; - } - if(this.getLastAccessedGatewayTime() != null) { - gatewayCfgStr+= "\"lastAccessedGatewayTime\":\""+this.getLastAccessedGatewayTime()+"\"}"; - }else { - gatewayCfgStr+= "\"lastAccessedGatewayTime\":\"\"}"; + if (this.getLastAccessedGatewayId() != null) { + gatewayCfgStr += "\"lastAccessedGatewayId\":\"" + this.getLastAccessedGatewayId() + "\","; + } else { + gatewayCfgStr += "\"lastAccessedGatewayId\":\"\","; + } + if (this.getLastAccessedGatewayTime() != null) { + gatewayCfgStr += "\"lastAccessedGatewayTime\":\"" + this.getLastAccessedGatewayTime() + "\"}"; + } else { + gatewayCfgStr += "\"lastAccessedGatewayTime\":\"\"}"; } return gatewayCfgStr; - + } } diff --git a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/utils/GatewayListOptions.java b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/devicetypes/GatewayListOptions.java similarity index 97% rename from clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/utils/GatewayListOptions.java rename to clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/devicetypes/GatewayListOptions.java index 9a21bab2..995f2f89 100644 --- a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/utils/GatewayListOptions.java +++ b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/devicetypes/GatewayListOptions.java @@ -1,4 +1,4 @@ -package com.clearblade.cloud.iot.v1.utils; +package com.clearblade.cloud.iot.v1.devicetypes; public class GatewayListOptions { diff --git a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/devicetypes/GatewayType.java b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/devicetypes/GatewayType.java new file mode 100644 index 00000000..a2ab96f1 --- /dev/null +++ b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/devicetypes/GatewayType.java @@ -0,0 +1,58 @@ +package com.clearblade.cloud.iot.v1.devicetypes; + +public enum GatewayType { + + GATEWAY_TYPE_UNSPECIFIED(0), + GATEWAY(1), + NON_GATEWAY(2), + UNRECOGNIZED(-1), + ; + + public static final int GATEWAY_TYPE_UNSPECIFIED_VALUE = 0; + public static final int GATEWAY_VALUE = 1; + public static final int NON_GATEWAY_VALUE = 2; + + public final int getNumber() { + if (this == UNRECOGNIZED) { + throw new java.lang.IllegalArgumentException( + "Can't get the number of an unknown enum value."); + } + return value; + } + + /** + * @param value The numeric wire value of the corresponding enum entry. + * @return The enum associated with the given numeric wire value. + */ + public static GatewayType valueOf(int value) { + return forNumber(value); + } + + /** + * @param value The numeric wire value of the corresponding enum entry. + * @return The enum associated with the given numeric wire value. + */ + public static GatewayType forNumber(int value) { + switch (value) { + case 0: + return GATEWAY_TYPE_UNSPECIFIED; + case 1: + return GATEWAY; + case 2: + return NON_GATEWAY; + default: + return null; + } + } + + public GatewayType findValueByNumber(int number) { + return GatewayType.forNumber(number); + } + + private final int value; + + private GatewayType(int value) { + this.value = value; + } + +} diff --git a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/utils/Status.java b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/devicetypes/Status.java similarity index 83% rename from clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/utils/Status.java rename to clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/devicetypes/Status.java index aa52069c..a795265a 100644 --- a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/utils/Status.java +++ b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/devicetypes/Status.java @@ -1,4 +1,4 @@ -package com.clearblade.cloud.iot.v1.utils; +package com.clearblade.cloud.iot.v1.devicetypes; import java.util.List; @@ -6,10 +6,10 @@ public class Status { private int code; private String message; private List details; - + public Status() { } - + private Status(Builder builder) { code = builder.code; message = builder.message; @@ -28,7 +28,7 @@ public void setMessage(String message) { public void setDetails(List details) { this.details = details; } - + public int getCode() { return code; } @@ -48,7 +48,7 @@ public static Builder newBuilder() { public Builder toBuilder() { return new Builder(this); } - + public static class Builder { private int code; private String message; @@ -57,28 +57,24 @@ public static class Builder { protected Builder() { } - public int getCode() { return code; } - + public Builder setCode(int code) { this.code = code; return this; } - public String getMessage() { return message; } - public Builder setMessage(String message) { this.message = message; return this; } - public List getDetails() { return details; } @@ -88,12 +84,12 @@ public Builder setDetails(List details) { return this; } - private Builder(Status status) { this.code = status.code; this.message = status.message; this.details = status.details; } + public Status build() { return new Status(this); } @@ -102,15 +98,15 @@ public Status build() { @Override public String toString() { String statuStr = ""; - if(this.getCode() != 0) { - statuStr+= "{\"code\":\""+this.getCode()+"\","; - }else { - statuStr+= "{\"code\":\"0\","; - } - if(this.getMessage() != null) { - statuStr+= "\"message\":\""+this.getMessage()+"\"}"; - }else { - statuStr+= "\"message\":\"\"}"; + if (this.getCode() != 0) { + statuStr += "{\"code\":\"" + this.getCode() + "\","; + } else { + statuStr += "{\"code\":\"0\","; + } + if (this.getMessage() != null) { + statuStr += "\"message\":\"" + this.getMessage() + "\"}"; + } else { + statuStr += "\"message\":\"\"}"; } return statuStr; } diff --git a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/exception/ApplicationException.java b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/exception/ApplicationException.java new file mode 100644 index 00000000..68e79f6c --- /dev/null +++ b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/exception/ApplicationException.java @@ -0,0 +1,7 @@ +package com.clearblade.cloud.iot.v1.exception; + +public class ApplicationException extends Exception { + public ApplicationException(String errorMessage) { + super(errorMessage); + } +} diff --git a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/getdevice/GetDeviceRequest.java b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/getdevice/GetDeviceRequest.java index 738864a9..5476374b 100644 --- a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/getdevice/GetDeviceRequest.java +++ b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/getdevice/GetDeviceRequest.java @@ -1,18 +1,18 @@ package com.clearblade.cloud.iot.v1.getdevice; -import com.clearblade.cloud.iot.v1.utils.DeviceName; -import com.clearblade.cloud.iot.v1.utils.FieldMask; +import com.clearblade.cloud.iot.v1.devicetypes.DeviceName; +import com.clearblade.cloud.iot.v1.devicetypes.FieldMask; public class GetDeviceRequest { - + private final DeviceName name; private final FieldMask fieldMask; - + private GetDeviceRequest(Builder builder) { this.name = builder.name; this.fieldMask = builder.fieldMask; } - + // Static class Builder public static class Builder { @@ -35,7 +35,8 @@ public FieldMask getFieldMask() { public Builder setFieldMask(FieldMask fieldMask) { this.fieldMask = fieldMask; return this; - } + } + public DeviceName getName() { return name; } @@ -55,12 +56,11 @@ public GetDeviceRequest build() { @Override public String toString() { String params = ""; - params = "name="+this.name.toString(); - if(this.fieldMask.toString() != "") { - params+= "&fieldMask="+this.fieldMask.toString(); + params = "name=" + this.name.toString(); + if (this.fieldMask.toString() != "") { + params += "&fieldMask=" + this.fieldMask.toString(); } return params; } - } diff --git a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/listdeviceconfigversions/ListDeviceConfigVersionsResponse.java b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/listdeviceconfigversions/ListDeviceConfigVersionsResponse.java index 88c8e3cf..fca71a06 100644 --- a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/listdeviceconfigversions/ListDeviceConfigVersionsResponse.java +++ b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/listdeviceconfigversions/ListDeviceConfigVersionsResponse.java @@ -3,13 +3,14 @@ import java.util.ArrayList; import java.util.Iterator; import java.util.List; +import java.util.logging.Level; import java.util.logging.Logger; import org.json.simple.JSONArray; import org.json.simple.JSONObject; import org.json.simple.parser.JSONParser; -import com.clearblade.cloud.iot.v1.utils.DeviceConfig; +import com.clearblade.cloud.iot.v1.devicetypes.DeviceConfig; public class ListDeviceConfigVersionsResponse { @@ -20,7 +21,6 @@ protected ListDeviceConfigVersionsResponse(Builder builder) { this.deviceConfigList = builder.deviceConfigList; } - // Static class Builder public static class Builder { @@ -38,6 +38,7 @@ private Builder() { public Builder setDeviceConfigVersionsListRequest(ListDeviceConfigVersionsRequest request) { return this; } + public Builder buildResponse(String configList) { try { JSONObject jsonObj = new JSONObject(); @@ -49,7 +50,8 @@ public Builder buildResponse(String configList) { Iterator configIterator = configArray.iterator(); while (configIterator.hasNext()) { JSONObject configJson = (JSONObject) configIterator.next(); - DeviceConfig configObj = DeviceConfig.newBuilder().setBinaryData((String) configJson.get("binaryData")) + DeviceConfig configObj = DeviceConfig.newBuilder() + .setBinaryData((String) configJson.get("binaryData")) .setCloudUpdateTime((String) configJson.get("cloudUpdateTime")) .setDeviceAckTime((String) configJson.get("deviceAckTime")) .setVersion((String) configJson.get("version")) @@ -58,7 +60,7 @@ public Builder buildResponse(String configList) { } } catch (Exception e) { - e.printStackTrace(); + log.log(Level.SEVERE, e.getMessage()); } return this; } @@ -70,15 +72,12 @@ public ListDeviceConfigVersionsResponse build() { } } - public List getDeviceConfigList() { return deviceConfigList; } - public void setDeviceConfigList(List deviceConfigList) { this.deviceConfigList = deviceConfigList; } - - + } \ No newline at end of file diff --git a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/listdeviceregistries/ListDeviceRegistriesResponse.java b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/listdeviceregistries/ListDeviceRegistriesResponse.java index 758ba8c9..af341bea 100644 --- a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/listdeviceregistries/ListDeviceRegistriesResponse.java +++ b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/listdeviceregistries/ListDeviceRegistriesResponse.java @@ -3,13 +3,14 @@ import java.util.ArrayList; import java.util.Iterator; import java.util.List; +import java.util.logging.Level; import java.util.logging.Logger; import org.json.simple.JSONArray; import org.json.simple.JSONObject; import org.json.simple.parser.JSONParser; -import com.clearblade.cloud.iot.v1.utils.DeviceRegistry; +import com.clearblade.cloud.iot.v1.registrytypes.DeviceRegistry; public class ListDeviceRegistriesResponse { static Logger log = Logger.getLogger(ListDeviceRegistriesResponse.class.getName()); @@ -73,7 +74,7 @@ public Builder buildResponse(String jsonString) { nextPageToken = jsonObj.get("nextPageToken").toString(); } catch (Exception e) { - e.printStackTrace(); + log.log(Level.SEVERE, e.getMessage()); } return this; } diff --git a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/modifycloudtodeviceconfig/ModifyCloudToDeviceConfigRequest.java b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/modifycloudtodeviceconfig/ModifyCloudToDeviceConfigRequest.java index b44c8b83..ccfb94c6 100644 --- a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/modifycloudtodeviceconfig/ModifyCloudToDeviceConfigRequest.java +++ b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/modifycloudtodeviceconfig/ModifyCloudToDeviceConfigRequest.java @@ -5,7 +5,6 @@ import org.json.simple.JSONObject; import com.clearblade.cloud.iot.v1.utils.ByteString; -import com.clearblade.cloud.iot.v1.utils.Constants; public class ModifyCloudToDeviceConfigRequest { @@ -73,7 +72,7 @@ public String toString() { @SuppressWarnings("unchecked") public String[] getBodyAndParams() { String[] output = new String[2]; - String params = "name=" + this.deviceName + "&method=" + Constants.MODIFY_CLOUD_TO_DEVICE_CONFIG; + String params = "name=" + this.deviceName + "&method=modifyCloudToDeviceConfig"; String bData = "EMPTY"; if (this.binaryData != null) { bData = new String(this.binaryData.getBinaryDataArray()); diff --git a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/utils/DeviceRegistry.java b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/registrytypes/DeviceRegistry.java similarity index 91% rename from clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/utils/DeviceRegistry.java rename to clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/registrytypes/DeviceRegistry.java index d573b765..9ef3875d 100644 --- a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/utils/DeviceRegistry.java +++ b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/registrytypes/DeviceRegistry.java @@ -1,16 +1,22 @@ -package com.clearblade.cloud.iot.v1.utils; +package com.clearblade.cloud.iot.v1.registrytypes; import java.util.ArrayList; import java.util.Iterator; import java.util.List; import java.util.Set; +import java.util.logging.Level; +import java.util.logging.Logger; import org.json.simple.JSONArray; import org.json.simple.JSONObject; import org.json.simple.parser.JSONParser; + +import com.clearblade.cloud.iot.v1.utils.LogLevel; + //https://cloud.google.com/iot/docs/reference/cloudiot/rest/v1/projects.locations.registries#DeviceRegistry public class DeviceRegistry { - + static Logger log = Logger.getLogger(DeviceRegistry.class.getName()); + private String id; private String name; private List eventNotificationConfigs; @@ -20,7 +26,6 @@ public class DeviceRegistry { private LogLevel logLevel; private List credentials; - public DeviceRegistry() { id = ""; name = ""; @@ -31,7 +36,7 @@ public DeviceRegistry() { logLevel = null; credentials = new ArrayList<>(); } - + private DeviceRegistry(Builder builder) { id = builder.getId(); name = builder.getName(); @@ -42,7 +47,6 @@ private DeviceRegistry(Builder builder) { logLevel = builder.getLogLevel(); credentials = builder.getCredentials(); } - public static Builder newBuilder() { return new Builder(); @@ -70,7 +74,7 @@ public static String format(String id, String name, List credentials; - protected Builder() { - + } - + public static Builder newBuilder() { return newBuilder(); } - + public String getId() { return id; } @@ -138,6 +141,7 @@ public Builder setEventNotificationConfigs(List eventNo this.eventNotificationConfigs = eventNotificationConfigs; return this; } + public Builder setStateNotificationConfig(StateNotificationConfig stateNotificationConfig) { this.stateNotificationConfig = stateNotificationConfig; return this; @@ -147,20 +151,22 @@ public Builder setMqttConfig(MqttConfig mqttConfig) { this.mqttConfig = mqttConfig; return this; } + public Builder setHttpConfig(HttpConfig httpConfig) { this.httpConfig = httpConfig; return this; } + public Builder setLogLevel(LogLevel logLevel) { this.logLevel = logLevel; return this; } + public Builder setCredentials(List credentials) { this.credentials = credentials; return this; } - private Builder(DeviceRegistry registry) { this.id = registry.id; this.name = registry.name; @@ -169,22 +175,23 @@ private Builder(DeviceRegistry registry) { this.mqttConfig = registry.mqttConfig; this.httpConfig = registry.httpConfig; this.logLevel = registry.logLevel; - this.credentials = registry.credentials; + this.credentials = registry.credentials; } public DeviceRegistry build() { return new DeviceRegistry(this); } } + @Override public String toString() { - return ("id="+this.id+",name="+this.name - +",eventNotificationConfigs="+this.eventNotificationConfigs - +",stateNotificationConfig="+this.stateNotificationConfig - +"mqttConfig="+this.mqttConfig.toBuilder().build() - +",httpConfig="+this.httpConfig - +",logLevel="+this.logLevel - +",credentials="+this.credentials); + return ("id=" + this.id + ",name=" + this.name + + ",eventNotificationConfigs=" + this.eventNotificationConfigs + + ",stateNotificationConfig=" + this.stateNotificationConfig + + "mqttConfig=" + this.mqttConfig.toBuilder().build() + + ",httpConfig=" + this.httpConfig + + ",logLevel=" + this.logLevel + + ",credentials=" + this.credentials); } @SuppressWarnings("unchecked") @@ -273,16 +280,16 @@ public void loadFromString(String inputStr) { .build(); eventNotificationCfgs.add(eventObj); } - this.eventNotificationConfigs = eventNotificationCfgs; + this.eventNotificationConfigs = eventNotificationCfgs; } - if(key.equals("stateNotificationConfig")) { + if (key.equals("stateNotificationConfig")) { JSONObject stateJsonObject = (JSONObject) value; StateNotificationConfig stateNotificationCfg = new StateNotificationConfig(); if (stateJsonObject.containsKey("pubsubTopicName")) stateNotificationCfg.setPubsubTopicName((String) stateJsonObject.get("pubsubTopicName")); - this.stateNotificationConfig = stateNotificationCfg; + this.stateNotificationConfig = stateNotificationCfg; } - if(key.equals("mqttConfig")) { + if (key.equals("mqttConfig")) { JSONObject mqttJsonObject = (JSONObject) value; MqttConfig mqttCfg = new MqttConfig(); if (mqttJsonObject.containsKey("mqttEnabledState")) @@ -290,7 +297,7 @@ public void loadFromString(String inputStr) { MqttState.valueOf((String) mqttJsonObject.get("mqttEnabledState"))); this.mqttConfig = mqttCfg; } - if(key.equals("httpConfig")) { + if (key.equals("httpConfig")) { JSONObject httpJsonObject = (JSONObject) value; HttpConfig httpCfg = new HttpConfig(); if (httpJsonObject.containsKey("httpEnabledState")) @@ -321,8 +328,8 @@ public void loadFromString(String inputStr) { } } } catch (Exception e) { - e.printStackTrace(); + log.log(Level.SEVERE, e.getMessage()); } } - + } diff --git a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/utils/EventNotificationConfig.java b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/registrytypes/EventNotificationConfig.java similarity index 91% rename from clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/utils/EventNotificationConfig.java rename to clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/registrytypes/EventNotificationConfig.java index c8ac17b2..478dee33 100644 --- a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/utils/EventNotificationConfig.java +++ b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/registrytypes/EventNotificationConfig.java @@ -1,4 +1,4 @@ -package com.clearblade.cloud.iot.v1.utils; +package com.clearblade.cloud.iot.v1.registrytypes; import org.json.simple.JSONObject; @@ -6,28 +6,33 @@ public class EventNotificationConfig { private String subfolderMatches; private String pubsubTopicName; - + public EventNotificationConfig() { subfolderMatches = ""; pubsubTopicName = ""; } + private EventNotificationConfig(Builder builder) { subfolderMatches = builder.getSubfolderMatches(); pubsubTopicName = builder.getPubsubTopicName(); } - + public String getSubfolderMatches() { return subfolderMatches; } + public void setSubfolderMatches(String subfolderMatches) { this.subfolderMatches = subfolderMatches; } + public String getPubsubTopicName() { return pubsubTopicName; } + public void setPubsubTopicName(String pubsubTopicName) { this.pubsubTopicName = pubsubTopicName; } + public static Builder newBuilder() { return new Builder(); } @@ -37,42 +42,49 @@ public Builder toBuilder() { } /** - * Builder for setting + * Builder for setting * EventNotificationConfig - subfolderMatches , pubsubTopicName */ public static class Builder { private String subfolderMatches; private String pubsubTopicName; - + protected Builder() { - + } + private Builder(EventNotificationConfig eventNotificationConfig) { this.subfolderMatches = eventNotificationConfig.subfolderMatches; this.pubsubTopicName = eventNotificationConfig.pubsubTopicName; } + public EventNotificationConfig build() { return new EventNotificationConfig(this); } + public String getSubfolderMatches() { return subfolderMatches; } + public Builder setSubfolderMatches(String subfolderMatches) { this.subfolderMatches = subfolderMatches; return this; } + public String getPubsubTopicName() { return pubsubTopicName; } + public Builder setPubsubTopicName(String pubsubTopicName) { this.pubsubTopicName = pubsubTopicName; return this; } - + } + @Override public String toString() { - return "subfolderMatches= "+this.subfolderMatches+",pubsubTopicName="+this.pubsubTopicName; + return "subfolderMatches= " + this.subfolderMatches + ",pubsubTopicName=" + this.pubsubTopicName; } @SuppressWarnings("unchecked") diff --git a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/utils/HttpConfig.java b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/registrytypes/HttpConfig.java similarity index 90% rename from clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/utils/HttpConfig.java rename to clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/registrytypes/HttpConfig.java index 5d4f5b7c..5f6729d2 100644 --- a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/utils/HttpConfig.java +++ b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/registrytypes/HttpConfig.java @@ -1,27 +1,27 @@ -package com.clearblade.cloud.iot.v1.utils; +package com.clearblade.cloud.iot.v1.registrytypes; import org.json.simple.JSONObject; public class HttpConfig { private HttpState httpEnabledState; - + public HttpConfig() { httpEnabledState = HttpState.HTTP_ENABLED; } + private HttpConfig(Builder builder) { this.httpEnabledState = builder.getHttpState(); } - - + public HttpState getHttpEnabledState() { return httpEnabledState; } - - + public void setHttpEnabledState(HttpState httpEnabledState) { this.httpEnabledState = httpEnabledState; } + public static Builder newBuilder() { return new Builder(); } @@ -31,30 +31,35 @@ public Builder toBuilder() { } /** - * Builder for setting + * Builder for setting * HttpConfig - httpConfig */ public static class Builder { private HttpState httpState; - + protected Builder() { - + } + private Builder(HttpConfig config) { - this.httpState = config.httpEnabledState; + this.httpState = config.httpEnabledState; } + public HttpConfig build() { return new HttpConfig(this); } + public HttpState getHttpState() { return httpState; } + public Builder setHttpState(HttpState state) { this.httpState = state; return this; } - + } + @Override public String toString() { return "{'httpEnabledState':'" + this.httpEnabledState + "'}"; diff --git a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/registrytypes/HttpState.java b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/registrytypes/HttpState.java new file mode 100644 index 00000000..fb31f9b9 --- /dev/null +++ b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/registrytypes/HttpState.java @@ -0,0 +1,57 @@ +package com.clearblade.cloud.iot.v1.registrytypes; + +public enum HttpState { + HTTP_STATE_UNSPECIFIED(0), + HTTP_ENABLED(1), + HTTP_DISABLED(2), + UNRECOGNIZED(-1), + ; + + public static final int HTTP_STATE_UNSPECIFIED_VALUE = 0; + public static final int HTTP_ENABLED_VALUE = 1; + public static final int HTTP_DISABLED_VALUE = 2; + + public final int getNumber() { + if (this == UNRECOGNIZED) { + throw new java.lang.IllegalArgumentException( + "Can't get the number of an unknown enum value."); + } + return value; + } + + /** + * @param value The numeric wire value of the corresponding enum entry. + * @return The enum associated with the given numeric wire value. + */ + public static HttpState valueOf(int value) { + return forNumber(value); + } + + /** + * @param value The numeric wire value of the corresponding enum entry. + * @return The enum associated with the given numeric wire value. + */ + public static HttpState forNumber(int value) { + switch (value) { + case 0: + return HTTP_STATE_UNSPECIFIED; + case 1: + return HTTP_ENABLED; + case 2: + return HTTP_DISABLED; + default: + return null; + } + } + + public HttpState findValueByNumber(int number) { + return HttpState.forNumber(number); + } + + private final int value; + + private HttpState(int value) { + this.value = value; + } + +} diff --git a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/utils/LocationName.java b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/registrytypes/LocationName.java similarity index 97% rename from clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/utils/LocationName.java rename to clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/registrytypes/LocationName.java index 4dbfb654..cbc8df04 100644 --- a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/utils/LocationName.java +++ b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/registrytypes/LocationName.java @@ -1,4 +1,4 @@ -package com.clearblade.cloud.iot.v1.utils; +package com.clearblade.cloud.iot.v1.registrytypes; public class LocationName { diff --git a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/utils/MqttConfig.java b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/registrytypes/MqttConfig.java similarity index 94% rename from clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/utils/MqttConfig.java rename to clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/registrytypes/MqttConfig.java index a2d203f1..73311b66 100644 --- a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/utils/MqttConfig.java +++ b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/registrytypes/MqttConfig.java @@ -1,25 +1,27 @@ -package com.clearblade.cloud.iot.v1.utils; +package com.clearblade.cloud.iot.v1.registrytypes; import org.json.simple.JSONObject; public class MqttConfig { private MqttState mqttEnabledState; - + public MqttConfig() { mqttEnabledState = MqttState.MQTT_ENABLED; } + private MqttConfig(Builder builder) { this.mqttEnabledState = builder.mqttEnabledState; } - - + public MqttState getMqttEnabledState() { return mqttEnabledState; } + public void setMqttEnabledState(MqttState mqttEnabledState) { this.mqttEnabledState = mqttEnabledState; } + public static Builder newBuilder() { return new Builder(); } @@ -29,30 +31,35 @@ public Builder toBuilder() { } /** - * Builder for setting + * Builder for setting * MqttState - mqttEnabledState */ public static class Builder { private MqttState mqttEnabledState; - + protected Builder() { - + } + private Builder(MqttConfig config) { this.mqttEnabledState = config.mqttEnabledState; } + public MqttConfig build() { return new MqttConfig(this); } + public MqttState getMqttEnabledState() { return mqttEnabledState; } + public Builder setMqttEnabledState(MqttState mqttEnabledState) { this.mqttEnabledState = mqttEnabledState; return this; } - + } + @Override public String toString() { return "{'mqttEnabledState':'" + this.mqttEnabledState + "'}"; diff --git a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/registrytypes/MqttState.java b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/registrytypes/MqttState.java new file mode 100644 index 00000000..71b4d687 --- /dev/null +++ b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/registrytypes/MqttState.java @@ -0,0 +1,57 @@ +package com.clearblade.cloud.iot.v1.registrytypes; + +public enum MqttState { + MQTT_STATE_UNSPECIFIED(0), + MQTT_ENABLED(1), + MQTT_DISABLED(2), + UNRECOGNIZED(-1), + ; + + public static final int MQTT_STATE_UNSPECIFIED_VALUE = 0; + public static final int MQTT_ENABLED_VALUE = 1; + public static final int MQTT_DISABLED_VALUE = 2; + + public final int getNumber() { + if (this == UNRECOGNIZED) { + throw new java.lang.IllegalArgumentException( + "Can't get the number of an unknown enum value."); + } + return value; + } + + /** + * @param value The numeric wire value of the corresponding enum entry. + * @return The enum associated with the given numeric wire value. + */ + public static MqttState valueOf(int value) { + return forNumber(value); + } + + /** + * @param value The numeric wire value of the corresponding enum entry. + * @return The enum associated with the given numeric wire value. + */ + public static MqttState forNumber(int value) { + switch (value) { + case 0: + return MQTT_STATE_UNSPECIFIED; + case 1: + return MQTT_ENABLED; + case 2: + return MQTT_DISABLED; + default: + return null; + } + } + + public MqttState findValueByNumber(int number) { + return MqttState.forNumber(number); + } + + private final int value; + + private MqttState(int value) { + this.value = value; + } + +} diff --git a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/utils/PublicKeyCertificate.java b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/registrytypes/PublicKeyCertificate.java similarity index 92% rename from clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/utils/PublicKeyCertificate.java rename to clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/registrytypes/PublicKeyCertificate.java index 6cfbe596..0dfddb4c 100644 --- a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/utils/PublicKeyCertificate.java +++ b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/registrytypes/PublicKeyCertificate.java @@ -1,32 +1,38 @@ -package com.clearblade.cloud.iot.v1.utils; +package com.clearblade.cloud.iot.v1.registrytypes; public class PublicKeyCertificate { - + private PublicKeyCertificateFormat format; private String certificate; private X509CertificateDetails x509Details; - + public PublicKeyCertificateFormat getFormat() { return format; } + public void setFormat(PublicKeyCertificateFormat format) { this.format = format; } + public String getCertificate() { return certificate; } + public void setCertificate(String certificate) { this.certificate = certificate; } + public X509CertificateDetails getX509Details() { return x509Details; } + public void setX509Details(X509CertificateDetails x509Details) { this.x509Details = x509Details; } + @Override public String toString() { return "PublicKeyCertificateFormat=" + this.format.toString() + ",Certificate=" + certificate; } - + } diff --git a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/utils/PublicKeyCertificateFormat.java b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/registrytypes/PublicKeyCertificateFormat.java similarity index 86% rename from clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/utils/PublicKeyCertificateFormat.java rename to clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/registrytypes/PublicKeyCertificateFormat.java index e62daba7..418e7ab9 100644 --- a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/utils/PublicKeyCertificateFormat.java +++ b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/registrytypes/PublicKeyCertificateFormat.java @@ -1,4 +1,4 @@ -package com.clearblade.cloud.iot.v1.utils; +package com.clearblade.cloud.iot.v1.registrytypes; public enum PublicKeyCertificateFormat { UNSPECIFIED_PUBLIC_KEY_CERTIFICATE_FORMAT(0), X509_CERTIFICATE_PEM(1), UNRECOGNIZED(-1),; @@ -27,12 +27,12 @@ public static PublicKeyCertificateFormat valueOf(int value) { */ public static PublicKeyCertificateFormat forNumber(int value) { switch (value) { - case 0: - return UNSPECIFIED_PUBLIC_KEY_CERTIFICATE_FORMAT; - case 1: - return X509_CERTIFICATE_PEM; - default: - return null; + case 0: + return UNSPECIFIED_PUBLIC_KEY_CERTIFICATE_FORMAT; + case 1: + return X509_CERTIFICATE_PEM; + default: + return null; } } diff --git a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/utils/PublicKeyCredential.java b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/registrytypes/PublicKeyCredential.java similarity index 95% rename from clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/utils/PublicKeyCredential.java rename to clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/registrytypes/PublicKeyCredential.java index aa76a081..3d519bcd 100644 --- a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/utils/PublicKeyCredential.java +++ b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/registrytypes/PublicKeyCredential.java @@ -1,13 +1,13 @@ -package com.clearblade.cloud.iot.v1.utils; +package com.clearblade.cloud.iot.v1.registrytypes; public class PublicKeyCredential { - + private PublicKeyFormat format; private String key; - + public PublicKeyCredential() { } - + public void setFormat(PublicKeyFormat format) { this.format = format; } @@ -20,6 +20,7 @@ private PublicKeyCredential(Builder builder) { format = builder.format; key = builder.key; } + public static Builder newBuilder() { return new Builder(); } @@ -27,7 +28,7 @@ public static Builder newBuilder() { public Builder toBuilder() { return new Builder(this); } - + public static class Builder { private PublicKeyFormat format; private String key; @@ -53,15 +54,15 @@ public Builder setKey(String key) { this.key = key; return this; } - + private Builder(PublicKeyCredential publicKeyCredential) { this.format = publicKeyCredential.format; this.key = publicKeyCredential.key; } + public PublicKeyCredential build() { return new PublicKeyCredential(this); } } - - + } diff --git a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/utils/PublicKeyFormat.java b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/registrytypes/PublicKeyFormat.java similarity index 82% rename from clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/utils/PublicKeyFormat.java rename to clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/registrytypes/PublicKeyFormat.java index 327ecf89..bbc592b5 100644 --- a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/utils/PublicKeyFormat.java +++ b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/registrytypes/PublicKeyFormat.java @@ -1,4 +1,4 @@ -package com.clearblade.cloud.iot.v1.utils; +package com.clearblade.cloud.iot.v1.registrytypes; public enum PublicKeyFormat { UNSPECIFIED_PUBLIC_KEY_FORMAT(0), RSA_PEM(3), RSA_X509_PEM(1), ES256_PEM(2), ES256_X509_PEM(4), UNRECOGNIZED(-1),; @@ -30,18 +30,18 @@ public static PublicKeyFormat valueOf(int value) { */ public static PublicKeyFormat forNumber(int value) { switch (value) { - case 0: - return UNSPECIFIED_PUBLIC_KEY_FORMAT; - case 3: - return RSA_PEM; - case 1: - return RSA_X509_PEM; - case 2: - return ES256_PEM; - case 4: - return ES256_X509_PEM; - default: - return null; + case 0: + return UNSPECIFIED_PUBLIC_KEY_FORMAT; + case 3: + return RSA_PEM; + case 1: + return RSA_X509_PEM; + case 2: + return ES256_PEM; + case 4: + return ES256_X509_PEM; + default: + return null; } } diff --git a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/utils/RegistryCredential.java b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/registrytypes/RegistryCredential.java similarity index 98% rename from clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/utils/RegistryCredential.java rename to clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/registrytypes/RegistryCredential.java index b48841ef..520fdd41 100644 --- a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/utils/RegistryCredential.java +++ b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/registrytypes/RegistryCredential.java @@ -1,4 +1,4 @@ -package com.clearblade.cloud.iot.v1.utils; +package com.clearblade.cloud.iot.v1.registrytypes; import org.json.simple.JSONObject; diff --git a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/utils/RegistryName.java b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/registrytypes/RegistryName.java similarity index 88% rename from clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/utils/RegistryName.java rename to clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/registrytypes/RegistryName.java index 26508b89..c97240fa 100644 --- a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/utils/RegistryName.java +++ b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/registrytypes/RegistryName.java @@ -1,11 +1,11 @@ -package com.clearblade.cloud.iot.v1.utils; +package com.clearblade.cloud.iot.v1.registrytypes; public class RegistryName { - + private final String project; private final String location; private final String registry; - + protected RegistryName() { project = null; location = null; @@ -96,12 +96,14 @@ public RegistryName build() { return new RegistryName(this); } } + @Override public String toString() { - return "projects/"+this.getProject()+"/locations/"+this.getLocation(); + return "projects/" + this.getProject() + "/locations/" + this.getLocation(); } - + public String getRegistryFullName() { - return "projects/"+this.getProject()+"/locations/"+this.getLocation()+"/registries/"+this.getRegistry(); + return "projects/" + this.getProject() + "/locations/" + this.getLocation() + "/registries/" + + this.getRegistry(); } } diff --git a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/utils/StateNotificationConfig.java b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/registrytypes/StateNotificationConfig.java similarity index 94% rename from clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/utils/StateNotificationConfig.java rename to clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/registrytypes/StateNotificationConfig.java index 05ec1dd9..4108f5f5 100644 --- a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/utils/StateNotificationConfig.java +++ b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/registrytypes/StateNotificationConfig.java @@ -1,24 +1,27 @@ -package com.clearblade.cloud.iot.v1.utils; +package com.clearblade.cloud.iot.v1.registrytypes; import org.json.simple.JSONObject; public class StateNotificationConfig { private String pubsubTopicName; - + public StateNotificationConfig() { pubsubTopicName = ""; } + private StateNotificationConfig(Builder builder) { pubsubTopicName = builder.getPubsubTopicName(); } - + public String getPubsubTopicName() { return pubsubTopicName; } + public void setPubsubTopicName(String pubsubTopicName) { this.pubsubTopicName = pubsubTopicName; } + public static Builder newBuilder() { return new Builder(); } @@ -28,30 +31,35 @@ public Builder toBuilder() { } /** - * Builder for setting + * Builder for setting * StateNotificationConfig - pubsubTopicName */ public static class Builder { private String pubsubTopicName; - + protected Builder() { - + } + private Builder(StateNotificationConfig stateNotificationConfig) { this.pubsubTopicName = stateNotificationConfig.pubsubTopicName; } + public StateNotificationConfig build() { return new StateNotificationConfig(this); } + public String getPubsubTopicName() { return pubsubTopicName; } + public Builder setPubsubTopicName(String pubsubTopicName) { this.pubsubTopicName = pubsubTopicName; return this; } - + } + @Override public String toString() { return "pubsubTopicName=" + this.pubsubTopicName; diff --git a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/utils/X509CertificateDetails.java b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/registrytypes/X509CertificateDetails.java similarity index 95% rename from clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/utils/X509CertificateDetails.java rename to clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/registrytypes/X509CertificateDetails.java index 24e7f862..283f8152 100644 --- a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/utils/X509CertificateDetails.java +++ b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/registrytypes/X509CertificateDetails.java @@ -1,4 +1,4 @@ -package com.clearblade.cloud.iot.v1.utils; +package com.clearblade.cloud.iot.v1.registrytypes; public class X509CertificateDetails { @@ -8,17 +8,19 @@ public class X509CertificateDetails { private String expiryTime; private String signatureAlgorithm; private String publicKeyType; - - + public String getIssuer() { return issuer; } + public void setIssuer(String issuer) { this.issuer = issuer; } + public String getSubject() { return subject; } + public void setSubject(String subject) { this.subject = subject; } @@ -38,24 +40,28 @@ public String getExpiryTime() { public void setExpiryTime(String expiryTime) { this.expiryTime = expiryTime; } + public String getSignatureAlgorithm() { return signatureAlgorithm; } + public void setSignatureAlgorithm(String signatureAlgorithm) { this.signatureAlgorithm = signatureAlgorithm; } + public String getPublicKeyType() { return publicKeyType; } + public void setPublicKeyType(String publicKeyType) { this.publicKeyType = publicKeyType; } - + @Override public String toString() { return "Issuer= " + this.issuer + ",Subject=" + this.subject + ",startTime=" + this.startTime + ",expiryTime=" + this.expiryTime + ",signatureAlgorithm=" + this.signatureAlgorithm + ",publicKeyType=" + this.publicKeyType; } - + } diff --git a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/sendcommandtodevice/SendCommandToDeviceRequest.java b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/sendcommandtodevice/SendCommandToDeviceRequest.java index fedd7303..a9cae20f 100644 --- a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/sendcommandtodevice/SendCommandToDeviceRequest.java +++ b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/sendcommandtodevice/SendCommandToDeviceRequest.java @@ -4,9 +4,9 @@ import org.json.simple.JSONObject; +import com.clearblade.cloud.iot.v1.devicetypes.DeviceName; import com.clearblade.cloud.iot.v1.utils.ByteString; import com.clearblade.cloud.iot.v1.utils.Constants; -import com.clearblade.cloud.iot.v1.utils.DeviceName; public class SendCommandToDeviceRequest { diff --git a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/unbinddevicefromgateway/UnbindDeviceFromGatewayRequest.java b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/unbinddevicefromgateway/UnbindDeviceFromGatewayRequest.java index ac5abf6f..55de5727 100644 --- a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/unbinddevicefromgateway/UnbindDeviceFromGatewayRequest.java +++ b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/unbinddevicefromgateway/UnbindDeviceFromGatewayRequest.java @@ -2,8 +2,6 @@ import org.json.simple.JSONObject; -import com.clearblade.cloud.iot.v1.utils.Constants; - public class UnbindDeviceFromGatewayRequest { private final String parent; private final String gateway; @@ -74,10 +72,10 @@ public void setBodyParams(JSONObject bodyParams) { @SuppressWarnings("unchecked") @Override public String toString() { + requestParams = new JSONObject(); bodyParams = new JSONObject(); - String method = Constants.UNBIND_DEVICE_FROM_GATEWAY; - requestParams.put("method", method); + requestParams.put("method", "unbindDeviceFromGateway"); requestParams.put("parent", this.parent); bodyParams.put("gatewayId", this.gateway); @@ -92,7 +90,7 @@ public String toString() { @SuppressWarnings("unchecked") public String[] getBodyAndParams() { String[] output = new String[2]; - String params = "parent=" + this.parent + "&method=" + Constants.UNBIND_DEVICE_FROM_GATEWAY; + String params = "parent=" + this.parent + "&method=unbindDeviceFromGateway"; bodyParams = new JSONObject(); bodyParams.put("gatewayId", this.gateway); bodyParams.put("deviceId", this.device); diff --git a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/updatedevice/UpdateDeviceRequest.java b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/updatedevice/UpdateDeviceRequest.java index ae7bf979..df9a3048 100644 --- a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/updatedevice/UpdateDeviceRequest.java +++ b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/updatedevice/UpdateDeviceRequest.java @@ -2,7 +2,7 @@ import org.json.simple.JSONObject; -import com.clearblade.cloud.iot.v1.utils.Device; +import com.clearblade.cloud.iot.v1.devicetypes.Device; public class UpdateDeviceRequest { private final String name; @@ -16,6 +16,7 @@ private UpdateDeviceRequest(Builder builder) { this.updateMask = builder.updateMask; this.device = builder.device; } + public JSONObject getRequestParams() { return requestParams; } @@ -52,7 +53,7 @@ public Builder setName(String name) { this.name = name; return this; } - + public Builder setDevice(Device device) { this.device = device; return this; @@ -62,7 +63,7 @@ public Builder setUpdateMask(String updateMask) { this.updateMask = updateMask; return this; } - + // build method to deal with outer class // to return outer instance public UpdateDeviceRequest build() { @@ -75,27 +76,28 @@ public UpdateDeviceRequest build() { public String toString() { requestParams.put("name", this.name); requestParams.put("updateMask", this.updateMask); - + bodyParams.put("id", this.device.toBuilder().getId()); bodyParams.put("name", this.device.toBuilder().getName()); bodyParams.put("logLevel", this.device.toBuilder().getLogLevel()); bodyParams.put("blocked", this.device.toBuilder().isBlocked()); - - return "name=" + this.name + ",updateMask=" + this.updateMask+", logLevel= "+this.device.toBuilder().getLogLevel(); + + return "name=" + this.name + ",updateMask=" + this.updateMask + ", logLevel= " + + this.device.toBuilder().getLogLevel(); } - + @SuppressWarnings("unchecked") public String[] getBodyAndParams() { String[] output = new String[2]; - - String params = "name="+this.name+"&updateMask="+this.updateMask; + + String params = "name=" + this.name + "&updateMask=" + this.updateMask; bodyParams = new JSONObject(); bodyParams.put("id", this.device.toBuilder().getId()); bodyParams.put("name", this.device.toBuilder().getName()); bodyParams.put("logLevel", this.device.toBuilder().getLogLevel().toString()); bodyParams.put("blocked", this.device.toBuilder().isBlocked()); - + output[0] = params; output[1] = bodyParams.toString(); return output; diff --git a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/updatedeviceregistry/UpdateDeviceRegistryRequest.java b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/updatedeviceregistry/UpdateDeviceRegistryRequest.java index 0b7fb89e..3ab06c7f 100644 --- a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/updatedeviceregistry/UpdateDeviceRegistryRequest.java +++ b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/updatedeviceregistry/UpdateDeviceRegistryRequest.java @@ -2,21 +2,22 @@ import org.json.simple.JSONObject; -import com.clearblade.cloud.iot.v1.utils.DeviceRegistry; +import com.clearblade.cloud.iot.v1.registrytypes.DeviceRegistry; public class UpdateDeviceRegistryRequest { private String name; - private String updateMask; - private DeviceRegistry deviceRegistry; + private String updateMask; + private DeviceRegistry deviceRegistry; JSONObject requestParams; JSONObject bodyParams; - + private UpdateDeviceRegistryRequest(Builder builder) { this.name = builder.name; this.updateMask = builder.updateMask; this.deviceRegistry = builder.deviceRegistry; } + public JSONObject getRequestParams() { return requestParams; } @@ -39,7 +40,7 @@ public static class Builder { /// instance fields private String name; private String updateMask; - private DeviceRegistry deviceRegistry; + private DeviceRegistry deviceRegistry; public static Builder newBuilder() { return new Builder(); @@ -53,7 +54,7 @@ public Builder setName(String name) { this.name = name; return this; } - + public Builder setDeviceRegistry(DeviceRegistry deviceRegistry) { this.deviceRegistry = deviceRegistry; return this; @@ -63,7 +64,7 @@ public Builder setUpdateMask(String updateMask) { this.updateMask = updateMask; return this; } - + // build method to deal with outer class // to return outer instance public UpdateDeviceRegistryRequest build() { @@ -76,23 +77,23 @@ public UpdateDeviceRegistryRequest build() { public String toString() { requestParams.put("name", this.name); requestParams.put("updateMask", this.updateMask); - + bodyParams.put("id", this.deviceRegistry.toBuilder().getId()); bodyParams.put("name", this.deviceRegistry.toBuilder().getName()); bodyParams.put("logLevel", this.deviceRegistry.toBuilder().getLogLevel()); - - return "name=" + this.name + ",updateMask=" + this.updateMask+", logLevel= "+this.deviceRegistry.toBuilder().getLogLevel(); + + return "name=" + this.name + ",updateMask=" + this.updateMask + ", logLevel= " + + this.deviceRegistry.toBuilder().getLogLevel(); } - + public String[] getBodyAndParams() { String[] output = new String[2]; - - String params = "name="+this.name+"&updateMask="+this.updateMask; - + + String params = "name=" + this.name + "&updateMask=" + this.updateMask; + output[0] = params; output[1] = this.deviceRegistry.createDeviceJSONObject(""); return output; } - } diff --git a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/utils/AuthParams.java b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/utils/AuthParams.java index ab02bbd0..47c417b8 100644 --- a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/utils/AuthParams.java +++ b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/utils/AuthParams.java @@ -1,7 +1,9 @@ package com.clearblade.cloud.iot.v1.utils; import java.io.BufferedReader; +import java.io.FileNotFoundException; import java.io.FileReader; +import java.io.IOException; import java.io.InputStreamReader; import java.io.OutputStream; import java.net.URL; @@ -13,10 +15,12 @@ import org.json.simple.JSONObject; import org.json.simple.parser.JSONParser; +import com.clearblade.cloud.iot.v1.exception.ApplicationException; + public class AuthParams { static Logger log = Logger.getLogger(AuthParams.class.getName()); - private static String adminSystemKey = null; + private static String adminSystemKey = null; private static String project = null; private static String baseURL = null; private static String adminToken = null; @@ -52,101 +56,107 @@ public static String getApiBaseURL() { return apiBaseURL; } - public static void setAdminCredentials() { + public static void setAdminCredentials() throws ApplicationException, IOException { - if(adminSystemKey != null) { + if (adminSystemKey != null) { return; } - String pathToAuthFile = System.getenv(Constants.AUTH_ACCESS); - - JSONParser jsonParser = new JSONParser(); - try (FileReader authReader = new FileReader(pathToAuthFile)) { - // Read JSON file - Object obj = jsonParser.parse(authReader); - JSONObject authJSONObject = (JSONObject) obj; - if (authJSONObject != null) { - - adminSystemKey = (authJSONObject.get(Constants.ADMIN_SYSTEM_KEY)).toString(); - adminToken = (authJSONObject.get(Constants.ADMIN_TOKEN)).toString(); - baseURL = (authJSONObject.get(Constants.BASE_URL)).toString(); - project = (authJSONObject.get(Constants.PROJECT_NAME)).toString(); + try { + String pathToAuthFile = System.getenv(Constants.AUTH_ACCESS); + if (pathToAuthFile != null) { + JSONParser jsonParser = new JSONParser(); + FileReader authReader = new FileReader(pathToAuthFile); + // Read JSON file + Object obj = jsonParser.parse(authReader); + JSONObject authJSONObject = (JSONObject) obj; + if (authJSONObject != null) { + + adminSystemKey = (authJSONObject.get(Constants.ADMIN_SYSTEM_KEY)).toString(); + adminToken = (authJSONObject.get(Constants.ADMIN_TOKEN)).toString(); + baseURL = (authJSONObject.get(Constants.BASE_URL)).toString(); + project = (authJSONObject.get(Constants.PROJECT_NAME)).toString(); + } + } else { + log.log(Level.SEVERE, "CLEARBLADE_CONFIGURATION Enviornment variable not set"); + throw new ApplicationException("CLEARBLADE_CONFIGURATION Enviornment variable not set"); } + } catch (FileNotFoundException fe) { + log.log(Level.SEVERE, "ClearBlade Configuration File not found"); + throw new FileNotFoundException("ClearBlade Configuration File not found"); + + } catch (IOException fe) { + log.log(Level.SEVERE, "Access Denied - ClearBlade Configuration File cannot be read"); + throw new IOException("Access Denied - ClearBlade Configuration File cannot be read"); + } catch (Exception e) { - log.log(Level.SEVERE, "Access Denied - ClearBlade Configuration variable is not set."); - e.printStackTrace(); + log.log(Level.SEVERE, e.getMessage()); + log.log(Level.SEVERE, e.getMessage()); + throw new ApplicationException(e.getMessage()); } - System.out.println(adminSystemKey); - System.out.println(adminToken); } - + @SuppressWarnings("unchecked") - public static void setRegistryCredentials() { - if(userSystemKey != null) { - return; + public static void setRegistryCredentials() throws ApplicationException, IOException { + if (userSystemKey != null) { + return; + } + setAdminCredentials(); + ConfigParameters configParameters = new ConfigParameters(); + String finalURL = baseURL.concat(configParameters.getGetSystemCredentialsExtension()) + .concat(adminSystemKey) + .concat("/" + Constants.GET_REGISTRY_CREDENTIALS); + URL obj = new URL(finalURL); + SetHttpConnection setCon = new SetHttpConnection(); + HttpsURLConnection con = setCon.getConnection(obj); + con.setRequestProperty(Constants.HTTP_REQUEST_PROPERTY_TOKEN_KEY, adminToken); + con.setRequestProperty(Constants.HTTP_REQUEST_PROPERTY_CONTENT_TYPE_KEY, + Constants.HTTP_REQUEST_PROPERTY_CONTENT_TYPE_ACCEPT_VALUE); + con.addRequestProperty(Constants.HTTP_REQUEST_PROPERTY_ACCEPT_KEY, + Constants.HTTP_REQUEST_PROPERTY_CONTENT_TYPE_ACCEPT_VALUE); + con.setRequestMethod(Constants.HTTP_REQUEST_METHOD_TYPE_POST); + con.setDoOutput(true); + StringBuilder response = new StringBuilder(); + try (OutputStream os = con.getOutputStream()) { + JSONObject js = new JSONObject(); + js.put("region", configParameters.getRegion()); + js.put("registry", configParameters.getRegistry()); + js.put("project", project); + + byte[] input = js.toString().getBytes(Constants.UTF8); + os.write(input, 0, input.length); + os.flush(); + int responseCode = con.getResponseCode(); + BufferedReader in = null; + if (con.getErrorStream() != null) { + in = new BufferedReader(new InputStreamReader(con.getErrorStream())); + } else if (con.getInputStream() != null) { + in = new BufferedReader(new InputStreamReader(con.getInputStream())); } - try { - setAdminCredentials(); - ConfigParameters configParameters = new ConfigParameters(); - String finalURL = baseURL .concat(configParameters.getGetSystemCredentialsExtension()) - .concat(adminSystemKey) - .concat("/"+Constants.GET_REGISTRY_CREDENTIALS); - URL obj = new URL(finalURL); - SetHttpConnection setCon = new SetHttpConnection(); - HttpsURLConnection con = setCon.getConnection(obj); - con.setRequestProperty(Constants.HTTP_REQUEST_PROPERTY_TOKEN_KEY, adminToken); - con.setRequestProperty(Constants.HTTP_REQUEST_PROPERTY_CONTENT_TYPE_KEY, - Constants.HTTP_REQUEST_PROPERTY_CONTENT_TYPE_ACCEPT_VALUE); - con.addRequestProperty(Constants.HTTP_REQUEST_PROPERTY_ACCEPT_KEY, - Constants.HTTP_REQUEST_PROPERTY_CONTENT_TYPE_ACCEPT_VALUE); - con.setRequestMethod(Constants.HTTP_REQUEST_METHOD_TYPE_POST); - con.setDoOutput(true); - StringBuilder response = new StringBuilder(); - try (OutputStream os = con.getOutputStream()) { - JSONObject js = new JSONObject(); - js.put("region", configParameters.getRegion()); - js.put("registry", configParameters.getRegistry()); - js.put("project", project); - - byte[] input = js.toString().getBytes(Constants.UTF8); - os.write(input, 0, input.length); - os.flush(); - int responseCode = con.getResponseCode(); - BufferedReader in = null; - if (con.getErrorStream() != null) { - in = new BufferedReader(new InputStreamReader(con.getErrorStream())); - } else if (con.getInputStream() != null) { - in = new BufferedReader(new InputStreamReader(con.getInputStream())); - } - JSONObject responseJSONObject = new JSONObject(); - JSONParser responseParser = new JSONParser(); - String inputLine; - String responseMessage = ""; - if (in != null) { - while ((inputLine = in.readLine()) != null) { - response.append(inputLine); - } - responseMessage = response.toString(); - System.out.println(responseMessage); + JSONObject responseJSONObject = new JSONObject(); + JSONParser responseParser = new JSONParser(); + String inputLine; + String responseMessage = ""; + if (in != null) { + while ((inputLine = in.readLine()) != null) { + response.append(inputLine); } - if (responseCode == 200) { - if(responseMessage != null && responseMessage.length() > 0) { - Object responseObj = responseParser.parse(responseMessage); - if(responseObj != null) { - responseJSONObject = (JSONObject) responseObj; - userSystemKey = responseJSONObject.get(Constants.USER_SYSTEM_KEY).toString(); - userToken = responseJSONObject.get(Constants.USER_TOKEN).toString(); - apiBaseURL = responseJSONObject.get(Constants.API_BASE_URL).toString(); - } + responseMessage = response.toString(); + } + if (responseCode == 200) { + if (responseMessage != null && responseMessage.length() > 0) { + Object responseObj = responseParser.parse(responseMessage); + if (responseObj != null) { + responseJSONObject = (JSONObject) responseObj; + userSystemKey = responseJSONObject.get(Constants.USER_SYSTEM_KEY).toString(); + userToken = responseJSONObject.get(Constants.USER_TOKEN).toString(); + apiBaseURL = responseJSONObject.get(Constants.API_BASE_URL).toString(); } } + } } catch (Exception e) { - e.printStackTrace(); + log.log(Level.SEVERE, e.getMessage()); } - - } catch (Exception e) { - e.printStackTrace(); } - } - + } diff --git a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/utils/ConfigParameters.java b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/utils/ConfigParameters.java index 5fd50514..7bc5ef06 100644 --- a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/utils/ConfigParameters.java +++ b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/utils/ConfigParameters.java @@ -3,16 +3,19 @@ import java.io.IOException; import java.io.InputStream; import java.util.Properties; +import java.util.logging.Level; +import java.util.logging.Logger; public class ConfigParameters { - + static Logger log = Logger.getLogger(ConfigParameters.class.getName()); + // Fields used to set values from properties file private String project; private String region; private String registry; private String endpointPort; - + private String getSystemCredentialsExtension; private String baseURL; @@ -20,8 +23,8 @@ public class ConfigParameters { private String devicesURLExtension; private String devicesStatesURLExtension; private String cloudiotdevicesURLExtension; - private String cloudiotDeviceConfigURLExtension; - private String cloudiotConfigURLExtension; + private String cloudiotDeviceConfigURLExtension; + private String cloudiotConfigURLExtension; // Fields used to fetch values from Properties file Properties properties; @@ -50,7 +53,7 @@ public void getConfigurations() { try { input.close(); } catch (IOException e) { - e.printStackTrace(); + log.log(Level.SEVERE, e.getMessage()); } } } @@ -72,7 +75,7 @@ public void setValues() { this.setProject(properties.getProperty("project")); this.setRegion(properties.getProperty("region")); this.setRegistry(properties.getProperty("registry")); - this.setGetSystemCredentialsExtension(properties.getProperty("getSystemCredentialsExtension")); + this.setGetSystemCredentialsExtension(properties.getProperty("getSystemCredentialsExtension")); this.setEndpointPort(properties.getProperty("endPointPort")); } @@ -107,8 +110,7 @@ public String getCloudiotdevicesURLExtension() { public void setCloudiotdevicesURLExtension(String cloudiotdevicesURLExtension) { this.cloudiotdevicesURLExtension = cloudiotdevicesURLExtension; } - - + public String getCloudiotDeviceConfigURLExtension() { return cloudiotDeviceConfigURLExtension; } @@ -116,7 +118,7 @@ public String getCloudiotDeviceConfigURLExtension() { public void setCloudiotDeviceConfigURLExtension(String cloudiotDeviceConfigURLExtension) { this.cloudiotDeviceConfigURLExtension = cloudiotDeviceConfigURLExtension; } - + public String getProject() { return project; } @@ -171,6 +173,6 @@ public String getCloudiotConfigURLExtension() { public void setCloudiotConfigURLExtension(String cloudiotConfigURLExtension) { this.cloudiotConfigURLExtension = cloudiotConfigURLExtension; - } + } } diff --git a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/utils/Constants.java b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/utils/Constants.java index 0f0c0f55..22806bc8 100644 --- a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/utils/Constants.java +++ b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/utils/Constants.java @@ -15,23 +15,6 @@ private Constants() {} public static final String USER_TOKEN = "serviceAccountToken"; public static final String API_BASE_URL = "url"; - public static final String SEND_COMMAND_TO_DEVICE = "sendCommandToDevice"; - public static final String CREATE_DEVICE = "createDevice"; - public static final String DELETE_DEVICE = "deleteDevice"; - public static final String GET_DEVICE = "getDevice"; - public static final String DEVICES_LIST = "devicesList"; - public static final String DEVICE_STATES_LIST = "deviceStatesList"; - public static final String DEVICE_SET_STATES = "setState"; - public static final String DEVICE_GET_CONFIG = "deviceGetConfig"; - public static final String MODIFY_CLOUD_TO_DEVICE_CONFIG = "modifyCloudToDeviceConfig"; - public static final String DEVICE_CONFIG_VERSIONS_LIST = "deviceConfigVersionsList"; - public static final String BIND_DEVICE_TO_GATEWAY = "bindDeviceToGateway"; - public static final String UNBIND_DEVICE_FROM_GATEWAY = "unbindDeviceFromGateway"; - public static final String UPDATE_DEVICE = "updateDevice"; - public static final String GET_REGISTRY_CREDENTIALS="getRegistryCredentials"; - public static final String GET_DEVICE_REGISTRY = "getDeviceRegistry"; - public static final String UPDATE_DEVICE_REGISTRY = "updateDeviceRegistry"; - public static final String CREATE_DEVICE_REGISTRY = "createDeviceRegistry"; // Constants used for setting up http connection - for common use public static final String HTTPS_URL_PREFIX = "https://"; @@ -44,10 +27,6 @@ private Constants() {} public static final String HTTP_REQUEST_PROPERTY_ACCEPT_KEY = "Accept"; public static final String HTTP_REQUEST_PROPERTY_CONTENT_TYPE_ACCEPT_VALUE = "application/json"; - //Commonly used String literal - public static final String SUBFOLDER = "subfolder"; - public static final String NAME = "?name="; - public static final String PARENT = "?parent="; public static final String UTF8 = "utf-8"; diff --git a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/utils/GatewayAuthMethod.java b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/utils/GatewayAuthMethod.java deleted file mode 100644 index 1a55cdb8..00000000 --- a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/utils/GatewayAuthMethod.java +++ /dev/null @@ -1,63 +0,0 @@ -package com.clearblade.cloud.iot.v1.utils; - -public enum GatewayAuthMethod { - - GATEWAY_AUTH_METHOD_UNSPECIFIED(0), - ASSOCIATION_ONLY(1), - DEVICE_AUTH_TOKEN_ONLY(2), - ASSOCIATION_AND_DEVICE_AUTH_TOKEN(3), - UNRECOGNIZED(-1), - ; - - public static final int GATEWAY_AUTH_METHOD_UNSPECIFIED_VALUE = 0; - public static final int ASSOCIATION_ONLY_VALUE = 1; - public static final int DEVICE_AUTH_TOKEN_ONLY_VALUE = 2; - public static final int ASSOCIATION_AND_DEVICE_AUTH_TOKEN_VALUE = 3; - - - public final int getNumber() { - if (this == UNRECOGNIZED) { - throw new java.lang.IllegalArgumentException( - "Can't get the number of an unknown enum value."); - } - return value; - } - - /** - * @param value The numeric wire value of the corresponding enum entry. - * @return The enum associated with the given numeric wire value. - */ - public static GatewayAuthMethod valueOf(int value) { - return forNumber(value); - } - - /** - * @param value The numeric wire value of the corresponding enum entry. - * @return The enum associated with the given numeric wire value. - */ - public static GatewayAuthMethod forNumber(int value) { - switch (value) { - case 0: - return GATEWAY_AUTH_METHOD_UNSPECIFIED; - case 1: - return ASSOCIATION_ONLY; - case 2: - return DEVICE_AUTH_TOKEN_ONLY; - case 3: - return ASSOCIATION_AND_DEVICE_AUTH_TOKEN; - default: - return null; - } - } - - public GatewayAuthMethod findValueByNumber(int number) { - return GatewayAuthMethod.forNumber(number); - } - - private final int value; - - private GatewayAuthMethod(int value) { - this.value = value; - } - -} diff --git a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/utils/GatewayType.java b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/utils/GatewayType.java deleted file mode 100644 index ccc9473f..00000000 --- a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/utils/GatewayType.java +++ /dev/null @@ -1,60 +0,0 @@ -package com.clearblade.cloud.iot.v1.utils; - -public enum GatewayType { - - GATEWAY_TYPE_UNSPECIFIED(0), - GATEWAY(1), - NON_GATEWAY(2), - UNRECOGNIZED(-1), - ; - - public static final int GATEWAY_TYPE_UNSPECIFIED_VALUE = 0; - public static final int GATEWAY_VALUE = 1; - public static final int NON_GATEWAY_VALUE = 2; - - - public final int getNumber() { - if (this == UNRECOGNIZED) { - throw new java.lang.IllegalArgumentException( - "Can't get the number of an unknown enum value."); - } - return value; - } - - /** - * @param value The numeric wire value of the corresponding enum entry. - * @return The enum associated with the given numeric wire value. - */ - public static GatewayType valueOf(int value) { - return forNumber(value); - } - - /** - * @param value The numeric wire value of the corresponding enum entry. - * @return The enum associated with the given numeric wire value. - */ - public static GatewayType forNumber(int value) { - switch (value) { - case 0: - return GATEWAY_TYPE_UNSPECIFIED; - case 1: - return GATEWAY; - case 2: - return NON_GATEWAY; - default: - return null; - } - } - - public GatewayType findValueByNumber(int number) { - return GatewayType.forNumber(number); - } - - private final int value; - - private GatewayType(int value) { - this.value = value; - } - - -} diff --git a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/utils/HttpState.java b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/utils/HttpState.java deleted file mode 100644 index d5b55ebd..00000000 --- a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/utils/HttpState.java +++ /dev/null @@ -1,57 +0,0 @@ -package com.clearblade.cloud.iot.v1.utils; - -public enum HttpState { - HTTP_STATE_UNSPECIFIED(0), - HTTP_ENABLED(1), - HTTP_DISABLED(2), - UNRECOGNIZED(-1), - ; - - public static final int HTTP_STATE_UNSPECIFIED_VALUE = 0; - public static final int HTTP_ENABLED_VALUE = 1; - public static final int HTTP_DISABLED_VALUE = 2; - - public final int getNumber() { - if (this == UNRECOGNIZED) { - throw new java.lang.IllegalArgumentException( - "Can't get the number of an unknown enum value."); - } - return value; - } - - /** - * @param value The numeric wire value of the corresponding enum entry. - * @return The enum associated with the given numeric wire value. - */ - public static HttpState valueOf(int value) { - return forNumber(value); - } - - /** - * @param value The numeric wire value of the corresponding enum entry. - * @return The enum associated with the given numeric wire value. - */ - public static HttpState forNumber(int value) { - switch (value) { - case 0: - return HTTP_STATE_UNSPECIFIED; - case 1: - return HTTP_ENABLED; - case 2: - return HTTP_DISABLED; - default: - return null; - } - } - - public HttpState findValueByNumber(int number) { - return HttpState.forNumber(number); - } - - private final int value; - - private HttpState(int value) { - this.value = value; - } - - } diff --git a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/utils/MqttState.java b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/utils/MqttState.java deleted file mode 100644 index 94355c15..00000000 --- a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/utils/MqttState.java +++ /dev/null @@ -1,57 +0,0 @@ -package com.clearblade.cloud.iot.v1.utils; - -public enum MqttState { - MQTT_STATE_UNSPECIFIED(0), - MQTT_ENABLED(1), - MQTT_DISABLED(2), - UNRECOGNIZED(-1), - ; - - public static final int MQTT_STATE_UNSPECIFIED_VALUE = 0; - public static final int MQTT_ENABLED_VALUE = 1; - public static final int MQTT_DISABLED_VALUE = 2; - - public final int getNumber() { - if (this == UNRECOGNIZED) { - throw new java.lang.IllegalArgumentException( - "Can't get the number of an unknown enum value."); - } - return value; - } - - /** - * @param value The numeric wire value of the corresponding enum entry. - * @return The enum associated with the given numeric wire value. - */ - public static MqttState valueOf(int value) { - return forNumber(value); - } - - /** - * @param value The numeric wire value of the corresponding enum entry. - * @return The enum associated with the given numeric wire value. - */ - public static MqttState forNumber(int value) { - switch (value) { - case 0: - return MQTT_STATE_UNSPECIFIED; - case 1: - return MQTT_ENABLED; - case 2: - return MQTT_DISABLED; - default: - return null; - } - } - - public MqttState findValueByNumber(int number) { - return MqttState.forNumber(number); - } - - private final int value; - - private MqttState(int value) { - this.value = value; - } - - } diff --git a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/utils/SetHttpConnection.java b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/utils/SetHttpConnection.java index 9ba92993..d1bb4c21 100644 --- a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/utils/SetHttpConnection.java +++ b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/utils/SetHttpConnection.java @@ -2,21 +2,24 @@ import java.io.IOException; import java.net.URL; +import java.util.logging.Level; +import java.util.logging.Logger; import javax.net.ssl.HttpsURLConnection; public class SetHttpConnection { + static Logger log = Logger.getLogger(SetHttpConnection.class.getName()); public HttpsURLConnection con; - + public SetHttpConnection() { con = null; } - + public HttpsURLConnection getConnection(URL url) { try { con = (HttpsURLConnection) url.openConnection(); } catch (IOException e) { - e.printStackTrace(); + log.log(Level.SEVERE, e.getMessage()); } return con; } From eaaab874a9977a02adf251aa2dcbafebb8179178 Mon Sep 17 00:00:00 2001 From: RashmiK14 Date: Wed, 23 Nov 2022 19:34:19 +0530 Subject: [PATCH 018/151] Updated for removal of constants --- .../iot/v1/sendcommandtodevice/SendCommandToDeviceRequest.java | 3 +-- .../src/com/clearblade/cloud/iot/v1/utils/AuthParams.java | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/sendcommandtodevice/SendCommandToDeviceRequest.java b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/sendcommandtodevice/SendCommandToDeviceRequest.java index a9cae20f..db535e95 100644 --- a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/sendcommandtodevice/SendCommandToDeviceRequest.java +++ b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/sendcommandtodevice/SendCommandToDeviceRequest.java @@ -6,7 +6,6 @@ import com.clearblade.cloud.iot.v1.devicetypes.DeviceName; import com.clearblade.cloud.iot.v1.utils.ByteString; -import com.clearblade.cloud.iot.v1.utils.Constants; public class SendCommandToDeviceRequest { @@ -111,7 +110,7 @@ public String toString() { @SuppressWarnings("unchecked") public String[] getBodyAndParams() { String[] output = new String[2]; - String params = "name=" + this.deviceName + "&method=" + Constants.SEND_COMMAND_TO_DEVICE; + String params = "name=" + this.deviceName + "&method=sendCommandToDevice"; String bData = null; if (this.binaryData != null) { bData = new String(this.binaryData.getBinaryDataArray()); diff --git a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/utils/AuthParams.java b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/utils/AuthParams.java index 47c417b8..2bae39d5 100644 --- a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/utils/AuthParams.java +++ b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/utils/AuthParams.java @@ -105,7 +105,7 @@ public static void setRegistryCredentials() throws ApplicationException, IOExcep ConfigParameters configParameters = new ConfigParameters(); String finalURL = baseURL.concat(configParameters.getGetSystemCredentialsExtension()) .concat(adminSystemKey) - .concat("/" + Constants.GET_REGISTRY_CREDENTIALS); + .concat("/getRegistryCredentials"); URL obj = new URL(finalURL); SetHttpConnection setCon = new SetHttpConnection(); HttpsURLConnection con = setCon.getConnection(obj); From fc55806832f86b981463ec569d8cd9688bbbf7c0 Mon Sep 17 00:00:00 2001 From: RashmiK14 Date: Mon, 28 Nov 2022 20:03:02 +0530 Subject: [PATCH 019/151] Set up environment variable, maven changes 1) Added logic to accept Registry and Location from Environmental Variables instead of hard coded values 2) Updated samples to work from maven command --- clearblade-cloud-iot/pom.xml | 23 ++-- .../v1/samples/getdevice/AsyncGetDevice.java | 13 +- .../v1/samples/getdevice/SyncGetDevice.java | 15 ++- .../AsyncGetDeviceRegistry.java | 13 +- .../SyncGetDeviceRegistry.java | 12 +- clearblade-cloud-iot/samples/pom.xml | 119 ++++++++++++++++++ .../clearblade/cloud/iot/v1/AsyncClient.java | 6 +- .../cloud/iot/v1/ClearBladeDeviceManager.java | 2 +- .../iot/v1/ClearBladeRegistryManager.java | 2 +- .../clearblade/cloud/iot/v1/SyncClient.java | 8 +- .../cloud/iot/v1/utils/AuthParams.java | 28 ++++- .../cloud/iot/v1/utils/ConfigParameters.java | 90 ++++--------- .../cloud/iot/v1/utils/Constants.java | 18 ++- clearblade-cloud-iot/src/config.properties | 14 --- 14 files changed, 241 insertions(+), 122 deletions(-) create mode 100644 clearblade-cloud-iot/samples/pom.xml delete mode 100644 clearblade-cloud-iot/src/config.properties diff --git a/clearblade-cloud-iot/pom.xml b/clearblade-cloud-iot/pom.xml index 42f44a87..f10ffabf 100644 --- a/clearblade-cloud-iot/pom.xml +++ b/clearblade-cloud-iot/pom.xml @@ -25,7 +25,7 @@ - samples + src @@ -42,10 +42,17 @@ - org.junit.jupiter - junit-jupiter-api - 5.9.1 - test + org.junit.jupiter + junit-jupiter-api + 5.8.2 + test + + + + org.junit.jupiter + junit-jupiter-engine + 5.8.2 + test @@ -53,11 +60,5 @@ jsr305 3.0.2 - - \ No newline at end of file diff --git a/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/getdevice/AsyncGetDevice.java b/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/getdevice/AsyncGetDevice.java index 2b0beab4..79ec357f 100644 --- a/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/getdevice/AsyncGetDevice.java +++ b/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/getdevice/AsyncGetDevice.java @@ -10,15 +10,22 @@ public class AsyncGetDevice { static Logger log = Logger.getLogger(AsyncGetDevice.class.getName()); + public static String PROJECT = ""; + public static String LOCATION = ""; + public static String REGISTRY = ""; + public static String DEVICE = ""; - public static void main(String[] args) { + public static void main(String[] args) { + PROJECT = args[0]; + LOCATION = args[1]; + REGISTRY = args[2]; + DEVICE = args[3]; asyncGetDevice(); } public static void asyncGetDevice() { DeviceManagerAsyncClient deviceManagerAsyncClient = new DeviceManagerAsyncClient(); - DeviceName name = DeviceName.of("ingressdevelopmentenv", "us-central1", "Rashmi_Registry_Test", - "Rashmi_Device_Test"); + DeviceName name = DeviceName.of(PROJECT, LOCATION, REGISTRY,DEVICE); GetDeviceRequest request = GetDeviceRequest.Builder.newBuilder().setName(name) .setFieldMask(FieldMask.newBuilder().build()).build(); Device response = deviceManagerAsyncClient.getDevice(request); diff --git a/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/getdevice/SyncGetDevice.java b/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/getdevice/SyncGetDevice.java index 06be3ff0..7a6416ae 100644 --- a/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/getdevice/SyncGetDevice.java +++ b/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/getdevice/SyncGetDevice.java @@ -10,15 +10,22 @@ public class SyncGetDevice { static Logger log = Logger.getLogger(SyncGetDevice.class.getName()); - - public static void main(String[] args) { + public static String PROJECT = ""; + public static String LOCATION = ""; + public static String REGISTRY = ""; + public static String DEVICE = ""; + public static void main(String[] args) { + PROJECT = args[0]; + LOCATION = args[1]; + REGISTRY = args[2]; + DEVICE = args[3]; syncGetDevice(); } public static void syncGetDevice() { DeviceManagerClient deviceManagerClient = new DeviceManagerClient(); - DeviceName name = DeviceName.of("ingressdevelopmentenv", "us-central1", "Rashmi_Registry_Test", - "Rashmi_Device_Test"); + //DeviceName name = DeviceName.of("ingressdevelopmentenv", "us-central1", "Rashmi_Registry_Test", "Rashmi_Device_Test"); + DeviceName name = DeviceName.of(PROJECT, LOCATION, REGISTRY, DEVICE); GetDeviceRequest request = GetDeviceRequest.Builder.newBuilder().setName(name) .setFieldMask(FieldMask.newBuilder().build()).build(); Device response = deviceManagerClient.getDevice(request); diff --git a/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/getdeviceregistry/AsyncGetDeviceRegistry.java b/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/getdeviceregistry/AsyncGetDeviceRegistry.java index 60e440b6..0a9255ac 100644 --- a/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/getdeviceregistry/AsyncGetDeviceRegistry.java +++ b/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/getdeviceregistry/AsyncGetDeviceRegistry.java @@ -9,16 +9,21 @@ public class AsyncGetDeviceRegistry { static Logger log = Logger.getLogger(AsyncGetDeviceRegistry.class.getName()); - - public static void main(String[] args) { + public static String PROJECT = ""; + public static String LOCATION = ""; + public static String REGISTRY = ""; + + public static void main(String[] args) { + PROJECT = args[0]; + LOCATION = args[1]; + REGISTRY = args[2]; asyncGetDeviceRegistry(); } public static void asyncGetDeviceRegistry() { DeviceManagerClient deviceManagerClient = new DeviceManagerClient(); GetDeviceRegistryRequest request = GetDeviceRegistryRequest.Builder.newBuilder() - .setName(RegistryName.of("ingressdevelopmentenv", "us-central1", "Rashmi_Registry_Test") - .getRegistryFullName()) + .setName(RegistryName.of(PROJECT, LOCATION, REGISTRY).getRegistryFullName()) .build(); DeviceRegistry response = deviceManagerClient.getDeviceRegistry(request); System.out.println(response.toString()); diff --git a/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/getdeviceregistry/SyncGetDeviceRegistry.java b/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/getdeviceregistry/SyncGetDeviceRegistry.java index 4e7f3827..245c046c 100644 --- a/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/getdeviceregistry/SyncGetDeviceRegistry.java +++ b/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/getdeviceregistry/SyncGetDeviceRegistry.java @@ -9,15 +9,21 @@ public class SyncGetDeviceRegistry { static Logger log = Logger.getLogger(SyncGetDeviceRegistry.class.getName()); - - public static void main(String[] args) { + public static String PROJECT = ""; + public static String LOCATION = ""; + public static String REGISTRY = ""; + + public static void main(String[] args) { + PROJECT = args[0]; + LOCATION = args[1]; + REGISTRY = args[2]; syncGetDeviceRegistry(); } public static void syncGetDeviceRegistry() { DeviceManagerAsyncClient deviceManagerAsyncClient = new DeviceManagerAsyncClient(); GetDeviceRegistryRequest request = GetDeviceRegistryRequest.Builder.newBuilder() - .setName(RegistryName.of("ingressdevelopmentenv", "us-central1", "MandarTest1").getRegistryFullName()) + .setName(RegistryName.of(PROJECT, LOCATION, REGISTRY).getRegistryFullName()) .build(); DeviceRegistry response = deviceManagerAsyncClient.getDeviceRegistry(request); System.out.println(response.createDeviceJSONObject("")); diff --git a/clearblade-cloud-iot/samples/pom.xml b/clearblade-cloud-iot/samples/pom.xml new file mode 100644 index 00000000..8b1ace2d --- /dev/null +++ b/clearblade-cloud-iot/samples/pom.xml @@ -0,0 +1,119 @@ + + 4.0.0 + clearblade-cloud-iot + clearblade-cloud-iot-samples + 0.0.1-SNAPSHOT + + . + + + org.apache.maven.plugins + maven-compiler-plugin + 3.8.0 + + 17 + + + + org.codehaus.mojo + build-helper-maven-plugin + 3.0.0 + + + generate-sources + + add-source + + + + . + ../src + + + + + + + org.apache.maven.plugins + maven-dependency-plugin + 3.3.0 + + + copy-dependencies + package + + copy-dependencies + + + ./target + false + true + true + + + + + + + + org.codehaus.mojo + exec-maven-plugin + 1.4.0 + + java + + + + clearblade-cloud-iot + clearblade-cloud-iot-samples + 0.0.1-SNAPSHOT + jar + + + + + + + + + + com.googlecode.json-simple + json-simple + 1.1.1 + + + + org.junit.jupiter + junit-jupiter-api + 5.8.2 + test + + + + org.junit.jupiter + junit-jupiter-engine + 5.8.2 + test + + + + com.google.code.findbugs + jsr305 + 3.0.2 + + + \ No newline at end of file diff --git a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/AsyncClient.java b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/AsyncClient.java index 79613cc4..f2c6d931 100644 --- a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/AsyncClient.java +++ b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/AsyncClient.java @@ -25,7 +25,7 @@ public class AsyncClient { static Logger log = Logger.getLogger(AsyncClient.class.getName()); - private ConfigParameters configParameters = new ConfigParameters(); + private ConfigParameters configParameters = ConfigParameters.getInstance(); private String[] responseArray = new String[3]; private String apiName; private String params; @@ -43,7 +43,7 @@ private String generateURL(String apiName, String params) { return AuthParams.getApiBaseURL() .concat(configParameters.getEndpointPort()) - .concat(configParameters.getBaseURL()) + .concat(configParameters.getWebhook()) .concat(AuthParams.getUserSystemKey()) .concat(apiName) .concat("?" + params); @@ -59,7 +59,7 @@ private String generateURL(String apiName, String params) { private String generateAdminURL(String apiName, String params) { return AuthParams.getBaseURL() - .concat(configParameters.getBaseURL()) + .concat(configParameters.getWebhook()) .concat(AuthParams.getAdminSystemKey()) .concat(apiName) .concat("?" + params); diff --git a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/ClearBladeDeviceManager.java b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/ClearBladeDeviceManager.java index 5eaa883f..5927c6fa 100644 --- a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/ClearBladeDeviceManager.java +++ b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/ClearBladeDeviceManager.java @@ -28,7 +28,7 @@ public class ClearBladeDeviceManager { static Logger log = Logger.getLogger(ClearBladeDeviceManager.class.getName()); - ConfigParameters configParameters = new ConfigParameters(); + ConfigParameters configParameters = ConfigParameters.getInstance(); public Device getDevice(GetDeviceRequest request) { SyncClient syncClient = new SyncClient(); diff --git a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/ClearBladeRegistryManager.java b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/ClearBladeRegistryManager.java index 4945f89c..bdf37658 100644 --- a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/ClearBladeRegistryManager.java +++ b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/ClearBladeRegistryManager.java @@ -12,7 +12,7 @@ public class ClearBladeRegistryManager { static Logger log = Logger.getLogger(ClearBladeRegistryManager.class.getName()); - ConfigParameters configParameters = new ConfigParameters(); + ConfigParameters configParameters = ConfigParameters.getInstance(); public DeviceRegistry getRegistry(GetDeviceRegistryRequest request) { SyncClient syncClient = new SyncClient(); diff --git a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/SyncClient.java b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/SyncClient.java index 1cc89ca6..7e772762 100644 --- a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/SyncClient.java +++ b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/SyncClient.java @@ -19,7 +19,8 @@ public class SyncClient { static Logger log = Logger.getLogger(SyncClient.class.getName()); - private ConfigParameters configParameters = new ConfigParameters(); + private ConfigParameters configParameters = ConfigParameters.getInstance(); + /** * Method used to generate URL for apicall @@ -32,7 +33,7 @@ private String generateURL(String apiName, String params) { return AuthParams.getApiBaseURL() .concat(configParameters.getEndpointPort()) - .concat(configParameters.getBaseURL()) + .concat(configParameters.getWebhook()) .concat(AuthParams.getUserSystemKey()) .concat(apiName) .concat("?" + params); @@ -40,7 +41,6 @@ private String generateURL(String apiName, String params) { /** * Method used to generate URL for apicall - * * @param apiName - path to api * @param params - parameters to be attached to request * @return URL formed and to be used @@ -48,7 +48,7 @@ private String generateURL(String apiName, String params) { private String generateAdminURL(String apiName, String params) { return AuthParams.getBaseURL() - .concat(configParameters.getBaseURL()) + .concat(configParameters.getWebhook()) .concat(AuthParams.getAdminSystemKey()) .concat(apiName) .concat("?" + params); diff --git a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/utils/AuthParams.java b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/utils/AuthParams.java index 2bae39d5..5d063d7e 100644 --- a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/utils/AuthParams.java +++ b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/utils/AuthParams.java @@ -19,7 +19,7 @@ public class AuthParams { static Logger log = Logger.getLogger(AuthParams.class.getName()); - + static ConfigParameters configParameters = ConfigParameters.getInstance(); private static String adminSystemKey = null; private static String project = null; private static String baseURL = null; @@ -90,19 +90,37 @@ public static void setAdminCredentials() throws ApplicationException, IOExceptio throw new IOException("Access Denied - ClearBlade Configuration File cannot be read"); } catch (Exception e) { - log.log(Level.SEVERE, e.getMessage()); log.log(Level.SEVERE, e.getMessage()); throw new ApplicationException(e.getMessage()); } } + private static void setRegistryRegion() throws ApplicationException { + if(configParameters.getRegistry()==null) { + String registryName = System.getenv(Constants.AUTH_REGISTRY); + if(registryName != null) { + configParameters.setRegistry(registryName); + } else { + log.log(Level.SEVERE, "CLEARBLADE_REGISTRY Enviornment variable not set"); + throw new ApplicationException("CLEARBLADE_REGISTRY Enviornment variable not set"); + } + String regionName = System.getenv(Constants.AUTH_REGION); + if(regionName != null) { + configParameters.setRegion(regionName); + } else { + log.log(Level.SEVERE, "CLEARBLADE_REGION Enviornment variable not set"); + throw new ApplicationException("CLEARBLADE_REGION Enviornment variable not set"); + } + } + } + @SuppressWarnings("unchecked") public static void setRegistryCredentials() throws ApplicationException, IOException { if (userSystemKey != null) { return; } setAdminCredentials(); - ConfigParameters configParameters = new ConfigParameters(); + setRegistryRegion(); String finalURL = baseURL.concat(configParameters.getGetSystemCredentialsExtension()) .concat(adminSystemKey) .concat("/getRegistryCredentials"); @@ -153,7 +171,9 @@ public static void setRegistryCredentials() throws ApplicationException, IOExcep apiBaseURL = responseJSONObject.get(Constants.API_BASE_URL).toString(); } } - } + }else { + log.log(Level.INFO, "Response code " + responseCode + " received with message::" + responseMessage); + } } catch (Exception e) { log.log(Level.SEVERE, e.getMessage()); } diff --git a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/utils/ConfigParameters.java b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/utils/ConfigParameters.java index 7bc5ef06..4af11dbb 100644 --- a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/utils/ConfigParameters.java +++ b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/utils/ConfigParameters.java @@ -1,82 +1,48 @@ package com.clearblade.cloud.iot.v1.utils; -import java.io.IOException; -import java.io.InputStream; -import java.util.Properties; -import java.util.logging.Level; import java.util.logging.Logger; public class ConfigParameters { static Logger log = Logger.getLogger(ConfigParameters.class.getName()); - // Fields used to set values from properties file - + private static ConfigParameters single_instance = null; + private String project; private String region; private String registry; - private String endpointPort; - private String getSystemCredentialsExtension; - - private String baseURL; + private String webhook; private String cloudiotURLExtension; private String devicesURLExtension; private String devicesStatesURLExtension; private String cloudiotdevicesURLExtension; - private String cloudiotDeviceConfigURLExtension; private String cloudiotConfigURLExtension; - - // Fields used to fetch values from Properties file - Properties properties; - InputStream input; + private String endpointPort; + + public static ConfigParameters getInstance() + { + if (single_instance == null) + single_instance = new ConfigParameters(); + + return single_instance; + } public ConfigParameters() { - properties = null; - input = null; setValues(); } - /** - * Method used to read values form config.properties file and setting in field - * setters - */ - public void getConfigurations() { - // Read inputs from properties file - properties = new Properties(); - input = getClass().getClassLoader().getResourceAsStream("config.properties"); - try { - properties.load(input); - } catch (IOException ex) { - ex.printStackTrace(); - } finally { - if (input != null) { - try { - input.close(); - } catch (IOException e) { - log.log(Level.SEVERE, e.getMessage()); - } - } - } - } - /** * Method used to set values in Constants setter method */ public void setValues() { - // get Configurations uploaded from config.properties file - getConfigurations(); - this.setBaseURL(properties.getProperty("baseURL")); - this.setCloudiotURLExtension(properties.getProperty("cloudiotURLExtension")); - this.setDevicesURLExtension(properties.getProperty("devicesURLExtension")); - this.setCloudiotdevicesURLExtension(properties.getProperty("cloudiotdevicesURLExtension")); - this.setDevicesStatesURLExtension(properties.getProperty("devicesStatesURLExtension")); - this.setCloudiotdevicesURLExtension(properties.getProperty("cloudiotDeviceConfigURLExtension")); - this.setCloudiotConfigURLExtension(properties.getProperty("cloudiotConfigURLExtension")); - this.setProject(properties.getProperty("project")); - this.setRegion(properties.getProperty("region")); - this.setRegistry(properties.getProperty("registry")); - this.setGetSystemCredentialsExtension(properties.getProperty("getSystemCredentialsExtension")); - this.setEndpointPort(properties.getProperty("endPointPort")); + this.setWebhook(Constants.WEBHOOK); + this.setCloudiotURLExtension(Constants.CLOUDIOT_URL_EXTENSION); + this.setDevicesURLExtension(Constants.DEVICES_URL_EXTENSION); + this.setCloudiotdevicesURLExtension(Constants.CLOUDIOT_DEVICES_URL_EXTENSION); + this.setDevicesStatesURLExtension(Constants.DEVICES_STATES_URL_EXTENSION); + this.setCloudiotdevicesURLExtension(Constants.CLOUDIOT_DEVICE_CONFIG_URL_EXTENSION); + this.setGetSystemCredentialsExtension(Constants.GET_SYSTEM_CREDENTIALS_EXTENSION); + this.setEndpointPort(Constants.ENDPOINTPORT); } public String getCloudiotURLExtension() { @@ -111,14 +77,6 @@ public void setCloudiotdevicesURLExtension(String cloudiotdevicesURLExtension) { this.cloudiotdevicesURLExtension = cloudiotdevicesURLExtension; } - public String getCloudiotDeviceConfigURLExtension() { - return cloudiotDeviceConfigURLExtension; - } - - public void setCloudiotDeviceConfigURLExtension(String cloudiotDeviceConfigURLExtension) { - this.cloudiotDeviceConfigURLExtension = cloudiotDeviceConfigURLExtension; - } - public String getProject() { return project; } @@ -159,12 +117,12 @@ public void setEndpointPort(String endpointPort) { this.endpointPort = endpointPort; } - public String getBaseURL() { - return baseURL; + public String getWebhook() { + return webhook; } - public void setBaseURL(String baseURL) { - this.baseURL = baseURL; + public void setWebhook(String webhook) { + this.webhook = webhook; } public String getCloudiotConfigURLExtension() { diff --git a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/utils/Constants.java b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/utils/Constants.java index 22806bc8..373fc66f 100644 --- a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/utils/Constants.java +++ b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/utils/Constants.java @@ -4,13 +4,15 @@ public class Constants { private Constants() {} + //keys used in project public static final String AUTH_ACCESS = "CLEARBLADE_CONFIGURATION"; + public static final String AUTH_REGISTRY = "CLEARBLADE_REGISTRY"; + public static final String AUTH_REGION = "CLEARBLADE_REGION"; + public static final String ADMIN_SYSTEM_KEY = "systemKey"; public static final String ADMIN_TOKEN = "token"; public static final String BASE_URL = "url"; public static final String PROJECT_NAME = "project"; - public static final String REGION = "region"; - public static final String REGISTRY ="registry"; public static final String USER_SYSTEM_KEY = "systemKey"; public static final String USER_TOKEN = "serviceAccountToken"; public static final String API_BASE_URL = "url"; @@ -27,7 +29,15 @@ private Constants() {} public static final String HTTP_REQUEST_PROPERTY_ACCEPT_KEY = "Accept"; public static final String HTTP_REQUEST_PROPERTY_CONTENT_TYPE_ACCEPT_VALUE = "application/json"; - + //Constant values used in project public static final String UTF8 = "utf-8"; - + public static final String ENDPOINTPORT=":443"; + public static final String WEBHOOK="/api/v/4/webhook/execute/"; + public static final String DEVICES_URL_EXTENSION="/cloudiot_devices"; + public static final String CLOUDIOT_URL_EXTENSION="/cloudiot"; + public static final String DEVICES_STATES_URL_EXTENSION="/cloudiot_devices_states"; + public static final String CLOUDIOT_DEVICES_URL_EXTENSION="/cloudiotdevice_devices"; + public static final String CLOUDIOT_DEVICE_CONFIG_URL_EXTENSION="/cloudiot_devices_configVersions"; + public static final String GET_SYSTEM_CREDENTIALS_EXTENSION="/api/v/1/code/"; + } diff --git a/clearblade-cloud-iot/src/config.properties b/clearblade-cloud-iot/src/config.properties deleted file mode 100644 index 078e5901..00000000 --- a/clearblade-cloud-iot/src/config.properties +++ /dev/null @@ -1,14 +0,0 @@ -region=us-central1 -registry=Rashmi_Registry_Test - -endPointPort=:443 - -baseURL=/api/v/4/webhook/execute/ -devicesURLExtension=/cloudiot_devices -cloudiotURLExtension=/cloudiot -devicesStatesURLExtension=/cloudiot_devices_states -cloudiotdevicesURLExtension=/cloudiotdevice_devices -cloudiotConfigURLExtension=/cloudiot_devices_configVersions - - -getSystemCredentialsExtension=/api/v/1/code/ From 63ebe3ef9d836a81f880f58642e25f9d98f1caf4 Mon Sep 17 00:00:00 2001 From: RashmiK14 Date: Wed, 30 Nov 2022 22:21:28 +0530 Subject: [PATCH 020/151] Committing changes related to Samples, maven and HTTP Client Change for PATCH to work Committing changes related to Samples, maven and HTTP Client Change for PATCH to work --- clearblade-cloud-iot/pom.xml | 48 +- .../AsyncBindDeviceToGateway.java | 26 +- .../SyncBindDeviceToGateway.java | 25 +- .../createdevice/AsyncCreateDevice.java | 27 +- .../createdevice/SyncCreateDevice.java | 29 +- .../AsyncCreateDeviceRegistry.java | 18 +- .../SyncCreateDeviceRegistry.java | 18 +- .../deletedevice/AsyncDeleteDevice.java | 17 +- .../deletedevice/SyncDeleteDevice.java | 17 +- .../AsyncDeleteDeviceRegistry.java | 15 +- .../SyncDeleteDeviceRegistry.java | 11 +- .../samples/deviceslist/AsyncDevicesList.java | 27 +- .../samples/deviceslist/SyncDevicesList.java | 28 +- .../AsyncDeviceStatesList.java | 26 +- .../SyncDeviceStatesList.java | 27 +- .../v1/samples/getdevice/AsyncGetDevice.java | 19 +- .../v1/samples/getdevice/SyncGetDevice.java | 19 +- .../AsyncGetDeviceRegistry.java | 22 +- .../SyncGetDeviceRegistry.java | 21 +- .../AsyncListDeviceConfigVersions.java | 33 +- .../SyncListDeviceConfigVersions.java | 31 +- .../AsyncListDeviceRegistries.java | 22 +- .../SyncListDeviceRegistries.java | 20 +- .../AsyncModifyCloudToDeviceConfig.java | 30 +- .../SyncModifyCloudToDeviceConfig.java | 31 +- .../AsyncSendCommandToDevice.java | 32 +- .../SyncSendCommandToDevice.java | 31 +- .../AsyncUnbindDeviceFromGateway.java | 25 +- .../SyncUnbindDeviceFromGateway.java | 25 +- .../updatedevice/AsyncUpdateDevice.java | 62 +- .../updatedevice/SyncUpdateDevice.java | 59 +- .../AsyncUpdateDeviceRegistry.java | 23 +- .../SyncUpdateDeviceRegistry.java | 23 +- clearblade-cloud-iot/samples/pom.xml | 119 ---- .../clearblade/cloud/iot/v1/AsyncClient.java | 574 ++++-------------- .../cloud/iot/v1/ClearBladeDeviceManager.java | 100 ++- .../iot/v1/ClearBladeRegistryManager.java | 40 +- .../clearblade/cloud/iot/v1/SyncClient.java | 269 ++++---- .../v1/exception/ApplicationException.java | 7 +- .../iot/v1/registrytypes/DeviceRegistry.java | 3 +- .../cloud/iot/v1/utils/AuthParams.java | 92 ++- .../cloud/iot/v1/utils/SetHttpConnection.java | 26 - .../iot/v1/test/DeviceManagerClientTest.java | 310 ++++++++++ .../iot/v1/test/ExpectedResponseTest.java | 353 +++++++++++ .../cloud/iot/v1/test/package-info.java | 1 + 45 files changed, 1648 insertions(+), 1133 deletions(-) delete mode 100644 clearblade-cloud-iot/samples/pom.xml delete mode 100644 clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/utils/SetHttpConnection.java create mode 100644 clearblade-cloud-iot/test/com/clearblade/cloud/iot/v1/test/DeviceManagerClientTest.java create mode 100644 clearblade-cloud-iot/test/com/clearblade/cloud/iot/v1/test/ExpectedResponseTest.java create mode 100644 clearblade-cloud-iot/test/com/clearblade/cloud/iot/v1/test/package-info.java diff --git a/clearblade-cloud-iot/pom.xml b/clearblade-cloud-iot/pom.xml index f10ffabf..9828d7cb 100644 --- a/clearblade-cloud-iot/pom.xml +++ b/clearblade-cloud-iot/pom.xml @@ -7,8 +7,9 @@ src + org.apache.maven.plugins maven-compiler-plugin - 3.8.1 + 3.8.0 17 @@ -24,14 +25,51 @@ add-source - - src - + + samples + - + + org.apache.maven.plugins + maven-dependency-plugin + 3.3.0 + + + copy-dependencies + package + + copy-dependencies + + + ./target + false + true + true + + + + + + org.codehaus.mojo + exec-maven-plugin + 1.4.0 + + java + + + + clearblade-cloud-iot + clearblade-cloud-iot + 0.0.1-SNAPSHOT + jar + + + + + diff --git a/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/binddevicetogateway/AsyncBindDeviceToGateway.java b/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/binddevicetogateway/AsyncBindDeviceToGateway.java index a4802088..febc205a 100644 --- a/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/binddevicetogateway/AsyncBindDeviceToGateway.java +++ b/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/binddevicetogateway/AsyncBindDeviceToGateway.java @@ -1,26 +1,36 @@ package com.clearblade.cloud.iot.v1.samples.binddevicetogateway; -import java.util.logging.Logger; - import com.clearblade.cloud.iot.v1.DeviceManagerAsyncClient; import com.clearblade.cloud.iot.v1.binddevicetogateway.BindDeviceToGatewayRequest; import com.clearblade.cloud.iot.v1.binddevicetogateway.BindDeviceToGatewayResponse; import com.clearblade.cloud.iot.v1.registrytypes.RegistryName; public class AsyncBindDeviceToGateway { - static Logger log = Logger.getLogger(AsyncBindDeviceToGateway.class.getName()); + public static String PROJECT = ""; + public static String LOCATION = ""; + public static String REGISTRY = ""; + public static String GATEWAY = ""; + public static String DEVICE = ""; - public static void main(String[] args) { + public static void main(String[] args) { + PROJECT = System.getProperty("projectName"); + LOCATION = System.getProperty("location"); + REGISTRY = System.getProperty("registryName"); + GATEWAY = System.getProperty("gatewayName"); + DEVICE = System.getProperty("deviceName"); asyncBindDeviceToGateway(); } public static void asyncBindDeviceToGateway() { DeviceManagerAsyncClient deviceManagerAsyncClient = new DeviceManagerAsyncClient(); BindDeviceToGatewayRequest request = BindDeviceToGatewayRequest.Builder.newBuilder() - .setParent(RegistryName.of("ingressdevelopmentenv", "us-central1", "Rashmi_Registry_Test").toString()) - .setGateway("Rashmi_Gateway_Test").setDevice("myOldDevice").build(); + .setParent(RegistryName.of(PROJECT, LOCATION, REGISTRY).toString()) + .setGateway(GATEWAY).setDevice(DEVICE).build(); BindDeviceToGatewayResponse response = deviceManagerAsyncClient.bindDeviceToGateway(request); - System.out.println(response.toString()); - + if(response != null) { + System.out.println("BindDeviceToGateway execution successful"); + }else { + System.out.println("BindDeviceToGateway execution failed"); + } } } diff --git a/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/binddevicetogateway/SyncBindDeviceToGateway.java b/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/binddevicetogateway/SyncBindDeviceToGateway.java index 39c973bb..ca0017e7 100644 --- a/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/binddevicetogateway/SyncBindDeviceToGateway.java +++ b/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/binddevicetogateway/SyncBindDeviceToGateway.java @@ -1,25 +1,36 @@ package com.clearblade.cloud.iot.v1.samples.binddevicetogateway; -import java.util.logging.Logger; - import com.clearblade.cloud.iot.v1.DeviceManagerClient; import com.clearblade.cloud.iot.v1.binddevicetogateway.BindDeviceToGatewayRequest; import com.clearblade.cloud.iot.v1.binddevicetogateway.BindDeviceToGatewayResponse; import com.clearblade.cloud.iot.v1.registrytypes.RegistryName; public class SyncBindDeviceToGateway { - static Logger log = Logger.getLogger(SyncBindDeviceToGateway.class.getName()); + public static String PROJECT = ""; + public static String LOCATION = ""; + public static String REGISTRY = ""; + public static String GATEWAY = ""; + public static String DEVICE = ""; - public static void main(String[] args) { + public static void main(String[] args) { + PROJECT = System.getProperty("projectName"); + LOCATION = System.getProperty("location"); + REGISTRY = System.getProperty("registryName"); + GATEWAY = System.getProperty("gatewayName"); + DEVICE = System.getProperty("deviceName"); syncBindDeviceToGateway(); } public static void syncBindDeviceToGateway() { DeviceManagerClient deviceManagerClient = new DeviceManagerClient(); BindDeviceToGatewayRequest request = BindDeviceToGatewayRequest.Builder.newBuilder() - .setParent(RegistryName.of("ingressdevelopmentenv", "us-central1", "Rashmi_Registry_Test").toString()) - .setGateway("Rashmi_Gateway_Test").setDevice("Rashmi_Device_Test").build(); + .setParent(RegistryName.of(PROJECT, LOCATION, REGISTRY).toString()) + .setGateway(GATEWAY).setDevice(DEVICE).build(); BindDeviceToGatewayResponse response = deviceManagerClient.bindDeviceToGateway(request); - System.out.println(response.toString()); + if(response != null) { + System.out.println("BindDeviceToGateway execution successful"); + }else { + System.out.println("BindDeviceToGateway execution failed"); + } } } diff --git a/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/createdevice/AsyncCreateDevice.java b/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/createdevice/AsyncCreateDevice.java index 8dff5eae..a2dc4e41 100644 --- a/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/createdevice/AsyncCreateDevice.java +++ b/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/createdevice/AsyncCreateDevice.java @@ -2,7 +2,6 @@ import java.util.ArrayList; import java.util.HashMap; -import java.util.logging.Logger; import com.clearblade.cloud.iot.v1.DeviceManagerAsyncClient; import com.clearblade.cloud.iot.v1.createdevice.CreateDeviceRequest; @@ -15,20 +14,28 @@ import com.clearblade.cloud.iot.v1.utils.LogLevel; public class AsyncCreateDevice { - static Logger log = Logger.getLogger(AsyncCreateDevice.class.getName()); - - public static void main(String[] args) { + public static String PROJECT = ""; + public static String LOCATION = ""; + public static String REGISTRY = ""; + public static String DEVICE = ""; + public static String NUMID = ""; + public static void main(String[] args) { + PROJECT = System.getProperty("projectName"); + LOCATION = System.getProperty("location"); + REGISTRY = System.getProperty("registryName"); + DEVICE = System.getProperty("deviceName"); + NUMID = System.getProperty("numId"); asyncCreateDevice(); } public static void asyncCreateDevice() { DeviceManagerAsyncClient deviceManagerAsyncClient = new DeviceManagerAsyncClient(); - RegistryName parent = RegistryName.of("ingressdevelopmentenv", "us-central1", "Rashmi_Registry_Test"); + RegistryName parent = RegistryName.of(PROJECT, LOCATION, REGISTRY); GatewayConfig gatewayCfg = new GatewayConfig(); gatewayCfg.setGatewayType(GatewayType.NON_GATEWAY); Device device = Device.newBuilder() - .setId("AsyncTest22").setName("AsyncTest22") - .setNumId("2315").setBlocked(false) + .setId(DEVICE).setName(DEVICE) + .setNumId(NUMID).setBlocked(false) .setGatewayConfig(gatewayCfg) .setLogLevel(LogLevel.ERROR) .setCredentials(new ArrayList<>()) @@ -39,6 +46,10 @@ public static void asyncCreateDevice() { CreateDeviceRequest request = CreateDeviceRequest.Builder.newBuilder().setParent(parent).setDevice(device) .build(); Device response = deviceManagerAsyncClient.createDevice(request); - System.out.println(response.toBuilder().getName()); + if(response != null) { + System.out.println("CreateDevice execution successful"); + }else { + System.out.println("CreateDevice execution failed"); + } } } diff --git a/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/createdevice/SyncCreateDevice.java b/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/createdevice/SyncCreateDevice.java index 19c10db3..1eb62d8c 100644 --- a/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/createdevice/SyncCreateDevice.java +++ b/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/createdevice/SyncCreateDevice.java @@ -2,7 +2,6 @@ import java.util.ArrayList; import java.util.HashMap; -import java.util.logging.Logger; import com.clearblade.cloud.iot.v1.DeviceManagerClient; import com.clearblade.cloud.iot.v1.createdevice.CreateDeviceRequest; @@ -15,21 +14,30 @@ import com.clearblade.cloud.iot.v1.utils.LogLevel; public class SyncCreateDevice { - static Logger log = Logger.getLogger(SyncCreateDevice.class.getName()); - public static void main(String[] args) { + public static String PROJECT = ""; + public static String LOCATION = ""; + public static String REGISTRY = ""; + public static String DEVICE = ""; + public static String NUMID = ""; + public static void main(String[] args) { + PROJECT = System.getProperty("projectName"); + LOCATION = System.getProperty("location"); + REGISTRY = System.getProperty("registryName"); + DEVICE = System.getProperty("deviceName"); + NUMID = System.getProperty("numId"); syncCreateDevice(); } public static void syncCreateDevice() { DeviceManagerClient deviceManagerClient = new DeviceManagerClient(); - RegistryName parent = RegistryName.of("ingressdevelopmentenv", "us-central1", "Rashmi_Registry_Test"); + RegistryName parent = RegistryName.of(PROJECT,LOCATION, REGISTRY); GatewayConfig gatewayCfg = new GatewayConfig(); - gatewayCfg.setGatewayType(GatewayType.NON_GATEWAY); + gatewayCfg.setGatewayType(GatewayType.GATEWAY); Device device = Device.newBuilder() - .setId("SyncTest22").setName("SyncTest22") - .setNumId("2314").setBlocked(false) + .setId(DEVICE).setName(DEVICE) + .setNumId(NUMID).setBlocked(false) .setGatewayConfig(gatewayCfg) .setLogLevel(LogLevel.DEBUG) .setCredentials(new ArrayList<>()) @@ -40,7 +48,10 @@ public static void syncCreateDevice() { CreateDeviceRequest request = CreateDeviceRequest.Builder.newBuilder().setParent(parent).setDevice(device) .build(); Device response = deviceManagerClient.createDevice(request); - System.out.println(response.toBuilder().getName()); - + if(response != null) { + System.out.println("CreateDevice execution successful"); + }else { + System.out.println("CreateDevice execution failed"); + } } } diff --git a/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/createdeviceregistry/AsyncCreateDeviceRegistry.java b/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/createdeviceregistry/AsyncCreateDeviceRegistry.java index 1f43889a..04a09fad 100644 --- a/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/createdeviceregistry/AsyncCreateDeviceRegistry.java +++ b/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/createdeviceregistry/AsyncCreateDeviceRegistry.java @@ -6,19 +6,29 @@ import com.clearblade.cloud.iot.v1.registrytypes.LocationName; public class AsyncCreateDeviceRegistry { - public static void main(String[] args) { + public static String PROJECT = ""; + public static String LOCATION = ""; + public static String REGISTRY = ""; + public static void main(String[] args) { + PROJECT = System.getProperty("projectName"); + LOCATION = System.getProperty("location"); + REGISTRY = System.getProperty("registryName"); asyncCreateDeviceRegistry(); } public static void asyncCreateDeviceRegistry() { DeviceManagerAsyncClient deviceManagerClient = new DeviceManagerAsyncClient(); CreateDeviceRegistryRequest request = CreateDeviceRegistryRequest.Builder.newBuilder() - .setParent(LocationName.of("ingressdevelopmentenv", "us-central1").toString()) + .setParent(LocationName.of(PROJECT, LOCATION).toString()) .setDeviceRegistry( - DeviceRegistry.newBuilder().setId("testCreate_reg3").build()) + DeviceRegistry.newBuilder().setId(REGISTRY).build()) .build(); DeviceRegistry response = deviceManagerClient.createDeviceRegistry(request); - System.out.println(response.toBuilder().getId()); + if(response != null) { + System.out.println("CreateDeviceRegistry execution successful"); + }else { + System.out.println("CreateDeviceRegistry execution failed"); + } } diff --git a/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/createdeviceregistry/SyncCreateDeviceRegistry.java b/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/createdeviceregistry/SyncCreateDeviceRegistry.java index b9aaa78c..5f238890 100644 --- a/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/createdeviceregistry/SyncCreateDeviceRegistry.java +++ b/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/createdeviceregistry/SyncCreateDeviceRegistry.java @@ -7,19 +7,29 @@ public class SyncCreateDeviceRegistry { - public static void main(String[] args) { + public static String PROJECT = ""; + public static String LOCATION = ""; + public static String REGISTRY = ""; + public static void main(String[] args) { + PROJECT = System.getProperty("projectName"); + LOCATION = System.getProperty("location"); + REGISTRY = System.getProperty("registryName"); syncCreateDeviceRegistry(); } public static void syncCreateDeviceRegistry() { DeviceManagerClient deviceManagerClient = new DeviceManagerClient(); CreateDeviceRegistryRequest request = CreateDeviceRegistryRequest.Builder.newBuilder() - .setParent(LocationName.of("ingressdevelopmentenv", "us-central1").toString()) + .setParent(LocationName.of(PROJECT, LOCATION).toString()) .setDeviceRegistry( - DeviceRegistry.newBuilder().setId("testCreate_reg5").build()) + DeviceRegistry.newBuilder().setId(REGISTRY).build()) .build(); DeviceRegistry response = deviceManagerClient.createDeviceRegistry(request); - System.out.println(response.toBuilder().getId()); + if(response != null) { + System.out.println("CreateDeviceRegistry execution successful"); + }else { + System.out.println("CreateDeviceRegistry execution failed"); + } } } diff --git a/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/deletedevice/AsyncDeleteDevice.java b/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/deletedevice/AsyncDeleteDevice.java index 09244ed8..d4935750 100644 --- a/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/deletedevice/AsyncDeleteDevice.java +++ b/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/deletedevice/AsyncDeleteDevice.java @@ -1,22 +1,27 @@ package com.clearblade.cloud.iot.v1.samples.deletedevice; -import java.util.logging.Logger; - import com.clearblade.cloud.iot.v1.DeviceManagerAsyncClient; import com.clearblade.cloud.iot.v1.deletedevice.DeleteDeviceRequest; import com.clearblade.cloud.iot.v1.devicetypes.DeviceName; public class AsyncDeleteDevice { - static Logger log = Logger.getLogger(AsyncDeleteDevice.class.getName()); - public static void main(String[] args) { + public static String PROJECT = ""; + public static String LOCATION = ""; + public static String REGISTRY = ""; + public static String DEVICE = ""; + + public static void main(String[] args) { + PROJECT = System.getProperty("projectName"); + LOCATION = System.getProperty("location"); + REGISTRY = System.getProperty("registryName"); + DEVICE = System.getProperty("deviceName"); asyncDeleteDevice(); } public static void asyncDeleteDevice() { DeviceManagerAsyncClient deviceManagerAsyncClient = new DeviceManagerAsyncClient(); - DeviceName deviceName = DeviceName.of("ingressdevelopmentenv", "us-central1", "Rashmi_Registry_Test", - "AsyncTest22"); + DeviceName deviceName = DeviceName.of(PROJECT, LOCATION, REGISTRY, DEVICE); DeleteDeviceRequest request = DeleteDeviceRequest.Builder.newBuilder().setName(deviceName).build(); deviceManagerAsyncClient.deleteDevice(request); } diff --git a/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/deletedevice/SyncDeleteDevice.java b/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/deletedevice/SyncDeleteDevice.java index 08825ac8..82e7ba2d 100644 --- a/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/deletedevice/SyncDeleteDevice.java +++ b/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/deletedevice/SyncDeleteDevice.java @@ -1,22 +1,27 @@ package com.clearblade.cloud.iot.v1.samples.deletedevice; -import java.util.logging.Logger; - import com.clearblade.cloud.iot.v1.DeviceManagerClient; import com.clearblade.cloud.iot.v1.deletedevice.DeleteDeviceRequest; import com.clearblade.cloud.iot.v1.devicetypes.DeviceName; public class SyncDeleteDevice { - static Logger log = Logger.getLogger(SyncDeleteDevice.class.getName()); - public static void main(String[] args) { + public static String PROJECT = ""; + public static String LOCATION = ""; + public static String REGISTRY = ""; + public static String DEVICE = ""; + + public static void main(String[] args) { + PROJECT = System.getProperty("projectName"); + LOCATION = System.getProperty("location"); + REGISTRY = System.getProperty("registryName"); + DEVICE = System.getProperty("deviceName"); syncDeleteDevice(); } public static void syncDeleteDevice() { DeviceManagerClient deviceManagerClient = new DeviceManagerClient(); - DeviceName deviceName = DeviceName.of("ingressdevelopmentenv", "us-central1", "Rashmi_Registry_Test", - "SyncTest22"); + DeviceName deviceName = DeviceName.of(PROJECT, LOCATION, REGISTRY, DEVICE); DeleteDeviceRequest request = DeleteDeviceRequest.Builder.newBuilder().setName(deviceName).build(); deviceManagerClient.deleteDevice(request); } diff --git a/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/deletedeviceregistry/AsyncDeleteDeviceRegistry.java b/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/deletedeviceregistry/AsyncDeleteDeviceRegistry.java index 267c4e6c..2dba4ccc 100644 --- a/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/deletedeviceregistry/AsyncDeleteDeviceRegistry.java +++ b/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/deletedeviceregistry/AsyncDeleteDeviceRegistry.java @@ -6,19 +6,26 @@ public class AsyncDeleteDeviceRegistry { - public static void main(String[] args) throws Exception { + public static String PROJECT = ""; + public static String LOCATION = ""; + public static String REGISTRY = ""; + + public static void main(String[] args) throws Exception { + PROJECT = System.getProperty("projectName"); + LOCATION = System.getProperty("location"); + REGISTRY = System.getProperty("registryName"); asyncDeleteDeviceRegistry(); } public static void asyncDeleteDeviceRegistry() throws Exception { - + DeviceManagerAsyncClient deviceManagerClient = new DeviceManagerAsyncClient(); DeleteDeviceRegistryRequest request = DeleteDeviceRegistryRequest.Builder.newBuilder() - .setName(RegistryName.of("ingressdevelopmentenv", "us-central1", "testCreate_reg2") + .setName(RegistryName.of(PROJECT, LOCATION, REGISTRY) .getRegistryFullName()) .build(); deviceManagerClient.deleteDeviceRegistry(request); - + } } \ No newline at end of file diff --git a/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/deletedeviceregistry/SyncDeleteDeviceRegistry.java b/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/deletedeviceregistry/SyncDeleteDeviceRegistry.java index cd5feea7..4c7cfaa9 100644 --- a/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/deletedeviceregistry/SyncDeleteDeviceRegistry.java +++ b/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/deletedeviceregistry/SyncDeleteDeviceRegistry.java @@ -6,14 +6,21 @@ public class SyncDeleteDeviceRegistry { - public static void main(String[] args) throws Exception { + public static String PROJECT = ""; + public static String LOCATION = ""; + public static String REGISTRY = ""; + + public static void main(String[] args) throws Exception { + PROJECT = System.getProperty("projectName"); + LOCATION = System.getProperty("location"); + REGISTRY = System.getProperty("registryName"); syncDeleteDeviceRegistry(); } public static void syncDeleteDeviceRegistry() throws Exception { DeviceManagerClient deviceManagerClient = new DeviceManagerClient(); DeleteDeviceRegistryRequest request = DeleteDeviceRegistryRequest.Builder.newBuilder() - .setName(RegistryName.of("ingressdevelopmentenv", "us-central1", "testCreate_reg3") + .setName(RegistryName.of(PROJECT,LOCATION,REGISTRY) .getRegistryFullName()) .build(); deviceManagerClient.deleteDeviceRegistry(request); diff --git a/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/deviceslist/AsyncDevicesList.java b/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/deviceslist/AsyncDevicesList.java index c194a4d8..f2f4cc91 100644 --- a/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/deviceslist/AsyncDevicesList.java +++ b/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/deviceslist/AsyncDevicesList.java @@ -1,7 +1,5 @@ package com.clearblade.cloud.iot.v1.samples.deviceslist; -import java.util.logging.Logger; - import com.clearblade.cloud.iot.v1.DeviceManagerAsyncClient; import com.clearblade.cloud.iot.v1.deviceslist.DevicesListRequest; import com.clearblade.cloud.iot.v1.deviceslist.DevicesListResponse; @@ -12,25 +10,36 @@ public class AsyncDevicesList { - static Logger log = Logger.getLogger(AsyncDevicesList.class.getName()); - - public static void main(String[] args) { + public static String PROJECT = ""; + public static String LOCATION = ""; + public static String REGISTRY = ""; + + public static void main(String[] args) { + PROJECT = System.getProperty("projectName"); + LOCATION = System.getProperty("location"); + REGISTRY = System.getProperty("registryName"); asyncDevicesList(); } public static void asyncDevicesList() { DeviceManagerAsyncClient deviceManagerAsyncClient = new DeviceManagerAsyncClient(); - RegistryName parent = RegistryName.of("ingressdevelopmentenv", "us-central1", "MandarTest1"); + RegistryName parent = RegistryName.of(PROJECT, LOCATION, REGISTRY); DevicesListRequest request = DevicesListRequest.Builder.newBuilder().setParent(parent.toString()) .setGatewayListOptions(GatewayListOptions.newBuilder().setGatewayType(GatewayType.NON_GATEWAY).build()) .setPageSize(2) .build(); DevicesListResponse response = deviceManagerAsyncClient.listDevices(request); - for (Device element : response.getDevicesList()) { - System.out.println(element.toBuilder().getName()); + if(response != null) { + System.out.println("DeviceList fetch successful"); + for (Device element : response.getDevicesList()) { + System.out.println(element.toBuilder().getName()); + + } + System.out.println(response.getNextPageToken()); + }else { + System.out.println("DeviceList fetch failed"); } - System.out.println(response.getNextPageToken()); } } diff --git a/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/deviceslist/SyncDevicesList.java b/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/deviceslist/SyncDevicesList.java index 14129da1..79a0c519 100644 --- a/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/deviceslist/SyncDevicesList.java +++ b/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/deviceslist/SyncDevicesList.java @@ -1,7 +1,5 @@ package com.clearblade.cloud.iot.v1.samples.deviceslist; -import java.util.logging.Logger; - import com.clearblade.cloud.iot.v1.DeviceManagerClient; import com.clearblade.cloud.iot.v1.deviceslist.DevicesListRequest; import com.clearblade.cloud.iot.v1.deviceslist.DevicesListResponse; @@ -11,26 +9,38 @@ import com.clearblade.cloud.iot.v1.registrytypes.RegistryName; public class SyncDevicesList { - static Logger log = Logger.getLogger(SyncDevicesList.class.getName()); - - public static void main(String[] args) { + public static String PROJECT = ""; + public static String LOCATION = ""; + public static String REGISTRY = ""; + + public static void main(String[] args) { + PROJECT = System.getProperty("projectName"); + LOCATION = System.getProperty("location"); + REGISTRY = System.getProperty("registryName"); syncDevicesList(); } public static void syncDevicesList() { DeviceManagerClient deviceManagerClient = new DeviceManagerClient(); - RegistryName parent = RegistryName.of("ingressdevelopmentenv", "us-central1", "MandarTest1"); + RegistryName parent = RegistryName.of(PROJECT, LOCATION, REGISTRY); DevicesListRequest request = DevicesListRequest.Builder.newBuilder().setParent(parent.toString()) .setGatewayListOptions(GatewayListOptions.newBuilder().setGatewayType(GatewayType.NON_GATEWAY).build()) .setPageSize(2) .build(); DevicesListResponse response = deviceManagerClient.listDevices(request); - for (Device element : response.getDevicesList()) { - System.out.println(element.toBuilder().getName()); + if(response != null) { + System.out.println("DeviceList fetch successful"); + for (Device element : response.getDevicesList()) { + System.out.println(element.toBuilder().getName()); + } + System.out.println(response.getNextPageToken()); + + }else { + System.out.println("DeviceList fetch failed"); } - System.out.println(response.getNextPageToken()); + } } diff --git a/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/devicestateslist/AsyncDeviceStatesList.java b/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/devicestateslist/AsyncDeviceStatesList.java index 2081c9b6..039453c1 100644 --- a/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/devicestateslist/AsyncDeviceStatesList.java +++ b/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/devicestateslist/AsyncDeviceStatesList.java @@ -1,7 +1,5 @@ package com.clearblade.cloud.iot.v1.samples.devicestateslist; -import java.util.logging.Logger; - import com.clearblade.cloud.iot.v1.DeviceManagerAsyncClient; import com.clearblade.cloud.iot.v1.devicestateslist.ListDeviceStatesRequest; import com.clearblade.cloud.iot.v1.devicestateslist.ListDeviceStatesResponse; @@ -10,9 +8,16 @@ public class AsyncDeviceStatesList { - static Logger log = Logger.getLogger(AsyncDeviceStatesList.class.getName()); + public static String PROJECT = ""; + public static String LOCATION = ""; + public static String REGISTRY = ""; + public static String DEVICE = ""; - public static void main(String[] args) { + public static void main(String[] args) { + PROJECT = System.getProperty("projectName"); + LOCATION = System.getProperty("location"); + REGISTRY = System.getProperty("registryName"); + DEVICE = System.getProperty("deviceName"); asyncDeviceStatesList(); } @@ -20,13 +25,20 @@ public static void asyncDeviceStatesList() { DeviceManagerAsyncClient deviceManagerClient = new DeviceManagerAsyncClient(); ListDeviceStatesRequest request = ListDeviceStatesRequest.Builder.newBuilder().setName(DeviceName - .of("ingressdevelopmentenv", "us-central1", "Rashmi_Registry_Test", "Rashmi_Device_Test") + .of(PROJECT, LOCATION, REGISTRY, DEVICE) .toString()).setNumStates(1643330779).build(); ListDeviceStatesResponse response = deviceManagerClient.listDeviceStates(request); - for (DeviceState element : response.getDeviceStatesList()) { - System.out.println(element.toString()); + if(response != null) { + System.out.println("DeviceStatesList fetch successful"); + for (DeviceState element : response.getDeviceStatesList()) { + System.out.println(element.toString()); + } + + }else { + System.out.println("DeviceStatesList fetch failed"); } + } } diff --git a/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/devicestateslist/SyncDeviceStatesList.java b/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/devicestateslist/SyncDeviceStatesList.java index 5af92657..a934c888 100644 --- a/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/devicestateslist/SyncDeviceStatesList.java +++ b/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/devicestateslist/SyncDeviceStatesList.java @@ -1,7 +1,5 @@ package com.clearblade.cloud.iot.v1.samples.devicestateslist; -import java.util.logging.Logger; - import com.clearblade.cloud.iot.v1.DeviceManagerClient; import com.clearblade.cloud.iot.v1.devicestateslist.ListDeviceStatesRequest; import com.clearblade.cloud.iot.v1.devicestateslist.ListDeviceStatesResponse; @@ -9,9 +7,16 @@ import com.clearblade.cloud.iot.v1.devicetypes.DeviceState; public class SyncDeviceStatesList { - static Logger log = Logger.getLogger(SyncDeviceStatesList.class.getName()); - - public static void main(String[] args) { + public static String PROJECT = ""; + public static String LOCATION = ""; + public static String REGISTRY = ""; + public static String DEVICE = ""; + + public static void main(String[] args) { + PROJECT = System.getProperty("projectName"); + LOCATION = System.getProperty("location"); + REGISTRY = System.getProperty("registryName"); + DEVICE = System.getProperty("deviceName"); syncDeviceStatesList(); } @@ -19,12 +24,16 @@ public static void syncDeviceStatesList() { DeviceManagerClient deviceManagerClient = new DeviceManagerClient(); ListDeviceStatesRequest request = ListDeviceStatesRequest.Builder.newBuilder().setName(DeviceName - .of("ingressdevelopmentenv", "us-central1", "Rashmi_Registry_Test", "Rashmi_Device_Test") + .of(PROJECT, LOCATION, REGISTRY, DEVICE) .toString()).setNumStates(1643330779).build(); ListDeviceStatesResponse response = deviceManagerClient.listDeviceStates(request); - - for (DeviceState element : response.getDeviceStatesList()) { - System.out.println(element.toString()); + if(response != null) { + System.out.println("DeviceStatesList fetch successful"); + for (DeviceState element : response.getDeviceStatesList()) { + System.out.println(element.toString()); + } + }else { + System.out.println("DeviceStatesList fetch failed"); } } diff --git a/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/getdevice/AsyncGetDevice.java b/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/getdevice/AsyncGetDevice.java index 79ec357f..b54c7802 100644 --- a/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/getdevice/AsyncGetDevice.java +++ b/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/getdevice/AsyncGetDevice.java @@ -1,7 +1,5 @@ package com.clearblade.cloud.iot.v1.samples.getdevice; -import java.util.logging.Logger; - import com.clearblade.cloud.iot.v1.DeviceManagerAsyncClient; import com.clearblade.cloud.iot.v1.devicetypes.Device; import com.clearblade.cloud.iot.v1.devicetypes.DeviceName; @@ -9,17 +7,16 @@ import com.clearblade.cloud.iot.v1.getdevice.GetDeviceRequest; public class AsyncGetDevice { - static Logger log = Logger.getLogger(AsyncGetDevice.class.getName()); public static String PROJECT = ""; public static String LOCATION = ""; public static String REGISTRY = ""; public static String DEVICE = ""; public static void main(String[] args) { - PROJECT = args[0]; - LOCATION = args[1]; - REGISTRY = args[2]; - DEVICE = args[3]; + PROJECT = System.getProperty("projectName"); + LOCATION = System.getProperty("location"); + REGISTRY = System.getProperty("registryName"); + DEVICE = System.getProperty("deviceName"); asyncGetDevice(); } @@ -29,7 +26,11 @@ public static void asyncGetDevice() { GetDeviceRequest request = GetDeviceRequest.Builder.newBuilder().setName(name) .setFieldMask(FieldMask.newBuilder().build()).build(); Device response = deviceManagerAsyncClient.getDevice(request); - System.out.println(response.toBuilder().getName()); - } + if(response != null) { + System.out.println("GetDevice execution successful ::" +response.toBuilder().getName()); + }else { + System.out.println("GetDevice execution failed"); + } + } } diff --git a/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/getdevice/SyncGetDevice.java b/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/getdevice/SyncGetDevice.java index 7a6416ae..25e3e051 100644 --- a/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/getdevice/SyncGetDevice.java +++ b/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/getdevice/SyncGetDevice.java @@ -1,7 +1,5 @@ package com.clearblade.cloud.iot.v1.samples.getdevice; -import java.util.logging.Logger; - import com.clearblade.cloud.iot.v1.DeviceManagerClient; import com.clearblade.cloud.iot.v1.devicetypes.Device; import com.clearblade.cloud.iot.v1.devicetypes.DeviceName; @@ -9,27 +7,30 @@ import com.clearblade.cloud.iot.v1.getdevice.GetDeviceRequest; public class SyncGetDevice { - static Logger log = Logger.getLogger(SyncGetDevice.class.getName()); public static String PROJECT = ""; public static String LOCATION = ""; public static String REGISTRY = ""; public static String DEVICE = ""; public static void main(String[] args) { - PROJECT = args[0]; - LOCATION = args[1]; - REGISTRY = args[2]; - DEVICE = args[3]; + PROJECT = System.getProperty("projectName"); + LOCATION = System.getProperty("location"); + REGISTRY = System.getProperty("registryName"); + DEVICE = System.getProperty("deviceName"); syncGetDevice(); } public static void syncGetDevice() { DeviceManagerClient deviceManagerClient = new DeviceManagerClient(); - //DeviceName name = DeviceName.of("ingressdevelopmentenv", "us-central1", "Rashmi_Registry_Test", "Rashmi_Device_Test"); DeviceName name = DeviceName.of(PROJECT, LOCATION, REGISTRY, DEVICE); GetDeviceRequest request = GetDeviceRequest.Builder.newBuilder().setName(name) .setFieldMask(FieldMask.newBuilder().build()).build(); Device response = deviceManagerClient.getDevice(request); - System.out.println(response.toBuilder().getName()); + if(response != null) { + System.out.println("GetDevice execution successful ::" +response.toBuilder().getName()); + + }else { + System.out.println("GetDevice execution failed"); + } } } diff --git a/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/getdeviceregistry/AsyncGetDeviceRegistry.java b/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/getdeviceregistry/AsyncGetDeviceRegistry.java index 0a9255ac..c1f20e7d 100644 --- a/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/getdeviceregistry/AsyncGetDeviceRegistry.java +++ b/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/getdeviceregistry/AsyncGetDeviceRegistry.java @@ -1,32 +1,34 @@ package com.clearblade.cloud.iot.v1.samples.getdeviceregistry; -import java.util.logging.Logger; - -import com.clearblade.cloud.iot.v1.DeviceManagerClient; +import com.clearblade.cloud.iot.v1.DeviceManagerAsyncClient; import com.clearblade.cloud.iot.v1.getdeviceregistry.GetDeviceRegistryRequest; import com.clearblade.cloud.iot.v1.registrytypes.DeviceRegistry; import com.clearblade.cloud.iot.v1.registrytypes.RegistryName; public class AsyncGetDeviceRegistry { - static Logger log = Logger.getLogger(AsyncGetDeviceRegistry.class.getName()); public static String PROJECT = ""; public static String LOCATION = ""; public static String REGISTRY = ""; public static void main(String[] args) { - PROJECT = args[0]; - LOCATION = args[1]; - REGISTRY = args[2]; + PROJECT = System.getProperty("projectName"); + LOCATION = System.getProperty("location"); + REGISTRY = System.getProperty("registryName"); asyncGetDeviceRegistry(); } public static void asyncGetDeviceRegistry() { - DeviceManagerClient deviceManagerClient = new DeviceManagerClient(); + DeviceManagerAsyncClient deviceManagerAsyncClient = new DeviceManagerAsyncClient(); GetDeviceRegistryRequest request = GetDeviceRegistryRequest.Builder.newBuilder() .setName(RegistryName.of(PROJECT, LOCATION, REGISTRY).getRegistryFullName()) .build(); - DeviceRegistry response = deviceManagerClient.getDeviceRegistry(request); - System.out.println(response.toString()); + DeviceRegistry response = deviceManagerAsyncClient.getDeviceRegistry(request); + if(response != null) { + System.out.println("GetDeviceRegistry execution successful ::"+response.toBuilder().getId()); + + }else { + System.out.println("GetDeviceRegistry execution failed"); + } } } diff --git a/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/getdeviceregistry/SyncGetDeviceRegistry.java b/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/getdeviceregistry/SyncGetDeviceRegistry.java index 245c046c..2bced32f 100644 --- a/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/getdeviceregistry/SyncGetDeviceRegistry.java +++ b/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/getdeviceregistry/SyncGetDeviceRegistry.java @@ -1,32 +1,33 @@ package com.clearblade.cloud.iot.v1.samples.getdeviceregistry; -import java.util.logging.Logger; - -import com.clearblade.cloud.iot.v1.DeviceManagerAsyncClient; +import com.clearblade.cloud.iot.v1.DeviceManagerClient; import com.clearblade.cloud.iot.v1.getdeviceregistry.GetDeviceRegistryRequest; import com.clearblade.cloud.iot.v1.registrytypes.DeviceRegistry; import com.clearblade.cloud.iot.v1.registrytypes.RegistryName; public class SyncGetDeviceRegistry { - static Logger log = Logger.getLogger(SyncGetDeviceRegistry.class.getName()); public static String PROJECT = ""; public static String LOCATION = ""; public static String REGISTRY = ""; public static void main(String[] args) { - PROJECT = args[0]; - LOCATION = args[1]; - REGISTRY = args[2]; + PROJECT = System.getProperty("projectName"); + LOCATION = System.getProperty("location"); + REGISTRY = System.getProperty("registryName"); syncGetDeviceRegistry(); } public static void syncGetDeviceRegistry() { - DeviceManagerAsyncClient deviceManagerAsyncClient = new DeviceManagerAsyncClient(); + DeviceManagerClient deviceManagerClient = new DeviceManagerClient(); GetDeviceRegistryRequest request = GetDeviceRegistryRequest.Builder.newBuilder() .setName(RegistryName.of(PROJECT, LOCATION, REGISTRY).getRegistryFullName()) .build(); - DeviceRegistry response = deviceManagerAsyncClient.getDeviceRegistry(request); - System.out.println(response.createDeviceJSONObject("")); + DeviceRegistry response = deviceManagerClient.getDeviceRegistry(request); + if(response != null) { + System.out.println("GetDeviceRegistry execution successful ::"+response.toBuilder().getId()); + }else { + System.out.println("GetDeviceRegistry execution failed"); + } } } diff --git a/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/listdeviceconfigversions/AsyncListDeviceConfigVersions.java b/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/listdeviceconfigversions/AsyncListDeviceConfigVersions.java index 93c6c149..ef62136d 100644 --- a/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/listdeviceconfigversions/AsyncListDeviceConfigVersions.java +++ b/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/listdeviceconfigversions/AsyncListDeviceConfigVersions.java @@ -1,7 +1,5 @@ package com.clearblade.cloud.iot.v1.samples.listdeviceconfigversions; -import java.util.logging.Logger; - import com.clearblade.cloud.iot.v1.DeviceManagerAsyncClient; import com.clearblade.cloud.iot.v1.devicetypes.DeviceConfig; import com.clearblade.cloud.iot.v1.devicetypes.DeviceName; @@ -10,9 +8,18 @@ public class AsyncListDeviceConfigVersions { - static Logger log = Logger.getLogger(AsyncListDeviceConfigVersions.class.getName()); - - public static void main(String[] args) { + public static String PROJECT = ""; + public static String LOCATION = ""; + public static String REGISTRY = ""; + public static String DEVICE = ""; + public static String NUMVERSION = ""; + + public static void main(String[] args) { + PROJECT = System.getProperty("projectName"); + LOCATION = System.getProperty("location"); + REGISTRY = System.getProperty("registryName"); + DEVICE = System.getProperty("deviceName"); + NUMVERSION = System.getProperty("numVersion"); asyncDevicesConfigVersionsList(); } @@ -20,13 +27,21 @@ public static void asyncDevicesConfigVersionsList() { DeviceManagerAsyncClient deviceManagerAsyncClient = new DeviceManagerAsyncClient(); ListDeviceConfigVersionsRequest request = ListDeviceConfigVersionsRequest.Builder.newBuilder() .setName(DeviceName - .of("ingressdevelopmentenv", "us-central1", "Rashmi_Registry_Test", "Rashmi_Device_Test") + .of(PROJECT, LOCATION, REGISTRY, DEVICE) .toString()) - .setNumVersions(2).build(); + .setNumVersions(Integer.parseInt(NUMVERSION)).build(); ListDeviceConfigVersionsResponse response = deviceManagerAsyncClient.listDeviceConfigVersions(request); - for (DeviceConfig element : response.getDeviceConfigList()) { - System.out.println(element.toString()); + + if(response != null) { + System.out.println("DeviceConfigVersionsList fetch successful"); + for (DeviceConfig element : response.getDeviceConfigList()) { + System.out.println(element.toString()); + } + + }else { + System.out.println("DeviceConfigVersionsList fetch failed"); } + } } diff --git a/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/listdeviceconfigversions/SyncListDeviceConfigVersions.java b/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/listdeviceconfigversions/SyncListDeviceConfigVersions.java index e8751279..9bfe7656 100644 --- a/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/listdeviceconfigversions/SyncListDeviceConfigVersions.java +++ b/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/listdeviceconfigversions/SyncListDeviceConfigVersions.java @@ -1,7 +1,5 @@ package com.clearblade.cloud.iot.v1.samples.listdeviceconfigversions; -import java.util.logging.Logger; - import com.clearblade.cloud.iot.v1.DeviceManagerClient; import com.clearblade.cloud.iot.v1.devicetypes.DeviceConfig; import com.clearblade.cloud.iot.v1.devicetypes.DeviceName; @@ -10,9 +8,18 @@ public class SyncListDeviceConfigVersions { - static Logger log = Logger.getLogger(SyncListDeviceConfigVersions.class.getName()); - - public static void main(String[] args) { + public static String PROJECT = ""; + public static String LOCATION = ""; + public static String REGISTRY = ""; + public static String DEVICE = ""; + public static String NUMVERSION = ""; + + public static void main(String[] args) { + PROJECT = System.getProperty("projectName"); + LOCATION = System.getProperty("location"); + REGISTRY = System.getProperty("registryName"); + DEVICE = System.getProperty("deviceName"); + NUMVERSION = System.getProperty("numVersion"); syncDevicesConfigVersionsList(); } @@ -20,12 +27,18 @@ public static void syncDevicesConfigVersionsList() { DeviceManagerClient deviceManagerClient = new DeviceManagerClient(); ListDeviceConfigVersionsRequest request = ListDeviceConfigVersionsRequest.Builder.newBuilder() .setName(DeviceName - .of("ingressdevelopmentenv", "us-central1", "Rashmi_Registry_Test", "Rashmi_Device_Test") + .of(PROJECT, LOCATION, REGISTRY, DEVICE) .toString()) - .setNumVersions(2).build(); + .setNumVersions(Integer.parseInt(NUMVERSION)).build(); ListDeviceConfigVersionsResponse response = deviceManagerClient.listDeviceConfigVersions(request); - for (DeviceConfig element : response.getDeviceConfigList()) { - System.out.println(element.toString()); + if(response != null) { + System.out.println("DeviceConfigVersionsList fetch successful"); + for (DeviceConfig element : response.getDeviceConfigList()) { + System.out.println(element.toString()); + } + + }else { + System.out.println("DeviceConfigVersionsList fetch failed"); } } diff --git a/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/listdeviceregistries/AsyncListDeviceRegistries.java b/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/listdeviceregistries/AsyncListDeviceRegistries.java index 1a811083..60a4091b 100644 --- a/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/listdeviceregistries/AsyncListDeviceRegistries.java +++ b/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/listdeviceregistries/AsyncListDeviceRegistries.java @@ -7,22 +7,32 @@ import com.clearblade.cloud.iot.v1.registrytypes.LocationName; public class AsyncListDeviceRegistries { - public static void main(String[] args) throws Exception { + public static String PROJECT = ""; + public static String LOCATION = ""; + + public static void main(String[] args) throws Exception{ + PROJECT = System.getProperty("projectName"); + LOCATION = System.getProperty("location"); asyncListDeviceRegistries(); } public static void asyncListDeviceRegistries() throws Exception { DeviceManagerAsyncClient deviceManagerClient = new DeviceManagerAsyncClient(); ListDeviceRegistriesRequest request = ListDeviceRegistriesRequest.Builder.newBuilder() - .setParent(LocationName.of("ingressdevelopmentenv", "us-central1").getLocationFullName()) + .setParent(LocationName.of(PROJECT, LOCATION).getLocationFullName()) .build(); ListDeviceRegistriesResponse response = deviceManagerClient.listDeviceRegistries(request); + if(response != null) { + System.out.println("DeviceRegistriesList fetch successful"); + for (DeviceRegistry element : response.getDeviceRegistriesList()) { + System.out.println(element.toBuilder().getName()); + } + System.out.println(response.getNextPageToken()); - for (DeviceRegistry element : response.getDeviceRegistriesList()) { - System.out.println(element.toBuilder().getName()); - + }else { + System.out.println("DeviceRegistriesList fetch failed"); } - System.out.println(response.getNextPageToken()); + } } diff --git a/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/listdeviceregistries/SyncListDeviceRegistries.java b/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/listdeviceregistries/SyncListDeviceRegistries.java index dc42d7cd..ebd2fc0b 100644 --- a/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/listdeviceregistries/SyncListDeviceRegistries.java +++ b/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/listdeviceregistries/SyncListDeviceRegistries.java @@ -7,21 +7,31 @@ import com.clearblade.cloud.iot.v1.registrytypes.LocationName; public class SyncListDeviceRegistries { - public static void main(String[] args) throws Exception { + public static String PROJECT = ""; + public static String LOCATION = ""; + + public static void main(String[] args) throws Exception{ + PROJECT = System.getProperty("projectName"); + LOCATION = System.getProperty("location"); syncListDeviceRegistries(); } public static void syncListDeviceRegistries() throws Exception { DeviceManagerClient deviceManagerClient = new DeviceManagerClient(); ListDeviceRegistriesRequest request = ListDeviceRegistriesRequest.Builder.newBuilder() - .setParent(LocationName.of("ingressdevelopmentenv", "us-central1").getLocationFullName()) + .setParent(LocationName.of(PROJECT,LOCATION).getLocationFullName()) .build(); ListDeviceRegistriesResponse response = deviceManagerClient.listDeviceRegistries(request); - for (DeviceRegistry element : response.getDeviceRegistriesList()) { - System.out.println(element.toBuilder().getName()); + if(response != null) { + System.out.println("DeviceRegistriesList fetch successful"); + for (DeviceRegistry element : response.getDeviceRegistriesList()) { + System.out.println(element.toBuilder().getName()); + } + System.out.println(response.getNextPageToken()); + }else { + System.out.println("DeviceRegistriesList fetch failed"); } - System.out.println(response.getNextPageToken()); } } diff --git a/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/modifycloudtodeviceconfig/AsyncModifyCloudToDeviceConfig.java b/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/modifycloudtodeviceconfig/AsyncModifyCloudToDeviceConfig.java index 07af37e7..9467b934 100644 --- a/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/modifycloudtodeviceconfig/AsyncModifyCloudToDeviceConfig.java +++ b/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/modifycloudtodeviceconfig/AsyncModifyCloudToDeviceConfig.java @@ -1,7 +1,5 @@ package com.clearblade.cloud.iot.v1.samples.modifycloudtodeviceconfig; -import java.util.logging.Logger; - import com.clearblade.cloud.iot.v1.DeviceManagerAsyncClient; import com.clearblade.cloud.iot.v1.devicetypes.DeviceConfig; import com.clearblade.cloud.iot.v1.devicetypes.DeviceName; @@ -9,20 +7,34 @@ import com.clearblade.cloud.iot.v1.utils.ByteString; public class AsyncModifyCloudToDeviceConfig { - static Logger log = Logger.getLogger(AsyncModifyCloudToDeviceConfig.class.getName()); - public static void main(String[] args) { + public static String PROJECT = ""; + public static String LOCATION = ""; + public static String REGISTRY = ""; + public static String DEVICE = ""; + public static String BINARYDATA = ""; + public static String VERSIONTOUPDATE = ""; + + public static void main(String[] args) { + PROJECT = System.getProperty("projectName"); + LOCATION = System.getProperty("location"); + REGISTRY = System.getProperty("registryName"); + DEVICE = System.getProperty("deviceName"); + BINARYDATA = System.getProperty("binaryData"); + VERSIONTOUPDATE = System.getProperty("versionToUpdate"); asyncModifyCloudToDeviceConfig(); } public static void asyncModifyCloudToDeviceConfig() { DeviceManagerAsyncClient deviceManagerClient = new DeviceManagerAsyncClient(); ModifyCloudToDeviceConfigRequest request = ModifyCloudToDeviceConfigRequest.Builder.newBuilder() - .setName(DeviceName - .of("ingressdevelopmentenv", "us-central1", "MandarTest1", "mandar_device") - .toString()) - .setBinaryData(new ByteString("WWV0QW5vdGhlck1lc3NhZ2U=")).setVersionToUpdate("3").build(); + .setName(DeviceName.of(PROJECT,LOCATION, REGISTRY, DEVICE).toString()) + .setBinaryData(new ByteString(BINARYDATA)).setVersionToUpdate(VERSIONTOUPDATE).build(); DeviceConfig response = deviceManagerClient.modifyCloudToDeviceConfig(request); - System.out.println(response.toString()); + if(response != null) { + System.out.println("ModifyDeviceToConfig execution successful"); + }else { + System.out.println("ModifyDeviceToConfig execution failed"); + } } } diff --git a/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/modifycloudtodeviceconfig/SyncModifyCloudToDeviceConfig.java b/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/modifycloudtodeviceconfig/SyncModifyCloudToDeviceConfig.java index d6a8fe3b..37e07cb7 100644 --- a/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/modifycloudtodeviceconfig/SyncModifyCloudToDeviceConfig.java +++ b/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/modifycloudtodeviceconfig/SyncModifyCloudToDeviceConfig.java @@ -1,7 +1,5 @@ package com.clearblade.cloud.iot.v1.samples.modifycloudtodeviceconfig; -import java.util.logging.Logger; - import com.clearblade.cloud.iot.v1.DeviceManagerClient; import com.clearblade.cloud.iot.v1.devicetypes.DeviceConfig; import com.clearblade.cloud.iot.v1.devicetypes.DeviceName; @@ -9,9 +7,20 @@ import com.clearblade.cloud.iot.v1.utils.ByteString; public class SyncModifyCloudToDeviceConfig { - static Logger log = Logger.getLogger(SyncModifyCloudToDeviceConfig.class.getName()); - - public static void main(String[] args) { + public static String PROJECT = ""; + public static String LOCATION = ""; + public static String REGISTRY = ""; + public static String DEVICE = ""; + public static String BINARYDATA = ""; + public static String VERSIONTOUPDATE = ""; + + public static void main(String[] args) { + PROJECT = System.getProperty("projectName"); + LOCATION = System.getProperty("location"); + REGISTRY = System.getProperty("registryName"); + DEVICE = System.getProperty("deviceName"); + BINARYDATA = System.getProperty("binaryData"); + VERSIONTOUPDATE = System.getProperty("versionToUpdate"); syncModifyCloudToDeviceConfig(); } @@ -19,11 +28,13 @@ public static void syncModifyCloudToDeviceConfig() { DeviceManagerClient deviceManagerClient = new DeviceManagerClient(); ModifyCloudToDeviceConfigRequest request = ModifyCloudToDeviceConfigRequest.Builder.newBuilder() - .setName(DeviceName - .of("ingressdevelopmentenv", "us-central1", "Rashmi_Registry_Test", "Rashmi_Device_Test") - .toString()) - .setBinaryData(new ByteString("bmV3TWVzc2FnZUZvckNvbmZpZw==")).setVersionToUpdate("6").build(); + .setName(DeviceName.of(PROJECT,LOCATION, REGISTRY, DEVICE).toString()) + .setBinaryData(new ByteString(BINARYDATA)).setVersionToUpdate(VERSIONTOUPDATE).build(); DeviceConfig response = deviceManagerClient.modifyCloudToDeviceConfig(request); - System.out.println(response.toString()); + if(response != null) { + System.out.println("ModifyDeviceToConfig execution successful"); + }else { + System.out.println("ModifyDeviceToConfig execution failed"); + } } } diff --git a/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/sendcommandtodevice/AsyncSendCommandToDevice.java b/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/sendcommandtodevice/AsyncSendCommandToDevice.java index 9ebe3e5e..5a509eb8 100644 --- a/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/sendcommandtodevice/AsyncSendCommandToDevice.java +++ b/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/sendcommandtodevice/AsyncSendCommandToDevice.java @@ -1,7 +1,5 @@ package com.clearblade.cloud.iot.v1.samples.sendcommandtodevice; -import java.util.logging.Logger; - import com.clearblade.cloud.iot.v1.DeviceManagerAsyncClient; import com.clearblade.cloud.iot.v1.devicetypes.DeviceName; import com.clearblade.cloud.iot.v1.sendcommandtodevice.SendCommandToDeviceRequest; @@ -10,21 +8,33 @@ public class AsyncSendCommandToDevice { - static Logger log = Logger.getLogger(AsyncSendCommandToDevice.class.getName()); - - public static void main(String[] args) { + public static String PROJECT = ""; + public static String LOCATION = ""; + public static String REGISTRY = ""; + public static String DEVICE = ""; + public static String BINARYDATA = ""; + public static String SUBFOLDER = ""; + + public static void main(String[] args) { + PROJECT = System.getProperty("projectName"); + LOCATION = System.getProperty("location"); + REGISTRY = System.getProperty("registryName"); + DEVICE = System.getProperty("deviceName"); + BINARYDATA = System.getProperty("binaryData"); + SUBFOLDER = System.getProperty("subFolder"); asyncSendCommandToDevice(); } public static void asyncSendCommandToDevice() { DeviceManagerAsyncClient deviceManagerAsyncClient = new DeviceManagerAsyncClient(); SendCommandToDeviceRequest request = SendCommandToDeviceRequest.Builder.newBuilder() - .setName(DeviceName - .of("ingressdevelopmentenv", "us-central1", "MandarTest1", "mandar_device") - .toString()) - .setBinaryData(new ByteString("c2VuZEZ1bm55TWVzc2FnZVRvRGV2aWNl")).setSubfolder("testdata").build(); + .setName(DeviceName.of(PROJECT, LOCATION, REGISTRY, DEVICE).toString()) + .setBinaryData(new ByteString(BINARYDATA)).setSubfolder(SUBFOLDER).build(); SendCommandToDeviceResponse response = deviceManagerAsyncClient.sendCommandToDevice(request); - System.out.println(response.toString()); - + if(response != null) { + System.out.println("SendCommandToDevice execution successful"); + }else { + System.out.println("SendCommandToDevice execution failed"); + } } } diff --git a/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/sendcommandtodevice/SyncSendCommandToDevice.java b/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/sendcommandtodevice/SyncSendCommandToDevice.java index b8ec4239..996f88ce 100644 --- a/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/sendcommandtodevice/SyncSendCommandToDevice.java +++ b/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/sendcommandtodevice/SyncSendCommandToDevice.java @@ -1,7 +1,5 @@ package com.clearblade.cloud.iot.v1.samples.sendcommandtodevice; -import java.util.logging.Logger; - import com.clearblade.cloud.iot.v1.DeviceManagerClient; import com.clearblade.cloud.iot.v1.devicetypes.DeviceName; import com.clearblade.cloud.iot.v1.sendcommandtodevice.SendCommandToDeviceRequest; @@ -10,20 +8,33 @@ public class SyncSendCommandToDevice { - static Logger log = Logger.getLogger(SyncSendCommandToDevice.class.getName()); - - public static void main(String[] args) { + public static String PROJECT = ""; + public static String LOCATION = ""; + public static String REGISTRY = ""; + public static String DEVICE = ""; + public static String BINARYDATA = ""; + public static String SUBFOLDER = ""; + + public static void main(String[] args) { + PROJECT = System.getProperty("projectName"); + LOCATION = System.getProperty("location"); + REGISTRY = System.getProperty("registryName"); + DEVICE = System.getProperty("deviceName"); + BINARYDATA = System.getProperty("binaryData"); + SUBFOLDER = System.getProperty("subFolder"); syncSendCommandToDevice(); } public static void syncSendCommandToDevice() { DeviceManagerClient deviceManagerClient = new DeviceManagerClient(); SendCommandToDeviceRequest request = SendCommandToDeviceRequest.Builder.newBuilder() - .setName(DeviceName - .of("ingressdevelopmentenv", "us-central1", "MandarTest1", "mandar_device") - .toString()) - .setBinaryData(new ByteString("c2VuZEZ1bm55TWVzc2FnZVRvRGV2aWNl")).setSubfolder("testdata").build(); + .setName(DeviceName.of(PROJECT, LOCATION, REGISTRY, DEVICE).toString()) + .setBinaryData(new ByteString(BINARYDATA)).setSubfolder(SUBFOLDER).build(); SendCommandToDeviceResponse response = deviceManagerClient.sendCommandToDevice(request); - System.out.println(response.toString()); + if(response != null) { + System.out.println("SendCommandToDevice execution successful"); + }else { + System.out.println("SendCommandToDevice execution failed"); + } } } diff --git a/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/unbinddevicefromgateway/AsyncUnbindDeviceFromGateway.java b/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/unbinddevicefromgateway/AsyncUnbindDeviceFromGateway.java index 3b80d731..5f6240e3 100644 --- a/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/unbinddevicefromgateway/AsyncUnbindDeviceFromGateway.java +++ b/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/unbinddevicefromgateway/AsyncUnbindDeviceFromGateway.java @@ -1,27 +1,38 @@ package com.clearblade.cloud.iot.v1.samples.unbinddevicefromgateway; -import java.util.logging.Logger; - import com.clearblade.cloud.iot.v1.DeviceManagerAsyncClient; import com.clearblade.cloud.iot.v1.registrytypes.RegistryName; import com.clearblade.cloud.iot.v1.unbinddevicefromgateway.UnbindDeviceFromGatewayRequest; import com.clearblade.cloud.iot.v1.unbinddevicefromgateway.UnbindDeviceFromGatewayResponse; public class AsyncUnbindDeviceFromGateway { - static Logger log = Logger.getLogger(AsyncUnbindDeviceFromGateway.class.getName()); + public static String PROJECT = ""; + public static String LOCATION = ""; + public static String REGISTRY = ""; + public static String GATEWAY = ""; + public static String DEVICE = ""; - public static void main(String[] args) { + public static void main(String[] args) { + PROJECT = System.getProperty("projectName"); + LOCATION = System.getProperty("location"); + REGISTRY = System.getProperty("registryName"); + GATEWAY = System.getProperty("gatewayName"); + DEVICE = System.getProperty("deviceName"); asyncUnbindDeviceFromGateway(); } public static void asyncUnbindDeviceFromGateway() { DeviceManagerAsyncClient deviceManagerAsyncClient = new DeviceManagerAsyncClient(); UnbindDeviceFromGatewayRequest request = UnbindDeviceFromGatewayRequest.Builder.newBuilder() - .setParent(RegistryName.of("ingressdevelopmentenv", "us-central1", "Rashmi_Registry_Test").toString()) - .setGateway("Rashmi_Gateway_Test").setDevice("myOldDevice").build(); + .setParent(RegistryName.of(PROJECT, LOCATION, REGISTRY).toString()) + .setGateway(GATEWAY).setDevice(DEVICE).build(); UnbindDeviceFromGatewayResponse response = deviceManagerAsyncClient.unbindDeviceFromGateway(request); - System.out.println(response.toString()); + if(response != null) { + System.out.println("UnbindDeviceFromGateway execution successful"); + }else { + System.out.println("UnbindDeviceFromGateway execution failed"); + } } } diff --git a/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/unbinddevicefromgateway/SyncUnbindDeviceFromGateway.java b/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/unbinddevicefromgateway/SyncUnbindDeviceFromGateway.java index 31656594..1cf937ed 100644 --- a/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/unbinddevicefromgateway/SyncUnbindDeviceFromGateway.java +++ b/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/unbinddevicefromgateway/SyncUnbindDeviceFromGateway.java @@ -1,26 +1,37 @@ package com.clearblade.cloud.iot.v1.samples.unbinddevicefromgateway; -import java.util.logging.Logger; - import com.clearblade.cloud.iot.v1.DeviceManagerClient; import com.clearblade.cloud.iot.v1.registrytypes.RegistryName; import com.clearblade.cloud.iot.v1.unbinddevicefromgateway.UnbindDeviceFromGatewayRequest; import com.clearblade.cloud.iot.v1.unbinddevicefromgateway.UnbindDeviceFromGatewayResponse; public class SyncUnbindDeviceFromGateway { - static Logger log = Logger.getLogger(SyncUnbindDeviceFromGateway.class.getName()); + public static String PROJECT = ""; + public static String LOCATION = ""; + public static String REGISTRY = ""; + public static String GATEWAY = ""; + public static String DEVICE = ""; - public static void main(String[] args) { + public static void main(String[] args) { + PROJECT = System.getProperty("projectName"); + LOCATION = System.getProperty("location"); + REGISTRY = System.getProperty("registryName"); + GATEWAY = System.getProperty("gatewayName"); + DEVICE = System.getProperty("deviceName"); syncUnbindDeviceFromGateway(); } public static void syncUnbindDeviceFromGateway() { DeviceManagerClient deviceManagerClient = new DeviceManagerClient(); UnbindDeviceFromGatewayRequest request = UnbindDeviceFromGatewayRequest.Builder.newBuilder() - .setParent(RegistryName.of("ingressdevelopmentenv", "us-central1", "Rashmi_Registry_Test").toString()) - .setGateway("Rashmi_Gateway_Test").setDevice("Rashmi_Device_Test").build(); + .setParent(RegistryName.of(PROJECT, LOCATION, REGISTRY).toString()) + .setGateway(GATEWAY).setDevice(DEVICE).build(); UnbindDeviceFromGatewayResponse response = deviceManagerClient.unbindDeviceFromGateway(request); - System.out.println(response.toString()); + if(response != null) { + System.out.println("UnbindDeviceFromGateway execution successful"); + }else { + System.out.println("UnbindDeviceFromGateway execution failed"); + } } } diff --git a/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/updatedevice/AsyncUpdateDevice.java b/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/updatedevice/AsyncUpdateDevice.java index 1f8a370e..14f4e0cd 100644 --- a/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/updatedevice/AsyncUpdateDevice.java +++ b/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/updatedevice/AsyncUpdateDevice.java @@ -1,28 +1,70 @@ package com.clearblade.cloud.iot.v1.samples.updatedevice; -import java.util.logging.Logger; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; import com.clearblade.cloud.iot.v1.DeviceManagerAsyncClient; import com.clearblade.cloud.iot.v1.devicetypes.Device; +import com.clearblade.cloud.iot.v1.devicetypes.DeviceCredential; +import com.clearblade.cloud.iot.v1.registrytypes.PublicKeyCredential; +import com.clearblade.cloud.iot.v1.registrytypes.PublicKeyFormat; import com.clearblade.cloud.iot.v1.updatedevice.UpdateDeviceRequest; import com.clearblade.cloud.iot.v1.utils.LogLevel; public class AsyncUpdateDevice { - static Logger log = Logger.getLogger(AsyncUpdateDevice.class.getName()); + public static String DEVICE = ""; + public static String UPDATEMASK = ""; + public static String ARG=""; + public static String[] NEWARGS = null; + public static String KEYFORMAT =""; + public static String KEYVAL = ""; - public static void main(String[] args) { + public static void main(String[] args) { + DEVICE = System.getProperty("deviceName"); + UPDATEMASK = System.getProperty("updateMask"); + if(!(System.getProperty("arg").isBlank() || System.getProperty("arg").isEmpty()|| System.getProperty("arg")==null)) + ARG = System.getProperty("arg"); + if(System.getProperty("newArgs") != null) + NEWARGS = System.getProperty("newArgs").split(","); asyncUpdateDevice(); } public static void asyncUpdateDevice() { - DeviceManagerAsyncClient deviceManagerAsyncClient = new DeviceManagerAsyncClient(); - Device device = Device.patch("myOldDevice", "myOldDevice", LogLevel.ERROR, true); - String updateMask = "logLevel"; - - UpdateDeviceRequest request = UpdateDeviceRequest.Builder.newBuilder().setName("myOldDevice").setDevice(device) - .setUpdateMask(updateMask).build(); + DeviceManagerAsyncClient deviceManagerAsyncClient = new DeviceManagerAsyncClient(); + Device device = new Device(); + device.toBuilder().setId(DEVICE).setName(DEVICE).build(); + if(UPDATEMASK .equals("logLevel")) { + device.toBuilder().setLogLevel(LogLevel.valueOf(ARG)); + }else if(UPDATEMASK .equals("blocked")) { + device.toBuilder().setBlocked(Boolean.valueOf(ARG)); + }else if(UPDATEMASK .equals("metadata")) { + Map metadata = new HashMap<>(); + for(int i=0;i listCredentials = new ArrayList<>(); + PublicKeyCredential publicKeyCredential = new PublicKeyCredential(); + publicKeyCredential.setFormat(PublicKeyFormat.valueOf(KEYFORMAT)); + publicKeyCredential.setKey(KEYVAL); + DeviceCredential credential = new DeviceCredential(); + credential.setPublicKey(publicKeyCredential); + listCredentials.add(credential); + device.toBuilder().setCredentials(listCredentials); + } + UpdateDeviceRequest request = UpdateDeviceRequest.Builder.newBuilder().setName(DEVICE).setDevice(device) + .setUpdateMask(UPDATEMASK).build(); Device response = deviceManagerAsyncClient.updateDevice(request); - System.out.println(response.toBuilder().getName() + "::" + response.toBuilder().getLogLevel().name()); + if(response != null) { + System.out.println("UpdateDevice execution successful"); + }else { + System.out.println("UpdateDevice execution failed"); + } } } diff --git a/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/updatedevice/SyncUpdateDevice.java b/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/updatedevice/SyncUpdateDevice.java index 48291a38..882cd3d0 100644 --- a/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/updatedevice/SyncUpdateDevice.java +++ b/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/updatedevice/SyncUpdateDevice.java @@ -1,28 +1,71 @@ package com.clearblade.cloud.iot.v1.samples.updatedevice; -import java.util.logging.Logger; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; import com.clearblade.cloud.iot.v1.DeviceManagerClient; import com.clearblade.cloud.iot.v1.devicetypes.Device; +import com.clearblade.cloud.iot.v1.devicetypes.DeviceCredential; +import com.clearblade.cloud.iot.v1.registrytypes.PublicKeyCredential; +import com.clearblade.cloud.iot.v1.registrytypes.PublicKeyFormat; import com.clearblade.cloud.iot.v1.updatedevice.UpdateDeviceRequest; import com.clearblade.cloud.iot.v1.utils.LogLevel; public class SyncUpdateDevice { - static Logger log = Logger.getLogger(SyncUpdateDevice.class.getName()); + public static String DEVICE = ""; + public static String UPDATEMASK = ""; + public static String ARG=""; + public static String[] NEWARGS = null; + public static String KEYFORMAT =""; + public static String KEYVAL = ""; - public static void main(String[] args) { + public static void main(String[] args) { + DEVICE = System.getProperty("deviceName"); + UPDATEMASK = System.getProperty("updateMask"); + if(!(System.getProperty("arg").isBlank() || System.getProperty("arg").isEmpty()|| System.getProperty("arg")==null)) + ARG = System.getProperty("arg"); + if(System.getProperty("newArgs") != null) + NEWARGS = System.getProperty("newArgs").split(","); syncUpdateDevice(); } public static void syncUpdateDevice() { DeviceManagerClient deviceManagerClient = new DeviceManagerClient(); - Device device = Device.patch("myOldDevice", "myOldDevice", LogLevel.DEBUG, true); - String updateMask = "logLevel"; + Device device = new Device(); + device.toBuilder().setId(DEVICE).setName(DEVICE).build(); + if(UPDATEMASK .equals("logLevel")) { + device.toBuilder().setLogLevel(LogLevel.valueOf(ARG)); + }else if(UPDATEMASK .equals("blocked")) { + device.toBuilder().setBlocked(Boolean.valueOf(ARG)); + }else if(UPDATEMASK .equals("metadata")) { + Map metadata = new HashMap<>(); + for(int i=0;i listCredentials = new ArrayList<>(); + PublicKeyCredential publicKeyCredential = new PublicKeyCredential(); + publicKeyCredential.setFormat(PublicKeyFormat.valueOf(KEYFORMAT)); + publicKeyCredential.setKey(KEYVAL); + DeviceCredential credential = new DeviceCredential(); + credential.setPublicKey(publicKeyCredential); + listCredentials.add(credential); + device.toBuilder().setCredentials(listCredentials); + } - UpdateDeviceRequest request = UpdateDeviceRequest.Builder.newBuilder().setName("myOldDevice").setDevice(device) - .setUpdateMask(updateMask).build(); + UpdateDeviceRequest request = UpdateDeviceRequest.Builder.newBuilder().setName(DEVICE).setDevice(device) + .setUpdateMask(UPDATEMASK).build(); Device response = deviceManagerClient.updateDevice(request); - System.out.println(response.toBuilder().getName() + "::" + response.toBuilder().getLogLevel().name()); + if(response != null) { + System.out.println("UpdateDevice execution successful"); + }else { + System.out.println("UpdateDevice execution failed"); + } } } diff --git a/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/updatedeviceregistry/AsyncUpdateDeviceRegistry.java b/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/updatedeviceregistry/AsyncUpdateDeviceRegistry.java index db66276f..70c41fc9 100644 --- a/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/updatedeviceregistry/AsyncUpdateDeviceRegistry.java +++ b/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/updatedeviceregistry/AsyncUpdateDeviceRegistry.java @@ -7,23 +7,34 @@ import com.clearblade.cloud.iot.v1.utils.LogLevel; public class AsyncUpdateDeviceRegistry { - public static void main(String[] args) throws Exception { + public static String PROJECT = ""; + public static String LOCATION = ""; + public static String REGISTRY = ""; + public static String LOGLEVEL = ""; + + public static void main(String[] args) throws Exception{ + PROJECT = System.getProperty("projectName"); + LOCATION = System.getProperty("location"); + REGISTRY = System.getProperty("registryName"); + LOGLEVEL = System.getProperty("logLevel"); asyncUpdateDeviceRegistry(); } public static void asyncUpdateDeviceRegistry() throws Exception { DeviceManagerAsyncClient deviceManagerClient = new DeviceManagerAsyncClient(); - RegistryName name = RegistryName.of("ingressdevelopmentenv", "us-central1", "Registry_Test1"); + RegistryName name = RegistryName.of(PROJECT, LOCATION, REGISTRY); UpdateDeviceRegistryRequest request = UpdateDeviceRegistryRequest.Builder.newBuilder() - .setDeviceRegistry(DeviceRegistry.newBuilder().setId("Rashmi_Registry_Test") + .setDeviceRegistry(DeviceRegistry.newBuilder().setId(REGISTRY) .setName(name.getRegistryFullName()) - .setLogLevel(LogLevel.DEBUG) + .setLogLevel(LogLevel.valueOf(LOGLEVEL)) .build()) .setName(name.getRegistryFullName()).setUpdateMask("logLevel").build(); DeviceRegistry response = deviceManagerClient.updateDeviceRegistry(request); - if (response != null) { - System.out.println(response.toBuilder().getName() + "::" + response.toBuilder().getLogLevel()); + if(response != null) { + System.out.println("UpdateDeviceRegistry execution successful"); + }else { + System.out.println("UpdateDeviceRegistry execution failed"); } } diff --git a/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/updatedeviceregistry/SyncUpdateDeviceRegistry.java b/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/updatedeviceregistry/SyncUpdateDeviceRegistry.java index 98d63425..a5d18263 100644 --- a/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/updatedeviceregistry/SyncUpdateDeviceRegistry.java +++ b/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/updatedeviceregistry/SyncUpdateDeviceRegistry.java @@ -8,24 +8,35 @@ public class SyncUpdateDeviceRegistry { - public static void main(String[] args) throws Exception { + public static String PROJECT = ""; + public static String LOCATION = ""; + public static String REGISTRY = ""; + public static String LOGLEVEL = ""; + + public static void main(String[] args) throws Exception{ + PROJECT = System.getProperty("projectName"); + LOCATION = System.getProperty("location"); + REGISTRY = System.getProperty("registryName"); + LOGLEVEL = System.getProperty("logLevel"); syncUpdateDeviceRegistry(); } public static void syncUpdateDeviceRegistry() throws Exception { DeviceManagerClient deviceManagerClient = new DeviceManagerClient(); - RegistryName name = RegistryName.of("ingressdevelopmentenv", "us-central1", "Rashmi_Registry_Test"); + RegistryName name = RegistryName.of(PROJECT, LOCATION, REGISTRY); UpdateDeviceRegistryRequest request = UpdateDeviceRegistryRequest.Builder.newBuilder() - .setDeviceRegistry(DeviceRegistry.newBuilder().setId("Rashmi_Registry_Test") + .setDeviceRegistry(DeviceRegistry.newBuilder().setId(REGISTRY) .setName(name.getRegistryFullName()) - .setLogLevel(LogLevel.DEBUG) + .setLogLevel(LogLevel.valueOf(LOGLEVEL)) .build()) .setName(name.getRegistryFullName()).setUpdateMask("logLevel").build(); DeviceRegistry response = deviceManagerClient.updateDeviceRegistry(request); - if (response != null) { - System.out.println(response.toBuilder().getName() + "::" + response.toBuilder().getLogLevel()); + if(response != null) { + System.out.println("UpdateDeviceRegistry execution successful"); + }else { + System.out.println("UpdateDeviceRegistry execution failed"); } } } diff --git a/clearblade-cloud-iot/samples/pom.xml b/clearblade-cloud-iot/samples/pom.xml deleted file mode 100644 index 8b1ace2d..00000000 --- a/clearblade-cloud-iot/samples/pom.xml +++ /dev/null @@ -1,119 +0,0 @@ - - 4.0.0 - clearblade-cloud-iot - clearblade-cloud-iot-samples - 0.0.1-SNAPSHOT - - . - - - org.apache.maven.plugins - maven-compiler-plugin - 3.8.0 - - 17 - - - - org.codehaus.mojo - build-helper-maven-plugin - 3.0.0 - - - generate-sources - - add-source - - - - . - ../src - - - - - - - org.apache.maven.plugins - maven-dependency-plugin - 3.3.0 - - - copy-dependencies - package - - copy-dependencies - - - ./target - false - true - true - - - - - - - - org.codehaus.mojo - exec-maven-plugin - 1.4.0 - - java - - - - clearblade-cloud-iot - clearblade-cloud-iot-samples - 0.0.1-SNAPSHOT - jar - - - - - - - - - - com.googlecode.json-simple - json-simple - 1.1.1 - - - - org.junit.jupiter - junit-jupiter-api - 5.8.2 - test - - - - org.junit.jupiter - junit-jupiter-engine - 5.8.2 - test - - - - com.google.code.findbugs - jsr305 - 3.0.2 - - - \ No newline at end of file diff --git a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/AsyncClient.java b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/AsyncClient.java index f2c6d931..211dc965 100644 --- a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/AsyncClient.java +++ b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/AsyncClient.java @@ -1,25 +1,20 @@ package com.clearblade.cloud.iot.v1; -import java.io.BufferedReader; import java.io.IOException; -import java.io.InputStreamReader; -import java.io.OutputStream; -import java.net.URL; +import java.net.URI; +import java.net.http.HttpClient; +import java.net.http.HttpRequest; +import java.net.http.HttpRequest.BodyPublisher; +import java.net.http.HttpRequest.BodyPublishers; +import java.net.http.HttpResponse; import java.util.concurrent.CompletableFuture; -import java.util.concurrent.ExecutionException; -import java.util.concurrent.Future; -import java.util.concurrent.TimeUnit; -import java.util.concurrent.TimeoutException; import java.util.logging.Level; import java.util.logging.Logger; -import javax.net.ssl.HttpsURLConnection; - import com.clearblade.cloud.iot.v1.exception.ApplicationException; import com.clearblade.cloud.iot.v1.utils.AuthParams; import com.clearblade.cloud.iot.v1.utils.ConfigParameters; import com.clearblade.cloud.iot.v1.utils.Constants; -import com.clearblade.cloud.iot.v1.utils.SetHttpConnection; public class AsyncClient { @@ -27,99 +22,77 @@ public class AsyncClient { private ConfigParameters configParameters = ConfigParameters.getInstance(); private String[] responseArray = new String[3]; - private String apiName; - private String params; - private String body; private boolean isAdmin = false; /** * Method used to generate URL for apicall - * * @param apiName - path to api * @param params - parameters to be attached to request * @return URL formed and to be used */ private String generateURL(String apiName, String params) { - return AuthParams.getApiBaseURL() - .concat(configParameters.getEndpointPort()) - .concat(configParameters.getWebhook()) - .concat(AuthParams.getUserSystemKey()) - .concat(apiName) + return AuthParams.getApiBaseURL().concat(configParameters.getEndpointPort()) + .concat(configParameters.getWebhook()).concat(AuthParams.getUserSystemKey()).concat(apiName) .concat("?" + params); } /** * Method used to generate URL for apicall - * * @param apiName - path to api * @param params - parameters to be attached to request * @return URL formed and to be used */ private String generateAdminURL(String apiName, String params) { - return AuthParams.getBaseURL() - .concat(configParameters.getWebhook()) - .concat(AuthParams.getAdminSystemKey()) - .concat(apiName) - .concat("?" + params); + return AuthParams.getBaseURL().concat(configParameters.getWebhook()).concat(AuthParams.getAdminSystemKey()) + .concat(apiName).concat("?" + params); } /** * Method used to Calls HTTP Get request - * * @param apiName * @param params * @return String[] containing responseCode, responseMessage and response object * @throws IOException * @throws ApplicationException */ - private Object get() { + public String[] get(String apiName, String params) { String finalURL = ""; + String token = ""; try { if (isAdmin) { AuthParams.setAdminCredentials(); finalURL = generateAdminURL(apiName, params); + token = AuthParams.getAdminToken(); } else { AuthParams.setRegistryCredentials(); finalURL = generateURL(apiName, params); + token = AuthParams.getUserToken(); } - URL obj = new URL(finalURL); - SetHttpConnection setCon = new SetHttpConnection(); - HttpsURLConnection con = setCon.getConnection(obj); - if (isAdmin) - con.setRequestProperty(Constants.HTTP_REQUEST_PROPERTY_TOKEN_KEY, AuthParams.getAdminToken()); - else - con.setRequestProperty(Constants.HTTP_REQUEST_PROPERTY_TOKEN_KEY, AuthParams.getUserToken()); - con.setRequestProperty(Constants.HTTP_REQUEST_PROPERTY_CONTENT_TYPE_KEY, - Constants.HTTP_REQUEST_PROPERTY_CONTENT_TYPE_ACCEPT_VALUE); - con.addRequestProperty(Constants.HTTP_REQUEST_PROPERTY_ACCEPT_KEY, - Constants.HTTP_REQUEST_PROPERTY_CONTENT_TYPE_ACCEPT_VALUE); - con.setRequestMethod(Constants.HTTP_REQUEST_METHOD_TYPE_GET); - StringBuilder response = new StringBuilder(); - responseArray[0] = String.valueOf(con.getResponseCode()); - responseArray[1] = con.getResponseMessage(); - BufferedReader in = null; - if (con.getErrorStream() != null) { - in = new BufferedReader(new InputStreamReader(con.getErrorStream())); - } else if (con.getInputStream() != null) { - in = new BufferedReader(new InputStreamReader(con.getInputStream())); - } - String inputLine; - String responseMessage = ""; - if (in != null) { - while ((inputLine = in.readLine()) != null) { - response.append(inputLine); - } - responseMessage = response.toString(); - responseArray[2] = responseMessage; - } - } catch (ApplicationException | IOException e) { - log.log(Level.SEVERE, e.getMessage()); - } + HttpRequest request = HttpRequest.newBuilder().uri(URI.create(finalURL)) + .headers(Constants.HTTP_REQUEST_PROPERTY_CONTENT_TYPE_KEY, + Constants.HTTP_REQUEST_PROPERTY_CONTENT_TYPE_ACCEPT_VALUE, + Constants.HTTP_REQUEST_PROPERTY_TOKEN_KEY, token, + Constants.HTTP_REQUEST_PROPERTY_ACCEPT_KEY, + Constants.HTTP_REQUEST_PROPERTY_CONTENT_TYPE_ACCEPT_VALUE) + .GET().build(); + + CompletableFuture> response = HttpClient.newBuilder().build() + .sendAsync(request, HttpResponse.BodyHandlers.ofString()); + + HttpResponse httpResponse = response.get(); + responseArray[0] = String.valueOf(httpResponse.statusCode()); + responseArray[1] = ""; + responseArray[2] = httpResponse.body(); - catch (Exception e) { + } catch (ApplicationException | IOException e) { log.log(Level.SEVERE, e.getMessage()); + } catch (InterruptedException ex) { + log.log(Level.SEVERE, ex.getMessage()); + Thread.currentThread().interrupt(); + } catch (Exception ec) { + log.log(Level.SEVERE, ec.getMessage()); } return responseArray; @@ -127,7 +100,6 @@ private Object get() { /** * Method used to call HTTP Post request - * * @param apiName * @param params * @param body @@ -135,472 +107,162 @@ private Object get() { * @throws IOException * @throws ApplicationException */ - public Object post() { + public String[] post(String apiName, String params, String body) { String finalURL = ""; + String token = ""; try { if (isAdmin) { AuthParams.setAdminCredentials(); finalURL = generateAdminURL(apiName, params); + token = AuthParams.getAdminToken(); } else { AuthParams.setRegistryCredentials(); finalURL = generateURL(apiName, params); + token = AuthParams.getUserToken(); } - - URL obj = new URL(finalURL); - SetHttpConnection setCon = new SetHttpConnection(); - HttpsURLConnection con = setCon.getConnection(obj); - if (isAdmin) - con.setRequestProperty(Constants.HTTP_REQUEST_PROPERTY_TOKEN_KEY, - AuthParams.getAdminToken()); - else - con.setRequestProperty(Constants.HTTP_REQUEST_PROPERTY_TOKEN_KEY, - AuthParams.getUserToken()); - con.setRequestProperty(Constants.HTTP_REQUEST_PROPERTY_CONTENT_TYPE_KEY, - Constants.HTTP_REQUEST_PROPERTY_CONTENT_TYPE_ACCEPT_VALUE); - con.addRequestProperty(Constants.HTTP_REQUEST_PROPERTY_ACCEPT_KEY, - Constants.HTTP_REQUEST_PROPERTY_CONTENT_TYPE_ACCEPT_VALUE); - con.setRequestMethod(Constants.HTTP_REQUEST_METHOD_TYPE_POST); - con.setDoOutput(true); - StringBuilder response = new StringBuilder(); - OutputStream os = con.getOutputStream(); - byte[] input = body.getBytes(Constants.UTF8); - os.write(input, 0, input.length); - os.flush(); - responseArray[0] = String.valueOf(con.getResponseCode()); - responseArray[1] = con.getResponseMessage(); - BufferedReader in = null; - if (con.getErrorStream() != null) { - in = new BufferedReader(new InputStreamReader(con.getErrorStream())); - } else if (con.getInputStream() != null) { - in = new BufferedReader(new InputStreamReader(con.getInputStream())); - } - String inputLine; - String responseMessage = ""; - if (in != null) { - while ((inputLine = in.readLine()) != null) { - response.append(inputLine); - } - responseMessage = response.toString(); - responseArray[2] = responseMessage; - } + BodyPublisher jsonPayload = BodyPublishers.ofString(body); + HttpRequest request = HttpRequest.newBuilder() + .uri(URI.create(finalURL)) + .method(Constants.HTTP_REQUEST_METHOD_TYPE_POST, jsonPayload) + .headers(Constants.HTTP_REQUEST_PROPERTY_CONTENT_TYPE_KEY, Constants.HTTP_REQUEST_PROPERTY_CONTENT_TYPE_ACCEPT_VALUE, + Constants.HTTP_REQUEST_PROPERTY_TOKEN_KEY, token, + Constants.HTTP_REQUEST_PROPERTY_ACCEPT_KEY, Constants.HTTP_REQUEST_PROPERTY_CONTENT_TYPE_ACCEPT_VALUE) + .build(); + + CompletableFuture> response = HttpClient.newBuilder() + .build() + .sendAsync(request, HttpResponse.BodyHandlers.ofString()); + + HttpResponse httpResponse = response.get(); + responseArray[0] = String.valueOf(httpResponse.statusCode()); + responseArray[1] = ""; + responseArray[2] = httpResponse.body(); + } catch (ApplicationException | IOException e) { log.log(Level.SEVERE, e.getMessage()); - } catch (Exception e) { - log.log(Level.SEVERE, e.getMessage()); + } catch (InterruptedException ex) { + log.log(Level.SEVERE, ex.getMessage()); + Thread.currentThread().interrupt(); + }catch(Exception ec) { + log.log(Level.SEVERE, ec.getMessage()); } return responseArray; + } /** * Method used to call HTTP delete request - * * @param apiName * @param params * @return String[] containing responseCode, responseMessage and response object * @throws IOException * @throws ApplicationException */ - public Object delete() { + public String[] delete(String apiName, String params) { String finalURL = ""; + String token = ""; try { if (isAdmin) { AuthParams.setAdminCredentials(); finalURL = generateAdminURL(apiName, params); + token = AuthParams.getAdminToken(); } else { AuthParams.setRegistryCredentials(); finalURL = generateURL(apiName, params); + token = AuthParams.getUserToken(); } - URL obj = new URL(finalURL); - SetHttpConnection setCon = new SetHttpConnection(); - HttpsURLConnection con = setCon.getConnection(obj); - if (isAdmin) - con.setRequestProperty(Constants.HTTP_REQUEST_PROPERTY_TOKEN_KEY, - AuthParams.getAdminToken()); - else - con.setRequestProperty(Constants.HTTP_REQUEST_PROPERTY_TOKEN_KEY, - AuthParams.getUserToken()); - con.setRequestProperty(Constants.HTTP_REQUEST_PROPERTY_CONTENT_TYPE_KEY, - Constants.HTTP_REQUEST_PROPERTY_CONTENT_TYPE_ACCEPT_VALUE); - con.addRequestProperty(Constants.HTTP_REQUEST_PROPERTY_ACCEPT_KEY, - Constants.HTTP_REQUEST_PROPERTY_CONTENT_TYPE_ACCEPT_VALUE); - con.setRequestMethod(Constants.HTTP_REQUEST_METHOD_TYPE_DELETE); - StringBuilder response = new StringBuilder(); - responseArray[0] = String.valueOf(con.getResponseCode()); - responseArray[1] = con.getResponseMessage(); - BufferedReader in = null; - if (con.getErrorStream() != null) { - in = new BufferedReader(new InputStreamReader(con.getErrorStream())); - } else if (con.getInputStream() != null) { - in = new BufferedReader(new InputStreamReader(con.getInputStream())); - } - String inputLine; - String responseMessage = ""; - if (in != null) { - while ((inputLine = in.readLine()) != null) { - response.append(inputLine); - } - responseMessage = response.toString(); - responseArray[2] = responseMessage; - } + + HttpRequest request = HttpRequest.newBuilder() + .uri(URI.create(finalURL)) + .headers(Constants.HTTP_REQUEST_PROPERTY_CONTENT_TYPE_KEY, Constants.HTTP_REQUEST_PROPERTY_CONTENT_TYPE_ACCEPT_VALUE, + Constants.HTTP_REQUEST_PROPERTY_TOKEN_KEY, token, + Constants.HTTP_REQUEST_PROPERTY_ACCEPT_KEY, Constants.HTTP_REQUEST_PROPERTY_CONTENT_TYPE_ACCEPT_VALUE) + .DELETE() + .build(); + + CompletableFuture> response = HttpClient.newBuilder() + .build() + .sendAsync(request, HttpResponse.BodyHandlers.ofString()); + + HttpResponse httpResponse = response.get(); + responseArray[0] = String.valueOf(httpResponse.statusCode()); + responseArray[1] = ""; + responseArray[2] = httpResponse.body(); + } catch (ApplicationException | IOException e) { log.log(Level.SEVERE, e.getMessage()); - } catch (Exception e) { - log.log(Level.SEVERE, e.getMessage()); + } catch (InterruptedException ex) { + log.log(Level.SEVERE, ex.getMessage()); + Thread.currentThread().interrupt(); + }catch(Exception ec) { + log.log(Level.SEVERE, ec.getMessage()); } return responseArray; + } /** * Method used to call HTTP Patch request - * * @param apiName * @param params * @param body * @return String[] Object containing responseCode, responseMessage and response * object */ - public Object update() { + public String[] update(String apiName, String params, String body) { try { AuthParams.setRegistryCredentials(); String finalURL = generateURL(apiName, params); - URL obj = new URL(finalURL); - SetHttpConnection setCon = new SetHttpConnection(); - HttpsURLConnection con = setCon.getConnection(obj); - con.setRequestProperty(Constants.HTTP_REQUEST_PROPERTY_TOKEN_KEY, - AuthParams.getUserToken()); - con.setRequestProperty(Constants.HTTP_REQUEST_PROPERTY_CONTENT_TYPE_KEY, - Constants.HTTP_REQUEST_PROPERTY_CONTENT_TYPE_ACCEPT_VALUE); - con.addRequestProperty(Constants.HTTP_REQUEST_PROPERTY_ACCEPT_KEY, - Constants.HTTP_REQUEST_PROPERTY_CONTENT_TYPE_ACCEPT_VALUE); - con.setRequestMethod(Constants.HTTP_REQUEST_METHOD_TYPE_POST); - con.setRequestProperty("X-HTTP-Method-Override", Constants.HTTP_REQUEST_METHOD_TYPE_PATCH); - con.setDoOutput(true); - StringBuilder response = new StringBuilder(); - OutputStream os = con.getOutputStream(); - byte[] input = body.getBytes(Constants.UTF8); - os.write(input, 0, input.length); - os.flush(); - responseArray[0] = String.valueOf(con.getResponseCode()); - responseArray[1] = con.getResponseMessage(); - BufferedReader in = null; - if (con.getErrorStream() != null) { - in = new BufferedReader(new InputStreamReader(con.getErrorStream())); - } else if (con.getInputStream() != null) { - in = new BufferedReader(new InputStreamReader(con.getInputStream())); - } - String inputLine; - String responseMessage = ""; - if (in != null) { - while ((inputLine = in.readLine()) != null) { - response.append(inputLine); - } - responseMessage = response.toString(); - responseArray[2] = responseMessage; - } - } catch (ApplicationException | IOException e) { - log.log(Level.SEVERE, e.getMessage()); - } catch (Exception e) { - log.log(Level.SEVERE, e.getMessage()); - } - - return responseArray; - } - - private Future getDeviceAsync() { - return CompletableFuture.supplyAsync(this::get); - } - - public String[] asyncGetDevice(String apiName, String params) throws InterruptedException { - this.apiName = apiName; - this.params = params; - Future future = getDeviceAsync(); - try { - future.get(15000, TimeUnit.MILLISECONDS); - } catch (InterruptedException | ExecutionException | TimeoutException e) { - log.log(Level.SEVERE, e.getMessage()); - Thread.currentThread().interrupt(); - } - return responseArray; - } - - private Future createObjectAsync() { - return CompletableFuture.supplyAsync(this::post); - } - - public String[] asyncCreate(String apiName, String params, String body) throws InterruptedException { - this.apiName = apiName; - this.params = params; - this.body = body; - Future future = createObjectAsync(); - try { - future.get(15000, TimeUnit.MILLISECONDS); - } catch (InterruptedException | ExecutionException | TimeoutException e) { - log.log(Level.SEVERE, e.getMessage()); - Thread.currentThread().interrupt(); - } - return responseArray; - } - - private Future bindDeviceToGatewayObjectAsync() { - return CompletableFuture.supplyAsync(this::post); - } - - public String[] asyncBindDeviceToGateway(String apiName, String params, String body) throws InterruptedException { - this.apiName = apiName; - this.params = params; - this.body = body; - Future future = bindDeviceToGatewayObjectAsync(); - try { - future.get(15000, TimeUnit.MILLISECONDS); - } catch (InterruptedException | ExecutionException | TimeoutException e) { - log.log(Level.SEVERE, e.getMessage()); - Thread.currentThread().interrupt(); - } - return responseArray; - } - - private Future unBindDeviceFromGatewayObjectAsync() { - return CompletableFuture.supplyAsync(this::post); - } - - public String[] asyncUnbindDeviceFromGateway(String apiName, String params, String body) - throws InterruptedException { - this.apiName = apiName; - this.params = params; - this.body = body; - Future future = unBindDeviceFromGatewayObjectAsync(); - try { - future.get(15000, TimeUnit.MILLISECONDS); - } catch (InterruptedException | ExecutionException | TimeoutException e) { - log.log(Level.SEVERE, e.getMessage()); - Thread.currentThread().interrupt(); - } - return responseArray; - } - - private Future sendCommandToDeviceAsync() { - return CompletableFuture.supplyAsync(this::post); - } - - public String[] asyncSendCommandToDevice(String apiName, String params, String body) throws InterruptedException { - this.apiName = apiName; - this.params = params; - this.body = body; - Future future = sendCommandToDeviceAsync(); - try { - future.get(15000, TimeUnit.MILLISECONDS); - } catch (InterruptedException | ExecutionException | TimeoutException e) { - log.log(Level.SEVERE, e.getMessage()); - Thread.currentThread().interrupt(); - } - return responseArray; - } - - private Future modifyCloudToDeviceConfigAsync() { - return CompletableFuture.supplyAsync(this::post); - } - - public String[] asyncModifyCloudToDeviceConfig(String apiName, String params, String body) - throws InterruptedException { - this.apiName = apiName; - this.params = params; - this.body = body; - Future future = modifyCloudToDeviceConfigAsync(); - try { - future.get(15000, TimeUnit.MILLISECONDS); - } catch (InterruptedException | ExecutionException | TimeoutException e) { - log.log(Level.SEVERE, e.getMessage()); - Thread.currentThread().interrupt(); - } - return responseArray; - } - - private Future listDeviceStatesAsync() { - return CompletableFuture.supplyAsync(this::get); - } - - public String[] asyncListDeviceStates(String apiName, String params) - throws InterruptedException { - this.apiName = apiName; - this.params = params; - Future future = listDeviceStatesAsync(); - try { - future.get(15000, TimeUnit.MILLISECONDS); - } catch (InterruptedException | ExecutionException | TimeoutException e) { - log.log(Level.SEVERE, e.getMessage()); - Thread.currentThread().interrupt(); - } - return responseArray; - } + BodyPublisher jsonPayload = BodyPublishers.ofString(body); + HttpRequest request = HttpRequest.newBuilder().uri(URI.create(finalURL)) + .method(Constants.HTTP_REQUEST_METHOD_TYPE_PATCH, jsonPayload) + .headers(Constants.HTTP_REQUEST_PROPERTY_CONTENT_TYPE_KEY, + Constants.HTTP_REQUEST_PROPERTY_CONTENT_TYPE_ACCEPT_VALUE, + Constants.HTTP_REQUEST_PROPERTY_TOKEN_KEY, AuthParams.getUserToken(), + Constants.HTTP_REQUEST_PROPERTY_ACCEPT_KEY, + Constants.HTTP_REQUEST_PROPERTY_CONTENT_TYPE_ACCEPT_VALUE) + .build(); - private Future deleteObjectAsync() { - return CompletableFuture.supplyAsync(this::delete); - } + CompletableFuture> response = HttpClient.newBuilder().build().sendAsync(request, + HttpResponse.BodyHandlers.ofString()); - public String[] asyncDelete(String apiName, String params) throws InterruptedException { - this.apiName = apiName; - this.params = params; - Future future = deleteObjectAsync(); - try { - future.get(15000, TimeUnit.MILLISECONDS); - } catch (InterruptedException | ExecutionException | TimeoutException e) { - log.log(Level.SEVERE, e.getMessage()); - Thread.currentThread().interrupt(); - } - return responseArray; - } + HttpResponse httpResponse = response.get(); + responseArray[0] = String.valueOf(httpResponse.statusCode()); + responseArray[1] = ""; + responseArray[2] = httpResponse.body(); - private Future updateObjectAsync() { - return CompletableFuture.supplyAsync(this::update); - } - - public String[] asyncUpdate(String apiName, String params, String body) throws InterruptedException { - this.apiName = apiName; - this.params = params; - this.body = body; - Future future = updateObjectAsync(); - try { - future.get(15000, TimeUnit.MILLISECONDS); - } catch (InterruptedException | ExecutionException | TimeoutException e) { - log.log(Level.SEVERE, e.getMessage()); - Thread.currentThread().interrupt(); - } - return responseArray; - } - - private Future listObjectAsync() { - return CompletableFuture.supplyAsync(this::get); - } - - public String[] asyncListDevices(String apiName, String params) throws InterruptedException { - this.apiName = apiName; - this.params = params; - Future future = listObjectAsync(); - try { - future.get(15000, TimeUnit.MILLISECONDS); - } catch (InterruptedException | ExecutionException | TimeoutException e) { + } catch (ApplicationException | IOException e) { log.log(Level.SEVERE, e.getMessage()); + } catch (InterruptedException ex) { + log.log(Level.SEVERE, ex.getMessage()); Thread.currentThread().interrupt(); + } catch (Exception ec) { + log.log(Level.SEVERE, ec.getMessage()); } - return responseArray; - } - private Future listDeviceConfigVersionsAsync() { - return CompletableFuture.supplyAsync(this::get); - } - - public String[] asyncListDeviceConfigVersions(String apiName, String params) - throws InterruptedException { - this.apiName = apiName; - this.params = params; - Future future = listDeviceConfigVersionsAsync(); - try { - future.get(15000, TimeUnit.MILLISECONDS); - } catch (InterruptedException | ExecutionException | TimeoutException e) { - log.log(Level.SEVERE, e.getMessage()); - Thread.currentThread().interrupt(); - } return responseArray; } // Registry Apis - private Future getRegistryAsync() { - return CompletableFuture.supplyAsync(this::get); - } - - public String[] asyncGetRegistry(String apiName, String params) throws InterruptedException { - this.apiName = apiName; - this.params = params; - Future future = getRegistryAsync(); - try { - future.get(15000, TimeUnit.MILLISECONDS); - } catch (InterruptedException | ExecutionException | TimeoutException e) { - log.log(Level.SEVERE, e.getMessage()); - Thread.currentThread().interrupt(); - } - return responseArray; - } - - private Future createRegistryAsync() { - return CompletableFuture.supplyAsync(this::post); - } - - public String[] asyncCreateDeviceRegistry(String apiName, String params, String body, boolean isAdmin) - throws InterruptedException { - this.apiName = apiName; - this.params = params; - this.body = body; + public String[] asyncCreateDeviceRegistry(String apiName, String params, String body, boolean isAdmin) { this.isAdmin = isAdmin; - Future future = createRegistryAsync(); - try { - future.get(15000, TimeUnit.MILLISECONDS); - } catch (InterruptedException | ExecutionException | TimeoutException e) { - log.log(Level.SEVERE, e.getMessage()); - Thread.currentThread().interrupt(); - } - return responseArray; + return this.post(apiName, params, body); } - private Future updateRegistryAsync() { - return CompletableFuture.supplyAsync(this::update); - } - public String[] asyncUpdateDeviceRegistry(String apiName, String params, String body) - throws InterruptedException { - this.apiName = apiName; - this.params = params; - this.body = body; - Future future = updateRegistryAsync(); - try { - future.get(15000, TimeUnit.MILLISECONDS); - } catch (InterruptedException | ExecutionException | TimeoutException e) { - log.log(Level.SEVERE, e.getMessage()); - Thread.currentThread().interrupt(); - } - return responseArray; - } - - private Future deleteRegistryAsync() { - return CompletableFuture.supplyAsync(this::delete); - } - - public String[] asyncDeleteDeviceRegistry(String apiName, String params, String body, boolean isAdmin) - throws InterruptedException { - this.apiName = apiName; - this.params = params; - this.body = body; + public String[] asyncDeleteDeviceRegistry(String apiName, String params, boolean isAdmin){ this.isAdmin = isAdmin; - Future future = deleteRegistryAsync(); - try { - future.get(15000, TimeUnit.MILLISECONDS); - } catch (InterruptedException | ExecutionException | TimeoutException e) { - log.log(Level.SEVERE, e.getMessage()); - Thread.currentThread().interrupt(); - } - return responseArray; + return this.delete(apiName, params); } - private Future listDeviceRegistriesAsync() { - return CompletableFuture.supplyAsync(this::get); - } - public String[] asyncListDeviceRegistries(String apiName, String params, boolean isAdmin) - throws InterruptedException { - this.apiName = apiName; - this.params = params; + public String[] asyncListDeviceRegistries(String apiName, String params, boolean isAdmin) { this.isAdmin = isAdmin; - Future future = listDeviceRegistriesAsync(); - try { - future.get(15000, TimeUnit.MILLISECONDS); - } catch (InterruptedException | ExecutionException | TimeoutException e) { - log.log(Level.SEVERE, e.getMessage()); - Thread.currentThread().interrupt(); - } - return responseArray; + return this.get(apiName, params); } } diff --git a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/ClearBladeDeviceManager.java b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/ClearBladeDeviceManager.java index 5927c6fa..84b8d6e1 100644 --- a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/ClearBladeDeviceManager.java +++ b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/ClearBladeDeviceManager.java @@ -47,7 +47,7 @@ public Device getDevice(GetDeviceRequest request) { public Device asyncGetDevice(GetDeviceRequest request) { try { AsyncClient asyncClient = new AsyncClient(); - String[] responseArray = asyncClient.asyncGetDevice(configParameters.getDevicesURLExtension(), + String[] responseArray = asyncClient.get(configParameters.getDevicesURLExtension(), request.toString()); if (responseArray[0] != null) { int responseCode = Integer.parseInt(responseArray[0]); @@ -86,7 +86,7 @@ public Device asyncCreateDevice(CreateDeviceRequest request) { String[] params = request.getParams(); String reqParams = params[0]; String body = params[1]; - String[] responseArray = asyncClient.asyncCreate(configParameters.getDevicesURLExtension(), reqParams, + String[] responseArray = asyncClient.post(configParameters.getDevicesURLExtension(), reqParams, body); if (responseArray[0] != null) { int responseCode = Integer.parseInt(responseArray[0]); @@ -107,17 +107,23 @@ public void deleteDevice(DeleteDeviceRequest request) { String[] responseArray = syncClient.delete(configParameters.getDevicesURLExtension(), request.toString(), false); if (responseArray[0] != null) { - log.log(Level.INFO, "Response code " + responseArray[0] + " received with message" + responseArray[2]); + System.out.println("DeleteDevice execution successful"); + log.log(Level.INFO, ()-> "Response code " + responseArray[0] + " received with message" + responseArray[2]); + }else { + System.out.println("DeleteDevice execution failed"); } } public void asyncDeleteDevice(DeleteDeviceRequest request) { try { AsyncClient asyncClient = new AsyncClient(); - String[] responseArray = asyncClient.asyncDelete(configParameters.getDevicesURLExtension(), + String[] responseArray = asyncClient.delete(configParameters.getDevicesURLExtension(), request.toString()); - if (responseArray[0] != null) { - log.log(Level.INFO, "Response code " + responseArray[0] + " received with message" + responseArray[2]); + if(responseArray[0] != null) { + System.out.println("DeleteDevice execution successful"); + log.log(Level.INFO, ()-> "Response code " + responseArray[0] + " received with message" + responseArray[2]); + }else { + System.out.println("DeleteDevice execution failed"); } } catch (Exception e) { @@ -126,11 +132,13 @@ public void asyncDeleteDevice(DeleteDeviceRequest request) { } public Device updateDevice(UpdateDeviceRequest request) { + try { SyncClient syncClient = new SyncClient(); String[] params = request.getBodyAndParams(); String reqParams = params[0]; String body = params[1]; - String[] responseArray = syncClient.update(configParameters.getDevicesURLExtension(), reqParams, body); + String[] responseArray; + responseArray = syncClient.update(configParameters.getDevicesURLExtension(), reqParams, body); if (responseArray[0] != null) { int responseCode = Integer.parseInt(responseArray[0]); if (responseCode == 200) { @@ -139,6 +147,10 @@ public Device updateDevice(UpdateDeviceRequest request) { return deviceObj; } } + } catch (InterruptedException e) { + log.log(Level.SEVERE, e.getMessage()); + Thread.currentThread().interrupt(); + } return null; } @@ -148,7 +160,7 @@ public Device asyncUpdateDevice(UpdateDeviceRequest request) { String[] params = request.getBodyAndParams(); String reqParams = params[0]; String body = params[1]; - String[] responseArray = asyncClient.asyncUpdate(configParameters.getDevicesURLExtension(), reqParams, + String[] responseArray = asyncClient.update(configParameters.getDevicesURLExtension(), reqParams, body); if (responseArray[0] != null) { int responseCode = Integer.parseInt(responseArray[0]); @@ -181,7 +193,7 @@ public BindDeviceToGatewayResponse asyncBindDeviceToGateway(BindDeviceToGatewayR try { AsyncClient asyncClient = new AsyncClient(); String[] paramBody = request.getBodyAndParams(); - String[] responseArray = asyncClient.asyncBindDeviceToGateway(configParameters.getCloudiotURLExtension(), + String[] responseArray = asyncClient.post(configParameters.getCloudiotURLExtension(), paramBody[0], paramBody[1]); BindDeviceToGatewayResponse response = BindDeviceToGatewayResponse.Builder.newBuilder().build(); if (responseArray[0] != null) { @@ -212,7 +224,7 @@ public UnbindDeviceFromGatewayResponse asyncUnbindDeviceFromGateway(UnbindDevice try { AsyncClient asyncClinet = new AsyncClient(); String[] paramBody = request.getBodyAndParams(); - String[] responseArray = asyncClinet.asyncUnbindDeviceFromGateway( + String[] responseArray = asyncClinet.post( configParameters.getCloudiotURLExtension(), paramBody[0], paramBody[1]); UnbindDeviceFromGatewayResponse response = UnbindDeviceFromGatewayResponse.Builder.newBuilder().build(); if (responseArray[0] != null) { @@ -243,7 +255,7 @@ public SendCommandToDeviceResponse asyncSendCommandToDevice(SendCommandToDeviceR try { AsyncClient asyncClient = new AsyncClient(); String[] paramBody = request.getBodyAndParams(); - String[] responseArray = asyncClient.asyncSendCommandToDevice(configParameters.getDevicesURLExtension(), + String[] responseArray = asyncClient.post(configParameters.getDevicesURLExtension(), paramBody[0], paramBody[1]); SendCommandToDeviceResponse response = SendCommandToDeviceResponse.Builder.newBuilder().build(); @@ -265,10 +277,7 @@ public DevicesListResponse listDevices(DevicesListRequest request) { if (responseArray[0] != null) { int responseCode = Integer.parseInt(responseArray[0]); if (responseCode == 200) { - DevicesListResponse devicesListResponse = DevicesListResponse.Builder.newBuilder() - .buildResponse(responseArray[2]).build(); - // deviceObj.loadFromString(responseArray[2]); - return devicesListResponse; + return DevicesListResponse.Builder.newBuilder().buildResponse(responseArray[2]).build(); } } return null; @@ -277,15 +286,12 @@ public DevicesListResponse listDevices(DevicesListRequest request) { public DevicesListResponse asyncListDevices(DevicesListRequest request) { try { AsyncClient asyncClient = new AsyncClient(); - String[] responseArray = asyncClient.asyncListDevices(configParameters.getDevicesURLExtension(), + String[] responseArray = asyncClient.get(configParameters.getDevicesURLExtension(), request.getParamsForList()); if (responseArray[0] != null) { int responseCode = Integer.parseInt(responseArray[0]); if (responseCode == 200) { - DevicesListResponse devicesListResponse = DevicesListResponse.Builder.newBuilder() - .buildResponse(responseArray[2]).build(); - // deviceObj.loadFromString(responseArray[2]); - return devicesListResponse; + return DevicesListResponse.Builder.newBuilder().buildResponse(responseArray[2]).build(); } } } catch (Exception e) { @@ -311,7 +317,7 @@ public DeviceConfig asyncModifyCloudToDeviceConfig(ModifyCloudToDeviceConfigRequ try { AsyncClient asyncClient = new AsyncClient(); String[] paramBody = request.getBodyAndParams(); - String[] responseArray = asyncClient.asyncModifyCloudToDeviceConfig( + String[] responseArray = asyncClient.post( configParameters.getDevicesURLExtension(), paramBody[0], paramBody[1]); DeviceConfig deviceConfig = DeviceConfig.newBuilder().build(); @@ -333,10 +339,7 @@ public ListDeviceStatesResponse listDeviceStates(ListDeviceStatesRequest request if (responseArray[0] != null) { int responseCode = Integer.parseInt(responseArray[0]); if (responseCode == 200) { - ListDeviceStatesResponse listDeviceStatesResponse = ListDeviceStatesResponse.Builder.newBuilder() - .buildResponse(responseArray[2]).build(); - // deviceObj.loadFromString(responseArray[2]); - return listDeviceStatesResponse; + return ListDeviceStatesResponse.Builder.newBuilder().buildResponse(responseArray[2]).build(); } } return null; @@ -345,15 +348,12 @@ public ListDeviceStatesResponse listDeviceStates(ListDeviceStatesRequest request public ListDeviceStatesResponse asyncListDeviceStates(ListDeviceStatesRequest request) { try { AsyncClient asyncClient = new AsyncClient(); - String[] responseArray = asyncClient.asyncListDeviceStates(configParameters.getDevicesStatesURLExtension(), + String[] responseArray = asyncClient.get(configParameters.getDevicesStatesURLExtension(), request.getParamsForList()); if (responseArray[0] != null) { int responseCode = Integer.parseInt(responseArray[0]); if (responseCode == 200) { - ListDeviceStatesResponse listDeviceStatesResponse = ListDeviceStatesResponse.Builder.newBuilder() - .buildResponse(responseArray[2]).build(); - // deviceObj.loadFromString(responseArray[2]); - return listDeviceStatesResponse; + return ListDeviceStatesResponse.Builder.newBuilder().buildResponse(responseArray[2]).build(); } } } catch (Exception e) { @@ -369,11 +369,7 @@ public ListDeviceConfigVersionsResponse listDeviceConfigVersions(ListDeviceConfi if (responseArray[0] != null) { int responseCode = Integer.parseInt(responseArray[0]); if (responseCode == 200) { - ListDeviceConfigVersionsResponse listDeviceConfigVersionsResponse = ListDeviceConfigVersionsResponse.Builder - .newBuilder() - .buildResponse(responseArray[2]).build(); - // deviceObj.loadFromString(responseArray[2]); - return listDeviceConfigVersionsResponse; + return ListDeviceConfigVersionsResponse.Builder.newBuilder().buildResponse(responseArray[2]).build(); } } return null; @@ -382,17 +378,13 @@ public ListDeviceConfigVersionsResponse listDeviceConfigVersions(ListDeviceConfi public ListDeviceConfigVersionsResponse asyncListDeviceConfigVersions(ListDeviceConfigVersionsRequest request) { try { AsyncClient asyncClient = new AsyncClient(); - String[] responseArray = asyncClient.asyncListDeviceConfigVersions( + String[] responseArray = asyncClient.get( configParameters.getCloudiotConfigURLExtension(), request.getParamsForList()); if (responseArray[0] != null) { int responseCode = Integer.parseInt(responseArray[0]); if (responseCode == 200) { - ListDeviceConfigVersionsResponse listDeviceConfigVersionsResponse = ListDeviceConfigVersionsResponse.Builder - .newBuilder() - .buildResponse(responseArray[2]).build(); - // deviceObj.loadFromString(responseArray[2]); - return listDeviceConfigVersionsResponse; + return ListDeviceConfigVersionsResponse.Builder.newBuilder().buildResponse(responseArray[2]).build(); } } } catch (Exception e) { @@ -408,31 +400,21 @@ public ListDeviceRegistriesResponse listDeviceRegistries(ListDeviceRegistriesReq if (responseArray[0] != null) { int responseCode = Integer.parseInt(responseArray[0]); if (responseCode == 200) { - ListDeviceRegistriesResponse deviceRegistriesListResponse = ListDeviceRegistriesResponse.Builder - .newBuilder() - .buildResponse(responseArray[2]).build(); - return deviceRegistriesListResponse; + return ListDeviceRegistriesResponse.Builder.newBuilder().buildResponse(responseArray[2]).build(); } } return null; } public ListDeviceRegistriesResponse asyncListDeviceRegistries(ListDeviceRegistriesRequest request) { - try { - AsyncClient asyncClient = new AsyncClient(); - String[] responseArray = asyncClient.asyncListDeviceRegistries(configParameters.getCloudiotURLExtension(), - request.getParamsForList(), true); - if (responseArray[0] != null) { - int responseCode = Integer.parseInt(responseArray[0]); - if (responseCode == 200) { - ListDeviceRegistriesResponse deviceRegistriesListResponse = ListDeviceRegistriesResponse.Builder - .newBuilder() - .buildResponse(responseArray[2]).build(); - return deviceRegistriesListResponse; - } + AsyncClient asyncClient = new AsyncClient(); + String[] responseArray = asyncClient.asyncListDeviceRegistries(configParameters.getCloudiotURLExtension(), + request.getParamsForList(), true); + if (responseArray[0] != null) { + int responseCode = Integer.parseInt(responseArray[0]); + if (responseCode == 200) { + return ListDeviceRegistriesResponse.Builder.newBuilder().buildResponse(responseArray[2]).build(); } - } catch (Exception e) { - log.log(Level.SEVERE, e.getMessage()); } return null; } diff --git a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/ClearBladeRegistryManager.java b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/ClearBladeRegistryManager.java index bdf37658..9de19f14 100644 --- a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/ClearBladeRegistryManager.java +++ b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/ClearBladeRegistryManager.java @@ -31,7 +31,7 @@ public DeviceRegistry getRegistry(GetDeviceRegistryRequest request) { public DeviceRegistry asyncGetDeviceRegistry(GetDeviceRegistryRequest request) { try { AsyncClient asyncClient = new AsyncClient(); - String[] responseArray = asyncClient.asyncGetRegistry(configParameters.getCloudiotURLExtension(), + String[] responseArray = asyncClient.get(configParameters.getCloudiotURLExtension(), request.toString()); if (responseArray[0] != null) { int responseCode = Integer.parseInt(responseArray[0]); @@ -87,18 +87,23 @@ public DeviceRegistry asyncCreateDeviceRegistry(CreateDeviceRegistryRequest requ } public DeviceRegistry updateDeviceRegistry(UpdateDeviceRegistryRequest request) { + try { SyncClient syncClient = new SyncClient(); - String[] bodyParams = request.getBodyAndParams(); - - String[] responseArray = syncClient.update(configParameters.getCloudiotURLExtension(), bodyParams[0], - bodyParams[1]); - if (responseArray[0] != null) { - int responseCode = Integer.parseInt(responseArray[0]); - if (responseCode == 200) { - DeviceRegistry deviceRegistry = DeviceRegistry.newBuilder().build(); - deviceRegistry.loadFromString(responseArray[2]); - return deviceRegistry; + String[] bodyParams = request.getBodyAndParams(); + + String[] responseArray = syncClient.update(configParameters.getCloudiotURLExtension(), bodyParams[0], + bodyParams[1]); + if (responseArray[0] != null) { + int responseCode = Integer.parseInt(responseArray[0]); + if (responseCode == 200) { + DeviceRegistry deviceRegistry = DeviceRegistry.newBuilder().build(); + deviceRegistry.loadFromString(responseArray[2]); + return deviceRegistry; + } } + }catch(InterruptedException e) { + log.log(Level.SEVERE, e.getMessage()); + Thread.currentThread().interrupt(); } return null; } @@ -108,7 +113,7 @@ public DeviceRegistry asyncUpdateDeviceRegistry(UpdateDeviceRegistryRequest requ AsyncClient asyncClient = new AsyncClient(); String[] bodyParams = request.getBodyAndParams(); - String[] responseArray = asyncClient.asyncUpdateDeviceRegistry(configParameters.getCloudiotURLExtension(), + String[] responseArray = asyncClient.update(configParameters.getCloudiotURLExtension(), bodyParams[0], bodyParams[1]); if (responseArray[0] != null) { @@ -131,7 +136,7 @@ public void deleteDeviceRegistry(DeleteDeviceRegistryRequest request) { String[] responseArray = syncClient.delete(configParameters.getCloudiotURLExtension(), bodyParams, true); if (responseArray[0] != null) { - log.log(Level.INFO, "Response code " + responseArray[0] + " received with message" + responseArray[2]); + log.log(Level.INFO, ()->"Response code " + responseArray[0] + " received with message" + responseArray[2]); } } @@ -141,11 +146,12 @@ public void asyncDeleteDeviceRegistry(DeleteDeviceRegistryRequest request) { AsyncClient asyncClient = new AsyncClient(); String bodyParams = request.getParams(); - String[] responseArray = asyncClient.asyncDeleteDeviceRegistry(configParameters.getCloudiotURLExtension(), - bodyParams, - "", true); + String[] responseArray = asyncClient.asyncDeleteDeviceRegistry(configParameters.getCloudiotURLExtension(), bodyParams, true); if (responseArray[0] != null) { - log.log(Level.INFO, "Response code " + responseArray[0] + " received with message" + responseArray[2]); + System.out.println("DeleteDeviceRegistry execution successful"); + log.log(Level.INFO, ()->"Response code " + responseArray[0] + " received with message" + responseArray[2]); + }else { + System.out.println("DeleteDeviceRegistry execution failed"); } } catch (Exception e) { diff --git a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/SyncClient.java b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/SyncClient.java index 7e772762..8f6e0897 100644 --- a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/SyncClient.java +++ b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/SyncClient.java @@ -1,20 +1,21 @@ package com.clearblade.cloud.iot.v1; -import java.io.BufferedReader; import java.io.IOException; -import java.io.InputStreamReader; -import java.io.OutputStream; -import java.net.URL; +import java.net.ProxySelector; +import java.net.URI; +import java.net.http.HttpClient; +import java.net.http.HttpRequest; +import java.net.http.HttpRequest.BodyPublisher; +import java.net.http.HttpRequest.BodyPublishers; +import java.net.http.HttpResponse; +import java.net.http.HttpResponse.BodyHandlers; import java.util.logging.Level; import java.util.logging.Logger; -import javax.net.ssl.HttpsURLConnection; - import com.clearblade.cloud.iot.v1.exception.ApplicationException; import com.clearblade.cloud.iot.v1.utils.AuthParams; import com.clearblade.cloud.iot.v1.utils.ConfigParameters; import com.clearblade.cloud.iot.v1.utils.Constants; -import com.clearblade.cloud.iot.v1.utils.SetHttpConnection; public class SyncClient { @@ -24,7 +25,6 @@ public class SyncClient { /** * Method used to generate URL for apicall - * * @param apiName - path to api * @param params - parameters to be attached to request * @return URL formed and to be used @@ -56,7 +56,6 @@ private String generateAdminURL(String apiName, String params) { /** * Method used to Calls HTTP Get request - * * @param apiName * @param params * @return String[] containing responseCode, responseMessage and response object @@ -66,51 +65,42 @@ private String generateAdminURL(String apiName, String params) { public String[] get(String apiName, String params, boolean isAdmin) { String[] responseArray = new String[3]; String finalURL = ""; + String token = ""; try { if (isAdmin) { AuthParams.setAdminCredentials(); finalURL = generateAdminURL(apiName, params); + token = AuthParams.getAdminToken(); } else { AuthParams.setRegistryCredentials(); finalURL = generateURL(apiName, params); + token = AuthParams.getUserToken(); } - URL obj = new URL(finalURL); - SetHttpConnection setCon = new SetHttpConnection(); - HttpsURLConnection con = setCon.getConnection(obj); - if (isAdmin) - con.setRequestProperty(Constants.HTTP_REQUEST_PROPERTY_TOKEN_KEY, AuthParams.getAdminToken()); - else - con.setRequestProperty(Constants.HTTP_REQUEST_PROPERTY_TOKEN_KEY, AuthParams.getUserToken()); - con.setRequestProperty(Constants.HTTP_REQUEST_PROPERTY_CONTENT_TYPE_KEY, - Constants.HTTP_REQUEST_PROPERTY_CONTENT_TYPE_ACCEPT_VALUE); - con.addRequestProperty(Constants.HTTP_REQUEST_PROPERTY_ACCEPT_KEY, - Constants.HTTP_REQUEST_PROPERTY_CONTENT_TYPE_ACCEPT_VALUE); - con.setRequestMethod(Constants.HTTP_REQUEST_METHOD_TYPE_GET); - StringBuilder response = new StringBuilder(); - responseArray[0] = String.valueOf(con.getResponseCode()); - responseArray[1] = con.getResponseMessage(); - BufferedReader in = null; - if (con.getErrorStream() != null) { - in = new BufferedReader(new InputStreamReader(con.getErrorStream())); - } else if (con.getInputStream() != null) { - in = new BufferedReader(new InputStreamReader(con.getInputStream())); - } - String inputLine; - String responseMessage = ""; - if (in != null) { - while ((inputLine = in.readLine()) != null) { - response.append(inputLine); - } - responseMessage = response.toString(); - responseArray[2] = responseMessage; - } - } catch (ApplicationException | IOException e) { - log.log(Level.SEVERE, e.getMessage()); - } + HttpRequest request = HttpRequest.newBuilder() + .uri(URI.create(finalURL)) + .headers(Constants.HTTP_REQUEST_PROPERTY_CONTENT_TYPE_KEY, Constants.HTTP_REQUEST_PROPERTY_CONTENT_TYPE_ACCEPT_VALUE, + Constants.HTTP_REQUEST_PROPERTY_TOKEN_KEY, token, + Constants.HTTP_REQUEST_PROPERTY_ACCEPT_KEY, Constants.HTTP_REQUEST_PROPERTY_CONTENT_TYPE_ACCEPT_VALUE) + .GET() + .build(); - catch (Exception e) { + HttpResponse response = HttpClient + .newBuilder() + .proxy(ProxySelector.getDefault()) + .build() + .send(request, BodyHandlers.ofString()); + + responseArray[0] = String.valueOf(response.statusCode()); + responseArray[1] = ""; + responseArray[2] = response.body(); + + + } catch (InterruptedException e) { log.log(Level.SEVERE, e.getMessage()); + Thread.currentThread().interrupt(); + }catch(Exception ex) { + log.log(Level.SEVERE, ex.getMessage()); } return responseArray; @@ -118,7 +108,6 @@ public String[] get(String apiName, String params, boolean isAdmin) { /** * Method used to call HTTP Post request - * * @param apiName * @param params * @param body @@ -129,57 +118,44 @@ public String[] get(String apiName, String params, boolean isAdmin) { public String[] post(String apiName, String params, String body, boolean isAdmin) { String[] responseArray = new String[3]; String finalURL = ""; + String token = ""; try { if (isAdmin) { AuthParams.setAdminCredentials(); finalURL = generateAdminURL(apiName, params); + token = AuthParams.getAdminToken(); } else { AuthParams.setRegistryCredentials(); finalURL = generateURL(apiName, params); + token = AuthParams.getUserToken(); } - URL obj = new URL(finalURL); - SetHttpConnection setCon = new SetHttpConnection(); - HttpsURLConnection con = setCon.getConnection(obj); - if (isAdmin) - con.setRequestProperty(Constants.HTTP_REQUEST_PROPERTY_TOKEN_KEY, - AuthParams.getAdminToken()); - else - con.setRequestProperty(Constants.HTTP_REQUEST_PROPERTY_TOKEN_KEY, - AuthParams.getUserToken()); - con.setRequestProperty(Constants.HTTP_REQUEST_PROPERTY_CONTENT_TYPE_KEY, - Constants.HTTP_REQUEST_PROPERTY_CONTENT_TYPE_ACCEPT_VALUE); - con.addRequestProperty(Constants.HTTP_REQUEST_PROPERTY_ACCEPT_KEY, - Constants.HTTP_REQUEST_PROPERTY_CONTENT_TYPE_ACCEPT_VALUE); - con.setRequestMethod(Constants.HTTP_REQUEST_METHOD_TYPE_POST); - con.setDoOutput(true); - StringBuilder response = new StringBuilder(); - OutputStream os = con.getOutputStream(); - byte[] input = body.getBytes(Constants.UTF8); - os.write(input, 0, input.length); - os.flush(); - responseArray[0] = String.valueOf(con.getResponseCode()); - responseArray[1] = con.getResponseMessage(); - BufferedReader in = null; - if (con.getErrorStream() != null) { - in = new BufferedReader(new InputStreamReader(con.getErrorStream())); - } else if (con.getInputStream() != null) { - in = new BufferedReader(new InputStreamReader(con.getInputStream())); - } - String inputLine; - String responseMessage = ""; - if (in != null) { - while ((inputLine = in.readLine()) != null) { - response.append(inputLine); - } - responseMessage = response.toString(); - responseArray[2] = responseMessage; - } + BodyPublisher jsonPayload = BodyPublishers.ofString(body); + HttpRequest request = HttpRequest.newBuilder() + .uri(URI.create(finalURL)) + .method(Constants.HTTP_REQUEST_METHOD_TYPE_POST, jsonPayload) + .headers(Constants.HTTP_REQUEST_PROPERTY_CONTENT_TYPE_KEY, Constants.HTTP_REQUEST_PROPERTY_CONTENT_TYPE_ACCEPT_VALUE, + Constants.HTTP_REQUEST_PROPERTY_TOKEN_KEY, token, + Constants.HTTP_REQUEST_PROPERTY_ACCEPT_KEY, Constants.HTTP_REQUEST_PROPERTY_CONTENT_TYPE_ACCEPT_VALUE) + .build(); + HttpResponse response = HttpClient + .newBuilder() + .proxy(ProxySelector.getDefault()) + .build() + .send(request, BodyHandlers.ofString()); + + responseArray[0] = String.valueOf(response.statusCode()); + responseArray[1] = ""; + responseArray[2] = response.body(); + } catch (ApplicationException | IOException e) { log.log(Level.SEVERE, e.getMessage()); - } catch (Exception e) { - log.log(Level.SEVERE, e.getMessage()); + } catch (InterruptedException ex) { + log.log(Level.SEVERE, ex.getMessage()); + Thread.currentThread().interrupt(); + }catch(Exception ec) { + log.log(Level.SEVERE, ec.getMessage()); } return responseArray; @@ -187,7 +163,6 @@ public String[] post(String apiName, String params, String body, boolean isAdmin /** * Method used to call HTTP delete request - * * @param apiName * @param params * @return String[] containing responseCode, responseMessage and response object @@ -197,50 +172,41 @@ public String[] post(String apiName, String params, String body, boolean isAdmin public String[] delete(String apiName, String params, boolean isAdmin) { String[] responseArray = new String[3]; String finalURL = ""; + String token = ""; try { if (isAdmin) { AuthParams.setAdminCredentials(); finalURL = generateAdminURL(apiName, params); + token = AuthParams.getAdminToken(); } else { AuthParams.setRegistryCredentials(); finalURL = generateURL(apiName, params); + token = AuthParams.getUserToken(); } - URL obj = new URL(finalURL); - SetHttpConnection setCon = new SetHttpConnection(); - HttpsURLConnection con = setCon.getConnection(obj); - if (isAdmin) - con.setRequestProperty(Constants.HTTP_REQUEST_PROPERTY_TOKEN_KEY, - AuthParams.getAdminToken()); - else - con.setRequestProperty(Constants.HTTP_REQUEST_PROPERTY_TOKEN_KEY, - AuthParams.getUserToken()); - con.setRequestProperty(Constants.HTTP_REQUEST_PROPERTY_CONTENT_TYPE_KEY, - Constants.HTTP_REQUEST_PROPERTY_CONTENT_TYPE_ACCEPT_VALUE); - con.addRequestProperty(Constants.HTTP_REQUEST_PROPERTY_ACCEPT_KEY, - Constants.HTTP_REQUEST_PROPERTY_CONTENT_TYPE_ACCEPT_VALUE); - con.setRequestMethod(Constants.HTTP_REQUEST_METHOD_TYPE_DELETE); - StringBuilder response = new StringBuilder(); - responseArray[0] = String.valueOf(con.getResponseCode()); - responseArray[1] = con.getResponseMessage(); - BufferedReader in = null; - if (con.getErrorStream() != null) { - in = new BufferedReader(new InputStreamReader(con.getErrorStream())); - } else if (con.getInputStream() != null) { - in = new BufferedReader(new InputStreamReader(con.getInputStream())); - } - String inputLine; - String responseMessage = ""; - if (in != null) { - while ((inputLine = in.readLine()) != null) { - response.append(inputLine); - } - responseMessage = response.toString(); - responseArray[2] = responseMessage; - } - } catch (ApplicationException | IOException e) { - log.log(Level.SEVERE, e.getMessage()); - } catch (Exception e) { + HttpRequest request = HttpRequest.newBuilder() + .uri(URI.create(finalURL)) + .headers(Constants.HTTP_REQUEST_PROPERTY_CONTENT_TYPE_KEY, Constants.HTTP_REQUEST_PROPERTY_CONTENT_TYPE_ACCEPT_VALUE, + Constants.HTTP_REQUEST_PROPERTY_TOKEN_KEY, token, + Constants.HTTP_REQUEST_PROPERTY_ACCEPT_KEY, Constants.HTTP_REQUEST_PROPERTY_CONTENT_TYPE_ACCEPT_VALUE) + .DELETE() + .build(); + + HttpResponse response = HttpClient + .newBuilder() + .proxy(ProxySelector.getDefault()) + .build() + .send(request, BodyHandlers.ofString()); + + responseArray[0] = String.valueOf(response.statusCode()); + responseArray[1] = ""; + responseArray[2] = response.body(); + + + } catch (InterruptedException e) { log.log(Level.SEVERE, e.getMessage()); + Thread.currentThread().interrupt(); + }catch(Exception ex) { + log.log(Level.SEVERE, ex.getMessage()); } return responseArray; @@ -248,56 +214,43 @@ public String[] delete(String apiName, String params, boolean isAdmin) { /** * Method used to call HTTP Patch request - * * @param apiName * @param params * @param body * @return String[] containing responseCode, responseMessage and response object */ - public String[] update(String apiName, String params, String body) { + public String[] update(String apiName, String params, String body) throws InterruptedException{ String[] responseArray = new String[3]; try { AuthParams.setRegistryCredentials(); String finalURL = generateURL(apiName, params); - URL obj = new URL(finalURL); - SetHttpConnection setCon = new SetHttpConnection(); - HttpsURLConnection con = setCon.getConnection(obj); - con.setRequestProperty(Constants.HTTP_REQUEST_PROPERTY_TOKEN_KEY, AuthParams.getUserToken()); - con.setRequestProperty(Constants.HTTP_REQUEST_PROPERTY_CONTENT_TYPE_KEY, - Constants.HTTP_REQUEST_PROPERTY_CONTENT_TYPE_ACCEPT_VALUE); - con.addRequestProperty(Constants.HTTP_REQUEST_PROPERTY_ACCEPT_KEY, - Constants.HTTP_REQUEST_PROPERTY_CONTENT_TYPE_ACCEPT_VALUE); - con.setRequestMethod(Constants.HTTP_REQUEST_METHOD_TYPE_POST); - con.setRequestProperty("X-HTTP-Method-Override", Constants.HTTP_REQUEST_METHOD_TYPE_PATCH); - con.setDoOutput(true); - StringBuilder response = new StringBuilder(); - OutputStream os = con.getOutputStream(); - byte[] input = body.getBytes(Constants.UTF8); - os.write(input, 0, input.length); - os.flush(); - responseArray[0] = String.valueOf(con.getResponseCode()); - responseArray[1] = con.getResponseMessage(); - BufferedReader in = null; - if (con.getErrorStream() != null) { - in = new BufferedReader(new InputStreamReader(con.getErrorStream())); - } else if (con.getInputStream() != null) { - in = new BufferedReader(new InputStreamReader(con.getInputStream())); - } - String inputLine; - String responseMessage = ""; - if (in != null) { - while ((inputLine = in.readLine()) != null) { - response.append(inputLine); - } - responseMessage = response.toString(); - responseArray[2] = responseMessage; - } - } catch (ApplicationException | IOException e) { - log.log(Level.SEVERE, e.getMessage()); - } catch (Exception e) { + + BodyPublisher jsonPayload = BodyPublishers.ofString(body); + HttpRequest request = HttpRequest.newBuilder() + .uri(URI.create(finalURL)) + .method(Constants.HTTP_REQUEST_METHOD_TYPE_PATCH, jsonPayload) + .headers(Constants.HTTP_REQUEST_PROPERTY_CONTENT_TYPE_KEY, + Constants.HTTP_REQUEST_PROPERTY_CONTENT_TYPE_ACCEPT_VALUE, + Constants.HTTP_REQUEST_PROPERTY_TOKEN_KEY, AuthParams.getUserToken(),Constants.HTTP_REQUEST_PROPERTY_ACCEPT_KEY, + Constants.HTTP_REQUEST_PROPERTY_CONTENT_TYPE_ACCEPT_VALUE ) + .build(); + + HttpResponse response = HttpClient + .newBuilder() + .proxy(ProxySelector.getDefault()) + .build() + .send(request, BodyHandlers.ofString()); + + responseArray[0] = String.valueOf(response.statusCode()); + responseArray[1] = ""; + responseArray[2] = response.body(); + + } catch (InterruptedException e) { log.log(Level.SEVERE, e.getMessage()); + Thread.currentThread().interrupt(); + }catch(Exception ex) { + log.log(Level.SEVERE, ex.getMessage()); } - return responseArray; } } diff --git a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/exception/ApplicationException.java b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/exception/ApplicationException.java index 68e79f6c..79f6252e 100644 --- a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/exception/ApplicationException.java +++ b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/exception/ApplicationException.java @@ -1,7 +1,12 @@ package com.clearblade.cloud.iot.v1.exception; public class ApplicationException extends Exception { - public ApplicationException(String errorMessage) { + /** + * + */ + private static final long serialVersionUID = 1L; + + public ApplicationException(String errorMessage) { super(errorMessage); } } diff --git a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/registrytypes/DeviceRegistry.java b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/registrytypes/DeviceRegistry.java index 9ef3875d..8056dcd1 100644 --- a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/registrytypes/DeviceRegistry.java +++ b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/registrytypes/DeviceRegistry.java @@ -31,7 +31,7 @@ public DeviceRegistry() { name = ""; eventNotificationConfigs = new ArrayList<>(); stateNotificationConfig = null; - mqttConfig = MqttConfig.newBuilder().build(); + mqttConfig = null; httpConfig = null; logLevel = null; credentials = new ArrayList<>(); @@ -331,5 +331,4 @@ public void loadFromString(String inputStr) { log.log(Level.SEVERE, e.getMessage()); } } - } diff --git a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/utils/AuthParams.java b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/utils/AuthParams.java index 5d063d7e..98c13f52 100644 --- a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/utils/AuthParams.java +++ b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/utils/AuthParams.java @@ -1,17 +1,19 @@ package com.clearblade.cloud.iot.v1.utils; -import java.io.BufferedReader; import java.io.FileNotFoundException; import java.io.FileReader; import java.io.IOException; -import java.io.InputStreamReader; -import java.io.OutputStream; -import java.net.URL; +import java.net.ProxySelector; +import java.net.URI; +import java.net.http.HttpClient; +import java.net.http.HttpRequest; +import java.net.http.HttpRequest.BodyPublisher; +import java.net.http.HttpRequest.BodyPublishers; +import java.net.http.HttpResponse; +import java.net.http.HttpResponse.BodyHandlers; import java.util.logging.Level; import java.util.logging.Logger; -import javax.net.ssl.HttpsURLConnection; - import org.json.simple.JSONObject; import org.json.simple.parser.JSONParser; @@ -28,6 +30,8 @@ public class AuthParams { private static String userToken = null; private static String apiBaseURL = null; + private AuthParams() {} + public static String getAdminSystemKey() { return adminSystemKey; } @@ -114,53 +118,43 @@ private static void setRegistryRegion() throws ApplicationException { } } + @SuppressWarnings("unchecked") public static void setRegistryCredentials() throws ApplicationException, IOException { + if (userSystemKey != null) { return; } - setAdminCredentials(); - setRegistryRegion(); - String finalURL = baseURL.concat(configParameters.getGetSystemCredentialsExtension()) - .concat(adminSystemKey) - .concat("/getRegistryCredentials"); - URL obj = new URL(finalURL); - SetHttpConnection setCon = new SetHttpConnection(); - HttpsURLConnection con = setCon.getConnection(obj); - con.setRequestProperty(Constants.HTTP_REQUEST_PROPERTY_TOKEN_KEY, adminToken); - con.setRequestProperty(Constants.HTTP_REQUEST_PROPERTY_CONTENT_TYPE_KEY, - Constants.HTTP_REQUEST_PROPERTY_CONTENT_TYPE_ACCEPT_VALUE); - con.addRequestProperty(Constants.HTTP_REQUEST_PROPERTY_ACCEPT_KEY, - Constants.HTTP_REQUEST_PROPERTY_CONTENT_TYPE_ACCEPT_VALUE); - con.setRequestMethod(Constants.HTTP_REQUEST_METHOD_TYPE_POST); - con.setDoOutput(true); - StringBuilder response = new StringBuilder(); - try (OutputStream os = con.getOutputStream()) { + try { + setAdminCredentials(); + setRegistryRegion(); + String finalURL = baseURL.concat(configParameters.getGetSystemCredentialsExtension()) + .concat(adminSystemKey) + .concat("/getRegistryCredentials"); + JSONObject js = new JSONObject(); js.put("region", configParameters.getRegion()); js.put("registry", configParameters.getRegistry()); js.put("project", project); - - byte[] input = js.toString().getBytes(Constants.UTF8); - os.write(input, 0, input.length); - os.flush(); - int responseCode = con.getResponseCode(); - BufferedReader in = null; - if (con.getErrorStream() != null) { - in = new BufferedReader(new InputStreamReader(con.getErrorStream())); - } else if (con.getInputStream() != null) { - in = new BufferedReader(new InputStreamReader(con.getInputStream())); - } - JSONObject responseJSONObject = new JSONObject(); + BodyPublisher jsonPayload = BodyPublishers.ofString(js.toString()); + + HttpRequest request = HttpRequest.newBuilder() + .uri(URI.create(finalURL)) + .method(Constants.HTTP_REQUEST_METHOD_TYPE_POST, jsonPayload) + .headers(Constants.HTTP_REQUEST_PROPERTY_CONTENT_TYPE_KEY, Constants.HTTP_REQUEST_PROPERTY_CONTENT_TYPE_ACCEPT_VALUE, + Constants.HTTP_REQUEST_PROPERTY_TOKEN_KEY, adminToken, + Constants.HTTP_REQUEST_PROPERTY_ACCEPT_KEY, Constants.HTTP_REQUEST_PROPERTY_CONTENT_TYPE_ACCEPT_VALUE) + .build(); + + HttpResponse response = HttpClient.newBuilder() + .proxy(ProxySelector.getDefault()) + .build() + .send(request, BodyHandlers.ofString()); + + int responseCode = response.statusCode(); + String responseMessage = response.body(); JSONParser responseParser = new JSONParser(); - String inputLine; - String responseMessage = ""; - if (in != null) { - while ((inputLine = in.readLine()) != null) { - response.append(inputLine); - } - responseMessage = response.toString(); - } + JSONObject responseJSONObject; if (responseCode == 200) { if (responseMessage != null && responseMessage.length() > 0) { Object responseObj = responseParser.parse(responseMessage); @@ -172,11 +166,15 @@ public static void setRegistryCredentials() throws ApplicationException, IOExcep } } }else { - log.log(Level.INFO, "Response code " + responseCode + " received with message::" + responseMessage); - } - } catch (Exception e) { + log.log(Level.INFO, ()->"Response code " + responseCode + " received with message::" + responseMessage); + } + } catch (ApplicationException | IOException e) { log.log(Level.SEVERE, e.getMessage()); + } catch (InterruptedException ex) { + log.log(Level.SEVERE, ex.getMessage()); + Thread.currentThread().interrupt(); + }catch(Exception ec) { + log.log(Level.SEVERE, ec.getMessage()); } } - } diff --git a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/utils/SetHttpConnection.java b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/utils/SetHttpConnection.java deleted file mode 100644 index d1bb4c21..00000000 --- a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/utils/SetHttpConnection.java +++ /dev/null @@ -1,26 +0,0 @@ -package com.clearblade.cloud.iot.v1.utils; - -import java.io.IOException; -import java.net.URL; -import java.util.logging.Level; -import java.util.logging.Logger; - -import javax.net.ssl.HttpsURLConnection; - -public class SetHttpConnection { - static Logger log = Logger.getLogger(SetHttpConnection.class.getName()); - public HttpsURLConnection con; - - public SetHttpConnection() { - con = null; - } - - public HttpsURLConnection getConnection(URL url) { - try { - con = (HttpsURLConnection) url.openConnection(); - } catch (IOException e) { - log.log(Level.SEVERE, e.getMessage()); - } - return con; - } -} diff --git a/clearblade-cloud-iot/test/com/clearblade/cloud/iot/v1/test/DeviceManagerClientTest.java b/clearblade-cloud-iot/test/com/clearblade/cloud/iot/v1/test/DeviceManagerClientTest.java new file mode 100644 index 00000000..5a79cc59 --- /dev/null +++ b/clearblade-cloud-iot/test/com/clearblade/cloud/iot/v1/test/DeviceManagerClientTest.java @@ -0,0 +1,310 @@ +package com.clearblade.cloud.iot.v1.test; + + +import java.util.ArrayList; +import java.util.HashMap; + +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.MethodOrderer; +import org.junit.jupiter.api.Order; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.TestMethodOrder; + +import com.clearblade.cloud.iot.v1.DeviceManagerClient; +import com.clearblade.cloud.iot.v1.binddevicetogateway.BindDeviceToGatewayRequest; +import com.clearblade.cloud.iot.v1.binddevicetogateway.BindDeviceToGatewayResponse; +import com.clearblade.cloud.iot.v1.createdevice.CreateDeviceRequest; +import com.clearblade.cloud.iot.v1.createdeviceregistry.CreateDeviceRegistryRequest; +import com.clearblade.cloud.iot.v1.deletedevice.DeleteDeviceRequest; +import com.clearblade.cloud.iot.v1.deletedeviceregistry.DeleteDeviceRegistryRequest; +import com.clearblade.cloud.iot.v1.devicetypes.Device; +import com.clearblade.cloud.iot.v1.devicetypes.DeviceConfig; +import com.clearblade.cloud.iot.v1.devicetypes.DeviceName; +import com.clearblade.cloud.iot.v1.devicetypes.FieldMask; +import com.clearblade.cloud.iot.v1.devicetypes.GatewayConfig; +import com.clearblade.cloud.iot.v1.devicetypes.GatewayType; +import com.clearblade.cloud.iot.v1.devicetypes.Status; +import com.clearblade.cloud.iot.v1.getdevice.GetDeviceRequest; +import com.clearblade.cloud.iot.v1.getdeviceregistry.GetDeviceRegistryRequest; +import com.clearblade.cloud.iot.v1.registrytypes.DeviceRegistry; +import com.clearblade.cloud.iot.v1.registrytypes.LocationName; +import com.clearblade.cloud.iot.v1.registrytypes.RegistryName; +import com.clearblade.cloud.iot.v1.sendcommandtodevice.SendCommandToDeviceRequest; +import com.clearblade.cloud.iot.v1.sendcommandtodevice.SendCommandToDeviceResponse; +import com.clearblade.cloud.iot.v1.unbinddevicefromgateway.UnbindDeviceFromGatewayRequest; +import com.clearblade.cloud.iot.v1.unbinddevicefromgateway.UnbindDeviceFromGatewayResponse; +import com.clearblade.cloud.iot.v1.updatedevice.UpdateDeviceRequest; +import com.clearblade.cloud.iot.v1.updatedeviceregistry.UpdateDeviceRegistryRequest; +import com.clearblade.cloud.iot.v1.utils.ByteString; +import com.clearblade.cloud.iot.v1.utils.LogLevel; + +@TestMethodOrder(MethodOrderer.OrderAnnotation.class) +public class DeviceManagerClientTest { + + private static DeviceManagerClient client; + private static ExpectedResponseTest testResponse; + private String project = "ingressdevelopmentenv"; + private String location = "us-central1"; + + + @BeforeAll + public static void setUp() { + client = new DeviceManagerClient(); + testResponse = new ExpectedResponseTest(); + } + + @Test + @Order(1) + public void testCreateRegistrySuccess() { + String registryId = "testCreate_reg03"; + DeviceRegistry expectedResponse = testResponse.getResponseTest2(registryId); + CreateDeviceRegistryRequest request = CreateDeviceRegistryRequest.Builder.newBuilder() + .setParent(LocationName.of(project, location).toString()) + .setDeviceRegistry( + DeviceRegistry.newBuilder().setId(registryId).setLogLevel(LogLevel.DEBUG).build()) + .build(); + DeviceRegistry actualResponse = client.createDeviceRegistry(request); + testResponse.assertEquals(expectedResponse, actualResponse); + } + + @Test + @Order(2) + public void testGetRegistrySuccess() { + String registryId = "testCreate_reg03"; + DeviceRegistry expectedResponse = testResponse.getResponseTest3(registryId); + GetDeviceRegistryRequest request = GetDeviceRegistryRequest.Builder.newBuilder() + .setName(RegistryName.of(project, location, registryId).getRegistryFullName()) + .build(); + DeviceRegistry actualResponse = client.getDeviceRegistry(request); + testResponse.assertEquals(expectedResponse, actualResponse); + + } + + @Test + @Order(3) + public void testGetRegistryFail() { + String registryId = "testCreate_reg01"; + DeviceRegistry expectedResponse = testResponse.getResponseTest4(registryId); + GetDeviceRegistryRequest request = GetDeviceRegistryRequest.Builder.newBuilder() + .setName(RegistryName.of(project, location, registryId).getRegistryFullName()) + .build(); + DeviceRegistry actualResponse = client.getDeviceRegistry(request); + testResponse.assertNotEquals(expectedResponse, actualResponse); + + } + + @Test + @Order(4) + public void testUpdateDeviceRegistrySuccess() { + String registryId = "Rashmi_Registry_Test"; + RegistryName name = RegistryName.of(project, location, registryId); + DeviceRegistry expectedResponse = testResponse.getResponseTest5(registryId); + UpdateDeviceRegistryRequest request = UpdateDeviceRegistryRequest.Builder.newBuilder() + .setDeviceRegistry(DeviceRegistry.newBuilder().setId(registryId) + .setName(name.getRegistryFullName()) + .setLogLevel(LogLevel.ERROR) + .build()) + .setName(name.getRegistryFullName()).setUpdateMask("logLevel").build(); + + DeviceRegistry actualResponse = client.updateDeviceRegistry(request); + testResponse.assertEquals(expectedResponse, actualResponse); + } + + @Test + @Order(5) + public void testCreateDeviceSuccess() { + String registryId = "Rashmi_Registry_Test"; + String deviceId = "test_device01"; + String numId = "1211"; + RegistryName parent = RegistryName.of(project, location, registryId); + Device expectedResponse = testResponse.getResponseTest7(deviceId,numId); + GatewayConfig gatewayCfg = new GatewayConfig(); + gatewayCfg.setGatewayType(GatewayType.NON_GATEWAY); + Device device = Device.newBuilder() + .setId(deviceId) + .setName(deviceId) + .setNumId(numId) + .setBlocked(false) + .setGatewayConfig(gatewayCfg) + .setLogLevel(LogLevel.DEBUG) + .setCredentials(new ArrayList<>()) + .setLastErrorStatus(new Status()) + .setConfig(new DeviceConfig()) + .setMetadata(new HashMap<>()) + .build(); + CreateDeviceRequest request = CreateDeviceRequest.Builder.newBuilder().setParent(parent).setDevice(device) + .build(); + Device actualResponse = client.createDevice(request); + testResponse.assertEqual(expectedResponse, actualResponse); + + } + + @Test + @Order(6) + public void testCreateDeviceAsAGatewaySuccess() { + String registryId = "Rashmi_Registry_Test"; + String deviceId = "test_device03"; + String numId = "1112"; + RegistryName parent = RegistryName.of(project, location, registryId); + Device expectedResponse = testResponse.getResponseTest8(deviceId,numId); + GatewayConfig gatewayCfg = new GatewayConfig(); + gatewayCfg.setGatewayType(GatewayType.GATEWAY); + Device device = Device.newBuilder() + .setId(deviceId) + .setName(deviceId) + .setNumId(numId) + .setBlocked(false) + .setGatewayConfig(gatewayCfg) + .setLogLevel(LogLevel.DEBUG) + .setCredentials(new ArrayList<>()) + .setLastErrorStatus(new Status()) + .setConfig(new DeviceConfig()) + .setMetadata(new HashMap<>()) + .build(); + CreateDeviceRequest request = CreateDeviceRequest.Builder.newBuilder().setParent(parent).setDevice(device) + .build(); + Device actualResponse = client.createDevice(request); + testResponse.assertEqual(expectedResponse, actualResponse); + + } + + @Test + @Order(7) + public void testGetDeviceFail() { + String registryId = "Rashmi_Registry_Test"; + String deviceId = "test_device01"; + String numId= "1211"; + DeviceName name = DeviceName.of(project, location, registryId, "test_device02"); + Device expectedResponse = testResponse.getResponseTest9(deviceId,numId); + GetDeviceRequest request = GetDeviceRequest.Builder.newBuilder().setName(name) + .setFieldMask(FieldMask.newBuilder().build()).build(); + Device actualResponse = client.getDevice(request); + testResponse.assertNotEqual(expectedResponse, actualResponse); + } + + @Test + @Order(8) + public void testGetDeviceSuccess() { + String registryId = "Rashmi_Registry_Test"; + String deviceId = "test_device01"; + String numId= "1211"; + DeviceName name = DeviceName.of(project, location, registryId, deviceId); + Device expectedResponse = testResponse.getResponseTest10(deviceId,numId); + GetDeviceRequest request = GetDeviceRequest.Builder.newBuilder().setName(name) + .setFieldMask(FieldMask.newBuilder().build()).build(); + Device actualResponse = client.getDevice(request); + testResponse.assertEqual(expectedResponse, actualResponse); + } + + @Test + @Order(9) + public void testGetDeviceAsAGatewaySuccess() { + String registryId = "Rashmi_Registry_Test"; + String deviceId = "test_device03"; + String numId= "1112"; + DeviceName name = DeviceName.of(project, location, registryId, deviceId); + Device expectedResponse = testResponse.getResponseTest11(deviceId,numId); + GetDeviceRequest request = GetDeviceRequest.Builder.newBuilder().setName(name) + .setFieldMask(FieldMask.newBuilder().build()).build(); + Device actualResponse = client.getDevice(request); + testResponse.assertEqual(expectedResponse, actualResponse); + } + + @Test + @Order(10) + @Disabled + public void testUpdateDevice() { + String deviceId = "myOldDevice"; + Device expectedResponse = testResponse.getResponseTest12(deviceId); + Device device = Device.patch(deviceId, deviceId, LogLevel.ERROR, true); + String updateMask = "logLevel"; + UpdateDeviceRequest request = UpdateDeviceRequest.Builder.newBuilder().setName(deviceId).setDevice(device) + .setUpdateMask(updateMask).build(); + Device actualResponse = client.updateDevice(request); + testResponse.assertEqual(expectedResponse, actualResponse); + + } + + @Test + @Order(11) + public void testBindDeviceToGateway() { + String registryId = "Rashmi_Registry_Test"; + String gatewayId = "Rashmi_Gateway_Test"; + String deviceId = "test_device01"; + + BindDeviceToGatewayResponse expectedResponse = testResponse.getResponseTest13(); + BindDeviceToGatewayRequest request = BindDeviceToGatewayRequest.Builder.newBuilder() + .setParent(RegistryName.of(project, location, registryId).toString()) + .setGateway(gatewayId).setDevice(deviceId).build(); + BindDeviceToGatewayResponse actualResponse = client.bindDeviceToGateway(request); + testResponse.assertEqualResponse(expectedResponse, actualResponse); + + } + + @Test + @Order(12) + public void testUnbindDeviceFromGateway() { + String registryId = "Rashmi_Registry_Test"; + String gatewayId = "Rashmi_Gateway_Test"; + String deviceId = "test_device01"; + + UnbindDeviceFromGatewayResponse expectedResponse = testResponse.getResponseTest14(); + UnbindDeviceFromGatewayRequest request = UnbindDeviceFromGatewayRequest.Builder.newBuilder() + .setParent(RegistryName.of(project, location, registryId).toString()) + .setGateway(gatewayId).setDevice(deviceId).build(); + UnbindDeviceFromGatewayResponse actualResponse = client.unbindDeviceFromGateway(request); + testResponse.assertEqualsResponse(expectedResponse, actualResponse); + } + + @Test + @Order(13) + public void testSendCommandToDevice() { + String registryId = "Rashmi_Registry_Test"; + String deviceId = "test_device01"; + String byteData = "c2VuZEZ1bm55TWVzc2FnZVRvRGV2aWNl"; + + SendCommandToDeviceResponse expectedResponse = testResponse.getResponseTest15(); + SendCommandToDeviceRequest request = SendCommandToDeviceRequest.Builder.newBuilder() + .setName(DeviceName + .of(project, location, registryId, deviceId) + .toString()) + .setBinaryData(new ByteString(byteData)).build(); + SendCommandToDeviceResponse actualResponse = client.sendCommandToDevice(request); + testResponse.assertEqualsResponses(expectedResponse, actualResponse); + + } + + @Test + @Order(14) + public void testDeleteDevice() { + String registryId = "Rashmi_Registry_Test"; + String deviceId = "test_device01"; + DeviceName deviceName = DeviceName.of(project, location, registryId, deviceId); + DeleteDeviceRequest request = DeleteDeviceRequest.Builder.newBuilder().setName(deviceName).build(); + client.deleteDevice(request); + } + + @Test + @Order(15) + public void testDeleteDeviceAsAGateway() { + String registryId = "Rashmi_Registry_Test"; + String deviceId = "test_device03"; + DeviceName deviceName = DeviceName.of(project, location, registryId, deviceId); + DeleteDeviceRequest request = DeleteDeviceRequest.Builder.newBuilder().setName(deviceName).build(); + client.deleteDevice(request); + } + + @Test + @Order(16) + public void testDeleteDeviceRegistry() { + String registryId = "testCreate_reg03"; + DeleteDeviceRegistryRequest request = DeleteDeviceRegistryRequest.Builder.newBuilder() + .setName(RegistryName.of(project, location, registryId) + .getRegistryFullName()) + .build(); + client.deleteDeviceRegistry(request); + + } + +} diff --git a/clearblade-cloud-iot/test/com/clearblade/cloud/iot/v1/test/ExpectedResponseTest.java b/clearblade-cloud-iot/test/com/clearblade/cloud/iot/v1/test/ExpectedResponseTest.java new file mode 100644 index 00000000..497b8bfe --- /dev/null +++ b/clearblade-cloud-iot/test/com/clearblade/cloud/iot/v1/test/ExpectedResponseTest.java @@ -0,0 +1,353 @@ +package com.clearblade.cloud.iot.v1.test; + +import java.util.ArrayList; +import java.util.HashMap; + +import com.clearblade.cloud.iot.v1.binddevicetogateway.BindDeviceToGatewayResponse; +import com.clearblade.cloud.iot.v1.devicetypes.Device; +import com.clearblade.cloud.iot.v1.devicetypes.DeviceConfig; +import com.clearblade.cloud.iot.v1.devicetypes.GatewayConfig; +import com.clearblade.cloud.iot.v1.devicetypes.GatewayType; +import com.clearblade.cloud.iot.v1.devicetypes.Status; +import com.clearblade.cloud.iot.v1.registrytypes.DeviceRegistry; +import com.clearblade.cloud.iot.v1.registrytypes.HttpConfig; +import com.clearblade.cloud.iot.v1.registrytypes.HttpState; +import com.clearblade.cloud.iot.v1.registrytypes.MqttConfig; +import com.clearblade.cloud.iot.v1.registrytypes.MqttState; +import com.clearblade.cloud.iot.v1.registrytypes.StateNotificationConfig; +import com.clearblade.cloud.iot.v1.sendcommandtodevice.SendCommandToDeviceResponse; +import com.clearblade.cloud.iot.v1.unbinddevicefromgateway.UnbindDeviceFromGatewayResponse; +import com.clearblade.cloud.iot.v1.utils.LogLevel; + +public class ExpectedResponseTest { + + public boolean assertEquals(DeviceRegistry obj1, DeviceRegistry obj2) { + boolean flag = true; + if(!obj1.toBuilder().getId().equals(obj2.toBuilder().getId()) + || obj1.toBuilder().getHttpConfig().equals(obj2.toBuilder().getHttpConfig()) + || obj1.toBuilder().getMqttConfig().equals(obj2.toBuilder().getMqttConfig()) + || obj1.toBuilder().getLogLevel().equals(obj2.toBuilder().getLogLevel()) + || obj1.toBuilder().getStateNotificationConfig().equals(obj2.toBuilder().getStateNotificationConfig())) + flag = false; + return flag; + } + + public boolean assertNotEquals(DeviceRegistry obj1, DeviceRegistry obj2) { + boolean flag = true; + if(obj2 == null) + return flag; + else if(obj1.toBuilder().getId().equals(obj2.toBuilder().getId()) + || obj1.toBuilder().getHttpConfig().equals(obj2.toBuilder().getHttpConfig()) + || obj1.toBuilder().getMqttConfig().equals(obj2.toBuilder().getMqttConfig()) + || obj1.toBuilder().getLogLevel().equals(obj2.toBuilder().getLogLevel()) + || obj1.toBuilder().getStateNotificationConfig().equals(obj2.toBuilder().getStateNotificationConfig())) + flag = false; + return flag; + } + + public boolean assertEqual(Device obj1, Device obj2) { + boolean flag = true; + if(obj2 == null) + return flag; + else if(!obj1.toBuilder().getId().equals(obj2.toBuilder().getId()) + || obj1.toBuilder().getGatewayConfig().equals(obj2.toBuilder().getGatewayConfig()) + || obj1.toBuilder().getLogLevel().equals(obj2.toBuilder().getLogLevel()) + || obj1.toBuilder().getCredentials().equals(obj2.toBuilder().getCredentials())) + flag = false; + return flag; + } + + public boolean assertNotEqual(Device obj1, Device obj2) { + boolean flag = true; + if(obj2 == null) + return flag; + else if(obj1.toBuilder().getId().equals(obj2.toBuilder().getId()) + || obj1.toBuilder().getName().equals(obj2.toBuilder().getName()) + || obj1.toBuilder().getNumId().equals(obj2.toBuilder().getNumId()) + || obj1.toBuilder().getGatewayConfig().equals(obj2.toBuilder().getGatewayConfig()) + || obj1.toBuilder().getLogLevel().equals(obj2.toBuilder().getLogLevel()) + || obj1.toBuilder().getCredentials().equals(obj2.toBuilder().getCredentials())) + flag = false; + return flag; + } + + public boolean assertEqualResponse(BindDeviceToGatewayResponse obj1, BindDeviceToGatewayResponse obj2) { + boolean flag = true; + if(obj1.getHttpStatusCode() != obj2.getHttpStatusCode() || !(obj1.getHttpStatusResponse().equals(obj2.getHttpStatusResponse()))) + flag = false; + return flag; + } + + public boolean assertEqualsResponse(UnbindDeviceFromGatewayResponse obj1, UnbindDeviceFromGatewayResponse obj2) { + boolean flag = true; + if(obj1.getHttpStatusCode() != obj2.getHttpStatusCode() || !(obj1.getHttpStatusResponse().equals(obj2.getHttpStatusResponse()))) + flag = false; + return flag; + } + + public boolean assertEqualsResponses(SendCommandToDeviceResponse obj1, SendCommandToDeviceResponse obj2) { + boolean flag = true; + if(obj1.getHttpStatusCode() != obj2.getHttpStatusCode() || !(obj1.getHttpStatusResponse().equals(obj2.getHttpStatusResponse()))) + flag = false; + return flag; + } + + public DeviceRegistry getResponseTest1(String registryId) { + + HttpConfig httpConfig = new HttpConfig(); + httpConfig.setHttpEnabledState(HttpState.HTTP_ENABLED); + + MqttConfig mqttConfig = new MqttConfig(); + mqttConfig.setMqttEnabledState(MqttState.MQTT_ENABLED); + + StateNotificationConfig stateConfig = new StateNotificationConfig(); + stateConfig.setPubsubTopicName(""); + + return DeviceRegistry.newBuilder() + .setId(registryId) + .setHttpConfig(httpConfig) + .setMqttConfig(mqttConfig) + .setLogLevel(LogLevel.DEBUG) + .setStateNotificationConfig(stateConfig) + .build(); + } + + public DeviceRegistry getResponseTest2(String registryId) { + + HttpConfig httpConfig = new HttpConfig(); + httpConfig.setHttpEnabledState(HttpState.HTTP_ENABLED); + + MqttConfig mqttConfig = new MqttConfig(); + mqttConfig.setMqttEnabledState(MqttState.MQTT_ENABLED); + + StateNotificationConfig stateConfig = new StateNotificationConfig(); + stateConfig.setPubsubTopicName(""); + + return DeviceRegistry.newBuilder() + .setId(registryId) + .setCredentials(new ArrayList<>()) + .setHttpConfig(httpConfig) + .setMqttConfig(mqttConfig) + .setLogLevel(LogLevel.DEBUG) + .setEventNotificationConfigs(new ArrayList<>()) + .setStateNotificationConfig(stateConfig) + .build(); + } + + + public DeviceRegistry getResponseTest3(String registryId) { + + HttpConfig httpConfig = new HttpConfig(); + httpConfig.setHttpEnabledState(HttpState.HTTP_ENABLED); + + MqttConfig mqttConfig = new MqttConfig(); + mqttConfig.setMqttEnabledState(MqttState.MQTT_ENABLED); + + StateNotificationConfig stateConfig = new StateNotificationConfig(); + stateConfig.setPubsubTopicName(""); + + return DeviceRegistry.newBuilder() + .setId(registryId) + .setHttpConfig(httpConfig) + .setMqttConfig(mqttConfig) + .setLogLevel(LogLevel.DEBUG) + .setStateNotificationConfig(stateConfig) + .build(); + } + + public DeviceRegistry getResponseTest4(String registryId) { + + HttpConfig httpConfig = new HttpConfig(); + httpConfig.setHttpEnabledState(HttpState.HTTP_ENABLED); + + MqttConfig mqttConfig = new MqttConfig(); + mqttConfig.setMqttEnabledState(MqttState.MQTT_ENABLED); + + StateNotificationConfig stateConfig = new StateNotificationConfig(); + stateConfig.setPubsubTopicName(""); + + return DeviceRegistry.newBuilder() + .setId(registryId) + .setHttpConfig(httpConfig) + .setMqttConfig(mqttConfig) + .setLogLevel(LogLevel.DEBUG) + .setStateNotificationConfig(stateConfig) + .build(); + } + + + public DeviceRegistry getResponseTest5(String registryId) { + + HttpConfig httpConfig = new HttpConfig(); + httpConfig.setHttpEnabledState(HttpState.HTTP_ENABLED); + + MqttConfig mqttConfig = new MqttConfig(); + mqttConfig.setMqttEnabledState(MqttState.MQTT_ENABLED); + + StateNotificationConfig stateConfig = new StateNotificationConfig(); + stateConfig.setPubsubTopicName(""); + + return DeviceRegistry.newBuilder() + .setId(registryId) + .setHttpConfig(httpConfig) + .setMqttConfig(mqttConfig) + .setLogLevel(LogLevel.ERROR) + .setStateNotificationConfig(stateConfig) + .build(); + } + + + public Device getResponseTest6(String deviceId,String numId) { + + GatewayConfig gatewayConfig = new GatewayConfig(); + gatewayConfig.setGatewayType(GatewayType.NON_GATEWAY); + + return Device.newBuilder() + .setId(deviceId) + .setName(deviceId) + .setNumId(numId) + .setBlocked(false) + .setGatewayConfig(gatewayConfig) + .setLogLevel(LogLevel.DEBUG) + .setCredentials(new ArrayList<>()) + .setLastErrorStatus(new Status()) + .setConfig(new DeviceConfig()) + .setMetadata(new HashMap<>()) + .build(); + + } + + public Device getResponseTest7(String deviceId,String numId) { + + GatewayConfig gatewayConfig = new GatewayConfig(); + gatewayConfig.setGatewayType(GatewayType.NON_GATEWAY); + + return Device.newBuilder() + .setId(deviceId) + .setName(deviceId) + .setNumId(numId) + .setBlocked(false) + .setGatewayConfig(gatewayConfig) + .setLogLevel(LogLevel.DEBUG) + .setCredentials(new ArrayList<>()) + .setLastErrorStatus(new Status()) + .setConfig(new DeviceConfig()) + .setMetadata(new HashMap<>()) + .build(); + + } + + public Device getResponseTest8(String deviceId,String numId) { + + GatewayConfig gatewayConfig = new GatewayConfig(); + gatewayConfig.setGatewayType(GatewayType.GATEWAY); + + return Device.newBuilder() + .setId(deviceId) + .setName(deviceId) + .setNumId(numId) + .setBlocked(false) + .setGatewayConfig(gatewayConfig) + .setLogLevel(LogLevel.DEBUG) + .setCredentials(new ArrayList<>()) + .setLastErrorStatus(new Status()) + .setConfig(new DeviceConfig()) + .setMetadata(new HashMap<>()) + .build(); + + } + + public Device getResponseTest9(String deviceId,String numId) { + + GatewayConfig gatewayConfig = new GatewayConfig(); + gatewayConfig.setGatewayType(GatewayType.NON_GATEWAY); + + return Device.newBuilder() + .setId(deviceId) + .setName(deviceId) + .setNumId(numId) + .setBlocked(false) + .setGatewayConfig(gatewayConfig) + .setLogLevel(LogLevel.DEBUG) + .setCredentials(new ArrayList<>()) + .setLastErrorStatus(new Status()) + .setConfig(new DeviceConfig()) + .setMetadata(new HashMap<>()) + .build(); + + } + + public Device getResponseTest10(String deviceId,String numId) { + + GatewayConfig gatewayConfig = new GatewayConfig(); + gatewayConfig.setGatewayType(GatewayType.NON_GATEWAY); + + return Device.newBuilder() + .setId(deviceId) + .setName(deviceId) + .setNumId(numId) + .setBlocked(false) + .setGatewayConfig(gatewayConfig) + .setLogLevel(LogLevel.DEBUG) + .setCredentials(new ArrayList<>()) + .setLastErrorStatus(new Status()) + .setConfig(new DeviceConfig()) + .setMetadata(new HashMap<>()) + .build(); + + } + + public Device getResponseTest11(String deviceId,String numId) { + + GatewayConfig gatewayConfig = new GatewayConfig(); + gatewayConfig.setGatewayType(GatewayType.GATEWAY); + + return Device.newBuilder() + .setId(deviceId) + .setName(deviceId) + .setNumId(numId) + .setBlocked(false) + .setGatewayConfig(gatewayConfig) + .setLogLevel(LogLevel.DEBUG) + .setCredentials(new ArrayList<>()) + .setLastErrorStatus(new Status()) + .setConfig(new DeviceConfig()) + .setMetadata(new HashMap<>()) + .build(); + + } + + public Device getResponseTest12(String deviceId) { + + return Device.newBuilder() + .setId(deviceId) + .setName(deviceId) + .setBlocked(false) + .setLogLevel(LogLevel.ERROR) + .build(); + } + + public BindDeviceToGatewayResponse getResponseTest13() { + + BindDeviceToGatewayResponse response = BindDeviceToGatewayResponse.Builder.newBuilder().build(); + response.setHttpStatusCode(200); + response.setHttpStatusResponse("OK"); + return response; + } + + public UnbindDeviceFromGatewayResponse getResponseTest14() { + + UnbindDeviceFromGatewayResponse response = UnbindDeviceFromGatewayResponse.Builder.newBuilder().build(); + response.setHttpStatusCode(200); + response.setHttpStatusResponse("OK"); + return response; + } + + public SendCommandToDeviceResponse getResponseTest15() { + + SendCommandToDeviceResponse response = SendCommandToDeviceResponse.Builder.newBuilder().build(); + response.setHttpStatusCode(200); + response.setHttpStatusResponse("OK"); + return response; + } +} diff --git a/clearblade-cloud-iot/test/com/clearblade/cloud/iot/v1/test/package-info.java b/clearblade-cloud-iot/test/com/clearblade/cloud/iot/v1/test/package-info.java new file mode 100644 index 00000000..32213406 --- /dev/null +++ b/clearblade-cloud-iot/test/com/clearblade/cloud/iot/v1/test/package-info.java @@ -0,0 +1 @@ +package com.clearblade.cloud.iot.v1.test; \ No newline at end of file From 5d3bbd5a9fd36e1f0a70d23f836b7cc69db195dc Mon Sep 17 00:00:00 2001 From: RashmiK14 Date: Wed, 30 Nov 2022 22:51:40 +0530 Subject: [PATCH 021/151] Create README.md Committing README file --- clearblade-cloud-iot/README.md | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 clearblade-cloud-iot/README.md diff --git a/clearblade-cloud-iot/README.md b/clearblade-cloud-iot/README.md new file mode 100644 index 00000000..a162f44c --- /dev/null +++ b/clearblade-cloud-iot/README.md @@ -0,0 +1,16 @@ +Quick Start +set an environment variable CLEARBLADE_CONFIGURATION which should point to your service account json file. +set an environment variable CLEARBLADE_REGISTRY which should be the name of registry you want to work upon. +set an environment variable CLEARBLADE_REGION which should point to the region. +Installation +Install this library as a MAVEN dependency in your project. Alternatively, you can get jar file of this library and add it as an External Jar in your project’s build path and can start using the same. +Code samples and snippets +Code samples and snippets live in the samples folder. +Test Cases +Test cases live in the test folder. +Supported JAVA Version +Minimum JAVA 11 version is required to use current library version. Clearblade JAVA SDK library is built using MAVEN version 4.0.0 and Junit Jupiter API version 5.8.2 for test cases to run. +Executing Samples +You have to use following maven command from command prompt :- +mvn exec:java -Dexec.cleanupDaemonThreads=false -Dexec.mainClass=<> -DprojectName=<> -Dlocation=<> -DregistryName=<> -DdeviceName=<> +Parameters to be sent will change, as the sample changes. One has to refer to list of samples to ensure which sample accepts which parameters. From 20b67efea440d6fd70e661f85f09f53f7e775140 Mon Sep 17 00:00:00 2001 From: RashmiK14 Date: Thu, 1 Dec 2022 20:02:03 +0530 Subject: [PATCH 022/151] Committing changes for timeout for Async_Post calls --- .../src/com/clearblade/cloud/iot/v1/AsyncClient.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/AsyncClient.java b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/AsyncClient.java index 211dc965..35abd4af 100644 --- a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/AsyncClient.java +++ b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/AsyncClient.java @@ -7,6 +7,7 @@ import java.net.http.HttpRequest.BodyPublisher; import java.net.http.HttpRequest.BodyPublishers; import java.net.http.HttpResponse; +import java.time.Duration; import java.util.concurrent.CompletableFuture; import java.util.logging.Level; import java.util.logging.Logger; @@ -130,7 +131,9 @@ public String[] post(String apiName, String params, String body) { .build(); CompletableFuture> response = HttpClient.newBuilder() - .build() + .version(HttpClient.Version.HTTP_2) + .connectTimeout(Duration.ofSeconds(20)) + .build() .sendAsync(request, HttpResponse.BodyHandlers.ofString()); HttpResponse httpResponse = response.get(); From cd0672b6adf1d91515f082cde8f1ce073dabf67d Mon Sep 17 00:00:00 2001 From: mikoaro Date: Thu, 1 Dec 2022 13:14:13 -0600 Subject: [PATCH 023/151] Update README with information --- clearblade-cloud-iot/README.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/clearblade-cloud-iot/README.md b/clearblade-cloud-iot/README.md index a162f44c..76e29f09 100644 --- a/clearblade-cloud-iot/README.md +++ b/clearblade-cloud-iot/README.md @@ -12,5 +12,7 @@ Supported JAVA Version Minimum JAVA 11 version is required to use current library version. Clearblade JAVA SDK library is built using MAVEN version 4.0.0 and Junit Jupiter API version 5.8.2 for test cases to run. Executing Samples You have to use following maven command from command prompt :- -mvn exec:java -Dexec.cleanupDaemonThreads=false -Dexec.mainClass=<> -DprojectName=<> -Dlocation=<> -DregistryName=<> -DdeviceName=<> +mvn exec:java -Dexec.cleanupDaemonThreads=false -Dexec.mainClass=<> -DprojectName=<> -Dlocation=<> -DregistryName=<> -DdeviceName=<> Parameters to be sent will change, as the sample changes. One has to refer to list of samples to ensure which sample accepts which parameters. + +TO DOs From ebd7e1fec2de2f2a163a7ec404454ee970ac00bc Mon Sep 17 00:00:00 2001 From: mikoaro Date: Thu, 1 Dec 2022 13:40:27 -0600 Subject: [PATCH 024/151] Update README with information --- README.md | 0 clearblade-cloud-iot/README.md | 18 ------------------ 2 files changed, 18 deletions(-) create mode 100644 README.md delete mode 100644 clearblade-cloud-iot/README.md diff --git a/README.md b/README.md new file mode 100644 index 00000000..e69de29b diff --git a/clearblade-cloud-iot/README.md b/clearblade-cloud-iot/README.md deleted file mode 100644 index 76e29f09..00000000 --- a/clearblade-cloud-iot/README.md +++ /dev/null @@ -1,18 +0,0 @@ -Quick Start -set an environment variable CLEARBLADE_CONFIGURATION which should point to your service account json file. -set an environment variable CLEARBLADE_REGISTRY which should be the name of registry you want to work upon. -set an environment variable CLEARBLADE_REGION which should point to the region. -Installation -Install this library as a MAVEN dependency in your project. Alternatively, you can get jar file of this library and add it as an External Jar in your project’s build path and can start using the same. -Code samples and snippets -Code samples and snippets live in the samples folder. -Test Cases -Test cases live in the test folder. -Supported JAVA Version -Minimum JAVA 11 version is required to use current library version. Clearblade JAVA SDK library is built using MAVEN version 4.0.0 and Junit Jupiter API version 5.8.2 for test cases to run. -Executing Samples -You have to use following maven command from command prompt :- -mvn exec:java -Dexec.cleanupDaemonThreads=false -Dexec.mainClass=<> -DprojectName=<> -Dlocation=<> -DregistryName=<> -DdeviceName=<> -Parameters to be sent will change, as the sample changes. One has to refer to list of samples to ensure which sample accepts which parameters. - -TO DOs From 9a6dfb1912831c79cceb1a39b9b6673959568824 Mon Sep 17 00:00:00 2001 From: mikoaro Date: Thu, 1 Dec 2022 13:41:17 -0600 Subject: [PATCH 025/151] Update README with information --- README.md | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/README.md b/README.md index e69de29b..bac1ebc3 100644 --- a/README.md +++ b/README.md @@ -0,0 +1,16 @@ +Quick Start +set an environment variable CLEARBLADE_CONFIGURATION which should point to your service account json file. +set an environment variable CLEARBLADE_REGISTRY which should be the name of registry you want to work upon. +set an environment variable CLEARBLADE_REGION which should point to the region. +Installation +Install this library as a MAVEN dependency in your project. Alternatively, you can get jar file of this library and add it as an External Jar in your project’s build path and can start using the same. +Code samples and snippets +Code samples and snippets live in the samples folder. +Test Cases +Test cases live in the test folder. +Supported JAVA Version +Minimum JAVA 11 version is required to use current library version. Clearblade JAVA SDK library is built using MAVEN version 4.0.0 and Junit Jupiter API version 5.8.2 for test cases to run. +Executing Samples +You have to use following maven command from command prompt :- +mvn exec:java -Dexec.cleanupDaemonThreads=false -Dexec.mainClass=<> -DprojectName=<> -Dlocation=<> -DregistryName=<> -DdeviceName=<> +Parameters to be sent will change, as the sample changes. One has to refer to list of samples to ensure which sample accepts which parameters. From 7e91616a8d62ba02d470b2d5db8e7088c37c9709 Mon Sep 17 00:00:00 2001 From: mikoaro Date: Thu, 1 Dec 2022 14:57:38 -0600 Subject: [PATCH 026/151] Updated README with information --- README.md | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/README.md b/README.md index bac1ebc3..4d6b1bab 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,10 @@ +# ClearBlade Internet of Things (IoT) Core Client for Java + +Java library and samples for [ClearBlade Internet of Things (IoT) Core][product-docs]. + +- [Product Documentation][product-docs] +- [Client Library Documentation][javasdk] + Quick Start set an environment variable CLEARBLADE_CONFIGURATION which should point to your service account json file. set an environment variable CLEARBLADE_REGISTRY which should be the name of registry you want to work upon. @@ -14,3 +21,6 @@ Executing Samples You have to use following maven command from command prompt :- mvn exec:java -Dexec.cleanupDaemonThreads=false -Dexec.mainClass=<> -DprojectName=<> -Dlocation=<> -DregistryName=<> -DdeviceName=<> Parameters to be sent will change, as the sample changes. One has to refer to list of samples to ensure which sample accepts which parameters. + +[product-docs]: https://clearblade.atlassian.net/wiki/spaces/IC/overview +[javasdk]: https://clearblade.atlassian.net/wiki/spaces/IC/pages/2231173185/Java From 16d4bea00d367181ad576be4001c3fc30c2874d6 Mon Sep 17 00:00:00 2001 From: mikoaro Date: Thu, 1 Dec 2022 15:56:56 -0600 Subject: [PATCH 027/151] Updated README with information --- README.md | 20 ++++++++++++++++++++ clearblade-cloud-iot/samples/README.md | 19 +++++++++++++++++++ 2 files changed, 39 insertions(+) create mode 100644 clearblade-cloud-iot/samples/README.md diff --git a/README.md b/README.md index 4d6b1bab..32c99a2f 100644 --- a/README.md +++ b/README.md @@ -5,6 +5,26 @@ Java library and samples for [ClearBlade Internet of Things (IoT) Core][product- - [Product Documentation][product-docs] - [Client Library Documentation][javasdk] +## ClearBlade IoT Core Samples Java + +The sample apps demonstrates registry and device creation for ClearBlade IoT Core. These are two of the over fifteen samples codes that come with the library. + +Note that before you can run the sample, you must configure a Google Cloud +PubSub topic for Cloud IoT as described in [the parent README](../README.md). + +Before running the samples, you can set the `GOOGLE_CLOUD_PROJECT` and +`GOOGLE_APPLICATION_CREDENTIALS` environment variables to avoid passing them to +the sample every time you run it. + +## Setup + +Run the following command to install the libraries and build the sample with +Maven: + + mvn clean compile assembly:single + +## Running the sample + Quick Start set an environment variable CLEARBLADE_CONFIGURATION which should point to your service account json file. set an environment variable CLEARBLADE_REGISTRY which should be the name of registry you want to work upon. diff --git a/clearblade-cloud-iot/samples/README.md b/clearblade-cloud-iot/samples/README.md new file mode 100644 index 00000000..7357550b --- /dev/null +++ b/clearblade-cloud-iot/samples/README.md @@ -0,0 +1,19 @@ +# Java Samples + +This folder contains Java samples that demonstrate an overview of the +ClearBlade IoT Core platform. + +## Quickstart + +1. From the [ClearBlade Migration from Google IoT Core section](https://clearblade.atlassian.net/wiki/spaces/IC/pages/2202664969/Migration+from+Google+IoT+Core) + migrate your existing Google IoT Core registries and/or devices into ClearBlade IoT Core or using the + of the ClearBlade IoT Core Console, create a device registry and devices. +2. [Add service accounts to a project](https://clearblade.atlassian.net/wiki/spaces/IC/pages/2240675843/Add+service+accounts+to+a+project). + +3. Use the following to set your environment variables keys: + + export CLEARBLADE_REGISTRY=[your-registry] + export CLEARBLADE_CONFIGURATION=PATH to json file + export CLEARBLADE_REGION=[your-region] + +4. Use the HTTP or MQTT samples in the [samples](./clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples) folder. From 3f5cf009d008be58829e5b50e964441ef15aff0e Mon Sep 17 00:00:00 2001 From: mikoaro Date: Thu, 1 Dec 2022 16:01:03 -0600 Subject: [PATCH 028/151] Updated README with information --- clearblade-cloud-iot/samples/README.md | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/clearblade-cloud-iot/samples/README.md b/clearblade-cloud-iot/samples/README.md index 7357550b..5c322534 100644 --- a/clearblade-cloud-iot/samples/README.md +++ b/clearblade-cloud-iot/samples/README.md @@ -12,8 +12,10 @@ ClearBlade IoT Core platform. 3. Use the following to set your environment variables keys: - export CLEARBLADE_REGISTRY=[your-registry] - export CLEARBLADE_CONFIGURATION=PATH to json file - export CLEARBLADE_REGION=[your-region] + ``` + export CLEARBLADE_CONFIGURATION=/path/to/file.json + export CLEARBLADE_REGISTRY=[your-registry] + export CLEARBLADE_REGION=[your-region] + ``` 4. Use the HTTP or MQTT samples in the [samples](./clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples) folder. From cc39189a4975c5e77014586a9f2aa63232b98657 Mon Sep 17 00:00:00 2001 From: mikoaro Date: Thu, 1 Dec 2022 16:03:00 -0600 Subject: [PATCH 029/151] Updated README with information --- clearblade-cloud-iot/samples/README.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/clearblade-cloud-iot/samples/README.md b/clearblade-cloud-iot/samples/README.md index 5c322534..60494aa4 100644 --- a/clearblade-cloud-iot/samples/README.md +++ b/clearblade-cloud-iot/samples/README.md @@ -8,7 +8,9 @@ ClearBlade IoT Core platform. 1. From the [ClearBlade Migration from Google IoT Core section](https://clearblade.atlassian.net/wiki/spaces/IC/pages/2202664969/Migration+from+Google+IoT+Core) migrate your existing Google IoT Core registries and/or devices into ClearBlade IoT Core or using the of the ClearBlade IoT Core Console, create a device registry and devices. -2. [Add service accounts to a project](https://clearblade.atlassian.net/wiki/spaces/IC/pages/2240675843/Add+service+accounts+to+a+project). + +2. [Add service accounts to a project](https://clearblade.atlassian.net/wiki/spaces/IC/pages/2240675843/Add+service+accounts+to+a+project) and download the json file with your service + account’s credentials. 3. Use the following to set your environment variables keys: From ac43c927bf341ede530fd46cba6271780f66e47f Mon Sep 17 00:00:00 2001 From: mikoaro Date: Thu, 1 Dec 2022 16:06:01 -0600 Subject: [PATCH 030/151] Updated README with information --- README.md | 25 ++++++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 32c99a2f..b8862c6d 100644 --- a/README.md +++ b/README.md @@ -5,6 +5,25 @@ Java library and samples for [ClearBlade Internet of Things (IoT) Core][product- - [Product Documentation][product-docs] - [Client Library Documentation][javasdk] +## Quickstart + +1. From the [ClearBlade Migration from Google IoT Core section](https://clearblade.atlassian.net/wiki/spaces/IC/pages/2202664969/Migration+from+Google+IoT+Core) + migrate your existing Google IoT Core registries and/or devices into ClearBlade IoT Core or using the + of the ClearBlade IoT Core Console, create a device registry and devices. + +2. [Add service accounts to a project](https://clearblade.atlassian.net/wiki/spaces/IC/pages/2240675843/Add+service+accounts+to+a+project) and download the json file with your service + account’s credentials. + +3. Use the following to set your environment variables keys: + + ``` + export CLEARBLADE_CONFIGURATION=/path/to/file.json + export CLEARBLADE_REGISTRY=[your-registry] + export CLEARBLADE_REGION=[your-region] + ``` + +4. Use the HTTP or MQTT samples in the [samples](./clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples) folder. + ## ClearBlade IoT Core Samples Java The sample apps demonstrates registry and device creation for ClearBlade IoT Core. These are two of the over fifteen samples codes that come with the library. @@ -12,8 +31,8 @@ The sample apps demonstrates registry and device creation for ClearBlade IoT Cor Note that before you can run the sample, you must configure a Google Cloud PubSub topic for Cloud IoT as described in [the parent README](../README.md). -Before running the samples, you can set the `GOOGLE_CLOUD_PROJECT` and -`GOOGLE_APPLICATION_CREDENTIALS` environment variables to avoid passing them to +Before running the samples, you can set the `CLEARBLADE_CONFIGURATION`, `CLEARBLADE_REGISTRY` and +`CLEARBLADE_REGION` environment variables to avoid passing them to the sample every time you run it. ## Setup @@ -21,7 +40,7 @@ the sample every time you run it. Run the following command to install the libraries and build the sample with Maven: - mvn clean compile assembly:single + mvn clean install ## Running the sample From b6b5388d10eb658fc622348993f44059250fb59d Mon Sep 17 00:00:00 2001 From: mikoaro Date: Thu, 1 Dec 2022 16:08:36 -0600 Subject: [PATCH 031/151] Updated README with information --- README.md | 2 +- clearblade-cloud-iot/samples/README.md | 2 -- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/README.md b/README.md index b8862c6d..5d9c9590 100644 --- a/README.md +++ b/README.md @@ -22,7 +22,7 @@ Java library and samples for [ClearBlade Internet of Things (IoT) Core][product- export CLEARBLADE_REGION=[your-region] ``` -4. Use the HTTP or MQTT samples in the [samples](./clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples) folder. +4. Use the HTTP or MQTT samples in the [samples](./clearblade-cloud-iot/samples) folder. ## ClearBlade IoT Core Samples Java diff --git a/clearblade-cloud-iot/samples/README.md b/clearblade-cloud-iot/samples/README.md index 60494aa4..a84028d8 100644 --- a/clearblade-cloud-iot/samples/README.md +++ b/clearblade-cloud-iot/samples/README.md @@ -19,5 +19,3 @@ ClearBlade IoT Core platform. export CLEARBLADE_REGISTRY=[your-registry] export CLEARBLADE_REGION=[your-region] ``` - -4. Use the HTTP or MQTT samples in the [samples](./clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples) folder. From d1068667fdbddeec5a4ad6eeaf4516d6371491da Mon Sep 17 00:00:00 2001 From: mikoaro Date: Thu, 1 Dec 2022 16:10:50 -0600 Subject: [PATCH 032/151] Updated README with information --- README.md | 2 +- clearblade-cloud-iot/samples/README.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 5d9c9590..fbf4806a 100644 --- a/README.md +++ b/README.md @@ -9,7 +9,7 @@ Java library and samples for [ClearBlade Internet of Things (IoT) Core][product- 1. From the [ClearBlade Migration from Google IoT Core section](https://clearblade.atlassian.net/wiki/spaces/IC/pages/2202664969/Migration+from+Google+IoT+Core) migrate your existing Google IoT Core registries and/or devices into ClearBlade IoT Core or using the - of the ClearBlade IoT Core Console, create a device registry and devices. + of the ClearBlade IoT Core Console, [create a device registry and devices] (https://clearblade.atlassian.net/wiki/spaces/IC/pages/2202206388/Creating+registries+and+devices). 2. [Add service accounts to a project](https://clearblade.atlassian.net/wiki/spaces/IC/pages/2240675843/Add+service+accounts+to+a+project) and download the json file with your service account’s credentials. diff --git a/clearblade-cloud-iot/samples/README.md b/clearblade-cloud-iot/samples/README.md index a84028d8..19dac650 100644 --- a/clearblade-cloud-iot/samples/README.md +++ b/clearblade-cloud-iot/samples/README.md @@ -7,7 +7,7 @@ ClearBlade IoT Core platform. 1. From the [ClearBlade Migration from Google IoT Core section](https://clearblade.atlassian.net/wiki/spaces/IC/pages/2202664969/Migration+from+Google+IoT+Core) migrate your existing Google IoT Core registries and/or devices into ClearBlade IoT Core or using the - of the ClearBlade IoT Core Console, create a device registry and devices. + of the ClearBlade IoT Core Console, [create a device registry and devices] (https://clearblade.atlassian.net/wiki/spaces/IC/pages/2202206388/Creating+registries+and+devices). 2. [Add service accounts to a project](https://clearblade.atlassian.net/wiki/spaces/IC/pages/2240675843/Add+service+accounts+to+a+project) and download the json file with your service account’s credentials. From 0dc93a971c0e96fc84511ef2cc798f12d968f17f Mon Sep 17 00:00:00 2001 From: mikoaro Date: Thu, 1 Dec 2022 16:11:39 -0600 Subject: [PATCH 033/151] Updated README with information --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index fbf4806a..e11049d7 100644 --- a/README.md +++ b/README.md @@ -9,7 +9,7 @@ Java library and samples for [ClearBlade Internet of Things (IoT) Core][product- 1. From the [ClearBlade Migration from Google IoT Core section](https://clearblade.atlassian.net/wiki/spaces/IC/pages/2202664969/Migration+from+Google+IoT+Core) migrate your existing Google IoT Core registries and/or devices into ClearBlade IoT Core or using the - of the ClearBlade IoT Core Console, [create a device registry and devices] (https://clearblade.atlassian.net/wiki/spaces/IC/pages/2202206388/Creating+registries+and+devices). + of the ClearBlade IoT Core Console, [create a device registry and devices](https://clearblade.atlassian.net/wiki/spaces/IC/pages/2202206388/Creating+registries+and+devices). 2. [Add service accounts to a project](https://clearblade.atlassian.net/wiki/spaces/IC/pages/2240675843/Add+service+accounts+to+a+project) and download the json file with your service account’s credentials. From 08bd90d0e458f679720525069191d7afc29890d1 Mon Sep 17 00:00:00 2001 From: mikoaro Date: Thu, 1 Dec 2022 16:12:25 -0600 Subject: [PATCH 034/151] Updated README with information --- README.md | 2 +- clearblade-cloud-iot/samples/README.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index e11049d7..35edb829 100644 --- a/README.md +++ b/README.md @@ -9,7 +9,7 @@ Java library and samples for [ClearBlade Internet of Things (IoT) Core][product- 1. From the [ClearBlade Migration from Google IoT Core section](https://clearblade.atlassian.net/wiki/spaces/IC/pages/2202664969/Migration+from+Google+IoT+Core) migrate your existing Google IoT Core registries and/or devices into ClearBlade IoT Core or using the - of the ClearBlade IoT Core Console, [create a device registry and devices](https://clearblade.atlassian.net/wiki/spaces/IC/pages/2202206388/Creating+registries+and+devices). + ClearBlade IoT Core Console, [create a device registry and devices](https://clearblade.atlassian.net/wiki/spaces/IC/pages/2202206388/Creating+registries+and+devices). 2. [Add service accounts to a project](https://clearblade.atlassian.net/wiki/spaces/IC/pages/2240675843/Add+service+accounts+to+a+project) and download the json file with your service account’s credentials. diff --git a/clearblade-cloud-iot/samples/README.md b/clearblade-cloud-iot/samples/README.md index 19dac650..a742e385 100644 --- a/clearblade-cloud-iot/samples/README.md +++ b/clearblade-cloud-iot/samples/README.md @@ -7,7 +7,7 @@ ClearBlade IoT Core platform. 1. From the [ClearBlade Migration from Google IoT Core section](https://clearblade.atlassian.net/wiki/spaces/IC/pages/2202664969/Migration+from+Google+IoT+Core) migrate your existing Google IoT Core registries and/or devices into ClearBlade IoT Core or using the - of the ClearBlade IoT Core Console, [create a device registry and devices] (https://clearblade.atlassian.net/wiki/spaces/IC/pages/2202206388/Creating+registries+and+devices). + ClearBlade IoT Core Console, [create a device registry and devices](https://clearblade.atlassian.net/wiki/spaces/IC/pages/2202206388/Creating+registries+and+devices). 2. [Add service accounts to a project](https://clearblade.atlassian.net/wiki/spaces/IC/pages/2240675843/Add+service+accounts+to+a+project) and download the json file with your service account’s credentials. From 1692a49a89dd60f93d535d9a893de9089599334e Mon Sep 17 00:00:00 2001 From: mikoaro Date: Thu, 1 Dec 2022 16:17:22 -0600 Subject: [PATCH 035/151] Updated README with information --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 35edb829..a217a6a9 100644 --- a/README.md +++ b/README.md @@ -26,10 +26,10 @@ Java library and samples for [ClearBlade Internet of Things (IoT) Core][product- ## ClearBlade IoT Core Samples Java -The sample apps demonstrates registry and device creation for ClearBlade IoT Core. These are two of the over fifteen samples codes that come with the library. +The sample apps demonstrates registry and device creation for ClearBlade IoT Core. The [samples](./clearblade-cloud-iot/samples) folder contains all the Java samples that demonstrate an overview of the ClearBlade IoT Core platform. -Note that before you can run the sample, you must configure a Google Cloud -PubSub topic for Cloud IoT as described in [the parent README](../README.md). +Note that before you can run the sample, you must configure your development environment +as described in the Qucikstart above or the [samples](./clearblade-cloud-iot/samples) folder. Before running the samples, you can set the `CLEARBLADE_CONFIGURATION`, `CLEARBLADE_REGISTRY` and `CLEARBLADE_REGION` environment variables to avoid passing them to From ec1ca01ed8d7ff09626156e99841ba45e93feed1 Mon Sep 17 00:00:00 2001 From: mikoaro Date: Thu, 1 Dec 2022 16:17:55 -0600 Subject: [PATCH 036/151] Updated README with information --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index a217a6a9..c9c99e08 100644 --- a/README.md +++ b/README.md @@ -29,7 +29,7 @@ Java library and samples for [ClearBlade Internet of Things (IoT) Core][product- The sample apps demonstrates registry and device creation for ClearBlade IoT Core. The [samples](./clearblade-cloud-iot/samples) folder contains all the Java samples that demonstrate an overview of the ClearBlade IoT Core platform. Note that before you can run the sample, you must configure your development environment -as described in the Qucikstart above or the [samples](./clearblade-cloud-iot/samples) folder. +as described in the Quickstart above or the [samples](./clearblade-cloud-iot/samples) folder. Before running the samples, you can set the `CLEARBLADE_CONFIGURATION`, `CLEARBLADE_REGISTRY` and `CLEARBLADE_REGION` environment variables to avoid passing them to From 12ea679f9395ce25221a5acdb89df3f152848988 Mon Sep 17 00:00:00 2001 From: mikoaro Date: Thu, 1 Dec 2022 16:28:26 -0600 Subject: [PATCH 037/151] Updated README with information --- README.md | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index c9c99e08..dafae494 100644 --- a/README.md +++ b/README.md @@ -5,6 +5,10 @@ Java library and samples for [ClearBlade Internet of Things (IoT) Core][product- - [Product Documentation][product-docs] - [Client Library Documentation][javasdk] +## Supported Java Versions + +Java 11 or above is required for using this client. Java 17 are the best choice for new development. + ## Quickstart 1. From the [ClearBlade Migration from Google IoT Core section](https://clearblade.atlassian.net/wiki/spaces/IC/pages/2202664969/Migration+from+Google+IoT+Core) @@ -14,7 +18,7 @@ Java library and samples for [ClearBlade Internet of Things (IoT) Core][product- 2. [Add service accounts to a project](https://clearblade.atlassian.net/wiki/spaces/IC/pages/2240675843/Add+service+accounts+to+a+project) and download the json file with your service account’s credentials. -3. Use the following to set your environment variables keys: +3. Use the following to set your environment variables keys in your terminal or IDE environment configurations: ``` export CLEARBLADE_CONFIGURATION=/path/to/file.json @@ -29,13 +33,13 @@ Java library and samples for [ClearBlade Internet of Things (IoT) Core][product- The sample apps demonstrates registry and device creation for ClearBlade IoT Core. The [samples](./clearblade-cloud-iot/samples) folder contains all the Java samples that demonstrate an overview of the ClearBlade IoT Core platform. Note that before you can run the sample, you must configure your development environment -as described in the Quickstart above or the [samples](./clearblade-cloud-iot/samples) folder. +and terminal as described in the Quickstart above or the [samples](./clearblade-cloud-iot/samples) folder. Before running the samples, you can set the `CLEARBLADE_CONFIGURATION`, `CLEARBLADE_REGISTRY` and `CLEARBLADE_REGION` environment variables to avoid passing them to the sample every time you run it. -## Setup +### Installation and setup Run the following command to install the libraries and build the sample with Maven: From b94221b453d6f311660ed0b56f9eb5c6e0fb1818 Mon Sep 17 00:00:00 2001 From: mikoaro Date: Thu, 1 Dec 2022 16:30:50 -0600 Subject: [PATCH 038/151] Updated README with information --- README.md | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index dafae494..7a9070f6 100644 --- a/README.md +++ b/README.md @@ -7,7 +7,7 @@ Java library and samples for [ClearBlade Internet of Things (IoT) Core][product- ## Supported Java Versions -Java 11 or above is required for using this client. Java 17 are the best choice for new development. +Java 11 or above is required for using this client. Java 17 is the best choice for new development. ## Quickstart @@ -37,7 +37,8 @@ and terminal as described in the Quickstart above or the [samples](./clearblade- Before running the samples, you can set the `CLEARBLADE_CONFIGURATION`, `CLEARBLADE_REGISTRY` and `CLEARBLADE_REGION` environment variables to avoid passing them to -the sample every time you run it. +the sample every time you run it. Update the `CLEARBLADE_REGISTRY` and +`CLEARBLADE_REGION` environment variables whenever switching to use new registries and regions. ### Installation and setup From 714a8700a1f60aa4c3ab7f4ce3dd1c59d8622835 Mon Sep 17 00:00:00 2001 From: mikoaro Date: Thu, 1 Dec 2022 16:31:14 -0600 Subject: [PATCH 039/151] Updated README with information --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 7a9070f6..0dd20f3b 100644 --- a/README.md +++ b/README.md @@ -38,7 +38,7 @@ and terminal as described in the Quickstart above or the [samples](./clearblade- Before running the samples, you can set the `CLEARBLADE_CONFIGURATION`, `CLEARBLADE_REGISTRY` and `CLEARBLADE_REGION` environment variables to avoid passing them to the sample every time you run it. Update the `CLEARBLADE_REGISTRY` and -`CLEARBLADE_REGION` environment variables whenever switching to use new registries and regions. +`CLEARBLADE_REGION` environment variables when switching to use new registries and regions. ### Installation and setup From 085ab030d319e890333f6a8a3f862b0c22f2800f Mon Sep 17 00:00:00 2001 From: mikoaro Date: Thu, 1 Dec 2022 16:35:23 -0600 Subject: [PATCH 040/151] Updated README with information --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 0dd20f3b..e148540e 100644 --- a/README.md +++ b/README.md @@ -42,7 +42,7 @@ the sample every time you run it. Update the `CLEARBLADE_REGISTRY` and ### Installation and setup -Run the following command to install the libraries and build the sample with +In the [clearblade-cloud-iot](./clearblade-cloud-iot) folder, run the following command to install the libraries and build the sample with Maven: mvn clean install From be3d669ee0520644d50279b982346f29cfddb976 Mon Sep 17 00:00:00 2001 From: mikoaro Date: Thu, 1 Dec 2022 16:45:32 -0600 Subject: [PATCH 041/151] Updated README with information --- README.md | 39 ++++++++++++++++++++++----------------- 1 file changed, 22 insertions(+), 17 deletions(-) diff --git a/README.md b/README.md index e148540e..24a0b40a 100644 --- a/README.md +++ b/README.md @@ -40,7 +40,7 @@ Before running the samples, you can set the `CLEARBLADE_CONFIGURATION`, `CLEARBL the sample every time you run it. Update the `CLEARBLADE_REGISTRY` and `CLEARBLADE_REGION` environment variables when switching to use new registries and regions. -### Installation and setup +## Installation and setup In the [clearblade-cloud-iot](./clearblade-cloud-iot) folder, run the following command to install the libraries and build the sample with Maven: @@ -49,22 +49,27 @@ Maven: ## Running the sample -Quick Start -set an environment variable CLEARBLADE_CONFIGURATION which should point to your service account json file. -set an environment variable CLEARBLADE_REGISTRY which should be the name of registry you want to work upon. -set an environment variable CLEARBLADE_REGION which should point to the region. -Installation -Install this library as a MAVEN dependency in your project. Alternatively, you can get jar file of this library and add it as an External Jar in your project’s build path and can start using the same. -Code samples and snippets -Code samples and snippets live in the samples folder. -Test Cases -Test cases live in the test folder. -Supported JAVA Version -Minimum JAVA 11 version is required to use current library version. Clearblade JAVA SDK library is built using MAVEN version 4.0.0 and Junit Jupiter API version 5.8.2 for test cases to run. -Executing Samples -You have to use following maven command from command prompt :- -mvn exec:java -Dexec.cleanupDaemonThreads=false -Dexec.mainClass=<> -DprojectName=<> -Dlocation=<> -DregistryName=<> -DdeviceName=<> -Parameters to be sent will change, as the sample changes. One has to refer to list of samples to ensure which sample accepts which parameters. +The following command summarizes the sample usage: + +Run registry example: + + mvn exec:java \ + -Dexec.cleanupDaemonThreads=false \ + -Dexec.mainClass="com.clearblade.cloud.iot.v1.samples.createdeviceregistry.SyncCreateDeviceRegistry" \ + -DprojectName="your-project-id" \ + -Dlocation="your-region" \ + -DregistryName="your-registry" + +Run device example: + + mvn exec:java \ + -Dexec.cleanupDaemonThreads=false \ + -Dexec.mainClass="com.clearblade.cloud.iot.v1.samples.createdevice.SyncCreateDevice" \ + -DprojectName="your-project-id" \ + -Dlocation="your-region" \ + -DregistryName="your-registry" \ + -DdeviceName="your-device-id" \ + -DgatewayName="your-gateway-id" [product-docs]: https://clearblade.atlassian.net/wiki/spaces/IC/overview [javasdk]: https://clearblade.atlassian.net/wiki/spaces/IC/pages/2231173185/Java From 0d415a5763853f557b85cdd6875d8090554413ca Mon Sep 17 00:00:00 2001 From: RashmiK14 Date: Fri, 2 Dec 2022 21:35:04 +0530 Subject: [PATCH 042/151] Updated samples for setting region and registry from command line Updated samples for setting region and registry from command line --- .../AsyncBindDeviceToGateway.java | 8 ++++++++ .../SyncBindDeviceToGateway.java | 8 ++++++++ .../v1/samples/createdevice/AsyncCreateDevice.java | 9 +++++++++ .../v1/samples/createdevice/SyncCreateDevice.java | 11 ++++++++++- .../AsyncCreateDeviceRegistry.java | 10 +++++++++- .../SyncCreateDeviceRegistry.java | 11 ++++++++++- .../v1/samples/deletedevice/AsyncDeleteDevice.java | 8 ++++++++ .../v1/samples/deletedevice/SyncDeleteDevice.java | 8 ++++++++ .../AsyncDeleteDeviceRegistry.java | 8 ++++++++ .../SyncDeleteDeviceRegistry.java | 8 ++++++++ .../v1/samples/deviceslist/AsyncDevicesList.java | 8 ++++++++ .../v1/samples/deviceslist/SyncDevicesList.java | 8 ++++++++ .../devicestateslist/AsyncDeviceStatesList.java | 8 ++++++++ .../devicestateslist/SyncDeviceStatesList.java | 8 ++++++++ .../iot/v1/samples/getdevice/AsyncGetDevice.java | 8 ++++++++ .../iot/v1/samples/getdevice/SyncGetDevice.java | 9 +++++++++ .../getdeviceregistry/AsyncGetDeviceRegistry.java | 8 ++++++++ .../getdeviceregistry/SyncGetDeviceRegistry.java | 8 ++++++++ .../AsyncListDeviceConfigVersions.java | 8 ++++++++ .../SyncListDeviceConfigVersions.java | 8 ++++++++ .../AsyncListDeviceRegistries.java | 5 +++++ .../SyncListDeviceRegistries.java | 5 +++++ .../AsyncModifyCloudToDeviceConfig.java | 8 ++++++++ .../SyncModifyCloudToDeviceConfig.java | 8 ++++++++ .../AsyncSendCommandToDevice.java | 8 ++++++++ .../SyncSendCommandToDevice.java | 8 ++++++++ .../AsyncUnbindDeviceFromGateway.java | 8 ++++++++ .../SyncUnbindDeviceFromGateway.java | 8 ++++++++ .../v1/samples/updatedevice/AsyncUpdateDevice.java | 14 +++++++++++++- .../v1/samples/updatedevice/SyncUpdateDevice.java | 13 +++++++++++++ .../AsyncUpdateDeviceRegistry.java | 8 ++++++++ .../SyncUpdateDeviceRegistry.java | 8 ++++++++ 32 files changed, 267 insertions(+), 4 deletions(-) diff --git a/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/binddevicetogateway/AsyncBindDeviceToGateway.java b/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/binddevicetogateway/AsyncBindDeviceToGateway.java index febc205a..f1299d77 100644 --- a/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/binddevicetogateway/AsyncBindDeviceToGateway.java +++ b/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/binddevicetogateway/AsyncBindDeviceToGateway.java @@ -4,6 +4,7 @@ import com.clearblade.cloud.iot.v1.binddevicetogateway.BindDeviceToGatewayRequest; import com.clearblade.cloud.iot.v1.binddevicetogateway.BindDeviceToGatewayResponse; import com.clearblade.cloud.iot.v1.registrytypes.RegistryName; +import com.clearblade.cloud.iot.v1.utils.ConfigParameters; public class AsyncBindDeviceToGateway { public static String PROJECT = ""; @@ -11,6 +12,7 @@ public class AsyncBindDeviceToGateway { public static String REGISTRY = ""; public static String GATEWAY = ""; public static String DEVICE = ""; + static ConfigParameters configParameters = ConfigParameters.getInstance(); public static void main(String[] args) { PROJECT = System.getProperty("projectName"); @@ -18,6 +20,12 @@ public static void main(String[] args) { REGISTRY = System.getProperty("registryName"); GATEWAY = System.getProperty("gatewayName"); DEVICE = System.getProperty("deviceName"); + if(REGISTRY != null) { + configParameters.setRegistry(REGISTRY); + } + if(LOCATION != null) { + configParameters.setRegion(LOCATION); + } asyncBindDeviceToGateway(); } diff --git a/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/binddevicetogateway/SyncBindDeviceToGateway.java b/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/binddevicetogateway/SyncBindDeviceToGateway.java index ca0017e7..5a4eecff 100644 --- a/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/binddevicetogateway/SyncBindDeviceToGateway.java +++ b/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/binddevicetogateway/SyncBindDeviceToGateway.java @@ -4,6 +4,7 @@ import com.clearblade.cloud.iot.v1.binddevicetogateway.BindDeviceToGatewayRequest; import com.clearblade.cloud.iot.v1.binddevicetogateway.BindDeviceToGatewayResponse; import com.clearblade.cloud.iot.v1.registrytypes.RegistryName; +import com.clearblade.cloud.iot.v1.utils.ConfigParameters; public class SyncBindDeviceToGateway { public static String PROJECT = ""; @@ -11,6 +12,7 @@ public class SyncBindDeviceToGateway { public static String REGISTRY = ""; public static String GATEWAY = ""; public static String DEVICE = ""; + static ConfigParameters configParameters = ConfigParameters.getInstance(); public static void main(String[] args) { PROJECT = System.getProperty("projectName"); @@ -18,6 +20,12 @@ public static void main(String[] args) { REGISTRY = System.getProperty("registryName"); GATEWAY = System.getProperty("gatewayName"); DEVICE = System.getProperty("deviceName"); + if(REGISTRY != null) { + configParameters.setRegistry(REGISTRY); + } + if(LOCATION != null) { + configParameters.setRegion(LOCATION); + } syncBindDeviceToGateway(); } diff --git a/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/createdevice/AsyncCreateDevice.java b/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/createdevice/AsyncCreateDevice.java index a2dc4e41..7f919e7d 100644 --- a/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/createdevice/AsyncCreateDevice.java +++ b/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/createdevice/AsyncCreateDevice.java @@ -11,6 +11,7 @@ import com.clearblade.cloud.iot.v1.devicetypes.GatewayType; import com.clearblade.cloud.iot.v1.devicetypes.Status; import com.clearblade.cloud.iot.v1.registrytypes.RegistryName; +import com.clearblade.cloud.iot.v1.utils.ConfigParameters; import com.clearblade.cloud.iot.v1.utils.LogLevel; public class AsyncCreateDevice { @@ -19,12 +20,20 @@ public class AsyncCreateDevice { public static String REGISTRY = ""; public static String DEVICE = ""; public static String NUMID = ""; + static ConfigParameters configParameters = ConfigParameters.getInstance(); + public static void main(String[] args) { PROJECT = System.getProperty("projectName"); LOCATION = System.getProperty("location"); REGISTRY = System.getProperty("registryName"); DEVICE = System.getProperty("deviceName"); NUMID = System.getProperty("numId"); + if(REGISTRY != null) { + configParameters.setRegistry(REGISTRY); + } + if(LOCATION != null) { + configParameters.setRegion(LOCATION); + } asyncCreateDevice(); } diff --git a/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/createdevice/SyncCreateDevice.java b/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/createdevice/SyncCreateDevice.java index 1eb62d8c..32b2b5cf 100644 --- a/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/createdevice/SyncCreateDevice.java +++ b/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/createdevice/SyncCreateDevice.java @@ -11,6 +11,7 @@ import com.clearblade.cloud.iot.v1.devicetypes.GatewayType; import com.clearblade.cloud.iot.v1.devicetypes.Status; import com.clearblade.cloud.iot.v1.registrytypes.RegistryName; +import com.clearblade.cloud.iot.v1.utils.ConfigParameters; import com.clearblade.cloud.iot.v1.utils.LogLevel; public class SyncCreateDevice { @@ -20,12 +21,20 @@ public class SyncCreateDevice { public static String REGISTRY = ""; public static String DEVICE = ""; public static String NUMID = ""; - public static void main(String[] args) { + static ConfigParameters configParameters = ConfigParameters.getInstance(); + + public static void main(String[] args){ PROJECT = System.getProperty("projectName"); LOCATION = System.getProperty("location"); REGISTRY = System.getProperty("registryName"); DEVICE = System.getProperty("deviceName"); NUMID = System.getProperty("numId"); + if(REGISTRY != null) { + configParameters.setRegistry(REGISTRY); + } + if(LOCATION != null) { + configParameters.setRegion(LOCATION); + } syncCreateDevice(); } diff --git a/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/createdeviceregistry/AsyncCreateDeviceRegistry.java b/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/createdeviceregistry/AsyncCreateDeviceRegistry.java index 04a09fad..b5ead80a 100644 --- a/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/createdeviceregistry/AsyncCreateDeviceRegistry.java +++ b/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/createdeviceregistry/AsyncCreateDeviceRegistry.java @@ -4,16 +4,24 @@ import com.clearblade.cloud.iot.v1.createdeviceregistry.CreateDeviceRegistryRequest; import com.clearblade.cloud.iot.v1.registrytypes.DeviceRegistry; import com.clearblade.cloud.iot.v1.registrytypes.LocationName; +import com.clearblade.cloud.iot.v1.utils.ConfigParameters; public class AsyncCreateDeviceRegistry { public static String PROJECT = ""; public static String LOCATION = ""; public static String REGISTRY = ""; + static ConfigParameters configParameters = ConfigParameters.getInstance(); public static void main(String[] args) { PROJECT = System.getProperty("projectName"); LOCATION = System.getProperty("location"); REGISTRY = System.getProperty("registryName"); - asyncCreateDeviceRegistry(); + if(REGISTRY != null) { + configParameters.setRegistry(REGISTRY); + } + if(LOCATION != null) { + configParameters.setRegion(LOCATION); + } + asyncCreateDeviceRegistry(); } public static void asyncCreateDeviceRegistry() { diff --git a/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/createdeviceregistry/SyncCreateDeviceRegistry.java b/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/createdeviceregistry/SyncCreateDeviceRegistry.java index 5f238890..59da8a19 100644 --- a/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/createdeviceregistry/SyncCreateDeviceRegistry.java +++ b/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/createdeviceregistry/SyncCreateDeviceRegistry.java @@ -4,17 +4,26 @@ import com.clearblade.cloud.iot.v1.createdeviceregistry.CreateDeviceRegistryRequest; import com.clearblade.cloud.iot.v1.registrytypes.DeviceRegistry; import com.clearblade.cloud.iot.v1.registrytypes.LocationName; +import com.clearblade.cloud.iot.v1.utils.ConfigParameters; public class SyncCreateDeviceRegistry { public static String PROJECT = ""; public static String LOCATION = ""; public static String REGISTRY = ""; + static ConfigParameters configParameters = ConfigParameters.getInstance(); + public static void main(String[] args) { PROJECT = System.getProperty("projectName"); LOCATION = System.getProperty("location"); REGISTRY = System.getProperty("registryName"); - syncCreateDeviceRegistry(); + if(REGISTRY != null) { + configParameters.setRegistry(REGISTRY); + } + if(LOCATION != null) { + configParameters.setRegion(LOCATION); + } + syncCreateDeviceRegistry(); } public static void syncCreateDeviceRegistry() { diff --git a/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/deletedevice/AsyncDeleteDevice.java b/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/deletedevice/AsyncDeleteDevice.java index d4935750..1e6d71a8 100644 --- a/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/deletedevice/AsyncDeleteDevice.java +++ b/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/deletedevice/AsyncDeleteDevice.java @@ -3,6 +3,7 @@ import com.clearblade.cloud.iot.v1.DeviceManagerAsyncClient; import com.clearblade.cloud.iot.v1.deletedevice.DeleteDeviceRequest; import com.clearblade.cloud.iot.v1.devicetypes.DeviceName; +import com.clearblade.cloud.iot.v1.utils.ConfigParameters; public class AsyncDeleteDevice { @@ -10,12 +11,19 @@ public class AsyncDeleteDevice { public static String LOCATION = ""; public static String REGISTRY = ""; public static String DEVICE = ""; + static ConfigParameters configParameters = ConfigParameters.getInstance(); public static void main(String[] args) { PROJECT = System.getProperty("projectName"); LOCATION = System.getProperty("location"); REGISTRY = System.getProperty("registryName"); DEVICE = System.getProperty("deviceName"); + if(REGISTRY != null) { + configParameters.setRegistry(REGISTRY); + } + if(LOCATION != null) { + configParameters.setRegion(LOCATION); + } asyncDeleteDevice(); } diff --git a/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/deletedevice/SyncDeleteDevice.java b/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/deletedevice/SyncDeleteDevice.java index 82e7ba2d..12b3825a 100644 --- a/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/deletedevice/SyncDeleteDevice.java +++ b/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/deletedevice/SyncDeleteDevice.java @@ -3,6 +3,7 @@ import com.clearblade.cloud.iot.v1.DeviceManagerClient; import com.clearblade.cloud.iot.v1.deletedevice.DeleteDeviceRequest; import com.clearblade.cloud.iot.v1.devicetypes.DeviceName; +import com.clearblade.cloud.iot.v1.utils.ConfigParameters; public class SyncDeleteDevice { @@ -10,12 +11,19 @@ public class SyncDeleteDevice { public static String LOCATION = ""; public static String REGISTRY = ""; public static String DEVICE = ""; + static ConfigParameters configParameters = ConfigParameters.getInstance(); public static void main(String[] args) { PROJECT = System.getProperty("projectName"); LOCATION = System.getProperty("location"); REGISTRY = System.getProperty("registryName"); DEVICE = System.getProperty("deviceName"); + if(REGISTRY != null) { + configParameters.setRegistry(REGISTRY); + } + if(LOCATION != null) { + configParameters.setRegion(LOCATION); + } syncDeleteDevice(); } diff --git a/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/deletedeviceregistry/AsyncDeleteDeviceRegistry.java b/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/deletedeviceregistry/AsyncDeleteDeviceRegistry.java index 2dba4ccc..cf60f960 100644 --- a/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/deletedeviceregistry/AsyncDeleteDeviceRegistry.java +++ b/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/deletedeviceregistry/AsyncDeleteDeviceRegistry.java @@ -3,17 +3,25 @@ import com.clearblade.cloud.iot.v1.DeviceManagerAsyncClient; import com.clearblade.cloud.iot.v1.deletedeviceregistry.DeleteDeviceRegistryRequest; import com.clearblade.cloud.iot.v1.registrytypes.RegistryName; +import com.clearblade.cloud.iot.v1.utils.ConfigParameters; public class AsyncDeleteDeviceRegistry { public static String PROJECT = ""; public static String LOCATION = ""; public static String REGISTRY = ""; + static ConfigParameters configParameters = ConfigParameters.getInstance(); public static void main(String[] args) throws Exception { PROJECT = System.getProperty("projectName"); LOCATION = System.getProperty("location"); REGISTRY = System.getProperty("registryName"); + if(REGISTRY != null) { + configParameters.setRegistry(REGISTRY); + } + if(LOCATION != null) { + configParameters.setRegion(LOCATION); + } asyncDeleteDeviceRegistry(); } diff --git a/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/deletedeviceregistry/SyncDeleteDeviceRegistry.java b/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/deletedeviceregistry/SyncDeleteDeviceRegistry.java index 4c7cfaa9..a7f8e150 100644 --- a/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/deletedeviceregistry/SyncDeleteDeviceRegistry.java +++ b/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/deletedeviceregistry/SyncDeleteDeviceRegistry.java @@ -3,17 +3,25 @@ import com.clearblade.cloud.iot.v1.DeviceManagerClient; import com.clearblade.cloud.iot.v1.deletedeviceregistry.DeleteDeviceRegistryRequest; import com.clearblade.cloud.iot.v1.registrytypes.RegistryName; +import com.clearblade.cloud.iot.v1.utils.ConfigParameters; public class SyncDeleteDeviceRegistry { public static String PROJECT = ""; public static String LOCATION = ""; public static String REGISTRY = ""; + static ConfigParameters configParameters = ConfigParameters.getInstance(); public static void main(String[] args) throws Exception { PROJECT = System.getProperty("projectName"); LOCATION = System.getProperty("location"); REGISTRY = System.getProperty("registryName"); + if(REGISTRY != null) { + configParameters.setRegistry(REGISTRY); + } + if(LOCATION != null) { + configParameters.setRegion(LOCATION); + } syncDeleteDeviceRegistry(); } diff --git a/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/deviceslist/AsyncDevicesList.java b/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/deviceslist/AsyncDevicesList.java index f2f4cc91..7b86b418 100644 --- a/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/deviceslist/AsyncDevicesList.java +++ b/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/deviceslist/AsyncDevicesList.java @@ -7,17 +7,25 @@ import com.clearblade.cloud.iot.v1.devicetypes.GatewayListOptions; import com.clearblade.cloud.iot.v1.devicetypes.GatewayType; import com.clearblade.cloud.iot.v1.registrytypes.RegistryName; +import com.clearblade.cloud.iot.v1.utils.ConfigParameters; public class AsyncDevicesList { public static String PROJECT = ""; public static String LOCATION = ""; public static String REGISTRY = ""; + static ConfigParameters configParameters = ConfigParameters.getInstance(); public static void main(String[] args) { PROJECT = System.getProperty("projectName"); LOCATION = System.getProperty("location"); REGISTRY = System.getProperty("registryName"); + if(REGISTRY != null) { + configParameters.setRegistry(REGISTRY); + } + if(LOCATION != null) { + configParameters.setRegion(LOCATION); + } asyncDevicesList(); } diff --git a/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/deviceslist/SyncDevicesList.java b/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/deviceslist/SyncDevicesList.java index 79a0c519..8ed04f71 100644 --- a/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/deviceslist/SyncDevicesList.java +++ b/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/deviceslist/SyncDevicesList.java @@ -7,16 +7,24 @@ import com.clearblade.cloud.iot.v1.devicetypes.GatewayListOptions; import com.clearblade.cloud.iot.v1.devicetypes.GatewayType; import com.clearblade.cloud.iot.v1.registrytypes.RegistryName; +import com.clearblade.cloud.iot.v1.utils.ConfigParameters; public class SyncDevicesList { public static String PROJECT = ""; public static String LOCATION = ""; public static String REGISTRY = ""; + static ConfigParameters configParameters = ConfigParameters.getInstance(); public static void main(String[] args) { PROJECT = System.getProperty("projectName"); LOCATION = System.getProperty("location"); REGISTRY = System.getProperty("registryName"); + if(REGISTRY != null) { + configParameters.setRegistry(REGISTRY); + } + if(LOCATION != null) { + configParameters.setRegion(LOCATION); + } syncDevicesList(); } diff --git a/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/devicestateslist/AsyncDeviceStatesList.java b/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/devicestateslist/AsyncDeviceStatesList.java index 039453c1..46af7fd4 100644 --- a/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/devicestateslist/AsyncDeviceStatesList.java +++ b/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/devicestateslist/AsyncDeviceStatesList.java @@ -5,6 +5,7 @@ import com.clearblade.cloud.iot.v1.devicestateslist.ListDeviceStatesResponse; import com.clearblade.cloud.iot.v1.devicetypes.DeviceName; import com.clearblade.cloud.iot.v1.devicetypes.DeviceState; +import com.clearblade.cloud.iot.v1.utils.ConfigParameters; public class AsyncDeviceStatesList { @@ -12,12 +13,19 @@ public class AsyncDeviceStatesList { public static String LOCATION = ""; public static String REGISTRY = ""; public static String DEVICE = ""; + static ConfigParameters configParameters = ConfigParameters.getInstance(); public static void main(String[] args) { PROJECT = System.getProperty("projectName"); LOCATION = System.getProperty("location"); REGISTRY = System.getProperty("registryName"); DEVICE = System.getProperty("deviceName"); + if(REGISTRY != null) { + configParameters.setRegistry(REGISTRY); + } + if(LOCATION != null) { + configParameters.setRegion(LOCATION); + } asyncDeviceStatesList(); } diff --git a/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/devicestateslist/SyncDeviceStatesList.java b/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/devicestateslist/SyncDeviceStatesList.java index a934c888..ae871824 100644 --- a/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/devicestateslist/SyncDeviceStatesList.java +++ b/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/devicestateslist/SyncDeviceStatesList.java @@ -5,18 +5,26 @@ import com.clearblade.cloud.iot.v1.devicestateslist.ListDeviceStatesResponse; import com.clearblade.cloud.iot.v1.devicetypes.DeviceName; import com.clearblade.cloud.iot.v1.devicetypes.DeviceState; +import com.clearblade.cloud.iot.v1.utils.ConfigParameters; public class SyncDeviceStatesList { public static String PROJECT = ""; public static String LOCATION = ""; public static String REGISTRY = ""; public static String DEVICE = ""; + static ConfigParameters configParameters = ConfigParameters.getInstance(); public static void main(String[] args) { PROJECT = System.getProperty("projectName"); LOCATION = System.getProperty("location"); REGISTRY = System.getProperty("registryName"); DEVICE = System.getProperty("deviceName"); + if(REGISTRY != null) { + configParameters.setRegistry(REGISTRY); + } + if(LOCATION != null) { + configParameters.setRegion(LOCATION); + } syncDeviceStatesList(); } diff --git a/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/getdevice/AsyncGetDevice.java b/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/getdevice/AsyncGetDevice.java index b54c7802..a3bd2ee1 100644 --- a/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/getdevice/AsyncGetDevice.java +++ b/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/getdevice/AsyncGetDevice.java @@ -5,18 +5,26 @@ import com.clearblade.cloud.iot.v1.devicetypes.DeviceName; import com.clearblade.cloud.iot.v1.devicetypes.FieldMask; import com.clearblade.cloud.iot.v1.getdevice.GetDeviceRequest; +import com.clearblade.cloud.iot.v1.utils.ConfigParameters; public class AsyncGetDevice { public static String PROJECT = ""; public static String LOCATION = ""; public static String REGISTRY = ""; public static String DEVICE = ""; + static ConfigParameters configParameters = ConfigParameters.getInstance(); public static void main(String[] args) { PROJECT = System.getProperty("projectName"); LOCATION = System.getProperty("location"); REGISTRY = System.getProperty("registryName"); DEVICE = System.getProperty("deviceName"); + if(REGISTRY != null) { + configParameters.setRegistry(REGISTRY); + } + if(LOCATION != null) { + configParameters.setRegion(LOCATION); + } asyncGetDevice(); } diff --git a/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/getdevice/SyncGetDevice.java b/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/getdevice/SyncGetDevice.java index 25e3e051..6c656d77 100644 --- a/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/getdevice/SyncGetDevice.java +++ b/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/getdevice/SyncGetDevice.java @@ -5,17 +5,26 @@ import com.clearblade.cloud.iot.v1.devicetypes.DeviceName; import com.clearblade.cloud.iot.v1.devicetypes.FieldMask; import com.clearblade.cloud.iot.v1.getdevice.GetDeviceRequest; +import com.clearblade.cloud.iot.v1.utils.ConfigParameters; public class SyncGetDevice { public static String PROJECT = ""; public static String LOCATION = ""; public static String REGISTRY = ""; public static String DEVICE = ""; + static ConfigParameters configParameters = ConfigParameters.getInstance(); + public static void main(String[] args) { PROJECT = System.getProperty("projectName"); LOCATION = System.getProperty("location"); REGISTRY = System.getProperty("registryName"); DEVICE = System.getProperty("deviceName"); + if(REGISTRY != null) { + configParameters.setRegistry(REGISTRY); + } + if(LOCATION != null) { + configParameters.setRegion(LOCATION); + } syncGetDevice(); } diff --git a/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/getdeviceregistry/AsyncGetDeviceRegistry.java b/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/getdeviceregistry/AsyncGetDeviceRegistry.java index c1f20e7d..678b8584 100644 --- a/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/getdeviceregistry/AsyncGetDeviceRegistry.java +++ b/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/getdeviceregistry/AsyncGetDeviceRegistry.java @@ -4,16 +4,24 @@ import com.clearblade.cloud.iot.v1.getdeviceregistry.GetDeviceRegistryRequest; import com.clearblade.cloud.iot.v1.registrytypes.DeviceRegistry; import com.clearblade.cloud.iot.v1.registrytypes.RegistryName; +import com.clearblade.cloud.iot.v1.utils.ConfigParameters; public class AsyncGetDeviceRegistry { public static String PROJECT = ""; public static String LOCATION = ""; public static String REGISTRY = ""; + static ConfigParameters configParameters = ConfigParameters.getInstance(); public static void main(String[] args) { PROJECT = System.getProperty("projectName"); LOCATION = System.getProperty("location"); REGISTRY = System.getProperty("registryName"); + if(REGISTRY != null) { + configParameters.setRegistry(REGISTRY); + } + if(LOCATION != null) { + configParameters.setRegion(LOCATION); + } asyncGetDeviceRegistry(); } diff --git a/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/getdeviceregistry/SyncGetDeviceRegistry.java b/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/getdeviceregistry/SyncGetDeviceRegistry.java index 2bced32f..edd17846 100644 --- a/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/getdeviceregistry/SyncGetDeviceRegistry.java +++ b/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/getdeviceregistry/SyncGetDeviceRegistry.java @@ -4,16 +4,24 @@ import com.clearblade.cloud.iot.v1.getdeviceregistry.GetDeviceRegistryRequest; import com.clearblade.cloud.iot.v1.registrytypes.DeviceRegistry; import com.clearblade.cloud.iot.v1.registrytypes.RegistryName; +import com.clearblade.cloud.iot.v1.utils.ConfigParameters; public class SyncGetDeviceRegistry { public static String PROJECT = ""; public static String LOCATION = ""; public static String REGISTRY = ""; + static ConfigParameters configParameters = ConfigParameters.getInstance(); public static void main(String[] args) { PROJECT = System.getProperty("projectName"); LOCATION = System.getProperty("location"); REGISTRY = System.getProperty("registryName"); + if(REGISTRY != null) { + configParameters.setRegistry(REGISTRY); + } + if(LOCATION != null) { + configParameters.setRegion(LOCATION); + } syncGetDeviceRegistry(); } diff --git a/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/listdeviceconfigversions/AsyncListDeviceConfigVersions.java b/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/listdeviceconfigversions/AsyncListDeviceConfigVersions.java index ef62136d..286d82a7 100644 --- a/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/listdeviceconfigversions/AsyncListDeviceConfigVersions.java +++ b/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/listdeviceconfigversions/AsyncListDeviceConfigVersions.java @@ -5,6 +5,7 @@ import com.clearblade.cloud.iot.v1.devicetypes.DeviceName; import com.clearblade.cloud.iot.v1.listdeviceconfigversions.ListDeviceConfigVersionsRequest; import com.clearblade.cloud.iot.v1.listdeviceconfigversions.ListDeviceConfigVersionsResponse; +import com.clearblade.cloud.iot.v1.utils.ConfigParameters; public class AsyncListDeviceConfigVersions { @@ -13,6 +14,7 @@ public class AsyncListDeviceConfigVersions { public static String REGISTRY = ""; public static String DEVICE = ""; public static String NUMVERSION = ""; + static ConfigParameters configParameters = ConfigParameters.getInstance(); public static void main(String[] args) { PROJECT = System.getProperty("projectName"); @@ -20,6 +22,12 @@ public static void main(String[] args) { REGISTRY = System.getProperty("registryName"); DEVICE = System.getProperty("deviceName"); NUMVERSION = System.getProperty("numVersion"); + if(REGISTRY != null) { + configParameters.setRegistry(REGISTRY); + } + if(LOCATION != null) { + configParameters.setRegion(LOCATION); + } asyncDevicesConfigVersionsList(); } diff --git a/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/listdeviceconfigversions/SyncListDeviceConfigVersions.java b/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/listdeviceconfigversions/SyncListDeviceConfigVersions.java index 9bfe7656..cda86857 100644 --- a/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/listdeviceconfigversions/SyncListDeviceConfigVersions.java +++ b/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/listdeviceconfigversions/SyncListDeviceConfigVersions.java @@ -5,6 +5,7 @@ import com.clearblade.cloud.iot.v1.devicetypes.DeviceName; import com.clearblade.cloud.iot.v1.listdeviceconfigversions.ListDeviceConfigVersionsRequest; import com.clearblade.cloud.iot.v1.listdeviceconfigversions.ListDeviceConfigVersionsResponse; +import com.clearblade.cloud.iot.v1.utils.ConfigParameters; public class SyncListDeviceConfigVersions { @@ -13,6 +14,7 @@ public class SyncListDeviceConfigVersions { public static String REGISTRY = ""; public static String DEVICE = ""; public static String NUMVERSION = ""; + static ConfigParameters configParameters = ConfigParameters.getInstance(); public static void main(String[] args) { PROJECT = System.getProperty("projectName"); @@ -20,6 +22,12 @@ public static void main(String[] args) { REGISTRY = System.getProperty("registryName"); DEVICE = System.getProperty("deviceName"); NUMVERSION = System.getProperty("numVersion"); + if(REGISTRY != null) { + configParameters.setRegistry(REGISTRY); + } + if(LOCATION != null) { + configParameters.setRegion(LOCATION); + } syncDevicesConfigVersionsList(); } diff --git a/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/listdeviceregistries/AsyncListDeviceRegistries.java b/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/listdeviceregistries/AsyncListDeviceRegistries.java index 60a4091b..f1aa88c1 100644 --- a/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/listdeviceregistries/AsyncListDeviceRegistries.java +++ b/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/listdeviceregistries/AsyncListDeviceRegistries.java @@ -5,14 +5,19 @@ import com.clearblade.cloud.iot.v1.listdeviceregistries.ListDeviceRegistriesResponse; import com.clearblade.cloud.iot.v1.registrytypes.DeviceRegistry; import com.clearblade.cloud.iot.v1.registrytypes.LocationName; +import com.clearblade.cloud.iot.v1.utils.ConfigParameters; public class AsyncListDeviceRegistries { public static String PROJECT = ""; public static String LOCATION = ""; + static ConfigParameters configParameters = ConfigParameters.getInstance(); public static void main(String[] args) throws Exception{ PROJECT = System.getProperty("projectName"); LOCATION = System.getProperty("location"); + if(LOCATION != null) { + configParameters.setRegion(LOCATION); + } asyncListDeviceRegistries(); } diff --git a/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/listdeviceregistries/SyncListDeviceRegistries.java b/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/listdeviceregistries/SyncListDeviceRegistries.java index ebd2fc0b..153fe9ba 100644 --- a/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/listdeviceregistries/SyncListDeviceRegistries.java +++ b/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/listdeviceregistries/SyncListDeviceRegistries.java @@ -5,14 +5,19 @@ import com.clearblade.cloud.iot.v1.listdeviceregistries.ListDeviceRegistriesResponse; import com.clearblade.cloud.iot.v1.registrytypes.DeviceRegistry; import com.clearblade.cloud.iot.v1.registrytypes.LocationName; +import com.clearblade.cloud.iot.v1.utils.ConfigParameters; public class SyncListDeviceRegistries { public static String PROJECT = ""; public static String LOCATION = ""; + static ConfigParameters configParameters = ConfigParameters.getInstance(); public static void main(String[] args) throws Exception{ PROJECT = System.getProperty("projectName"); LOCATION = System.getProperty("location"); + if(LOCATION != null) { + configParameters.setRegion(LOCATION); + } syncListDeviceRegistries(); } diff --git a/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/modifycloudtodeviceconfig/AsyncModifyCloudToDeviceConfig.java b/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/modifycloudtodeviceconfig/AsyncModifyCloudToDeviceConfig.java index 9467b934..5a885be0 100644 --- a/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/modifycloudtodeviceconfig/AsyncModifyCloudToDeviceConfig.java +++ b/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/modifycloudtodeviceconfig/AsyncModifyCloudToDeviceConfig.java @@ -5,6 +5,7 @@ import com.clearblade.cloud.iot.v1.devicetypes.DeviceName; import com.clearblade.cloud.iot.v1.modifycloudtodeviceconfig.ModifyCloudToDeviceConfigRequest; import com.clearblade.cloud.iot.v1.utils.ByteString; +import com.clearblade.cloud.iot.v1.utils.ConfigParameters; public class AsyncModifyCloudToDeviceConfig { @@ -14,6 +15,7 @@ public class AsyncModifyCloudToDeviceConfig { public static String DEVICE = ""; public static String BINARYDATA = ""; public static String VERSIONTOUPDATE = ""; + static ConfigParameters configParameters = ConfigParameters.getInstance(); public static void main(String[] args) { PROJECT = System.getProperty("projectName"); @@ -22,6 +24,12 @@ public static void main(String[] args) { DEVICE = System.getProperty("deviceName"); BINARYDATA = System.getProperty("binaryData"); VERSIONTOUPDATE = System.getProperty("versionToUpdate"); + if(REGISTRY != null) { + configParameters.setRegistry(REGISTRY); + } + if(LOCATION != null) { + configParameters.setRegion(LOCATION); + } asyncModifyCloudToDeviceConfig(); } diff --git a/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/modifycloudtodeviceconfig/SyncModifyCloudToDeviceConfig.java b/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/modifycloudtodeviceconfig/SyncModifyCloudToDeviceConfig.java index 37e07cb7..7dd8456f 100644 --- a/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/modifycloudtodeviceconfig/SyncModifyCloudToDeviceConfig.java +++ b/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/modifycloudtodeviceconfig/SyncModifyCloudToDeviceConfig.java @@ -5,6 +5,7 @@ import com.clearblade.cloud.iot.v1.devicetypes.DeviceName; import com.clearblade.cloud.iot.v1.modifycloudtodeviceconfig.ModifyCloudToDeviceConfigRequest; import com.clearblade.cloud.iot.v1.utils.ByteString; +import com.clearblade.cloud.iot.v1.utils.ConfigParameters; public class SyncModifyCloudToDeviceConfig { public static String PROJECT = ""; @@ -13,6 +14,7 @@ public class SyncModifyCloudToDeviceConfig { public static String DEVICE = ""; public static String BINARYDATA = ""; public static String VERSIONTOUPDATE = ""; + static ConfigParameters configParameters = ConfigParameters.getInstance(); public static void main(String[] args) { PROJECT = System.getProperty("projectName"); @@ -21,6 +23,12 @@ public static void main(String[] args) { DEVICE = System.getProperty("deviceName"); BINARYDATA = System.getProperty("binaryData"); VERSIONTOUPDATE = System.getProperty("versionToUpdate"); + if(REGISTRY != null) { + configParameters.setRegistry(REGISTRY); + } + if(LOCATION != null) { + configParameters.setRegion(LOCATION); + } syncModifyCloudToDeviceConfig(); } diff --git a/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/sendcommandtodevice/AsyncSendCommandToDevice.java b/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/sendcommandtodevice/AsyncSendCommandToDevice.java index 5a509eb8..96902bcd 100644 --- a/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/sendcommandtodevice/AsyncSendCommandToDevice.java +++ b/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/sendcommandtodevice/AsyncSendCommandToDevice.java @@ -5,6 +5,7 @@ import com.clearblade.cloud.iot.v1.sendcommandtodevice.SendCommandToDeviceRequest; import com.clearblade.cloud.iot.v1.sendcommandtodevice.SendCommandToDeviceResponse; import com.clearblade.cloud.iot.v1.utils.ByteString; +import com.clearblade.cloud.iot.v1.utils.ConfigParameters; public class AsyncSendCommandToDevice { @@ -14,6 +15,7 @@ public class AsyncSendCommandToDevice { public static String DEVICE = ""; public static String BINARYDATA = ""; public static String SUBFOLDER = ""; + static ConfigParameters configParameters = ConfigParameters.getInstance(); public static void main(String[] args) { PROJECT = System.getProperty("projectName"); @@ -22,6 +24,12 @@ public static void main(String[] args) { DEVICE = System.getProperty("deviceName"); BINARYDATA = System.getProperty("binaryData"); SUBFOLDER = System.getProperty("subFolder"); + if(REGISTRY != null) { + configParameters.setRegistry(REGISTRY); + } + if(LOCATION != null) { + configParameters.setRegion(LOCATION); + } asyncSendCommandToDevice(); } diff --git a/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/sendcommandtodevice/SyncSendCommandToDevice.java b/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/sendcommandtodevice/SyncSendCommandToDevice.java index 996f88ce..0fce3ca4 100644 --- a/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/sendcommandtodevice/SyncSendCommandToDevice.java +++ b/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/sendcommandtodevice/SyncSendCommandToDevice.java @@ -5,6 +5,7 @@ import com.clearblade.cloud.iot.v1.sendcommandtodevice.SendCommandToDeviceRequest; import com.clearblade.cloud.iot.v1.sendcommandtodevice.SendCommandToDeviceResponse; import com.clearblade.cloud.iot.v1.utils.ByteString; +import com.clearblade.cloud.iot.v1.utils.ConfigParameters; public class SyncSendCommandToDevice { @@ -14,6 +15,7 @@ public class SyncSendCommandToDevice { public static String DEVICE = ""; public static String BINARYDATA = ""; public static String SUBFOLDER = ""; + static ConfigParameters configParameters = ConfigParameters.getInstance(); public static void main(String[] args) { PROJECT = System.getProperty("projectName"); @@ -22,6 +24,12 @@ public static void main(String[] args) { DEVICE = System.getProperty("deviceName"); BINARYDATA = System.getProperty("binaryData"); SUBFOLDER = System.getProperty("subFolder"); + if(REGISTRY != null) { + configParameters.setRegistry(REGISTRY); + } + if(LOCATION != null) { + configParameters.setRegion(LOCATION); + } syncSendCommandToDevice(); } diff --git a/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/unbinddevicefromgateway/AsyncUnbindDeviceFromGateway.java b/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/unbinddevicefromgateway/AsyncUnbindDeviceFromGateway.java index 5f6240e3..4d503cef 100644 --- a/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/unbinddevicefromgateway/AsyncUnbindDeviceFromGateway.java +++ b/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/unbinddevicefromgateway/AsyncUnbindDeviceFromGateway.java @@ -4,6 +4,7 @@ import com.clearblade.cloud.iot.v1.registrytypes.RegistryName; import com.clearblade.cloud.iot.v1.unbinddevicefromgateway.UnbindDeviceFromGatewayRequest; import com.clearblade.cloud.iot.v1.unbinddevicefromgateway.UnbindDeviceFromGatewayResponse; +import com.clearblade.cloud.iot.v1.utils.ConfigParameters; public class AsyncUnbindDeviceFromGateway { public static String PROJECT = ""; @@ -11,6 +12,7 @@ public class AsyncUnbindDeviceFromGateway { public static String REGISTRY = ""; public static String GATEWAY = ""; public static String DEVICE = ""; + static ConfigParameters configParameters = ConfigParameters.getInstance(); public static void main(String[] args) { PROJECT = System.getProperty("projectName"); @@ -18,6 +20,12 @@ public static void main(String[] args) { REGISTRY = System.getProperty("registryName"); GATEWAY = System.getProperty("gatewayName"); DEVICE = System.getProperty("deviceName"); + if(REGISTRY != null) { + configParameters.setRegistry(REGISTRY); + } + if(LOCATION != null) { + configParameters.setRegion(LOCATION); + } asyncUnbindDeviceFromGateway(); } diff --git a/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/unbinddevicefromgateway/SyncUnbindDeviceFromGateway.java b/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/unbinddevicefromgateway/SyncUnbindDeviceFromGateway.java index 1cf937ed..224596c4 100644 --- a/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/unbinddevicefromgateway/SyncUnbindDeviceFromGateway.java +++ b/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/unbinddevicefromgateway/SyncUnbindDeviceFromGateway.java @@ -4,6 +4,7 @@ import com.clearblade.cloud.iot.v1.registrytypes.RegistryName; import com.clearblade.cloud.iot.v1.unbinddevicefromgateway.UnbindDeviceFromGatewayRequest; import com.clearblade.cloud.iot.v1.unbinddevicefromgateway.UnbindDeviceFromGatewayResponse; +import com.clearblade.cloud.iot.v1.utils.ConfigParameters; public class SyncUnbindDeviceFromGateway { public static String PROJECT = ""; @@ -11,6 +12,7 @@ public class SyncUnbindDeviceFromGateway { public static String REGISTRY = ""; public static String GATEWAY = ""; public static String DEVICE = ""; + static ConfigParameters configParameters = ConfigParameters.getInstance(); public static void main(String[] args) { PROJECT = System.getProperty("projectName"); @@ -18,6 +20,12 @@ public static void main(String[] args) { REGISTRY = System.getProperty("registryName"); GATEWAY = System.getProperty("gatewayName"); DEVICE = System.getProperty("deviceName"); + if(REGISTRY != null) { + configParameters.setRegistry(REGISTRY); + } + if(LOCATION != null) { + configParameters.setRegion(LOCATION); + } syncUnbindDeviceFromGateway(); } diff --git a/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/updatedevice/AsyncUpdateDevice.java b/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/updatedevice/AsyncUpdateDevice.java index 14f4e0cd..969fec75 100644 --- a/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/updatedevice/AsyncUpdateDevice.java +++ b/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/updatedevice/AsyncUpdateDevice.java @@ -11,19 +11,31 @@ import com.clearblade.cloud.iot.v1.registrytypes.PublicKeyCredential; import com.clearblade.cloud.iot.v1.registrytypes.PublicKeyFormat; import com.clearblade.cloud.iot.v1.updatedevice.UpdateDeviceRequest; +import com.clearblade.cloud.iot.v1.utils.ConfigParameters; import com.clearblade.cloud.iot.v1.utils.LogLevel; public class AsyncUpdateDevice { + public static String LOCATION = ""; + public static String REGISTRY = ""; public static String DEVICE = ""; public static String UPDATEMASK = ""; public static String ARG=""; - public static String[] NEWARGS = null; + public static String[] NEWARGS = null; public static String KEYFORMAT =""; public static String KEYVAL = ""; + static ConfigParameters configParameters = ConfigParameters.getInstance(); public static void main(String[] args) { + LOCATION = System.getProperty("location"); + REGISTRY = System.getProperty("registryName"); DEVICE = System.getProperty("deviceName"); UPDATEMASK = System.getProperty("updateMask"); + if(REGISTRY != null) { + configParameters.setRegistry(REGISTRY); + } + if(LOCATION != null) { + configParameters.setRegion(LOCATION); + } if(!(System.getProperty("arg").isBlank() || System.getProperty("arg").isEmpty()|| System.getProperty("arg")==null)) ARG = System.getProperty("arg"); if(System.getProperty("newArgs") != null) diff --git a/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/updatedevice/SyncUpdateDevice.java b/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/updatedevice/SyncUpdateDevice.java index 882cd3d0..012dead6 100644 --- a/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/updatedevice/SyncUpdateDevice.java +++ b/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/updatedevice/SyncUpdateDevice.java @@ -11,19 +11,32 @@ import com.clearblade.cloud.iot.v1.registrytypes.PublicKeyCredential; import com.clearblade.cloud.iot.v1.registrytypes.PublicKeyFormat; import com.clearblade.cloud.iot.v1.updatedevice.UpdateDeviceRequest; +import com.clearblade.cloud.iot.v1.utils.ConfigParameters; import com.clearblade.cloud.iot.v1.utils.LogLevel; public class SyncUpdateDevice { + + public static String LOCATION = ""; + public static String REGISTRY = ""; public static String DEVICE = ""; public static String UPDATEMASK = ""; public static String ARG=""; public static String[] NEWARGS = null; public static String KEYFORMAT =""; public static String KEYVAL = ""; + static ConfigParameters configParameters = ConfigParameters.getInstance(); public static void main(String[] args) { + LOCATION = System.getProperty("location"); + REGISTRY = System.getProperty("registryName"); DEVICE = System.getProperty("deviceName"); UPDATEMASK = System.getProperty("updateMask"); + if(REGISTRY != null) { + configParameters.setRegistry(REGISTRY); + } + if(LOCATION != null) { + configParameters.setRegion(LOCATION); + } if(!(System.getProperty("arg").isBlank() || System.getProperty("arg").isEmpty()|| System.getProperty("arg")==null)) ARG = System.getProperty("arg"); if(System.getProperty("newArgs") != null) diff --git a/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/updatedeviceregistry/AsyncUpdateDeviceRegistry.java b/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/updatedeviceregistry/AsyncUpdateDeviceRegistry.java index 70c41fc9..10d8739a 100644 --- a/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/updatedeviceregistry/AsyncUpdateDeviceRegistry.java +++ b/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/updatedeviceregistry/AsyncUpdateDeviceRegistry.java @@ -4,6 +4,7 @@ import com.clearblade.cloud.iot.v1.registrytypes.DeviceRegistry; import com.clearblade.cloud.iot.v1.registrytypes.RegistryName; import com.clearblade.cloud.iot.v1.updatedeviceregistry.UpdateDeviceRegistryRequest; +import com.clearblade.cloud.iot.v1.utils.ConfigParameters; import com.clearblade.cloud.iot.v1.utils.LogLevel; public class AsyncUpdateDeviceRegistry { @@ -11,12 +12,19 @@ public class AsyncUpdateDeviceRegistry { public static String LOCATION = ""; public static String REGISTRY = ""; public static String LOGLEVEL = ""; + static ConfigParameters configParameters = ConfigParameters.getInstance(); public static void main(String[] args) throws Exception{ PROJECT = System.getProperty("projectName"); LOCATION = System.getProperty("location"); REGISTRY = System.getProperty("registryName"); LOGLEVEL = System.getProperty("logLevel"); + if(REGISTRY != null) { + configParameters.setRegistry(REGISTRY); + } + if(LOCATION != null) { + configParameters.setRegion(LOCATION); + } asyncUpdateDeviceRegistry(); } diff --git a/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/updatedeviceregistry/SyncUpdateDeviceRegistry.java b/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/updatedeviceregistry/SyncUpdateDeviceRegistry.java index a5d18263..66a49574 100644 --- a/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/updatedeviceregistry/SyncUpdateDeviceRegistry.java +++ b/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/updatedeviceregistry/SyncUpdateDeviceRegistry.java @@ -4,6 +4,7 @@ import com.clearblade.cloud.iot.v1.registrytypes.DeviceRegistry; import com.clearblade.cloud.iot.v1.registrytypes.RegistryName; import com.clearblade.cloud.iot.v1.updatedeviceregistry.UpdateDeviceRegistryRequest; +import com.clearblade.cloud.iot.v1.utils.ConfigParameters; import com.clearblade.cloud.iot.v1.utils.LogLevel; public class SyncUpdateDeviceRegistry { @@ -12,12 +13,19 @@ public class SyncUpdateDeviceRegistry { public static String LOCATION = ""; public static String REGISTRY = ""; public static String LOGLEVEL = ""; + static ConfigParameters configParameters = ConfigParameters.getInstance(); public static void main(String[] args) throws Exception{ PROJECT = System.getProperty("projectName"); LOCATION = System.getProperty("location"); REGISTRY = System.getProperty("registryName"); LOGLEVEL = System.getProperty("logLevel"); + if(REGISTRY != null) { + configParameters.setRegistry(REGISTRY); + } + if(LOCATION != null) { + configParameters.setRegion(LOCATION); + } syncUpdateDeviceRegistry(); } From 372ee60a7ee8951d6a605404e20e4429965be514 Mon Sep 17 00:00:00 2001 From: RashmiK14 Date: Fri, 2 Dec 2022 21:49:49 +0530 Subject: [PATCH 043/151] Updated files to get Credentials set from Command line for this sample to work Updated files to get Credentials set from Command line for this sample to work --- .../iot/v1/samples/updatedevice/AsyncUpdateDevice.java | 6 +++++- .../cloud/iot/v1/samples/updatedevice/SyncUpdateDevice.java | 4 ++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/updatedevice/AsyncUpdateDevice.java b/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/updatedevice/AsyncUpdateDevice.java index 969fec75..027fbc73 100644 --- a/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/updatedevice/AsyncUpdateDevice.java +++ b/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/updatedevice/AsyncUpdateDevice.java @@ -39,7 +39,11 @@ public static void main(String[] args) { if(!(System.getProperty("arg").isBlank() || System.getProperty("arg").isEmpty()|| System.getProperty("arg")==null)) ARG = System.getProperty("arg"); if(System.getProperty("newArgs") != null) - NEWARGS = System.getProperty("newArgs").split(","); + NEWARGS = System.getProperty("newArgs").split(","); + if(System.getProperty("keyFormat") != null) + KEYFORMAT = System.getProperty("keyFormat"); + if(System.getProperty("keyVal") != null) + KEYVAL = System.getProperty("keyVal"); asyncUpdateDevice(); } diff --git a/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/updatedevice/SyncUpdateDevice.java b/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/updatedevice/SyncUpdateDevice.java index 012dead6..f1fba720 100644 --- a/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/updatedevice/SyncUpdateDevice.java +++ b/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/updatedevice/SyncUpdateDevice.java @@ -41,6 +41,10 @@ public static void main(String[] args) { ARG = System.getProperty("arg"); if(System.getProperty("newArgs") != null) NEWARGS = System.getProperty("newArgs").split(","); + if(System.getProperty("keyFormat") != null) + KEYFORMAT = System.getProperty("keyFormat"); + if(System.getProperty("keyVal") != null) + KEYVAL = System.getProperty("keyVal"); syncUpdateDevice(); } From debe438c5fc0ca9cfe2ac1cedbc21cc84f9a0547 Mon Sep 17 00:00:00 2001 From: mikoaro Date: Wed, 21 Dec 2022 07:26:08 -0600 Subject: [PATCH 044/151] pom update --- clearblade-cloud-iot/pom.xml | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/clearblade-cloud-iot/pom.xml b/clearblade-cloud-iot/pom.xml index 9828d7cb..e236c15b 100644 --- a/clearblade-cloud-iot/pom.xml +++ b/clearblade-cloud-iot/pom.xml @@ -1,8 +1,8 @@ 4.0.0 - clearblade-cloud-iot + com.clearblade clearblade-cloud-iot - 0.0.1-SNAPSHOT + 0.0.1 src @@ -11,8 +11,9 @@ maven-compiler-plugin 3.8.0 - 17 - + 11 + 11 + org.codehaus.mojo From 7c60d7a85a595a8e04cd8e30c4f31b08c64fc1fa Mon Sep 17 00:00:00 2001 From: mikoaro Date: Wed, 21 Dec 2022 07:46:22 -0600 Subject: [PATCH 045/151] updated groupid --- clearblade-cloud-iot/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/clearblade-cloud-iot/pom.xml b/clearblade-cloud-iot/pom.xml index e236c15b..0a62d110 100644 --- a/clearblade-cloud-iot/pom.xml +++ b/clearblade-cloud-iot/pom.xml @@ -1,6 +1,6 @@ 4.0.0 - com.clearblade + io.github.clearblade clearblade-cloud-iot 0.0.1 From 47ca8236ed23d4b7aaac5c6f8a6a2ccc91926f81 Mon Sep 17 00:00:00 2001 From: mikoaro Date: Wed, 21 Dec 2022 09:40:47 -0600 Subject: [PATCH 046/151] Maven Central Deploy --- LICENSE | 201 +++++++++++++++++++++++++++++++++++ clearblade-cloud-iot/pom.xml | 113 +++++++++++++++++++- 2 files changed, 311 insertions(+), 3 deletions(-) create mode 100644 LICENSE diff --git a/LICENSE b/LICENSE new file mode 100644 index 00000000..6e999024 --- /dev/null +++ b/LICENSE @@ -0,0 +1,201 @@ + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + +TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + +1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + +2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + +3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + +4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + +5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + +6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + +7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + +8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + +9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + +END OF TERMS AND CONDITIONS + +APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + +Copyright 2022 ClearBlade Inc + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. diff --git a/clearblade-cloud-iot/pom.xml b/clearblade-cloud-iot/pom.xml index 0a62d110..994ac96d 100644 --- a/clearblade-cloud-iot/pom.xml +++ b/clearblade-cloud-iot/pom.xml @@ -1,8 +1,49 @@ 4.0.0 + io.github.clearblade clearblade-cloud-iot 0.0.1 + jar + + Java Client Library for ClearBlade IoT Core + ClearBlade Java SDK allows for rapid development of ClearBlade IoT Core clients. + https://github.com/ClearBlade/java-iot + + + + The Apache License, Version 2.0 + http://www.apache.org/licenses/LICENSE-2.0.txt + + + + + + ClearBlade Inc. + maro@clearblade.com + ClearBlade + http://www.clearblade.com + + + + + scm:git:git://github.com/ClearBlade/java-iot.git + scm:git:ssh://github.com:ClearBlade/java-iot.git + https://github.com/ClearBlade/java-iot + + + + + ossrh + https://s01.oss.sonatype.org/content/repositories/snapshots + + + ossrh + https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/ + + + + src @@ -15,6 +56,17 @@ 11 + + org.sonatype.plugins + nexus-staging-maven-plugin + 1.6.7 + true + + ossrh + https://s01.oss.sonatype.org/ + true + + org.codehaus.mojo build-helper-maven-plugin @@ -62,16 +114,71 @@ - clearblade-cloud-iot + io.github.clearblade clearblade-cloud-iot - 0.0.1-SNAPSHOT + 0.0.1 jar - + + + org.apache.maven.plugins + maven-source-plugin + 2.2.1 + + + attach-sources + + jar-no-fork + + + + + + org.apache.maven.plugins + maven-javadoc-plugin + 2.9.1 + + + attach-javadocs + + jar + + + + + + org.apache.maven.plugins + maven-gpg-plugin + 1.5 + + + sign-artifacts + verify + + sign + + + + + + org.sonatype.plugins + nexus-staging-maven-plugin + 1.6.7 + true + + ossrh + https://s01.oss.sonatype.org/ + true + + + + + + From 974bc6a77718069c2470df2343f3f5ba359021ad Mon Sep 17 00:00:00 2001 From: mikoaro Date: Wed, 21 Dec 2022 13:36:03 -0600 Subject: [PATCH 047/151] Maven Central Deploy --- .gitignore | 2 ++ clearblade-cloud-iot/pom.xml | 21 +++++++++++++++++---- 2 files changed, 19 insertions(+), 4 deletions(-) diff --git a/.gitignore b/.gitignore index 069d08fc..8dd0525a 100644 --- a/.gitignore +++ b/.gitignore @@ -10,6 +10,8 @@ target/ *.iml .idea/ +.vscode/ + # python utilities *.pyc __pycache__ diff --git a/clearblade-cloud-iot/pom.xml b/clearblade-cloud-iot/pom.xml index 994ac96d..35358de1 100644 --- a/clearblade-cloud-iot/pom.xml +++ b/clearblade-cloud-iot/pom.xml @@ -43,6 +43,17 @@ + + + java8-doclint-disabled + + [11,17) + + + -Xdoclint:none + + + src @@ -50,7 +61,6 @@ org.apache.maven.plugins maven-compiler-plugin - 3.8.0 11 11 @@ -137,20 +147,23 @@ org.apache.maven.plugins maven-javadoc-plugin - 2.9.1 + 3.4.1 attach-javadocs jar + + none + org.apache.maven.plugins maven-gpg-plugin - 1.5 + 3.0.1 sign-artifacts @@ -164,7 +177,7 @@ org.sonatype.plugins nexus-staging-maven-plugin - 1.6.7 + 1.6.13 true ossrh From 84841a8badc0c79cd46e9b9714ccf4c536ecbef9 Mon Sep 17 00:00:00 2001 From: ronak-ingress Date: Mon, 26 Dec 2022 20:42:56 +0530 Subject: [PATCH 048/151] - Added JSON object format to make proper request. - Changed logic to add multiple credentials instead of single one. - Resolved issue of create and update device. --- .../cloud/iot/v1/devicetypes/Device.java | 52 +++++++++---------- .../iot/v1/devicetypes/DeviceCredential.java | 14 ++++- .../v1/registrytypes/PublicKeyCredential.java | 9 ++++ .../v1/updatedevice/UpdateDeviceRequest.java | 20 ++++++- 4 files changed, 67 insertions(+), 28 deletions(-) diff --git a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/devicetypes/Device.java b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/devicetypes/Device.java index b596fa6d..9defa355 100644 --- a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/devicetypes/Device.java +++ b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/devicetypes/Device.java @@ -9,6 +9,7 @@ import java.util.logging.Level; import java.util.logging.Logger; +import org.json.simple.JSONArray; import org.json.simple.JSONObject; import org.json.simple.parser.JSONParser; @@ -96,19 +97,16 @@ public Builder toBuilder() { } public static Device of(String id, String name, String numId, List credentials, - String lastHeartbeatTime, String lastEventTime, - String lastStateTime, String lastConfigAckTime, String lastConfigSendTime, boolean blocked, - String lastErrorTime, - Status lastErrorStatus, DeviceConfig config, DeviceState state, LogLevel logLevel, - Map metadata, GatewayConfig gatewayConfig) { + String lastHeartbeatTime, String lastEventTime, String lastStateTime, String lastConfigAckTime, + String lastConfigSendTime, boolean blocked, String lastErrorTime, Status lastErrorStatus, + DeviceConfig config, DeviceState state, LogLevel logLevel, Map metadata, + GatewayConfig gatewayConfig) { return newBuilder().setId(id).setName(name).setNumId(numId).setCredentials(credentials) - .setLastHeartbeatTime(lastHeartbeatTime).setLastEventTime(lastEventTime) - .setLastStateTime(lastStateTime).setLastConfigAckTime(lastConfigAckTime) - .setLastConfigSendTime(lastConfigSendTime).setBlocked(blocked).setLastErrorTime(lastErrorTime) - .setLastErrorStatus(lastErrorStatus).setConfig(config).setState(state).setLogLevel(logLevel) - .setMetadata(metadata).setGatewayConfig(gatewayConfig) - .build(); + .setLastHeartbeatTime(lastHeartbeatTime).setLastEventTime(lastEventTime).setLastStateTime(lastStateTime) + .setLastConfigAckTime(lastConfigAckTime).setLastConfigSendTime(lastConfigSendTime).setBlocked(blocked) + .setLastErrorTime(lastErrorTime).setLastErrorStatus(lastErrorStatus).setConfig(config).setState(state) + .setLogLevel(logLevel).setMetadata(metadata).setGatewayConfig(gatewayConfig).build(); } public static Device patch(String id, String name, LogLevel logLevel, boolean blocked) { @@ -116,19 +114,16 @@ public static Device patch(String id, String name, LogLevel logLevel, boolean bl } public static String format(String id, String name, String numId, List credentials, - String lastHeartbeatTime, String lastEventTime, - String lastStateTime, String lastConfigAckTime, String lastConfigSendTime, boolean blocked, - String lastErrorTime, - Status lastErrorStatus, DeviceConfig config, DeviceState state, LogLevel logLevel, - Map metadata, GatewayConfig gatewayConfig) { + String lastHeartbeatTime, String lastEventTime, String lastStateTime, String lastConfigAckTime, + String lastConfigSendTime, boolean blocked, String lastErrorTime, Status lastErrorStatus, + DeviceConfig config, DeviceState state, LogLevel logLevel, Map metadata, + GatewayConfig gatewayConfig) { return newBuilder().setId(id).setName(name).setNumId(numId).setCredentials(credentials) - .setLastHeartbeatTime(lastHeartbeatTime).setLastEventTime(lastEventTime) - .setLastStateTime(lastStateTime).setLastConfigAckTime(lastConfigAckTime) - .setLastConfigSendTime(lastConfigSendTime).setBlocked(blocked).setLastErrorTime(lastErrorTime) - .setLastErrorStatus(lastErrorStatus).setConfig(config).setState(state).setLogLevel(logLevel) - .setMetadata(metadata).setGatewayConfig(gatewayConfig) - .build().toString(); + .setLastHeartbeatTime(lastHeartbeatTime).setLastEventTime(lastEventTime).setLastStateTime(lastStateTime) + .setLastConfigAckTime(lastConfigAckTime).setLastConfigSendTime(lastConfigSendTime).setBlocked(blocked) + .setLastErrorTime(lastErrorTime).setLastErrorStatus(lastErrorStatus).setConfig(config).setState(state) + .setLogLevel(logLevel).setMetadata(metadata).setGatewayConfig(gatewayConfig).build().toString(); } /** @@ -359,12 +354,17 @@ public String createDeviceJSONObject() { deviceObj.put("id", this.id); deviceObj.put("name", this.name); deviceObj.put("numId", this.numId); - List credentialList = new ArrayList<>(); + JSONArray jsonArray = new JSONArray(); if (this.credentials.size() > 0) { - DeviceCredential credentialObj = this.credentials.get(0); - credentialList.add(credentialObj); + + for (int i = 0; i < this.credentials.size(); i++) { + if (!this.credentials.get(i).isEmpty()) { + DeviceCredential credentialObj = this.credentials.get(i); + jsonArray.add(credentialObj.toJSONObject()); + } + } } - deviceObj.put("credentials", credentialList); + deviceObj.put("credentials", jsonArray); deviceObj.put("gatewayConfig", this.gatewayConfig.toString()); deviceObj.put("logLevel", this.logLevel.name()); deviceObj.put("lastHeartbeatTime", this.lastHeartbeatTime); diff --git a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/devicetypes/DeviceCredential.java b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/devicetypes/DeviceCredential.java index 114188b1..333d44e6 100644 --- a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/devicetypes/DeviceCredential.java +++ b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/devicetypes/DeviceCredential.java @@ -1,10 +1,12 @@ package com.clearblade.cloud.iot.v1.devicetypes; +import org.json.simple.JSONObject; + import com.clearblade.cloud.iot.v1.registrytypes.PublicKeyCredential; public class DeviceCredential { - private String expirationTime; + private String expirationTime = ""; private PublicKeyCredential publicKey; public DeviceCredential() { @@ -67,4 +69,14 @@ public void setPublicKey(PublicKeyCredential publicKey) { this.publicKey = publicKey; } + public boolean isEmpty() { + return publicKey == null; + } + + public JSONObject toJSONObject() { + JSONObject jsonObject = new JSONObject(); + jsonObject.put("expirationTime", this.expirationTime); + jsonObject.put("publicKey", this.publicKey.toJSONObject()); + return jsonObject; + } } diff --git a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/registrytypes/PublicKeyCredential.java b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/registrytypes/PublicKeyCredential.java index 3d519bcd..5fef09e8 100644 --- a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/registrytypes/PublicKeyCredential.java +++ b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/registrytypes/PublicKeyCredential.java @@ -1,5 +1,7 @@ package com.clearblade.cloud.iot.v1.registrytypes; +import org.json.simple.JSONObject; + public class PublicKeyCredential { private PublicKeyFormat format; @@ -65,4 +67,11 @@ public PublicKeyCredential build() { } } + public JSONObject toJSONObject() { + JSONObject jsonObject = new JSONObject(); + jsonObject.put("format", this.format.name()); + jsonObject.put("key", this.key); + return jsonObject; + } + } diff --git a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/updatedevice/UpdateDeviceRequest.java b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/updatedevice/UpdateDeviceRequest.java index df9a3048..d043a96f 100644 --- a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/updatedevice/UpdateDeviceRequest.java +++ b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/updatedevice/UpdateDeviceRequest.java @@ -1,8 +1,14 @@ package com.clearblade.cloud.iot.v1.updatedevice; +import java.util.ArrayList; +import java.util.Iterator; +import java.util.List; + +import org.json.simple.JSONArray; import org.json.simple.JSONObject; import com.clearblade.cloud.iot.v1.devicetypes.Device; +import com.clearblade.cloud.iot.v1.devicetypes.DeviceCredential; public class UpdateDeviceRequest { private final String name; @@ -95,8 +101,20 @@ public String[] getBodyAndParams() { bodyParams.put("id", this.device.toBuilder().getId()); bodyParams.put("name", this.device.toBuilder().getName()); - bodyParams.put("logLevel", this.device.toBuilder().getLogLevel().toString()); + if (this.device.toBuilder().getLogLevel() != null) { + bodyParams.put("logLevel", this.device.toBuilder().getLogLevel().toString()); + } bodyParams.put("blocked", this.device.toBuilder().isBlocked()); + if (this.device.toBuilder().getCredentials().size() > 0) { + JSONArray jsonArray = new JSONArray(); + for (int i = 0; i < this.device.toBuilder().getCredentials().size(); i++) { + if (!this.device.toBuilder().getCredentials().get(i).isEmpty()) { + DeviceCredential credentialObj = this.device.toBuilder().getCredentials().get(i); + jsonArray.add(credentialObj.toJSONObject()); + } + } + bodyParams.put("credentials", jsonArray); + } output[0] = params; output[1] = bodyParams.toString(); From 06cdad212a39fc64171d32588d2baa6c92f2c27d Mon Sep 17 00:00:00 2001 From: mikoaro Date: Thu, 29 Dec 2022 08:28:43 -0600 Subject: [PATCH 049/151] Maven Central Deploy --- README.md | 33 ++++++++++++++++++++++++--------- clearblade-cloud-iot/pom.xml | 34 ++++++++++++---------------------- 2 files changed, 36 insertions(+), 31 deletions(-) diff --git a/README.md b/README.md index 24a0b40a..aca07d5b 100644 --- a/README.md +++ b/README.md @@ -9,6 +9,29 @@ Java library and samples for [ClearBlade Internet of Things (IoT) Core][product- Java 11 or above is required for using this client. Java 17 is the best choice for new development. +## Usage + +# Maven artifact + +If you are using Maven artifact, simply add the following dependency to your pom.xml file in a newly created/generated Maven App: + +```xml + + io.github.clearblade + clearblade-cloud-iot + 0.1.0 + +``` + +# Local Installation and setup + +For local installation of Maven: + +In the [clearblade-cloud-iot](./clearblade-cloud-iot) folder, run the following command to install the libraries and build the sample with +Maven: + + mvn clean install + ## Quickstart 1. From the [ClearBlade Migration from Google IoT Core section](https://clearblade.atlassian.net/wiki/spaces/IC/pages/2202664969/Migration+from+Google+IoT+Core) @@ -40,13 +63,6 @@ Before running the samples, you can set the `CLEARBLADE_CONFIGURATION`, `CLEARBL the sample every time you run it. Update the `CLEARBLADE_REGISTRY` and `CLEARBLADE_REGION` environment variables when switching to use new registries and regions. -## Installation and setup - -In the [clearblade-cloud-iot](./clearblade-cloud-iot) folder, run the following command to install the libraries and build the sample with -Maven: - - mvn clean install - ## Running the sample The following command summarizes the sample usage: @@ -64,12 +80,11 @@ Run device example: mvn exec:java \ -Dexec.cleanupDaemonThreads=false \ - -Dexec.mainClass="com.clearblade.cloud.iot.v1.samples.createdevice.SyncCreateDevice" \ + -Dexec.mainClass="com.clearblade.cloud.iot.v1.samples.createdevice.AsyncCreateDevice" \ -DprojectName="your-project-id" \ -Dlocation="your-region" \ -DregistryName="your-registry" \ -DdeviceName="your-device-id" \ - -DgatewayName="your-gateway-id" [product-docs]: https://clearblade.atlassian.net/wiki/spaces/IC/overview [javasdk]: https://clearblade.atlassian.net/wiki/spaces/IC/pages/2231173185/Java diff --git a/clearblade-cloud-iot/pom.xml b/clearblade-cloud-iot/pom.xml index 35358de1..23d1de77 100644 --- a/clearblade-cloud-iot/pom.xml +++ b/clearblade-cloud-iot/pom.xml @@ -3,7 +3,7 @@ io.github.clearblade clearblade-cloud-iot - 0.0.1 + 0.1.0 jar Java Client Library for ClearBlade IoT Core @@ -61,22 +61,23 @@ org.apache.maven.plugins maven-compiler-plugin + 3.10.1 11 11 - org.sonatype.plugins - nexus-staging-maven-plugin - 1.6.7 - true - - ossrh - https://s01.oss.sonatype.org/ - true - - + org.sonatype.plugins + nexus-staging-maven-plugin + 1.6.13 + true + + ossrh + https://s01.oss.sonatype.org/ + true + + org.codehaus.mojo build-helper-maven-plugin @@ -174,17 +175,6 @@ - - org.sonatype.plugins - nexus-staging-maven-plugin - 1.6.13 - true - - ossrh - https://s01.oss.sonatype.org/ - true - - From 0291a35bb39f84417865c5ec0d591c68ff569978 Mon Sep 17 00:00:00 2001 From: mikoaro Date: Thu, 29 Dec 2022 08:30:29 -0600 Subject: [PATCH 050/151] Maven Central Deploy --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index aca07d5b..b9a9bd6a 100644 --- a/README.md +++ b/README.md @@ -9,9 +9,9 @@ Java library and samples for [ClearBlade Internet of Things (IoT) Core][product- Java 11 or above is required for using this client. Java 17 is the best choice for new development. -## Usage +# Usage -# Maven artifact +## Maven artifact If you are using Maven artifact, simply add the following dependency to your pom.xml file in a newly created/generated Maven App: @@ -23,7 +23,7 @@ If you are using Maven artifact, simply add the following dependency to your pom ``` -# Local Installation and setup +## Local Installation and setup For local installation of Maven: From 3940763b4251772e03739fc7679c4171f3c5a6eb Mon Sep 17 00:00:00 2001 From: mikoaro Date: Thu, 29 Dec 2022 08:32:02 -0600 Subject: [PATCH 051/151] Maven Central Deploy --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index b9a9bd6a..61be643c 100644 --- a/README.md +++ b/README.md @@ -11,6 +11,8 @@ Java 11 or above is required for using this client. Java 17 is the best choice f # Usage +You can either use the Maven artifact or do a local installation and setup of Maven. + ## Maven artifact If you are using Maven artifact, simply add the following dependency to your pom.xml file in a newly created/generated Maven App: From e833cd176424c0e1bb94d74eb002cfbc08215524 Mon Sep 17 00:00:00 2001 From: mikoaro Date: Thu, 5 Jan 2023 09:47:31 -0600 Subject: [PATCH 052/151] Updated README --- README.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/README.md b/README.md index 61be643c..db921851 100644 --- a/README.md +++ b/README.md @@ -47,6 +47,11 @@ Maven: ``` export CLEARBLADE_CONFIGURATION=/path/to/file.json + ``` + + Optional + + ``` export CLEARBLADE_REGISTRY=[your-registry] export CLEARBLADE_REGION=[your-region] ``` From 6ee210fef21898f80c3ea83934b0d7566a90e5c2 Mon Sep 17 00:00:00 2001 From: mikoaro Date: Thu, 5 Jan 2023 09:56:18 -0600 Subject: [PATCH 053/151] Updated README --- README.md | 11 +++++++---- clearblade-cloud-iot/samples/README.md | 6 ++++++ 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index db921851..7e0b6de8 100644 --- a/README.md +++ b/README.md @@ -65,10 +65,13 @@ The sample apps demonstrates registry and device creation for ClearBlade IoT Cor Note that before you can run the sample, you must configure your development environment and terminal as described in the Quickstart above or the [samples](./clearblade-cloud-iot/samples) folder. -Before running the samples, you can set the `CLEARBLADE_CONFIGURATION`, `CLEARBLADE_REGISTRY` and -`CLEARBLADE_REGION` environment variables to avoid passing them to -the sample every time you run it. Update the `CLEARBLADE_REGISTRY` and -`CLEARBLADE_REGION` environment variables when switching to use new registries and regions. +Before running the samples, you must set the `CLEARBLADE_CONFIGURATION`. Optionally set the `CLEARBLADE_REGISTRY` and +`CLEARBLADE_REGION` environment variables to avoid changing them in the the sample app every time you run it. + +When switching to use new registries and/or regions, either: + +1. Update the `CLEARBLADE_REGISTRY` and `CLEARBLADE_REGION` environment variables; or +2. Change the `REGISTRY` and/or `REGION` in the sample code/app. ## Running the sample diff --git a/clearblade-cloud-iot/samples/README.md b/clearblade-cloud-iot/samples/README.md index a742e385..49289cdd 100644 --- a/clearblade-cloud-iot/samples/README.md +++ b/clearblade-cloud-iot/samples/README.md @@ -16,6 +16,12 @@ ClearBlade IoT Core platform. ``` export CLEARBLADE_CONFIGURATION=/path/to/file.json + + ``` + + Optional + + ``` export CLEARBLADE_REGISTRY=[your-registry] export CLEARBLADE_REGION=[your-region] ``` From fa1714bcc7a64cafe910e569899f4d60465198fe Mon Sep 17 00:00:00 2001 From: mikoaro Date: Thu, 5 Jan 2023 09:57:04 -0600 Subject: [PATCH 054/151] Updated README --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 7e0b6de8..ea49bfd8 100644 --- a/README.md +++ b/README.md @@ -71,7 +71,7 @@ Before running the samples, you must set the `CLEARBLADE_CONFIGURATION`. Optiona When switching to use new registries and/or regions, either: 1. Update the `CLEARBLADE_REGISTRY` and `CLEARBLADE_REGION` environment variables; or -2. Change the `REGISTRY` and/or `REGION` in the sample code/app. +2. Change the `REGISTRY` and/or `REGION` variables in the sample code/app. ## Running the sample From 3728f7c6b89f1efe2bb1b4824feb7e458028af14 Mon Sep 17 00:00:00 2001 From: mikoaro Date: Tue, 10 Jan 2023 12:48:40 -0600 Subject: [PATCH 055/151] Updated README --- README.md | 37 ++++++++++++++++++++++++++++++++++++- 1 file changed, 36 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index ea49bfd8..21d52535 100644 --- a/README.md +++ b/README.md @@ -73,10 +73,45 @@ When switching to use new registries and/or regions, either: 1. Update the `CLEARBLADE_REGISTRY` and `CLEARBLADE_REGION` environment variables; or 2. Change the `REGISTRY` and/or `REGION` variables in the sample code/app. -## Running the sample +## Using the client library within an Example app + +``` +public class App { + + public static String PROJECT = ""; + public static String LOCATION = ""; + public static String REGISTRY = ""; + static ConfigParameters configParameters = ConfigParameters.getInstance(); + + public static void main(String[] args) { + PROJECT = "enter project id here"; + LOCATION = "enter a region or location here"; + REGISTRY = "enter a registry here"; + if (REGISTRY != null) { + configParameters.setRegistry(REGISTRY); + } + if (LOCATION != null) { + configParameters.setRegion(LOCATION); + } + asyncDevicesList(); + } + + public static void asyncDevicesList() { + DeviceManagerAsyncClient deviceManagerAsyncClient = new DeviceManagerAsyncClient(); + RegistryName parent = RegistryName.of(PROJECT, LOCATION, REGISTRY); + DevicesListRequest request = DevicesListRequest.Builder.newBuilder().setParent(parent.toString()) + .setGatewayListOptions(GatewayListOptions.newBuilder().setGatewayType(GatewayType.NON_GATEWAY).build()) + .setPageSize(10) + .build(); + DevicesListResponse response = deviceManagerAsyncClient.listDevices(request); +``` + +## Running the sample - Command Line The following command summarizes the sample usage: +First compile the sample. + Run registry example: mvn exec:java \ From 44ce7a57edeb70dec3b1a829ae15c95f06494a57 Mon Sep 17 00:00:00 2001 From: mikoaro Date: Tue, 10 Jan 2023 12:50:09 -0600 Subject: [PATCH 056/151] Updated README --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 21d52535..1bb87343 100644 --- a/README.md +++ b/README.md @@ -84,9 +84,9 @@ public class App { static ConfigParameters configParameters = ConfigParameters.getInstance(); public static void main(String[] args) { - PROJECT = "enter project id here"; - LOCATION = "enter a region or location here"; - REGISTRY = "enter a registry here"; + PROJECT = "your-project-id"; + LOCATION = "your-region"; + REGISTRY = "your-registry"; if (REGISTRY != null) { configParameters.setRegistry(REGISTRY); } From c403bbd2a618404856d9e567d1b6c3be5c2a497c Mon Sep 17 00:00:00 2001 From: ronak-ingress Date: Tue, 31 Jan 2023 10:42:55 +0530 Subject: [PATCH 057/151] - Created callback interface for API success and fail - Replaced string based JSON creation to Object based JSON. - Updated one sample to test it. --- .../createdevice/AsyncCreateDevice.java | 102 ++++++++++++++---- .../cloud/iot/v1/ClearBladeDeviceManager.java | 5 +- .../iot/v1/DeviceManagerAsyncClient.java | 7 +- .../cloud/iot/v1/ResponseCallback.java | 8 ++ .../cloud/iot/v1/devicetypes/Device.java | 61 +++++++---- .../iot/v1/devicetypes/DeviceConfig.java | 9 ++ .../cloud/iot/v1/devicetypes/DeviceState.java | 17 +++ .../iot/v1/devicetypes/GatewayConfig.java | 55 +++++++--- .../cloud/iot/v1/devicetypes/Status.java | 14 +++ 9 files changed, 221 insertions(+), 57 deletions(-) create mode 100644 clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/ResponseCallback.java diff --git a/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/createdevice/AsyncCreateDevice.java b/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/createdevice/AsyncCreateDevice.java index 7f919e7d..1382ae52 100644 --- a/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/createdevice/AsyncCreateDevice.java +++ b/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/createdevice/AsyncCreateDevice.java @@ -1,15 +1,24 @@ package com.clearblade.cloud.iot.v1.samples.createdevice; +import java.awt.Taskbar.State; +import java.sql.Time; import java.util.ArrayList; import java.util.HashMap; +import java.util.List; import com.clearblade.cloud.iot.v1.DeviceManagerAsyncClient; +import com.clearblade.cloud.iot.v1.ResponseCallback; import com.clearblade.cloud.iot.v1.createdevice.CreateDeviceRequest; import com.clearblade.cloud.iot.v1.devicetypes.Device; import com.clearblade.cloud.iot.v1.devicetypes.DeviceConfig; +import com.clearblade.cloud.iot.v1.devicetypes.DeviceCredential; +import com.clearblade.cloud.iot.v1.devicetypes.DeviceState; +import com.clearblade.cloud.iot.v1.devicetypes.GatewayAuthMethod; import com.clearblade.cloud.iot.v1.devicetypes.GatewayConfig; import com.clearblade.cloud.iot.v1.devicetypes.GatewayType; import com.clearblade.cloud.iot.v1.devicetypes.Status; +import com.clearblade.cloud.iot.v1.registrytypes.PublicKeyCredential; +import com.clearblade.cloud.iot.v1.registrytypes.PublicKeyFormat; import com.clearblade.cloud.iot.v1.registrytypes.RegistryName; import com.clearblade.cloud.iot.v1.utils.ConfigParameters; import com.clearblade.cloud.iot.v1.utils.LogLevel; @@ -21,44 +30,93 @@ public class AsyncCreateDevice { public static String DEVICE = ""; public static String NUMID = ""; static ConfigParameters configParameters = ConfigParameters.getInstance(); - - public static void main(String[] args) { - PROJECT = System.getProperty("projectName"); - LOCATION = System.getProperty("location"); - REGISTRY = System.getProperty("registryName"); - DEVICE = System.getProperty("deviceName"); - NUMID = System.getProperty("numId"); - if(REGISTRY != null) { + + public static void main(String[] args) { +// PROJECT = System.getProperty("projectName"); +// LOCATION = System.getProperty("location"); +// REGISTRY = System.getProperty("registryName"); +// DEVICE = System.getProperty("deviceName"); +// NUMID = System.getProperty("numId"); + PROJECT = "api-project-320446546234"; + LOCATION = "asia-east1"; + REGISTRY = "test-asia-east1"; + DEVICE = "Java_SDK_Updated"; + NUMID = null; + if (REGISTRY != null) { configParameters.setRegistry(REGISTRY); - } - if(LOCATION != null) { + } + if (LOCATION != null) { configParameters.setRegion(LOCATION); } asyncCreateDevice(); } public static void asyncCreateDevice() { + String KEYVAL = "-----BEGIN PUBLIC KEY-----\nMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA5P0Z4OUD5PSjri8xexGo\n6eQ39NGyQbXamIgWAwvnAs/oDRVqEejE2nwDhnpykaCGLkuDEN0LPd2wF+vC2Cq3\nY3YvkJh71IkjuAjMZQ+00CXdezfCjmTtEpMCNA3cV+G1g6uIcdEpHKs0YHfC9CFQ\nrjkc7tl3idmcQLngIov/gsFY7D1pbOgkCVVcZCRLgsdFfhCUYwYCvdEVJP3w+5mG\nybvmhNRbbFG7eG3+hmZoOg0h3f6r2fqgSx6l0+Z3D77SRT6lBEHvGDlxb08ASeuE\n0SJAc6PdAKd3FDqdZok4z1qJsgMqtU/ZGJJG54pNECWmhoOar+aQmmqnZ6kGQ5cn\nEwIDAQAB\n-----END PUBLIC KEY-----\n"; + + PublicKeyCredential publicKeyCredential = new PublicKeyCredential(); + publicKeyCredential.setKey(KEYVAL); + publicKeyCredential.setFormat(PublicKeyFormat.ES256_PEM); + + DeviceCredential devCredential = new DeviceCredential(); + devCredential.setPublicKey(publicKeyCredential); + + + DeviceManagerAsyncClient deviceManagerAsyncClient = new DeviceManagerAsyncClient(); + RegistryName parent = RegistryName.of(PROJECT, LOCATION, REGISTRY); GatewayConfig gatewayCfg = new GatewayConfig(); + gatewayCfg.setGatewayAuthMethod(GatewayAuthMethod.GATEWAY_AUTH_METHOD_UNSPECIFIED); gatewayCfg.setGatewayType(GatewayType.NON_GATEWAY); + + Status status = new Status(); + status.setCode(200); + status.setMessage("Testing status code"); + + DeviceConfig deviceConfig = new DeviceConfig(); + deviceConfig.setVersion("3"); + deviceConfig.setBinaryData("U3RhdGVPZkdyYWNl"); + + HashMap metadata = new HashMap<>(); + metadata.put("test", "value"); + + DeviceState deviceState = new DeviceState(); + deviceState.setBinaryData("VGVzdGluZy4h"); + deviceState.setUpdateTime(String.valueOf(System.currentTimeMillis())); + Device device = Device.newBuilder() - .setId(DEVICE).setName(DEVICE) - .setNumId(NUMID).setBlocked(false) + .setId(DEVICE) + .setName(DEVICE) + .setNumId(NUMID) + .setBlocked(false) .setGatewayConfig(gatewayCfg) .setLogLevel(LogLevel.ERROR) - .setCredentials(new ArrayList<>()) - .setLastErrorStatus(new Status()) - .setConfig(new DeviceConfig()) - .setMetadata(new HashMap<>()) + .setCredentials(List.of(devCredential)) + .setLastErrorStatus(status) + .setConfig(deviceConfig) + .setState(deviceState) + .setLastConfigAckTime(String.valueOf(System.currentTimeMillis())) + .setLastConfigSendTime(String.valueOf(System.currentTimeMillis())) + .setLastErrorTime(String.valueOf(System.currentTimeMillis())) + .setMetadata(metadata) .build(); + CreateDeviceRequest request = CreateDeviceRequest.Builder.newBuilder().setParent(parent).setDevice(device) .build(); - Device response = deviceManagerAsyncClient.createDevice(request); - if(response != null) { - System.out.println("CreateDevice execution successful"); - }else { - System.out.println("CreateDevice execution failed"); - } + deviceManagerAsyncClient.createDevice(request, new ResponseCallback() { + + @Override + public void onSuccess(String message) { + // TODO Auto-generated method stub + System.out.println("onSuccess: " + message); + } + + @Override + public void onFail(String message) { + // TODO Auto-generated method stub + System.out.println("onFail: " + message); + } + }); } } diff --git a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/ClearBladeDeviceManager.java b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/ClearBladeDeviceManager.java index 84b8d6e1..8d9ce622 100644 --- a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/ClearBladeDeviceManager.java +++ b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/ClearBladeDeviceManager.java @@ -80,7 +80,7 @@ public Device createDevice(CreateDeviceRequest request) { return null; } - public Device asyncCreateDevice(CreateDeviceRequest request) { + public Device asyncCreateDevice(CreateDeviceRequest request, ResponseCallback callback) { try { AsyncClient asyncClient = new AsyncClient(); String[] params = request.getParams(); @@ -93,7 +93,10 @@ public Device asyncCreateDevice(CreateDeviceRequest request) { if (responseCode == 200) { Device deviceObj = Device.newBuilder().build(); deviceObj.loadFromString(responseArray[2]); + callback.onSuccess(responseArray[2]); return deviceObj; + } else { + callback.onFail(responseArray[2]); } } } catch (Exception e) { diff --git a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/DeviceManagerAsyncClient.java b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/DeviceManagerAsyncClient.java index ac7918ca..7fa97da3 100644 --- a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/DeviceManagerAsyncClient.java +++ b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/DeviceManagerAsyncClient.java @@ -53,7 +53,12 @@ public Device getDevice(GetDeviceRequest request) { */ public Device createDevice(CreateDeviceRequest request) { ClearBladeDeviceManager cbManager = new ClearBladeDeviceManager(); - return cbManager.asyncCreateDevice(request); + return cbManager.asyncCreateDevice(request, null); + } + + public Device createDevice(CreateDeviceRequest request, ResponseCallback callback) { + ClearBladeDeviceManager cbManager = new ClearBladeDeviceManager(); + return cbManager.asyncCreateDevice(request, callback); } /** diff --git a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/ResponseCallback.java b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/ResponseCallback.java new file mode 100644 index 00000000..9de02003 --- /dev/null +++ b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/ResponseCallback.java @@ -0,0 +1,8 @@ +package com.clearblade.cloud.iot.v1; + +public interface ResponseCallback { + + void onSuccess(String message); + + void onFail(String message); +} diff --git a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/devicetypes/Device.java b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/devicetypes/Device.java index 9defa355..ecb50ce0 100644 --- a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/devicetypes/Device.java +++ b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/devicetypes/Device.java @@ -365,17 +365,36 @@ public String createDeviceJSONObject() { } } deviceObj.put("credentials", jsonArray); - deviceObj.put("gatewayConfig", this.gatewayConfig.toString()); + deviceObj.put("gatewayConfig", this.gatewayConfig.toJSONObject()); deviceObj.put("logLevel", this.logLevel.name()); - deviceObj.put("lastHeartbeatTime", this.lastHeartbeatTime); - deviceObj.put("lastEventTime", this.lastEventTime); - deviceObj.put("lastStateTime", this.lastStateTime); - deviceObj.put("lastConfigAckTime", this.lastConfigAckTime); - deviceObj.put("lastConfigSendTime", this.lastConfigSendTime); + + if (this.lastHeartbeatTime != null) { + deviceObj.put("lastHeartbeatTime", this.lastHeartbeatTime); + } + + if (this.lastEventTime != null) { + deviceObj.put("lastEventTime", this.lastEventTime); + } + + if (this.lastStateTime != null) { + deviceObj.put("lastStateTime", this.lastStateTime); + } + + if (this.lastConfigAckTime != null) { + deviceObj.put("lastConfigAckTime", this.lastConfigAckTime); + } + + if (this.lastConfigSendTime != null) { + deviceObj.put("lastConfigSendTime", this.lastConfigSendTime); + } + deviceObj.put("blocked", false); - deviceObj.put("lastErrorTime", this.lastErrorTime); + + if (this.lastErrorTime != null) + deviceObj.put("lastErrorTime", this.lastErrorTime); + String metaStr = ""; - if (this.metadata != null) { + if (this.metadata != null && this.metadata.size() > 0) { Set metaSet = this.metadata.keySet(); Iterator itr = metaSet.iterator(); int setSize = metaSet.size(); @@ -392,23 +411,27 @@ public String createDeviceJSONObject() { } i++; } + deviceObj.put("metadata", metaStr); } - deviceObj.put("metadata", metaStr); - String errorStatusStr = ""; - if (this.lastErrorStatus != null) { - errorStatusStr += this.lastErrorStatus.toString(); + + if (this.lastErrorStatus != null && this.lastErrorStatus.getCode() != 0) { + deviceObj.put("lastErrorStatus", this.lastErrorStatus.toJSONObject()); } - deviceObj.put("lastErrorStatus", errorStatusStr); - String configStr = ""; + + String lastEventTime = ""; + if (this.lastEventTime != null) { + lastEventTime = this.lastEventTime.toString(); + deviceObj.put("lastEventTime", lastEventTime); + } + if (this.config != null) { - configStr += this.config.toString(); + deviceObj.put("config", this.config.toJSONObject()); } - deviceObj.put("config", configStr); - String stateStr = ""; + if (this.state != null) { - stateStr += this.state.toString(); + deviceObj.put("state", this.state.toJSONObject()); } - deviceObj.put("state", stateStr); + bodyStr = deviceObj.toString(); return bodyStr; } diff --git a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/devicetypes/DeviceConfig.java b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/devicetypes/DeviceConfig.java index da33eb8a..2c508cbd 100644 --- a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/devicetypes/DeviceConfig.java +++ b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/devicetypes/DeviceConfig.java @@ -159,4 +159,13 @@ public void loadFromString(String jsonString) { log.log(Level.SEVERE, e.getMessage()); } } + + public JSONObject toJSONObject() { + JSONObject jsonObject = new JSONObject(); + jsonObject.put("version", this.getVersion()); + jsonObject.put("cloudUpdateTime", this.getCloudUpdateTime()); + jsonObject.put("deviceAckTime", this.getDeviceAckTime()); + jsonObject.put("binaryData", this.getBinaryData()); + return jsonObject; + } } diff --git a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/devicetypes/DeviceState.java b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/devicetypes/DeviceState.java index b1a5ff34..20c2427a 100644 --- a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/devicetypes/DeviceState.java +++ b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/devicetypes/DeviceState.java @@ -1,5 +1,7 @@ package com.clearblade.cloud.iot.v1.devicetypes; +import org.json.simple.JSONObject; + public class DeviceState { private String updateTime; private String binaryData; @@ -87,4 +89,19 @@ public String toString() { } return stateStr; } + + public JSONObject toJSONObject() { + JSONObject jsonObject = new JSONObject(); + if (this.getUpdateTime() != null) { + jsonObject.put("updateTime", this.getUpdateTime()); + } else { + jsonObject.put("updateTime", ""); + } + if (this.getBinaryData() != null) { + jsonObject.put("binaryData", this.getBinaryData()); + } else { + jsonObject.put("binaryData", ""); + } + return jsonObject; + } } diff --git a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/devicetypes/GatewayConfig.java b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/devicetypes/GatewayConfig.java index 4ec9c9ce..071045bd 100644 --- a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/devicetypes/GatewayConfig.java +++ b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/devicetypes/GatewayConfig.java @@ -1,5 +1,7 @@ package com.clearblade.cloud.iot.v1.devicetypes; +import org.json.simple.JSONObject; + public class GatewayConfig { private GatewayType gatewayType; @@ -78,32 +80,57 @@ public GatewayConfig build() { } } - @Override - public String toString() { - String gatewayCfgStr = ""; - +// @Override +// public String toString() { +// String gatewayCfgStr = ""; +// +// if (this.getGatewayAuthMethod() != null) { +// gatewayCfgStr += "{\"gatewayAuthMethod\":\"" + this.getGatewayAuthMethod().name() + "\","; +// } else { +// gatewayCfgStr += "{\"gatewayAuthMethod\":\"" + GatewayAuthMethod.GATEWAY_AUTH_METHOD_UNSPECIFIED + "\","; +// } +// if (this.getGatewayType() != null) { +// gatewayCfgStr += "\"gatewayType\":\"" + this.getGatewayType().name() + "\","; +// } else { +// gatewayCfgStr += "\"gatewayType\":\"" + GatewayType.valueOf(GatewayType.NON_GATEWAY_VALUE) + "\","; +// } +// if (this.getLastAccessedGatewayId() != null) { +// gatewayCfgStr += "\"lastAccessedGatewayId\":\"" + this.getLastAccessedGatewayId() + "\","; +// } else { +// gatewayCfgStr += "\"lastAccessedGatewayId\":\"\","; +// } +// if (this.getLastAccessedGatewayTime() != null) { +// gatewayCfgStr += "\"lastAccessedGatewayTime\":\"" + this.getLastAccessedGatewayTime() + "\"}"; +// } else { +// gatewayCfgStr += "\"lastAccessedGatewayTime\":\"\"}"; +// } +// return gatewayCfgStr; +// +// } + + public JSONObject toJSONObject() { + JSONObject jsonObject = new JSONObject(); if (this.getGatewayAuthMethod() != null) { - gatewayCfgStr += "{\"gatewayAuthMethod\":\"" + this.getGatewayAuthMethod().name() + "\","; + jsonObject.put("gatewayAuthMethod", this.getGatewayAuthMethod().name()); } else { - gatewayCfgStr += "{\"gatewayAuthMethod\":\"" + GatewayAuthMethod.GATEWAY_AUTH_METHOD_UNSPECIFIED + "\","; + jsonObject.put("gatewayAuthMethod", GatewayAuthMethod.GATEWAY_AUTH_METHOD_UNSPECIFIED.toString()); } if (this.getGatewayType() != null) { - gatewayCfgStr += "\"gatewayType\":\"" + this.getGatewayType().name() + "\","; + jsonObject.put("gatewayType", this.getGatewayType().name()); } else { - gatewayCfgStr += "\"gatewayType\":\"" + GatewayType.valueOf(GatewayType.NON_GATEWAY_VALUE) + "\","; + jsonObject.put("gatewayType", GatewayType.valueOf(GatewayType.NON_GATEWAY_VALUE)); } if (this.getLastAccessedGatewayId() != null) { - gatewayCfgStr += "\"lastAccessedGatewayId\":\"" + this.getLastAccessedGatewayId() + "\","; + jsonObject.put("gatewayAuthMethod", this.getLastAccessedGatewayId()); } else { - gatewayCfgStr += "\"lastAccessedGatewayId\":\"\","; + jsonObject.put("gatewayAuthMethod", ""); } if (this.getLastAccessedGatewayTime() != null) { - gatewayCfgStr += "\"lastAccessedGatewayTime\":\"" + this.getLastAccessedGatewayTime() + "\"}"; + jsonObject.put("lastAccessedGatewayTime", this.getLastAccessedGatewayTime()); } else { - gatewayCfgStr += "\"lastAccessedGatewayTime\":\"\"}"; + jsonObject.put("lastAccessedGatewayTime", ""); } - return gatewayCfgStr; - + return jsonObject; } } diff --git a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/devicetypes/Status.java b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/devicetypes/Status.java index a795265a..7550a125 100644 --- a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/devicetypes/Status.java +++ b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/devicetypes/Status.java @@ -2,6 +2,8 @@ import java.util.List; +import org.json.simple.JSONObject; + public class Status { private int code; private String message; @@ -110,4 +112,16 @@ public String toString() { } return statuStr; } + + public JSONObject toJSONObject() { + JSONObject jsonObject = new JSONObject(); + jsonObject.put("code", this.getCode()); + if (this.getMessage() != null) { + jsonObject.put("message", this.getMessage()); + } else { + jsonObject.put("message", ""); + } + return jsonObject; + } + } From 7b59fcd2c30c721c472e21762c059fe0084a1c10 Mon Sep 17 00:00:00 2001 From: mikoaro Date: Tue, 31 Jan 2023 12:23:39 -0600 Subject: [PATCH 058/151] Maven Central Deploy --- README.md | 2 +- clearblade-cloud-iot/pom.xml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 1bb87343..acace340 100644 --- a/README.md +++ b/README.md @@ -21,7 +21,7 @@ If you are using Maven artifact, simply add the following dependency to your pom io.github.clearblade clearblade-cloud-iot - 0.1.0 + 0.1.1 ``` diff --git a/clearblade-cloud-iot/pom.xml b/clearblade-cloud-iot/pom.xml index 23d1de77..7ca7811b 100644 --- a/clearblade-cloud-iot/pom.xml +++ b/clearblade-cloud-iot/pom.xml @@ -3,7 +3,7 @@ io.github.clearblade clearblade-cloud-iot - 0.1.0 + 0.1.1 jar Java Client Library for ClearBlade IoT Core From 1eee8f2823fbf3866a583604c26f29f6ea2cb43b Mon Sep 17 00:00:00 2001 From: ronak-ingress Date: Wed, 1 Feb 2023 20:43:48 +0530 Subject: [PATCH 059/151] - Removed toString method --- .../cloud/iot/v1/devicetypes/Device.java | 15 ++------ .../iot/v1/devicetypes/GatewayConfig.java | 38 +------------------ 2 files changed, 4 insertions(+), 49 deletions(-) diff --git a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/devicetypes/Device.java b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/devicetypes/Device.java index ecb50ce0..1f393105 100644 --- a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/devicetypes/Device.java +++ b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/devicetypes/Device.java @@ -393,25 +393,16 @@ public String createDeviceJSONObject() { if (this.lastErrorTime != null) deviceObj.put("lastErrorTime", this.lastErrorTime); - String metaStr = ""; if (this.metadata != null && this.metadata.size() > 0) { Set metaSet = this.metadata.keySet(); Iterator itr = metaSet.iterator(); - int setSize = metaSet.size(); - int i = 0; + JSONObject jsonObject = new JSONObject(); while (itr.hasNext()) { String key = (String) itr.next(); String value = this.metadata.get(key).toString(); - if (i >= 0 && i < setSize) { - metaStr += "{\"" + key + "\":" + "\"" + value + "\","; - } else if (i == setSize) { - metaStr += "{\"" + key + "\":" + "\"" + value + "\"}"; - } else { - metaStr += "{\"" + key + "\":" + "\"" + value + "\""; - } - i++; + jsonObject.put(key, value); } - deviceObj.put("metadata", metaStr); + deviceObj.put("metadata", jsonObject); } if (this.lastErrorStatus != null && this.lastErrorStatus.getCode() != 0) { diff --git a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/devicetypes/GatewayConfig.java b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/devicetypes/GatewayConfig.java index 071045bd..8bdf982c 100644 --- a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/devicetypes/GatewayConfig.java +++ b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/devicetypes/GatewayConfig.java @@ -80,55 +80,19 @@ public GatewayConfig build() { } } -// @Override -// public String toString() { -// String gatewayCfgStr = ""; -// -// if (this.getGatewayAuthMethod() != null) { -// gatewayCfgStr += "{\"gatewayAuthMethod\":\"" + this.getGatewayAuthMethod().name() + "\","; -// } else { -// gatewayCfgStr += "{\"gatewayAuthMethod\":\"" + GatewayAuthMethod.GATEWAY_AUTH_METHOD_UNSPECIFIED + "\","; -// } -// if (this.getGatewayType() != null) { -// gatewayCfgStr += "\"gatewayType\":\"" + this.getGatewayType().name() + "\","; -// } else { -// gatewayCfgStr += "\"gatewayType\":\"" + GatewayType.valueOf(GatewayType.NON_GATEWAY_VALUE) + "\","; -// } -// if (this.getLastAccessedGatewayId() != null) { -// gatewayCfgStr += "\"lastAccessedGatewayId\":\"" + this.getLastAccessedGatewayId() + "\","; -// } else { -// gatewayCfgStr += "\"lastAccessedGatewayId\":\"\","; -// } -// if (this.getLastAccessedGatewayTime() != null) { -// gatewayCfgStr += "\"lastAccessedGatewayTime\":\"" + this.getLastAccessedGatewayTime() + "\"}"; -// } else { -// gatewayCfgStr += "\"lastAccessedGatewayTime\":\"\"}"; -// } -// return gatewayCfgStr; -// -// } - public JSONObject toJSONObject() { - JSONObject jsonObject = new JSONObject(); + final JSONObject jsonObject = new JSONObject(); if (this.getGatewayAuthMethod() != null) { jsonObject.put("gatewayAuthMethod", this.getGatewayAuthMethod().name()); - } else { - jsonObject.put("gatewayAuthMethod", GatewayAuthMethod.GATEWAY_AUTH_METHOD_UNSPECIFIED.toString()); } if (this.getGatewayType() != null) { jsonObject.put("gatewayType", this.getGatewayType().name()); - } else { - jsonObject.put("gatewayType", GatewayType.valueOf(GatewayType.NON_GATEWAY_VALUE)); } if (this.getLastAccessedGatewayId() != null) { jsonObject.put("gatewayAuthMethod", this.getLastAccessedGatewayId()); - } else { - jsonObject.put("gatewayAuthMethod", ""); } if (this.getLastAccessedGatewayTime() != null) { jsonObject.put("lastAccessedGatewayTime", this.getLastAccessedGatewayTime()); - } else { - jsonObject.put("lastAccessedGatewayTime", ""); } return jsonObject; } From e8b4d1da8c275f2d5de41ac5093dd7a0d23df99c Mon Sep 17 00:00:00 2001 From: mikoaro <37387347+mikoaro@users.noreply.github.com> Date: Wed, 1 Feb 2023 09:26:14 -0600 Subject: [PATCH 060/151] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index acace340..1bb87343 100644 --- a/README.md +++ b/README.md @@ -21,7 +21,7 @@ If you are using Maven artifact, simply add the following dependency to your pom io.github.clearblade clearblade-cloud-iot - 0.1.1 + 0.1.0 ``` From 462daf0d8dc7d2dc52127c2e88e2a276d036622f Mon Sep 17 00:00:00 2001 From: ronak-ingress Date: Tue, 7 Feb 2023 00:50:46 +0530 Subject: [PATCH 061/151] - Added exception handlings. - Added exception to support custom exception. - Updated sample code. --- .../createdevice/AsyncCreateDevice.java | 92 ++---- .../AsyncCreateDeviceRegistry.java | 38 +-- .../deletedevice/AsyncDeleteDevice.java | 21 +- .../AsyncDeleteDeviceRegistry.java | 33 +- .../v1/samples/getdevice/AsyncGetDevice.java | 36 +-- .../AsyncSendCommandToDevice.java | 24 +- .../updatedevice/AsyncUpdateDevice.java | 73 ++--- .../AsyncUpdateDeviceRegistry.java | 45 +-- .../cloud/iot/v1/ClearBladeDeviceManager.java | 284 +++++++++++------- .../iot/v1/ClearBladeRegistryManager.java | 76 +++-- .../iot/v1/DeviceManagerAsyncClient.java | 44 +-- .../cloud/iot/v1/ResponseCallback.java | 8 - .../cloud/iot/v1/devicetypes/Device.java | 2 +- .../v1/exception/ApplicationException.java | 23 +- 14 files changed, 442 insertions(+), 357 deletions(-) delete mode 100644 clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/ResponseCallback.java diff --git a/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/createdevice/AsyncCreateDevice.java b/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/createdevice/AsyncCreateDevice.java index 1382ae52..21a7d64b 100644 --- a/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/createdevice/AsyncCreateDevice.java +++ b/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/createdevice/AsyncCreateDevice.java @@ -7,7 +7,6 @@ import java.util.List; import com.clearblade.cloud.iot.v1.DeviceManagerAsyncClient; -import com.clearblade.cloud.iot.v1.ResponseCallback; import com.clearblade.cloud.iot.v1.createdevice.CreateDeviceRequest; import com.clearblade.cloud.iot.v1.devicetypes.Device; import com.clearblade.cloud.iot.v1.devicetypes.DeviceConfig; @@ -17,6 +16,7 @@ import com.clearblade.cloud.iot.v1.devicetypes.GatewayConfig; import com.clearblade.cloud.iot.v1.devicetypes.GatewayType; import com.clearblade.cloud.iot.v1.devicetypes.Status; +import com.clearblade.cloud.iot.v1.exception.ApplicationException; import com.clearblade.cloud.iot.v1.registrytypes.PublicKeyCredential; import com.clearblade.cloud.iot.v1.registrytypes.PublicKeyFormat; import com.clearblade.cloud.iot.v1.registrytypes.RegistryName; @@ -32,16 +32,11 @@ public class AsyncCreateDevice { static ConfigParameters configParameters = ConfigParameters.getInstance(); public static void main(String[] args) { -// PROJECT = System.getProperty("projectName"); -// LOCATION = System.getProperty("location"); -// REGISTRY = System.getProperty("registryName"); -// DEVICE = System.getProperty("deviceName"); -// NUMID = System.getProperty("numId"); - PROJECT = "api-project-320446546234"; - LOCATION = "asia-east1"; - REGISTRY = "test-asia-east1"; - DEVICE = "Java_SDK_Updated"; - NUMID = null; + PROJECT = System.getProperty("projectName"); + LOCATION = System.getProperty("location"); + REGISTRY = System.getProperty("registryName"); + DEVICE = System.getProperty("deviceName"); + NUMID = System.getProperty("numId"); if (REGISTRY != null) { configParameters.setRegistry(REGISTRY); } @@ -52,19 +47,17 @@ public static void main(String[] args) { } public static void asyncCreateDevice() { - String KEYVAL = "-----BEGIN PUBLIC KEY-----\nMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA5P0Z4OUD5PSjri8xexGo\n6eQ39NGyQbXamIgWAwvnAs/oDRVqEejE2nwDhnpykaCGLkuDEN0LPd2wF+vC2Cq3\nY3YvkJh71IkjuAjMZQ+00CXdezfCjmTtEpMCNA3cV+G1g6uIcdEpHKs0YHfC9CFQ\nrjkc7tl3idmcQLngIov/gsFY7D1pbOgkCVVcZCRLgsdFfhCUYwYCvdEVJP3w+5mG\nybvmhNRbbFG7eG3+hmZoOg0h3f6r2fqgSx6l0+Z3D77SRT6lBEHvGDlxb08ASeuE\n0SJAc6PdAKd3FDqdZok4z1qJsgMqtU/ZGJJG54pNECWmhoOar+aQmmqnZ6kGQ5cn\nEwIDAQAB\n-----END PUBLIC KEY-----\n"; + String TEST_KEYVAL = "-----BEGIN PUBLIC KEY-----\nMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA5P0Z4OUD5PSjri8xexGo\n6eQ39NGyQbXamIgWAwvnAs/oDRVqEejE2nwDhnpykaCGLkuDEN0LPd2wF+vC2Cq3\nY3YvkJh71IkjuAjMZQ+00CXdezfCjmTtEpMCNA3cV+G1g6uIcdEpHKs0YHfC9CFQ\nrjkc7tl3idmcQLngIov/gsFY7D1pbOgkCVVcZCRLgsdFfhCUYwYCvdEVJP3w+5mG\nybvmhNRbbFG7eG3+hmZoOg0h3f6r2fqgSx6l0+Z3D77SRT6lBEHvGDlxb08ASeuE\n0SJAc6PdAKd3FDqdZok4z1qJsgMqtU/ZGJJG54pNECWmhoOar+aQmmqnZ6kGQ5cn\nEwIDAQAB\n-----END PUBLIC KEY-----\n"; PublicKeyCredential publicKeyCredential = new PublicKeyCredential(); - publicKeyCredential.setKey(KEYVAL); - publicKeyCredential.setFormat(PublicKeyFormat.ES256_PEM); + publicKeyCredential.setKey(TEST_KEYVAL); + publicKeyCredential.setFormat(PublicKeyFormat.ES256_PEM); + + DeviceCredential devCredential = new DeviceCredential(); + devCredential.setPublicKey(publicKeyCredential); - DeviceCredential devCredential = new DeviceCredential(); - devCredential.setPublicKey(publicKeyCredential); - - - DeviceManagerAsyncClient deviceManagerAsyncClient = new DeviceManagerAsyncClient(); - + RegistryName parent = RegistryName.of(PROJECT, LOCATION, REGISTRY); GatewayConfig gatewayCfg = new GatewayConfig(); gatewayCfg.setGatewayAuthMethod(GatewayAuthMethod.GATEWAY_AUTH_METHOD_UNSPECIFIED); @@ -72,51 +65,32 @@ public static void asyncCreateDevice() { Status status = new Status(); status.setCode(200); - status.setMessage("Testing status code"); - + status.setMessage("Test status"); + DeviceConfig deviceConfig = new DeviceConfig(); - deviceConfig.setVersion("3"); - deviceConfig.setBinaryData("U3RhdGVPZkdyYWNl"); - + deviceConfig.setVersion("1"); + deviceConfig.setBinaryData("VGVzdGluZw=="); + HashMap metadata = new HashMap<>(); - metadata.put("test", "value"); - + metadata.put("test_key", "test_value"); + DeviceState deviceState = new DeviceState(); - deviceState.setBinaryData("VGVzdGluZy4h"); + deviceState.setBinaryData("VGVzdGluZw=="); deviceState.setUpdateTime(String.valueOf(System.currentTimeMillis())); - - Device device = Device.newBuilder() - .setId(DEVICE) - .setName(DEVICE) - .setNumId(NUMID) - .setBlocked(false) - .setGatewayConfig(gatewayCfg) - .setLogLevel(LogLevel.ERROR) - .setCredentials(List.of(devCredential)) - .setLastErrorStatus(status) - .setConfig(deviceConfig) - .setState(deviceState) - .setLastConfigAckTime(String.valueOf(System.currentTimeMillis())) - .setLastConfigSendTime(String.valueOf(System.currentTimeMillis())) - .setLastErrorTime(String.valueOf(System.currentTimeMillis())) - .setMetadata(metadata) - .build(); + + Device device = Device.newBuilder().setId(DEVICE).setNumId(NUMID).setBlocked(false).setGatewayConfig(gatewayCfg) + .setLogLevel(LogLevel.ERROR).setCredentials(List.of(devCredential)).setConfig(deviceConfig) + .setMetadata(metadata).build(); CreateDeviceRequest request = CreateDeviceRequest.Builder.newBuilder().setParent(parent).setDevice(device) .build(); - deviceManagerAsyncClient.createDevice(request, new ResponseCallback() { - - @Override - public void onSuccess(String message) { - // TODO Auto-generated method stub - System.out.println("onSuccess: " + message); - } - - @Override - public void onFail(String message) { - // TODO Auto-generated method stub - System.out.println("onFail: " + message); - } - }); + Device response = null; + try { + response = deviceManagerAsyncClient.createDevice(request); + } catch (ApplicationException e) { + // TODO: handle exception + e.printStackTrace(); + System.out.println(e.getMessage()); + } } } diff --git a/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/createdeviceregistry/AsyncCreateDeviceRegistry.java b/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/createdeviceregistry/AsyncCreateDeviceRegistry.java index b5ead80a..9a426193 100644 --- a/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/createdeviceregistry/AsyncCreateDeviceRegistry.java +++ b/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/createdeviceregistry/AsyncCreateDeviceRegistry.java @@ -2,6 +2,7 @@ import com.clearblade.cloud.iot.v1.DeviceManagerAsyncClient; import com.clearblade.cloud.iot.v1.createdeviceregistry.CreateDeviceRegistryRequest; +import com.clearblade.cloud.iot.v1.exception.ApplicationException; import com.clearblade.cloud.iot.v1.registrytypes.DeviceRegistry; import com.clearblade.cloud.iot.v1.registrytypes.LocationName; import com.clearblade.cloud.iot.v1.utils.ConfigParameters; @@ -11,33 +12,32 @@ public class AsyncCreateDeviceRegistry { public static String LOCATION = ""; public static String REGISTRY = ""; static ConfigParameters configParameters = ConfigParameters.getInstance(); - public static void main(String[] args) { + + public static void main(String[] args) { PROJECT = System.getProperty("projectName"); LOCATION = System.getProperty("location"); REGISTRY = System.getProperty("registryName"); - if(REGISTRY != null) { + if (REGISTRY != null) { configParameters.setRegistry(REGISTRY); - } - if(LOCATION != null) { + } + if (LOCATION != null) { configParameters.setRegion(LOCATION); } asyncCreateDeviceRegistry(); - } + } - public static void asyncCreateDeviceRegistry() { - DeviceManagerAsyncClient deviceManagerClient = new DeviceManagerAsyncClient(); - CreateDeviceRegistryRequest request = CreateDeviceRegistryRequest.Builder.newBuilder() - .setParent(LocationName.of(PROJECT, LOCATION).toString()) - .setDeviceRegistry( - DeviceRegistry.newBuilder().setId(REGISTRY).build()) - .build(); - DeviceRegistry response = deviceManagerClient.createDeviceRegistry(request); - if(response != null) { - System.out.println("CreateDeviceRegistry execution successful"); - }else { - System.out.println("CreateDeviceRegistry execution failed"); + public static void asyncCreateDeviceRegistry() { + DeviceManagerAsyncClient deviceManagerClient = new DeviceManagerAsyncClient(); + CreateDeviceRegistryRequest request = CreateDeviceRegistryRequest.Builder.newBuilder() + .setParent(LocationName.of(PROJECT, LOCATION).toString()) + .setDeviceRegistry(DeviceRegistry.newBuilder().setId(REGISTRY).build()).build(); + try { + DeviceRegistry response = deviceManagerClient.createDeviceRegistry(request); + System.out.print(response); + } catch (ApplicationException e) { + // TODO: handle exception + e.printStackTrace(); } - - } + } } diff --git a/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/deletedevice/AsyncDeleteDevice.java b/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/deletedevice/AsyncDeleteDevice.java index 1e6d71a8..f57ef2b1 100644 --- a/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/deletedevice/AsyncDeleteDevice.java +++ b/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/deletedevice/AsyncDeleteDevice.java @@ -8,20 +8,20 @@ public class AsyncDeleteDevice { public static String PROJECT = ""; - public static String LOCATION = ""; - public static String REGISTRY = ""; - public static String DEVICE = ""; + public static String LOCATION = ""; + public static String REGISTRY = ""; + public static String DEVICE = ""; static ConfigParameters configParameters = ConfigParameters.getInstance(); - public static void main(String[] args) { + public static void main(String[] args) { PROJECT = System.getProperty("projectName"); LOCATION = System.getProperty("location"); REGISTRY = System.getProperty("registryName"); DEVICE = System.getProperty("deviceName"); - if(REGISTRY != null) { + if (REGISTRY != null) { configParameters.setRegistry(REGISTRY); - } - if(LOCATION != null) { + } + if (LOCATION != null) { configParameters.setRegion(LOCATION); } asyncDeleteDevice(); @@ -31,7 +31,12 @@ public static void asyncDeleteDevice() { DeviceManagerAsyncClient deviceManagerAsyncClient = new DeviceManagerAsyncClient(); DeviceName deviceName = DeviceName.of(PROJECT, LOCATION, REGISTRY, DEVICE); DeleteDeviceRequest request = DeleteDeviceRequest.Builder.newBuilder().setName(deviceName).build(); - deviceManagerAsyncClient.deleteDevice(request); + try { + deviceManagerAsyncClient.deleteDevice(request); + } catch (Exception e) { + // TODO: handle exception + e.printStackTrace(); + } } } diff --git a/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/deletedeviceregistry/AsyncDeleteDeviceRegistry.java b/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/deletedeviceregistry/AsyncDeleteDeviceRegistry.java index cf60f960..dbe448ad 100644 --- a/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/deletedeviceregistry/AsyncDeleteDeviceRegistry.java +++ b/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/deletedeviceregistry/AsyncDeleteDeviceRegistry.java @@ -8,32 +8,35 @@ public class AsyncDeleteDeviceRegistry { public static String PROJECT = ""; - public static String LOCATION = ""; - public static String REGISTRY = ""; + public static String LOCATION = ""; + public static String REGISTRY = ""; static ConfigParameters configParameters = ConfigParameters.getInstance(); - public static void main(String[] args) throws Exception { - PROJECT = System.getProperty("projectName"); - LOCATION = System.getProperty("location"); - REGISTRY = System.getProperty("registryName"); - if(REGISTRY != null) { + public static void main(String[] args) throws Exception { + PROJECT = System.getProperty("projectName"); + LOCATION = System.getProperty("location"); + REGISTRY = System.getProperty("registryName"); + if (REGISTRY != null) { configParameters.setRegistry(REGISTRY); - } - if(LOCATION != null) { + } + if (LOCATION != null) { configParameters.setRegion(LOCATION); } asyncDeleteDeviceRegistry(); } public static void asyncDeleteDeviceRegistry() throws Exception { - + DeviceManagerAsyncClient deviceManagerClient = new DeviceManagerAsyncClient(); DeleteDeviceRegistryRequest request = DeleteDeviceRegistryRequest.Builder.newBuilder() - .setName(RegistryName.of(PROJECT, LOCATION, REGISTRY) - .getRegistryFullName()) - .build(); - deviceManagerClient.deleteDeviceRegistry(request); - + .setName(RegistryName.of(PROJECT, LOCATION, REGISTRY).getRegistryFullName()).build(); + try { + deviceManagerClient.deleteDeviceRegistry(request); + } catch (Exception e) { + // TODO: handle exception + e.printStackTrace(); + System.out.print(e.getMessage()); + } } } \ No newline at end of file diff --git a/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/getdevice/AsyncGetDevice.java b/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/getdevice/AsyncGetDevice.java index a3bd2ee1..042afc6b 100644 --- a/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/getdevice/AsyncGetDevice.java +++ b/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/getdevice/AsyncGetDevice.java @@ -9,20 +9,20 @@ public class AsyncGetDevice { public static String PROJECT = ""; - public static String LOCATION = ""; - public static String REGISTRY = ""; - public static String DEVICE = ""; + public static String LOCATION = ""; + public static String REGISTRY = ""; + public static String DEVICE = ""; static ConfigParameters configParameters = ConfigParameters.getInstance(); - public static void main(String[] args) { - PROJECT = System.getProperty("projectName"); - LOCATION = System.getProperty("location"); - REGISTRY = System.getProperty("registryName"); - DEVICE = System.getProperty("deviceName"); - if(REGISTRY != null) { + public static void main(String[] args) { + PROJECT = System.getProperty("projectName"); + LOCATION = System.getProperty("location"); + REGISTRY = System.getProperty("registryName"); + DEVICE = System.getProperty("deviceName"); + if (REGISTRY != null) { configParameters.setRegistry(REGISTRY); - } - if(LOCATION != null) { + } + if (LOCATION != null) { configParameters.setRegion(LOCATION); } asyncGetDevice(); @@ -30,15 +30,15 @@ public static void main(String[] args) { public static void asyncGetDevice() { DeviceManagerAsyncClient deviceManagerAsyncClient = new DeviceManagerAsyncClient(); - DeviceName name = DeviceName.of(PROJECT, LOCATION, REGISTRY,DEVICE); + DeviceName name = DeviceName.of(PROJECT, LOCATION, REGISTRY, DEVICE); GetDeviceRequest request = GetDeviceRequest.Builder.newBuilder().setName(name) .setFieldMask(FieldMask.newBuilder().build()).build(); - Device response = deviceManagerAsyncClient.getDevice(request); - if(response != null) { - System.out.println("GetDevice execution successful ::" +response.toBuilder().getName()); - - }else { - System.out.println("GetDevice execution failed"); + try { + Device response = deviceManagerAsyncClient.getDevice(request); + System.out.print(response); + } catch (Exception e) { + // TODO: handle exception + e.printStackTrace(); } } } diff --git a/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/sendcommandtodevice/AsyncSendCommandToDevice.java b/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/sendcommandtodevice/AsyncSendCommandToDevice.java index 96902bcd..9a6e13dd 100644 --- a/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/sendcommandtodevice/AsyncSendCommandToDevice.java +++ b/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/sendcommandtodevice/AsyncSendCommandToDevice.java @@ -16,18 +16,18 @@ public class AsyncSendCommandToDevice { public static String BINARYDATA = ""; public static String SUBFOLDER = ""; static ConfigParameters configParameters = ConfigParameters.getInstance(); - - public static void main(String[] args) { + + public static void main(String[] args) { PROJECT = System.getProperty("projectName"); LOCATION = System.getProperty("location"); REGISTRY = System.getProperty("registryName"); DEVICE = System.getProperty("deviceName"); BINARYDATA = System.getProperty("binaryData"); SUBFOLDER = System.getProperty("subFolder"); - if(REGISTRY != null) { + if (REGISTRY != null) { configParameters.setRegistry(REGISTRY); - } - if(LOCATION != null) { + } + if (LOCATION != null) { configParameters.setRegion(LOCATION); } asyncSendCommandToDevice(); @@ -38,11 +38,15 @@ public static void asyncSendCommandToDevice() { SendCommandToDeviceRequest request = SendCommandToDeviceRequest.Builder.newBuilder() .setName(DeviceName.of(PROJECT, LOCATION, REGISTRY, DEVICE).toString()) .setBinaryData(new ByteString(BINARYDATA)).setSubfolder(SUBFOLDER).build(); - SendCommandToDeviceResponse response = deviceManagerAsyncClient.sendCommandToDevice(request); - if(response != null) { - System.out.println("SendCommandToDevice execution successful"); - }else { - System.out.println("SendCommandToDevice execution failed"); + try { + SendCommandToDeviceResponse response = deviceManagerAsyncClient.sendCommandToDevice(request); + if (response != null) { + System.out.println("SendCommandToDevice execution successful"); + } + } catch (Exception e) { + // TODO: handle exception + e.printStackTrace(); } + } } diff --git a/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/updatedevice/AsyncUpdateDevice.java b/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/updatedevice/AsyncUpdateDevice.java index 027fbc73..9e41a2eb 100644 --- a/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/updatedevice/AsyncUpdateDevice.java +++ b/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/updatedevice/AsyncUpdateDevice.java @@ -7,6 +7,8 @@ import com.clearblade.cloud.iot.v1.DeviceManagerAsyncClient; import com.clearblade.cloud.iot.v1.devicetypes.Device; +import com.clearblade.cloud.iot.v1.devicetypes.Device.Builder; +import com.clearblade.cloud.iot.v1.exception.ApplicationException; import com.clearblade.cloud.iot.v1.devicetypes.DeviceCredential; import com.clearblade.cloud.iot.v1.registrytypes.PublicKeyCredential; import com.clearblade.cloud.iot.v1.registrytypes.PublicKeyFormat; @@ -17,53 +19,52 @@ public class AsyncUpdateDevice { public static String LOCATION = ""; public static String REGISTRY = ""; - public static String DEVICE = ""; - public static String UPDATEMASK = ""; - public static String ARG=""; + public static String DEVICE = ""; + public static String UPDATEMASK = ""; + public static String ARG = ""; public static String[] NEWARGS = null; - public static String KEYFORMAT =""; + public static String KEYFORMAT = PublicKeyFormat.RSA_PEM.name(); public static String KEYVAL = ""; static ConfigParameters configParameters = ConfigParameters.getInstance(); - public static void main(String[] args) { + public static void main(String[] args) { LOCATION = System.getProperty("location"); REGISTRY = System.getProperty("registryName"); DEVICE = System.getProperty("deviceName"); UPDATEMASK = System.getProperty("updateMask"); - if(REGISTRY != null) { + if (REGISTRY != null) { configParameters.setRegistry(REGISTRY); - } - if(LOCATION != null) { + } + if (LOCATION != null) { configParameters.setRegion(LOCATION); } - if(!(System.getProperty("arg").isBlank() || System.getProperty("arg").isEmpty()|| System.getProperty("arg")==null)) + if (!(System.getProperty("arg") == null || System.getProperty("arg").isBlank() + || System.getProperty("arg").isEmpty())) ARG = System.getProperty("arg"); - if(System.getProperty("newArgs") != null) + if (System.getProperty("newArgs") != null) NEWARGS = System.getProperty("newArgs").split(","); - if(System.getProperty("keyFormat") != null) - KEYFORMAT = System.getProperty("keyFormat"); - if(System.getProperty("keyVal") != null) - KEYVAL = System.getProperty("keyVal"); + if (System.getProperty("keyFormat") != null) + KEYFORMAT = System.getProperty("keyFormat"); + if (System.getProperty("keyVal") != null) + KEYVAL = System.getProperty("keyVal"); asyncUpdateDevice(); } public static void asyncUpdateDevice() { - DeviceManagerAsyncClient deviceManagerAsyncClient = new DeviceManagerAsyncClient(); - Device device = new Device(); - device.toBuilder().setId(DEVICE).setName(DEVICE).build(); - if(UPDATEMASK .equals("logLevel")) { - device.toBuilder().setLogLevel(LogLevel.valueOf(ARG)); - }else if(UPDATEMASK .equals("blocked")) { - device.toBuilder().setBlocked(Boolean.valueOf(ARG)); - }else if(UPDATEMASK .equals("metadata")) { + DeviceManagerAsyncClient deviceManagerAsyncClient = new DeviceManagerAsyncClient(); + Builder device = Device.newBuilder().setId(DEVICE).setName(DEVICE); + if (UPDATEMASK.equals("logLevel")) { + device.setLogLevel(LogLevel.valueOf(ARG)); + } else if (UPDATEMASK.equals("blocked")) { + device.setBlocked(Boolean.valueOf(ARG)); + } else if (UPDATEMASK.equals("metadata")) { Map metadata = new HashMap<>(); - for(int i=0;i listCredentials = new ArrayList<>(); PublicKeyCredential publicKeyCredential = new PublicKeyCredential(); publicKeyCredential.setFormat(PublicKeyFormat.valueOf(KEYFORMAT)); @@ -71,16 +72,18 @@ public static void asyncUpdateDevice() { DeviceCredential credential = new DeviceCredential(); credential.setPublicKey(publicKeyCredential); listCredentials.add(credential); - device.toBuilder().setCredentials(listCredentials); + device.setCredentials(listCredentials); } - UpdateDeviceRequest request = UpdateDeviceRequest.Builder.newBuilder().setName(DEVICE).setDevice(device) + UpdateDeviceRequest request = UpdateDeviceRequest.Builder.newBuilder().setName(DEVICE).setDevice(device.build()) .setUpdateMask(UPDATEMASK).build(); - Device response = deviceManagerAsyncClient.updateDevice(request); - if(response != null) { - System.out.println("UpdateDevice execution successful"); - }else { - System.out.println("UpdateDevice execution failed"); + Device response = null; + try { + response = deviceManagerAsyncClient.updateDevice(request); + System.out.println("Response: " + response); + } catch (Exception e) { + // TODO: handle exception + e.printStackTrace(); + System.out.println("Ex: " + e.getMessage()); } - } } diff --git a/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/updatedeviceregistry/AsyncUpdateDeviceRegistry.java b/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/updatedeviceregistry/AsyncUpdateDeviceRegistry.java index 10d8739a..a5089c42 100644 --- a/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/updatedeviceregistry/AsyncUpdateDeviceRegistry.java +++ b/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/updatedeviceregistry/AsyncUpdateDeviceRegistry.java @@ -8,21 +8,21 @@ import com.clearblade.cloud.iot.v1.utils.LogLevel; public class AsyncUpdateDeviceRegistry { - public static String PROJECT = ""; - public static String LOCATION = ""; - public static String REGISTRY = ""; - public static String LOGLEVEL = ""; + public static String PROJECT = ""; + public static String LOCATION = ""; + public static String REGISTRY = ""; + public static String LOGLEVEL = ""; static ConfigParameters configParameters = ConfigParameters.getInstance(); - public static void main(String[] args) throws Exception{ - PROJECT = System.getProperty("projectName"); - LOCATION = System.getProperty("location"); - REGISTRY = System.getProperty("registryName"); - LOGLEVEL = System.getProperty("logLevel"); - if(REGISTRY != null) { + public static void main(String[] args) throws Exception { + PROJECT = System.getProperty("projectName"); + LOCATION = System.getProperty("location"); + REGISTRY = System.getProperty("registryName"); + LOGLEVEL = System.getProperty("logLevel"); + if (REGISTRY != null) { configParameters.setRegistry(REGISTRY); - } - if(LOCATION != null) { + } + if (LOCATION != null) { configParameters.setRegion(LOCATION); } asyncUpdateDeviceRegistry(); @@ -32,17 +32,18 @@ public static void asyncUpdateDeviceRegistry() throws Exception { DeviceManagerAsyncClient deviceManagerClient = new DeviceManagerAsyncClient(); RegistryName name = RegistryName.of(PROJECT, LOCATION, REGISTRY); UpdateDeviceRegistryRequest request = UpdateDeviceRegistryRequest.Builder.newBuilder() - .setDeviceRegistry(DeviceRegistry.newBuilder().setId(REGISTRY) - .setName(name.getRegistryFullName()) - .setLogLevel(LogLevel.valueOf(LOGLEVEL)) - .build()) + .setDeviceRegistry(DeviceRegistry.newBuilder().setId(REGISTRY).setName(name.getRegistryFullName()) + .setLogLevel(LogLevel.valueOf(LOGLEVEL)).build()) .setName(name.getRegistryFullName()).setUpdateMask("logLevel").build(); - - DeviceRegistry response = deviceManagerClient.updateDeviceRegistry(request); - if(response != null) { - System.out.println("UpdateDeviceRegistry execution successful"); - }else { - System.out.println("UpdateDeviceRegistry execution failed"); + try { + DeviceRegistry response = deviceManagerClient.updateDeviceRegistry(request); + if (response != null) { + System.out.println(response); + } + } catch (Exception e) { + // TODO: handle exception + System.out.println(e.getMessage()); + //e.printStackTrace(); } } diff --git a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/ClearBladeDeviceManager.java b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/ClearBladeDeviceManager.java index 8d9ce622..da52ff3c 100644 --- a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/ClearBladeDeviceManager.java +++ b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/ClearBladeDeviceManager.java @@ -13,6 +13,7 @@ import com.clearblade.cloud.iot.v1.devicestateslist.ListDeviceStatesResponse; import com.clearblade.cloud.iot.v1.devicetypes.Device; import com.clearblade.cloud.iot.v1.devicetypes.DeviceConfig; +import com.clearblade.cloud.iot.v1.exception.ApplicationException; import com.clearblade.cloud.iot.v1.getdevice.GetDeviceRequest; import com.clearblade.cloud.iot.v1.listdeviceconfigversions.ListDeviceConfigVersionsRequest; import com.clearblade.cloud.iot.v1.listdeviceconfigversions.ListDeviceConfigVersionsResponse; @@ -30,7 +31,7 @@ public class ClearBladeDeviceManager { static Logger log = Logger.getLogger(ClearBladeDeviceManager.class.getName()); ConfigParameters configParameters = ConfigParameters.getInstance(); - public Device getDevice(GetDeviceRequest request) { + public Device getDevice(GetDeviceRequest request) throws ApplicationException { SyncClient syncClient = new SyncClient(); String[] responseArray = syncClient.get(configParameters.getDevicesURLExtension(), request.toString(), false); if (responseArray[0] != null) { @@ -39,31 +40,34 @@ public Device getDevice(GetDeviceRequest request) { Device device = Device.newBuilder().build(); device.loadFromString(responseArray[2]); return device; + } else { + throw new ApplicationException(responseArray[2]); } } return null; } - public Device asyncGetDevice(GetDeviceRequest request) { + public Device asyncGetDevice(GetDeviceRequest request) throws ApplicationException { try { AsyncClient asyncClient = new AsyncClient(); - String[] responseArray = asyncClient.get(configParameters.getDevicesURLExtension(), - request.toString()); + String[] responseArray = asyncClient.get(configParameters.getDevicesURLExtension(), request.toString()); if (responseArray[0] != null) { int responseCode = Integer.parseInt(responseArray[0]); if (responseCode == 200) { Device device = Device.newBuilder().build(); device.loadFromString(responseArray[2]); return device; + } else { + throw new ApplicationException(responseArray[2]); } } } catch (Exception e) { - log.log(Level.SEVERE, e.getMessage()); + throw new ApplicationException(e.getMessage(), e); } return null; } - public Device createDevice(CreateDeviceRequest request) { + public Device createDevice(CreateDeviceRequest request) throws ApplicationException { SyncClient syncClient = new SyncClient(); String[] params = request.getParams(); String reqParams = params[0]; @@ -75,133 +79,156 @@ public Device createDevice(CreateDeviceRequest request) { Device deviceObj = Device.newBuilder().build(); deviceObj.loadFromString(responseArray[2]); return deviceObj; + } else { + throw new ApplicationException(responseArray[2]); } + } else { + throw new ApplicationException(""); } - return null; } - public Device asyncCreateDevice(CreateDeviceRequest request, ResponseCallback callback) { + public Device asyncCreateDevice(CreateDeviceRequest request) throws ApplicationException { try { AsyncClient asyncClient = new AsyncClient(); String[] params = request.getParams(); String reqParams = params[0]; String body = params[1]; - String[] responseArray = asyncClient.post(configParameters.getDevicesURLExtension(), reqParams, - body); + String[] responseArray = asyncClient.post(configParameters.getDevicesURLExtension(), reqParams, body); if (responseArray[0] != null) { int responseCode = Integer.parseInt(responseArray[0]); if (responseCode == 200) { Device deviceObj = Device.newBuilder().build(); deviceObj.loadFromString(responseArray[2]); - callback.onSuccess(responseArray[2]); return deviceObj; } else { - callback.onFail(responseArray[2]); + throw new ApplicationException(responseArray[2]); } } + return null; } catch (Exception e) { - log.log(Level.SEVERE, e.getMessage()); + // TODO: handle exception + throw new ApplicationException(e.getMessage(), e); } - return null; } - public void deleteDevice(DeleteDeviceRequest request) { + public void deleteDevice(DeleteDeviceRequest request) throws ApplicationException { SyncClient syncClient = new SyncClient(); String[] responseArray = syncClient.delete(configParameters.getDevicesURLExtension(), request.toString(), false); if (responseArray[0] != null) { - System.out.println("DeleteDevice execution successful"); - log.log(Level.INFO, ()-> "Response code " + responseArray[0] + " received with message" + responseArray[2]); - }else { - System.out.println("DeleteDevice execution failed"); + int responseCode = Integer.parseInt(responseArray[0]); + if (responseCode != 200) { + throw new ApplicationException(responseArray[2]); + } + } else { + throw new ApplicationException(""); } } - public void asyncDeleteDevice(DeleteDeviceRequest request) { + public void asyncDeleteDevice(DeleteDeviceRequest request) throws ApplicationException { try { AsyncClient asyncClient = new AsyncClient(); - String[] responseArray = asyncClient.delete(configParameters.getDevicesURLExtension(), - request.toString()); - if(responseArray[0] != null) { - System.out.println("DeleteDevice execution successful"); - log.log(Level.INFO, ()-> "Response code " + responseArray[0] + " received with message" + responseArray[2]); - }else { - System.out.println("DeleteDevice execution failed"); + String[] responseArray = asyncClient.delete(configParameters.getDevicesURLExtension(), request.toString()); + if (responseArray[0] != null) { + int responseCode = Integer.parseInt(responseArray[0]); + if (responseCode != 200) { + throw new ApplicationException(responseArray[2]); + } + } else { + throw new ApplicationException(""); } - } catch (Exception e) { log.log(Level.SEVERE, e.getMessage()); + throw new ApplicationException(e.getMessage(), e); } } - public Device updateDevice(UpdateDeviceRequest request) { + public Device updateDevice(UpdateDeviceRequest request) throws ApplicationException { try { - SyncClient syncClient = new SyncClient(); - String[] params = request.getBodyAndParams(); - String reqParams = params[0]; - String body = params[1]; - String[] responseArray; + SyncClient syncClient = new SyncClient(); + String[] params = request.getBodyAndParams(); + String reqParams = params[0]; + String body = params[1]; + String[] responseArray; responseArray = syncClient.update(configParameters.getDevicesURLExtension(), reqParams, body); - if (responseArray[0] != null) { - int responseCode = Integer.parseInt(responseArray[0]); - if (responseCode == 200) { - Device deviceObj = Device.newBuilder().build(); - deviceObj.loadFromString(responseArray[2]); - return deviceObj; + if (responseArray[0] != null) { + int responseCode = Integer.parseInt(responseArray[0]); + if (responseCode == 200) { + Device deviceObj = Device.newBuilder().build(); + deviceObj.loadFromString(responseArray[2]); + return deviceObj; + } else { + throw new ApplicationException(responseArray[2]); + } + } else { + throw new ApplicationException(); } - } } catch (InterruptedException e) { log.log(Level.SEVERE, e.getMessage()); Thread.currentThread().interrupt(); + throw new ApplicationException(e.getMessage(), e); } - return null; } - public Device asyncUpdateDevice(UpdateDeviceRequest request) { + public Device asyncUpdateDevice(UpdateDeviceRequest request) throws ApplicationException { try { AsyncClient asyncClient = new AsyncClient(); String[] params = request.getBodyAndParams(); String reqParams = params[0]; String body = params[1]; - String[] responseArray = asyncClient.update(configParameters.getDevicesURLExtension(), reqParams, - body); + String[] responseArray = asyncClient.update(configParameters.getDevicesURLExtension(), reqParams, body); if (responseArray[0] != null) { int responseCode = Integer.parseInt(responseArray[0]); if (responseCode == 200) { Device deviceObj = Device.newBuilder().build(); deviceObj.loadFromString(responseArray[2]); return deviceObj; + } else { + throw new ApplicationException(responseArray[2]); } + } else { + throw new ApplicationException(responseArray[2]); } } catch (Exception e) { - log.log(Level.SEVERE, e.getMessage()); + throw new ApplicationException(e.getMessage(), e); } - return null; } - public BindDeviceToGatewayResponse bindDeviceToGateway(BindDeviceToGatewayRequest request) { + public BindDeviceToGatewayResponse bindDeviceToGateway(BindDeviceToGatewayRequest request) + throws ApplicationException { SyncClient syncClient = new SyncClient(); String[] paramBody = request.getBodyAndParams(); - String[] responseArray = syncClient.post(configParameters.getCloudiotURLExtension(), paramBody[0], - paramBody[1], false); + String[] responseArray = syncClient.post(configParameters.getCloudiotURLExtension(), paramBody[0], paramBody[1], + false); BindDeviceToGatewayResponse response = BindDeviceToGatewayResponse.Builder.newBuilder().build(); if (responseArray[0] != null) { - response.setHttpStatusCode(Integer.parseInt(responseArray[0])); - response.setHttpStatusResponse(responseArray[1]); + int responseCode = Integer.parseInt(responseArray[0]); + if (responseCode == 200) { + response.setHttpStatusCode(Integer.parseInt(responseArray[0])); + response.setHttpStatusResponse(responseArray[1]); + } else { + throw new ApplicationException(responseArray[2]); + } } return response; } - public BindDeviceToGatewayResponse asyncBindDeviceToGateway(BindDeviceToGatewayRequest request) { + public BindDeviceToGatewayResponse asyncBindDeviceToGateway(BindDeviceToGatewayRequest request) + throws ApplicationException { try { AsyncClient asyncClient = new AsyncClient(); String[] paramBody = request.getBodyAndParams(); - String[] responseArray = asyncClient.post(configParameters.getCloudiotURLExtension(), - paramBody[0], paramBody[1]); + String[] responseArray = asyncClient.post(configParameters.getCloudiotURLExtension(), paramBody[0], + paramBody[1]); BindDeviceToGatewayResponse response = BindDeviceToGatewayResponse.Builder.newBuilder().build(); if (responseArray[0] != null) { - response.setHttpStatusCode(Integer.parseInt(responseArray[0])); - response.setHttpStatusResponse(responseArray[1]); + int responseCode = Integer.parseInt(responseArray[0]); + if (responseCode == 200) { + response.setHttpStatusCode(Integer.parseInt(responseArray[0])); + response.setHttpStatusResponse(responseArray[1]); + } else { + throw new ApplicationException(responseArray[2]); + } } return response; } catch (Exception e) { @@ -210,70 +237,91 @@ public BindDeviceToGatewayResponse asyncBindDeviceToGateway(BindDeviceToGatewayR return null; } - public UnbindDeviceFromGatewayResponse unbindDeviceFromGateway(UnbindDeviceFromGatewayRequest request) { + public UnbindDeviceFromGatewayResponse unbindDeviceFromGateway(UnbindDeviceFromGatewayRequest request) + throws ApplicationException { SyncClient syncClinet = new SyncClient(); String[] paramBody = request.getBodyAndParams(); - String[] responseArray = syncClinet.post(configParameters.getCloudiotURLExtension(), paramBody[0], - paramBody[1], false); + String[] responseArray = syncClinet.post(configParameters.getCloudiotURLExtension(), paramBody[0], paramBody[1], + false); UnbindDeviceFromGatewayResponse response = UnbindDeviceFromGatewayResponse.Builder.newBuilder().build(); if (responseArray[0] != null) { - response.setHttpStatusCode(Integer.parseInt(responseArray[0])); - response.setHttpStatusResponse(responseArray[1]); + int responseCode = Integer.parseInt(responseArray[0]); + if (responseCode == 200) { + response.setHttpStatusCode(Integer.parseInt(responseArray[0])); + response.setHttpStatusResponse(responseArray[1]); + } else { + throw new ApplicationException(responseArray[2]); + } } return response; } - public UnbindDeviceFromGatewayResponse asyncUnbindDeviceFromGateway(UnbindDeviceFromGatewayRequest request) { + public UnbindDeviceFromGatewayResponse asyncUnbindDeviceFromGateway(UnbindDeviceFromGatewayRequest request) + throws ApplicationException { try { AsyncClient asyncClinet = new AsyncClient(); String[] paramBody = request.getBodyAndParams(); - String[] responseArray = asyncClinet.post( - configParameters.getCloudiotURLExtension(), paramBody[0], paramBody[1]); + String[] responseArray = asyncClinet.post(configParameters.getCloudiotURLExtension(), paramBody[0], + paramBody[1]); UnbindDeviceFromGatewayResponse response = UnbindDeviceFromGatewayResponse.Builder.newBuilder().build(); if (responseArray[0] != null) { - response.setHttpStatusCode(Integer.parseInt(responseArray[0])); - response.setHttpStatusResponse(responseArray[1]); + int responseCode = Integer.parseInt(responseArray[0]); + if (responseCode == 200) { + response.setHttpStatusCode(Integer.parseInt(responseArray[0])); + response.setHttpStatusResponse(responseArray[1]); + } else { + throw new ApplicationException(responseArray[2]); + } } return response; } catch (Exception e) { - log.log(Level.SEVERE, e.getMessage()); + throw new ApplicationException(e.getMessage(), e); } - return null; } - public SendCommandToDeviceResponse sendCommandToDevice(SendCommandToDeviceRequest request) { + public SendCommandToDeviceResponse sendCommandToDevice(SendCommandToDeviceRequest request) + throws ApplicationException { SyncClient syncClient = new SyncClient(); String[] paramBody = request.getBodyAndParams(); - String[] responseArray = syncClient.post(configParameters.getDevicesURLExtension(), paramBody[0], - paramBody[1], false); + String[] responseArray = syncClient.post(configParameters.getDevicesURLExtension(), paramBody[0], paramBody[1], + false); SendCommandToDeviceResponse response = SendCommandToDeviceResponse.Builder.newBuilder().build(); if (responseArray[0] != null) { - response.setHttpStatusCode(Integer.parseInt(responseArray[0])); - response.setHttpStatusResponse(responseArray[1]); + int responseCode = Integer.parseInt(responseArray[0]); + if (responseCode == 200) { + response.setHttpStatusCode(Integer.parseInt(responseArray[0])); + response.setHttpStatusResponse(responseArray[1]); + } else { + throw new ApplicationException(responseArray[2]); + } } return response; } - public SendCommandToDeviceResponse asyncSendCommandToDevice(SendCommandToDeviceRequest request) { + public SendCommandToDeviceResponse asyncSendCommandToDevice(SendCommandToDeviceRequest request) + throws ApplicationException { try { AsyncClient asyncClient = new AsyncClient(); String[] paramBody = request.getBodyAndParams(); - String[] responseArray = asyncClient.post(configParameters.getDevicesURLExtension(), - paramBody[0], + String[] responseArray = asyncClient.post(configParameters.getDevicesURLExtension(), paramBody[0], paramBody[1]); SendCommandToDeviceResponse response = SendCommandToDeviceResponse.Builder.newBuilder().build(); if (responseArray[0] != null) { - response.setHttpStatusCode(Integer.parseInt(responseArray[0])); - response.setHttpStatusResponse(responseArray[1]); + int responseCode = Integer.parseInt(responseArray[0]); + if (responseCode == 200) { + response.setHttpStatusCode(Integer.parseInt(responseArray[0])); + response.setHttpStatusResponse(responseArray[1]); + } else { + throw new ApplicationException(responseArray[2]); + } } return response; } catch (Exception e) { - log.log(Level.SEVERE, e.getMessage()); + throw new ApplicationException(e.getMessage(), e); } - return null; } - public DevicesListResponse listDevices(DevicesListRequest request) { + public DevicesListResponse listDevices(DevicesListRequest request) throws ApplicationException { SyncClient syncClient = new SyncClient(); String[] responseArray = syncClient.get(configParameters.getDevicesURLExtension(), request.getParamsForList(), false); @@ -281,12 +329,14 @@ public DevicesListResponse listDevices(DevicesListRequest request) { int responseCode = Integer.parseInt(responseArray[0]); if (responseCode == 200) { return DevicesListResponse.Builder.newBuilder().buildResponse(responseArray[2]).build(); + } else { + throw new ApplicationException(responseArray[2]); } } return null; } - public DevicesListResponse asyncListDevices(DevicesListRequest request) { + public DevicesListResponse asyncListDevices(DevicesListRequest request) throws ApplicationException { try { AsyncClient asyncClient = new AsyncClient(); String[] responseArray = asyncClient.get(configParameters.getDevicesURLExtension(), @@ -295,47 +345,53 @@ public DevicesListResponse asyncListDevices(DevicesListRequest request) { int responseCode = Integer.parseInt(responseArray[0]); if (responseCode == 200) { return DevicesListResponse.Builder.newBuilder().buildResponse(responseArray[2]).build(); + } else { + throw new ApplicationException(responseArray[2]); } } } catch (Exception e) { - log.log(Level.SEVERE, e.getMessage()); + throw new ApplicationException(e.getMessage(), e); } return null; } - public DeviceConfig modifyCloudToDeviceConfig(ModifyCloudToDeviceConfigRequest request) { + public DeviceConfig modifyCloudToDeviceConfig(ModifyCloudToDeviceConfigRequest request) + throws ApplicationException { SyncClient syncClient = new SyncClient(); String[] paramBody = request.getBodyAndParams(); - String[] responseArray = syncClient.post(configParameters.getDevicesURLExtension(), paramBody[0], - paramBody[1], false); + String[] responseArray = syncClient.post(configParameters.getDevicesURLExtension(), paramBody[0], paramBody[1], + false); DeviceConfig deviceConfig = DeviceConfig.newBuilder().build(); if (responseArray[0] != null) { if (Integer.parseInt(responseArray[0]) == 200) deviceConfig.loadFromString(responseArray[2]); + else + throw new ApplicationException(responseArray[2]); } return deviceConfig; } - public DeviceConfig asyncModifyCloudToDeviceConfig(ModifyCloudToDeviceConfigRequest request) { + public DeviceConfig asyncModifyCloudToDeviceConfig(ModifyCloudToDeviceConfigRequest request) + throws ApplicationException { try { AsyncClient asyncClient = new AsyncClient(); String[] paramBody = request.getBodyAndParams(); - String[] responseArray = asyncClient.post( - configParameters.getDevicesURLExtension(), paramBody[0], + String[] responseArray = asyncClient.post(configParameters.getDevicesURLExtension(), paramBody[0], paramBody[1]); DeviceConfig deviceConfig = DeviceConfig.newBuilder().build(); if (responseArray[0] != null) { if (Integer.parseInt(responseArray[0]) == 200) deviceConfig.loadFromString(responseArray[2]); + else + throw new ApplicationException(responseArray[2]); } return deviceConfig; } catch (Exception e) { - log.log(Level.SEVERE, e.getMessage()); + throw new ApplicationException(e.getMessage(), e); } - return null; } - public ListDeviceStatesResponse listDeviceStates(ListDeviceStatesRequest request) { + public ListDeviceStatesResponse listDeviceStates(ListDeviceStatesRequest request) throws ApplicationException { SyncClient syncClient = new SyncClient(); String[] responseArray = syncClient.get(configParameters.getDevicesStatesURLExtension(), request.getParamsForList(), false); @@ -343,12 +399,13 @@ public ListDeviceStatesResponse listDeviceStates(ListDeviceStatesRequest request int responseCode = Integer.parseInt(responseArray[0]); if (responseCode == 200) { return ListDeviceStatesResponse.Builder.newBuilder().buildResponse(responseArray[2]).build(); - } + } else + throw new ApplicationException(responseArray[2]); } return null; } - public ListDeviceStatesResponse asyncListDeviceStates(ListDeviceStatesRequest request) { + public ListDeviceStatesResponse asyncListDeviceStates(ListDeviceStatesRequest request) throws ApplicationException { try { AsyncClient asyncClient = new AsyncClient(); String[] responseArray = asyncClient.get(configParameters.getDevicesStatesURLExtension(), @@ -357,15 +414,17 @@ public ListDeviceStatesResponse asyncListDeviceStates(ListDeviceStatesRequest re int responseCode = Integer.parseInt(responseArray[0]); if (responseCode == 200) { return ListDeviceStatesResponse.Builder.newBuilder().buildResponse(responseArray[2]).build(); - } + } else + throw new ApplicationException(responseArray[2]); } } catch (Exception e) { - log.log(Level.SEVERE, e.getMessage()); + throw new ApplicationException(e.getMessage(), e); } return null; } - public ListDeviceConfigVersionsResponse listDeviceConfigVersions(ListDeviceConfigVersionsRequest request) { + public ListDeviceConfigVersionsResponse listDeviceConfigVersions(ListDeviceConfigVersionsRequest request) + throws ApplicationException { SyncClient syncClient = new SyncClient(); String[] responseArray = syncClient.get(configParameters.getCloudiotConfigURLExtension(), request.getParamsForList(), false); @@ -373,30 +432,34 @@ public ListDeviceConfigVersionsResponse listDeviceConfigVersions(ListDeviceConfi int responseCode = Integer.parseInt(responseArray[0]); if (responseCode == 200) { return ListDeviceConfigVersionsResponse.Builder.newBuilder().buildResponse(responseArray[2]).build(); - } + } else + throw new ApplicationException(responseArray[2]); } return null; } - public ListDeviceConfigVersionsResponse asyncListDeviceConfigVersions(ListDeviceConfigVersionsRequest request) { + public ListDeviceConfigVersionsResponse asyncListDeviceConfigVersions(ListDeviceConfigVersionsRequest request) + throws ApplicationException { try { AsyncClient asyncClient = new AsyncClient(); - String[] responseArray = asyncClient.get( - configParameters.getCloudiotConfigURLExtension(), + String[] responseArray = asyncClient.get(configParameters.getCloudiotConfigURLExtension(), request.getParamsForList()); if (responseArray[0] != null) { int responseCode = Integer.parseInt(responseArray[0]); if (responseCode == 200) { - return ListDeviceConfigVersionsResponse.Builder.newBuilder().buildResponse(responseArray[2]).build(); - } + return ListDeviceConfigVersionsResponse.Builder.newBuilder().buildResponse(responseArray[2]) + .build(); + } else + throw new ApplicationException(responseArray[2]); } } catch (Exception e) { - log.log(Level.SEVERE, e.getMessage()); + throw new ApplicationException(e.getMessage(), e); } return null; } - public ListDeviceRegistriesResponse listDeviceRegistries(ListDeviceRegistriesRequest request) { + public ListDeviceRegistriesResponse listDeviceRegistries(ListDeviceRegistriesRequest request) + throws ApplicationException { SyncClient syncClient = new SyncClient(); String[] responseArray = syncClient.get(configParameters.getCloudiotURLExtension(), request.getParamsForList(), true); @@ -404,12 +467,14 @@ public ListDeviceRegistriesResponse listDeviceRegistries(ListDeviceRegistriesReq int responseCode = Integer.parseInt(responseArray[0]); if (responseCode == 200) { return ListDeviceRegistriesResponse.Builder.newBuilder().buildResponse(responseArray[2]).build(); - } + } else + throw new ApplicationException(responseArray[2]); } return null; } - public ListDeviceRegistriesResponse asyncListDeviceRegistries(ListDeviceRegistriesRequest request) { + public ListDeviceRegistriesResponse asyncListDeviceRegistries(ListDeviceRegistriesRequest request) + throws ApplicationException { AsyncClient asyncClient = new AsyncClient(); String[] responseArray = asyncClient.asyncListDeviceRegistries(configParameters.getCloudiotURLExtension(), request.getParamsForList(), true); @@ -417,7 +482,8 @@ public ListDeviceRegistriesResponse asyncListDeviceRegistries(ListDeviceRegistri int responseCode = Integer.parseInt(responseArray[0]); if (responseCode == 200) { return ListDeviceRegistriesResponse.Builder.newBuilder().buildResponse(responseArray[2]).build(); - } + } else + throw new ApplicationException(responseArray[2]); } return null; } diff --git a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/ClearBladeRegistryManager.java b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/ClearBladeRegistryManager.java index 9de19f14..cf854d28 100644 --- a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/ClearBladeRegistryManager.java +++ b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/ClearBladeRegistryManager.java @@ -5,6 +5,7 @@ import com.clearblade.cloud.iot.v1.createdeviceregistry.CreateDeviceRegistryRequest; import com.clearblade.cloud.iot.v1.deletedeviceregistry.DeleteDeviceRegistryRequest; +import com.clearblade.cloud.iot.v1.exception.ApplicationException; import com.clearblade.cloud.iot.v1.getdeviceregistry.GetDeviceRegistryRequest; import com.clearblade.cloud.iot.v1.registrytypes.DeviceRegistry; import com.clearblade.cloud.iot.v1.updatedeviceregistry.UpdateDeviceRegistryRequest; @@ -14,7 +15,7 @@ public class ClearBladeRegistryManager { static Logger log = Logger.getLogger(ClearBladeRegistryManager.class.getName()); ConfigParameters configParameters = ConfigParameters.getInstance(); - public DeviceRegistry getRegistry(GetDeviceRegistryRequest request) { + public DeviceRegistry getRegistry(GetDeviceRegistryRequest request) throws ApplicationException { SyncClient syncClient = new SyncClient(); String[] responseArray = syncClient.get(configParameters.getCloudiotURLExtension(), request.toString(), false); if (responseArray[0] != null) { @@ -23,31 +24,34 @@ public DeviceRegistry getRegistry(GetDeviceRegistryRequest request) { DeviceRegistry deviceRegistry = DeviceRegistry.newBuilder().build(); deviceRegistry.loadFromString(responseArray[2]); return deviceRegistry; + } else { + throw new ApplicationException(responseArray[2]); } } return null; } - public DeviceRegistry asyncGetDeviceRegistry(GetDeviceRegistryRequest request) { + public DeviceRegistry asyncGetDeviceRegistry(GetDeviceRegistryRequest request) throws ApplicationException { try { AsyncClient asyncClient = new AsyncClient(); - String[] responseArray = asyncClient.get(configParameters.getCloudiotURLExtension(), - request.toString()); + String[] responseArray = asyncClient.get(configParameters.getCloudiotURLExtension(), request.toString()); if (responseArray[0] != null) { int responseCode = Integer.parseInt(responseArray[0]); if (responseCode == 200) { DeviceRegistry deviceRegistry = DeviceRegistry.newBuilder().build(); deviceRegistry.loadFromString(responseArray[2]); return deviceRegistry; + } else { + throw new ApplicationException(responseArray[2]); } } } catch (Exception e) { - log.log(Level.SEVERE, e.getMessage()); + throw new ApplicationException(e.getMessage(), e); } return null; } - public DeviceRegistry createDeviceRegistry(CreateDeviceRegistryRequest request) { + public DeviceRegistry createDeviceRegistry(CreateDeviceRegistryRequest request) throws ApplicationException { SyncClient syncClient = new SyncClient(); String[] bodyParams = request.getBodyAndParams(); @@ -59,38 +63,41 @@ public DeviceRegistry createDeviceRegistry(CreateDeviceRegistryRequest request) DeviceRegistry deviceRegistry = DeviceRegistry.newBuilder().build(); deviceRegistry.loadFromString(responseArray[2]); return deviceRegistry; + } else { + throw new ApplicationException(responseArray[2]); } } return null; } - public DeviceRegistry asyncCreateDeviceRegistry(CreateDeviceRegistryRequest request) { + public DeviceRegistry asyncCreateDeviceRegistry(CreateDeviceRegistryRequest request) throws ApplicationException { try { AsyncClient asyncClient = new AsyncClient(); String[] bodyParams = request.getBodyAndParams(); String[] responseArray = asyncClient.asyncCreateDeviceRegistry(configParameters.getCloudiotURLExtension(), - bodyParams[0], - bodyParams[1], true); + bodyParams[0], bodyParams[1], true); if (responseArray[0] != null) { int responseCode = Integer.parseInt(responseArray[0]); if (responseCode == 200) { DeviceRegistry deviceRegistry = DeviceRegistry.newBuilder().build(); deviceRegistry.loadFromString(responseArray[2]); return deviceRegistry; + } else { + throw new ApplicationException(responseArray[2]); } } } catch (Exception e) { - log.log(Level.SEVERE, e.getMessage()); + throw new ApplicationException(e.getMessage(), e); } return null; } - public DeviceRegistry updateDeviceRegistry(UpdateDeviceRegistryRequest request) { + public DeviceRegistry updateDeviceRegistry(UpdateDeviceRegistryRequest request) throws ApplicationException { try { - SyncClient syncClient = new SyncClient(); + SyncClient syncClient = new SyncClient(); String[] bodyParams = request.getBodyAndParams(); - + String[] responseArray = syncClient.update(configParameters.getCloudiotURLExtension(), bodyParams[0], bodyParams[1]); if (responseArray[0] != null) { @@ -99,22 +106,23 @@ public DeviceRegistry updateDeviceRegistry(UpdateDeviceRegistryRequest request) DeviceRegistry deviceRegistry = DeviceRegistry.newBuilder().build(); deviceRegistry.loadFromString(responseArray[2]); return deviceRegistry; + } else { + throw new ApplicationException(responseArray[2]); } } - }catch(InterruptedException e) { - log.log(Level.SEVERE, e.getMessage()); + } catch (InterruptedException e) { Thread.currentThread().interrupt(); + throw new ApplicationException(e.getMessage(), e); } return null; } - public DeviceRegistry asyncUpdateDeviceRegistry(UpdateDeviceRegistryRequest request) { + public DeviceRegistry asyncUpdateDeviceRegistry(UpdateDeviceRegistryRequest request) throws ApplicationException { try { AsyncClient asyncClient = new AsyncClient(); String[] bodyParams = request.getBodyAndParams(); - String[] responseArray = asyncClient.update(configParameters.getCloudiotURLExtension(), - bodyParams[0], + String[] responseArray = asyncClient.update(configParameters.getCloudiotURLExtension(), bodyParams[0], bodyParams[1]); if (responseArray[0] != null) { int responseCode = Integer.parseInt(responseArray[0]); @@ -122,40 +130,52 @@ public DeviceRegistry asyncUpdateDeviceRegistry(UpdateDeviceRegistryRequest requ DeviceRegistry deviceRegistry = DeviceRegistry.newBuilder().build(); deviceRegistry.loadFromString(responseArray[2]); return deviceRegistry; + } else { + throw new ApplicationException(responseArray[2]); } } } catch (Exception e) { - log.log(Level.SEVERE, e.getMessage()); + throw new ApplicationException(e.getMessage(), e); } return null; } - public void deleteDeviceRegistry(DeleteDeviceRegistryRequest request) { + public void deleteDeviceRegistry(DeleteDeviceRegistryRequest request) throws ApplicationException { SyncClient syncClient = new SyncClient(); String bodyParams = request.getParams(); String[] responseArray = syncClient.delete(configParameters.getCloudiotURLExtension(), bodyParams, true); if (responseArray[0] != null) { - log.log(Level.INFO, ()->"Response code " + responseArray[0] + " received with message" + responseArray[2]); + int responseCode = Integer.parseInt(responseArray[0]); + if (responseCode == 200) { + log.log(Level.INFO, + () -> "Response code " + responseArray[0] + " received with message" + responseArray[2]); + } else { + throw new ApplicationException(responseArray[2]); + } } } - public void asyncDeleteDeviceRegistry(DeleteDeviceRegistryRequest request) { + public void asyncDeleteDeviceRegistry(DeleteDeviceRegistryRequest request) throws ApplicationException { try { AsyncClient asyncClient = new AsyncClient(); String bodyParams = request.getParams(); - String[] responseArray = asyncClient.asyncDeleteDeviceRegistry(configParameters.getCloudiotURLExtension(), bodyParams, true); + String[] responseArray = asyncClient.asyncDeleteDeviceRegistry(configParameters.getCloudiotURLExtension(), + bodyParams, true); if (responseArray[0] != null) { - System.out.println("DeleteDeviceRegistry execution successful"); - log.log(Level.INFO, ()->"Response code " + responseArray[0] + " received with message" + responseArray[2]); - }else { + int responseCode = Integer.parseInt(responseArray[0]); + if (responseCode == 200) { + System.out.println("DeleteDeviceRegistry execution successful"); + } else { + throw new ApplicationException(responseArray[2]); + } + } else { System.out.println("DeleteDeviceRegistry execution failed"); } - } catch (Exception e) { - log.log(Level.SEVERE, e.getMessage()); + throw new ApplicationException(e.getMessage(), e); } } } diff --git a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/DeviceManagerAsyncClient.java b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/DeviceManagerAsyncClient.java index 7fa97da3..a9abac9d 100644 --- a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/DeviceManagerAsyncClient.java +++ b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/DeviceManagerAsyncClient.java @@ -14,6 +14,7 @@ import com.clearblade.cloud.iot.v1.devicestateslist.ListDeviceStatesResponse; import com.clearblade.cloud.iot.v1.devicetypes.Device; import com.clearblade.cloud.iot.v1.devicetypes.DeviceConfig; +import com.clearblade.cloud.iot.v1.exception.ApplicationException; import com.clearblade.cloud.iot.v1.getdevice.GetDeviceRequest; import com.clearblade.cloud.iot.v1.getdeviceregistry.GetDeviceRegistryRequest; import com.clearblade.cloud.iot.v1.listdeviceconfigversions.ListDeviceConfigVersionsRequest; @@ -51,14 +52,9 @@ public Device getDevice(GetDeviceRequest request) { * @param request * @return Device object */ - public Device createDevice(CreateDeviceRequest request) { + public Device createDevice(CreateDeviceRequest request) throws ApplicationException { ClearBladeDeviceManager cbManager = new ClearBladeDeviceManager(); - return cbManager.asyncCreateDevice(request, null); - } - - public Device createDevice(CreateDeviceRequest request, ResponseCallback callback) { - ClearBladeDeviceManager cbManager = new ClearBladeDeviceManager(); - return cbManager.asyncCreateDevice(request, callback); + return cbManager.asyncCreateDevice(request); } /** @@ -66,7 +62,7 @@ public Device createDevice(CreateDeviceRequest request, ResponseCallback callbac * * @param request */ - public void deleteDevice(DeleteDeviceRequest request) { + public void deleteDevice(DeleteDeviceRequest request) throws ApplicationException { ClearBladeDeviceManager cbManager = new ClearBladeDeviceManager(); cbManager.asyncDeleteDevice(request); } @@ -77,7 +73,7 @@ public void deleteDevice(DeleteDeviceRequest request) { * @param request * @return Device object */ - public Device updateDevice(UpdateDeviceRequest request) { + public Device updateDevice(UpdateDeviceRequest request) throws ApplicationException { ClearBladeDeviceManager cbManager = new ClearBladeDeviceManager(); return cbManager.asyncUpdateDevice(request); } @@ -88,7 +84,8 @@ public Device updateDevice(UpdateDeviceRequest request) { * @param request * @return */ - public BindDeviceToGatewayResponse bindDeviceToGateway(BindDeviceToGatewayRequest request) { + public BindDeviceToGatewayResponse bindDeviceToGateway(BindDeviceToGatewayRequest request) + throws ApplicationException { ClearBladeDeviceManager cbManager = new ClearBladeDeviceManager(); return cbManager.asyncBindDeviceToGateway(request); } @@ -99,33 +96,37 @@ public BindDeviceToGatewayResponse bindDeviceToGateway(BindDeviceToGatewayReques * @param request * @return */ - public UnbindDeviceFromGatewayResponse unbindDeviceFromGateway(UnbindDeviceFromGatewayRequest request) { + public UnbindDeviceFromGatewayResponse unbindDeviceFromGateway(UnbindDeviceFromGatewayRequest request) + throws ApplicationException { ClearBladeDeviceManager cbManager = new ClearBladeDeviceManager(); return cbManager.asyncUnbindDeviceFromGateway(request); } - public SendCommandToDeviceResponse sendCommandToDevice(SendCommandToDeviceRequest request) { + public SendCommandToDeviceResponse sendCommandToDevice(SendCommandToDeviceRequest request) + throws ApplicationException { ClearBladeDeviceManager cbManager = new ClearBladeDeviceManager(); return cbManager.asyncSendCommandToDevice(request); } - public DeviceConfig modifyCloudToDeviceConfig(ModifyCloudToDeviceConfigRequest request) { + public DeviceConfig modifyCloudToDeviceConfig(ModifyCloudToDeviceConfigRequest request) + throws ApplicationException { ClearBladeDeviceManager cbManager = new ClearBladeDeviceManager(); return cbManager.asyncModifyCloudToDeviceConfig(request); } - public DevicesListResponse listDevices(DevicesListRequest request) { + public DevicesListResponse listDevices(DevicesListRequest request) throws ApplicationException { ClearBladeDeviceManager cbManager = new ClearBladeDeviceManager(); return cbManager.asyncListDevices(request); } - public ListDeviceStatesResponse listDeviceStates(ListDeviceStatesRequest request) { + public ListDeviceStatesResponse listDeviceStates(ListDeviceStatesRequest request) throws ApplicationException { ClearBladeDeviceManager cbManager = new ClearBladeDeviceManager(); return cbManager.asyncListDeviceStates(request); } - public ListDeviceConfigVersionsResponse listDeviceConfigVersions(ListDeviceConfigVersionsRequest request) { + public ListDeviceConfigVersionsResponse listDeviceConfigVersions(ListDeviceConfigVersionsRequest request) + throws ApplicationException { ClearBladeDeviceManager cbManager = new ClearBladeDeviceManager(); return cbManager.asyncListDeviceConfigVersions(request); } @@ -138,27 +139,28 @@ public ListDeviceConfigVersionsResponse listDeviceConfigVersions(ListDeviceConfi * @return Device object */ - public DeviceRegistry getDeviceRegistry(GetDeviceRegistryRequest request) { + public DeviceRegistry getDeviceRegistry(GetDeviceRegistryRequest request) throws ApplicationException { ClearBladeRegistryManager cbManager = new ClearBladeRegistryManager(); return cbManager.asyncGetDeviceRegistry(request); } - public DeviceRegistry createDeviceRegistry(CreateDeviceRegistryRequest request) { + public DeviceRegistry createDeviceRegistry(CreateDeviceRegistryRequest request) throws ApplicationException { ClearBladeRegistryManager cbManager = new ClearBladeRegistryManager(); return cbManager.asyncCreateDeviceRegistry(request); } - public DeviceRegistry updateDeviceRegistry(UpdateDeviceRegistryRequest request) { + public DeviceRegistry updateDeviceRegistry(UpdateDeviceRegistryRequest request) throws ApplicationException { ClearBladeRegistryManager cbManager = new ClearBladeRegistryManager(); return cbManager.asyncUpdateDeviceRegistry(request); } - public void deleteDeviceRegistry(DeleteDeviceRegistryRequest request) { + public void deleteDeviceRegistry(DeleteDeviceRegistryRequest request) throws ApplicationException { ClearBladeRegistryManager cbManager = new ClearBladeRegistryManager(); cbManager.asyncDeleteDeviceRegistry(request); } - public ListDeviceRegistriesResponse listDeviceRegistries(ListDeviceRegistriesRequest request) { + public ListDeviceRegistriesResponse listDeviceRegistries(ListDeviceRegistriesRequest request) + throws ApplicationException { ClearBladeDeviceManager cbManager = new ClearBladeDeviceManager(); return cbManager.asyncListDeviceRegistries(request); } diff --git a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/ResponseCallback.java b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/ResponseCallback.java deleted file mode 100644 index 9de02003..00000000 --- a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/ResponseCallback.java +++ /dev/null @@ -1,8 +0,0 @@ -package com.clearblade.cloud.iot.v1; - -public interface ResponseCallback { - - void onSuccess(String message); - - void onFail(String message); -} diff --git a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/devicetypes/Device.java b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/devicetypes/Device.java index 1f393105..daf1228a 100644 --- a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/devicetypes/Device.java +++ b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/devicetypes/Device.java @@ -400,7 +400,7 @@ public String createDeviceJSONObject() { while (itr.hasNext()) { String key = (String) itr.next(); String value = this.metadata.get(key).toString(); - jsonObject.put(key, value); + jsonObject.put(key, value); } deviceObj.put("metadata", jsonObject); } diff --git a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/exception/ApplicationException.java b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/exception/ApplicationException.java index 79f6252e..87b8a1ff 100644 --- a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/exception/ApplicationException.java +++ b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/exception/ApplicationException.java @@ -1,12 +1,27 @@ package com.clearblade.cloud.iot.v1.exception; -public class ApplicationException extends Exception { - /** +public class ApplicationException extends RuntimeException { + /** * */ private static final long serialVersionUID = 1L; + + private static final String defaultMessage = "RuntimeException"; + + public ApplicationException() { + super(defaultMessage); + } public ApplicationException(String errorMessage) { - super(errorMessage); - } + super(errorMessage); + } + + public ApplicationException(Throwable throwable) { + super(throwable); + } + + public ApplicationException(String message, Throwable throwable) { + // super(message, throwable); + super(message, throwable, true, true); + } } From d47d06cb6638a03b26427be770625cce4a1a12c0 Mon Sep 17 00:00:00 2001 From: ronak-ingress Date: Tue, 7 Feb 2023 01:07:21 +0530 Subject: [PATCH 062/151] - Code clean up --- .../iot/v1/devicetypes/DeviceConfig.java | 26 ------------------- .../cloud/iot/v1/devicetypes/DeviceState.java | 16 ------------ .../cloud/iot/v1/devicetypes/Status.java | 16 ------------ 3 files changed, 58 deletions(-) diff --git a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/devicetypes/DeviceConfig.java b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/devicetypes/DeviceConfig.java index 2c508cbd..78af8ce1 100644 --- a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/devicetypes/DeviceConfig.java +++ b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/devicetypes/DeviceConfig.java @@ -121,32 +121,6 @@ public DeviceConfig build() { } } - @Override - public String toString() { - String configStr = ""; - if (this.getVersion() != null) { - configStr += "{\"version\":\"" + this.getBinaryData() + "\","; - } else { - configStr += "{\"version\":\"\","; - } - if (this.getCloudUpdateTime() != null) { - configStr += "\"cloudUpdateTime\":\"" + this.getCloudUpdateTime() + "\","; - } else { - configStr += "\"cloudUpdateTime\":\"\","; - } - if (this.getDeviceAckTime() != null) { - configStr += "\"deviceAckTime\":\"" + this.getDeviceAckTime() + "\","; - } else { - configStr += "\"deviceAckTime\":\"\","; - } - if (this.getBinaryData() != null) { - configStr += "\"binaryData\":\"" + this.getBinaryData() + "\"}"; - } else { - configStr += "\"binaryData\":\"\"}"; - } - return configStr; - } - public void loadFromString(String jsonString) { try { JSONParser jsonParser = new JSONParser(); diff --git a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/devicetypes/DeviceState.java b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/devicetypes/DeviceState.java index 20c2427a..8a4ca7ae 100644 --- a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/devicetypes/DeviceState.java +++ b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/devicetypes/DeviceState.java @@ -74,22 +74,6 @@ public DeviceState build() { } } - @Override - public String toString() { - String stateStr = ""; - if (this.getUpdateTime() != null) { - stateStr += "{\"updateTime\":\"" + this.getUpdateTime() + "\","; - } else { - stateStr += "{\"updateTime\":\"\","; - } - if (this.getBinaryData() != null) { - stateStr += "\"binaryData\":\"" + this.getBinaryData() + "\"}"; - } else { - stateStr += "\"binaryData\":\"\"}"; - } - return stateStr; - } - public JSONObject toJSONObject() { JSONObject jsonObject = new JSONObject(); if (this.getUpdateTime() != null) { diff --git a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/devicetypes/Status.java b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/devicetypes/Status.java index 7550a125..cd3e7ffe 100644 --- a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/devicetypes/Status.java +++ b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/devicetypes/Status.java @@ -97,22 +97,6 @@ public Status build() { } } - @Override - public String toString() { - String statuStr = ""; - if (this.getCode() != 0) { - statuStr += "{\"code\":\"" + this.getCode() + "\","; - } else { - statuStr += "{\"code\":\"0\","; - } - if (this.getMessage() != null) { - statuStr += "\"message\":\"" + this.getMessage() + "\"}"; - } else { - statuStr += "\"message\":\"\"}"; - } - return statuStr; - } - public JSONObject toJSONObject() { JSONObject jsonObject = new JSONObject(); jsonObject.put("code", this.getCode()); From 0f5f4bd0cd20983ed47bf818b424cac42d62b6d3 Mon Sep 17 00:00:00 2001 From: mikoaro Date: Mon, 6 Feb 2023 21:57:41 -0600 Subject: [PATCH 063/151] Error Messages and Central Deploy --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 1bb87343..9774c6ea 100644 --- a/README.md +++ b/README.md @@ -21,7 +21,7 @@ If you are using Maven artifact, simply add the following dependency to your pom io.github.clearblade clearblade-cloud-iot - 0.1.0 + 0.1.2 ``` From 21e82511390413755947f7ffebc3ccbfca86c089 Mon Sep 17 00:00:00 2001 From: mikoaro Date: Mon, 6 Feb 2023 22:00:38 -0600 Subject: [PATCH 064/151] Error Messages and Central Deploy --- clearblade-cloud-iot/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/clearblade-cloud-iot/pom.xml b/clearblade-cloud-iot/pom.xml index 7ca7811b..2cf09b8a 100644 --- a/clearblade-cloud-iot/pom.xml +++ b/clearblade-cloud-iot/pom.xml @@ -3,7 +3,7 @@ io.github.clearblade clearblade-cloud-iot - 0.1.1 + 0.1.2 jar Java Client Library for ClearBlade IoT Core From 9df27992dd7a8867b5ac19ea0f5ed02bfda7e949 Mon Sep 17 00:00:00 2001 From: mikoaro Date: Tue, 7 Feb 2023 05:43:05 -0600 Subject: [PATCH 065/151] COPYRIGHT update --- .../AsyncBindDeviceToGateway.java | 30 +++++++++++++++++++ .../SyncBindDeviceToGateway.java | 30 +++++++++++++++++++ .../createdevice/AsyncCreateDevice.java | 30 +++++++++++++++++++ .../createdevice/SyncCreateDevice.java | 30 +++++++++++++++++++ .../AsyncCreateDeviceRegistry.java | 30 +++++++++++++++++++ .../SyncCreateDeviceRegistry.java | 30 +++++++++++++++++++ .../deletedevice/AsyncDeleteDevice.java | 30 +++++++++++++++++++ .../deletedevice/SyncDeleteDevice.java | 30 +++++++++++++++++++ .../AsyncDeleteDeviceRegistry.java | 30 +++++++++++++++++++ .../SyncDeleteDeviceRegistry.java | 30 +++++++++++++++++++ .../samples/deviceslist/AsyncDevicesList.java | 30 +++++++++++++++++++ .../samples/deviceslist/SyncDevicesList.java | 30 +++++++++++++++++++ .../AsyncDeviceStatesList.java | 30 +++++++++++++++++++ .../SyncDeviceStatesList.java | 30 +++++++++++++++++++ .../v1/samples/getdevice/AsyncGetDevice.java | 30 +++++++++++++++++++ .../v1/samples/getdevice/SyncGetDevice.java | 30 +++++++++++++++++++ .../AsyncGetDeviceRegistry.java | 30 +++++++++++++++++++ .../SyncGetDeviceRegistry.java | 30 +++++++++++++++++++ .../AsyncListDeviceConfigVersions.java | 30 +++++++++++++++++++ .../SyncListDeviceConfigVersions.java | 30 +++++++++++++++++++ .../AsyncListDeviceRegistries.java | 30 +++++++++++++++++++ .../SyncListDeviceRegistries.java | 30 +++++++++++++++++++ .../AsyncModifyCloudToDeviceConfig.java | 30 +++++++++++++++++++ .../SyncModifyCloudToDeviceConfig.java | 30 +++++++++++++++++++ .../AsyncSendCommandToDevice.java | 30 +++++++++++++++++++ .../SyncSendCommandToDevice.java | 30 +++++++++++++++++++ .../AsyncUnbindDeviceFromGateway.java | 30 +++++++++++++++++++ .../SyncUnbindDeviceFromGateway.java | 30 +++++++++++++++++++ .../updatedevice/AsyncUpdateDevice.java | 30 +++++++++++++++++++ .../updatedevice/SyncUpdateDevice.java | 30 +++++++++++++++++++ .../AsyncUpdateDeviceRegistry.java | 30 +++++++++++++++++++ .../SyncUpdateDeviceRegistry.java | 30 +++++++++++++++++++ .../clearblade/cloud/iot/v1/AsyncClient.java | 30 +++++++++++++++++++ .../cloud/iot/v1/ClearBladeDeviceManager.java | 30 +++++++++++++++++++ .../iot/v1/ClearBladeRegistryManager.java | 30 +++++++++++++++++++ .../iot/v1/DeviceManagerAsyncClient.java | 30 +++++++++++++++++++ .../cloud/iot/v1/DeviceManagerClient.java | 30 +++++++++++++++++++ .../clearblade/cloud/iot/v1/SyncClient.java | 30 +++++++++++++++++++ .../BindDeviceToGatewayRequest.java | 30 +++++++++++++++++++ .../BindDeviceToGatewayResponse.java | 30 +++++++++++++++++++ .../v1/createdevice/CreateDeviceRequest.java | 30 +++++++++++++++++++ .../CreateDeviceRegistryRequest.java | 30 +++++++++++++++++++ .../v1/deletedevice/DeleteDeviceRequest.java | 30 +++++++++++++++++++ .../DeleteDeviceRegistryRequest.java | 30 +++++++++++++++++++ .../v1/deviceslist/DevicesListRequest.java | 30 +++++++++++++++++++ .../v1/deviceslist/DevicesListResponse.java | 30 +++++++++++++++++++ .../ListDeviceStatesRequest.java | 30 +++++++++++++++++++ .../ListDeviceStatesResponse.java | 30 +++++++++++++++++++ .../cloud/iot/v1/devicetypes/Device.java | 30 +++++++++++++++++++ .../iot/v1/devicetypes/DeviceConfig.java | 30 +++++++++++++++++++ .../iot/v1/devicetypes/DeviceCredential.java | 30 +++++++++++++++++++ .../cloud/iot/v1/devicetypes/DeviceName.java | 30 +++++++++++++++++++ .../cloud/iot/v1/devicetypes/DeviceState.java | 30 +++++++++++++++++++ .../cloud/iot/v1/devicetypes/FieldMask.java | 30 +++++++++++++++++++ .../iot/v1/devicetypes/GatewayAuthMethod.java | 30 +++++++++++++++++++ .../iot/v1/devicetypes/GatewayConfig.java | 30 +++++++++++++++++++ .../v1/devicetypes/GatewayListOptions.java | 30 +++++++++++++++++++ .../cloud/iot/v1/devicetypes/GatewayType.java | 30 +++++++++++++++++++ .../cloud/iot/v1/devicetypes/Status.java | 30 +++++++++++++++++++ .../v1/exception/ApplicationException.java | 30 +++++++++++++++++++ .../iot/v1/getdevice/GetDeviceRequest.java | 30 +++++++++++++++++++ .../GetDeviceRegistryRequest.java | 30 +++++++++++++++++++ .../ListDeviceConfigVersionsRequest.java | 30 +++++++++++++++++++ .../ListDeviceConfigVersionsResponse.java | 30 +++++++++++++++++++ .../ListDeviceRegistriesRequest.java | 30 +++++++++++++++++++ .../ListDeviceRegistriesResponse.java | 30 +++++++++++++++++++ .../ModifyCloudToDeviceConfigRequest.java | 30 +++++++++++++++++++ .../iot/v1/registrytypes/DeviceRegistry.java | 30 +++++++++++++++++++ .../EventNotificationConfig.java | 30 +++++++++++++++++++ .../iot/v1/registrytypes/HttpConfig.java | 30 +++++++++++++++++++ .../cloud/iot/v1/registrytypes/HttpState.java | 30 +++++++++++++++++++ .../iot/v1/registrytypes/LocationName.java | 30 +++++++++++++++++++ .../iot/v1/registrytypes/MqttConfig.java | 30 +++++++++++++++++++ .../cloud/iot/v1/registrytypes/MqttState.java | 30 +++++++++++++++++++ .../registrytypes/PublicKeyCertificate.java | 30 +++++++++++++++++++ .../PublicKeyCertificateFormat.java | 30 +++++++++++++++++++ .../v1/registrytypes/PublicKeyCredential.java | 30 +++++++++++++++++++ .../iot/v1/registrytypes/PublicKeyFormat.java | 30 +++++++++++++++++++ .../v1/registrytypes/RegistryCredential.java | 30 +++++++++++++++++++ .../iot/v1/registrytypes/RegistryName.java | 30 +++++++++++++++++++ .../StateNotificationConfig.java | 30 +++++++++++++++++++ .../registrytypes/X509CertificateDetails.java | 30 +++++++++++++++++++ .../SendCommandToDeviceRequest.java | 30 +++++++++++++++++++ .../SendCommandToDeviceResponse.java | 30 +++++++++++++++++++ .../UnbindDeviceFromGatewayRequest.java | 30 +++++++++++++++++++ .../UnbindDeviceFromGatewayResponse.java | 30 +++++++++++++++++++ .../v1/updatedevice/UpdateDeviceRequest.java | 30 +++++++++++++++++++ .../UpdateDeviceRegistryRequest.java | 30 +++++++++++++++++++ .../cloud/iot/v1/utils/AuthParams.java | 30 +++++++++++++++++++ .../cloud/iot/v1/utils/ByteString.java | 30 +++++++++++++++++++ .../cloud/iot/v1/utils/ConfigParameters.java | 30 +++++++++++++++++++ .../cloud/iot/v1/utils/Constants.java | 30 +++++++++++++++++++ .../cloud/iot/v1/utils/LogLevel.java | 30 +++++++++++++++++++ .../iot/v1/test/DeviceManagerClientTest.java | 30 +++++++++++++++++++ .../iot/v1/test/ExpectedResponseTest.java | 30 +++++++++++++++++++ .../cloud/iot/v1/test/package-info.java | 30 +++++++++++++++++++ 96 files changed, 2880 insertions(+) diff --git a/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/binddevicetogateway/AsyncBindDeviceToGateway.java b/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/binddevicetogateway/AsyncBindDeviceToGateway.java index f1299d77..3d038a7e 100644 --- a/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/binddevicetogateway/AsyncBindDeviceToGateway.java +++ b/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/binddevicetogateway/AsyncBindDeviceToGateway.java @@ -1,3 +1,33 @@ +/* + * Copyright 2023 ClearBlade Inc. + * + * 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. + * + * 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.clearblade.cloud.iot.v1.samples.binddevicetogateway; import com.clearblade.cloud.iot.v1.DeviceManagerAsyncClient; diff --git a/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/binddevicetogateway/SyncBindDeviceToGateway.java b/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/binddevicetogateway/SyncBindDeviceToGateway.java index 5a4eecff..39f35775 100644 --- a/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/binddevicetogateway/SyncBindDeviceToGateway.java +++ b/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/binddevicetogateway/SyncBindDeviceToGateway.java @@ -1,3 +1,33 @@ +/* + * Copyright 2023 ClearBlade Inc. + * + * 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. + * + * 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.clearblade.cloud.iot.v1.samples.binddevicetogateway; import com.clearblade.cloud.iot.v1.DeviceManagerClient; diff --git a/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/createdevice/AsyncCreateDevice.java b/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/createdevice/AsyncCreateDevice.java index 21a7d64b..3f14f855 100644 --- a/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/createdevice/AsyncCreateDevice.java +++ b/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/createdevice/AsyncCreateDevice.java @@ -1,3 +1,33 @@ +/* + * Copyright 2023 ClearBlade Inc. + * + * 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. + * + * 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.clearblade.cloud.iot.v1.samples.createdevice; import java.awt.Taskbar.State; diff --git a/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/createdevice/SyncCreateDevice.java b/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/createdevice/SyncCreateDevice.java index 32b2b5cf..36a5123a 100644 --- a/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/createdevice/SyncCreateDevice.java +++ b/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/createdevice/SyncCreateDevice.java @@ -1,3 +1,33 @@ +/* + * Copyright 2023 ClearBlade Inc. + * + * 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. + * + * 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.clearblade.cloud.iot.v1.samples.createdevice; import java.util.ArrayList; diff --git a/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/createdeviceregistry/AsyncCreateDeviceRegistry.java b/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/createdeviceregistry/AsyncCreateDeviceRegistry.java index 9a426193..9b56608e 100644 --- a/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/createdeviceregistry/AsyncCreateDeviceRegistry.java +++ b/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/createdeviceregistry/AsyncCreateDeviceRegistry.java @@ -1,3 +1,33 @@ +/* + * Copyright 2023 ClearBlade Inc. + * + * 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. + * + * 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.clearblade.cloud.iot.v1.samples.createdeviceregistry; import com.clearblade.cloud.iot.v1.DeviceManagerAsyncClient; diff --git a/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/createdeviceregistry/SyncCreateDeviceRegistry.java b/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/createdeviceregistry/SyncCreateDeviceRegistry.java index 59da8a19..36dd3a24 100644 --- a/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/createdeviceregistry/SyncCreateDeviceRegistry.java +++ b/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/createdeviceregistry/SyncCreateDeviceRegistry.java @@ -1,3 +1,33 @@ +/* + * Copyright 2023 ClearBlade Inc. + * + * 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. + * + * 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.clearblade.cloud.iot.v1.samples.createdeviceregistry; import com.clearblade.cloud.iot.v1.DeviceManagerClient; diff --git a/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/deletedevice/AsyncDeleteDevice.java b/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/deletedevice/AsyncDeleteDevice.java index f57ef2b1..cd83e209 100644 --- a/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/deletedevice/AsyncDeleteDevice.java +++ b/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/deletedevice/AsyncDeleteDevice.java @@ -1,3 +1,33 @@ +/* + * Copyright 2023 ClearBlade Inc. + * + * 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. + * + * 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.clearblade.cloud.iot.v1.samples.deletedevice; import com.clearblade.cloud.iot.v1.DeviceManagerAsyncClient; diff --git a/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/deletedevice/SyncDeleteDevice.java b/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/deletedevice/SyncDeleteDevice.java index 12b3825a..e6f5f019 100644 --- a/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/deletedevice/SyncDeleteDevice.java +++ b/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/deletedevice/SyncDeleteDevice.java @@ -1,3 +1,33 @@ +/* + * Copyright 2023 ClearBlade Inc. + * + * 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. + * + * 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.clearblade.cloud.iot.v1.samples.deletedevice; import com.clearblade.cloud.iot.v1.DeviceManagerClient; diff --git a/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/deletedeviceregistry/AsyncDeleteDeviceRegistry.java b/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/deletedeviceregistry/AsyncDeleteDeviceRegistry.java index dbe448ad..6235c606 100644 --- a/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/deletedeviceregistry/AsyncDeleteDeviceRegistry.java +++ b/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/deletedeviceregistry/AsyncDeleteDeviceRegistry.java @@ -1,3 +1,33 @@ +/* + * Copyright 2023 ClearBlade Inc. + * + * 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. + * + * 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.clearblade.cloud.iot.v1.samples.deletedeviceregistry; import com.clearblade.cloud.iot.v1.DeviceManagerAsyncClient; diff --git a/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/deletedeviceregistry/SyncDeleteDeviceRegistry.java b/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/deletedeviceregistry/SyncDeleteDeviceRegistry.java index a7f8e150..dc370435 100644 --- a/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/deletedeviceregistry/SyncDeleteDeviceRegistry.java +++ b/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/deletedeviceregistry/SyncDeleteDeviceRegistry.java @@ -1,3 +1,33 @@ +/* + * Copyright 2023 ClearBlade Inc. + * + * 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. + * + * 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.clearblade.cloud.iot.v1.samples.deletedeviceregistry; import com.clearblade.cloud.iot.v1.DeviceManagerClient; diff --git a/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/deviceslist/AsyncDevicesList.java b/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/deviceslist/AsyncDevicesList.java index 7b86b418..c7c8f909 100644 --- a/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/deviceslist/AsyncDevicesList.java +++ b/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/deviceslist/AsyncDevicesList.java @@ -1,3 +1,33 @@ +/* + * Copyright 2023 ClearBlade Inc. + * + * 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. + * + * 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.clearblade.cloud.iot.v1.samples.deviceslist; import com.clearblade.cloud.iot.v1.DeviceManagerAsyncClient; diff --git a/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/deviceslist/SyncDevicesList.java b/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/deviceslist/SyncDevicesList.java index 8ed04f71..2e6171ab 100644 --- a/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/deviceslist/SyncDevicesList.java +++ b/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/deviceslist/SyncDevicesList.java @@ -1,3 +1,33 @@ +/* + * Copyright 2023 ClearBlade Inc. + * + * 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. + * + * 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.clearblade.cloud.iot.v1.samples.deviceslist; import com.clearblade.cloud.iot.v1.DeviceManagerClient; diff --git a/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/devicestateslist/AsyncDeviceStatesList.java b/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/devicestateslist/AsyncDeviceStatesList.java index 46af7fd4..9a32f47e 100644 --- a/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/devicestateslist/AsyncDeviceStatesList.java +++ b/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/devicestateslist/AsyncDeviceStatesList.java @@ -1,3 +1,33 @@ +/* + * Copyright 2023 ClearBlade Inc. + * + * 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. + * + * 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.clearblade.cloud.iot.v1.samples.devicestateslist; import com.clearblade.cloud.iot.v1.DeviceManagerAsyncClient; diff --git a/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/devicestateslist/SyncDeviceStatesList.java b/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/devicestateslist/SyncDeviceStatesList.java index ae871824..544dc1ee 100644 --- a/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/devicestateslist/SyncDeviceStatesList.java +++ b/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/devicestateslist/SyncDeviceStatesList.java @@ -1,3 +1,33 @@ +/* + * Copyright 2023 ClearBlade Inc. + * + * 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. + * + * 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.clearblade.cloud.iot.v1.samples.devicestateslist; import com.clearblade.cloud.iot.v1.DeviceManagerClient; diff --git a/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/getdevice/AsyncGetDevice.java b/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/getdevice/AsyncGetDevice.java index 042afc6b..1253d271 100644 --- a/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/getdevice/AsyncGetDevice.java +++ b/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/getdevice/AsyncGetDevice.java @@ -1,3 +1,33 @@ +/* + * Copyright 2023 ClearBlade Inc. + * + * 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. + * + * 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.clearblade.cloud.iot.v1.samples.getdevice; import com.clearblade.cloud.iot.v1.DeviceManagerAsyncClient; diff --git a/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/getdevice/SyncGetDevice.java b/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/getdevice/SyncGetDevice.java index 6c656d77..50f21c6a 100644 --- a/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/getdevice/SyncGetDevice.java +++ b/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/getdevice/SyncGetDevice.java @@ -1,3 +1,33 @@ +/* + * Copyright 2023 ClearBlade Inc. + * + * 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. + * + * 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.clearblade.cloud.iot.v1.samples.getdevice; import com.clearblade.cloud.iot.v1.DeviceManagerClient; diff --git a/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/getdeviceregistry/AsyncGetDeviceRegistry.java b/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/getdeviceregistry/AsyncGetDeviceRegistry.java index 678b8584..4ac8d221 100644 --- a/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/getdeviceregistry/AsyncGetDeviceRegistry.java +++ b/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/getdeviceregistry/AsyncGetDeviceRegistry.java @@ -1,3 +1,33 @@ +/* + * Copyright 2023 ClearBlade Inc. + * + * 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. + * + * 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.clearblade.cloud.iot.v1.samples.getdeviceregistry; import com.clearblade.cloud.iot.v1.DeviceManagerAsyncClient; diff --git a/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/getdeviceregistry/SyncGetDeviceRegistry.java b/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/getdeviceregistry/SyncGetDeviceRegistry.java index edd17846..d8c77f51 100644 --- a/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/getdeviceregistry/SyncGetDeviceRegistry.java +++ b/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/getdeviceregistry/SyncGetDeviceRegistry.java @@ -1,3 +1,33 @@ +/* + * Copyright 2023 ClearBlade Inc. + * + * 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. + * + * 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.clearblade.cloud.iot.v1.samples.getdeviceregistry; import com.clearblade.cloud.iot.v1.DeviceManagerClient; diff --git a/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/listdeviceconfigversions/AsyncListDeviceConfigVersions.java b/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/listdeviceconfigversions/AsyncListDeviceConfigVersions.java index 286d82a7..469b4ce0 100644 --- a/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/listdeviceconfigversions/AsyncListDeviceConfigVersions.java +++ b/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/listdeviceconfigversions/AsyncListDeviceConfigVersions.java @@ -1,3 +1,33 @@ +/* + * Copyright 2023 ClearBlade Inc. + * + * 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. + * + * 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.clearblade.cloud.iot.v1.samples.listdeviceconfigversions; import com.clearblade.cloud.iot.v1.DeviceManagerAsyncClient; diff --git a/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/listdeviceconfigversions/SyncListDeviceConfigVersions.java b/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/listdeviceconfigversions/SyncListDeviceConfigVersions.java index cda86857..20b1b8f8 100644 --- a/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/listdeviceconfigversions/SyncListDeviceConfigVersions.java +++ b/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/listdeviceconfigversions/SyncListDeviceConfigVersions.java @@ -1,3 +1,33 @@ +/* + * Copyright 2023 ClearBlade Inc. + * + * 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. + * + * 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.clearblade.cloud.iot.v1.samples.listdeviceconfigversions; import com.clearblade.cloud.iot.v1.DeviceManagerClient; diff --git a/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/listdeviceregistries/AsyncListDeviceRegistries.java b/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/listdeviceregistries/AsyncListDeviceRegistries.java index f1aa88c1..1c052f94 100644 --- a/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/listdeviceregistries/AsyncListDeviceRegistries.java +++ b/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/listdeviceregistries/AsyncListDeviceRegistries.java @@ -1,3 +1,33 @@ +/* + * Copyright 2023 ClearBlade Inc. + * + * 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. + * + * 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.clearblade.cloud.iot.v1.samples.listdeviceregistries; import com.clearblade.cloud.iot.v1.DeviceManagerAsyncClient; diff --git a/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/listdeviceregistries/SyncListDeviceRegistries.java b/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/listdeviceregistries/SyncListDeviceRegistries.java index 153fe9ba..cfee2f5f 100644 --- a/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/listdeviceregistries/SyncListDeviceRegistries.java +++ b/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/listdeviceregistries/SyncListDeviceRegistries.java @@ -1,3 +1,33 @@ +/* + * Copyright 2023 ClearBlade Inc. + * + * 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. + * + * 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.clearblade.cloud.iot.v1.samples.listdeviceregistries; import com.clearblade.cloud.iot.v1.DeviceManagerClient; diff --git a/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/modifycloudtodeviceconfig/AsyncModifyCloudToDeviceConfig.java b/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/modifycloudtodeviceconfig/AsyncModifyCloudToDeviceConfig.java index 5a885be0..7bebefb7 100644 --- a/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/modifycloudtodeviceconfig/AsyncModifyCloudToDeviceConfig.java +++ b/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/modifycloudtodeviceconfig/AsyncModifyCloudToDeviceConfig.java @@ -1,3 +1,33 @@ +/* + * Copyright 2023 ClearBlade Inc. + * + * 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. + * + * 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.clearblade.cloud.iot.v1.samples.modifycloudtodeviceconfig; import com.clearblade.cloud.iot.v1.DeviceManagerAsyncClient; diff --git a/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/modifycloudtodeviceconfig/SyncModifyCloudToDeviceConfig.java b/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/modifycloudtodeviceconfig/SyncModifyCloudToDeviceConfig.java index 7dd8456f..c6a78150 100644 --- a/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/modifycloudtodeviceconfig/SyncModifyCloudToDeviceConfig.java +++ b/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/modifycloudtodeviceconfig/SyncModifyCloudToDeviceConfig.java @@ -1,3 +1,33 @@ +/* + * Copyright 2023 ClearBlade Inc. + * + * 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. + * + * 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.clearblade.cloud.iot.v1.samples.modifycloudtodeviceconfig; import com.clearblade.cloud.iot.v1.DeviceManagerClient; diff --git a/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/sendcommandtodevice/AsyncSendCommandToDevice.java b/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/sendcommandtodevice/AsyncSendCommandToDevice.java index 9a6e13dd..12744006 100644 --- a/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/sendcommandtodevice/AsyncSendCommandToDevice.java +++ b/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/sendcommandtodevice/AsyncSendCommandToDevice.java @@ -1,3 +1,33 @@ +/* + * Copyright 2023 ClearBlade Inc. + * + * 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. + * + * 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.clearblade.cloud.iot.v1.samples.sendcommandtodevice; import com.clearblade.cloud.iot.v1.DeviceManagerAsyncClient; diff --git a/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/sendcommandtodevice/SyncSendCommandToDevice.java b/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/sendcommandtodevice/SyncSendCommandToDevice.java index 0fce3ca4..76f9dc7e 100644 --- a/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/sendcommandtodevice/SyncSendCommandToDevice.java +++ b/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/sendcommandtodevice/SyncSendCommandToDevice.java @@ -1,3 +1,33 @@ +/* + * Copyright 2023 ClearBlade Inc. + * + * 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. + * + * 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.clearblade.cloud.iot.v1.samples.sendcommandtodevice; import com.clearblade.cloud.iot.v1.DeviceManagerClient; diff --git a/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/unbinddevicefromgateway/AsyncUnbindDeviceFromGateway.java b/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/unbinddevicefromgateway/AsyncUnbindDeviceFromGateway.java index 4d503cef..a86dff99 100644 --- a/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/unbinddevicefromgateway/AsyncUnbindDeviceFromGateway.java +++ b/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/unbinddevicefromgateway/AsyncUnbindDeviceFromGateway.java @@ -1,3 +1,33 @@ +/* + * Copyright 2023 ClearBlade Inc. + * + * 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. + * + * 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.clearblade.cloud.iot.v1.samples.unbinddevicefromgateway; import com.clearblade.cloud.iot.v1.DeviceManagerAsyncClient; diff --git a/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/unbinddevicefromgateway/SyncUnbindDeviceFromGateway.java b/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/unbinddevicefromgateway/SyncUnbindDeviceFromGateway.java index 224596c4..756b5795 100644 --- a/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/unbinddevicefromgateway/SyncUnbindDeviceFromGateway.java +++ b/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/unbinddevicefromgateway/SyncUnbindDeviceFromGateway.java @@ -1,3 +1,33 @@ +/* + * Copyright 2023 ClearBlade Inc. + * + * 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. + * + * 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.clearblade.cloud.iot.v1.samples.unbinddevicefromgateway; import com.clearblade.cloud.iot.v1.DeviceManagerClient; diff --git a/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/updatedevice/AsyncUpdateDevice.java b/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/updatedevice/AsyncUpdateDevice.java index 9e41a2eb..fbc5d904 100644 --- a/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/updatedevice/AsyncUpdateDevice.java +++ b/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/updatedevice/AsyncUpdateDevice.java @@ -1,3 +1,33 @@ +/* + * Copyright 2023 ClearBlade Inc. + * + * 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. + * + * 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.clearblade.cloud.iot.v1.samples.updatedevice; import java.util.ArrayList; diff --git a/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/updatedevice/SyncUpdateDevice.java b/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/updatedevice/SyncUpdateDevice.java index f1fba720..128be72a 100644 --- a/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/updatedevice/SyncUpdateDevice.java +++ b/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/updatedevice/SyncUpdateDevice.java @@ -1,3 +1,33 @@ +/* + * Copyright 2023 ClearBlade Inc. + * + * 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. + * + * 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.clearblade.cloud.iot.v1.samples.updatedevice; import java.util.ArrayList; diff --git a/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/updatedeviceregistry/AsyncUpdateDeviceRegistry.java b/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/updatedeviceregistry/AsyncUpdateDeviceRegistry.java index a5089c42..bedfdf93 100644 --- a/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/updatedeviceregistry/AsyncUpdateDeviceRegistry.java +++ b/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/updatedeviceregistry/AsyncUpdateDeviceRegistry.java @@ -1,3 +1,33 @@ +/* + * Copyright 2023 ClearBlade Inc. + * + * 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. + * + * 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.clearblade.cloud.iot.v1.samples.updatedeviceregistry; import com.clearblade.cloud.iot.v1.DeviceManagerAsyncClient; diff --git a/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/updatedeviceregistry/SyncUpdateDeviceRegistry.java b/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/updatedeviceregistry/SyncUpdateDeviceRegistry.java index 66a49574..3c5c724b 100644 --- a/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/updatedeviceregistry/SyncUpdateDeviceRegistry.java +++ b/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/updatedeviceregistry/SyncUpdateDeviceRegistry.java @@ -1,3 +1,33 @@ +/* + * Copyright 2023 ClearBlade Inc. + * + * 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. + * + * 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.clearblade.cloud.iot.v1.samples.updatedeviceregistry; import com.clearblade.cloud.iot.v1.DeviceManagerClient; diff --git a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/AsyncClient.java b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/AsyncClient.java index 35abd4af..0eadd81c 100644 --- a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/AsyncClient.java +++ b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/AsyncClient.java @@ -1,3 +1,33 @@ +/* + * Copyright 2023 ClearBlade Inc. + * + * 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. + * + * 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.clearblade.cloud.iot.v1; import java.io.IOException; diff --git a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/ClearBladeDeviceManager.java b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/ClearBladeDeviceManager.java index da52ff3c..ad18ff79 100644 --- a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/ClearBladeDeviceManager.java +++ b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/ClearBladeDeviceManager.java @@ -1,3 +1,33 @@ +/* + * Copyright 2023 ClearBlade Inc. + * + * 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. + * + * 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.clearblade.cloud.iot.v1; import java.util.logging.Level; diff --git a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/ClearBladeRegistryManager.java b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/ClearBladeRegistryManager.java index cf854d28..c4c7fc05 100644 --- a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/ClearBladeRegistryManager.java +++ b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/ClearBladeRegistryManager.java @@ -1,3 +1,33 @@ +/* + * Copyright 2023 ClearBlade Inc. + * + * 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. + * + * 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.clearblade.cloud.iot.v1; import java.util.logging.Level; diff --git a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/DeviceManagerAsyncClient.java b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/DeviceManagerAsyncClient.java index a9abac9d..f7576404 100644 --- a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/DeviceManagerAsyncClient.java +++ b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/DeviceManagerAsyncClient.java @@ -1,3 +1,33 @@ +/* + * Copyright 2023 ClearBlade Inc. + * + * 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. + * + * 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.clearblade.cloud.iot.v1; import java.util.logging.Logger; diff --git a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/DeviceManagerClient.java b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/DeviceManagerClient.java index 381e30c1..5a4c28a1 100644 --- a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/DeviceManagerClient.java +++ b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/DeviceManagerClient.java @@ -1,3 +1,33 @@ +/* + * Copyright 2023 ClearBlade Inc. + * + * 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. + * + * 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.clearblade.cloud.iot.v1; import java.io.IOException; diff --git a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/SyncClient.java b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/SyncClient.java index 8f6e0897..83bc48ba 100644 --- a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/SyncClient.java +++ b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/SyncClient.java @@ -1,3 +1,33 @@ +/* + * Copyright 2023 ClearBlade Inc. + * + * 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. + * + * 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.clearblade.cloud.iot.v1; import java.io.IOException; diff --git a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/binddevicetogateway/BindDeviceToGatewayRequest.java b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/binddevicetogateway/BindDeviceToGatewayRequest.java index 52b0fe6c..82cb2a13 100644 --- a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/binddevicetogateway/BindDeviceToGatewayRequest.java +++ b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/binddevicetogateway/BindDeviceToGatewayRequest.java @@ -1,3 +1,33 @@ +/* + * Copyright 2023 ClearBlade Inc. + * + * 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. + * + * 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.clearblade.cloud.iot.v1.binddevicetogateway; import org.json.simple.JSONObject; diff --git a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/binddevicetogateway/BindDeviceToGatewayResponse.java b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/binddevicetogateway/BindDeviceToGatewayResponse.java index f6d3bedd..1ffe9b21 100644 --- a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/binddevicetogateway/BindDeviceToGatewayResponse.java +++ b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/binddevicetogateway/BindDeviceToGatewayResponse.java @@ -1,3 +1,33 @@ +/* + * Copyright 2023 ClearBlade Inc. + * + * 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. + * + * 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.clearblade.cloud.iot.v1.binddevicetogateway; import java.util.logging.Logger; diff --git a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/createdevice/CreateDeviceRequest.java b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/createdevice/CreateDeviceRequest.java index 18ca56fc..9a77c215 100644 --- a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/createdevice/CreateDeviceRequest.java +++ b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/createdevice/CreateDeviceRequest.java @@ -1,3 +1,33 @@ +/* + * Copyright 2023 ClearBlade Inc. + * + * 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. + * + * 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.clearblade.cloud.iot.v1.createdevice; import com.clearblade.cloud.iot.v1.devicetypes.Device; diff --git a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/createdeviceregistry/CreateDeviceRegistryRequest.java b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/createdeviceregistry/CreateDeviceRegistryRequest.java index 4b5a5885..e0df85bb 100644 --- a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/createdeviceregistry/CreateDeviceRegistryRequest.java +++ b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/createdeviceregistry/CreateDeviceRegistryRequest.java @@ -1,3 +1,33 @@ +/* + * Copyright 2023 ClearBlade Inc. + * + * 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. + * + * 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.clearblade.cloud.iot.v1.createdeviceregistry; import com.clearblade.cloud.iot.v1.registrytypes.DeviceRegistry; diff --git a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/deletedevice/DeleteDeviceRequest.java b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/deletedevice/DeleteDeviceRequest.java index 38e039b7..3845b09b 100644 --- a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/deletedevice/DeleteDeviceRequest.java +++ b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/deletedevice/DeleteDeviceRequest.java @@ -1,3 +1,33 @@ +/* + * Copyright 2023 ClearBlade Inc. + * + * 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. + * + * 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.clearblade.cloud.iot.v1.deletedevice; import com.clearblade.cloud.iot.v1.devicetypes.DeviceName; diff --git a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/deletedeviceregistry/DeleteDeviceRegistryRequest.java b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/deletedeviceregistry/DeleteDeviceRegistryRequest.java index 3aa63151..fb0cbf05 100644 --- a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/deletedeviceregistry/DeleteDeviceRegistryRequest.java +++ b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/deletedeviceregistry/DeleteDeviceRegistryRequest.java @@ -1,3 +1,33 @@ +/* + * Copyright 2023 ClearBlade Inc. + * + * 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. + * + * 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.clearblade.cloud.iot.v1.deletedeviceregistry; public class DeleteDeviceRegistryRequest { diff --git a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/deviceslist/DevicesListRequest.java b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/deviceslist/DevicesListRequest.java index cd2aab7e..9cdab701 100644 --- a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/deviceslist/DevicesListRequest.java +++ b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/deviceslist/DevicesListRequest.java @@ -1,3 +1,33 @@ +/* + * Copyright 2023 ClearBlade Inc. + * + * 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. + * + * 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.clearblade.cloud.iot.v1.deviceslist; import com.clearblade.cloud.iot.v1.devicetypes.GatewayListOptions; diff --git a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/deviceslist/DevicesListResponse.java b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/deviceslist/DevicesListResponse.java index 8b1891dd..6542d377 100644 --- a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/deviceslist/DevicesListResponse.java +++ b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/deviceslist/DevicesListResponse.java @@ -1,3 +1,33 @@ +/* + * Copyright 2023 ClearBlade Inc. + * + * 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. + * + * 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.clearblade.cloud.iot.v1.deviceslist; import java.util.ArrayList; diff --git a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/devicestateslist/ListDeviceStatesRequest.java b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/devicestateslist/ListDeviceStatesRequest.java index 1f602ab5..2e2e0e03 100644 --- a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/devicestateslist/ListDeviceStatesRequest.java +++ b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/devicestateslist/ListDeviceStatesRequest.java @@ -1,3 +1,33 @@ +/* + * Copyright 2023 ClearBlade Inc. + * + * 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. + * + * 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.clearblade.cloud.iot.v1.devicestateslist; import org.json.simple.JSONObject; diff --git a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/devicestateslist/ListDeviceStatesResponse.java b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/devicestateslist/ListDeviceStatesResponse.java index 77d7590a..1c91ccc9 100644 --- a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/devicestateslist/ListDeviceStatesResponse.java +++ b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/devicestateslist/ListDeviceStatesResponse.java @@ -1,3 +1,33 @@ +/* + * Copyright 2023 ClearBlade Inc. + * + * 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. + * + * 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.clearblade.cloud.iot.v1.devicestateslist; import java.util.List; diff --git a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/devicetypes/Device.java b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/devicetypes/Device.java index daf1228a..f666011a 100644 --- a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/devicetypes/Device.java +++ b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/devicetypes/Device.java @@ -1,3 +1,33 @@ +/* + * Copyright 2023 ClearBlade Inc. + * + * 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. + * + * 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.clearblade.cloud.iot.v1.devicetypes; import java.util.ArrayList; diff --git a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/devicetypes/DeviceConfig.java b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/devicetypes/DeviceConfig.java index 78af8ce1..cf886fae 100644 --- a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/devicetypes/DeviceConfig.java +++ b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/devicetypes/DeviceConfig.java @@ -1,3 +1,33 @@ +/* + * Copyright 2023 ClearBlade Inc. + * + * 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. + * + * 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.clearblade.cloud.iot.v1.devicetypes; import java.util.logging.Level; diff --git a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/devicetypes/DeviceCredential.java b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/devicetypes/DeviceCredential.java index 333d44e6..af58f873 100644 --- a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/devicetypes/DeviceCredential.java +++ b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/devicetypes/DeviceCredential.java @@ -1,3 +1,33 @@ +/* + * Copyright 2023 ClearBlade Inc. + * + * 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. + * + * 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.clearblade.cloud.iot.v1.devicetypes; import org.json.simple.JSONObject; diff --git a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/devicetypes/DeviceName.java b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/devicetypes/DeviceName.java index 02ec4a04..9174c039 100644 --- a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/devicetypes/DeviceName.java +++ b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/devicetypes/DeviceName.java @@ -1,3 +1,33 @@ +/* + * Copyright 2023 ClearBlade Inc. + * + * 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. + * + * 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.clearblade.cloud.iot.v1.devicetypes; public class DeviceName { diff --git a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/devicetypes/DeviceState.java b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/devicetypes/DeviceState.java index 8a4ca7ae..4b950438 100644 --- a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/devicetypes/DeviceState.java +++ b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/devicetypes/DeviceState.java @@ -1,3 +1,33 @@ +/* + * Copyright 2023 ClearBlade Inc. + * + * 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. + * + * 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.clearblade.cloud.iot.v1.devicetypes; import org.json.simple.JSONObject; diff --git a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/devicetypes/FieldMask.java b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/devicetypes/FieldMask.java index 19fe7ca0..d1bc99e8 100644 --- a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/devicetypes/FieldMask.java +++ b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/devicetypes/FieldMask.java @@ -1,3 +1,33 @@ +/* + * Copyright 2023 ClearBlade Inc. + * + * 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. + * + * 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.clearblade.cloud.iot.v1.devicetypes; public class FieldMask { diff --git a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/devicetypes/GatewayAuthMethod.java b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/devicetypes/GatewayAuthMethod.java index 96abc4d4..ad083f91 100644 --- a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/devicetypes/GatewayAuthMethod.java +++ b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/devicetypes/GatewayAuthMethod.java @@ -1,3 +1,33 @@ +/* + * Copyright 2023 ClearBlade Inc. + * + * 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. + * + * 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.clearblade.cloud.iot.v1.devicetypes; public enum GatewayAuthMethod { diff --git a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/devicetypes/GatewayConfig.java b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/devicetypes/GatewayConfig.java index 8bdf982c..bc1f0cb6 100644 --- a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/devicetypes/GatewayConfig.java +++ b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/devicetypes/GatewayConfig.java @@ -1,3 +1,33 @@ +/* + * Copyright 2023 ClearBlade Inc. + * + * 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. + * + * 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.clearblade.cloud.iot.v1.devicetypes; import org.json.simple.JSONObject; diff --git a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/devicetypes/GatewayListOptions.java b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/devicetypes/GatewayListOptions.java index 995f2f89..22f8cc5d 100644 --- a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/devicetypes/GatewayListOptions.java +++ b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/devicetypes/GatewayListOptions.java @@ -1,3 +1,33 @@ +/* + * Copyright 2023 ClearBlade Inc. + * + * 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. + * + * 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.clearblade.cloud.iot.v1.devicetypes; public class GatewayListOptions { diff --git a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/devicetypes/GatewayType.java b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/devicetypes/GatewayType.java index a2ab96f1..39305c75 100644 --- a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/devicetypes/GatewayType.java +++ b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/devicetypes/GatewayType.java @@ -1,3 +1,33 @@ +/* + * Copyright 2023 ClearBlade Inc. + * + * 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. + * + * 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.clearblade.cloud.iot.v1.devicetypes; public enum GatewayType { diff --git a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/devicetypes/Status.java b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/devicetypes/Status.java index cd3e7ffe..60032068 100644 --- a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/devicetypes/Status.java +++ b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/devicetypes/Status.java @@ -1,3 +1,33 @@ +/* + * Copyright 2023 ClearBlade Inc. + * + * 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. + * + * 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.clearblade.cloud.iot.v1.devicetypes; import java.util.List; diff --git a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/exception/ApplicationException.java b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/exception/ApplicationException.java index 87b8a1ff..3bd35c9e 100644 --- a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/exception/ApplicationException.java +++ b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/exception/ApplicationException.java @@ -1,3 +1,33 @@ +/* + * Copyright 2023 ClearBlade Inc. + * + * 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. + * + * 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.clearblade.cloud.iot.v1.exception; public class ApplicationException extends RuntimeException { diff --git a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/getdevice/GetDeviceRequest.java b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/getdevice/GetDeviceRequest.java index 5476374b..41a02c8a 100644 --- a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/getdevice/GetDeviceRequest.java +++ b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/getdevice/GetDeviceRequest.java @@ -1,3 +1,33 @@ +/* + * Copyright 2023 ClearBlade Inc. + * + * 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. + * + * 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.clearblade.cloud.iot.v1.getdevice; import com.clearblade.cloud.iot.v1.devicetypes.DeviceName; diff --git a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/getdeviceregistry/GetDeviceRegistryRequest.java b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/getdeviceregistry/GetDeviceRegistryRequest.java index 62fc56d7..f712e7fd 100644 --- a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/getdeviceregistry/GetDeviceRegistryRequest.java +++ b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/getdeviceregistry/GetDeviceRegistryRequest.java @@ -1,3 +1,33 @@ +/* + * Copyright 2023 ClearBlade Inc. + * + * 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. + * + * 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.clearblade.cloud.iot.v1.getdeviceregistry; public class GetDeviceRegistryRequest { diff --git a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/listdeviceconfigversions/ListDeviceConfigVersionsRequest.java b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/listdeviceconfigversions/ListDeviceConfigVersionsRequest.java index 4062dd35..35248520 100644 --- a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/listdeviceconfigversions/ListDeviceConfigVersionsRequest.java +++ b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/listdeviceconfigversions/ListDeviceConfigVersionsRequest.java @@ -1,3 +1,33 @@ +/* + * Copyright 2023 ClearBlade Inc. + * + * 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. + * + * 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.clearblade.cloud.iot.v1.listdeviceconfigversions; import org.json.simple.JSONObject; diff --git a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/listdeviceconfigversions/ListDeviceConfigVersionsResponse.java b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/listdeviceconfigversions/ListDeviceConfigVersionsResponse.java index fca71a06..0b439237 100644 --- a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/listdeviceconfigversions/ListDeviceConfigVersionsResponse.java +++ b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/listdeviceconfigversions/ListDeviceConfigVersionsResponse.java @@ -1,3 +1,33 @@ +/* + * Copyright 2023 ClearBlade Inc. + * + * 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. + * + * 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.clearblade.cloud.iot.v1.listdeviceconfigversions; import java.util.ArrayList; diff --git a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/listdeviceregistries/ListDeviceRegistriesRequest.java b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/listdeviceregistries/ListDeviceRegistriesRequest.java index 7ac1d092..153bac1c 100644 --- a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/listdeviceregistries/ListDeviceRegistriesRequest.java +++ b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/listdeviceregistries/ListDeviceRegistriesRequest.java @@ -1,3 +1,33 @@ +/* + * Copyright 2023 ClearBlade Inc. + * + * 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. + * + * 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.clearblade.cloud.iot.v1.listdeviceregistries; public class ListDeviceRegistriesRequest { diff --git a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/listdeviceregistries/ListDeviceRegistriesResponse.java b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/listdeviceregistries/ListDeviceRegistriesResponse.java index af341bea..c4e3bdde 100644 --- a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/listdeviceregistries/ListDeviceRegistriesResponse.java +++ b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/listdeviceregistries/ListDeviceRegistriesResponse.java @@ -1,3 +1,33 @@ +/* + * Copyright 2023 ClearBlade Inc. + * + * 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. + * + * 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.clearblade.cloud.iot.v1.listdeviceregistries; import java.util.ArrayList; diff --git a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/modifycloudtodeviceconfig/ModifyCloudToDeviceConfigRequest.java b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/modifycloudtodeviceconfig/ModifyCloudToDeviceConfigRequest.java index ccfb94c6..96966dab 100644 --- a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/modifycloudtodeviceconfig/ModifyCloudToDeviceConfigRequest.java +++ b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/modifycloudtodeviceconfig/ModifyCloudToDeviceConfigRequest.java @@ -1,3 +1,33 @@ +/* + * Copyright 2023 ClearBlade Inc. + * + * 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. + * + * 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.clearblade.cloud.iot.v1.modifycloudtodeviceconfig; import java.util.Arrays; diff --git a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/registrytypes/DeviceRegistry.java b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/registrytypes/DeviceRegistry.java index 8056dcd1..62957e80 100644 --- a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/registrytypes/DeviceRegistry.java +++ b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/registrytypes/DeviceRegistry.java @@ -1,3 +1,33 @@ +/* + * Copyright 2023 ClearBlade Inc. + * + * 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. + * + * 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.clearblade.cloud.iot.v1.registrytypes; import java.util.ArrayList; diff --git a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/registrytypes/EventNotificationConfig.java b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/registrytypes/EventNotificationConfig.java index 478dee33..5710a021 100644 --- a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/registrytypes/EventNotificationConfig.java +++ b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/registrytypes/EventNotificationConfig.java @@ -1,3 +1,33 @@ +/* + * Copyright 2023 ClearBlade Inc. + * + * 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. + * + * 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.clearblade.cloud.iot.v1.registrytypes; import org.json.simple.JSONObject; diff --git a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/registrytypes/HttpConfig.java b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/registrytypes/HttpConfig.java index 5f6729d2..3b954a23 100644 --- a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/registrytypes/HttpConfig.java +++ b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/registrytypes/HttpConfig.java @@ -1,3 +1,33 @@ +/* + * Copyright 2023 ClearBlade Inc. + * + * 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. + * + * 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.clearblade.cloud.iot.v1.registrytypes; import org.json.simple.JSONObject; diff --git a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/registrytypes/HttpState.java b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/registrytypes/HttpState.java index fb31f9b9..92dc5d51 100644 --- a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/registrytypes/HttpState.java +++ b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/registrytypes/HttpState.java @@ -1,3 +1,33 @@ +/* + * Copyright 2023 ClearBlade Inc. + * + * 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. + * + * 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.clearblade.cloud.iot.v1.registrytypes; public enum HttpState { diff --git a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/registrytypes/LocationName.java b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/registrytypes/LocationName.java index cbc8df04..0d45f528 100644 --- a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/registrytypes/LocationName.java +++ b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/registrytypes/LocationName.java @@ -1,3 +1,33 @@ +/* + * Copyright 2023 ClearBlade Inc. + * + * 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. + * + * 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.clearblade.cloud.iot.v1.registrytypes; public class LocationName { diff --git a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/registrytypes/MqttConfig.java b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/registrytypes/MqttConfig.java index 73311b66..7a5251f2 100644 --- a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/registrytypes/MqttConfig.java +++ b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/registrytypes/MqttConfig.java @@ -1,3 +1,33 @@ +/* + * Copyright 2023 ClearBlade Inc. + * + * 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. + * + * 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.clearblade.cloud.iot.v1.registrytypes; import org.json.simple.JSONObject; diff --git a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/registrytypes/MqttState.java b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/registrytypes/MqttState.java index 71b4d687..662c1686 100644 --- a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/registrytypes/MqttState.java +++ b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/registrytypes/MqttState.java @@ -1,3 +1,33 @@ +/* + * Copyright 2023 ClearBlade Inc. + * + * 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. + * + * 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.clearblade.cloud.iot.v1.registrytypes; public enum MqttState { diff --git a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/registrytypes/PublicKeyCertificate.java b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/registrytypes/PublicKeyCertificate.java index 0dfddb4c..f20c996d 100644 --- a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/registrytypes/PublicKeyCertificate.java +++ b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/registrytypes/PublicKeyCertificate.java @@ -1,3 +1,33 @@ +/* + * Copyright 2023 ClearBlade Inc. + * + * 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. + * + * 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.clearblade.cloud.iot.v1.registrytypes; public class PublicKeyCertificate { diff --git a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/registrytypes/PublicKeyCertificateFormat.java b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/registrytypes/PublicKeyCertificateFormat.java index 418e7ab9..7481c049 100644 --- a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/registrytypes/PublicKeyCertificateFormat.java +++ b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/registrytypes/PublicKeyCertificateFormat.java @@ -1,3 +1,33 @@ +/* + * Copyright 2023 ClearBlade Inc. + * + * 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. + * + * 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.clearblade.cloud.iot.v1.registrytypes; public enum PublicKeyCertificateFormat { diff --git a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/registrytypes/PublicKeyCredential.java b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/registrytypes/PublicKeyCredential.java index 5fef09e8..473fa931 100644 --- a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/registrytypes/PublicKeyCredential.java +++ b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/registrytypes/PublicKeyCredential.java @@ -1,3 +1,33 @@ +/* + * Copyright 2023 ClearBlade Inc. + * + * 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. + * + * 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.clearblade.cloud.iot.v1.registrytypes; import org.json.simple.JSONObject; diff --git a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/registrytypes/PublicKeyFormat.java b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/registrytypes/PublicKeyFormat.java index bbc592b5..5665b40a 100644 --- a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/registrytypes/PublicKeyFormat.java +++ b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/registrytypes/PublicKeyFormat.java @@ -1,3 +1,33 @@ +/* + * Copyright 2023 ClearBlade Inc. + * + * 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. + * + * 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.clearblade.cloud.iot.v1.registrytypes; public enum PublicKeyFormat { diff --git a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/registrytypes/RegistryCredential.java b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/registrytypes/RegistryCredential.java index 520fdd41..a15e8474 100644 --- a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/registrytypes/RegistryCredential.java +++ b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/registrytypes/RegistryCredential.java @@ -1,3 +1,33 @@ +/* + * Copyright 2023 ClearBlade Inc. + * + * 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. + * + * 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.clearblade.cloud.iot.v1.registrytypes; import org.json.simple.JSONObject; diff --git a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/registrytypes/RegistryName.java b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/registrytypes/RegistryName.java index c97240fa..a01b0a33 100644 --- a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/registrytypes/RegistryName.java +++ b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/registrytypes/RegistryName.java @@ -1,3 +1,33 @@ +/* + * Copyright 2023 ClearBlade Inc. + * + * 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. + * + * 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.clearblade.cloud.iot.v1.registrytypes; public class RegistryName { diff --git a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/registrytypes/StateNotificationConfig.java b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/registrytypes/StateNotificationConfig.java index 4108f5f5..8532d0f3 100644 --- a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/registrytypes/StateNotificationConfig.java +++ b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/registrytypes/StateNotificationConfig.java @@ -1,3 +1,33 @@ +/* + * Copyright 2023 ClearBlade Inc. + * + * 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. + * + * 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.clearblade.cloud.iot.v1.registrytypes; import org.json.simple.JSONObject; diff --git a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/registrytypes/X509CertificateDetails.java b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/registrytypes/X509CertificateDetails.java index 283f8152..cb0594b6 100644 --- a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/registrytypes/X509CertificateDetails.java +++ b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/registrytypes/X509CertificateDetails.java @@ -1,3 +1,33 @@ +/* + * Copyright 2023 ClearBlade Inc. + * + * 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. + * + * 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.clearblade.cloud.iot.v1.registrytypes; public class X509CertificateDetails { diff --git a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/sendcommandtodevice/SendCommandToDeviceRequest.java b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/sendcommandtodevice/SendCommandToDeviceRequest.java index db535e95..0d5c035d 100644 --- a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/sendcommandtodevice/SendCommandToDeviceRequest.java +++ b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/sendcommandtodevice/SendCommandToDeviceRequest.java @@ -1,3 +1,33 @@ +/* + * Copyright 2023 ClearBlade Inc. + * + * 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. + * + * 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.clearblade.cloud.iot.v1.sendcommandtodevice; import java.util.Arrays; diff --git a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/sendcommandtodevice/SendCommandToDeviceResponse.java b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/sendcommandtodevice/SendCommandToDeviceResponse.java index 4e67f56e..072b9e5c 100644 --- a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/sendcommandtodevice/SendCommandToDeviceResponse.java +++ b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/sendcommandtodevice/SendCommandToDeviceResponse.java @@ -1,3 +1,33 @@ +/* + * Copyright 2023 ClearBlade Inc. + * + * 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. + * + * 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.clearblade.cloud.iot.v1.sendcommandtodevice; import java.util.logging.Logger; diff --git a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/unbinddevicefromgateway/UnbindDeviceFromGatewayRequest.java b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/unbinddevicefromgateway/UnbindDeviceFromGatewayRequest.java index 55de5727..38319ec8 100644 --- a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/unbinddevicefromgateway/UnbindDeviceFromGatewayRequest.java +++ b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/unbinddevicefromgateway/UnbindDeviceFromGatewayRequest.java @@ -1,3 +1,33 @@ +/* + * Copyright 2023 ClearBlade Inc. + * + * 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. + * + * 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.clearblade.cloud.iot.v1.unbinddevicefromgateway; import org.json.simple.JSONObject; diff --git a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/unbinddevicefromgateway/UnbindDeviceFromGatewayResponse.java b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/unbinddevicefromgateway/UnbindDeviceFromGatewayResponse.java index 6e558aa9..9cf8436e 100644 --- a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/unbinddevicefromgateway/UnbindDeviceFromGatewayResponse.java +++ b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/unbinddevicefromgateway/UnbindDeviceFromGatewayResponse.java @@ -1,3 +1,33 @@ +/* + * Copyright 2023 ClearBlade Inc. + * + * 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. + * + * 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.clearblade.cloud.iot.v1.unbinddevicefromgateway; import java.util.logging.Logger; diff --git a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/updatedevice/UpdateDeviceRequest.java b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/updatedevice/UpdateDeviceRequest.java index d043a96f..8ae9fb9b 100644 --- a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/updatedevice/UpdateDeviceRequest.java +++ b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/updatedevice/UpdateDeviceRequest.java @@ -1,3 +1,33 @@ +/* + * Copyright 2023 ClearBlade Inc. + * + * 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. + * + * 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.clearblade.cloud.iot.v1.updatedevice; import java.util.ArrayList; diff --git a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/updatedeviceregistry/UpdateDeviceRegistryRequest.java b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/updatedeviceregistry/UpdateDeviceRegistryRequest.java index 3ab06c7f..9d957532 100644 --- a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/updatedeviceregistry/UpdateDeviceRegistryRequest.java +++ b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/updatedeviceregistry/UpdateDeviceRegistryRequest.java @@ -1,3 +1,33 @@ +/* + * Copyright 2023 ClearBlade Inc. + * + * 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. + * + * 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.clearblade.cloud.iot.v1.updatedeviceregistry; import org.json.simple.JSONObject; diff --git a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/utils/AuthParams.java b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/utils/AuthParams.java index 98c13f52..25d4504a 100644 --- a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/utils/AuthParams.java +++ b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/utils/AuthParams.java @@ -1,3 +1,33 @@ +/* + * Copyright 2023 ClearBlade Inc. + * + * 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. + * + * 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.clearblade.cloud.iot.v1.utils; import java.io.FileNotFoundException; diff --git a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/utils/ByteString.java b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/utils/ByteString.java index 8270a7ae..ac8004ce 100644 --- a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/utils/ByteString.java +++ b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/utils/ByteString.java @@ -1,3 +1,33 @@ +/* + * Copyright 2023 ClearBlade Inc. + * + * 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. + * + * 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.clearblade.cloud.iot.v1.utils; public class ByteString { diff --git a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/utils/ConfigParameters.java b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/utils/ConfigParameters.java index 4af11dbb..bf199802 100644 --- a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/utils/ConfigParameters.java +++ b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/utils/ConfigParameters.java @@ -1,3 +1,33 @@ +/* + * Copyright 2023 ClearBlade Inc. + * + * 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. + * + * 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.clearblade.cloud.iot.v1.utils; import java.util.logging.Logger; diff --git a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/utils/Constants.java b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/utils/Constants.java index 373fc66f..953ecf4a 100644 --- a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/utils/Constants.java +++ b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/utils/Constants.java @@ -1,3 +1,33 @@ +/* + * Copyright 2023 ClearBlade Inc. + * + * 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. + * + * 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.clearblade.cloud.iot.v1.utils; public class Constants { diff --git a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/utils/LogLevel.java b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/utils/LogLevel.java index e630eaf0..1d60350a 100644 --- a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/utils/LogLevel.java +++ b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/utils/LogLevel.java @@ -1,3 +1,33 @@ +/* + * Copyright 2023 ClearBlade Inc. + * + * 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. + * + * 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.clearblade.cloud.iot.v1.utils; public enum LogLevel { diff --git a/clearblade-cloud-iot/test/com/clearblade/cloud/iot/v1/test/DeviceManagerClientTest.java b/clearblade-cloud-iot/test/com/clearblade/cloud/iot/v1/test/DeviceManagerClientTest.java index 5a79cc59..dd0b5e08 100644 --- a/clearblade-cloud-iot/test/com/clearblade/cloud/iot/v1/test/DeviceManagerClientTest.java +++ b/clearblade-cloud-iot/test/com/clearblade/cloud/iot/v1/test/DeviceManagerClientTest.java @@ -1,3 +1,33 @@ +/* + * Copyright 2023 ClearBlade Inc. + * + * 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. + * + * 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.clearblade.cloud.iot.v1.test; diff --git a/clearblade-cloud-iot/test/com/clearblade/cloud/iot/v1/test/ExpectedResponseTest.java b/clearblade-cloud-iot/test/com/clearblade/cloud/iot/v1/test/ExpectedResponseTest.java index 497b8bfe..7b86b2ff 100644 --- a/clearblade-cloud-iot/test/com/clearblade/cloud/iot/v1/test/ExpectedResponseTest.java +++ b/clearblade-cloud-iot/test/com/clearblade/cloud/iot/v1/test/ExpectedResponseTest.java @@ -1,3 +1,33 @@ +/* + * Copyright 2023 ClearBlade Inc. + * + * 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. + * + * 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.clearblade.cloud.iot.v1.test; import java.util.ArrayList; diff --git a/clearblade-cloud-iot/test/com/clearblade/cloud/iot/v1/test/package-info.java b/clearblade-cloud-iot/test/com/clearblade/cloud/iot/v1/test/package-info.java index 32213406..6d011c40 100644 --- a/clearblade-cloud-iot/test/com/clearblade/cloud/iot/v1/test/package-info.java +++ b/clearblade-cloud-iot/test/com/clearblade/cloud/iot/v1/test/package-info.java @@ -1 +1,31 @@ +/* + * Copyright 2023 ClearBlade Inc. + * + * 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. + * + * 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.clearblade.cloud.iot.v1.test; \ No newline at end of file From 51176805c1c8264b4136f3a1a3185031d176954b Mon Sep 17 00:00:00 2001 From: ronak-ingress Date: Tue, 7 Mar 2023 15:13:31 +0530 Subject: [PATCH 066/151] - Added new env varialbe of BINARYDATA_AND_TIME_GOOGLE_FORMAT - Modified the response of device state list, device config version, modify device config as per google's structure - binary data converted from string to byte array - update time, ack time converted to Timestamp object - Solved issue of null numId in Device.java - Added new class of Timestamp. - Replaced current string to Object to support backward compatibility. - Resolved issue of wrongly pointed out config URL to correct URL in ConfigParameters.java - Added condition for success response 200 to 204. --- .../cloud/iot/v1/ClearBladeDeviceManager.java | 4 +- .../iot/v1/ClearBladeRegistryManager.java | 2 +- .../cloud/iot/v1/devicetypes/Device.java | 4 +- .../iot/v1/devicetypes/DeviceConfig.java | 80 +++-- .../cloud/iot/v1/devicetypes/DeviceState.java | 59 +++- .../ModifyCloudToDeviceConfigRequest.java | 2 +- .../SendCommandToDeviceRequest.java | 4 +- .../cloud/iot/v1/utils/ByteString.java | 303 ++++++++++++++++-- .../cloud/iot/v1/utils/ConfigParameters.java | 2 +- .../cloud/iot/v1/utils/Constants.java | 31 +- .../cloud/iot/v1/utils/Timestamp.java | 60 ++++ .../iot/v1/utils/TimestampOrBuilder.java | 7 + .../clearblade/cloud/iot/v1/utils/Utils.java | 28 ++ 13 files changed, 504 insertions(+), 82 deletions(-) create mode 100644 clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/utils/Timestamp.java create mode 100644 clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/utils/TimestampOrBuilder.java create mode 100644 clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/utils/Utils.java diff --git a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/ClearBladeDeviceManager.java b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/ClearBladeDeviceManager.java index ad18ff79..23d5ce84 100644 --- a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/ClearBladeDeviceManager.java +++ b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/ClearBladeDeviceManager.java @@ -318,7 +318,7 @@ public SendCommandToDeviceResponse sendCommandToDevice(SendCommandToDeviceReques SendCommandToDeviceResponse response = SendCommandToDeviceResponse.Builder.newBuilder().build(); if (responseArray[0] != null) { int responseCode = Integer.parseInt(responseArray[0]); - if (responseCode == 200) { + if (responseCode == 200 || responseCode == 204) { response.setHttpStatusCode(Integer.parseInt(responseArray[0])); response.setHttpStatusResponse(responseArray[1]); } else { @@ -338,7 +338,7 @@ public SendCommandToDeviceResponse asyncSendCommandToDevice(SendCommandToDeviceR SendCommandToDeviceResponse response = SendCommandToDeviceResponse.Builder.newBuilder().build(); if (responseArray[0] != null) { int responseCode = Integer.parseInt(responseArray[0]); - if (responseCode == 200) { + if (responseCode == 200 || responseCode == 204) { response.setHttpStatusCode(Integer.parseInt(responseArray[0])); response.setHttpStatusResponse(responseArray[1]); } else { diff --git a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/ClearBladeRegistryManager.java b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/ClearBladeRegistryManager.java index c4c7fc05..43c61eb1 100644 --- a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/ClearBladeRegistryManager.java +++ b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/ClearBladeRegistryManager.java @@ -177,7 +177,7 @@ public void deleteDeviceRegistry(DeleteDeviceRegistryRequest request) throws App String[] responseArray = syncClient.delete(configParameters.getCloudiotURLExtension(), bodyParams, true); if (responseArray[0] != null) { int responseCode = Integer.parseInt(responseArray[0]); - if (responseCode == 200) { + if (responseCode == 200 || responseCode == 204) { log.log(Level.INFO, () -> "Response code " + responseArray[0] + " received with message" + responseArray[2]); } else { diff --git a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/devicetypes/Device.java b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/devicetypes/Device.java index f666011a..5e033357 100644 --- a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/devicetypes/Device.java +++ b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/devicetypes/Device.java @@ -383,7 +383,9 @@ public String createDeviceJSONObject() { JSONObject deviceObj = new JSONObject(); deviceObj.put("id", this.id); deviceObj.put("name", this.name); - deviceObj.put("numId", this.numId); + if (this.numId != null) { + deviceObj.put("numId", this.numId); + } JSONArray jsonArray = new JSONArray(); if (this.credentials.size() > 0) { diff --git a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/devicetypes/DeviceConfig.java b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/devicetypes/DeviceConfig.java index cf886fae..f019d212 100644 --- a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/devicetypes/DeviceConfig.java +++ b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/devicetypes/DeviceConfig.java @@ -30,18 +30,23 @@ package com.clearblade.cloud.iot.v1.devicetypes; +import java.time.Instant; import java.util.logging.Level; import java.util.logging.Logger; import org.json.simple.JSONObject; import org.json.simple.parser.JSONParser; +import com.clearblade.cloud.iot.v1.utils.ByteString; +import com.clearblade.cloud.iot.v1.utils.Timestamp; +import com.clearblade.cloud.iot.v1.utils.Utils; + public class DeviceConfig { static Logger log = Logger.getLogger(DeviceConfig.class.getName()); private String version; - private String cloudUpdateTime; - private String deviceAckTime; - private String binaryData; + private Object cloudUpdateTime; + private Object deviceAckTime; + private Object binaryData; public DeviceConfig() { } @@ -73,16 +78,27 @@ public String getVersion() { return version; } - public String getCloudUpdateTime() { - return cloudUpdateTime; + public Object getCloudUpdateTime() { + if (Utils.isBinary() && !Utils.isEmpty(cloudUpdateTime.toString())) { + Instant timeStamp = Instant.parse(cloudUpdateTime.toString()); + return new Timestamp(timeStamp.getEpochSecond(), timeStamp.getNano()); + } else + return cloudUpdateTime.toString(); } - public String getDeviceAckTime() { - return deviceAckTime; + public Object getDeviceAckTime() { + if (Utils.isBinary() && !Utils.isEmpty(deviceAckTime.toString())) { + Instant timeStamp = Instant.parse(deviceAckTime.toString()); + return new Timestamp(timeStamp.getEpochSecond(), timeStamp.getNano()); + } else + return deviceAckTime.toString(); } - public String getBinaryData() { - return binaryData; + public Object getBinaryData() { + if (Utils.isBinary()) + return ByteString.copyFromUtf8(binaryData.toString()); + else + return binaryData.toString(); } public static Builder newBuilder() { @@ -95,9 +111,9 @@ public Builder toBuilder() { public static class Builder { private String version; - private String cloudUpdateTime; - private String deviceAckTime; - private String binaryData; + private Object cloudUpdateTime; + private Object deviceAckTime; + private Object binaryData; protected Builder() { @@ -112,8 +128,12 @@ public Builder setVersion(String version) { return this; } - public String getCloudUpdateTime() { - return cloudUpdateTime; + public Object getCloudUpdateTime() { + if (Utils.isBinary()) { + Instant timeStamp = Instant.parse(cloudUpdateTime.toString()); + return new Timestamp(timeStamp.getEpochSecond(), timeStamp.getNano()); + } else + return cloudUpdateTime.toString(); } public Builder setCloudUpdateTime(String cloudUpdateTime) { @@ -121,8 +141,12 @@ public Builder setCloudUpdateTime(String cloudUpdateTime) { return this; } - public String getDeviceAckTime() { - return deviceAckTime; + public Object getDeviceAckTime() { + if (Utils.isBinary()) { + Instant timeStamp = Instant.parse(deviceAckTime.toString()); + return new Timestamp(timeStamp.getEpochSecond(), timeStamp.getNano()); + } else + return deviceAckTime.toString(); } public Builder setDeviceAckTime(String deviceAckTime) { @@ -130,8 +154,11 @@ public Builder setDeviceAckTime(String deviceAckTime) { return this; } - public String getBinaryData() { - return binaryData; + public Object getBinaryData() { + if (Utils.isBinary()) + return ByteString.copyFromUtf8(binaryData.toString()); + else + return binaryData.toString(); } public Builder setBinaryData(String binaryData) { @@ -164,12 +191,21 @@ public void loadFromString(String jsonString) { } } + @SuppressWarnings("unchecked") public JSONObject toJSONObject() { JSONObject jsonObject = new JSONObject(); - jsonObject.put("version", this.getVersion()); - jsonObject.put("cloudUpdateTime", this.getCloudUpdateTime()); - jsonObject.put("deviceAckTime", this.getDeviceAckTime()); - jsonObject.put("binaryData", this.getBinaryData()); + if (this.getVersion() != null) { + jsonObject.put("version", this.getVersion()); + } + if (this.cloudUpdateTime != null) { + jsonObject.put("cloudUpdateTime", this.cloudUpdateTime.toString()); + } + if (this.deviceAckTime != null) { + jsonObject.put("deviceAckTime", this.deviceAckTime.toString()); + } + if (this.binaryData != null) { + jsonObject.put("binaryData", this.binaryData.toString()); + } return jsonObject; } } diff --git a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/devicetypes/DeviceState.java b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/devicetypes/DeviceState.java index 4b950438..55b8cfd0 100644 --- a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/devicetypes/DeviceState.java +++ b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/devicetypes/DeviceState.java @@ -30,11 +30,17 @@ package com.clearblade.cloud.iot.v1.devicetypes; +import java.time.Instant; + import org.json.simple.JSONObject; +import com.clearblade.cloud.iot.v1.utils.ByteString; +import com.clearblade.cloud.iot.v1.utils.Timestamp; +import com.clearblade.cloud.iot.v1.utils.Utils; + public class DeviceState { - private String updateTime; - private String binaryData; + private Object updateTime; + private Object binaryData; public DeviceState(Builder builder) { updateTime = builder.updateTime; @@ -45,19 +51,26 @@ public DeviceState() { } - public String getBinaryData() { - return binaryData; + public Object getBinaryData() { + if (Utils.isBinary()) + return ByteString.copyFromUtf8(binaryData.toString()); + else + return binaryData.toString(); } - public String getUpdateTime() { - return updateTime; + public Object getUpdateTime() { + if (Utils.isBinary() && !Utils.isEmpty(updateTime.toString())) { + Instant timeStamp = Instant.parse(updateTime.toString()); + return new Timestamp(timeStamp.getEpochSecond(), timeStamp.getNano()); + } else + return updateTime.toString(); } - public void setUpdateTime(String updateTime) { + public void setUpdateTime(Object updateTime) { this.updateTime = updateTime; } - public void setBinaryData(String binaryData) { + public void setBinaryData(Object binaryData) { this.binaryData = binaryData; } @@ -70,27 +83,38 @@ public Builder toBuilder() { } public static class Builder { - private String binaryData; - private String updateTime; + private Object binaryData; + private Object updateTime; protected Builder() { } - public String getUpdateTime() { - return updateTime; + public Object getUpdateTime() { + if (Utils.isBinary() && !Utils.isEmpty(updateTime.toString())) { + Instant timeStamp = Instant.parse(updateTime.toString()); + return new Timestamp(timeStamp.getEpochSecond(), timeStamp.getNano()); + } else + return updateTime.toString(); } public Builder setUpdateTime(String updateTime) { - this.updateTime = updateTime; + this.updateTime = updateTime.toString(); return this; } - public String getBinaryData() { + public Object getBinaryDataByte() { return binaryData; } + public Object getBinaryData() { + if (Utils.isBinary()) + return ByteString.copyFromUtf8(binaryData.toString()); + else + return binaryData.toString(); + } + public Builder setBinaryData(String binaryData) { - this.binaryData = binaryData; + this.binaryData = binaryData.toString(); return this; } @@ -104,15 +128,16 @@ public DeviceState build() { } } + @SuppressWarnings("unchecked") public JSONObject toJSONObject() { JSONObject jsonObject = new JSONObject(); if (this.getUpdateTime() != null) { - jsonObject.put("updateTime", this.getUpdateTime()); + jsonObject.put("updateTime", this.updateTime.toString()); } else { jsonObject.put("updateTime", ""); } if (this.getBinaryData() != null) { - jsonObject.put("binaryData", this.getBinaryData()); + jsonObject.put("binaryData", this.binaryData.toString()); } else { jsonObject.put("binaryData", ""); } diff --git a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/modifycloudtodeviceconfig/ModifyCloudToDeviceConfigRequest.java b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/modifycloudtodeviceconfig/ModifyCloudToDeviceConfigRequest.java index 96966dab..f03c3af6 100644 --- a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/modifycloudtodeviceconfig/ModifyCloudToDeviceConfigRequest.java +++ b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/modifycloudtodeviceconfig/ModifyCloudToDeviceConfigRequest.java @@ -105,7 +105,7 @@ public String[] getBodyAndParams() { String params = "name=" + this.deviceName + "&method=modifyCloudToDeviceConfig"; String bData = "EMPTY"; if (this.binaryData != null) { - bData = new String(this.binaryData.getBinaryDataArray()); + bData = new String(this.binaryData.toByteArray()); } else if (this.binaryDataByte != null) { if (this.binaryDataByte.length == 0) { bData = "EMPTY"; diff --git a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/sendcommandtodevice/SendCommandToDeviceRequest.java b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/sendcommandtodevice/SendCommandToDeviceRequest.java index 0d5c035d..115bab46 100644 --- a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/sendcommandtodevice/SendCommandToDeviceRequest.java +++ b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/sendcommandtodevice/SendCommandToDeviceRequest.java @@ -120,7 +120,7 @@ public String toString() { dName = this.deviceName; } if (this.binaryData != null) { - bData = new String(this.binaryData.getBinaryDataArray()); + bData = new String(this.binaryData.toByteArray()); } else if (this.binaryDataByte != null) { if (this.binaryDataByte.length == 0) { bData = "EMPTY"; @@ -143,7 +143,7 @@ public String[] getBodyAndParams() { String params = "name=" + this.deviceName + "&method=sendCommandToDevice"; String bData = null; if (this.binaryData != null) { - bData = new String(this.binaryData.getBinaryDataArray()); + bData = new String(this.binaryData.toByteArray()); } else if (this.binaryDataByte != null) { if (this.binaryDataByte.length == 0) { bData = "EMPTY"; diff --git a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/utils/ByteString.java b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/utils/ByteString.java index ac8004ce..1a538c0b 100644 --- a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/utils/ByteString.java +++ b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/utils/ByteString.java @@ -30,41 +30,304 @@ package com.clearblade.cloud.iot.v1.utils; +import java.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; +import java.io.FilterOutputStream; +import java.io.InputStream; +import java.io.UnsupportedEncodingException; +import java.nio.ByteBuffer; +import java.util.List; + + public class ByteString { - private String binaryDataStr; - private ByteString binaryData; - private byte[] binaryDataArray; - public static final byte[] EMPTY = new byte[0]; + private final byte[] bytes; - public ByteString(String str) { - this.setBinaryDataArray(str.getBytes()); + private ByteString(final byte[] bytes) { + this.bytes = bytes; + } + + public ByteString(String str) { + this.bytes = str.getBytes(); } - public ByteString getBinaryData() { - return binaryData; + /** + * Gets the byte at the given index. + * + * @throws ArrayIndexOutOfBoundsException {@code index} is < 0 or >= size + */ + public byte byteAt(final int index) { + return bytes[index]; } - public void setBinaryData(ByteString binaryData) { - this.binaryData = binaryData; + /** + * Gets the number of bytes. + */ + public int size() { + return bytes.length; } - public byte[] getBinaryDataArray() { - return binaryDataArray; + /** + * Returns {@code true} if the size is {@code 0}, {@code false} otherwise. + */ + public boolean isEmpty() { + return bytes.length == 0; } - public void setBinaryDataArray(byte[] binaryDataArray) { - this.binaryDataArray = binaryDataArray; + // ================================================================= + // byte[] -> ByteString + /** + * Empty ByteString. + */ + public static final ByteString EMPTY = new ByteString(new byte[0]); + + /** + * Copies the given bytes into a {@code ByteString}. + */ + public static ByteString copyFrom(final byte[] bytes, final int offset, final int size) { + final byte[] copy = new byte[size]; + System.arraycopy(bytes, offset, copy, 0, size); + return new ByteString(copy); } - public String getBinaryDataStr() { - return binaryDataStr; + /** + * Copies the given bytes into a {@code ByteString}. + */ + public static ByteString copyFrom(final byte[] bytes) { + return copyFrom(bytes, 0, bytes.length); } - public void setBinaryDataStr(String binaryDataStr) { - this.binaryDataStr = binaryDataStr; + /** + * Copies {@code size} bytes from a {@code java.nio.ByteBuffer} into a + * {@code ByteString}. + */ + public static ByteString copyFrom(final ByteBuffer bytes, final int size) { + final byte[] copy = new byte[size]; + bytes.get(copy); + return new ByteString(copy); + } + + /** + * Copies the remaining bytes from a {@code java.nio.ByteBuffer} into a + * {@code ByteString}. + */ + public static ByteString copyFrom(final ByteBuffer bytes) { + return copyFrom(bytes, bytes.remaining()); + } + + /** + * Encodes {@code text} into a sequence of bytes using the named charset and + * returns the result as a {@code ByteString}. + */ + public static ByteString copyFrom(final String text, final String charsetName) throws UnsupportedEncodingException { + return new ByteString(text.getBytes(charsetName)); + } + + /** + * Encodes {@code text} into a sequence of UTF-8 bytes and returns the result as + * a {@code ByteString}. + */ + public static ByteString copyFromUtf8(final String text) { + try { + return new ByteString(text.getBytes("UTF-8")); + } catch (UnsupportedEncodingException e) { + throw new RuntimeException("UTF-8 not supported?", e); + } + } + + /** + * Concatenates all byte strings in the list and returns the result. + * + *

+ * The returned {@code ByteString} is not necessarily a unique object. If the + * list is empty, the returned object is the singleton empty {@code ByteString}. + * If the list has only one element, that {@code ByteString} will be returned + * without copying. + */ + public static ByteString copyFrom(List list) { + if (list.size() == 0) { + return EMPTY; + } else if (list.size() == 1) { + return list.get(0); + } + int size = 0; + for (ByteString str : list) { + size += str.size(); + } + byte[] bytes = new byte[size]; + int pos = 0; + for (ByteString str : list) { + System.arraycopy(str.bytes, 0, bytes, pos, str.size()); + pos += str.size(); + } + return new ByteString(bytes); + } + + // ================================================================= + // ByteString -> byte[] + /** + * Copies bytes into a buffer at the given offset. + * + * @param target buffer to copy into + * @param offset in the target buffer + */ + public void copyTo(final byte[] target, final int offset) { + System.arraycopy(bytes, 0, target, offset, bytes.length); + } + + /** + * Copies bytes into a buffer. + * + * @param target buffer to copy into + * @param sourceOffset offset within these bytes + * @param targetOffset offset within the target buffer + * @param size number of bytes to copy + */ + public void copyTo(final byte[] target, final int sourceOffset, final int targetOffset, final int size) { + System.arraycopy(bytes, sourceOffset, target, targetOffset, size); + } + + /** + * Copies bytes to a {@code byte[]}. + */ + public byte[] toByteArray() { + final int size = bytes.length; + final byte[] copy = new byte[size]; + System.arraycopy(bytes, 0, copy, 0, size); + return copy; + } + + /** + * Constructs a new read-only {@code java.nio.ByteBuffer} with the same backing + * byte array. + */ + public ByteBuffer asReadOnlyByteBuffer() { + final ByteBuffer byteBuffer = ByteBuffer.wrap(bytes); + return byteBuffer.asReadOnlyBuffer(); + } + + /** + * Constructs a new {@code String} by decoding the bytes using the specified + * charset. + */ + public String toString(final String charsetName) throws UnsupportedEncodingException { + return new String(bytes, charsetName); + } + + /** + * Constructs a new {@code String} by decoding the bytes as UTF-8. + */ + public String toStringUtf8() { + try { + return new String(bytes, "UTF-8"); + } catch (UnsupportedEncodingException e) { + throw new RuntimeException("UTF-8 not supported?", e); + } + } + + // ================================================================= + // equals() and hashCode() + @Override + public boolean equals(final Object o) { + if (o == this) { + return true; + } + if (!(o instanceof ByteString)) { + return false; + } + final ByteString other = (ByteString) o; + final int size = bytes.length; + if (size != other.bytes.length) { + return false; + } + final byte[] thisBytes = bytes; + final byte[] otherBytes = other.bytes; + for (int i = 0; i < size; i++) { + if (thisBytes[i] != otherBytes[i]) { + return false; + } + } + return true; + } + + private volatile int hash = 0; + + @Override + public int hashCode() { + int h = hash; + if (h == 0) { + final byte[] thisBytes = bytes; + final int size = bytes.length; + h = size; + for (int i = 0; i < size; i++) { + h = h * 31 + thisBytes[i]; + } + if (h == 0) { + h = 1; + } + hash = h; + } + return h; + } + + // ================================================================= + // Input stream + /** + * Creates an {@code InputStream} which can be used to read the bytes. + */ + public InputStream newInput() { + return new ByteArrayInputStream(bytes); + } + + /** + * Creates a {@link CodedInputStream} which can be used to read the bytes. Using + * this is more efficient than creating a {@link CodedInputStream} wrapping the + * result of {@link #newInput()}. + */ + // ================================================================= + // Output stream + /** + * Creates a new {@link Output} with the given initial capacity. + */ + public static Output newOutput(final int initialCapacity) { + return new Output(new ByteArrayOutputStream(initialCapacity)); + } + + /** + * Creates a new {@link Output}. + */ + public static Output newOutput() { + return newOutput(32); + } + + /** + * Outputs to a {@code ByteString} instance. Call {@link #toByteString()} to + * create the {@code ByteString} instance. + */ + public static final class Output extends FilterOutputStream { + private final ByteArrayOutputStream bout; + + /** + * Constructs a new output with the given initial capacity. + */ + private Output(final ByteArrayOutputStream bout) { + super(bout); + this.bout = bout; + } + + /** + * Creates a {@code ByteString} instance from this {@code Output}. + */ + public ByteString toByteString() { + final byte[] byteArray = bout.toByteArray(); + return new ByteString(byteArray); + } + } + + @Override + public String toString() { + // TODO Auto-generated method stub + return toStringUtf8(); } - - } diff --git a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/utils/ConfigParameters.java b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/utils/ConfigParameters.java index bf199802..28b4c13e 100644 --- a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/utils/ConfigParameters.java +++ b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/utils/ConfigParameters.java @@ -70,7 +70,7 @@ public void setValues() { this.setDevicesURLExtension(Constants.DEVICES_URL_EXTENSION); this.setCloudiotdevicesURLExtension(Constants.CLOUDIOT_DEVICES_URL_EXTENSION); this.setDevicesStatesURLExtension(Constants.DEVICES_STATES_URL_EXTENSION); - this.setCloudiotdevicesURLExtension(Constants.CLOUDIOT_DEVICE_CONFIG_URL_EXTENSION); + this.setCloudiotConfigURLExtension(Constants.CLOUDIOT_DEVICE_CONFIG_URL_EXTENSION); this.setGetSystemCredentialsExtension(Constants.GET_SYSTEM_CREDENTIALS_EXTENSION); this.setEndpointPort(Constants.ENDPOINTPORT); } diff --git a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/utils/Constants.java b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/utils/Constants.java index 953ecf4a..56c1caaa 100644 --- a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/utils/Constants.java +++ b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/utils/Constants.java @@ -31,14 +31,16 @@ package com.clearblade.cloud.iot.v1.utils; public class Constants { - - private Constants() {} - //keys used in project + private Constants() { + } + + // keys used in project public static final String AUTH_ACCESS = "CLEARBLADE_CONFIGURATION"; public static final String AUTH_REGISTRY = "CLEARBLADE_REGISTRY"; public static final String AUTH_REGION = "CLEARBLADE_REGION"; - + public static final String BINARYDATA = "BINARYDATA_AND_TIME_GOOGLE_FORMAT"; + public static final String ADMIN_SYSTEM_KEY = "systemKey"; public static final String ADMIN_TOKEN = "token"; public static final String BASE_URL = "url"; @@ -58,16 +60,15 @@ private Constants() {} public static final String HTTP_REQUEST_PROPERTY_CONTENT_TYPE_KEY = "Content-Type"; public static final String HTTP_REQUEST_PROPERTY_ACCEPT_KEY = "Accept"; public static final String HTTP_REQUEST_PROPERTY_CONTENT_TYPE_ACCEPT_VALUE = "application/json"; - - //Constant values used in project + + // Constant values used in project public static final String UTF8 = "utf-8"; - public static final String ENDPOINTPORT=":443"; - public static final String WEBHOOK="/api/v/4/webhook/execute/"; - public static final String DEVICES_URL_EXTENSION="/cloudiot_devices"; - public static final String CLOUDIOT_URL_EXTENSION="/cloudiot"; - public static final String DEVICES_STATES_URL_EXTENSION="/cloudiot_devices_states"; - public static final String CLOUDIOT_DEVICES_URL_EXTENSION="/cloudiotdevice_devices"; - public static final String CLOUDIOT_DEVICE_CONFIG_URL_EXTENSION="/cloudiot_devices_configVersions"; - public static final String GET_SYSTEM_CREDENTIALS_EXTENSION="/api/v/1/code/"; - + public static final String ENDPOINTPORT = ":443"; + public static final String WEBHOOK = "/api/v/4/webhook/execute/"; + public static final String DEVICES_URL_EXTENSION = "/cloudiot_devices"; + public static final String CLOUDIOT_URL_EXTENSION = "/cloudiot"; + public static final String DEVICES_STATES_URL_EXTENSION = "/cloudiot_devices_states"; + public static final String CLOUDIOT_DEVICES_URL_EXTENSION = "/cloudiotdevice_devices"; + public static final String CLOUDIOT_DEVICE_CONFIG_URL_EXTENSION = "/cloudiot_devices_configVersions"; + public static final String GET_SYSTEM_CREDENTIALS_EXTENSION = "/api/v/1/code/"; } diff --git a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/utils/Timestamp.java b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/utils/Timestamp.java new file mode 100644 index 00000000..7e0dccd7 --- /dev/null +++ b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/utils/Timestamp.java @@ -0,0 +1,60 @@ +package com.clearblade.cloud.iot.v1.utils; + +public class Timestamp implements TimestampOrBuilder { + + public static final int SECONDS_FIELD_NUMBER = 1; + private long seconds_; + public static final int NANOS_FIELD_NUMBER = 2; + private int nanos_; + private byte memoizedIsInitialized; + private static final Timestamp DEFAULT_INSTANCE; + + private Timestamp() { + this.seconds_ = 0L; + this.nanos_ = 0; + this.memoizedIsInitialized = -1; + } + + public Timestamp(long seconds, int nanos) { + this.seconds_ = seconds; + this.nanos_ = nanos; + this.memoizedIsInitialized = -1; + } + + public long getSeconds() { + return this.seconds_; + } + + public int getNanos() { + return this.nanos_; + } + + public final boolean isInitialized() { + final byte isInitialized = this.memoizedIsInitialized; + if (isInitialized == 1) { + return true; + } + if (isInitialized == 0) { + return false; + } + this.memoizedIsInitialized = 1; + return true; + } + + public static Timestamp getDefaultInstance() { + return Timestamp.DEFAULT_INSTANCE; + } + + public Timestamp getDefaultInstanceForType() { + return Timestamp.DEFAULT_INSTANCE; + } + + static { + DEFAULT_INSTANCE = new Timestamp(); + } + + @Override + public String toString() { + return "seconds: " + getSeconds() + " nanos: " + getNanos(); + } +} \ No newline at end of file diff --git a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/utils/TimestampOrBuilder.java b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/utils/TimestampOrBuilder.java new file mode 100644 index 00000000..7a5e8159 --- /dev/null +++ b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/utils/TimestampOrBuilder.java @@ -0,0 +1,7 @@ +package com.clearblade.cloud.iot.v1.utils; + +public interface TimestampOrBuilder { + long getSeconds(); + + int getNanos(); +} \ No newline at end of file diff --git a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/utils/Utils.java b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/utils/Utils.java new file mode 100644 index 00000000..21944391 --- /dev/null +++ b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/utils/Utils.java @@ -0,0 +1,28 @@ +package com.clearblade.cloud.iot.v1.utils; + +public class Utils { + + /** + * Check if env variable set as Binary Data enabled. + * + * @return + */ + public static boolean isBinary() { + String isBinary = System.getenv(Constants.BINARYDATA); + if (isBinary != null && isBinary.equalsIgnoreCase("true")) { + return true; + } else + return false; + } + + public static boolean isEmpty(String text) { + int strLength; + if (text == null || (strLength = text.length()) == 0) + return true; + for (int i = 0; i < strLength; i++) + if (!Character.isWhitespace(text.charAt(i))) + return false; + return false; + } + +} From d2a7b6bcdee0ad41c789036fccd2cb6487109859 Mon Sep 17 00:00:00 2001 From: ronak-ingress Date: Wed, 8 Mar 2023 01:01:27 +0530 Subject: [PATCH 067/151] - Updated read me. --- README.md | 21 ++++++++++++++++++- .../iot/v1/ClearBladeRegistryManager.java | 2 +- 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 9774c6ea..8952b724 100644 --- a/README.md +++ b/README.md @@ -54,6 +54,7 @@ Maven: ``` export CLEARBLADE_REGISTRY=[your-registry] export CLEARBLADE_REGION=[your-region] + export BINARYDATA_AND_TIME_GOOGLE_FORMAT=true ``` 4. Use the HTTP or MQTT samples in the [samples](./clearblade-cloud-iot/samples) folder. @@ -66,7 +67,25 @@ Note that before you can run the sample, you must configure your development env and terminal as described in the Quickstart above or the [samples](./clearblade-cloud-iot/samples) folder. Before running the samples, you must set the `CLEARBLADE_CONFIGURATION`. Optionally set the `CLEARBLADE_REGISTRY` and -`CLEARBLADE_REGION` environment variables to avoid changing them in the the sample app every time you run it. +`CLEARBLADE_REGION` environment variables to avoid changing them in the the sample app every time you run it. + +If you set `BINARYDATA_AND_TIME_GOOGLE_FORMAT` environment variable then it will give binaryData object's response in binary +form and time in Timestamp format which will have seconds and nanos in it which is following google's structure. Basically +it's applicable on get device state list, modify config, device config versions methods. To get the data in proper format +it should be cast in proper format. + +``` + ListDeviceStatesResponse response = deviceManagerClient.listDeviceStates(request); + if(response != null) { + for (DeviceState element : response.getDeviceStatesList()) { + System.out.println(((ByteString)element.getBinaryData()).toByteArray()); + System.out.println(((ByteString)element.getBinaryData()).toStringUtf8()); + System.out.println(((Timestamp)element.getUpdateTime()).getSeconds()); + System.out.println(((Timestamp)element.getUpdateTime()).getNanos()); + } + } +``` + When switching to use new registries and/or regions, either: diff --git a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/ClearBladeRegistryManager.java b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/ClearBladeRegistryManager.java index 43c61eb1..ce4d6b22 100644 --- a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/ClearBladeRegistryManager.java +++ b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/ClearBladeRegistryManager.java @@ -196,7 +196,7 @@ public void asyncDeleteDeviceRegistry(DeleteDeviceRegistryRequest request) throw bodyParams, true); if (responseArray[0] != null) { int responseCode = Integer.parseInt(responseArray[0]); - if (responseCode == 200) { + if (responseCode == 200 || responseCode == 204) { System.out.println("DeleteDeviceRegistry execution successful"); } else { throw new ApplicationException(responseArray[2]); From a98791b053615d4a5f94f9cd850f9086922a7758 Mon Sep 17 00:00:00 2001 From: mikoaro Date: Tue, 7 Mar 2023 16:03:17 -0600 Subject: [PATCH 068/151] release 0.1.3 --- README.md | 2 +- clearblade-cloud-iot/pom.xml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 8952b724..a588900f 100644 --- a/README.md +++ b/README.md @@ -21,7 +21,7 @@ If you are using Maven artifact, simply add the following dependency to your pom io.github.clearblade clearblade-cloud-iot - 0.1.2 + 0.1.3 ``` diff --git a/clearblade-cloud-iot/pom.xml b/clearblade-cloud-iot/pom.xml index 2cf09b8a..8a306841 100644 --- a/clearblade-cloud-iot/pom.xml +++ b/clearblade-cloud-iot/pom.xml @@ -3,7 +3,7 @@ io.github.clearblade clearblade-cloud-iot - 0.1.2 + 0.1.3 jar Java Client Library for ClearBlade IoT Core From 110a1105cdf5b0a8bc4fb31e1aa8161cbee04e71 Mon Sep 17 00:00:00 2001 From: ronak-ingress Date: Mon, 20 Mar 2023 19:17:29 +0530 Subject: [PATCH 069/151] - Removed hardcoded false value. --- .../src/com/clearblade/cloud/iot/v1/devicetypes/Device.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/devicetypes/Device.java b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/devicetypes/Device.java index 5e033357..800d5a5f 100644 --- a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/devicetypes/Device.java +++ b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/devicetypes/Device.java @@ -420,7 +420,7 @@ public String createDeviceJSONObject() { deviceObj.put("lastConfigSendTime", this.lastConfigSendTime); } - deviceObj.put("blocked", false); + deviceObj.put("blocked", this.blocked); if (this.lastErrorTime != null) deviceObj.put("lastErrorTime", this.lastErrorTime); From 8d7886680be185fc2a772559ec36c56cfa870b90 Mon Sep 17 00:00:00 2001 From: mikoaro Date: Mon, 20 Mar 2023 09:43:24 -0500 Subject: [PATCH 070/151] release 0.1.4 --- README.md | 2 +- clearblade-cloud-iot/pom.xml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index a588900f..9129ae19 100644 --- a/README.md +++ b/README.md @@ -21,7 +21,7 @@ If you are using Maven artifact, simply add the following dependency to your pom io.github.clearblade clearblade-cloud-iot - 0.1.3 + 0.1.4 ``` diff --git a/clearblade-cloud-iot/pom.xml b/clearblade-cloud-iot/pom.xml index 8a306841..7f5d05f0 100644 --- a/clearblade-cloud-iot/pom.xml +++ b/clearblade-cloud-iot/pom.xml @@ -3,7 +3,7 @@ io.github.clearblade clearblade-cloud-iot - 0.1.3 + 0.1.4 jar Java Client Library for ClearBlade IoT Core From f87bca9cf45bcfc8d57951d019cd5007c1e233e0 Mon Sep 17 00:00:00 2001 From: ronak-ingress Date: Sat, 1 Apr 2023 01:36:09 +0530 Subject: [PATCH 071/151] Added null conditions while accessing Generic objects. --- .../iot/v1/devicetypes/DeviceConfig.java | 24 +++++++++---------- .../cloud/iot/v1/devicetypes/DeviceState.java | 16 ++++++------- .../clearblade/cloud/iot/v1/utils/Utils.java | 8 ++++--- 3 files changed, 25 insertions(+), 23 deletions(-) diff --git a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/devicetypes/DeviceConfig.java b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/devicetypes/DeviceConfig.java index f019d212..177cd10f 100644 --- a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/devicetypes/DeviceConfig.java +++ b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/devicetypes/DeviceConfig.java @@ -79,26 +79,26 @@ public String getVersion() { } public Object getCloudUpdateTime() { - if (Utils.isBinary() && !Utils.isEmpty(cloudUpdateTime.toString())) { + if (Utils.isBinary() && !Utils.isEmpty(cloudUpdateTime)) { Instant timeStamp = Instant.parse(cloudUpdateTime.toString()); return new Timestamp(timeStamp.getEpochSecond(), timeStamp.getNano()); } else - return cloudUpdateTime.toString(); + return (cloudUpdateTime != null ? cloudUpdateTime.toString() : ""); } public Object getDeviceAckTime() { - if (Utils.isBinary() && !Utils.isEmpty(deviceAckTime.toString())) { + if (Utils.isBinary() && !Utils.isEmpty(deviceAckTime)) { Instant timeStamp = Instant.parse(deviceAckTime.toString()); return new Timestamp(timeStamp.getEpochSecond(), timeStamp.getNano()); } else - return deviceAckTime.toString(); + return (deviceAckTime != null ? deviceAckTime.toString() : ""); } public Object getBinaryData() { - if (Utils.isBinary()) + if (Utils.isBinary() && !Utils.isEmpty(binaryData)) return ByteString.copyFromUtf8(binaryData.toString()); else - return binaryData.toString(); + return (binaryData != null ? binaryData.toString() : ""); } public static Builder newBuilder() { @@ -129,11 +129,11 @@ public Builder setVersion(String version) { } public Object getCloudUpdateTime() { - if (Utils.isBinary()) { + if (Utils.isBinary() && !Utils.isEmpty(cloudUpdateTime)) { Instant timeStamp = Instant.parse(cloudUpdateTime.toString()); return new Timestamp(timeStamp.getEpochSecond(), timeStamp.getNano()); } else - return cloudUpdateTime.toString(); + return (cloudUpdateTime != null ? cloudUpdateTime.toString() : ""); } public Builder setCloudUpdateTime(String cloudUpdateTime) { @@ -142,11 +142,11 @@ public Builder setCloudUpdateTime(String cloudUpdateTime) { } public Object getDeviceAckTime() { - if (Utils.isBinary()) { + if (Utils.isBinary() && !Utils.isEmpty(deviceAckTime)) { Instant timeStamp = Instant.parse(deviceAckTime.toString()); return new Timestamp(timeStamp.getEpochSecond(), timeStamp.getNano()); } else - return deviceAckTime.toString(); + return (deviceAckTime != null ? deviceAckTime.toString() : ""); } public Builder setDeviceAckTime(String deviceAckTime) { @@ -155,10 +155,10 @@ public Builder setDeviceAckTime(String deviceAckTime) { } public Object getBinaryData() { - if (Utils.isBinary()) + if (Utils.isBinary() && !Utils.isEmpty(binaryData)) return ByteString.copyFromUtf8(binaryData.toString()); else - return binaryData.toString(); + return (binaryData != null ? binaryData.toString() : ""); } public Builder setBinaryData(String binaryData) { diff --git a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/devicetypes/DeviceState.java b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/devicetypes/DeviceState.java index 55b8cfd0..425fd292 100644 --- a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/devicetypes/DeviceState.java +++ b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/devicetypes/DeviceState.java @@ -52,18 +52,18 @@ public DeviceState() { } public Object getBinaryData() { - if (Utils.isBinary()) + if (Utils.isBinary() && !Utils.isEmpty(binaryData)) return ByteString.copyFromUtf8(binaryData.toString()); else - return binaryData.toString(); + return (binaryData != null ? binaryData.toString() : ""); } public Object getUpdateTime() { - if (Utils.isBinary() && !Utils.isEmpty(updateTime.toString())) { + if (Utils.isBinary() && !Utils.isEmpty(updateTime)) { Instant timeStamp = Instant.parse(updateTime.toString()); return new Timestamp(timeStamp.getEpochSecond(), timeStamp.getNano()); } else - return updateTime.toString(); + return (updateTime != null ? updateTime.toString() : ""); } public void setUpdateTime(Object updateTime) { @@ -90,11 +90,11 @@ protected Builder() { } public Object getUpdateTime() { - if (Utils.isBinary() && !Utils.isEmpty(updateTime.toString())) { + if (Utils.isBinary() && !Utils.isEmpty(updateTime)) { Instant timeStamp = Instant.parse(updateTime.toString()); return new Timestamp(timeStamp.getEpochSecond(), timeStamp.getNano()); } else - return updateTime.toString(); + return (updateTime != null ? updateTime.toString() : ""); } public Builder setUpdateTime(String updateTime) { @@ -107,10 +107,10 @@ public Object getBinaryDataByte() { } public Object getBinaryData() { - if (Utils.isBinary()) + if (Utils.isBinary() && !Utils.isEmpty(binaryData)) return ByteString.copyFromUtf8(binaryData.toString()); else - return binaryData.toString(); + return (binaryData != null ? binaryData.toString() : ""); } public Builder setBinaryData(String binaryData) { diff --git a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/utils/Utils.java b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/utils/Utils.java index 21944391..839b2be8 100644 --- a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/utils/Utils.java +++ b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/utils/Utils.java @@ -15,12 +15,14 @@ public static boolean isBinary() { return false; } - public static boolean isEmpty(String text) { + public static boolean isEmpty(Object text) { int strLength; - if (text == null || (strLength = text.length()) == 0) + if (text == null) + return true; + if (text == null || (strLength = text.toString().length()) == 0) return true; for (int i = 0; i < strLength; i++) - if (!Character.isWhitespace(text.charAt(i))) + if (!Character.isWhitespace(text.toString().charAt(i))) return false; return false; } From f3c0769daadeb61ed21b965411f88719b997634f Mon Sep 17 00:00:00 2001 From: ronak-ingress Date: Tue, 4 Apr 2023 23:31:30 +0530 Subject: [PATCH 072/151] - updated if conditions --- .../iot/v1/devicetypes/DeviceConfig.java | 48 ++++++++++++------- .../cloud/iot/v1/devicetypes/DeviceState.java | 28 +++++++---- 2 files changed, 50 insertions(+), 26 deletions(-) diff --git a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/devicetypes/DeviceConfig.java b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/devicetypes/DeviceConfig.java index 177cd10f..0de5a855 100644 --- a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/devicetypes/DeviceConfig.java +++ b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/devicetypes/DeviceConfig.java @@ -79,24 +79,32 @@ public String getVersion() { } public Object getCloudUpdateTime() { - if (Utils.isBinary() && !Utils.isEmpty(cloudUpdateTime)) { - Instant timeStamp = Instant.parse(cloudUpdateTime.toString()); - return new Timestamp(timeStamp.getEpochSecond(), timeStamp.getNano()); + if (Utils.isBinary()) { + if (!Utils.isEmpty(cloudUpdateTime)) { + Instant timeStamp = Instant.parse(cloudUpdateTime.toString()); + return new Timestamp(timeStamp.getEpochSecond(), timeStamp.getNano()); + } else { + return new Timestamp(0, 0); + } } else return (cloudUpdateTime != null ? cloudUpdateTime.toString() : ""); } public Object getDeviceAckTime() { - if (Utils.isBinary() && !Utils.isEmpty(deviceAckTime)) { - Instant timeStamp = Instant.parse(deviceAckTime.toString()); - return new Timestamp(timeStamp.getEpochSecond(), timeStamp.getNano()); + if (Utils.isBinary()) { + if (!Utils.isEmpty(deviceAckTime)) { + Instant timeStamp = Instant.parse(deviceAckTime.toString()); + return new Timestamp(timeStamp.getEpochSecond(), timeStamp.getNano()); + } else { + return new Timestamp(0, 0); + } } else return (deviceAckTime != null ? deviceAckTime.toString() : ""); } public Object getBinaryData() { - if (Utils.isBinary() && !Utils.isEmpty(binaryData)) - return ByteString.copyFromUtf8(binaryData.toString()); + if (Utils.isBinary()) + return ByteString.copyFromUtf8(!Utils.isEmpty(binaryData) ? binaryData.toString() : ""); else return (binaryData != null ? binaryData.toString() : ""); } @@ -129,9 +137,13 @@ public Builder setVersion(String version) { } public Object getCloudUpdateTime() { - if (Utils.isBinary() && !Utils.isEmpty(cloudUpdateTime)) { - Instant timeStamp = Instant.parse(cloudUpdateTime.toString()); - return new Timestamp(timeStamp.getEpochSecond(), timeStamp.getNano()); + if (Utils.isBinary()) { + if (!Utils.isEmpty(cloudUpdateTime)) { + Instant timeStamp = Instant.parse(cloudUpdateTime.toString()); + return new Timestamp(timeStamp.getEpochSecond(), timeStamp.getNano()); + } else { + return new Timestamp(0, 0); + } } else return (cloudUpdateTime != null ? cloudUpdateTime.toString() : ""); } @@ -142,9 +154,13 @@ public Builder setCloudUpdateTime(String cloudUpdateTime) { } public Object getDeviceAckTime() { - if (Utils.isBinary() && !Utils.isEmpty(deviceAckTime)) { - Instant timeStamp = Instant.parse(deviceAckTime.toString()); - return new Timestamp(timeStamp.getEpochSecond(), timeStamp.getNano()); + if (Utils.isBinary()) { + if (!Utils.isEmpty(deviceAckTime)) { + Instant timeStamp = Instant.parse(deviceAckTime.toString()); + return new Timestamp(timeStamp.getEpochSecond(), timeStamp.getNano()); + } else { + return new Timestamp(0, 0); + } } else return (deviceAckTime != null ? deviceAckTime.toString() : ""); } @@ -155,8 +171,8 @@ public Builder setDeviceAckTime(String deviceAckTime) { } public Object getBinaryData() { - if (Utils.isBinary() && !Utils.isEmpty(binaryData)) - return ByteString.copyFromUtf8(binaryData.toString()); + if (Utils.isBinary()) + return ByteString.copyFromUtf8(!Utils.isEmpty(binaryData) ? binaryData.toString() : ""); else return (binaryData != null ? binaryData.toString() : ""); } diff --git a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/devicetypes/DeviceState.java b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/devicetypes/DeviceState.java index 425fd292..f4beb8ff 100644 --- a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/devicetypes/DeviceState.java +++ b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/devicetypes/DeviceState.java @@ -52,16 +52,20 @@ public DeviceState() { } public Object getBinaryData() { - if (Utils.isBinary() && !Utils.isEmpty(binaryData)) - return ByteString.copyFromUtf8(binaryData.toString()); + if (Utils.isBinary()) + return ByteString.copyFromUtf8(!Utils.isEmpty(binaryData) ? binaryData.toString() : ""); else return (binaryData != null ? binaryData.toString() : ""); } public Object getUpdateTime() { - if (Utils.isBinary() && !Utils.isEmpty(updateTime)) { - Instant timeStamp = Instant.parse(updateTime.toString()); - return new Timestamp(timeStamp.getEpochSecond(), timeStamp.getNano()); + if (Utils.isBinary()) { + if (!Utils.isEmpty(updateTime)) { + Instant timeStamp = Instant.parse(updateTime.toString()); + return new Timestamp(timeStamp.getEpochSecond(), timeStamp.getNano()); + } else { + return new Timestamp(0, 0); + } } else return (updateTime != null ? updateTime.toString() : ""); } @@ -90,9 +94,13 @@ protected Builder() { } public Object getUpdateTime() { - if (Utils.isBinary() && !Utils.isEmpty(updateTime)) { - Instant timeStamp = Instant.parse(updateTime.toString()); - return new Timestamp(timeStamp.getEpochSecond(), timeStamp.getNano()); + if (Utils.isBinary()) { + if (!Utils.isEmpty(updateTime)) { + Instant timeStamp = Instant.parse(updateTime.toString()); + return new Timestamp(timeStamp.getEpochSecond(), timeStamp.getNano()); + } else { + return new Timestamp(0, 0); + } } else return (updateTime != null ? updateTime.toString() : ""); } @@ -107,8 +115,8 @@ public Object getBinaryDataByte() { } public Object getBinaryData() { - if (Utils.isBinary() && !Utils.isEmpty(binaryData)) - return ByteString.copyFromUtf8(binaryData.toString()); + if (Utils.isBinary()) + return ByteString.copyFromUtf8(!Utils.isEmpty(binaryData) ? binaryData.toString() : ""); else return (binaryData != null ? binaryData.toString() : ""); } From 2a86457714c749c0160f25e83057e6d663ee557d Mon Sep 17 00:00:00 2001 From: ronak-ingress Date: Mon, 8 May 2023 11:04:35 +0530 Subject: [PATCH 073/151] fixed meta data and credentials null pointer issue. --- .../v1/updatedevice/UpdateDeviceRequest.java | 218 +++++++++--------- 1 file changed, 115 insertions(+), 103 deletions(-) diff --git a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/updatedevice/UpdateDeviceRequest.java b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/updatedevice/UpdateDeviceRequest.java index 8ae9fb9b..d6cde0b2 100644 --- a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/updatedevice/UpdateDeviceRequest.java +++ b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/updatedevice/UpdateDeviceRequest.java @@ -33,6 +33,7 @@ import java.util.ArrayList; import java.util.Iterator; import java.util.List; +import java.util.Set; import org.json.simple.JSONArray; import org.json.simple.JSONObject; @@ -41,114 +42,125 @@ import com.clearblade.cloud.iot.v1.devicetypes.DeviceCredential; public class UpdateDeviceRequest { - private final String name; - private final Device device; - private final String updateMask; - JSONObject requestParams; - JSONObject bodyParams; - - private UpdateDeviceRequest(Builder builder) { - this.name = builder.name; - this.updateMask = builder.updateMask; - this.device = builder.device; - } - - public JSONObject getRequestParams() { - return requestParams; - } - - public void setRequestParams(JSONObject requestParams) { - this.requestParams = requestParams; - } - - public JSONObject getBodyParams() { - return bodyParams; - } - - public void setBodyParams(JSONObject bodyParams) { - this.bodyParams = bodyParams; - } - - // Static class Builder - public static class Builder { - - /// instance fields - private String name; - private Device device; - private String updateMask; - - public static Builder newBuilder() { - return new Builder(); - } - - private Builder() { - } - - // Setter methods - public Builder setName(String name) { - this.name = name; - return this; - } - - public Builder setDevice(Device device) { - this.device = device; - return this; - } - - public Builder setUpdateMask(String updateMask) { - this.updateMask = updateMask; - return this; - } - - // build method to deal with outer class - // to return outer instance - public UpdateDeviceRequest build() { - return new UpdateDeviceRequest(this); - } - } - - @SuppressWarnings("unchecked") - @Override - public String toString() { - requestParams.put("name", this.name); - requestParams.put("updateMask", this.updateMask); + private final String name; + private final Device device; + private final String updateMask; + JSONObject requestParams; + JSONObject bodyParams; + + private UpdateDeviceRequest(Builder builder) { + this.name = builder.name; + this.updateMask = builder.updateMask; + this.device = builder.device; + } + + public JSONObject getRequestParams() { + return requestParams; + } + + public void setRequestParams(JSONObject requestParams) { + this.requestParams = requestParams; + } + + public JSONObject getBodyParams() { + return bodyParams; + } + + public void setBodyParams(JSONObject bodyParams) { + this.bodyParams = bodyParams; + } + + // Static class Builder + public static class Builder { + + /// instance fields + private String name; + private Device device; + private String updateMask; + + public static Builder newBuilder() { + return new Builder(); + } + + private Builder() { + } + + // Setter methods + public Builder setName(String name) { + this.name = name; + return this; + } + + public Builder setDevice(Device device) { + this.device = device; + return this; + } + + public Builder setUpdateMask(String updateMask) { + this.updateMask = updateMask; + return this; + } + + // build method to deal with outer class + // to return outer instance + public UpdateDeviceRequest build() { + return new UpdateDeviceRequest(this); + } + } + + @SuppressWarnings("unchecked") + @Override + public String toString() { + requestParams.put("name", this.name); + requestParams.put("updateMask", this.updateMask); bodyParams.put("id", this.device.toBuilder().getId()); bodyParams.put("name", this.device.toBuilder().getName()); bodyParams.put("logLevel", this.device.toBuilder().getLogLevel()); bodyParams.put("blocked", this.device.toBuilder().isBlocked()); - return "name=" + this.name + ",updateMask=" + this.updateMask + ", logLevel= " - + this.device.toBuilder().getLogLevel(); - } - - @SuppressWarnings("unchecked") - public String[] getBodyAndParams() { - String[] output = new String[2]; - - String params = "name=" + this.name + "&updateMask=" + this.updateMask; - bodyParams = new JSONObject(); - - bodyParams.put("id", this.device.toBuilder().getId()); - bodyParams.put("name", this.device.toBuilder().getName()); - if (this.device.toBuilder().getLogLevel() != null) { - bodyParams.put("logLevel", this.device.toBuilder().getLogLevel().toString()); - } - bodyParams.put("blocked", this.device.toBuilder().isBlocked()); - if (this.device.toBuilder().getCredentials().size() > 0) { - JSONArray jsonArray = new JSONArray(); - for (int i = 0; i < this.device.toBuilder().getCredentials().size(); i++) { - if (!this.device.toBuilder().getCredentials().get(i).isEmpty()) { - DeviceCredential credentialObj = this.device.toBuilder().getCredentials().get(i); - jsonArray.add(credentialObj.toJSONObject()); - } - } - bodyParams.put("credentials", jsonArray); - } - - output[0] = params; - output[1] = bodyParams.toString(); - return output; - } + return "name=" + this.name + ",updateMask=" + this.updateMask + ", logLevel= " + + this.device.toBuilder().getLogLevel(); + } + + @SuppressWarnings("unchecked") + public String[] getBodyAndParams() { + String[] output = new String[2]; + + String params = "name=" + this.name + "&updateMask=" + this.updateMask; + bodyParams = new JSONObject(); + + bodyParams.put("id", this.device.toBuilder().getId()); + bodyParams.put("name", this.device.toBuilder().getName()); + if (this.device.toBuilder().getLogLevel() != null) { + bodyParams.put("logLevel", this.device.toBuilder().getLogLevel().toString()); + } + bodyParams.put("blocked", this.device.toBuilder().isBlocked()); + if (this.device.toBuilder().getCredentials() != null && this.device.toBuilder().getCredentials().size() > 0) { + JSONArray jsonArray = new JSONArray(); + for (int i = 0; i < this.device.toBuilder().getCredentials().size(); i++) { + if (!this.device.toBuilder().getCredentials().get(i).isEmpty()) { + DeviceCredential credentialObj = this.device.toBuilder().getCredentials().get(i); + jsonArray.add(credentialObj.toJSONObject()); + } + } + bodyParams.put("credentials", jsonArray); + } + if (this.device.toBuilder().getMetadata() != null && this.device.toBuilder().getMetadata().size() > 0) { + Set metaSet = this.device.toBuilder().getMetadata().keySet(); + Iterator itr = metaSet.iterator(); + JSONObject jsonObject = new JSONObject(); + while (itr.hasNext()) { + String key = (String) itr.next(); + String value = this.device.toBuilder().getMetadata().get(key).toString(); + jsonObject.put(key, value); + } + bodyParams.put("metadata", jsonObject); + } + + output[0] = params; + output[1] = bodyParams.toString(); + return output; + } } From 7d1f3f952e1be789cffc0952ddfa3c76f0005ef5 Mon Sep 17 00:00:00 2001 From: mikoaro Date: Thu, 11 May 2023 10:48:11 -0500 Subject: [PATCH 074/151] release 0.1.5 --- README.md | 13 ++++++------- clearblade-cloud-iot/pom.xml | 2 +- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index 9129ae19..bf063124 100644 --- a/README.md +++ b/README.md @@ -21,7 +21,7 @@ If you are using Maven artifact, simply add the following dependency to your pom io.github.clearblade clearblade-cloud-iot - 0.1.4 + 0.1.5 ``` @@ -54,7 +54,7 @@ Maven: ``` export CLEARBLADE_REGISTRY=[your-registry] export CLEARBLADE_REGION=[your-region] - export BINARYDATA_AND_TIME_GOOGLE_FORMAT=true + export BINARYDATA_AND_TIME_GOOGLE_FORMAT=true ``` 4. Use the HTTP or MQTT samples in the [samples](./clearblade-cloud-iot/samples) folder. @@ -67,11 +67,11 @@ Note that before you can run the sample, you must configure your development env and terminal as described in the Quickstart above or the [samples](./clearblade-cloud-iot/samples) folder. Before running the samples, you must set the `CLEARBLADE_CONFIGURATION`. Optionally set the `CLEARBLADE_REGISTRY` and -`CLEARBLADE_REGION` environment variables to avoid changing them in the the sample app every time you run it. +`CLEARBLADE_REGION` environment variables to avoid changing them in the the sample app every time you run it. If you set `BINARYDATA_AND_TIME_GOOGLE_FORMAT` environment variable then it will give binaryData object's response in binary -form and time in Timestamp format which will have seconds and nanos in it which is following google's structure. Basically -it's applicable on get device state list, modify config, device config versions methods. To get the data in proper format +form and time in Timestamp format which will have seconds and nanos in it which is following google's structure. Basically +it's applicable on get device state list, modify config, device config versions methods. To get the data in proper format it should be cast in proper format. ``` @@ -81,12 +81,11 @@ it should be cast in proper format. System.out.println(((ByteString)element.getBinaryData()).toByteArray()); System.out.println(((ByteString)element.getBinaryData()).toStringUtf8()); System.out.println(((Timestamp)element.getUpdateTime()).getSeconds()); - System.out.println(((Timestamp)element.getUpdateTime()).getNanos()); + System.out.println(((Timestamp)element.getUpdateTime()).getNanos()); } } ``` - When switching to use new registries and/or regions, either: 1. Update the `CLEARBLADE_REGISTRY` and `CLEARBLADE_REGION` environment variables; or diff --git a/clearblade-cloud-iot/pom.xml b/clearblade-cloud-iot/pom.xml index 7f5d05f0..c5547811 100644 --- a/clearblade-cloud-iot/pom.xml +++ b/clearblade-cloud-iot/pom.xml @@ -3,7 +3,7 @@ io.github.clearblade clearblade-cloud-iot - 0.1.4 + 0.1.5 jar Java Client Library for ClearBlade IoT Core From 64a7a351a45de1097999cc891629c110d3cffd6f Mon Sep 17 00:00:00 2001 From: ronak-ingress Date: Sat, 13 May 2023 02:48:19 +0530 Subject: [PATCH 075/151] - Removed ConfigParameters static variables. - Updated logic to call getRegistryCred API each time, store its value with combination of location and registry, and if cached return from there. - Updated all request classes and added public access of its parent, device name, registry - Added PathTemplate as per google's structure. - Updated DeviceName, LocationName and RegistryName. - Updated AsyncClient and SyncClient. --- clearblade-cloud-iot/pom.xml | 5 + .../clearblade/cloud/iot/v1/AsyncClient.java | 551 ++++++----- .../cloud/iot/v1/ClearBladeDeviceManager.java | 832 ++++++++--------- .../iot/v1/ClearBladeRegistryManager.java | 333 +++---- .../iot/v1/DeviceManagerAsyncClient.java | 266 +++--- .../clearblade/cloud/iot/v1/SyncClient.java | 530 ++++++----- .../BindDeviceToGatewayRequest.java | 200 ++-- .../v1/createdevice/CreateDeviceRequest.java | 78 +- .../CreateDeviceRegistryRequest.java | 6 + .../v1/deviceslist/DevicesListRequest.java | 233 ++--- .../ListDeviceStatesRequest.java | 140 +-- .../cloud/iot/v1/devicetypes/DeviceName.java | 250 ++--- .../iot/v1/getdevice/GetDeviceRequest.java | 118 +-- .../GetDeviceRegistryRequest.java | 66 +- .../ListDeviceConfigVersionsRequest.java | 140 +-- .../ListDeviceRegistriesRequest.java | 139 +-- .../ModifyCloudToDeviceConfigRequest.java | 172 ++-- .../iot/v1/registrytypes/LocationName.java | 186 ++-- .../iot/v1/registrytypes/RegistryName.java | 221 ++--- .../SendCommandToDeviceRequest.java | 252 ++--- .../UnbindDeviceFromGatewayRequest.java | 199 ++-- .../v1/updatedevice/UpdateDeviceRequest.java | 223 ++--- .../UpdateDeviceRegistryRequest.java | 183 ++-- .../cloud/iot/v1/utils/AuthParams.java | 296 +++--- .../cloud/iot/v1/utils/AutoValue.java | 18 + .../utils/AutoValue_PathTemplate_Segment.java | 63 ++ .../cloud/iot/v1/utils/ConfigParameters.java | 251 +++-- .../cloud/iot/v1/utils/PathTemplate.java | 863 ++++++++++++++++++ .../iot/v1/utils/TemplatedResourceName.java | 170 ++++ .../iot/v1/utils/ValidationException.java | 58 ++ 30 files changed, 4207 insertions(+), 2835 deletions(-) create mode 100644 clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/utils/AutoValue.java create mode 100644 clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/utils/AutoValue_PathTemplate_Segment.java create mode 100644 clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/utils/PathTemplate.java create mode 100644 clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/utils/TemplatedResourceName.java create mode 100644 clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/utils/ValidationException.java diff --git a/clearblade-cloud-iot/pom.xml b/clearblade-cloud-iot/pom.xml index 7f5d05f0..f2be1f6c 100644 --- a/clearblade-cloud-iot/pom.xml +++ b/clearblade-cloud-iot/pom.xml @@ -209,5 +209,10 @@ jsr305 3.0.2 + + com.google.guava + guava + 31.1-jre + \ No newline at end of file diff --git a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/AsyncClient.java b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/AsyncClient.java index 0eadd81c..aece175f 100644 --- a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/AsyncClient.java +++ b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/AsyncClient.java @@ -42,260 +42,315 @@ import java.util.logging.Level; import java.util.logging.Logger; +import com.clearblade.cloud.iot.v1.binddevicetogateway.BindDeviceToGatewayRequest; +import com.clearblade.cloud.iot.v1.createdevice.CreateDeviceRequest; +import com.clearblade.cloud.iot.v1.deletedevice.DeleteDeviceRequest; +import com.clearblade.cloud.iot.v1.deviceslist.DevicesListRequest; +import com.clearblade.cloud.iot.v1.devicestateslist.ListDeviceStatesRequest; import com.clearblade.cloud.iot.v1.exception.ApplicationException; +import com.clearblade.cloud.iot.v1.getdevice.GetDeviceRequest; +import com.clearblade.cloud.iot.v1.getdeviceregistry.GetDeviceRegistryRequest; +import com.clearblade.cloud.iot.v1.listdeviceconfigversions.ListDeviceConfigVersionsRequest; +import com.clearblade.cloud.iot.v1.modifycloudtodeviceconfig.ModifyCloudToDeviceConfigRequest; +import com.clearblade.cloud.iot.v1.sendcommandtodevice.SendCommandToDeviceRequest; +import com.clearblade.cloud.iot.v1.unbinddevicefromgateway.UnbindDeviceFromGatewayRequest; +import com.clearblade.cloud.iot.v1.updatedevice.UpdateDeviceRequest; +import com.clearblade.cloud.iot.v1.updatedeviceregistry.UpdateDeviceRegistryRequest; import com.clearblade.cloud.iot.v1.utils.AuthParams; import com.clearblade.cloud.iot.v1.utils.ConfigParameters; import com.clearblade.cloud.iot.v1.utils.Constants; +import org.json.simple.parser.ParseException; public class AsyncClient { - static Logger log = Logger.getLogger(AsyncClient.class.getName()); - - private ConfigParameters configParameters = ConfigParameters.getInstance(); - private String[] responseArray = new String[3]; - private boolean isAdmin = false; - - /** - * Method used to generate URL for apicall - * @param apiName - path to api - * @param params - parameters to be attached to request - * @return URL formed and to be used - */ - private String generateURL(String apiName, String params) { - - return AuthParams.getApiBaseURL().concat(configParameters.getEndpointPort()) - .concat(configParameters.getWebhook()).concat(AuthParams.getUserSystemKey()).concat(apiName) - .concat("?" + params); - } - - /** - * Method used to generate URL for apicall - * @param apiName - path to api - * @param params - parameters to be attached to request - * @return URL formed and to be used - */ - private String generateAdminURL(String apiName, String params) { - - return AuthParams.getBaseURL().concat(configParameters.getWebhook()).concat(AuthParams.getAdminSystemKey()) - .concat(apiName).concat("?" + params); - } - - /** - * Method used to Calls HTTP Get request - * @param apiName - * @param params - * @return String[] containing responseCode, responseMessage and response object - * @throws IOException - * @throws ApplicationException - */ - public String[] get(String apiName, String params) { - String finalURL = ""; - String token = ""; - try { - if (isAdmin) { - AuthParams.setAdminCredentials(); - finalURL = generateAdminURL(apiName, params); - token = AuthParams.getAdminToken(); - } else { - AuthParams.setRegistryCredentials(); - finalURL = generateURL(apiName, params); - token = AuthParams.getUserToken(); - } - HttpRequest request = HttpRequest.newBuilder().uri(URI.create(finalURL)) - .headers(Constants.HTTP_REQUEST_PROPERTY_CONTENT_TYPE_KEY, - Constants.HTTP_REQUEST_PROPERTY_CONTENT_TYPE_ACCEPT_VALUE, - Constants.HTTP_REQUEST_PROPERTY_TOKEN_KEY, token, - Constants.HTTP_REQUEST_PROPERTY_ACCEPT_KEY, - Constants.HTTP_REQUEST_PROPERTY_CONTENT_TYPE_ACCEPT_VALUE) - .GET().build(); - - CompletableFuture> response = HttpClient.newBuilder().build() - .sendAsync(request, HttpResponse.BodyHandlers.ofString()); - - HttpResponse httpResponse = response.get(); - responseArray[0] = String.valueOf(httpResponse.statusCode()); - responseArray[1] = ""; - responseArray[2] = httpResponse.body(); - - } catch (ApplicationException | IOException e) { - log.log(Level.SEVERE, e.getMessage()); - } catch (InterruptedException ex) { - log.log(Level.SEVERE, ex.getMessage()); - Thread.currentThread().interrupt(); - } catch (Exception ec) { - log.log(Level.SEVERE, ec.getMessage()); - } - - return responseArray; - } - - /** - * Method used to call HTTP Post request - * @param apiName - * @param params - * @param body - * @return String[] containing responseCode, responseMessage and response object - * @throws IOException - * @throws ApplicationException - */ - public String[] post(String apiName, String params, String body) { - String finalURL = ""; - String token = ""; - try { - if (isAdmin) { - AuthParams.setAdminCredentials(); - finalURL = generateAdminURL(apiName, params); - token = AuthParams.getAdminToken(); - } else { - AuthParams.setRegistryCredentials(); - finalURL = generateURL(apiName, params); - token = AuthParams.getUserToken(); - } - BodyPublisher jsonPayload = BodyPublishers.ofString(body); - HttpRequest request = HttpRequest.newBuilder() - .uri(URI.create(finalURL)) - .method(Constants.HTTP_REQUEST_METHOD_TYPE_POST, jsonPayload) - .headers(Constants.HTTP_REQUEST_PROPERTY_CONTENT_TYPE_KEY, Constants.HTTP_REQUEST_PROPERTY_CONTENT_TYPE_ACCEPT_VALUE, - Constants.HTTP_REQUEST_PROPERTY_TOKEN_KEY, token, - Constants.HTTP_REQUEST_PROPERTY_ACCEPT_KEY, Constants.HTTP_REQUEST_PROPERTY_CONTENT_TYPE_ACCEPT_VALUE) - .build(); - - CompletableFuture> response = HttpClient.newBuilder() - .version(HttpClient.Version.HTTP_2) - .connectTimeout(Duration.ofSeconds(20)) - .build() - .sendAsync(request, HttpResponse.BodyHandlers.ofString()); - - HttpResponse httpResponse = response.get(); - responseArray[0] = String.valueOf(httpResponse.statusCode()); - responseArray[1] = ""; - responseArray[2] = httpResponse.body(); - - } catch (ApplicationException | IOException e) { - log.log(Level.SEVERE, e.getMessage()); - } catch (InterruptedException ex) { - log.log(Level.SEVERE, ex.getMessage()); - Thread.currentThread().interrupt(); - }catch(Exception ec) { - log.log(Level.SEVERE, ec.getMessage()); - } - - return responseArray; - - } - - /** - * Method used to call HTTP delete request - * @param apiName - * @param params - * @return String[] containing responseCode, responseMessage and response object - * @throws IOException - * @throws ApplicationException - */ - public String[] delete(String apiName, String params) { - String finalURL = ""; - String token = ""; - try { - if (isAdmin) { - AuthParams.setAdminCredentials(); - finalURL = generateAdminURL(apiName, params); - token = AuthParams.getAdminToken(); - } else { - AuthParams.setRegistryCredentials(); - finalURL = generateURL(apiName, params); - token = AuthParams.getUserToken(); - } - - HttpRequest request = HttpRequest.newBuilder() - .uri(URI.create(finalURL)) - .headers(Constants.HTTP_REQUEST_PROPERTY_CONTENT_TYPE_KEY, Constants.HTTP_REQUEST_PROPERTY_CONTENT_TYPE_ACCEPT_VALUE, - Constants.HTTP_REQUEST_PROPERTY_TOKEN_KEY, token, - Constants.HTTP_REQUEST_PROPERTY_ACCEPT_KEY, Constants.HTTP_REQUEST_PROPERTY_CONTENT_TYPE_ACCEPT_VALUE) - .DELETE() - .build(); - - CompletableFuture> response = HttpClient.newBuilder() - .build() - .sendAsync(request, HttpResponse.BodyHandlers.ofString()); - - HttpResponse httpResponse = response.get(); - responseArray[0] = String.valueOf(httpResponse.statusCode()); - responseArray[1] = ""; - responseArray[2] = httpResponse.body(); - - } catch (ApplicationException | IOException e) { - log.log(Level.SEVERE, e.getMessage()); - } catch (InterruptedException ex) { - log.log(Level.SEVERE, ex.getMessage()); - Thread.currentThread().interrupt(); - }catch(Exception ec) { - log.log(Level.SEVERE, ec.getMessage()); - } - - return responseArray; - - } - - /** - * Method used to call HTTP Patch request - * @param apiName - * @param params - * @param body - * @return String[] Object containing responseCode, responseMessage and response - * object - */ - public String[] update(String apiName, String params, String body) { - try { - AuthParams.setRegistryCredentials(); - String finalURL = generateURL(apiName, params); - - BodyPublisher jsonPayload = BodyPublishers.ofString(body); - HttpRequest request = HttpRequest.newBuilder().uri(URI.create(finalURL)) - .method(Constants.HTTP_REQUEST_METHOD_TYPE_PATCH, jsonPayload) - .headers(Constants.HTTP_REQUEST_PROPERTY_CONTENT_TYPE_KEY, - Constants.HTTP_REQUEST_PROPERTY_CONTENT_TYPE_ACCEPT_VALUE, - Constants.HTTP_REQUEST_PROPERTY_TOKEN_KEY, AuthParams.getUserToken(), - Constants.HTTP_REQUEST_PROPERTY_ACCEPT_KEY, - Constants.HTTP_REQUEST_PROPERTY_CONTENT_TYPE_ACCEPT_VALUE) - .build(); - - CompletableFuture> response = HttpClient.newBuilder().build().sendAsync(request, - HttpResponse.BodyHandlers.ofString()); - - HttpResponse httpResponse = response.get(); - responseArray[0] = String.valueOf(httpResponse.statusCode()); - responseArray[1] = ""; - responseArray[2] = httpResponse.body(); - - } catch (ApplicationException | IOException e) { - log.log(Level.SEVERE, e.getMessage()); - } catch (InterruptedException ex) { - log.log(Level.SEVERE, ex.getMessage()); - Thread.currentThread().interrupt(); - } catch (Exception ec) { - log.log(Level.SEVERE, ec.getMessage()); - } - - return responseArray; - } - - // Registry Apis - - public String[] asyncCreateDeviceRegistry(String apiName, String params, String body, boolean isAdmin) { - this.isAdmin = isAdmin; - return this.post(apiName, params, body); - } - - - public String[] asyncDeleteDeviceRegistry(String apiName, String params, boolean isAdmin){ - this.isAdmin = isAdmin; - return this.delete(apiName, params); - } - - - public String[] asyncListDeviceRegistries(String apiName, String params, boolean isAdmin) { - this.isAdmin = isAdmin; - return this.get(apiName, params); - } + static Logger log = Logger.getLogger(AsyncClient.class.getName()); + private String[] responseArray = new String[3]; + private boolean isAdmin = false; + private AuthParams authParams = new AuthParams(); + + /** + * Method used to generate URL for apicall + * + * @param apiName - path to api + * @param params - parameters to be attached to request + * @return URL formed and to be used + */ + private String generateURL(AuthParams authParams, String apiName, String params) { + + return authParams.getApiBaseURL().concat(Constants.ENDPOINTPORT).concat(Constants.WEBHOOK).concat(authParams.getUserSystemKey()).concat(apiName).concat("?" + params); + } + + /** + * Method used to generate URL for apicall + * + * @param apiName - path to api + * @param params - parameters to be attached to request + * @return URL formed and to be used + */ + private String generateAdminURL(AuthParams authParams, String apiName, String params) { + + return authParams.getBaseURL().concat(Constants.WEBHOOK).concat(authParams.getAdminSystemKey()).concat(apiName).concat("?" + params); + } + + /** + * Method used to Calls HTTP Get request + * + * @param apiName + * @return String[] containing responseCode, responseMessage and response object + * @throws IOException + * @throws ApplicationException + */ + public String[] get(String apiName, GetDeviceRequest request) throws IOException, ParseException { + authParams.setRegistryCredentials(request.getName().getProject(), request.getName().getRegistry(), request.getName().getLocation()); + String finalURL = generateURL(authParams, apiName, request.toString()); + String token = authParams.getUserToken(); + return get(finalURL, token); + } + + public String[] get(String apiName, String params, DevicesListRequest request) throws IOException, ParseException { + authParams.setRegistryCredentials(request.getParent().getProject(), request.getParent().getRegistry(), request.getParent().getLocation()); + String finalURL = generateURL(authParams, apiName, params); + String token = authParams.getUserToken(); + return get(finalURL, token); + } + + public String[] get(String apiName, String params, ListDeviceStatesRequest request) throws IOException, ParseException { + authParams.setRegistryCredentials(request.getName().getProject(), request.getName().getRegistry(), request.getName().getLocation()); + String finalURL = generateURL(authParams, apiName, params); + String token = authParams.getUserToken(); + return get(finalURL, token); + } + + public String[] get(String apiName, String params, GetDeviceRegistryRequest request) throws IOException, ParseException { + authParams.setRegistryCredentials(request.getName().getProject(), request.getName().getRegistry(), request.getName().getLocation()); + String finalURL = generateURL(authParams, apiName, params); + String token = authParams.getUserToken(); + return get(finalURL, token); + } + + public String[] get(String apiName, String params, ListDeviceConfigVersionsRequest request) throws IOException, ParseException { + authParams.setRegistryCredentials(request.getName().getProject(), request.getName().getRegistry(), request.getName().getLocation()); + String finalURL = generateURL(authParams, apiName, params); + String token = authParams.getUserToken(); + return get(finalURL, token); + } + + public String[] get(String finalURL, String token) { + try { + HttpRequest request = HttpRequest.newBuilder().uri(URI.create(finalURL)).headers(Constants.HTTP_REQUEST_PROPERTY_CONTENT_TYPE_KEY, Constants.HTTP_REQUEST_PROPERTY_CONTENT_TYPE_ACCEPT_VALUE, Constants.HTTP_REQUEST_PROPERTY_TOKEN_KEY, token, Constants.HTTP_REQUEST_PROPERTY_ACCEPT_KEY, Constants.HTTP_REQUEST_PROPERTY_CONTENT_TYPE_ACCEPT_VALUE).GET().build(); + + CompletableFuture> response = HttpClient.newBuilder().build().sendAsync(request, HttpResponse.BodyHandlers.ofString()); + + HttpResponse httpResponse = response.get(); + responseArray[0] = String.valueOf(httpResponse.statusCode()); + responseArray[1] = ""; + responseArray[2] = httpResponse.body(); + + } catch (ApplicationException e) { + log.log(Level.SEVERE, e.getMessage()); + } catch (InterruptedException ex) { + log.log(Level.SEVERE, ex.getMessage()); + Thread.currentThread().interrupt(); + } catch (Exception ec) { + log.log(Level.SEVERE, ec.getMessage()); + } + return responseArray; + } + + public String[] post(String apiName, String params, String body, CreateDeviceRequest request) throws IOException, ParseException { + authParams.setRegistryCredentials(request.getParent().getProject(), request.getParent().getRegistry(), request.getParent().getLocation()); + String finalURL = generateURL(authParams, apiName, params); + String token = authParams.getUserToken(); + return post(finalURL, body, token); + } + + public String[] post(String apiName, String params, String body, SendCommandToDeviceRequest request) throws IOException, ParseException { + String finalURL = ""; + String token = ""; + authParams.setRegistryCredentials(request.getDeviceName().getProject(), request.getDeviceName().getRegistry(), request.getDeviceName().getLocation()); + finalURL = generateURL(authParams, apiName, params); + token = authParams.getUserToken(); + return post(finalURL, body, token); + } + + public String[] post(String apiName, String params, String body, BindDeviceToGatewayRequest request) throws IOException, ParseException { + authParams.setRegistryCredentials(request.getParent().getProject(), request.getParent().getRegistry(), request.getParent().getLocation()); + String finalURL = generateURL(authParams, apiName, params); + String token = authParams.getUserToken(); + return post(finalURL, body, token); + } + + public String[] post(String apiName, String params, String body, ModifyCloudToDeviceConfigRequest request) throws IOException, ParseException { + authParams.setRegistryCredentials(request.getDeviceName().getProject(), request.getDeviceName().getRegistry(), request.getDeviceName().getLocation()); + String finalURL = generateURL(authParams, apiName, params); + String token = authParams.getUserToken(); + return post(finalURL, body, token); + } + + public String[] post(String apiName, String params, String body, UnbindDeviceFromGatewayRequest request) throws IOException, ParseException { + authParams.setRegistryCredentials(request.getParent().getProject(), request.getParent().getRegistry(), request.getParent().getLocation()); + String finalURL = generateURL(authParams, apiName, params); + String token = authParams.getUserToken(); + return post(finalURL, body, token); + } + + /** + * Method used to call HTTP Post request + * + * @param body + * @return String[] containing responseCode, responseMessage and response object + * @throws IOException + * @throws ApplicationException + */ + public String[] post(String finalURL, String body, String token) { + try { + BodyPublisher jsonPayload = BodyPublishers.ofString(body); + HttpRequest request = HttpRequest.newBuilder().uri(URI.create(finalURL)).method(Constants.HTTP_REQUEST_METHOD_TYPE_POST, jsonPayload).headers(Constants.HTTP_REQUEST_PROPERTY_CONTENT_TYPE_KEY, Constants.HTTP_REQUEST_PROPERTY_CONTENT_TYPE_ACCEPT_VALUE, Constants.HTTP_REQUEST_PROPERTY_TOKEN_KEY, token, Constants.HTTP_REQUEST_PROPERTY_ACCEPT_KEY, Constants.HTTP_REQUEST_PROPERTY_CONTENT_TYPE_ACCEPT_VALUE).build(); + + CompletableFuture> response = HttpClient.newBuilder().version(HttpClient.Version.HTTP_2).connectTimeout(Duration.ofSeconds(20)).build().sendAsync(request, HttpResponse.BodyHandlers.ofString()); + + HttpResponse httpResponse = response.get(); + responseArray[0] = String.valueOf(httpResponse.statusCode()); + responseArray[1] = ""; + responseArray[2] = httpResponse.body(); + + } catch (ApplicationException e) { + log.log(Level.SEVERE, e.getMessage()); + } catch (InterruptedException ex) { + log.log(Level.SEVERE, ex.getMessage()); + Thread.currentThread().interrupt(); + } catch (Exception ec) { + log.log(Level.SEVERE, ec.getMessage()); + } + + return responseArray; + + } + + public String[] delete(String apiName, String params, DeleteDeviceRequest request) throws IOException, ParseException { + String finalURL = ""; + String token = ""; + if (isAdmin) { + authParams.setAdminCredentials(); + finalURL = generateAdminURL(authParams, apiName, params); + token = authParams.getAdminToken(); + } else { + authParams.setRegistryCredentials(request.getName().getProject(), request.getName().getRegistry(), request.getName().getLocation()); + finalURL = generateURL(authParams, apiName, params); + token = authParams.getUserToken(); + } + return delete(finalURL, token); + } + + /** + * Method used to call HTTP delete request + * + * @return String[] containing responseCode, responseMessage and response object + * @throws IOException + * @throws ApplicationException + */ + public String[] delete(String finalURL, String token) { + try { + HttpRequest request = HttpRequest.newBuilder().uri(URI.create(finalURL)).headers(Constants.HTTP_REQUEST_PROPERTY_CONTENT_TYPE_KEY, Constants.HTTP_REQUEST_PROPERTY_CONTENT_TYPE_ACCEPT_VALUE, Constants.HTTP_REQUEST_PROPERTY_TOKEN_KEY, token, Constants.HTTP_REQUEST_PROPERTY_ACCEPT_KEY, Constants.HTTP_REQUEST_PROPERTY_CONTENT_TYPE_ACCEPT_VALUE).DELETE().build(); + + CompletableFuture> response = HttpClient.newBuilder().build().sendAsync(request, HttpResponse.BodyHandlers.ofString()); + + HttpResponse httpResponse = response.get(); + responseArray[0] = String.valueOf(httpResponse.statusCode()); + responseArray[1] = ""; + responseArray[2] = httpResponse.body(); + + } catch (ApplicationException e) { + log.log(Level.SEVERE, e.getMessage()); + } catch (InterruptedException ex) { + log.log(Level.SEVERE, ex.getMessage()); + Thread.currentThread().interrupt(); + } catch (Exception ec) { + log.log(Level.SEVERE, ec.getMessage()); + } + + return responseArray; + + } + + public String[] update(String apiName, String params, String body, UpdateDeviceRegistryRequest request) throws IOException, ParseException { + authParams.setRegistryCredentials(request.getParent().getProject(), request.getParent().getRegistry(), request.getParent().getLocation()); + String finalURL = generateURL(authParams, apiName, params); + String token = authParams.getUserToken(); + return post(finalURL, body, token); + } + + public String[] update(String apiName, String params, String body, UpdateDeviceRequest request) throws IOException, ParseException { + String finalURL = ""; + String token = ""; + authParams.setRegistryCredentials(request.getDeviceName().getProject(), request.getDeviceName().getRegistry(), request.getDeviceName().getLocation()); + finalURL = generateURL(authParams, apiName, params); + token = authParams.getUserToken(); + return update(finalURL, body, token); + } + + /** + * Method used to call HTTP Patch request + * + * @param body + * @return String[] Object containing responseCode, responseMessage and response + * object + */ + public String[] update(String finalURL, String body, String token) { + try { + BodyPublisher jsonPayload = BodyPublishers.ofString(body); + HttpRequest request = HttpRequest.newBuilder().uri(URI.create(finalURL)).method(Constants.HTTP_REQUEST_METHOD_TYPE_PATCH, jsonPayload).headers(Constants.HTTP_REQUEST_PROPERTY_CONTENT_TYPE_KEY, Constants.HTTP_REQUEST_PROPERTY_CONTENT_TYPE_ACCEPT_VALUE, Constants.HTTP_REQUEST_PROPERTY_TOKEN_KEY, token, Constants.HTTP_REQUEST_PROPERTY_ACCEPT_KEY, Constants.HTTP_REQUEST_PROPERTY_CONTENT_TYPE_ACCEPT_VALUE).build(); + + CompletableFuture> response = HttpClient.newBuilder().build().sendAsync(request, HttpResponse.BodyHandlers.ofString()); + + HttpResponse httpResponse = response.get(); + responseArray[0] = String.valueOf(httpResponse.statusCode()); + responseArray[1] = ""; + responseArray[2] = httpResponse.body(); + + } catch (ApplicationException e) { + log.log(Level.SEVERE, e.getMessage()); + } catch (InterruptedException ex) { + log.log(Level.SEVERE, ex.getMessage()); + Thread.currentThread().interrupt(); + } catch (Exception ec) { + log.log(Level.SEVERE, ec.getMessage()); + } + + return responseArray; + } + + // Registry Apis + + public String[] asyncCreateDeviceRegistry(String apiName, String params, String body, boolean isAdmin) throws IOException { + String finalURL = ""; + String token = ""; + if (isAdmin) { + authParams.setAdminCredentials(); + finalURL = generateAdminURL(authParams, apiName, params); + token = authParams.getAdminToken(); + } + return post(finalURL, body, token); + } + + + public String[] asyncDeleteDeviceRegistry(String apiName, String params, boolean isAdmin) throws IOException { + authParams.setAdminCredentials(); + String finalURL = generateAdminURL(authParams, apiName, params); + String token = authParams.getAdminToken(); + return this.delete(finalURL, token); + } + + + public String[] asyncListDeviceRegistries(String apiName, String params, boolean isAdmin) throws IOException { + String finalURL = ""; + String token = ""; + if (isAdmin) { + authParams.setAdminCredentials(); + finalURL = generateAdminURL(authParams, apiName, params); + token = authParams.getAdminToken(); + } + return this.get(finalURL, token); + } } diff --git a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/ClearBladeDeviceManager.java b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/ClearBladeDeviceManager.java index 23d5ce84..3eb4262a 100644 --- a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/ClearBladeDeviceManager.java +++ b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/ClearBladeDeviceManager.java @@ -30,6 +30,7 @@ package com.clearblade.cloud.iot.v1; +import java.io.IOException; import java.util.logging.Level; import java.util.logging.Logger; @@ -56,465 +57,426 @@ import com.clearblade.cloud.iot.v1.unbinddevicefromgateway.UnbindDeviceFromGatewayResponse; import com.clearblade.cloud.iot.v1.updatedevice.UpdateDeviceRequest; import com.clearblade.cloud.iot.v1.utils.ConfigParameters; +import org.json.simple.parser.ParseException; public class ClearBladeDeviceManager { - static Logger log = Logger.getLogger(ClearBladeDeviceManager.class.getName()); - ConfigParameters configParameters = ConfigParameters.getInstance(); + static Logger log = Logger.getLogger(ClearBladeDeviceManager.class.getName()); + ConfigParameters configParameters = ConfigParameters.getInstance(); - public Device getDevice(GetDeviceRequest request) throws ApplicationException { - SyncClient syncClient = new SyncClient(); - String[] responseArray = syncClient.get(configParameters.getDevicesURLExtension(), request.toString(), false); - if (responseArray[0] != null) { - int responseCode = Integer.parseInt(responseArray[0]); - if (responseCode == 200) { - Device device = Device.newBuilder().build(); - device.loadFromString(responseArray[2]); - return device; - } else { - throw new ApplicationException(responseArray[2]); - } - } - return null; - } + public Device getDevice(GetDeviceRequest request) throws ApplicationException { + SyncClient syncClient = new SyncClient(); + String[] responseArray = syncClient.get(configParameters.getDevicesURLExtension(), request); + if (responseArray[0] != null) { + int responseCode = Integer.parseInt(responseArray[0]); + if (responseCode == 200) { + Device device = Device.newBuilder().build(); + device.loadFromString(responseArray[2]); + return device; + } else { + throw new ApplicationException(responseArray[2]); + } + } + return null; + } - public Device asyncGetDevice(GetDeviceRequest request) throws ApplicationException { - try { - AsyncClient asyncClient = new AsyncClient(); - String[] responseArray = asyncClient.get(configParameters.getDevicesURLExtension(), request.toString()); - if (responseArray[0] != null) { - int responseCode = Integer.parseInt(responseArray[0]); - if (responseCode == 200) { - Device device = Device.newBuilder().build(); - device.loadFromString(responseArray[2]); - return device; - } else { - throw new ApplicationException(responseArray[2]); - } - } - } catch (Exception e) { - throw new ApplicationException(e.getMessage(), e); - } - return null; - } + public Device asyncGetDevice(GetDeviceRequest request) throws ApplicationException { + try { + AsyncClient asyncClient = new AsyncClient(); + String[] responseArray = asyncClient.get(configParameters.getDevicesURLExtension(), request); + if (responseArray[0] != null) { + int responseCode = Integer.parseInt(responseArray[0]); + if (responseCode == 200) { + Device device = Device.newBuilder().build(); + device.loadFromString(responseArray[2]); + return device; + } else { + throw new ApplicationException(responseArray[2]); + } + } + } catch (Exception e) { + throw new ApplicationException(e.getMessage(), e); + } + return null; + } - public Device createDevice(CreateDeviceRequest request) throws ApplicationException { - SyncClient syncClient = new SyncClient(); - String[] params = request.getParams(); - String reqParams = params[0]; - String body = params[1]; - String[] responseArray = syncClient.post(configParameters.getDevicesURLExtension(), reqParams, body, false); - if (responseArray[0] != null) { - int responseCode = Integer.parseInt(responseArray[0]); - if (responseCode == 200) { - Device deviceObj = Device.newBuilder().build(); - deviceObj.loadFromString(responseArray[2]); - return deviceObj; - } else { - throw new ApplicationException(responseArray[2]); - } - } else { - throw new ApplicationException(""); - } - } + public Device createDevice(CreateDeviceRequest request) throws ApplicationException { + SyncClient syncClient = new SyncClient(); + String[] params = request.getParams(); + String reqParams = params[0]; + String body = params[1]; + String[] responseArray = syncClient.post(configParameters.getDevicesURLExtension(), reqParams, body, request); + if (responseArray[0] != null) { + int responseCode = Integer.parseInt(responseArray[0]); + if (responseCode == 200) { + Device deviceObj = Device.newBuilder().build(); + deviceObj.loadFromString(responseArray[2]); + return deviceObj; + } else { + throw new ApplicationException(responseArray[2]); + } + } else { + throw new ApplicationException(""); + } + } - public Device asyncCreateDevice(CreateDeviceRequest request) throws ApplicationException { - try { - AsyncClient asyncClient = new AsyncClient(); - String[] params = request.getParams(); - String reqParams = params[0]; - String body = params[1]; - String[] responseArray = asyncClient.post(configParameters.getDevicesURLExtension(), reqParams, body); - if (responseArray[0] != null) { - int responseCode = Integer.parseInt(responseArray[0]); - if (responseCode == 200) { - Device deviceObj = Device.newBuilder().build(); - deviceObj.loadFromString(responseArray[2]); - return deviceObj; - } else { - throw new ApplicationException(responseArray[2]); - } - } - return null; - } catch (Exception e) { - // TODO: handle exception - throw new ApplicationException(e.getMessage(), e); - } - } + public Device asyncCreateDevice(CreateDeviceRequest request) throws ApplicationException { + try { + AsyncClient asyncClient = new AsyncClient(); + String[] params = request.getParams(); + String reqParams = params[0]; + String body = params[1]; + String[] responseArray = asyncClient.post(configParameters.getDevicesURLExtension(), reqParams, body, request); + if (responseArray[0] != null) { + int responseCode = Integer.parseInt(responseArray[0]); + if (responseCode == 200) { + Device deviceObj = Device.newBuilder().build(); + deviceObj.loadFromString(responseArray[2]); + return deviceObj; + } else { + throw new ApplicationException(responseArray[2]); + } + } + return null; + } catch (Exception e) { + // TODO: handle exception + throw new ApplicationException(e.getMessage(), e); + } + } - public void deleteDevice(DeleteDeviceRequest request) throws ApplicationException { - SyncClient syncClient = new SyncClient(); - String[] responseArray = syncClient.delete(configParameters.getDevicesURLExtension(), request.toString(), - false); - if (responseArray[0] != null) { - int responseCode = Integer.parseInt(responseArray[0]); - if (responseCode != 200) { - throw new ApplicationException(responseArray[2]); - } - } else { - throw new ApplicationException(""); - } - } + public void deleteDevice(DeleteDeviceRequest request) throws ApplicationException { + SyncClient syncClient = new SyncClient(); + String[] responseArray = syncClient.delete(configParameters.getDevicesURLExtension(), request.toString(), false, request); + if (responseArray[0] != null) { + int responseCode = Integer.parseInt(responseArray[0]); + if (responseCode != 200) { + throw new ApplicationException(responseArray[2]); + } + } else { + throw new ApplicationException(""); + } + } - public void asyncDeleteDevice(DeleteDeviceRequest request) throws ApplicationException { - try { - AsyncClient asyncClient = new AsyncClient(); - String[] responseArray = asyncClient.delete(configParameters.getDevicesURLExtension(), request.toString()); - if (responseArray[0] != null) { - int responseCode = Integer.parseInt(responseArray[0]); - if (responseCode != 200) { - throw new ApplicationException(responseArray[2]); - } - } else { - throw new ApplicationException(""); - } - } catch (Exception e) { - log.log(Level.SEVERE, e.getMessage()); - throw new ApplicationException(e.getMessage(), e); - } - } + public void asyncDeleteDevice(DeleteDeviceRequest request) throws ApplicationException { + try { + AsyncClient asyncClient = new AsyncClient(); + String[] responseArray = asyncClient.delete(configParameters.getDevicesURLExtension(), request.toString(), request); + if (responseArray[0] != null) { + int responseCode = Integer.parseInt(responseArray[0]); + if (responseCode != 200) { + throw new ApplicationException(responseArray[2]); + } + } else { + throw new ApplicationException(""); + } + } catch (Exception e) { + log.log(Level.SEVERE, e.getMessage()); + throw new ApplicationException(e.getMessage(), e); + } + } - public Device updateDevice(UpdateDeviceRequest request) throws ApplicationException { - try { - SyncClient syncClient = new SyncClient(); - String[] params = request.getBodyAndParams(); - String reqParams = params[0]; - String body = params[1]; - String[] responseArray; - responseArray = syncClient.update(configParameters.getDevicesURLExtension(), reqParams, body); - if (responseArray[0] != null) { - int responseCode = Integer.parseInt(responseArray[0]); - if (responseCode == 200) { - Device deviceObj = Device.newBuilder().build(); - deviceObj.loadFromString(responseArray[2]); - return deviceObj; - } else { - throw new ApplicationException(responseArray[2]); - } - } else { - throw new ApplicationException(); - } - } catch (InterruptedException e) { - log.log(Level.SEVERE, e.getMessage()); - Thread.currentThread().interrupt(); - throw new ApplicationException(e.getMessage(), e); - } - } + public Device updateDevice(UpdateDeviceRequest request) throws ApplicationException { + try { + SyncClient syncClient = new SyncClient(); + String[] params = request.getBodyAndParams(); + String reqParams = params[0]; + String body = params[1]; + String[] responseArray; + responseArray = syncClient.update(configParameters.getDevicesURLExtension(), reqParams, body, request); + if (responseArray[0] != null) { + int responseCode = Integer.parseInt(responseArray[0]); + if (responseCode == 200) { + Device deviceObj = Device.newBuilder().build(); + deviceObj.loadFromString(responseArray[2]); + return deviceObj; + } else { + throw new ApplicationException(responseArray[2]); + } + } else { + throw new ApplicationException(); + } + } catch (Exception e) { + log.log(Level.SEVERE, e.getMessage()); + Thread.currentThread().interrupt(); + throw new ApplicationException(e.getMessage(), e); + } + } - public Device asyncUpdateDevice(UpdateDeviceRequest request) throws ApplicationException { - try { - AsyncClient asyncClient = new AsyncClient(); - String[] params = request.getBodyAndParams(); - String reqParams = params[0]; - String body = params[1]; - String[] responseArray = asyncClient.update(configParameters.getDevicesURLExtension(), reqParams, body); - if (responseArray[0] != null) { - int responseCode = Integer.parseInt(responseArray[0]); - if (responseCode == 200) { - Device deviceObj = Device.newBuilder().build(); - deviceObj.loadFromString(responseArray[2]); - return deviceObj; - } else { - throw new ApplicationException(responseArray[2]); - } - } else { - throw new ApplicationException(responseArray[2]); - } - } catch (Exception e) { - throw new ApplicationException(e.getMessage(), e); - } - } + public Device asyncUpdateDevice(UpdateDeviceRequest request) throws ApplicationException { + try { + AsyncClient asyncClient = new AsyncClient(); + String[] params = request.getBodyAndParams(); + String reqParams = params[0]; + String body = params[1]; + String[] responseArray = asyncClient.update(configParameters.getDevicesURLExtension(), reqParams, body, request); + if (responseArray[0] != null) { + int responseCode = Integer.parseInt(responseArray[0]); + if (responseCode == 200) { + Device deviceObj = Device.newBuilder().build(); + deviceObj.loadFromString(responseArray[2]); + return deviceObj; + } else { + throw new ApplicationException(responseArray[2]); + } + } else { + throw new ApplicationException(responseArray[2]); + } + } catch (Exception e) { + throw new ApplicationException(e.getMessage(), e); + } + } - public BindDeviceToGatewayResponse bindDeviceToGateway(BindDeviceToGatewayRequest request) - throws ApplicationException { - SyncClient syncClient = new SyncClient(); - String[] paramBody = request.getBodyAndParams(); - String[] responseArray = syncClient.post(configParameters.getCloudiotURLExtension(), paramBody[0], paramBody[1], - false); - BindDeviceToGatewayResponse response = BindDeviceToGatewayResponse.Builder.newBuilder().build(); - if (responseArray[0] != null) { - int responseCode = Integer.parseInt(responseArray[0]); - if (responseCode == 200) { - response.setHttpStatusCode(Integer.parseInt(responseArray[0])); - response.setHttpStatusResponse(responseArray[1]); - } else { - throw new ApplicationException(responseArray[2]); - } - } - return response; - } + public BindDeviceToGatewayResponse bindDeviceToGateway(BindDeviceToGatewayRequest request) throws ApplicationException { + SyncClient syncClient = new SyncClient(); + String[] paramBody = request.getBodyAndParams(); + String[] responseArray = syncClient.post(configParameters.getCloudiotURLExtension(), paramBody[0], paramBody[1], request); + BindDeviceToGatewayResponse response = BindDeviceToGatewayResponse.Builder.newBuilder().build(); + if (responseArray[0] != null) { + int responseCode = Integer.parseInt(responseArray[0]); + if (responseCode == 200) { + response.setHttpStatusCode(Integer.parseInt(responseArray[0])); + response.setHttpStatusResponse(responseArray[1]); + } else { + throw new ApplicationException(responseArray[2]); + } + } + return response; + } - public BindDeviceToGatewayResponse asyncBindDeviceToGateway(BindDeviceToGatewayRequest request) - throws ApplicationException { - try { - AsyncClient asyncClient = new AsyncClient(); - String[] paramBody = request.getBodyAndParams(); - String[] responseArray = asyncClient.post(configParameters.getCloudiotURLExtension(), paramBody[0], - paramBody[1]); - BindDeviceToGatewayResponse response = BindDeviceToGatewayResponse.Builder.newBuilder().build(); - if (responseArray[0] != null) { - int responseCode = Integer.parseInt(responseArray[0]); - if (responseCode == 200) { - response.setHttpStatusCode(Integer.parseInt(responseArray[0])); - response.setHttpStatusResponse(responseArray[1]); - } else { - throw new ApplicationException(responseArray[2]); - } - } - return response; - } catch (Exception e) { - log.log(Level.SEVERE, e.getMessage()); - } - return null; - } + public BindDeviceToGatewayResponse asyncBindDeviceToGateway(BindDeviceToGatewayRequest request) throws ApplicationException { + try { + AsyncClient asyncClient = new AsyncClient(); + String[] paramBody = request.getBodyAndParams(); + String[] responseArray = asyncClient.post(configParameters.getCloudiotURLExtension(), paramBody[0], paramBody[1], request); + BindDeviceToGatewayResponse response = BindDeviceToGatewayResponse.Builder.newBuilder().build(); + if (responseArray[0] != null) { + int responseCode = Integer.parseInt(responseArray[0]); + if (responseCode == 200) { + response.setHttpStatusCode(Integer.parseInt(responseArray[0])); + response.setHttpStatusResponse(responseArray[1]); + } else { + throw new ApplicationException(responseArray[2]); + } + } + return response; + } catch (Exception e) { + log.log(Level.SEVERE, e.getMessage()); + } + return null; + } - public UnbindDeviceFromGatewayResponse unbindDeviceFromGateway(UnbindDeviceFromGatewayRequest request) - throws ApplicationException { - SyncClient syncClinet = new SyncClient(); - String[] paramBody = request.getBodyAndParams(); - String[] responseArray = syncClinet.post(configParameters.getCloudiotURLExtension(), paramBody[0], paramBody[1], - false); - UnbindDeviceFromGatewayResponse response = UnbindDeviceFromGatewayResponse.Builder.newBuilder().build(); - if (responseArray[0] != null) { - int responseCode = Integer.parseInt(responseArray[0]); - if (responseCode == 200) { - response.setHttpStatusCode(Integer.parseInt(responseArray[0])); - response.setHttpStatusResponse(responseArray[1]); - } else { - throw new ApplicationException(responseArray[2]); - } - } - return response; - } + public UnbindDeviceFromGatewayResponse unbindDeviceFromGateway(UnbindDeviceFromGatewayRequest request) throws ApplicationException { + SyncClient syncClinet = new SyncClient(); + String[] paramBody = request.getBodyAndParams(); + String[] responseArray = syncClinet.post(configParameters.getCloudiotURLExtension(), paramBody[0], paramBody[1], request); + UnbindDeviceFromGatewayResponse response = UnbindDeviceFromGatewayResponse.Builder.newBuilder().build(); + if (responseArray[0] != null) { + int responseCode = Integer.parseInt(responseArray[0]); + if (responseCode == 200) { + response.setHttpStatusCode(Integer.parseInt(responseArray[0])); + response.setHttpStatusResponse(responseArray[1]); + } else { + throw new ApplicationException(responseArray[2]); + } + } + return response; + } - public UnbindDeviceFromGatewayResponse asyncUnbindDeviceFromGateway(UnbindDeviceFromGatewayRequest request) - throws ApplicationException { - try { - AsyncClient asyncClinet = new AsyncClient(); - String[] paramBody = request.getBodyAndParams(); - String[] responseArray = asyncClinet.post(configParameters.getCloudiotURLExtension(), paramBody[0], - paramBody[1]); - UnbindDeviceFromGatewayResponse response = UnbindDeviceFromGatewayResponse.Builder.newBuilder().build(); - if (responseArray[0] != null) { - int responseCode = Integer.parseInt(responseArray[0]); - if (responseCode == 200) { - response.setHttpStatusCode(Integer.parseInt(responseArray[0])); - response.setHttpStatusResponse(responseArray[1]); - } else { - throw new ApplicationException(responseArray[2]); - } - } - return response; - } catch (Exception e) { - throw new ApplicationException(e.getMessage(), e); - } - } + public UnbindDeviceFromGatewayResponse asyncUnbindDeviceFromGateway(UnbindDeviceFromGatewayRequest request) throws ApplicationException { + try { + AsyncClient asyncClinet = new AsyncClient(); + String[] paramBody = request.getBodyAndParams(); + String[] responseArray = asyncClinet.post(configParameters.getCloudiotURLExtension(), paramBody[0], paramBody[1], request); + UnbindDeviceFromGatewayResponse response = UnbindDeviceFromGatewayResponse.Builder.newBuilder().build(); + if (responseArray[0] != null) { + int responseCode = Integer.parseInt(responseArray[0]); + if (responseCode == 200) { + response.setHttpStatusCode(Integer.parseInt(responseArray[0])); + response.setHttpStatusResponse(responseArray[1]); + } else { + throw new ApplicationException(responseArray[2]); + } + } + return response; + } catch (Exception e) { + throw new ApplicationException(e.getMessage(), e); + } + } - public SendCommandToDeviceResponse sendCommandToDevice(SendCommandToDeviceRequest request) - throws ApplicationException { - SyncClient syncClient = new SyncClient(); - String[] paramBody = request.getBodyAndParams(); - String[] responseArray = syncClient.post(configParameters.getDevicesURLExtension(), paramBody[0], paramBody[1], - false); - SendCommandToDeviceResponse response = SendCommandToDeviceResponse.Builder.newBuilder().build(); - if (responseArray[0] != null) { - int responseCode = Integer.parseInt(responseArray[0]); - if (responseCode == 200 || responseCode == 204) { - response.setHttpStatusCode(Integer.parseInt(responseArray[0])); - response.setHttpStatusResponse(responseArray[1]); - } else { - throw new ApplicationException(responseArray[2]); - } - } - return response; - } + public SendCommandToDeviceResponse sendCommandToDevice(SendCommandToDeviceRequest request) throws ApplicationException { + SyncClient syncClient = new SyncClient(); + String[] paramBody = request.getBodyAndParams(); + String[] responseArray = syncClient.post(configParameters.getDevicesURLExtension(), paramBody[0], paramBody[1], request); + SendCommandToDeviceResponse response = SendCommandToDeviceResponse.Builder.newBuilder().build(); + if (responseArray[0] != null) { + int responseCode = Integer.parseInt(responseArray[0]); + if (responseCode == 200 || responseCode == 204) { + response.setHttpStatusCode(Integer.parseInt(responseArray[0])); + response.setHttpStatusResponse(responseArray[1]); + } else { + throw new ApplicationException(responseArray[2]); + } + } + return response; + } - public SendCommandToDeviceResponse asyncSendCommandToDevice(SendCommandToDeviceRequest request) - throws ApplicationException { - try { - AsyncClient asyncClient = new AsyncClient(); - String[] paramBody = request.getBodyAndParams(); - String[] responseArray = asyncClient.post(configParameters.getDevicesURLExtension(), paramBody[0], - paramBody[1]); - SendCommandToDeviceResponse response = SendCommandToDeviceResponse.Builder.newBuilder().build(); - if (responseArray[0] != null) { - int responseCode = Integer.parseInt(responseArray[0]); - if (responseCode == 200 || responseCode == 204) { - response.setHttpStatusCode(Integer.parseInt(responseArray[0])); - response.setHttpStatusResponse(responseArray[1]); - } else { - throw new ApplicationException(responseArray[2]); - } - } - return response; - } catch (Exception e) { - throw new ApplicationException(e.getMessage(), e); - } - } + public SendCommandToDeviceResponse asyncSendCommandToDevice(SendCommandToDeviceRequest request) throws ApplicationException { + try { + AsyncClient asyncClient = new AsyncClient(); + String[] paramBody = request.getBodyAndParams(); + String[] responseArray = asyncClient.post(configParameters.getDevicesURLExtension(), paramBody[0], paramBody[1], request); + SendCommandToDeviceResponse response = SendCommandToDeviceResponse.Builder.newBuilder().build(); + if (responseArray[0] != null) { + int responseCode = Integer.parseInt(responseArray[0]); + if (responseCode == 200 || responseCode == 204) { + response.setHttpStatusCode(Integer.parseInt(responseArray[0])); + response.setHttpStatusResponse(responseArray[1]); + } else { + throw new ApplicationException(responseArray[2]); + } + } + return response; + } catch (Exception e) { + throw new ApplicationException(e.getMessage(), e); + } + } - public DevicesListResponse listDevices(DevicesListRequest request) throws ApplicationException { - SyncClient syncClient = new SyncClient(); - String[] responseArray = syncClient.get(configParameters.getDevicesURLExtension(), request.getParamsForList(), - false); - if (responseArray[0] != null) { - int responseCode = Integer.parseInt(responseArray[0]); - if (responseCode == 200) { - return DevicesListResponse.Builder.newBuilder().buildResponse(responseArray[2]).build(); - } else { - throw new ApplicationException(responseArray[2]); - } - } - return null; - } + public DevicesListResponse listDevices(DevicesListRequest request) throws ApplicationException { + SyncClient syncClient = new SyncClient(); + String[] responseArray = syncClient.get(configParameters.getDevicesURLExtension(), request.getParamsForList(), request); + if (responseArray[0] != null) { + int responseCode = Integer.parseInt(responseArray[0]); + if (responseCode == 200) { + return DevicesListResponse.Builder.newBuilder().buildResponse(responseArray[2]).build(); + } else { + throw new ApplicationException(responseArray[2]); + } + } + return null; + } - public DevicesListResponse asyncListDevices(DevicesListRequest request) throws ApplicationException { - try { - AsyncClient asyncClient = new AsyncClient(); - String[] responseArray = asyncClient.get(configParameters.getDevicesURLExtension(), - request.getParamsForList()); - if (responseArray[0] != null) { - int responseCode = Integer.parseInt(responseArray[0]); - if (responseCode == 200) { - return DevicesListResponse.Builder.newBuilder().buildResponse(responseArray[2]).build(); - } else { - throw new ApplicationException(responseArray[2]); - } - } - } catch (Exception e) { - throw new ApplicationException(e.getMessage(), e); - } - return null; - } + public DevicesListResponse asyncListDevices(DevicesListRequest request) throws ApplicationException { + try { + AsyncClient asyncClient = new AsyncClient(); + String[] responseArray = asyncClient.get(configParameters.getDevicesURLExtension(), request.getParamsForList(), request); + if (responseArray[0] != null) { + int responseCode = Integer.parseInt(responseArray[0]); + if (responseCode == 200) { + return DevicesListResponse.Builder.newBuilder().buildResponse(responseArray[2]).build(); + } else { + throw new ApplicationException(responseArray[2]); + } + } + } catch (Exception e) { + throw new ApplicationException(e.getMessage(), e); + } + return null; + } - public DeviceConfig modifyCloudToDeviceConfig(ModifyCloudToDeviceConfigRequest request) - throws ApplicationException { - SyncClient syncClient = new SyncClient(); - String[] paramBody = request.getBodyAndParams(); - String[] responseArray = syncClient.post(configParameters.getDevicesURLExtension(), paramBody[0], paramBody[1], - false); - DeviceConfig deviceConfig = DeviceConfig.newBuilder().build(); - if (responseArray[0] != null) { - if (Integer.parseInt(responseArray[0]) == 200) - deviceConfig.loadFromString(responseArray[2]); - else - throw new ApplicationException(responseArray[2]); - } - return deviceConfig; - } + public DeviceConfig modifyCloudToDeviceConfig(ModifyCloudToDeviceConfigRequest request) throws ApplicationException { + SyncClient syncClient = new SyncClient(); + String[] paramBody = request.getBodyAndParams(); + String[] responseArray = syncClient.post(configParameters.getDevicesURLExtension(), paramBody[0], paramBody[1], request); + DeviceConfig deviceConfig = DeviceConfig.newBuilder().build(); + if (responseArray[0] != null) { + if (Integer.parseInt(responseArray[0]) == 200) deviceConfig.loadFromString(responseArray[2]); + else throw new ApplicationException(responseArray[2]); + } + return deviceConfig; + } - public DeviceConfig asyncModifyCloudToDeviceConfig(ModifyCloudToDeviceConfigRequest request) - throws ApplicationException { - try { - AsyncClient asyncClient = new AsyncClient(); - String[] paramBody = request.getBodyAndParams(); - String[] responseArray = asyncClient.post(configParameters.getDevicesURLExtension(), paramBody[0], - paramBody[1]); - DeviceConfig deviceConfig = DeviceConfig.newBuilder().build(); - if (responseArray[0] != null) { - if (Integer.parseInt(responseArray[0]) == 200) - deviceConfig.loadFromString(responseArray[2]); - else - throw new ApplicationException(responseArray[2]); - } - return deviceConfig; - } catch (Exception e) { - throw new ApplicationException(e.getMessage(), e); - } - } + public DeviceConfig asyncModifyCloudToDeviceConfig(ModifyCloudToDeviceConfigRequest request) throws ApplicationException { + try { + AsyncClient asyncClient = new AsyncClient(); + String[] paramBody = request.getBodyAndParams(); + String[] responseArray = asyncClient.post(configParameters.getDevicesURLExtension(), paramBody[0], paramBody[1], request); + DeviceConfig deviceConfig = DeviceConfig.newBuilder().build(); + if (responseArray[0] != null) { + if (Integer.parseInt(responseArray[0]) == 200) deviceConfig.loadFromString(responseArray[2]); + else throw new ApplicationException(responseArray[2]); + } + return deviceConfig; + } catch (Exception e) { + throw new ApplicationException(e.getMessage(), e); + } + } - public ListDeviceStatesResponse listDeviceStates(ListDeviceStatesRequest request) throws ApplicationException { - SyncClient syncClient = new SyncClient(); - String[] responseArray = syncClient.get(configParameters.getDevicesStatesURLExtension(), - request.getParamsForList(), false); - if (responseArray[0] != null) { - int responseCode = Integer.parseInt(responseArray[0]); - if (responseCode == 200) { - return ListDeviceStatesResponse.Builder.newBuilder().buildResponse(responseArray[2]).build(); - } else - throw new ApplicationException(responseArray[2]); - } - return null; - } + public ListDeviceStatesResponse listDeviceStates(ListDeviceStatesRequest request) throws ApplicationException { + SyncClient syncClient = new SyncClient(); + String[] responseArray = syncClient.get(configParameters.getDevicesStatesURLExtension(), request.getParamsForList(), request); + if (responseArray[0] != null) { + int responseCode = Integer.parseInt(responseArray[0]); + if (responseCode == 200) { + return ListDeviceStatesResponse.Builder.newBuilder().buildResponse(responseArray[2]).build(); + } else throw new ApplicationException(responseArray[2]); + } + return null; + } - public ListDeviceStatesResponse asyncListDeviceStates(ListDeviceStatesRequest request) throws ApplicationException { - try { - AsyncClient asyncClient = new AsyncClient(); - String[] responseArray = asyncClient.get(configParameters.getDevicesStatesURLExtension(), - request.getParamsForList()); - if (responseArray[0] != null) { - int responseCode = Integer.parseInt(responseArray[0]); - if (responseCode == 200) { - return ListDeviceStatesResponse.Builder.newBuilder().buildResponse(responseArray[2]).build(); - } else - throw new ApplicationException(responseArray[2]); - } - } catch (Exception e) { - throw new ApplicationException(e.getMessage(), e); - } - return null; - } + public ListDeviceStatesResponse asyncListDeviceStates(ListDeviceStatesRequest request) throws ApplicationException { + try { + AsyncClient asyncClient = new AsyncClient(); + String[] responseArray = asyncClient.get(configParameters.getDevicesStatesURLExtension(), request.getParamsForList(), request); + if (responseArray[0] != null) { + int responseCode = Integer.parseInt(responseArray[0]); + if (responseCode == 200) { + return ListDeviceStatesResponse.Builder.newBuilder().buildResponse(responseArray[2]).build(); + } else throw new ApplicationException(responseArray[2]); + } + } catch (Exception e) { + throw new ApplicationException(e.getMessage(), e); + } + return null; + } - public ListDeviceConfigVersionsResponse listDeviceConfigVersions(ListDeviceConfigVersionsRequest request) - throws ApplicationException { - SyncClient syncClient = new SyncClient(); - String[] responseArray = syncClient.get(configParameters.getCloudiotConfigURLExtension(), - request.getParamsForList(), false); - if (responseArray[0] != null) { - int responseCode = Integer.parseInt(responseArray[0]); - if (responseCode == 200) { - return ListDeviceConfigVersionsResponse.Builder.newBuilder().buildResponse(responseArray[2]).build(); - } else - throw new ApplicationException(responseArray[2]); - } - return null; - } + public ListDeviceConfigVersionsResponse listDeviceConfigVersions(ListDeviceConfigVersionsRequest request) throws ApplicationException { + SyncClient syncClient = new SyncClient(); + String[] responseArray = syncClient.get(configParameters.getCloudiotConfigURLExtension(), request.getParamsForList(), request); + if (responseArray[0] != null) { + int responseCode = Integer.parseInt(responseArray[0]); + if (responseCode == 200) { + return ListDeviceConfigVersionsResponse.Builder.newBuilder().buildResponse(responseArray[2]).build(); + } else throw new ApplicationException(responseArray[2]); + } + return null; + } - public ListDeviceConfigVersionsResponse asyncListDeviceConfigVersions(ListDeviceConfigVersionsRequest request) - throws ApplicationException { - try { - AsyncClient asyncClient = new AsyncClient(); - String[] responseArray = asyncClient.get(configParameters.getCloudiotConfigURLExtension(), - request.getParamsForList()); - if (responseArray[0] != null) { - int responseCode = Integer.parseInt(responseArray[0]); - if (responseCode == 200) { - return ListDeviceConfigVersionsResponse.Builder.newBuilder().buildResponse(responseArray[2]) - .build(); - } else - throw new ApplicationException(responseArray[2]); - } - } catch (Exception e) { - throw new ApplicationException(e.getMessage(), e); - } - return null; - } + public ListDeviceConfigVersionsResponse asyncListDeviceConfigVersions(ListDeviceConfigVersionsRequest request) throws ApplicationException { + try { + AsyncClient asyncClient = new AsyncClient(); + String[] responseArray = asyncClient.get(configParameters.getCloudiotConfigURLExtension(), request.getParamsForList(), request); + if (responseArray[0] != null) { + int responseCode = Integer.parseInt(responseArray[0]); + if (responseCode == 200) { + return ListDeviceConfigVersionsResponse.Builder.newBuilder().buildResponse(responseArray[2]).build(); + } else throw new ApplicationException(responseArray[2]); + } + } catch (Exception e) { + throw new ApplicationException(e.getMessage(), e); + } + return null; + } - public ListDeviceRegistriesResponse listDeviceRegistries(ListDeviceRegistriesRequest request) - throws ApplicationException { - SyncClient syncClient = new SyncClient(); - String[] responseArray = syncClient.get(configParameters.getCloudiotURLExtension(), request.getParamsForList(), - true); - if (responseArray[0] != null) { - int responseCode = Integer.parseInt(responseArray[0]); - if (responseCode == 200) { - return ListDeviceRegistriesResponse.Builder.newBuilder().buildResponse(responseArray[2]).build(); - } else - throw new ApplicationException(responseArray[2]); - } - return null; - } + public ListDeviceRegistriesResponse listDeviceRegistries(ListDeviceRegistriesRequest request) throws ApplicationException { + SyncClient syncClient = new SyncClient(); + String[] responseArray = syncClient.get(configParameters.getCloudiotURLExtension(), request.getParamsForList(), true); + if (responseArray[0] != null) { + int responseCode = Integer.parseInt(responseArray[0]); + if (responseCode == 200) { + return ListDeviceRegistriesResponse.Builder.newBuilder().buildResponse(responseArray[2]).build(); + } else throw new ApplicationException(responseArray[2]); + } + return null; + } - public ListDeviceRegistriesResponse asyncListDeviceRegistries(ListDeviceRegistriesRequest request) - throws ApplicationException { - AsyncClient asyncClient = new AsyncClient(); - String[] responseArray = asyncClient.asyncListDeviceRegistries(configParameters.getCloudiotURLExtension(), - request.getParamsForList(), true); - if (responseArray[0] != null) { - int responseCode = Integer.parseInt(responseArray[0]); - if (responseCode == 200) { - return ListDeviceRegistriesResponse.Builder.newBuilder().buildResponse(responseArray[2]).build(); - } else - throw new ApplicationException(responseArray[2]); - } - return null; - } + public ListDeviceRegistriesResponse asyncListDeviceRegistries(ListDeviceRegistriesRequest request) throws ApplicationException, IOException { + AsyncClient asyncClient = new AsyncClient(); + String[] responseArray = asyncClient.asyncListDeviceRegistries(configParameters.getCloudiotURLExtension(), request.getParamsForList(), true); + if (responseArray[0] != null) { + int responseCode = Integer.parseInt(responseArray[0]); + if (responseCode == 200) { + return ListDeviceRegistriesResponse.Builder.newBuilder().buildResponse(responseArray[2]).build(); + } else throw new ApplicationException(responseArray[2]); + } + return null; + } } diff --git a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/ClearBladeRegistryManager.java b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/ClearBladeRegistryManager.java index ce4d6b22..d192ec20 100644 --- a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/ClearBladeRegistryManager.java +++ b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/ClearBladeRegistryManager.java @@ -30,6 +30,7 @@ package com.clearblade.cloud.iot.v1; +import java.io.IOException; import java.util.logging.Level; import java.util.logging.Logger; @@ -42,170 +43,170 @@ import com.clearblade.cloud.iot.v1.utils.ConfigParameters; public class ClearBladeRegistryManager { - static Logger log = Logger.getLogger(ClearBladeRegistryManager.class.getName()); - ConfigParameters configParameters = ConfigParameters.getInstance(); - - public DeviceRegistry getRegistry(GetDeviceRegistryRequest request) throws ApplicationException { - SyncClient syncClient = new SyncClient(); - String[] responseArray = syncClient.get(configParameters.getCloudiotURLExtension(), request.toString(), false); - if (responseArray[0] != null) { - int responseCode = Integer.parseInt(responseArray[0]); - if (responseCode == 200) { - DeviceRegistry deviceRegistry = DeviceRegistry.newBuilder().build(); - deviceRegistry.loadFromString(responseArray[2]); - return deviceRegistry; - } else { - throw new ApplicationException(responseArray[2]); - } - } - return null; - } - - public DeviceRegistry asyncGetDeviceRegistry(GetDeviceRegistryRequest request) throws ApplicationException { - try { - AsyncClient asyncClient = new AsyncClient(); - String[] responseArray = asyncClient.get(configParameters.getCloudiotURLExtension(), request.toString()); - if (responseArray[0] != null) { - int responseCode = Integer.parseInt(responseArray[0]); - if (responseCode == 200) { - DeviceRegistry deviceRegistry = DeviceRegistry.newBuilder().build(); - deviceRegistry.loadFromString(responseArray[2]); - return deviceRegistry; - } else { - throw new ApplicationException(responseArray[2]); - } - } - } catch (Exception e) { - throw new ApplicationException(e.getMessage(), e); - } - return null; - } - - public DeviceRegistry createDeviceRegistry(CreateDeviceRegistryRequest request) throws ApplicationException { - SyncClient syncClient = new SyncClient(); - String[] bodyParams = request.getBodyAndParams(); - - String[] responseArray = syncClient.post(configParameters.getCloudiotURLExtension(), bodyParams[0], - bodyParams[1], true); - if (responseArray[0] != null) { - int responseCode = Integer.parseInt(responseArray[0]); - if (responseCode == 200) { - DeviceRegistry deviceRegistry = DeviceRegistry.newBuilder().build(); - deviceRegistry.loadFromString(responseArray[2]); - return deviceRegistry; - } else { - throw new ApplicationException(responseArray[2]); - } - } - return null; - } - - public DeviceRegistry asyncCreateDeviceRegistry(CreateDeviceRegistryRequest request) throws ApplicationException { - try { - AsyncClient asyncClient = new AsyncClient(); - String[] bodyParams = request.getBodyAndParams(); - - String[] responseArray = asyncClient.asyncCreateDeviceRegistry(configParameters.getCloudiotURLExtension(), - bodyParams[0], bodyParams[1], true); - if (responseArray[0] != null) { - int responseCode = Integer.parseInt(responseArray[0]); - if (responseCode == 200) { - DeviceRegistry deviceRegistry = DeviceRegistry.newBuilder().build(); - deviceRegistry.loadFromString(responseArray[2]); - return deviceRegistry; - } else { - throw new ApplicationException(responseArray[2]); - } - } - } catch (Exception e) { - throw new ApplicationException(e.getMessage(), e); - } - return null; - } - - public DeviceRegistry updateDeviceRegistry(UpdateDeviceRegistryRequest request) throws ApplicationException { - try { - SyncClient syncClient = new SyncClient(); - String[] bodyParams = request.getBodyAndParams(); - - String[] responseArray = syncClient.update(configParameters.getCloudiotURLExtension(), bodyParams[0], - bodyParams[1]); - if (responseArray[0] != null) { - int responseCode = Integer.parseInt(responseArray[0]); - if (responseCode == 200) { - DeviceRegistry deviceRegistry = DeviceRegistry.newBuilder().build(); - deviceRegistry.loadFromString(responseArray[2]); - return deviceRegistry; - } else { - throw new ApplicationException(responseArray[2]); - } - } - } catch (InterruptedException e) { - Thread.currentThread().interrupt(); - throw new ApplicationException(e.getMessage(), e); - } - return null; - } - - public DeviceRegistry asyncUpdateDeviceRegistry(UpdateDeviceRegistryRequest request) throws ApplicationException { - try { - AsyncClient asyncClient = new AsyncClient(); - String[] bodyParams = request.getBodyAndParams(); - - String[] responseArray = asyncClient.update(configParameters.getCloudiotURLExtension(), bodyParams[0], - bodyParams[1]); - if (responseArray[0] != null) { - int responseCode = Integer.parseInt(responseArray[0]); - if (responseCode == 200) { - DeviceRegistry deviceRegistry = DeviceRegistry.newBuilder().build(); - deviceRegistry.loadFromString(responseArray[2]); - return deviceRegistry; - } else { - throw new ApplicationException(responseArray[2]); - } - } - } catch (Exception e) { - throw new ApplicationException(e.getMessage(), e); - } - return null; - } - - public void deleteDeviceRegistry(DeleteDeviceRegistryRequest request) throws ApplicationException { - SyncClient syncClient = new SyncClient(); - String bodyParams = request.getParams(); - - String[] responseArray = syncClient.delete(configParameters.getCloudiotURLExtension(), bodyParams, true); - if (responseArray[0] != null) { - int responseCode = Integer.parseInt(responseArray[0]); - if (responseCode == 200 || responseCode == 204) { - log.log(Level.INFO, - () -> "Response code " + responseArray[0] + " received with message" + responseArray[2]); - } else { - throw new ApplicationException(responseArray[2]); - } - } - - } - - public void asyncDeleteDeviceRegistry(DeleteDeviceRegistryRequest request) throws ApplicationException { - try { - AsyncClient asyncClient = new AsyncClient(); - String bodyParams = request.getParams(); - - String[] responseArray = asyncClient.asyncDeleteDeviceRegistry(configParameters.getCloudiotURLExtension(), - bodyParams, true); - if (responseArray[0] != null) { - int responseCode = Integer.parseInt(responseArray[0]); - if (responseCode == 200 || responseCode == 204) { - System.out.println("DeleteDeviceRegistry execution successful"); - } else { - throw new ApplicationException(responseArray[2]); - } - } else { - System.out.println("DeleteDeviceRegistry execution failed"); - } - } catch (Exception e) { - throw new ApplicationException(e.getMessage(), e); - } - } + static Logger log = Logger.getLogger(ClearBladeRegistryManager.class.getName()); + ConfigParameters configParameters = ConfigParameters.getInstance(); + + public DeviceRegistry getRegistry(GetDeviceRegistryRequest request) throws ApplicationException { + SyncClient syncClient = new SyncClient(); + String[] responseArray = syncClient.get(configParameters.getCloudiotURLExtension(), request.toString(), request); + if (responseArray[0] != null) { + int responseCode = Integer.parseInt(responseArray[0]); + if (responseCode == 200) { + DeviceRegistry deviceRegistry = DeviceRegistry.newBuilder().build(); + deviceRegistry.loadFromString(responseArray[2]); + return deviceRegistry; + } else { + throw new ApplicationException(responseArray[2]); + } + } + return null; + } + + public DeviceRegistry asyncGetDeviceRegistry(GetDeviceRegistryRequest request) throws ApplicationException { + try { + AsyncClient asyncClient = new AsyncClient(); + String[] responseArray = asyncClient.get(configParameters.getCloudiotURLExtension(), request.toString(), request); + if (responseArray[0] != null) { + int responseCode = Integer.parseInt(responseArray[0]); + if (responseCode == 200) { + DeviceRegistry deviceRegistry = DeviceRegistry.newBuilder().build(); + deviceRegistry.loadFromString(responseArray[2]); + return deviceRegistry; + } else { + throw new ApplicationException(responseArray[2]); + } + } + } catch (Exception e) { + throw new ApplicationException(e.getMessage(), e); + } + return null; + } + + public DeviceRegistry createDeviceRegistry(CreateDeviceRegistryRequest request) throws ApplicationException { + SyncClient syncClient = new SyncClient(); + String[] bodyParams = request.getBodyAndParams(); + + String[] responseArray = syncClient.post(configParameters.getCloudiotURLExtension(), bodyParams[0], + bodyParams[1], true, request); + if (responseArray[0] != null) { + int responseCode = Integer.parseInt(responseArray[0]); + if (responseCode == 200) { + DeviceRegistry deviceRegistry = DeviceRegistry.newBuilder().build(); + deviceRegistry.loadFromString(responseArray[2]); + return deviceRegistry; + } else { + throw new ApplicationException(responseArray[2]); + } + } + return null; + } + + public DeviceRegistry asyncCreateDeviceRegistry(CreateDeviceRegistryRequest request) throws ApplicationException { + try { + AsyncClient asyncClient = new AsyncClient(); + String[] bodyParams = request.getBodyAndParams(); + + String[] responseArray = asyncClient.asyncCreateDeviceRegistry(configParameters.getCloudiotURLExtension(), + bodyParams[0], bodyParams[1], true); + if (responseArray[0] != null) { + int responseCode = Integer.parseInt(responseArray[0]); + if (responseCode == 200) { + DeviceRegistry deviceRegistry = DeviceRegistry.newBuilder().build(); + deviceRegistry.loadFromString(responseArray[2]); + return deviceRegistry; + } else { + throw new ApplicationException(responseArray[2]); + } + } + } catch (Exception e) { + throw new ApplicationException(e.getMessage(), e); + } + return null; + } + + public DeviceRegistry updateDeviceRegistry(UpdateDeviceRegistryRequest request) throws ApplicationException { + try { + SyncClient syncClient = new SyncClient(); + String[] bodyParams = request.getBodyAndParams(); + + String[] responseArray = syncClient.update(configParameters.getCloudiotURLExtension(), bodyParams[0], + bodyParams[1], request); + if (responseArray[0] != null) { + int responseCode = Integer.parseInt(responseArray[0]); + if (responseCode == 200) { + DeviceRegistry deviceRegistry = DeviceRegistry.newBuilder().build(); + deviceRegistry.loadFromString(responseArray[2]); + return deviceRegistry; + } else { + throw new ApplicationException(responseArray[2]); + } + } + } catch (Exception e) { + Thread.currentThread().interrupt(); + throw new ApplicationException(e.getMessage(), e); + } + return null; + } + + public DeviceRegistry asyncUpdateDeviceRegistry(UpdateDeviceRegistryRequest request) throws ApplicationException { + try { + AsyncClient asyncClient = new AsyncClient(); + String[] bodyParams = request.getBodyAndParams(); + + String[] responseArray = asyncClient.update(configParameters.getCloudiotURLExtension(), bodyParams[0], + bodyParams[1], request); + if (responseArray[0] != null) { + int responseCode = Integer.parseInt(responseArray[0]); + if (responseCode == 200) { + DeviceRegistry deviceRegistry = DeviceRegistry.newBuilder().build(); + deviceRegistry.loadFromString(responseArray[2]); + return deviceRegistry; + } else { + throw new ApplicationException(responseArray[2]); + } + } + } catch (Exception e) { + throw new ApplicationException(e.getMessage(), e); + } + return null; + } + + public void deleteDeviceRegistry(DeleteDeviceRegistryRequest request) throws ApplicationException { + SyncClient syncClient = new SyncClient(); + String bodyParams = request.getParams(); + + String[] responseArray = syncClient.delete(configParameters.getCloudiotURLExtension(), bodyParams, true); + if (responseArray[0] != null) { + int responseCode = Integer.parseInt(responseArray[0]); + if (responseCode == 200 || responseCode == 204) { + log.log(Level.INFO, + () -> "Response code " + responseArray[0] + " received with message" + responseArray[2]); + } else { + throw new ApplicationException(responseArray[2]); + } + } + + } + + public void asyncDeleteDeviceRegistry(DeleteDeviceRegistryRequest request) throws ApplicationException { + try { + AsyncClient asyncClient = new AsyncClient(); + String bodyParams = request.getParams(); + + String[] responseArray = asyncClient.asyncDeleteDeviceRegistry(configParameters.getCloudiotURLExtension(), + bodyParams, true); + if (responseArray[0] != null) { + int responseCode = Integer.parseInt(responseArray[0]); + if (responseCode == 200 || responseCode == 204) { + System.out.println("DeleteDeviceRegistry execution successful"); + } else { + throw new ApplicationException(responseArray[2]); + } + } else { + System.out.println("DeleteDeviceRegistry execution failed"); + } + } catch (Exception e) { + throw new ApplicationException(e.getMessage(), e); + } + } } diff --git a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/DeviceManagerAsyncClient.java b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/DeviceManagerAsyncClient.java index f7576404..9041a8fe 100644 --- a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/DeviceManagerAsyncClient.java +++ b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/DeviceManagerAsyncClient.java @@ -30,6 +30,7 @@ package com.clearblade.cloud.iot.v1; +import java.io.IOException; import java.util.logging.Logger; import com.clearblade.cloud.iot.v1.binddevicetogateway.BindDeviceToGatewayRequest; @@ -62,137 +63,138 @@ public class DeviceManagerAsyncClient { - static Logger log = Logger.getLogger(DeviceManagerAsyncClient.class.getName()); - - /** - * Calling getDevice api - * - * @param request - * @return Device object - */ - - public Device getDevice(GetDeviceRequest request) { - ClearBladeDeviceManager cbManager = new ClearBladeDeviceManager(); - return cbManager.asyncGetDevice(request); - } - - /** - * Calling createDevice api - * - * @param request - * @return Device object - */ - public Device createDevice(CreateDeviceRequest request) throws ApplicationException { - ClearBladeDeviceManager cbManager = new ClearBladeDeviceManager(); - return cbManager.asyncCreateDevice(request); - } - - /** - * Calling deleteDevice api - * - * @param request - */ - public void deleteDevice(DeleteDeviceRequest request) throws ApplicationException { - ClearBladeDeviceManager cbManager = new ClearBladeDeviceManager(); - cbManager.asyncDeleteDevice(request); - } - - /** - * Calling updateDevice api - * - * @param request - * @return Device object - */ - public Device updateDevice(UpdateDeviceRequest request) throws ApplicationException { - ClearBladeDeviceManager cbManager = new ClearBladeDeviceManager(); - return cbManager.asyncUpdateDevice(request); - } - - /** - * Calling bindDeviceToGateway api - * - * @param request - * @return - */ - public BindDeviceToGatewayResponse bindDeviceToGateway(BindDeviceToGatewayRequest request) - throws ApplicationException { - ClearBladeDeviceManager cbManager = new ClearBladeDeviceManager(); - return cbManager.asyncBindDeviceToGateway(request); - } - - /** - * Calling unbindDeviceFromGateway api - * - * @param request - * @return - */ - public UnbindDeviceFromGatewayResponse unbindDeviceFromGateway(UnbindDeviceFromGatewayRequest request) - throws ApplicationException { - ClearBladeDeviceManager cbManager = new ClearBladeDeviceManager(); - return cbManager.asyncUnbindDeviceFromGateway(request); - } - - public SendCommandToDeviceResponse sendCommandToDevice(SendCommandToDeviceRequest request) - throws ApplicationException { - ClearBladeDeviceManager cbManager = new ClearBladeDeviceManager(); - return cbManager.asyncSendCommandToDevice(request); - - } - - public DeviceConfig modifyCloudToDeviceConfig(ModifyCloudToDeviceConfigRequest request) - throws ApplicationException { - ClearBladeDeviceManager cbManager = new ClearBladeDeviceManager(); - return cbManager.asyncModifyCloudToDeviceConfig(request); - } - - public DevicesListResponse listDevices(DevicesListRequest request) throws ApplicationException { - ClearBladeDeviceManager cbManager = new ClearBladeDeviceManager(); - return cbManager.asyncListDevices(request); - } - - public ListDeviceStatesResponse listDeviceStates(ListDeviceStatesRequest request) throws ApplicationException { - ClearBladeDeviceManager cbManager = new ClearBladeDeviceManager(); - return cbManager.asyncListDeviceStates(request); - } - - public ListDeviceConfigVersionsResponse listDeviceConfigVersions(ListDeviceConfigVersionsRequest request) - throws ApplicationException { - ClearBladeDeviceManager cbManager = new ClearBladeDeviceManager(); - return cbManager.asyncListDeviceConfigVersions(request); - } - - // Registry Apis - /** - * Calling getDevice api - * - * @param request - * @return Device object - */ - - public DeviceRegistry getDeviceRegistry(GetDeviceRegistryRequest request) throws ApplicationException { - ClearBladeRegistryManager cbManager = new ClearBladeRegistryManager(); - return cbManager.asyncGetDeviceRegistry(request); - } - - public DeviceRegistry createDeviceRegistry(CreateDeviceRegistryRequest request) throws ApplicationException { - ClearBladeRegistryManager cbManager = new ClearBladeRegistryManager(); - return cbManager.asyncCreateDeviceRegistry(request); - } - - public DeviceRegistry updateDeviceRegistry(UpdateDeviceRegistryRequest request) throws ApplicationException { - ClearBladeRegistryManager cbManager = new ClearBladeRegistryManager(); - return cbManager.asyncUpdateDeviceRegistry(request); - } - - public void deleteDeviceRegistry(DeleteDeviceRegistryRequest request) throws ApplicationException { - ClearBladeRegistryManager cbManager = new ClearBladeRegistryManager(); - cbManager.asyncDeleteDeviceRegistry(request); - } - - public ListDeviceRegistriesResponse listDeviceRegistries(ListDeviceRegistriesRequest request) - throws ApplicationException { - ClearBladeDeviceManager cbManager = new ClearBladeDeviceManager(); - return cbManager.asyncListDeviceRegistries(request); - } + static Logger log = Logger.getLogger(DeviceManagerAsyncClient.class.getName()); + + /** + * Calling getDevice api + * + * @param request + * @return Device object + */ + + public Device getDevice(GetDeviceRequest request) { + ClearBladeDeviceManager cbManager = new ClearBladeDeviceManager(); + return cbManager.asyncGetDevice(request); + } + + /** + * Calling createDevice api + * + * @param request + * @return Device object + */ + public Device createDevice(CreateDeviceRequest request) throws ApplicationException { + ClearBladeDeviceManager cbManager = new ClearBladeDeviceManager(); + return cbManager.asyncCreateDevice(request); + } + + /** + * Calling deleteDevice api + * + * @param request + */ + public void deleteDevice(DeleteDeviceRequest request) throws ApplicationException { + ClearBladeDeviceManager cbManager = new ClearBladeDeviceManager(); + cbManager.asyncDeleteDevice(request); + } + + /** + * Calling updateDevice api + * + * @param request + * @return Device object + */ + public Device updateDevice(UpdateDeviceRequest request) throws ApplicationException { + ClearBladeDeviceManager cbManager = new ClearBladeDeviceManager(); + return cbManager.asyncUpdateDevice(request); + } + + /** + * Calling bindDeviceToGateway api + * + * @param request + * @return + */ + public BindDeviceToGatewayResponse bindDeviceToGateway(BindDeviceToGatewayRequest request) + throws ApplicationException { + ClearBladeDeviceManager cbManager = new ClearBladeDeviceManager(); + return cbManager.asyncBindDeviceToGateway(request); + } + + /** + * Calling unbindDeviceFromGateway api + * + * @param request + * @return + */ + public UnbindDeviceFromGatewayResponse unbindDeviceFromGateway(UnbindDeviceFromGatewayRequest request) + throws ApplicationException { + ClearBladeDeviceManager cbManager = new ClearBladeDeviceManager(); + return cbManager.asyncUnbindDeviceFromGateway(request); + } + + public SendCommandToDeviceResponse sendCommandToDevice(SendCommandToDeviceRequest request) + throws ApplicationException { + ClearBladeDeviceManager cbManager = new ClearBladeDeviceManager(); + return cbManager.asyncSendCommandToDevice(request); + + } + + public DeviceConfig modifyCloudToDeviceConfig(ModifyCloudToDeviceConfigRequest request) + throws ApplicationException { + ClearBladeDeviceManager cbManager = new ClearBladeDeviceManager(); + return cbManager.asyncModifyCloudToDeviceConfig(request); + } + + public DevicesListResponse listDevices(DevicesListRequest request) throws ApplicationException { + ClearBladeDeviceManager cbManager = new ClearBladeDeviceManager(); + return cbManager.asyncListDevices(request); + } + + public ListDeviceStatesResponse listDeviceStates(ListDeviceStatesRequest request) throws ApplicationException { + ClearBladeDeviceManager cbManager = new ClearBladeDeviceManager(); + return cbManager.asyncListDeviceStates(request); + } + + public ListDeviceConfigVersionsResponse listDeviceConfigVersions(ListDeviceConfigVersionsRequest request) + throws ApplicationException { + ClearBladeDeviceManager cbManager = new ClearBladeDeviceManager(); + return cbManager.asyncListDeviceConfigVersions(request); + } + + // Registry Apis + + /** + * Calling getDevice api + * + * @param request + * @return Device object + */ + + public DeviceRegistry getDeviceRegistry(GetDeviceRegistryRequest request) throws ApplicationException { + ClearBladeRegistryManager cbManager = new ClearBladeRegistryManager(); + return cbManager.asyncGetDeviceRegistry(request); + } + + public DeviceRegistry createDeviceRegistry(CreateDeviceRegistryRequest request) throws ApplicationException { + ClearBladeRegistryManager cbManager = new ClearBladeRegistryManager(); + return cbManager.asyncCreateDeviceRegistry(request); + } + + public DeviceRegistry updateDeviceRegistry(UpdateDeviceRegistryRequest request) throws ApplicationException { + ClearBladeRegistryManager cbManager = new ClearBladeRegistryManager(); + return cbManager.asyncUpdateDeviceRegistry(request); + } + + public void deleteDeviceRegistry(DeleteDeviceRegistryRequest request) throws ApplicationException { + ClearBladeRegistryManager cbManager = new ClearBladeRegistryManager(); + cbManager.asyncDeleteDeviceRegistry(request); + } + + public ListDeviceRegistriesResponse listDeviceRegistries(ListDeviceRegistriesRequest request) + throws ApplicationException, IOException { + ClearBladeDeviceManager cbManager = new ClearBladeDeviceManager(); + return cbManager.asyncListDeviceRegistries(request); + } } diff --git a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/SyncClient.java b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/SyncClient.java index 83bc48ba..424086bc 100644 --- a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/SyncClient.java +++ b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/SyncClient.java @@ -42,245 +42,307 @@ import java.util.logging.Level; import java.util.logging.Logger; +import com.clearblade.cloud.iot.v1.binddevicetogateway.BindDeviceToGatewayRequest; +import com.clearblade.cloud.iot.v1.createdevice.CreateDeviceRequest; +import com.clearblade.cloud.iot.v1.createdeviceregistry.CreateDeviceRegistryRequest; +import com.clearblade.cloud.iot.v1.deletedevice.DeleteDeviceRequest; +import com.clearblade.cloud.iot.v1.deletedeviceregistry.DeleteDeviceRegistryRequest; +import com.clearblade.cloud.iot.v1.deviceslist.DevicesListRequest; +import com.clearblade.cloud.iot.v1.devicestateslist.ListDeviceStatesRequest; import com.clearblade.cloud.iot.v1.exception.ApplicationException; +import com.clearblade.cloud.iot.v1.getdevice.GetDeviceRequest; +import com.clearblade.cloud.iot.v1.getdeviceregistry.GetDeviceRegistryRequest; +import com.clearblade.cloud.iot.v1.listdeviceconfigversions.ListDeviceConfigVersionsRequest; +import com.clearblade.cloud.iot.v1.modifycloudtodeviceconfig.ModifyCloudToDeviceConfigRequest; +import com.clearblade.cloud.iot.v1.sendcommandtodevice.SendCommandToDeviceRequest; +import com.clearblade.cloud.iot.v1.unbinddevicefromgateway.UnbindDeviceFromGatewayRequest; +import com.clearblade.cloud.iot.v1.updatedevice.UpdateDeviceRequest; +import com.clearblade.cloud.iot.v1.updatedeviceregistry.UpdateDeviceRegistryRequest; import com.clearblade.cloud.iot.v1.utils.AuthParams; import com.clearblade.cloud.iot.v1.utils.ConfigParameters; import com.clearblade.cloud.iot.v1.utils.Constants; +import org.json.simple.parser.ParseException; public class SyncClient { - static Logger log = Logger.getLogger(SyncClient.class.getName()); - private ConfigParameters configParameters = ConfigParameters.getInstance(); - - - /** - * Method used to generate URL for apicall - * @param apiName - path to api - * @param params - parameters to be attached to request - * @return URL formed and to be used - */ - private String generateURL(String apiName, String params) { - - return AuthParams.getApiBaseURL() - .concat(configParameters.getEndpointPort()) - .concat(configParameters.getWebhook()) - .concat(AuthParams.getUserSystemKey()) - .concat(apiName) - .concat("?" + params); - } - - /** - * Method used to generate URL for apicall - * @param apiName - path to api - * @param params - parameters to be attached to request - * @return URL formed and to be used - */ - private String generateAdminURL(String apiName, String params) { - - return AuthParams.getBaseURL() - .concat(configParameters.getWebhook()) - .concat(AuthParams.getAdminSystemKey()) - .concat(apiName) - .concat("?" + params); - } - - /** - * Method used to Calls HTTP Get request - * @param apiName - * @param params - * @return String[] containing responseCode, responseMessage and response object - * @throws IOException - * @throws ApplicationException - */ - public String[] get(String apiName, String params, boolean isAdmin) { - String[] responseArray = new String[3]; - String finalURL = ""; - String token = ""; - try { - if (isAdmin) { - AuthParams.setAdminCredentials(); - finalURL = generateAdminURL(apiName, params); - token = AuthParams.getAdminToken(); - } else { - AuthParams.setRegistryCredentials(); - finalURL = generateURL(apiName, params); - token = AuthParams.getUserToken(); - } - - HttpRequest request = HttpRequest.newBuilder() - .uri(URI.create(finalURL)) - .headers(Constants.HTTP_REQUEST_PROPERTY_CONTENT_TYPE_KEY, Constants.HTTP_REQUEST_PROPERTY_CONTENT_TYPE_ACCEPT_VALUE, - Constants.HTTP_REQUEST_PROPERTY_TOKEN_KEY, token, - Constants.HTTP_REQUEST_PROPERTY_ACCEPT_KEY, Constants.HTTP_REQUEST_PROPERTY_CONTENT_TYPE_ACCEPT_VALUE) - .GET() - .build(); - - HttpResponse response = HttpClient - .newBuilder() - .proxy(ProxySelector.getDefault()) - .build() - .send(request, BodyHandlers.ofString()); - - responseArray[0] = String.valueOf(response.statusCode()); - responseArray[1] = ""; - responseArray[2] = response.body(); - - - } catch (InterruptedException e) { - log.log(Level.SEVERE, e.getMessage()); - Thread.currentThread().interrupt(); - }catch(Exception ex) { - log.log(Level.SEVERE, ex.getMessage()); - } - - return responseArray; - } - - /** - * Method used to call HTTP Post request - * @param apiName - * @param params - * @param body - * @return String[] containing responseCode, responseMessage and response object - * @throws IOException - * @throws ApplicationException - */ - public String[] post(String apiName, String params, String body, boolean isAdmin) { - String[] responseArray = new String[3]; - String finalURL = ""; - String token = ""; - try { - if (isAdmin) { - AuthParams.setAdminCredentials(); - finalURL = generateAdminURL(apiName, params); - token = AuthParams.getAdminToken(); - } else { - AuthParams.setRegistryCredentials(); - finalURL = generateURL(apiName, params); - token = AuthParams.getUserToken(); - } - - BodyPublisher jsonPayload = BodyPublishers.ofString(body); - HttpRequest request = HttpRequest.newBuilder() - .uri(URI.create(finalURL)) - .method(Constants.HTTP_REQUEST_METHOD_TYPE_POST, jsonPayload) - .headers(Constants.HTTP_REQUEST_PROPERTY_CONTENT_TYPE_KEY, Constants.HTTP_REQUEST_PROPERTY_CONTENT_TYPE_ACCEPT_VALUE, - Constants.HTTP_REQUEST_PROPERTY_TOKEN_KEY, token, - Constants.HTTP_REQUEST_PROPERTY_ACCEPT_KEY, Constants.HTTP_REQUEST_PROPERTY_CONTENT_TYPE_ACCEPT_VALUE) - .build(); - - HttpResponse response = HttpClient - .newBuilder() - .proxy(ProxySelector.getDefault()) - .build() - .send(request, BodyHandlers.ofString()); - - responseArray[0] = String.valueOf(response.statusCode()); - responseArray[1] = ""; - responseArray[2] = response.body(); - - } catch (ApplicationException | IOException e) { - log.log(Level.SEVERE, e.getMessage()); - } catch (InterruptedException ex) { - log.log(Level.SEVERE, ex.getMessage()); - Thread.currentThread().interrupt(); - }catch(Exception ec) { - log.log(Level.SEVERE, ec.getMessage()); - } - - return responseArray; - } - - /** - * Method used to call HTTP delete request - * @param apiName - * @param params - * @return String[] containing responseCode, responseMessage and response object - * @throws IOException - * @throws ApplicationException - */ - public String[] delete(String apiName, String params, boolean isAdmin) { - String[] responseArray = new String[3]; - String finalURL = ""; - String token = ""; - try { - if (isAdmin) { - AuthParams.setAdminCredentials(); - finalURL = generateAdminURL(apiName, params); - token = AuthParams.getAdminToken(); - } else { - AuthParams.setRegistryCredentials(); - finalURL = generateURL(apiName, params); - token = AuthParams.getUserToken(); - } - HttpRequest request = HttpRequest.newBuilder() - .uri(URI.create(finalURL)) - .headers(Constants.HTTP_REQUEST_PROPERTY_CONTENT_TYPE_KEY, Constants.HTTP_REQUEST_PROPERTY_CONTENT_TYPE_ACCEPT_VALUE, - Constants.HTTP_REQUEST_PROPERTY_TOKEN_KEY, token, - Constants.HTTP_REQUEST_PROPERTY_ACCEPT_KEY, Constants.HTTP_REQUEST_PROPERTY_CONTENT_TYPE_ACCEPT_VALUE) - .DELETE() - .build(); - - HttpResponse response = HttpClient - .newBuilder() - .proxy(ProxySelector.getDefault()) - .build() - .send(request, BodyHandlers.ofString()); - - responseArray[0] = String.valueOf(response.statusCode()); - responseArray[1] = ""; - responseArray[2] = response.body(); - - - } catch (InterruptedException e) { - log.log(Level.SEVERE, e.getMessage()); - Thread.currentThread().interrupt(); - }catch(Exception ex) { - log.log(Level.SEVERE, ex.getMessage()); - } - - return responseArray; - } - - /** - * Method used to call HTTP Patch request - * @param apiName - * @param params - * @param body - * @return String[] containing responseCode, responseMessage and response object - */ - public String[] update(String apiName, String params, String body) throws InterruptedException{ - String[] responseArray = new String[3]; - try { - AuthParams.setRegistryCredentials(); - String finalURL = generateURL(apiName, params); - - BodyPublisher jsonPayload = BodyPublishers.ofString(body); - HttpRequest request = HttpRequest.newBuilder() - .uri(URI.create(finalURL)) - .method(Constants.HTTP_REQUEST_METHOD_TYPE_PATCH, jsonPayload) - .headers(Constants.HTTP_REQUEST_PROPERTY_CONTENT_TYPE_KEY, - Constants.HTTP_REQUEST_PROPERTY_CONTENT_TYPE_ACCEPT_VALUE, - Constants.HTTP_REQUEST_PROPERTY_TOKEN_KEY, AuthParams.getUserToken(),Constants.HTTP_REQUEST_PROPERTY_ACCEPT_KEY, - Constants.HTTP_REQUEST_PROPERTY_CONTENT_TYPE_ACCEPT_VALUE ) - .build(); - - HttpResponse response = HttpClient - .newBuilder() - .proxy(ProxySelector.getDefault()) - .build() - .send(request, BodyHandlers.ofString()); - - responseArray[0] = String.valueOf(response.statusCode()); - responseArray[1] = ""; - responseArray[2] = response.body(); - - } catch (InterruptedException e) { - log.log(Level.SEVERE, e.getMessage()); - Thread.currentThread().interrupt(); - }catch(Exception ex) { - log.log(Level.SEVERE, ex.getMessage()); - } - return responseArray; - } + static Logger log = Logger.getLogger(SyncClient.class.getName()); + private ConfigParameters configParameters = ConfigParameters.getInstance(); + + private AuthParams authParams = new AuthParams(); + + /** + * Method used to generate URL for apicall + * + * @param apiName - path to api + * @param params - parameters to be attached to request + * @return URL formed and to be used + */ + private String generateURL(AuthParams authParams, String apiName, String params) { + return authParams.getApiBaseURL().concat(configParameters.getEndpointPort()).concat(configParameters.getWebhook()).concat(authParams.getUserSystemKey()).concat(apiName).concat("?" + params); + } + + /** + * Method used to generate URL for apicall + * + * @param apiName - path to api + * @param params - parameters to be attached to request + * @return URL formed and to be used + */ + private String generateAdminURL(AuthParams authParams, String apiName, String params) { + + return authParams.getBaseURL().concat(configParameters.getWebhook()).concat(authParams.getAdminSystemKey()).concat(apiName).concat("?" + params); + } + + public String[] get(String apiName, GetDeviceRequest request) { + authParams.setRegistryCredentials(request.getName().getProject(), request.getName().getRegistry(), request.getName().getLocation()); + String finalURL = generateURL(authParams, apiName, request.toString()); + String token = authParams.getUserToken(); + return get(finalURL, token); + } + + public String[] get(String apiName, String params, DevicesListRequest request) { + authParams.setRegistryCredentials(request.getParent().getProject(), request.getParent().getRegistry(), request.getParent().getLocation()); + String finalURL = generateURL(authParams, apiName, params); + String token = authParams.getUserToken(); + return get(finalURL, token); + } + + public String[] get(String apiName, String params, ListDeviceStatesRequest request) { + authParams.setRegistryCredentials(request.getName().getProject(), request.getName().getRegistry(), request.getName().getLocation()); + String finalURL = generateURL(authParams, apiName, params); + String token = authParams.getUserToken(); + return get(finalURL, token); + } + + public String[] get(String apiName, String params, GetDeviceRegistryRequest request) { + authParams.setRegistryCredentials(request.getName().getProject(), request.getName().getRegistry(), request.getName().getLocation()); + String finalURL = generateURL(authParams, apiName, params); + String token = authParams.getUserToken(); + return get(finalURL, token); + } + + public String[] get(String apiName, String params, ListDeviceConfigVersionsRequest request) { + authParams.setRegistryCredentials(request.getName().getProject(), request.getName().getRegistry(), request.getName().getLocation()); + String finalURL = generateURL(authParams, apiName, params); + String token = authParams.getUserToken(); + return get(finalURL, token); + } + + public String[] get(String apiName, String params, boolean isAdmin) { + String finalURL = ""; + String token = ""; + if (isAdmin) { + try { + authParams.setAdminCredentials(); + } catch (IOException e) { + throw new ApplicationException(e); + } + finalURL = generateAdminURL(authParams, apiName, params); + token = authParams.getAdminToken(); + } + return this.get(finalURL, token); + } + + /** + * Method used to Calls HTTP Get request + * + * @param apiName + * @param params + * @return String[] containing responseCode, responseMessage and response object + * @throws IOException + * @throws ApplicationException + */ + public String[] get(String finalURL, String token) { + String[] responseArray = new String[3]; + try { + HttpRequest request = HttpRequest.newBuilder().uri(URI.create(finalURL)).headers(Constants.HTTP_REQUEST_PROPERTY_CONTENT_TYPE_KEY, Constants.HTTP_REQUEST_PROPERTY_CONTENT_TYPE_ACCEPT_VALUE, Constants.HTTP_REQUEST_PROPERTY_TOKEN_KEY, token, Constants.HTTP_REQUEST_PROPERTY_ACCEPT_KEY, Constants.HTTP_REQUEST_PROPERTY_CONTENT_TYPE_ACCEPT_VALUE).GET().build(); + + HttpResponse response = HttpClient.newBuilder().proxy(ProxySelector.getDefault()).build().send(request, BodyHandlers.ofString()); + + responseArray[0] = String.valueOf(response.statusCode()); + responseArray[1] = ""; + responseArray[2] = response.body(); + + + } catch (InterruptedException e) { + log.log(Level.SEVERE, e.getMessage()); + Thread.currentThread().interrupt(); + } catch (Exception ex) { + log.log(Level.SEVERE, ex.getMessage()); + } + + return responseArray; + } + + public String[] post(String apiName, String params, String body, CreateDeviceRequest request) { + authParams.setRegistryCredentials(request.getParent().getProject(), request.getParent().getRegistry(), request.getParent().getLocation()); + String finalURL = generateURL(authParams, apiName, params); + String token = authParams.getUserToken(); + return post(finalURL, body, token); + } + + public String[] post(String apiName, String params, String body, SendCommandToDeviceRequest request) { + String finalURL = ""; + String token = ""; + authParams.setRegistryCredentials(request.getDeviceName().getProject(), request.getDeviceName().getRegistry(), request.getDeviceName().getLocation()); + finalURL = generateURL(authParams, apiName, params); + token = authParams.getUserToken(); + return post(finalURL, body, token); + } + + public String[] post(String apiName, String params, String body, BindDeviceToGatewayRequest request) { + authParams.setRegistryCredentials(request.getParent().getProject(), request.getParent().getRegistry(), request.getParent().getLocation()); + String finalURL = generateURL(authParams, apiName, params); + String token = authParams.getUserToken(); + return post(finalURL, body, token); + } + + public String[] post(String apiName, String params, String body, ModifyCloudToDeviceConfigRequest request) { + authParams.setRegistryCredentials(request.getDeviceName().getProject(), request.getDeviceName().getRegistry(), request.getDeviceName().getLocation()); + String finalURL = generateURL(authParams, apiName, params); + String token = authParams.getUserToken(); + return post(finalURL, body, token); + } + + public String[] post(String apiName, String params, String body, UnbindDeviceFromGatewayRequest request) { + authParams.setRegistryCredentials(request.getParent().getProject(), request.getParent().getRegistry(), request.getParent().getLocation()); + String finalURL = generateURL(authParams, apiName, params); + String token = authParams.getUserToken(); + return post(finalURL, body, token); + } + + public String[] post(String apiName, String params, String body, boolean isAdmin, CreateDeviceRegistryRequest request) { + String finalURL = ""; + String token = ""; + if (isAdmin) { + try { + authParams.setAdminCredentials(); + } catch (IOException e) { + throw new ApplicationException(e); + } + finalURL = generateAdminURL(authParams, apiName, params); + token = authParams.getAdminToken(); + } + return post(finalURL, body, token); + } + + /** + * Method used to call HTTP Post request + * + * @param apiName + * @param params + * @param body + * @return String[] containing responseCode, responseMessage and response object + * @throws IOException + * @throws ApplicationException + */ + public String[] post(String finalURL, String body, String token) { + String[] responseArray = new String[3]; + try { + BodyPublisher jsonPayload = BodyPublishers.ofString(body); + HttpRequest request = HttpRequest.newBuilder().uri(URI.create(finalURL)).method(Constants.HTTP_REQUEST_METHOD_TYPE_POST, jsonPayload).headers(Constants.HTTP_REQUEST_PROPERTY_CONTENT_TYPE_KEY, Constants.HTTP_REQUEST_PROPERTY_CONTENT_TYPE_ACCEPT_VALUE, Constants.HTTP_REQUEST_PROPERTY_TOKEN_KEY, token, Constants.HTTP_REQUEST_PROPERTY_ACCEPT_KEY, Constants.HTTP_REQUEST_PROPERTY_CONTENT_TYPE_ACCEPT_VALUE).build(); + + HttpResponse response = HttpClient.newBuilder().proxy(ProxySelector.getDefault()).build().send(request, BodyHandlers.ofString()); + + responseArray[0] = String.valueOf(response.statusCode()); + responseArray[1] = ""; + responseArray[2] = response.body(); + + } catch (ApplicationException e) { + log.log(Level.SEVERE, e.getMessage()); + Thread.currentThread().interrupt(); + } catch (Exception ec) { + log.log(Level.SEVERE, ec.getMessage()); + } + return responseArray; + } + + public String[] delete(String apiName, String params, boolean isAdmin, DeleteDeviceRequest request) { + authParams.setRegistryCredentials(request.getName().getProject(), request.getName().getRegistry(), request.getName().getLocation()); + String finalURL = generateURL(authParams, apiName, params); + String token = authParams.getUserToken(); + return this.delete(finalURL, token); + } + + public String[] delete(String apiName, String params, boolean isAdmin) { + try { + authParams.setAdminCredentials(); + } catch (IOException e) { + throw new ApplicationException(e); + } + String finalURL = generateAdminURL(authParams, apiName, params); + String token = authParams.getAdminToken(); + return this.delete(finalURL, token); + } + + /** + * Method used to call HTTP delete request + * + * @return String[] containing responseCode, responseMessage and response object + * @throws IOException + * @throws ApplicationException + */ + public String[] delete(String finalURL, String token) { + String[] responseArray = new String[3]; + try { + HttpRequest request = HttpRequest.newBuilder().uri(URI.create(finalURL)).headers(Constants.HTTP_REQUEST_PROPERTY_CONTENT_TYPE_KEY, Constants.HTTP_REQUEST_PROPERTY_CONTENT_TYPE_ACCEPT_VALUE, Constants.HTTP_REQUEST_PROPERTY_TOKEN_KEY, token, Constants.HTTP_REQUEST_PROPERTY_ACCEPT_KEY, Constants.HTTP_REQUEST_PROPERTY_CONTENT_TYPE_ACCEPT_VALUE).DELETE().build(); + + HttpResponse response = HttpClient.newBuilder().proxy(ProxySelector.getDefault()).build().send(request, BodyHandlers.ofString()); + + responseArray[0] = String.valueOf(response.statusCode()); + responseArray[1] = ""; + responseArray[2] = response.body(); + + + } catch (InterruptedException e) { + log.log(Level.SEVERE, e.getMessage()); + Thread.currentThread().interrupt(); + } catch (Exception ex) { + log.log(Level.SEVERE, ex.getMessage()); + } + + return responseArray; + } + + public String[] update(String apiName, String params, String body, UpdateDeviceRequest request) throws InterruptedException { + String finalURL = ""; + String token = ""; + authParams.setRegistryCredentials(request.getDeviceName().getProject(), request.getDeviceName().getRegistry(), request.getDeviceName().getLocation()); + finalURL = generateURL(authParams, apiName, params); + token = authParams.getUserToken(); + return update(finalURL, body, token); + } + + public String[] update(String apiName, String params, String body, UpdateDeviceRegistryRequest request) { + authParams.setRegistryCredentials(request.getParent().getProject(), request.getParent().getRegistry(), request.getParent().getLocation()); + String finalURL = generateURL(authParams, apiName, params); + String token = authParams.getUserToken(); + return post(finalURL, body, token); + } + + /** + * Method used to call HTTP Patch request + * + * @param apiName + * @param params + * @param body + * @return String[] containing responseCode, responseMessage and response object + */ + public String[] update(String finalURL, String body, String token) throws InterruptedException { + String[] responseArray = new String[3]; + try { + BodyPublisher jsonPayload = BodyPublishers.ofString(body); + HttpRequest request = HttpRequest.newBuilder().uri(URI.create(finalURL)).method(Constants.HTTP_REQUEST_METHOD_TYPE_PATCH, jsonPayload).headers(Constants.HTTP_REQUEST_PROPERTY_CONTENT_TYPE_KEY, Constants.HTTP_REQUEST_PROPERTY_CONTENT_TYPE_ACCEPT_VALUE, Constants.HTTP_REQUEST_PROPERTY_TOKEN_KEY, token, Constants.HTTP_REQUEST_PROPERTY_ACCEPT_KEY, Constants.HTTP_REQUEST_PROPERTY_CONTENT_TYPE_ACCEPT_VALUE).build(); + + HttpResponse response = HttpClient.newBuilder().proxy(ProxySelector.getDefault()).build().send(request, BodyHandlers.ofString()); + + responseArray[0] = String.valueOf(response.statusCode()); + responseArray[1] = ""; + responseArray[2] = response.body(); + + } catch (Exception ex) { + log.log(Level.SEVERE, ex.getMessage()); + } + return responseArray; + } } diff --git a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/binddevicetogateway/BindDeviceToGatewayRequest.java b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/binddevicetogateway/BindDeviceToGatewayRequest.java index 82cb2a13..19ec8286 100644 --- a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/binddevicetogateway/BindDeviceToGatewayRequest.java +++ b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/binddevicetogateway/BindDeviceToGatewayRequest.java @@ -30,105 +30,111 @@ package com.clearblade.cloud.iot.v1.binddevicetogateway; +import com.clearblade.cloud.iot.v1.registrytypes.RegistryName; +import com.clearblade.cloud.iot.v1.utils.PathTemplate; import org.json.simple.JSONObject; public class BindDeviceToGatewayRequest { - private final String parent; - private final String gateway; - private final String device; - JSONObject requestParams; - JSONObject bodyParams; - - private BindDeviceToGatewayRequest(Builder builder) { - this.parent = builder.parent; - this.gateway = builder.gateway; - this.device = builder.device; - } - - // Static class Builder - public static class Builder { - - /// instance fields - private String parent; - private String gateway; - private String device; - - public static Builder newBuilder() { - return new Builder(); - } - - private Builder() { - } - - // Setter methods - public Builder setParent(String parent) { - this.parent = parent; - return this; - } - - public Builder setGateway(String gateway) { - this.gateway = gateway; - return this; - } - - public Builder setDevice(String device) { - this.device = device; - return this; - } - - // build method to deal with outer class - // to return outer instance - public BindDeviceToGatewayRequest build() { - return new BindDeviceToGatewayRequest(this); - } - } - - public JSONObject getRequestParams() { - return requestParams; - } - - public void setRequestParams(JSONObject requestParams) { - this.requestParams = requestParams; - } - - public JSONObject getBodyParams() { - return bodyParams; - } - - public void setBodyParams(JSONObject bodyParams) { - this.bodyParams = bodyParams; - } - - @SuppressWarnings("unchecked") - @Override - public String toString() { - requestParams = new JSONObject(); - bodyParams = new JSONObject(); - - String method = "bindDeviceToGateway"; - requestParams.put("method", method); - requestParams.put("parent", this.parent); - - bodyParams.put("gatewayId", this.gateway); - bodyParams.put("deviceId", this.device); - - this.setRequestParams(requestParams); - this.setBodyParams(bodyParams); - - return "parent=" + this.parent + ",gateway=" + this.gateway + ", device= " + this.device; - } - - @SuppressWarnings("unchecked") - public String[] getBodyAndParams() { - String[] output = new String[2]; - String params = "parent=" + this.parent + "&method=" + "bindDeviceToGateway"; - bodyParams = new JSONObject(); - bodyParams.put("gatewayId", this.gateway); - bodyParams.put("deviceId", this.device); - - output[0] = params; - output[1] = bodyParams.toJSONString(); - return output; - } + private final String parent; + private final String gateway; + private final String device; + JSONObject requestParams; + JSONObject bodyParams; + + private BindDeviceToGatewayRequest(Builder builder) { + this.parent = builder.parent; + this.gateway = builder.gateway; + this.device = builder.device; + } + + // Static class Builder + public static class Builder { + + /// instance fields + private String parent; + private String gateway; + private String device; + + public static Builder newBuilder() { + return new Builder(); + } + + private Builder() { + } + + // Setter methods + public Builder setParent(String parent) { + this.parent = parent; + return this; + } + + public Builder setGateway(String gateway) { + this.gateway = gateway; + return this; + } + + public Builder setDevice(String device) { + this.device = device; + return this; + } + + // build method to deal with outer class + // to return outer instance + public BindDeviceToGatewayRequest build() { + return new BindDeviceToGatewayRequest(this); + } + } + + public JSONObject getRequestParams() { + return requestParams; + } + + public void setRequestParams(JSONObject requestParams) { + this.requestParams = requestParams; + } + + public JSONObject getBodyParams() { + return bodyParams; + } + + public void setBodyParams(JSONObject bodyParams) { + this.bodyParams = bodyParams; + } + + public RegistryName getParent() { + return RegistryName.parse(this.parent); + } + + @SuppressWarnings("unchecked") + @Override + public String toString() { + requestParams = new JSONObject(); + bodyParams = new JSONObject(); + + String method = "bindDeviceToGateway"; + requestParams.put("method", method); + requestParams.put("parent", this.parent); + + bodyParams.put("gatewayId", this.gateway); + bodyParams.put("deviceId", this.device); + + this.setRequestParams(requestParams); + this.setBodyParams(bodyParams); + + return "parent=" + this.parent + ",gateway=" + this.gateway + ", device= " + this.device; + } + + @SuppressWarnings("unchecked") + public String[] getBodyAndParams() { + String[] output = new String[2]; + String params = "parent=" + this.parent + "&method=" + "bindDeviceToGateway"; + bodyParams = new JSONObject(); + bodyParams.put("gatewayId", this.gateway); + bodyParams.put("deviceId", this.device); + + output[0] = params; + output[1] = bodyParams.toJSONString(); + return output; + } } diff --git a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/createdevice/CreateDeviceRequest.java b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/createdevice/CreateDeviceRequest.java index 9a77c215..130d8827 100644 --- a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/createdevice/CreateDeviceRequest.java +++ b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/createdevice/CreateDeviceRequest.java @@ -34,50 +34,54 @@ import com.clearblade.cloud.iot.v1.registrytypes.RegistryName; public class CreateDeviceRequest { - private final RegistryName parent; - private final Device device; + private final RegistryName parent; + private final Device device; - private CreateDeviceRequest(Builder builder) { - this.parent = builder.parent; - this.device = builder.device; - } + private CreateDeviceRequest(Builder builder) { + this.parent = builder.parent; + this.device = builder.device; + } - // Static class Builder - public static class Builder { + // Static class Builder + public static class Builder { - /// instance fields - private RegistryName parent; - private Device device; + /// instance fields + private RegistryName parent; + private Device device; - public static Builder newBuilder() { - return new Builder(); - } + public static Builder newBuilder() { + return new Builder(); + } - private Builder() { - } + private Builder() { + } - // Setter methods - public Builder setParent(RegistryName parent) { - this.parent = parent; - return this; - } + // Setter methods + public Builder setParent(RegistryName parent) { + this.parent = parent; + return this; + } - public Builder setDevice(Device device) { - this.device = device; - return this; - } + public Builder setDevice(Device device) { + this.device = device; + return this; + } - // build method to deal with outer class - // to return outer instance - public CreateDeviceRequest build() { - return new CreateDeviceRequest(this); - } - } + // build method to deal with outer class + // to return outer instance + public CreateDeviceRequest build() { + return new CreateDeviceRequest(this); + } + } - public String[] getParams() { - String[] params = new String[2]; - params[0] = "parent=" + this.parent.getRegistryFullName(); - params[1] = this.device.createDeviceJSONObject(); - return params; - } + public RegistryName getParent() { + return parent; + } + + public String[] getParams() { + String[] params = new String[2]; + params[0] = "parent=" + this.parent.getRegistryFullName(); + params[1] = this.device.createDeviceJSONObject(); + return params; + } } diff --git a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/createdeviceregistry/CreateDeviceRegistryRequest.java b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/createdeviceregistry/CreateDeviceRegistryRequest.java index e0df85bb..8c16120b 100644 --- a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/createdeviceregistry/CreateDeviceRegistryRequest.java +++ b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/createdeviceregistry/CreateDeviceRegistryRequest.java @@ -31,6 +31,8 @@ package com.clearblade.cloud.iot.v1.createdeviceregistry; import com.clearblade.cloud.iot.v1.registrytypes.DeviceRegistry; +import com.clearblade.cloud.iot.v1.registrytypes.LocationName; +import com.clearblade.cloud.iot.v1.registrytypes.RegistryName; public class CreateDeviceRegistryRequest { private String parent; @@ -73,6 +75,10 @@ public CreateDeviceRegistryRequest build() { } } + public LocationName getParent() { + return LocationName.parse(this.parent); + } + public String[] getBodyAndParams() { String[] output = new String[2]; output[0] = "parent=" + this.parent; diff --git a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/deviceslist/DevicesListRequest.java b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/deviceslist/DevicesListRequest.java index 9cdab701..aeac253b 100644 --- a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/deviceslist/DevicesListRequest.java +++ b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/deviceslist/DevicesListRequest.java @@ -31,122 +31,127 @@ package com.clearblade.cloud.iot.v1.deviceslist; import com.clearblade.cloud.iot.v1.devicetypes.GatewayListOptions; +import com.clearblade.cloud.iot.v1.registrytypes.RegistryName; public class DevicesListRequest { - private String parent; - private String deviceNumIds; - private String deviceIds; - private String fieldMask; - private int pageSize = -1; - private String pageToken; - private GatewayListOptions gatewayListOptions; - - private DevicesListRequest(Builder builder) { - this.parent = builder.parent; - this.deviceNumIds = builder.deviceNumIds; - this.deviceIds = builder.deviceIds; - this.fieldMask = builder.fieldMask; - this.pageSize = builder.pageSize; - this.pageToken = builder.pageToken; - this.gatewayListOptions = builder.gatewayListOptions; - } - - // Static class Builder - public static class Builder { - - /// instance fields - private String parent; - private String deviceNumIds; - private String deviceIds; - private String fieldMask; - private int pageSize; - private String pageToken; - private GatewayListOptions gatewayListOptions; - - public static Builder newBuilder() { - return new Builder(); - } - - private Builder() { - } - - // Setter methods - public Builder setParent(String parent) { - this.parent = parent; - return this; - } - - public Builder setDeviceNumIds(String deviceNumIds) { - this.deviceNumIds = deviceNumIds; - return this; - } - - public Builder setDeviceIds(String deviceIds) { - this.deviceIds = deviceIds; - return this; - } - - public Builder setFieldMask(String fieldMask) { - this.fieldMask = fieldMask; - return this; - } - - public Builder setPageSize(int pageSize) { - this.pageSize = pageSize; - return this; - } - - public Builder setPageToken(String pageToken) { - this.pageToken = pageToken; - return this; - } - - public Builder setGatewayListOptions(GatewayListOptions gatewayListOptions) { - this.gatewayListOptions = gatewayListOptions; - return this; - } - - // build method to deal with outer class - // to return outer instance - public DevicesListRequest build() { - return new DevicesListRequest(this); - } - - } - - @Override - public String toString() { - return this.parent.toString(); - } - - public String getParamsForList() { - String params = ""; - params = "parent=" + this.parent; - if (this.deviceNumIds != null) - params += "&deviceNumIds=" + this.deviceNumIds; - if (this.deviceIds != null) - params += "&deviceIds=" + this.deviceIds; - if (this.fieldMask != null) - params += "&fieldMask=" + this.fieldMask; - if (this.pageSize > 0) - params += "&pageSize=" + String.valueOf(this.pageSize); - if (this.pageToken != null) - params += "&pageToken=" + this.pageToken; - if (this.gatewayListOptions != null) { - if (this.gatewayListOptions.getGatewayType() != null) { - params += "&gatewayListOptions.gatewayType=" + this.gatewayListOptions.getGatewayType().name(); - } else if (this.gatewayListOptions.getAssociationsDeviceId() != null) { - params += "&gatewayListOptions.associationsDeviceId=" - + this.gatewayListOptions.getAssociationsDeviceId(); - } else if (this.gatewayListOptions.getAssociationsGatewayId() != null) { - params += "&gatewayListOptions.associationsGatewayId=" - + this.gatewayListOptions.getAssociationsGatewayId(); - } - - } - - return params; - } + private String parent; + private String deviceNumIds; + private String deviceIds; + private String fieldMask; + private int pageSize = -1; + private String pageToken; + private GatewayListOptions gatewayListOptions; + + private DevicesListRequest(Builder builder) { + this.parent = builder.parent; + this.deviceNumIds = builder.deviceNumIds; + this.deviceIds = builder.deviceIds; + this.fieldMask = builder.fieldMask; + this.pageSize = builder.pageSize; + this.pageToken = builder.pageToken; + this.gatewayListOptions = builder.gatewayListOptions; + } + + // Static class Builder + public static class Builder { + + /// instance fields + private String parent; + private String deviceNumIds; + private String deviceIds; + private String fieldMask; + private int pageSize; + private String pageToken; + private GatewayListOptions gatewayListOptions; + + public static Builder newBuilder() { + return new Builder(); + } + + private Builder() { + } + + // Setter methods + public Builder setParent(String parent) { + this.parent = parent; + return this; + } + + public Builder setDeviceNumIds(String deviceNumIds) { + this.deviceNumIds = deviceNumIds; + return this; + } + + public Builder setDeviceIds(String deviceIds) { + this.deviceIds = deviceIds; + return this; + } + + public Builder setFieldMask(String fieldMask) { + this.fieldMask = fieldMask; + return this; + } + + public Builder setPageSize(int pageSize) { + this.pageSize = pageSize; + return this; + } + + public Builder setPageToken(String pageToken) { + this.pageToken = pageToken; + return this; + } + + public Builder setGatewayListOptions(GatewayListOptions gatewayListOptions) { + this.gatewayListOptions = gatewayListOptions; + return this; + } + + // build method to deal with outer class + // to return outer instance + public DevicesListRequest build() { + return new DevicesListRequest(this); + } + + } + + public RegistryName getParent() { + return RegistryName.parse(this.parent); + } + + @Override + public String toString() { + return this.parent.toString(); + } + + public String getParamsForList() { + String params = ""; + params = "parent=" + this.parent; + if (this.deviceNumIds != null) + params += "&deviceNumIds=" + this.deviceNumIds; + if (this.deviceIds != null) + params += "&deviceIds=" + this.deviceIds; + if (this.fieldMask != null) + params += "&fieldMask=" + this.fieldMask; + if (this.pageSize > 0) + params += "&pageSize=" + String.valueOf(this.pageSize); + if (this.pageToken != null) + params += "&pageToken=" + this.pageToken; + if (this.gatewayListOptions != null) { + if (this.gatewayListOptions.getGatewayType() != null) { + params += "&gatewayListOptions.gatewayType=" + this.gatewayListOptions.getGatewayType().name(); + } else if (this.gatewayListOptions.getAssociationsDeviceId() != null) { + params += "&gatewayListOptions.associationsDeviceId=" + + this.gatewayListOptions.getAssociationsDeviceId(); + } else if (this.gatewayListOptions.getAssociationsGatewayId() != null) { + params += "&gatewayListOptions.associationsGatewayId=" + + this.gatewayListOptions.getAssociationsGatewayId(); + } + + } + + return params; + } } diff --git a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/devicestateslist/ListDeviceStatesRequest.java b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/devicestateslist/ListDeviceStatesRequest.java index 2e2e0e03..41f8777f 100644 --- a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/devicestateslist/ListDeviceStatesRequest.java +++ b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/devicestateslist/ListDeviceStatesRequest.java @@ -30,75 +30,81 @@ package com.clearblade.cloud.iot.v1.devicestateslist; +import com.clearblade.cloud.iot.v1.devicetypes.DeviceName; +import com.clearblade.cloud.iot.v1.registrytypes.RegistryName; import org.json.simple.JSONObject; public class ListDeviceStatesRequest { - private final String name; - private final String numStates; - JSONObject requestParams; - - private ListDeviceStatesRequest(Builder builder) { - this.name = builder.name; - this.numStates = builder.numStates; - } - - // Static class Builder - public static class Builder { - - /// instance fields - private String name; - private String numStates; - - public static Builder newBuilder() { - return new Builder(); - } - - private Builder() { - } - - // Setter methods - public Builder setName(String name) { - this.name = name; - return this; - } - - public Builder setNumStates(int numStates) { - this.numStates = String.valueOf(numStates); - return this; - } - - // build method to deal with outer class - // to return outer instance - public ListDeviceStatesRequest build() { - return new ListDeviceStatesRequest(this); - } - - } - - public JSONObject getRequestParams() { - return requestParams; - } - - public void setRequestParams(JSONObject requestParams) { - this.requestParams = requestParams; - } - - @SuppressWarnings("unchecked") - @Override - public String toString() { - requestParams = new JSONObject(); - requestParams.put("name", this.name); - requestParams.put("numStates", this.numStates); - this.setRequestParams(requestParams); - return "name=" + this.name + ",numStates=" + this.numStates; - } - - public String getParamsForList() { - String params = ""; - params = "name=" + this.name; - params += "&numStates=" + this.numStates; - - return params; - } + private final String name; + private final String numStates; + JSONObject requestParams; + + private ListDeviceStatesRequest(Builder builder) { + this.name = builder.name; + this.numStates = builder.numStates; + } + + // Static class Builder + public static class Builder { + + /// instance fields + private String name; + private String numStates; + + public static Builder newBuilder() { + return new Builder(); + } + + private Builder() { + } + + // Setter methods + public Builder setName(String name) { + this.name = name; + return this; + } + + public Builder setNumStates(int numStates) { + this.numStates = String.valueOf(numStates); + return this; + } + + // build method to deal with outer class + // to return outer instance + public ListDeviceStatesRequest build() { + return new ListDeviceStatesRequest(this); + } + + } + + public JSONObject getRequestParams() { + return requestParams; + } + + public void setRequestParams(JSONObject requestParams) { + this.requestParams = requestParams; + } + + public DeviceName getName() { + return DeviceName.parse(this.name); + } + + @SuppressWarnings("unchecked") + @Override + public String toString() { + requestParams = new JSONObject(); + requestParams.put("name", this.name); + requestParams.put("numStates", this.numStates); + this.setRequestParams(requestParams); + return "name=" + this.name + ",numStates=" + this.numStates; + } + + public String getParamsForList() { + String params = ""; + params = "name=" + this.name; + params += "&numStates=" + this.numStates; + + return params; + } } diff --git a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/devicetypes/DeviceName.java b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/devicetypes/DeviceName.java index 9174c039..ee1f2c1b 100644 --- a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/devicetypes/DeviceName.java +++ b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/devicetypes/DeviceName.java @@ -30,125 +30,137 @@ package com.clearblade.cloud.iot.v1.devicetypes; +import com.clearblade.cloud.iot.v1.utils.PathTemplate; + +import java.util.Map; + public class DeviceName { - private final String project; - private final String location; - private final String registry; - private final String device; - - protected DeviceName() { - project = null; - location = null; - registry = null; - device = null; - } - - private DeviceName(Builder builder) { - project = builder.getProject(); - location = builder.getLocation(); - registry = builder.getRegistry(); - device = builder.getDevice(); - } - - public String getProject() { - return project; - } - - public String getLocation() { - return location; - } - - public String getRegistry() { - return registry; - } - - public String getDevice() { - return device; - } - - public static Builder newBuilder() { - return new Builder(); - } - - public Builder toBuilder() { - return new Builder(this); - } - - public static DeviceName of(String project, String location, String registry, String device) { - return newBuilder().setProject(project).setLocation(location).setRegistry(registry).setDevice(device).build(); - } - - public static String format(String project, String location, String registry, String device) { - return newBuilder().setProject(project).setLocation(location).setRegistry(registry).setDevice(device).build() - .toString(); - } - - /** - * Builder for - * projects/{project}/locations/{location}/registries/{registry}/devices/{device}. - */ - public static class Builder { - private String project; - private String location; - private String registry; - private String device; - - protected Builder() { - } - - public String getProject() { - return project; - } - - public String getLocation() { - return location; - } - - public String getRegistry() { - return registry; - } - - public String getDevice() { - return device; - } - - public Builder setProject(String project) { - this.project = project; - return this; - } - - public Builder setLocation(String location) { - this.location = location; - return this; - } - - public Builder setRegistry(String registry) { - this.registry = registry; - return this; - } - - public Builder setDevice(String device) { - this.device = device; - return this; - } - - private Builder(DeviceName deviceName) { - this.project = deviceName.project; - this.location = deviceName.location; - this.registry = deviceName.registry; - this.device = deviceName.device; - } - - public DeviceName build() { - return new DeviceName(this); - } - } - - @Override - public String toString() { - - return this.device; - - } + private static final PathTemplate PROJECT_LOCATION_REGISTRY_DEVICE = PathTemplate.createWithoutUrlEncoding("projects/{project}/locations/{location}/registries/{registry}/devices/{device}"); + private final String project; + private final String location; + private final String registry; + private final String device; + + protected DeviceName() { + project = null; + location = null; + registry = null; + device = null; + } + + private DeviceName(Builder builder) { + project = builder.getProject(); + location = builder.getLocation(); + registry = builder.getRegistry(); + device = builder.getDevice(); + } + + public String getProject() { + return project; + } + + public String getLocation() { + return location; + } + + public String getRegistry() { + return registry; + } + + public String getDevice() { + return device; + } + + public static Builder newBuilder() { + return new Builder(); + } + + public Builder toBuilder() { + return new Builder(this); + } + + public static DeviceName of(String project, String location, String registry, String device) { + return newBuilder().setProject(project).setLocation(location).setRegistry(registry).setDevice(device).build(); + } + + public static String format(String project, String location, String registry, String device) { + return newBuilder().setProject(project).setLocation(location).setRegistry(registry).setDevice(device).build() + .toString(); + } + + public static DeviceName parse(String formattedString) { + if (formattedString.isEmpty()) { + return null; + } else { + Map matchMap = PROJECT_LOCATION_REGISTRY_DEVICE.validatedMatch(formattedString, "DeviceName.parse: formattedString not in valid format"); + return of((String) matchMap.get("project"), (String) matchMap.get("location"), (String) matchMap.get("registry"), (String) matchMap.get("device")); + } + } + + /** + * Builder for + * projects/{project}/locations/{location}/registries/{registry}/devices/{device}. + */ + public static class Builder { + private String project; + private String location; + private String registry; + private String device; + + protected Builder() { + } + + public String getProject() { + return project; + } + + public String getLocation() { + return location; + } + + public String getRegistry() { + return registry; + } + + public String getDevice() { + return device; + } + + public Builder setProject(String project) { + this.project = project; + return this; + } + + public Builder setLocation(String location) { + this.location = location; + return this; + } + + public Builder setRegistry(String registry) { + this.registry = registry; + return this; + } + + public Builder setDevice(String device) { + this.device = device; + return this; + } + + private Builder(DeviceName deviceName) { + this.project = deviceName.project; + this.location = deviceName.location; + this.registry = deviceName.registry; + this.device = deviceName.device; + } + + public DeviceName build() { + return new DeviceName(this); + } + } + + @Override + public String toString() { + return PROJECT_LOCATION_REGISTRY_DEVICE.instantiate(new String[]{"project", this.project, "location", this.location, "registry", this.registry, "device", this.device}); + } } diff --git a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/getdevice/GetDeviceRequest.java b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/getdevice/GetDeviceRequest.java index 41a02c8a..d42fafec 100644 --- a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/getdevice/GetDeviceRequest.java +++ b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/getdevice/GetDeviceRequest.java @@ -35,62 +35,66 @@ public class GetDeviceRequest { - private final DeviceName name; - private final FieldMask fieldMask; - - private GetDeviceRequest(Builder builder) { - this.name = builder.name; - this.fieldMask = builder.fieldMask; - } - - // Static class Builder - public static class Builder { - - /// instance fields - private DeviceName name; - private FieldMask fieldMask; - - public static Builder newBuilder() { - return new Builder(); - } - - private Builder() { - } - - // Setter methods - public FieldMask getFieldMask() { - return fieldMask; - } - - public Builder setFieldMask(FieldMask fieldMask) { - this.fieldMask = fieldMask; - return this; - } - - public DeviceName getName() { - return name; - } - - public Builder setName(DeviceName name) { - this.name = name; - return this; - } - - // build method to deal with outer class - // to return outer instance - public GetDeviceRequest build() { - return new GetDeviceRequest(this); - } - } - - @Override - public String toString() { - String params = ""; - params = "name=" + this.name.toString(); - if (this.fieldMask.toString() != "") { - params += "&fieldMask=" + this.fieldMask.toString(); - } - return params; - } + private final DeviceName name; + private final FieldMask fieldMask; + + private GetDeviceRequest(Builder builder) { + this.name = builder.name; + this.fieldMask = builder.fieldMask; + } + + // Static class Builder + public static class Builder { + + /// instance fields + private DeviceName name; + private FieldMask fieldMask; + + public static Builder newBuilder() { + return new Builder(); + } + + private Builder() { + } + + // Setter methods + public FieldMask getFieldMask() { + return fieldMask; + } + + public Builder setFieldMask(FieldMask fieldMask) { + this.fieldMask = fieldMask; + return this; + } + + public DeviceName getName() { + return name; + } + + public Builder setName(DeviceName name) { + this.name = name; + return this; + } + + // build method to deal with outer class + // to return outer instance + public GetDeviceRequest build() { + return new GetDeviceRequest(this); + } + } + + public DeviceName getName() { + return this.name; + } + + @Override + public String toString() { + String params = ""; + params = "name=" + this.name.toString(); + if (this.fieldMask.toString() != "") { + params += "&fieldMask=" + this.fieldMask.toString(); + } + return params; + } } diff --git a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/getdeviceregistry/GetDeviceRegistryRequest.java b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/getdeviceregistry/GetDeviceRegistryRequest.java index f712e7fd..2ab4c9e8 100644 --- a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/getdeviceregistry/GetDeviceRegistryRequest.java +++ b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/getdeviceregistry/GetDeviceRegistryRequest.java @@ -30,43 +30,49 @@ package com.clearblade.cloud.iot.v1.getdeviceregistry; +import com.clearblade.cloud.iot.v1.registrytypes.RegistryName; + public class GetDeviceRegistryRequest { - - private final String name; - private GetDeviceRegistryRequest(Builder builder) { - this.name = builder.name; - } - - // Static class Builder - public static class Builder { + private final String name; + + private GetDeviceRegistryRequest(Builder builder) { + this.name = builder.name; + } + + // Static class Builder + public static class Builder { + + /// instance fields + private String name; - /// instance fields - private String name; + public static Builder newBuilder() { + return new Builder(); + } - public static Builder newBuilder() { - return new Builder(); - } + private Builder() { + } - private Builder() { - } + // Setter methods + public Builder setName(String name) { + this.name = name; + return this; + } - // Setter methods - public Builder setName(String name) { - this.name = name; - return this; - } + // build method to deal with outer class + // to return outer instance + public GetDeviceRegistryRequest build() { + return new GetDeviceRegistryRequest(this); + } + } - // build method to deal with outer class - // to return outer instance - public GetDeviceRegistryRequest build() { - return new GetDeviceRegistryRequest(this); - } - } + public RegistryName getName() { + return RegistryName.parse(this.name); + } - @Override - public String toString() { - return "name="+this.name; - } + @Override + public String toString() { + return "name=" + this.name; + } } diff --git a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/listdeviceconfigversions/ListDeviceConfigVersionsRequest.java b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/listdeviceconfigversions/ListDeviceConfigVersionsRequest.java index 35248520..999c6783 100644 --- a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/listdeviceconfigversions/ListDeviceConfigVersionsRequest.java +++ b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/listdeviceconfigversions/ListDeviceConfigVersionsRequest.java @@ -30,74 +30,80 @@ package com.clearblade.cloud.iot.v1.listdeviceconfigversions; +import com.clearblade.cloud.iot.v1.devicetypes.DeviceName; +import com.clearblade.cloud.iot.v1.registrytypes.LocationName; import org.json.simple.JSONObject; public class ListDeviceConfigVersionsRequest { - private final String name; - private final String numVersions; - JSONObject requestParams; - - private ListDeviceConfigVersionsRequest(Builder builder) { - this.name = builder.name; - this.numVersions = builder.numVersions; - } - - // Static class Builder - public static class Builder { - - /// instance fields - private String name; - private String numVersions; - - public static Builder newBuilder() { - return new Builder(); - } - - private Builder() { - } - - // Setter methods - public Builder setName(String name) { - this.name = name; - return this; - } - - public Builder setNumVersions(int numVersions) { - this.numVersions = String.valueOf(numVersions); - return this; - } - - // build method to deal with outer class - // to return outer instance - public ListDeviceConfigVersionsRequest build() { - return new ListDeviceConfigVersionsRequest(this); - } - - } - - public JSONObject getRequestParams() { - return requestParams; - } - - public void setRequestParams(JSONObject requestParams) { - this.requestParams = requestParams; - } - - @SuppressWarnings("unchecked") - @Override - public String toString() { - requestParams = new JSONObject(); - requestParams.put("name", this.name); - requestParams.put("numVersions", this.numVersions); - this.setRequestParams(requestParams); - return "name=" + this.name + ",numVersions=" + this.numVersions; - } - - public String getParamsForList() { - String params = ""; - params = "name=" + this.name; - params += "&numVersions=" + this.numVersions; - - return params; - } + private final String name; + private final String numVersions; + JSONObject requestParams; + + private ListDeviceConfigVersionsRequest(Builder builder) { + this.name = builder.name; + this.numVersions = builder.numVersions; + } + + // Static class Builder + public static class Builder { + + /// instance fields + private String name; + private String numVersions; + + public static Builder newBuilder() { + return new Builder(); + } + + private Builder() { + } + + // Setter methods + public Builder setName(String name) { + this.name = name; + return this; + } + + public Builder setNumVersions(int numVersions) { + this.numVersions = String.valueOf(numVersions); + return this; + } + + // build method to deal with outer class + // to return outer instance + public ListDeviceConfigVersionsRequest build() { + return new ListDeviceConfigVersionsRequest(this); + } + + } + + public JSONObject getRequestParams() { + return requestParams; + } + + public void setRequestParams(JSONObject requestParams) { + this.requestParams = requestParams; + } + + public DeviceName getName() { + return DeviceName.parse(this.name); + } + + @SuppressWarnings("unchecked") + @Override + public String toString() { + requestParams = new JSONObject(); + requestParams.put("name", this.name); + requestParams.put("numVersions", this.numVersions); + this.setRequestParams(requestParams); + return "name=" + this.name + ",numVersions=" + this.numVersions; + } + + public String getParamsForList() { + String params = ""; + params = "name=" + this.name; + params += "&numVersions=" + this.numVersions; + + return params; + } } diff --git a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/listdeviceregistries/ListDeviceRegistriesRequest.java b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/listdeviceregistries/ListDeviceRegistriesRequest.java index 153bac1c..14b50981 100644 --- a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/listdeviceregistries/ListDeviceRegistriesRequest.java +++ b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/listdeviceregistries/ListDeviceRegistriesRequest.java @@ -30,72 +30,81 @@ package com.clearblade.cloud.iot.v1.listdeviceregistries; +import com.clearblade.cloud.iot.v1.devicetypes.DeviceName; +import com.clearblade.cloud.iot.v1.registrytypes.LocationName; + +import java.util.Locale; + public class ListDeviceRegistriesRequest { - - private String parent; - private int pageSize = -1; - private String pageToken; - - private ListDeviceRegistriesRequest(Builder builder) { - - this.parent = builder.parent; - this.pageSize = builder.pageSize; - this.pageToken = builder.pageToken; - } - - // Static class Builder - public static class Builder { - - /// instance fields - private String parent; - private int pageSize; - private String pageToken; - - public static Builder newBuilder() { - return new Builder(); - } - - private Builder() { - } - - // Setter methods - public Builder setParent(String parent) { - this.parent = parent; - return this; - } - - public Builder setPageSize(int pageSize) { - this.pageSize = pageSize; - return this; - } - - public Builder setPageToken(String pageToken) { - this.pageToken = pageToken; - return this; - } - - // build method to deal with outer class - // to return outer instance - public ListDeviceRegistriesRequest build() { - return new ListDeviceRegistriesRequest(this); - } - - } - - @Override - public String toString() { - return this.parent.toString(); - } - - public String getParamsForList() { - String params = ""; - params = "parent=" + this.parent; - if (this.pageSize > 0) - params += "&pageSize=" + String.valueOf(this.pageSize); - if (this.pageToken != null) - params += "&pageToken=" + this.pageToken; - return params; - } + + private String parent; + private int pageSize = -1; + private String pageToken; + + private ListDeviceRegistriesRequest(Builder builder) { + + this.parent = builder.parent; + this.pageSize = builder.pageSize; + this.pageToken = builder.pageToken; + } + + // Static class Builder + public static class Builder { + + /// instance fields + private String parent; + private int pageSize; + private String pageToken; + + public static Builder newBuilder() { + return new Builder(); + } + + private Builder() { + } + + // Setter methods + public Builder setParent(String parent) { + this.parent = parent; + return this; + } + + public Builder setPageSize(int pageSize) { + this.pageSize = pageSize; + return this; + } + + public Builder setPageToken(String pageToken) { + this.pageToken = pageToken; + return this; + } + + // build method to deal with outer class + // to return outer instance + public ListDeviceRegistriesRequest build() { + return new ListDeviceRegistriesRequest(this); + } + + } + + public LocationName getParent() { + return LocationName.parse(this.parent); + } + + @Override + public String toString() { + return this.parent.toString(); + } + + public String getParamsForList() { + String params = ""; + params = "parent=" + this.parent; + if (this.pageSize > 0) + params += "&pageSize=" + String.valueOf(this.pageSize); + if (this.pageToken != null) + params += "&pageToken=" + this.pageToken; + return params; + } } diff --git a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/modifycloudtodeviceconfig/ModifyCloudToDeviceConfigRequest.java b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/modifycloudtodeviceconfig/ModifyCloudToDeviceConfigRequest.java index f03c3af6..61324ac5 100644 --- a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/modifycloudtodeviceconfig/ModifyCloudToDeviceConfigRequest.java +++ b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/modifycloudtodeviceconfig/ModifyCloudToDeviceConfigRequest.java @@ -32,93 +32,99 @@ import java.util.Arrays; +import com.clearblade.cloud.iot.v1.devicetypes.DeviceName; +import com.clearblade.cloud.iot.v1.registrytypes.LocationName; import org.json.simple.JSONObject; import com.clearblade.cloud.iot.v1.utils.ByteString; public class ModifyCloudToDeviceConfigRequest { - private String deviceName; - private String versionToUpdate; - private ByteString binaryData; - private byte[] binaryDataByte; - - private ModifyCloudToDeviceConfigRequest(Builder builder) { - this.deviceName = builder.deviceName; - this.versionToUpdate = builder.versionToUpdate; - this.binaryData = builder.binaryData; - this.binaryDataByte = builder.binaryDataByte; - } - - // Static class Builder - public static class Builder { - - /// instance fields - private String deviceName; - private String versionToUpdate; - private ByteString binaryData; - private byte[] binaryDataByte; - - public static Builder newBuilder() { - return new Builder(); - } - - private Builder() { - } - - // Setter methods - public Builder setName(String deviceName) { - this.deviceName = deviceName; - return this; - } - - public Builder setVersionToUpdate(String versionToUpdate) { - this.versionToUpdate = versionToUpdate; - return this; - } - - public Builder setBinaryData(ByteString binaryData) { - this.binaryData = binaryData; - return this; - } - - public Builder setBinaryData(byte[] binaryDataByte) { - this.binaryDataByte = binaryDataByte; - return this; - } - - // build method to deal with outer class - // to return outer instance - public ModifyCloudToDeviceConfigRequest build() { - return new ModifyCloudToDeviceConfigRequest(this); - } - } - - @Override - public String toString() { - return "name = " + this.deviceName + ", versionToUpdate = " + this.versionToUpdate; - } - - @SuppressWarnings("unchecked") - public String[] getBodyAndParams() { - String[] output = new String[2]; - String params = "name=" + this.deviceName + "&method=modifyCloudToDeviceConfig"; - String bData = "EMPTY"; - if (this.binaryData != null) { - bData = new String(this.binaryData.toByteArray()); - } else if (this.binaryDataByte != null) { - if (this.binaryDataByte.length == 0) { - bData = "EMPTY"; - } else { - bData = Arrays.toString(this.binaryDataByte); - } - } - JSONObject bodyParams = new JSONObject(); - bodyParams.put("binaryData", bData); - bodyParams.put("versionToUpdate", this.versionToUpdate); - - output[0] = params; - output[1] = bodyParams.toJSONString(); - return output; - } + private String deviceName; + private String versionToUpdate; + private ByteString binaryData; + private byte[] binaryDataByte; + + private ModifyCloudToDeviceConfigRequest(Builder builder) { + this.deviceName = builder.deviceName; + this.versionToUpdate = builder.versionToUpdate; + this.binaryData = builder.binaryData; + this.binaryDataByte = builder.binaryDataByte; + } + + // Static class Builder + public static class Builder { + + /// instance fields + private String deviceName; + private String versionToUpdate; + private ByteString binaryData; + private byte[] binaryDataByte; + + public static Builder newBuilder() { + return new Builder(); + } + + private Builder() { + } + + // Setter methods + public Builder setName(String deviceName) { + this.deviceName = deviceName; + return this; + } + + public Builder setVersionToUpdate(String versionToUpdate) { + this.versionToUpdate = versionToUpdate; + return this; + } + + public Builder setBinaryData(ByteString binaryData) { + this.binaryData = binaryData; + return this; + } + + public Builder setBinaryData(byte[] binaryDataByte) { + this.binaryDataByte = binaryDataByte; + return this; + } + + // build method to deal with outer class + // to return outer instance + public ModifyCloudToDeviceConfigRequest build() { + return new ModifyCloudToDeviceConfigRequest(this); + } + } + + public DeviceName getDeviceName() { + return DeviceName.parse(this.deviceName); + } + + @Override + public String toString() { + return "name = " + this.deviceName + ", versionToUpdate = " + this.versionToUpdate; + } + + @SuppressWarnings("unchecked") + public String[] getBodyAndParams() { + String[] output = new String[2]; + String params = "name=" + this.deviceName + "&method=modifyCloudToDeviceConfig"; + String bData = "EMPTY"; + if (this.binaryData != null) { + bData = new String(this.binaryData.toByteArray()); + } else if (this.binaryDataByte != null) { + if (this.binaryDataByte.length == 0) { + bData = "EMPTY"; + } else { + bData = Arrays.toString(this.binaryDataByte); + } + } + JSONObject bodyParams = new JSONObject(); + bodyParams.put("binaryData", bData); + bodyParams.put("versionToUpdate", this.versionToUpdate); + + output[0] = params; + output[1] = bodyParams.toJSONString(); + return output; + } } diff --git a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/registrytypes/LocationName.java b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/registrytypes/LocationName.java index 0d45f528..e3d4530f 100644 --- a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/registrytypes/LocationName.java +++ b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/registrytypes/LocationName.java @@ -30,91 +30,107 @@ package com.clearblade.cloud.iot.v1.registrytypes; +import com.clearblade.cloud.iot.v1.utils.PathTemplate; + +import java.util.Map; + public class LocationName { - private final String project; - private final String location; - - protected LocationName() { - project = null; - location = null; - } - - private LocationName(Builder builder) { - project = builder.getProject(); - location = builder.getLocation(); - } - - public String getProject() { - return project; - } - - public String getLocation() { - return location; - } - - public static Builder newBuilder() { - return new Builder(); - } - - public Builder toBuilder() { - return new Builder(this); - } - - public static LocationName of(String project, String location) { - return newBuilder().setProject(project).setLocation(location).build(); - } - - public static String format(String project, String location) { - return newBuilder().setProject(project).setLocation(location).build() - .toString(); - } - - /** - * Builder for - * projects/{project}/locations/{location}/registries/{registry}. - */ - public static class Builder { - private String project; - private String location; - - protected Builder() { - } - - public String getProject() { - return project; - } - - public String getLocation() { - return location; - } - - public Builder setProject(String project) { - this.project = project; - return this; - } - - public Builder setLocation(String location) { - this.location = location; - return this; - } - - private Builder(LocationName locationName) { - this.project = locationName.project; - this.location = locationName.location; - } - - public LocationName build() { - return new LocationName(this); - } - } - - @Override - public String toString() { - return "projects/" + this.getProject() + "/locations/" + this.getLocation(); - } - - public String getLocationFullName() { - return "projects/" + this.getProject() + "/locations/" + this.getLocation(); - } + private static final PathTemplate PROJECT_LOCATION = PathTemplate.createWithoutUrlEncoding("projects/{project}/locations/{location}"); + + private final String project; + private final String location; + + protected LocationName() { + project = null; + location = null; + } + + private LocationName(Builder builder) { + project = builder.getProject(); + location = builder.getLocation(); + } + + public String getProject() { + return project; + } + + public String getLocation() { + return location; + } + + public static Builder newBuilder() { + return new Builder(); + } + + public Builder toBuilder() { + return new Builder(this); + } + + public static LocationName of(String project, String location) { + return newBuilder().setProject(project).setLocation(location).build(); + } + + public static String format(String project, String location) { + return newBuilder().setProject(project).setLocation(location).build() + .toString(); + } + + public static LocationName parse(String formattedString) { + if (formattedString.isEmpty()) { + return null; + } else { + Map matchMap = PROJECT_LOCATION.validatedMatch(formattedString, "LocationName.parse: formattedString not in valid format"); + return of((String) matchMap.get("project"), (String) matchMap.get("location")); + } + } + + + /** + * Builder for + * projects/{project}/locations/{location}/registries/{registry}. + */ + public static class Builder { + private String project; + private String location; + + protected Builder() { + } + + public String getProject() { + return project; + } + + public String getLocation() { + return location; + } + + public Builder setProject(String project) { + this.project = project; + return this; + } + + public Builder setLocation(String location) { + this.location = location; + return this; + } + + private Builder(LocationName locationName) { + this.project = locationName.project; + this.location = locationName.location; + } + + public LocationName build() { + return new LocationName(this); + } + } + + @Override + public String toString() { + return PROJECT_LOCATION.instantiate(new String[]{"project", this.project, "location", this.location}); + } + + public String getLocationFullName() { + return PROJECT_LOCATION.instantiate(new String[]{"project", this.project, "location", this.location}); + } } diff --git a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/registrytypes/RegistryName.java b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/registrytypes/RegistryName.java index a01b0a33..7093368f 100644 --- a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/registrytypes/RegistryName.java +++ b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/registrytypes/RegistryName.java @@ -30,110 +30,123 @@ package com.clearblade.cloud.iot.v1.registrytypes; +import com.clearblade.cloud.iot.v1.utils.PathTemplate; + +import java.util.Map; + public class RegistryName { - private final String project; - private final String location; - private final String registry; - - protected RegistryName() { - project = null; - location = null; - registry = null; - } - - private RegistryName(Builder builder) { - project = builder.getProject(); - location = builder.getLocation(); - registry = builder.getRegistry(); - } - - public String getProject() { - return project; - } - - public String getLocation() { - return location; - } - - public String getRegistry() { - return registry; - } - - public static Builder newBuilder() { - return new Builder(); - } - - public Builder toBuilder() { - return new Builder(this); - } - - public static RegistryName of(String project, String location, String registry) { - return newBuilder().setProject(project).setLocation(location).setRegistry(registry).build(); - } - - public static String format(String project, String location, String registry) { - return newBuilder().setProject(project).setLocation(location).setRegistry(registry).build() - .toString(); - } - - /** - * Builder for - * projects/{project}/locations/{location}/registries/{registry}. - */ - public static class Builder { - private String project; - private String location; - private String registry; - - protected Builder() { - } - - public String getProject() { - return project; - } - - public String getLocation() { - return location; - } - - public String getRegistry() { - return registry; - } - - public Builder setProject(String project) { - this.project = project; - return this; - } - - public Builder setLocation(String location) { - this.location = location; - return this; - } - - public Builder setRegistry(String registry) { - this.registry = registry; - return this; - } - - private Builder(RegistryName registryName) { - this.project = registryName.project; - this.location = registryName.location; - this.registry = registryName.registry; - } - - public RegistryName build() { - return new RegistryName(this); - } - } - - @Override - public String toString() { - return "projects/" + this.getProject() + "/locations/" + this.getLocation(); - } - - public String getRegistryFullName() { - return "projects/" + this.getProject() + "/locations/" + this.getLocation() + "/registries/" - + this.getRegistry(); - } + private static final PathTemplate PROJECT_LOCATION_REGISTRY = PathTemplate.createWithoutUrlEncoding("projects/{project}/locations/{location}/registries/{registry}"); + private final String project; + private final String location; + private final String registry; + + protected RegistryName() { + project = null; + location = null; + registry = null; + } + + private RegistryName(Builder builder) { + project = builder.getProject(); + location = builder.getLocation(); + registry = builder.getRegistry(); + } + + public String getProject() { + return project; + } + + public String getLocation() { + return location; + } + + public String getRegistry() { + return registry; + } + + public static Builder newBuilder() { + return new Builder(); + } + + public Builder toBuilder() { + return new Builder(this); + } + + public static RegistryName of(String project, String location, String registry) { + return newBuilder().setProject(project).setLocation(location).setRegistry(registry).build(); + } + + public static String format(String project, String location, String registry) { + return newBuilder().setProject(project).setLocation(location).setRegistry(registry).build() + .toString(); + } + + /** + * Builder for + * projects/{project}/locations/{location}/registries/{registry}. + */ + public static class Builder { + private String project; + private String location; + private String registry; + + protected Builder() { + } + + public String getProject() { + return project; + } + + public String getLocation() { + return location; + } + + public String getRegistry() { + return registry; + } + + public Builder setProject(String project) { + this.project = project; + return this; + } + + public Builder setLocation(String location) { + this.location = location; + return this; + } + + public Builder setRegistry(String registry) { + this.registry = registry; + return this; + } + + private Builder(RegistryName registryName) { + this.project = registryName.project; + this.location = registryName.location; + this.registry = registryName.registry; + } + + public RegistryName build() { + return new RegistryName(this); + } + } + + @Override + public String toString() { + return PROJECT_LOCATION_REGISTRY.instantiate(new String[]{"project", this.project, "location", this.location, "registry", this.registry}); + } + + public static RegistryName parse(String formattedString) { + if (formattedString.isEmpty()) { + return null; + } else { + Map matchMap = PROJECT_LOCATION_REGISTRY.validatedMatch(formattedString, "RegistryName.parse: formattedString not in valid format"); + return of((String) matchMap.get("project"), (String) matchMap.get("location"), (String) matchMap.get("registry")); + } + } + + public String getRegistryFullName() { + return PROJECT_LOCATION_REGISTRY.instantiate(new String[]{"project", this.project, "location", this.location, "registry", this.registry}); + } } diff --git a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/sendcommandtodevice/SendCommandToDeviceRequest.java b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/sendcommandtodevice/SendCommandToDeviceRequest.java index 115bab46..6e98eb78 100644 --- a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/sendcommandtodevice/SendCommandToDeviceRequest.java +++ b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/sendcommandtodevice/SendCommandToDeviceRequest.java @@ -39,126 +39,134 @@ public class SendCommandToDeviceRequest { - private final DeviceName name; - private final ByteString binaryData; - private final byte[] binaryDataByte; - private final String subfolder; - private final String deviceName; - public JSONObject requestParams; - public JSONObject bodyParams; - - private SendCommandToDeviceRequest(Builder builder) { - this.name = builder.name; - this.binaryData = builder.binaryData; - this.subfolder = builder.subfolder; - this.binaryDataByte = builder.binaryDataByte; - this.deviceName = builder.deviceName; - } - - // Static class Builder - public static class Builder { - - /// instance fields - private DeviceName name; - private ByteString binaryData; - private String subfolder; - private byte[] binaryDataByte; - private String deviceName; - - public static Builder newBuilder() { - return new Builder(); - } - - private Builder() { - } - - // Setter methods - public Builder setName(DeviceName name) { - this.name = name; - return this; - } - - public Builder setBinaryData(ByteString binaryData) { - this.binaryData = binaryData; - return this; - } - - public Builder setBinaryDataByte(byte[] binaryDataByte) { - this.binaryDataByte = binaryDataByte; - return this; - } - - public Builder setSubfolder(String subfolder) { - this.subfolder = subfolder; - return this; - } - - public Builder setName(String deviceName) { - this.deviceName = deviceName; - return this; - } - - // build method to deal with outer class - // to return outer instance - public SendCommandToDeviceRequest build() { - return new SendCommandToDeviceRequest(this); - } - } - - @SuppressWarnings("unchecked") - @Override - public String toString() { - requestParams = new JSONObject(); - bodyParams = new JSONObject(); - - String dName = ""; - String bData = null; - - if (this.name != null) { - dName = this.name.getDevice(); - } else if (this.deviceName != null) { - dName = this.deviceName; - } - if (this.binaryData != null) { - bData = new String(this.binaryData.toByteArray()); - } else if (this.binaryDataByte != null) { - if (this.binaryDataByte.length == 0) { - bData = "EMPTY"; - } else { - bData = Arrays.toString(this.binaryDataByte); - } - } - - requestParams.put("name", dName); - bodyParams.put("binaryData", bData); - bodyParams.put("subfolder", subfolder); - - return "name = " + dName + ", binaryData = " + bData + ", subfolder = " + subfolder; - - } - - @SuppressWarnings("unchecked") - public String[] getBodyAndParams() { - String[] output = new String[2]; - String params = "name=" + this.deviceName + "&method=sendCommandToDevice"; - String bData = null; - if (this.binaryData != null) { - bData = new String(this.binaryData.toByteArray()); - } else if (this.binaryDataByte != null) { - if (this.binaryDataByte.length == 0) { - bData = "EMPTY"; - } else { - bData = Arrays.toString(this.binaryDataByte); - } - } - bodyParams = new JSONObject(); - bodyParams.put("binaryData", bData); - if (this.subfolder != null) { - bodyParams.put("subfolder", this.subfolder); - } - - output[0] = params; - output[1] = bodyParams.toJSONString(); - return output; - } + private final DeviceName name; + private final ByteString binaryData; + private final byte[] binaryDataByte; + private final String subfolder; + private final String deviceName; + public JSONObject requestParams; + public JSONObject bodyParams; + + private SendCommandToDeviceRequest(Builder builder) { + this.name = builder.name; + this.binaryData = builder.binaryData; + this.subfolder = builder.subfolder; + this.binaryDataByte = builder.binaryDataByte; + this.deviceName = builder.deviceName; + } + + // Static class Builder + public static class Builder { + + /// instance fields + private DeviceName name; + private ByteString binaryData; + private String subfolder; + private byte[] binaryDataByte; + private String deviceName; + + public static Builder newBuilder() { + return new Builder(); + } + + private Builder() { + } + + // Setter methods + public Builder setName(DeviceName name) { + this.name = name; + return this; + } + + public Builder setBinaryData(ByteString binaryData) { + this.binaryData = binaryData; + return this; + } + + public Builder setBinaryDataByte(byte[] binaryDataByte) { + this.binaryDataByte = binaryDataByte; + return this; + } + + public Builder setSubfolder(String subfolder) { + this.subfolder = subfolder; + return this; + } + + public Builder setName(String deviceName) { + this.deviceName = deviceName; + return this; + } + + // build method to deal with outer class + // to return outer instance + public SendCommandToDeviceRequest build() { + return new SendCommandToDeviceRequest(this); + } + } + + public DeviceName getDeviceName() { + if (name != null) { + return name; + } else { + return DeviceName.parse(this.deviceName); + } + } + + @SuppressWarnings("unchecked") + @Override + public String toString() { + requestParams = new JSONObject(); + bodyParams = new JSONObject(); + + String dName = ""; + String bData = null; + + if (this.name != null) { + dName = this.name.getDevice(); + } else if (this.deviceName != null) { + dName = this.deviceName; + } + if (this.binaryData != null) { + bData = new String(this.binaryData.toByteArray()); + } else if (this.binaryDataByte != null) { + if (this.binaryDataByte.length == 0) { + bData = "EMPTY"; + } else { + bData = Arrays.toString(this.binaryDataByte); + } + } + + requestParams.put("name", dName); + bodyParams.put("binaryData", bData); + bodyParams.put("subfolder", subfolder); + + return "name = " + dName + ", binaryData = " + bData + ", subfolder = " + subfolder; + + } + + @SuppressWarnings("unchecked") + public String[] getBodyAndParams() { + String[] output = new String[2]; + String params = "name=" + this.deviceName + "&method=sendCommandToDevice"; + String bData = null; + if (this.binaryData != null) { + bData = new String(this.binaryData.toByteArray()); + } else if (this.binaryDataByte != null) { + if (this.binaryDataByte.length == 0) { + bData = "EMPTY"; + } else { + bData = Arrays.toString(this.binaryDataByte); + } + } + bodyParams = new JSONObject(); + bodyParams.put("binaryData", bData); + if (this.subfolder != null) { + bodyParams.put("subfolder", this.subfolder); + } + + output[0] = params; + output[1] = bodyParams.toJSONString(); + return output; + } } diff --git a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/unbinddevicefromgateway/UnbindDeviceFromGatewayRequest.java b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/unbinddevicefromgateway/UnbindDeviceFromGatewayRequest.java index 38319ec8..e6f52068 100644 --- a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/unbinddevicefromgateway/UnbindDeviceFromGatewayRequest.java +++ b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/unbinddevicefromgateway/UnbindDeviceFromGatewayRequest.java @@ -30,104 +30,111 @@ package com.clearblade.cloud.iot.v1.unbinddevicefromgateway; +import com.clearblade.cloud.iot.v1.devicetypes.DeviceName; +import com.clearblade.cloud.iot.v1.registrytypes.RegistryName; import org.json.simple.JSONObject; public class UnbindDeviceFromGatewayRequest { - private final String parent; - private final String gateway; - private final String device; - JSONObject requestParams; - JSONObject bodyParams; - - private UnbindDeviceFromGatewayRequest(Builder builder) { - this.parent = builder.parent; - this.gateway = builder.gateway; - this.device = builder.device; - } - - // Static class Builder - public static class Builder { - - /// instance fields - private String parent; - private String gateway; - private String device; - - public static Builder newBuilder() { - return new Builder(); - } - - private Builder() { - } - - // Setter methods - public Builder setParent(String parent) { - this.parent = parent; - return this; - } - - public Builder setGateway(String gateway) { - this.gateway = gateway; - return this; - } - - public Builder setDevice(String device) { - this.device = device; - return this; - } - - // build method to deal with outer class - // to return outer instance - public UnbindDeviceFromGatewayRequest build() { - return new UnbindDeviceFromGatewayRequest(this); - } - } - - public JSONObject getRequestParams() { - return requestParams; - } - - public void setRequestParams(JSONObject requestParams) { - this.requestParams = requestParams; - } - - public JSONObject getBodyParams() { - return bodyParams; - } - - public void setBodyParams(JSONObject bodyParams) { - this.bodyParams = bodyParams; - } - - @SuppressWarnings("unchecked") - @Override - public String toString() { - - requestParams = new JSONObject(); - bodyParams = new JSONObject(); - requestParams.put("method", "unbindDeviceFromGateway"); - requestParams.put("parent", this.parent); - - bodyParams.put("gatewayId", this.gateway); - bodyParams.put("deviceId", this.device); - - this.setRequestParams(requestParams); - this.setBodyParams(bodyParams); - - return "parent=" + this.parent + ",gateway=" + this.gateway + ", device= " + this.device; - } - - @SuppressWarnings("unchecked") - public String[] getBodyAndParams() { - String[] output = new String[2]; - String params = "parent=" + this.parent + "&method=unbindDeviceFromGateway"; - bodyParams = new JSONObject(); - bodyParams.put("gatewayId", this.gateway); - bodyParams.put("deviceId", this.device); - - output[0] = params; - output[1] = bodyParams.toJSONString(); - return output; - } + private final String parent; + private final String gateway; + private final String device; + JSONObject requestParams; + JSONObject bodyParams; + + private UnbindDeviceFromGatewayRequest(Builder builder) { + this.parent = builder.parent; + this.gateway = builder.gateway; + this.device = builder.device; + } + + // Static class Builder + public static class Builder { + + /// instance fields + private String parent; + private String gateway; + private String device; + + public static Builder newBuilder() { + return new Builder(); + } + + private Builder() { + } + + // Setter methods + public Builder setParent(String parent) { + this.parent = parent; + return this; + } + + public Builder setGateway(String gateway) { + this.gateway = gateway; + return this; + } + + public Builder setDevice(String device) { + this.device = device; + return this; + } + + // build method to deal with outer class + // to return outer instance + public UnbindDeviceFromGatewayRequest build() { + return new UnbindDeviceFromGatewayRequest(this); + } + } + + public RegistryName getParent() { + return RegistryName.parse(this.parent); + } + + + public JSONObject getRequestParams() { + return requestParams; + } + + public void setRequestParams(JSONObject requestParams) { + this.requestParams = requestParams; + } + + public JSONObject getBodyParams() { + return bodyParams; + } + + public void setBodyParams(JSONObject bodyParams) { + this.bodyParams = bodyParams; + } + + @SuppressWarnings("unchecked") + @Override + public String toString() { + + requestParams = new JSONObject(); + bodyParams = new JSONObject(); + requestParams.put("method", "unbindDeviceFromGateway"); + requestParams.put("parent", this.parent); + + bodyParams.put("gatewayId", this.gateway); + bodyParams.put("deviceId", this.device); + + this.setRequestParams(requestParams); + this.setBodyParams(bodyParams); + + return "parent=" + this.parent + ",gateway=" + this.gateway + ", device= " + this.device; + } + + @SuppressWarnings("unchecked") + public String[] getBodyAndParams() { + String[] output = new String[2]; + String params = "parent=" + this.parent + "&method=unbindDeviceFromGateway"; + bodyParams = new JSONObject(); + bodyParams.put("gatewayId", this.gateway); + bodyParams.put("deviceId", this.device); + + output[0] = params; + output[1] = bodyParams.toJSONString(); + return output; + } } diff --git a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/updatedevice/UpdateDeviceRequest.java b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/updatedevice/UpdateDeviceRequest.java index 8ae9fb9b..2d165bc7 100644 --- a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/updatedevice/UpdateDeviceRequest.java +++ b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/updatedevice/UpdateDeviceRequest.java @@ -34,6 +34,7 @@ import java.util.Iterator; import java.util.List; +import com.clearblade.cloud.iot.v1.devicetypes.DeviceName; import org.json.simple.JSONArray; import org.json.simple.JSONObject; @@ -41,114 +42,118 @@ import com.clearblade.cloud.iot.v1.devicetypes.DeviceCredential; public class UpdateDeviceRequest { - private final String name; - private final Device device; - private final String updateMask; - JSONObject requestParams; - JSONObject bodyParams; - - private UpdateDeviceRequest(Builder builder) { - this.name = builder.name; - this.updateMask = builder.updateMask; - this.device = builder.device; - } - - public JSONObject getRequestParams() { - return requestParams; - } - - public void setRequestParams(JSONObject requestParams) { - this.requestParams = requestParams; - } - - public JSONObject getBodyParams() { - return bodyParams; - } - - public void setBodyParams(JSONObject bodyParams) { - this.bodyParams = bodyParams; - } - - // Static class Builder - public static class Builder { - - /// instance fields - private String name; - private Device device; - private String updateMask; - - public static Builder newBuilder() { - return new Builder(); - } - - private Builder() { - } - - // Setter methods - public Builder setName(String name) { - this.name = name; - return this; - } - - public Builder setDevice(Device device) { - this.device = device; - return this; - } - - public Builder setUpdateMask(String updateMask) { - this.updateMask = updateMask; - return this; - } - - // build method to deal with outer class - // to return outer instance - public UpdateDeviceRequest build() { - return new UpdateDeviceRequest(this); - } - } - - @SuppressWarnings("unchecked") - @Override - public String toString() { - requestParams.put("name", this.name); - requestParams.put("updateMask", this.updateMask); - - bodyParams.put("id", this.device.toBuilder().getId()); - bodyParams.put("name", this.device.toBuilder().getName()); - bodyParams.put("logLevel", this.device.toBuilder().getLogLevel()); - bodyParams.put("blocked", this.device.toBuilder().isBlocked()); - - return "name=" + this.name + ",updateMask=" + this.updateMask + ", logLevel= " - + this.device.toBuilder().getLogLevel(); - } - - @SuppressWarnings("unchecked") - public String[] getBodyAndParams() { - String[] output = new String[2]; - - String params = "name=" + this.name + "&updateMask=" + this.updateMask; - bodyParams = new JSONObject(); - - bodyParams.put("id", this.device.toBuilder().getId()); - bodyParams.put("name", this.device.toBuilder().getName()); - if (this.device.toBuilder().getLogLevel() != null) { - bodyParams.put("logLevel", this.device.toBuilder().getLogLevel().toString()); - } - bodyParams.put("blocked", this.device.toBuilder().isBlocked()); - if (this.device.toBuilder().getCredentials().size() > 0) { - JSONArray jsonArray = new JSONArray(); - for (int i = 0; i < this.device.toBuilder().getCredentials().size(); i++) { - if (!this.device.toBuilder().getCredentials().get(i).isEmpty()) { - DeviceCredential credentialObj = this.device.toBuilder().getCredentials().get(i); - jsonArray.add(credentialObj.toJSONObject()); - } - } - bodyParams.put("credentials", jsonArray); - } - - output[0] = params; - output[1] = bodyParams.toString(); - return output; - } + private final String name; + private final Device device; + private final String updateMask; + JSONObject requestParams; + JSONObject bodyParams; + + private UpdateDeviceRequest(Builder builder) { + this.name = builder.name; + this.updateMask = builder.updateMask; + this.device = builder.device; + } + + public JSONObject getRequestParams() { + return requestParams; + } + + public void setRequestParams(JSONObject requestParams) { + this.requestParams = requestParams; + } + + public JSONObject getBodyParams() { + return bodyParams; + } + + public void setBodyParams(JSONObject bodyParams) { + this.bodyParams = bodyParams; + } + + // Static class Builder + public static class Builder { + + /// instance fields + private String name; + private Device device; + private String updateMask; + + public static Builder newBuilder() { + return new Builder(); + } + + private Builder() { + } + + // Setter methods + public Builder setName(String name) { + this.name = name; + return this; + } + + public Builder setDevice(Device device) { + this.device = device; + return this; + } + + public Builder setUpdateMask(String updateMask) { + this.updateMask = updateMask; + return this; + } + + // build method to deal with outer class + // to return outer instance + public UpdateDeviceRequest build() { + return new UpdateDeviceRequest(this); + } + } + + @SuppressWarnings("unchecked") + @Override + public String toString() { + requestParams.put("name", this.name); + requestParams.put("updateMask", this.updateMask); + + bodyParams.put("id", this.device.toBuilder().getId()); + bodyParams.put("name", this.device.toBuilder().getName()); + bodyParams.put("logLevel", this.device.toBuilder().getLogLevel()); + bodyParams.put("blocked", this.device.toBuilder().isBlocked()); + + return "name=" + this.name + ",updateMask=" + this.updateMask + ", logLevel= " + + this.device.toBuilder().getLogLevel(); + } + + public DeviceName getDeviceName() { + return DeviceName.parse(this.name); + } + + @SuppressWarnings("unchecked") + public String[] getBodyAndParams() { + String[] output = new String[2]; + + String params = "name=" + this.name + "&updateMask=" + this.updateMask; + bodyParams = new JSONObject(); + + bodyParams.put("id", this.device.toBuilder().getId()); + bodyParams.put("name", this.device.toBuilder().getName()); + if (this.device.toBuilder().getLogLevel() != null) { + bodyParams.put("logLevel", this.device.toBuilder().getLogLevel().toString()); + } + bodyParams.put("blocked", this.device.toBuilder().isBlocked()); + if (this.device.toBuilder().getCredentials().size() > 0) { + JSONArray jsonArray = new JSONArray(); + for (int i = 0; i < this.device.toBuilder().getCredentials().size(); i++) { + if (!this.device.toBuilder().getCredentials().get(i).isEmpty()) { + DeviceCredential credentialObj = this.device.toBuilder().getCredentials().get(i); + jsonArray.add(credentialObj.toJSONObject()); + } + } + bodyParams.put("credentials", jsonArray); + } + + output[0] = params; + output[1] = bodyParams.toString(); + return output; + } } diff --git a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/updatedeviceregistry/UpdateDeviceRegistryRequest.java b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/updatedeviceregistry/UpdateDeviceRegistryRequest.java index 9d957532..505139cb 100644 --- a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/updatedeviceregistry/UpdateDeviceRegistryRequest.java +++ b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/updatedeviceregistry/UpdateDeviceRegistryRequest.java @@ -30,100 +30,105 @@ package com.clearblade.cloud.iot.v1.updatedeviceregistry; +import com.clearblade.cloud.iot.v1.registrytypes.RegistryName; import org.json.simple.JSONObject; import com.clearblade.cloud.iot.v1.registrytypes.DeviceRegistry; public class UpdateDeviceRegistryRequest { - private String name; - private String updateMask; - private DeviceRegistry deviceRegistry; - JSONObject requestParams; - JSONObject bodyParams; - - private UpdateDeviceRegistryRequest(Builder builder) { - this.name = builder.name; - this.updateMask = builder.updateMask; - this.deviceRegistry = builder.deviceRegistry; - } - - public JSONObject getRequestParams() { - return requestParams; - } - - public void setRequestParams(JSONObject requestParams) { - this.requestParams = requestParams; - } - - public JSONObject getBodyParams() { - return bodyParams; - } - - public void setBodyParams(JSONObject bodyParams) { - this.bodyParams = bodyParams; - } - - // Static class Builder - public static class Builder { - - /// instance fields - private String name; - private String updateMask; - private DeviceRegistry deviceRegistry; - - public static Builder newBuilder() { - return new Builder(); - } - - private Builder() { - } - - // Setter methods - public Builder setName(String name) { - this.name = name; - return this; - } - - public Builder setDeviceRegistry(DeviceRegistry deviceRegistry) { - this.deviceRegistry = deviceRegistry; - return this; - } - - public Builder setUpdateMask(String updateMask) { - this.updateMask = updateMask; - return this; - } - - // build method to deal with outer class - // to return outer instance - public UpdateDeviceRegistryRequest build() { - return new UpdateDeviceRegistryRequest(this); - } - } - - @SuppressWarnings("unchecked") - @Override - public String toString() { - requestParams.put("name", this.name); - requestParams.put("updateMask", this.updateMask); - - bodyParams.put("id", this.deviceRegistry.toBuilder().getId()); - bodyParams.put("name", this.deviceRegistry.toBuilder().getName()); - bodyParams.put("logLevel", this.deviceRegistry.toBuilder().getLogLevel()); - - return "name=" + this.name + ",updateMask=" + this.updateMask + ", logLevel= " - + this.deviceRegistry.toBuilder().getLogLevel(); - } - - public String[] getBodyAndParams() { - String[] output = new String[2]; - - String params = "name=" + this.name + "&updateMask=" + this.updateMask; - - output[0] = params; - output[1] = this.deviceRegistry.createDeviceJSONObject(""); - return output; - } + private String name; + private String updateMask; + private DeviceRegistry deviceRegistry; + JSONObject requestParams; + JSONObject bodyParams; + + private UpdateDeviceRegistryRequest(Builder builder) { + this.name = builder.name; + this.updateMask = builder.updateMask; + this.deviceRegistry = builder.deviceRegistry; + } + + public JSONObject getRequestParams() { + return requestParams; + } + + public void setRequestParams(JSONObject requestParams) { + this.requestParams = requestParams; + } + + public JSONObject getBodyParams() { + return bodyParams; + } + + public void setBodyParams(JSONObject bodyParams) { + this.bodyParams = bodyParams; + } + + // Static class Builder + public static class Builder { + + /// instance fields + private String name; + private String updateMask; + private DeviceRegistry deviceRegistry; + + public static Builder newBuilder() { + return new Builder(); + } + + private Builder() { + } + + // Setter methods + public Builder setName(String name) { + this.name = name; + return this; + } + + public Builder setDeviceRegistry(DeviceRegistry deviceRegistry) { + this.deviceRegistry = deviceRegistry; + return this; + } + + public Builder setUpdateMask(String updateMask) { + this.updateMask = updateMask; + return this; + } + + // build method to deal with outer class + // to return outer instance + public UpdateDeviceRegistryRequest build() { + return new UpdateDeviceRegistryRequest(this); + } + } + + public RegistryName getParent() { + return RegistryName.parse(this.name); + } + + @SuppressWarnings("unchecked") + @Override + public String toString() { + requestParams.put("name", this.name); + requestParams.put("updateMask", this.updateMask); + + bodyParams.put("id", this.deviceRegistry.toBuilder().getId()); + bodyParams.put("name", this.deviceRegistry.toBuilder().getName()); + bodyParams.put("logLevel", this.deviceRegistry.toBuilder().getLogLevel()); + + return "name=" + this.name + ",updateMask=" + this.updateMask + ", logLevel= " + + this.deviceRegistry.toBuilder().getLogLevel(); + } + + public String[] getBodyAndParams() { + String[] output = new String[2]; + + String params = "name=" + this.name + "&updateMask=" + this.updateMask; + + output[0] = params; + output[1] = this.deviceRegistry.createDeviceJSONObject(""); + return output; + } } diff --git a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/utils/AuthParams.java b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/utils/AuthParams.java index 25d4504a..4b0b034d 100644 --- a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/utils/AuthParams.java +++ b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/utils/AuthParams.java @@ -41,6 +41,7 @@ import java.net.http.HttpRequest.BodyPublishers; import java.net.http.HttpResponse; import java.net.http.HttpResponse.BodyHandlers; +import java.util.HashMap; import java.util.logging.Level; import java.util.logging.Logger; @@ -48,163 +49,152 @@ import org.json.simple.parser.JSONParser; import com.clearblade.cloud.iot.v1.exception.ApplicationException; +import org.json.simple.parser.ParseException; public class AuthParams { - static Logger log = Logger.getLogger(AuthParams.class.getName()); - static ConfigParameters configParameters = ConfigParameters.getInstance(); - private static String adminSystemKey = null; - private static String project = null; - private static String baseURL = null; - private static String adminToken = null; - private static String userSystemKey = null; - private static String userToken = null; - private static String apiBaseURL = null; - - private AuthParams() {} - - public static String getAdminSystemKey() { - return adminSystemKey; - } - - public static String getProject() { - return project; - } - - public static String getBaseURL() { - return baseURL; - } - - public static String getAdminToken() { - return adminToken; - } - - public static String getUserSystemKey() { - return userSystemKey; - } - - public static String getUserToken() { - return userToken; - } - - public static String getApiBaseURL() { - return apiBaseURL; - } - - public static void setAdminCredentials() throws ApplicationException, IOException { - - if (adminSystemKey != null) { - return; - } - try { - String pathToAuthFile = System.getenv(Constants.AUTH_ACCESS); - if (pathToAuthFile != null) { - JSONParser jsonParser = new JSONParser(); - FileReader authReader = new FileReader(pathToAuthFile); - // Read JSON file - Object obj = jsonParser.parse(authReader); - JSONObject authJSONObject = (JSONObject) obj; - if (authJSONObject != null) { - - adminSystemKey = (authJSONObject.get(Constants.ADMIN_SYSTEM_KEY)).toString(); - adminToken = (authJSONObject.get(Constants.ADMIN_TOKEN)).toString(); - baseURL = (authJSONObject.get(Constants.BASE_URL)).toString(); - project = (authJSONObject.get(Constants.PROJECT_NAME)).toString(); - } - } else { - log.log(Level.SEVERE, "CLEARBLADE_CONFIGURATION Enviornment variable not set"); - throw new ApplicationException("CLEARBLADE_CONFIGURATION Enviornment variable not set"); - } - - } catch (FileNotFoundException fe) { - log.log(Level.SEVERE, "ClearBlade Configuration File not found"); - throw new FileNotFoundException("ClearBlade Configuration File not found"); - - } catch (IOException fe) { - log.log(Level.SEVERE, "Access Denied - ClearBlade Configuration File cannot be read"); - throw new IOException("Access Denied - ClearBlade Configuration File cannot be read"); - - } catch (Exception e) { - log.log(Level.SEVERE, e.getMessage()); - throw new ApplicationException(e.getMessage()); - } - } - - private static void setRegistryRegion() throws ApplicationException { - if(configParameters.getRegistry()==null) { - String registryName = System.getenv(Constants.AUTH_REGISTRY); - if(registryName != null) { - configParameters.setRegistry(registryName); - } else { - log.log(Level.SEVERE, "CLEARBLADE_REGISTRY Enviornment variable not set"); - throw new ApplicationException("CLEARBLADE_REGISTRY Enviornment variable not set"); - } - String regionName = System.getenv(Constants.AUTH_REGION); - if(regionName != null) { - configParameters.setRegion(regionName); - } else { - log.log(Level.SEVERE, "CLEARBLADE_REGION Enviornment variable not set"); - throw new ApplicationException("CLEARBLADE_REGION Enviornment variable not set"); - } - } - } - - - @SuppressWarnings("unchecked") - public static void setRegistryCredentials() throws ApplicationException, IOException { - - if (userSystemKey != null) { - return; - } - try { - setAdminCredentials(); - setRegistryRegion(); - String finalURL = baseURL.concat(configParameters.getGetSystemCredentialsExtension()) - .concat(adminSystemKey) - .concat("/getRegistryCredentials"); - - JSONObject js = new JSONObject(); - js.put("region", configParameters.getRegion()); - js.put("registry", configParameters.getRegistry()); - js.put("project", project); - BodyPublisher jsonPayload = BodyPublishers.ofString(js.toString()); - - HttpRequest request = HttpRequest.newBuilder() + static Logger log = Logger.getLogger(AuthParams.class.getName()); + + private static HashMap cachedResponse = new HashMap<>(); + + private String adminSystemKey = null; + private String project = null; + private String baseURL = null; + private String adminToken = null; + private String userSystemKey = null; + private String userToken = null; + private String apiBaseURL = null; + + public String getAdminSystemKey() { + return adminSystemKey; + } + + public String getProject() { + return project; + } + + public String getBaseURL() { + return baseURL; + } + + public String getAdminToken() { + return adminToken; + } + + public String getUserSystemKey() { + return userSystemKey; + } + + public String getUserToken() { + return userToken; + } + + public String getApiBaseURL() { + return apiBaseURL; + } + + public void setAdminCredentials() throws ApplicationException, IOException { + try { + String pathToAuthFile = System.getenv(Constants.AUTH_ACCESS); + if (pathToAuthFile != null) { + JSONParser jsonParser = new JSONParser(); + FileReader authReader = new FileReader(pathToAuthFile); + // Read JSON file + Object obj = jsonParser.parse(authReader); + JSONObject authJSONObject = (JSONObject) obj; + if (authJSONObject != null) { + adminSystemKey = (authJSONObject.get(Constants.ADMIN_SYSTEM_KEY)).toString(); + adminToken = (authJSONObject.get(Constants.ADMIN_TOKEN)).toString(); + baseURL = (authJSONObject.get(Constants.BASE_URL)).toString(); + project = (authJSONObject.get(Constants.PROJECT_NAME)).toString(); + } + } else { + log.log(Level.SEVERE, "CLEARBLADE_CONFIGURATION Enviornment variable not set"); + throw new ApplicationException("CLEARBLADE_CONFIGURATION Enviornment variable not set"); + } + + } catch (FileNotFoundException fe) { + log.log(Level.SEVERE, "ClearBlade Configuration File not found"); + throw new FileNotFoundException("ClearBlade Configuration File not found"); + + } catch (IOException fe) { + log.log(Level.SEVERE, "Access Denied - ClearBlade Configuration File cannot be read"); + throw new IOException("Access Denied - ClearBlade Configuration File cannot be read"); + + } catch (Exception e) { + log.log(Level.SEVERE, e.getMessage()); + throw new ApplicationException(e.getMessage()); + } + } + + @SuppressWarnings("unchecked") + public void setRegistryCredentials(String project, String registry, String location) throws ApplicationException { + + if (cachedResponse.containsKey(location + "-" + registry)) { + String responseMessage = cachedResponse.get(location + "-" + registry); + JSONParser responseParser = new JSONParser(); + JSONObject responseJSONObject; + Object responseObj = null; + try { + responseObj = responseParser.parse(responseMessage); + } catch (ParseException e) { + throw new ApplicationException(e); + } + if (responseObj != null) { + responseJSONObject = (JSONObject) responseObj; + userSystemKey = responseJSONObject.get(Constants.USER_SYSTEM_KEY).toString(); + userToken = responseJSONObject.get(Constants.USER_TOKEN).toString(); + apiBaseURL = responseJSONObject.get(Constants.API_BASE_URL).toString(); + } + return; + } + try { + setAdminCredentials(); + String finalURL = baseURL.concat(Constants.GET_SYSTEM_CREDENTIALS_EXTENSION) + .concat(adminSystemKey) + .concat("/getRegistryCredentials"); + + JSONObject js = new JSONObject(); + js.put("region", location); + js.put("registry", registry); + js.put("project", project); + BodyPublisher jsonPayload = BodyPublishers.ofString(js.toString()); + + HttpRequest request = HttpRequest.newBuilder() .uri(URI.create(finalURL)) .method(Constants.HTTP_REQUEST_METHOD_TYPE_POST, jsonPayload) - .headers(Constants.HTTP_REQUEST_PROPERTY_CONTENT_TYPE_KEY, Constants.HTTP_REQUEST_PROPERTY_CONTENT_TYPE_ACCEPT_VALUE, - Constants.HTTP_REQUEST_PROPERTY_TOKEN_KEY, adminToken, - Constants.HTTP_REQUEST_PROPERTY_ACCEPT_KEY, Constants.HTTP_REQUEST_PROPERTY_CONTENT_TYPE_ACCEPT_VALUE) + .headers(Constants.HTTP_REQUEST_PROPERTY_CONTENT_TYPE_KEY, Constants.HTTP_REQUEST_PROPERTY_CONTENT_TYPE_ACCEPT_VALUE, + Constants.HTTP_REQUEST_PROPERTY_TOKEN_KEY, adminToken, + Constants.HTTP_REQUEST_PROPERTY_ACCEPT_KEY, Constants.HTTP_REQUEST_PROPERTY_CONTENT_TYPE_ACCEPT_VALUE) .build(); - HttpResponse response = HttpClient.newBuilder() - .proxy(ProxySelector.getDefault()) - .build() - .send(request, BodyHandlers.ofString()); - - int responseCode = response.statusCode(); - String responseMessage = response.body(); - JSONParser responseParser = new JSONParser(); - JSONObject responseJSONObject; - if (responseCode == 200) { - if (responseMessage != null && responseMessage.length() > 0) { - Object responseObj = responseParser.parse(responseMessage); - if (responseObj != null) { - responseJSONObject = (JSONObject) responseObj; - userSystemKey = responseJSONObject.get(Constants.USER_SYSTEM_KEY).toString(); - userToken = responseJSONObject.get(Constants.USER_TOKEN).toString(); - apiBaseURL = responseJSONObject.get(Constants.API_BASE_URL).toString(); - } - } - }else { - log.log(Level.INFO, ()->"Response code " + responseCode + " received with message::" + responseMessage); - } - } catch (ApplicationException | IOException e) { - log.log(Level.SEVERE, e.getMessage()); - } catch (InterruptedException ex) { - log.log(Level.SEVERE, ex.getMessage()); - Thread.currentThread().interrupt(); - }catch(Exception ec) { - log.log(Level.SEVERE, ec.getMessage()); - } - } + HttpResponse response = HttpClient.newBuilder() + .proxy(ProxySelector.getDefault()) + .build() + .send(request, BodyHandlers.ofString()); + + int responseCode = response.statusCode(); + String responseMessage = response.body(); + JSONParser responseParser = new JSONParser(); + JSONObject responseJSONObject; + if (responseCode == 200) { + if (responseMessage != null && responseMessage.length() > 0) { + Object responseObj = responseParser.parse(responseMessage); + if (responseObj != null) { + responseJSONObject = (JSONObject) responseObj; + userSystemKey = responseJSONObject.get(Constants.USER_SYSTEM_KEY).toString(); + userToken = responseJSONObject.get(Constants.USER_TOKEN).toString(); + apiBaseURL = responseJSONObject.get(Constants.API_BASE_URL).toString(); + cachedResponse.put(location + "-" + registry, responseMessage); + } + } + } else { + log.log(Level.INFO, () -> "Response code " + responseCode + " received with message::" + responseMessage); + } + } catch (ApplicationException e) { + log.log(Level.SEVERE, e.getMessage()); + Thread.currentThread().interrupt(); + } catch (Exception ec) { + log.log(Level.SEVERE, ec.getMessage()); + } + } } diff --git a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/utils/AutoValue.java b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/utils/AutoValue.java new file mode 100644 index 00000000..8a5f1910 --- /dev/null +++ b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/utils/AutoValue.java @@ -0,0 +1,18 @@ +package com.clearblade.cloud.iot.v1.utils; + +import java.lang.annotation.*; + +@Retention(RetentionPolicy.CLASS) +@Target({ElementType.TYPE}) +public @interface AutoValue { + @Retention(RetentionPolicy.CLASS) + @Target({ElementType.TYPE, ElementType.METHOD}) + public @interface CopyAnnotations { + Class[] exclude() default {}; + } + + @Retention(RetentionPolicy.CLASS) + @Target({ElementType.TYPE}) + public @interface Builder { + } +} \ No newline at end of file diff --git a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/utils/AutoValue_PathTemplate_Segment.java b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/utils/AutoValue_PathTemplate_Segment.java new file mode 100644 index 00000000..47a14a6b --- /dev/null +++ b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/utils/AutoValue_PathTemplate_Segment.java @@ -0,0 +1,63 @@ +package com.clearblade.cloud.iot.v1.utils; + +final class AutoValue_PathTemplate_Segment extends PathTemplate.Segment { + private final PathTemplate.SegmentKind kind; + private final String value; + private final String complexSeparator; + + AutoValue_PathTemplate_Segment(PathTemplate.SegmentKind kind, String value, String complexSeparator) { + if (kind == null) { + throw new NullPointerException("Null kind"); + } else { + this.kind = kind; + if (value == null) { + throw new NullPointerException("Null value"); + } else { + this.value = value; + if (complexSeparator == null) { + throw new NullPointerException("Null complexSeparator"); + } else { + this.complexSeparator = complexSeparator; + } + } + } + } + + PathTemplate.SegmentKind kind() { + return this.kind; + } + + String value() { + return this.value; + } + + String complexSeparator() { + return this.complexSeparator; + } + + public String toString() { + return "Segment{kind=" + this.kind + ", value=" + this.value + ", complexSeparator=" + this.complexSeparator + "}"; + } + + public boolean equals(Object o) { + if (o == this) { + return true; + } else if (!(o instanceof PathTemplate.Segment)) { + return false; + } else { + PathTemplate.Segment that = (PathTemplate.Segment)o; + return this.kind.equals(that.kind()) && this.value.equals(that.value()) && this.complexSeparator.equals(that.complexSeparator()); + } + } + + public int hashCode() { + int h$ = 1; + h$ *= 1000003; + h$ ^= this.kind.hashCode(); + h$ *= 1000003; + h$ ^= this.value.hashCode(); + h$ *= 1000003; + h$ ^= this.complexSeparator.hashCode(); + return h$; + } +} \ No newline at end of file diff --git a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/utils/ConfigParameters.java b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/utils/ConfigParameters.java index 28b4c13e..fd83d22b 100644 --- a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/utils/ConfigParameters.java +++ b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/utils/ConfigParameters.java @@ -33,134 +33,133 @@ import java.util.logging.Logger; public class ConfigParameters { - static Logger log = Logger.getLogger(ConfigParameters.class.getName()); - - private static ConfigParameters single_instance = null; - - private String project; - private String region; - private String registry; - private String getSystemCredentialsExtension; - private String webhook; - private String cloudiotURLExtension; - private String devicesURLExtension; - private String devicesStatesURLExtension; - private String cloudiotdevicesURLExtension; - private String cloudiotConfigURLExtension; - private String endpointPort; - - public static ConfigParameters getInstance() - { + static Logger log = Logger.getLogger(ConfigParameters.class.getName()); + + private static ConfigParameters single_instance = null; + + private String project; + private String region; + private String registry; + private String getSystemCredentialsExtension; + private String webhook; + private String cloudiotURLExtension; + private String devicesURLExtension; + private String devicesStatesURLExtension; + private String cloudiotdevicesURLExtension; + private String cloudiotConfigURLExtension; + private String endpointPort; + + public static ConfigParameters getInstance() { if (single_instance == null) single_instance = new ConfigParameters(); - + return single_instance; - } - - public ConfigParameters() { - setValues(); - } - - /** - * Method used to set values in Constants setter method - */ - public void setValues() { - this.setWebhook(Constants.WEBHOOK); - this.setCloudiotURLExtension(Constants.CLOUDIOT_URL_EXTENSION); - this.setDevicesURLExtension(Constants.DEVICES_URL_EXTENSION); - this.setCloudiotdevicesURLExtension(Constants.CLOUDIOT_DEVICES_URL_EXTENSION); - this.setDevicesStatesURLExtension(Constants.DEVICES_STATES_URL_EXTENSION); - this.setCloudiotConfigURLExtension(Constants.CLOUDIOT_DEVICE_CONFIG_URL_EXTENSION); - this.setGetSystemCredentialsExtension(Constants.GET_SYSTEM_CREDENTIALS_EXTENSION); - this.setEndpointPort(Constants.ENDPOINTPORT); - } - - public String getCloudiotURLExtension() { - return cloudiotURLExtension; - } - - public void setCloudiotURLExtension(String cloudiotURLExtension) { - this.cloudiotURLExtension = cloudiotURLExtension; - } - - public String getDevicesURLExtension() { - return devicesURLExtension; - } - - public void setDevicesURLExtension(String devicesURLExtension) { - this.devicesURLExtension = devicesURLExtension; - } - - public String getDevicesStatesURLExtension() { - return devicesStatesURLExtension; - } - - public void setDevicesStatesURLExtension(String devicesStatesURLExtension) { - this.devicesStatesURLExtension = devicesStatesURLExtension; - } - - public String getCloudiotdevicesURLExtension() { - return cloudiotdevicesURLExtension; - } - - public void setCloudiotdevicesURLExtension(String cloudiotdevicesURLExtension) { - this.cloudiotdevicesURLExtension = cloudiotdevicesURLExtension; - } - - public String getProject() { - return project; - } - - public void setProject(String project) { - this.project = project; - } - - public String getRegion() { - return region; - } - - public void setRegion(String region) { - this.region = region; - } - - public String getRegistry() { - return registry; - } - - public void setRegistry(String registry) { - this.registry = registry; - } - - public String getGetSystemCredentialsExtension() { - return getSystemCredentialsExtension; - } - - public void setGetSystemCredentialsExtension(String getSystemCredentialsExtension) { - this.getSystemCredentialsExtension = getSystemCredentialsExtension; - } - - public String getEndpointPort() { - return endpointPort; - } - - public void setEndpointPort(String endpointPort) { - this.endpointPort = endpointPort; - } - - public String getWebhook() { - return webhook; - } - - public void setWebhook(String webhook) { - this.webhook = webhook; - } - - public String getCloudiotConfigURLExtension() { - return cloudiotConfigURLExtension; - } - - public void setCloudiotConfigURLExtension(String cloudiotConfigURLExtension) { - this.cloudiotConfigURLExtension = cloudiotConfigURLExtension; - } + } + + public ConfigParameters() { + setValues(); + } + + /** + * Method used to set values in Constants setter method + */ + public void setValues() { + this.setWebhook(Constants.WEBHOOK); + this.setCloudiotURLExtension(Constants.CLOUDIOT_URL_EXTENSION); + this.setDevicesURLExtension(Constants.DEVICES_URL_EXTENSION); + this.setCloudiotdevicesURLExtension(Constants.CLOUDIOT_DEVICES_URL_EXTENSION); + this.setDevicesStatesURLExtension(Constants.DEVICES_STATES_URL_EXTENSION); + this.setCloudiotConfigURLExtension(Constants.CLOUDIOT_DEVICE_CONFIG_URL_EXTENSION); + this.setGetSystemCredentialsExtension(Constants.GET_SYSTEM_CREDENTIALS_EXTENSION); + this.setEndpointPort(Constants.ENDPOINTPORT); + } + + public String getCloudiotURLExtension() { + return cloudiotURLExtension; + } + + public void setCloudiotURLExtension(String cloudiotURLExtension) { + this.cloudiotURLExtension = cloudiotURLExtension; + } + + public String getDevicesURLExtension() { + return devicesURLExtension; + } + + public void setDevicesURLExtension(String devicesURLExtension) { + this.devicesURLExtension = devicesURLExtension; + } + + public String getDevicesStatesURLExtension() { + return devicesStatesURLExtension; + } + + public void setDevicesStatesURLExtension(String devicesStatesURLExtension) { + this.devicesStatesURLExtension = devicesStatesURLExtension; + } + + public String getCloudiotdevicesURLExtension() { + return cloudiotdevicesURLExtension; + } + + public void setCloudiotdevicesURLExtension(String cloudiotdevicesURLExtension) { + this.cloudiotdevicesURLExtension = cloudiotdevicesURLExtension; + } + + public String getProject() { + return project; + } + + public void setProject(String project) { + this.project = project; + } + + public String getRegion() { + return region; + } + + public void setRegion(String region) { + this.region = region; + } + + public String getRegistry() { + return registry; + } + + public void setRegistry(String registry) { + this.registry = registry; + } + + public String getGetSystemCredentialsExtension() { + return getSystemCredentialsExtension; + } + + public void setGetSystemCredentialsExtension(String getSystemCredentialsExtension) { + this.getSystemCredentialsExtension = getSystemCredentialsExtension; + } + + public String getEndpointPort() { + return endpointPort; + } + + public void setEndpointPort(String endpointPort) { + this.endpointPort = endpointPort; + } + + public String getWebhook() { + return webhook; + } + + public void setWebhook(String webhook) { + this.webhook = webhook; + } + + public String getCloudiotConfigURLExtension() { + return cloudiotConfigURLExtension; + } + + public void setCloudiotConfigURLExtension(String cloudiotConfigURLExtension) { + this.cloudiotConfigURLExtension = cloudiotConfigURLExtension; + } } diff --git a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/utils/PathTemplate.java b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/utils/PathTemplate.java new file mode 100644 index 00000000..46c44442 --- /dev/null +++ b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/utils/PathTemplate.java @@ -0,0 +1,863 @@ +package com.clearblade.cloud.iot.v1.utils; + +import com.google.common.base.Splitter; +import com.google.common.collect.*; + +import javax.annotation.Nullable; +import java.io.UnsupportedEncodingException; +import java.net.URLDecoder; +import java.net.URLEncoder; +import java.util.*; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +public class PathTemplate { + public static final String HOSTNAME_VAR = "$hostname"; + private static final Pattern CUSTOM_VERB_PATTERN = Pattern.compile(":([^/*}{=]+)$"); + private static final Pattern HOSTNAME_PATTERN = Pattern.compile("^(\\w+:)?//"); + private static final Splitter SLASH_SPLITTER = Splitter.on('/').trimResults(); + private static final Pattern COMPLEX_DELIMITER_PATTERN = Pattern.compile("[_\\-\\.~]"); + private static final Pattern MULTIPLE_COMPLEX_DELIMITER_PATTERN = Pattern.compile("\\}[_\\-\\.~]{2,}\\{"); + private static final Pattern MISSING_COMPLEX_DELIMITER_PATTERN = Pattern.compile("\\}\\{"); + private static final Pattern INVALID_COMPLEX_DELIMITER_PATTERN = Pattern.compile("\\}[^_\\-\\.~]\\{"); + private static final Pattern END_SEGMENT_COMPLEX_DELIMITER_PATTERN = Pattern.compile("\\}[_\\-\\.~]{1}"); + private final ImmutableList segments; + private final ImmutableMap bindings; + private final boolean urlEncoding; + + public static PathTemplate create(String template) { + return create(template, true); + } + + public static PathTemplate createWithoutUrlEncoding(String template) { + return create(template, false); + } + + private static PathTemplate create(String template, boolean urlEncoding) { + return new PathTemplate(parseTemplate(template), urlEncoding); + } + + private PathTemplate(Iterable segments, boolean urlEncoding) { + this.segments = ImmutableList.copyOf(segments); + if (this.segments.isEmpty()) { + throw new ValidationException("template cannot be empty.", new Object[0]); + } else { + Map bindings = Maps.newLinkedHashMap(); + UnmodifiableIterator var4 = this.segments.iterator(); + + while(var4.hasNext()) { + Segment seg = (Segment)var4.next(); + if (seg.kind() == PathTemplate.SegmentKind.BINDING) { + if (bindings.containsKey(seg.value())) { + throw new ValidationException("Duplicate binding '%s'", new Object[]{seg.value()}); + } + + bindings.put(seg.value(), seg); + } + } + + this.bindings = ImmutableMap.copyOf(bindings); + this.urlEncoding = urlEncoding; + } + } + + public Set vars() { + return this.bindings.keySet(); + } + + public PathTemplate parentTemplate() { + int i = this.segments.size(); + --i; + Segment seg = (Segment)this.segments.get(i); + if (seg.kind() == PathTemplate.SegmentKind.END_BINDING) { + while(i > 0) { + --i; + if (((Segment)this.segments.get(i)).kind() == PathTemplate.SegmentKind.BINDING) { + break; + } + } + } + + if (i == 0) { + throw new ValidationException("template does not have a parent", new Object[0]); + } else { + return new PathTemplate(this.segments.subList(0, i), this.urlEncoding); + } + } + + public PathTemplate withoutVars() { + StringBuilder result = new StringBuilder(); + ListIterator iterator = this.segments.listIterator(); + boolean start = true; + + while(iterator.hasNext()) { + Segment seg = (Segment)iterator.next(); + switch (seg.kind()) { + case END_BINDING: + case BINDING: + break; + default: + if (!start) { + result.append(seg.separator()); + } else { + start = false; + } + + result.append(seg.value()); + } + } + + return create(result.toString(), this.urlEncoding); + } + + public PathTemplate subTemplate(String varName) { + List sub = Lists.newArrayList(); + boolean inBinding = false; + UnmodifiableIterator var4 = this.segments.iterator(); + + while(true) { + while(var4.hasNext()) { + Segment seg = (Segment)var4.next(); + if (seg.kind() == PathTemplate.SegmentKind.BINDING && seg.value().equals(varName)) { + inBinding = true; + } else if (inBinding) { + if (seg.kind() == PathTemplate.SegmentKind.END_BINDING) { + return create(toSyntax(sub, true), this.urlEncoding); + } + + sub.add(seg); + } + } + + throw new ValidationException(String.format("Variable '%s' is undefined in template '%s'", varName, this.toRawString()), new Object[0]); + } + } + + public boolean endsWithLiteral() { + return ((Segment)this.segments.get(this.segments.size() - 1)).kind() == PathTemplate.SegmentKind.LITERAL; + } + + public boolean endsWithCustomVerb() { + return ((Segment)this.segments.get(this.segments.size() - 1)).kind() == PathTemplate.SegmentKind.CUSTOM_VERB; + } + + public TemplatedResourceName parse(String path) { + return TemplatedResourceName.create(this, path); + } + + @Nullable + public String singleVar() { + return this.bindings.size() == 1 ? (String)((Map.Entry)this.bindings.entrySet().iterator().next()).getKey() : null; + } + + public void validate(String path, String exceptionMessagePrefix) { + if (!this.matches(path)) { + throw new ValidationException(String.format("%s: Parameter \"%s\" must be in the form \"%s\"", exceptionMessagePrefix, path, this.toString()), new Object[0]); + } + } + + public Map validatedMatch(String path, String exceptionMessagePrefix) { + Map matchMap = this.match(path); + if (matchMap == null) { + throw new ValidationException(String.format("%s: Parameter \"%s\" must be in the form \"%s\"", exceptionMessagePrefix, path, this.toString()), new Object[0]); + } else { + return matchMap; + } + } + + public boolean matches(String path) { + return this.match(path) != null; + } + + @Nullable + public Map match(String path) { + return this.match(path, false); + } + + @Nullable + public Map matchFromFullName(String path) { + return this.match(path, true); + } + + private Map match(String path, boolean forceHostName) { + Segment last = (Segment)this.segments.get(this.segments.size() - 1); + Matcher matcher; + if (last.kind() == PathTemplate.SegmentKind.CUSTOM_VERB) { + matcher = CUSTOM_VERB_PATTERN.matcher(path); + if (!matcher.find() || !this.decodeUrl(matcher.group(1)).equals(last.value())) { + return null; + } + + path = path.substring(0, matcher.start(0)); + } + + matcher = HOSTNAME_PATTERN.matcher(path); + boolean withHostName = matcher.find(); + if (withHostName) { + path = matcher.replaceFirst(""); + } + + List input = SLASH_SPLITTER.splitToList(path); + int inPos = 0; + Map values = Maps.newLinkedHashMap(); + if (withHostName || forceHostName) { + if (input.isEmpty()) { + return null; + } + + String hostName = (String)input.get(inPos++); + if (withHostName) { + hostName = matcher.group(0) + hostName; + } + + values.put("$hostname", hostName); + } + + if (withHostName) { + inPos = this.alignInputToAlignableSegment(input, inPos, (Segment)this.segments.get(0)); + } + + if (!this.match(input, inPos, this.segments, 0, values)) { + return null; + } else { + return ImmutableMap.copyOf(values); + } + } + + private int alignInputToAlignableSegment(List input, int inPos, Segment segment) { + switch (segment.kind()) { + case BINDING: + inPos = this.alignInputPositionToLiteral(input, inPos, segment.value() + "s"); + return inPos + 1; + case LITERAL: + return this.alignInputPositionToLiteral(input, inPos, segment.value()); + default: + return inPos; + } + } + + private int alignInputPositionToLiteral(List input, int inPos, String literalSegmentValue) { + while(inPos < input.size()) { + if (literalSegmentValue.equals(input.get(inPos))) { + return inPos; + } + + ++inPos; + } + + return inPos; + } + + private boolean match(List input, int inPos, List segments, int segPos, Map values) { + String currentVar = null; + List modifiableInput = new ArrayList(input); + + while(true) { + while(segPos < segments.size()) { + Segment seg = (Segment)segments.get(segPos++); + int complexSeparatorIndex; + switch (seg.kind()) { + case CUSTOM_VERB: + default: + break; + case END_BINDING: + currentVar = null; + break; + case BINDING: + currentVar = seg.value(); + break; + case LITERAL: + case WILDCARD: + if (inPos >= modifiableInput.size()) { + return false; + } + + String next = this.decodeUrl((String)modifiableInput.get(inPos++)); + if (seg.kind() == PathTemplate.SegmentKind.LITERAL && !seg.value().equals(next)) { + return false; + } + + if (seg.kind() == PathTemplate.SegmentKind.WILDCARD && !seg.complexSeparator().isEmpty()) { + complexSeparatorIndex = next.indexOf(seg.complexSeparator()); + if (complexSeparatorIndex < 0) { + return false; + } + + modifiableInput.add(inPos, next.substring(complexSeparatorIndex + 1)); + next = next.substring(0, complexSeparatorIndex); + modifiableInput.set(inPos - 1, next); + } + + if (currentVar != null) { + values.put(currentVar, concatCaptures((String)values.get(currentVar), next)); + } + break; + case PATH_WILDCARD: + complexSeparatorIndex = 0; + int available = segPos; + + while(available < segments.size()) { + switch (((Segment)segments.get(available)).kind()) { + default: + ++complexSeparatorIndex; + case CUSTOM_VERB: + case END_BINDING: + case BINDING: + ++available; + } + } + + available = modifiableInput.size() - inPos - complexSeparatorIndex; + if (available == 0 && !values.containsKey(currentVar)) { + values.put(currentVar, ""); + } + + while(available-- > 0) { + values.put(currentVar, concatCaptures((String)values.get(currentVar), this.decodeUrl((String)modifiableInput.get(inPos++)))); + } + } + } + + return inPos == modifiableInput.size(); + } + } + + private static String concatCaptures(@Nullable String cur, String next) { + return cur == null ? next : cur + "/" + next; + } + + public String instantiate(Map values) { + return this.instantiate(values, false); + } + + public String instantiate(String... keysAndValues) { + ImmutableMap.Builder builder = ImmutableMap.builder(); + + for(int i = 0; i < keysAndValues.length; i += 2) { + builder.put(keysAndValues[i], keysAndValues[i + 1]); + } + + return this.instantiate((Map)builder.build()); + } + + public String instantiatePartial(Map values) { + return this.instantiate(values, true); + } + + private String instantiate(Map values, boolean allowPartial) { + StringBuilder result = new StringBuilder(); + if (values.containsKey("$hostname")) { + result.append((String)values.get("$hostname")); + result.append('/'); + } + + boolean continueLast = true; + boolean skip = false; + ListIterator iterator = this.segments.listIterator(); + String prevSeparator = ""; + + while(true) { + while(true) { + while(iterator.hasNext()) { + Segment seg = (Segment)iterator.next(); + String var; + if (!skip && !continueLast) { + var = !prevSeparator.isEmpty() && iterator.hasNext() ? prevSeparator : seg.separator(); + result.append(var); + prevSeparator = seg.complexSeparator().isEmpty() ? seg.separator() : seg.complexSeparator(); + } + + continueLast = false; + switch (seg.kind()) { + case END_BINDING: + if (!skip) { + result.append('}'); + } + + skip = false; + break; + case BINDING: + var = seg.value(); + String value = (String)values.get(seg.value()); + if (value == null) { + if (!allowPartial) { + throw new ValidationException(String.format("Unbound variable '%s'. Bindings: %s", var, values), new Object[0]); + } + + if (var.startsWith("$")) { + result.append(((Segment)iterator.next()).value()); + iterator.next(); + } else { + result.append('{'); + result.append(seg.value()); + result.append('='); + continueLast = true; + } + break; + } + + Segment next = (Segment)iterator.next(); + Segment nextNext = (Segment)iterator.next(); + boolean pathEscape = next.kind() == PathTemplate.SegmentKind.PATH_WILDCARD || nextNext.kind() != PathTemplate.SegmentKind.END_BINDING; + restore(iterator, iterator.nextIndex() - 2); + if (!pathEscape) { + result.append(this.encodeUrl(value)); + } else { + boolean first = true; + Iterator var15 = SLASH_SPLITTER.split(value).iterator(); + + while(var15.hasNext()) { + String subSeg = (String)var15.next(); + if (!first) { + result.append('/'); + } + + first = false; + result.append(this.encodeUrl(subSeg)); + } + } + + skip = true; + break; + default: + if (!skip) { + result.append(seg.value()); + } + } + } + + return result.toString(); + } + } + } + + public String encode(String... values) { + ImmutableMap.Builder builder = ImmutableMap.builder(); + int i = 0; + String[] var4 = values; + int var5 = values.length; + + for(int var6 = 0; var6 < var5; ++var6) { + String value = var4[var6]; + builder.put("$" + i++, value); + } + + return this.instantiate((Map)builder.build()); + } + + public List decode(String path) { + Map match = this.match(path); + if (match == null) { + throw new IllegalArgumentException(String.format("template '%s' does not match '%s'", this, path)); + } else { + List result = Lists.newArrayList(); + Iterator var4 = match.entrySet().iterator(); + + while(var4.hasNext()) { + Map.Entry entry = (Map.Entry)var4.next(); + String key = (String)entry.getKey(); + if (!key.startsWith("$")) { + throw new IllegalArgumentException("template must not contain named bindings"); + } + + int i = Integer.parseInt(key.substring(1)); + + while(result.size() <= i) { + result.add(""); + } + + result.set(i, entry.getValue()); + } + + return ImmutableList.copyOf(result); + } + } + + private static ImmutableList parseTemplate(String template) { + if (template.startsWith("/")) { + template = template.substring(1); + } + + Matcher matcher = CUSTOM_VERB_PATTERN.matcher(template); + String customVerb = null; + if (matcher.find()) { + customVerb = matcher.group(1); + template = template.substring(0, matcher.start(0)); + } + + ImmutableList.Builder builder = ImmutableList.builder(); + String varName = null; + int freeWildcardCounter = 0; + int pathWildCardBound = 0; + Iterator var7 = Splitter.on('/').trimResults().split(template).iterator(); + + while(true) { + while(var7.hasNext()) { + String seg = (String)var7.next(); + if (!seg.equals("_deleted-topic_")) { + boolean isLastSegment = template.indexOf(seg) + seg.length() == template.length(); + boolean isCollectionWildcard = !isLastSegment && (seg.equals("-") || seg.equals("-}")); + if (!isCollectionWildcard && isSegmentBeginOrEndInvalid(seg)) { + throw new ValidationException("parse error: invalid begin or end character in '%s'", new Object[]{seg}); + } + + if (MULTIPLE_COMPLEX_DELIMITER_PATTERN.matcher(seg).find() || MISSING_COMPLEX_DELIMITER_PATTERN.matcher(seg).find()) { + throw new ValidationException("parse error: missing or 2+ consecutive delimiter characters in '%s'", new Object[]{seg}); + } + + boolean bindingStarts = seg.startsWith("{"); + boolean implicitWildcard = false; + boolean complexDelimiterFound = false; + if (bindingStarts) { + if (varName != null) { + throw new ValidationException("parse error: nested binding in '%s'", new Object[]{template}); + } + + seg = seg.substring(1); + if (INVALID_COMPLEX_DELIMITER_PATTERN.matcher(seg).find()) { + throw new ValidationException("parse error: invalid complex resource ID delimiter character in '%s'", new Object[]{seg}); + } + + Matcher complexPatternDelimiterMatcher = END_SEGMENT_COMPLEX_DELIMITER_PATTERN.matcher(seg); + complexDelimiterFound = !isCollectionWildcard && complexPatternDelimiterMatcher.find(); + if (complexDelimiterFound) { + builder.addAll(parseComplexResourceId(seg)); + } else { + int i = seg.indexOf(61); + if (i <= 0) { + if (!seg.endsWith("}")) { + throw new ValidationException("parse error: invalid binding syntax in '%s'", new Object[]{template}); + } + + implicitWildcard = true; + varName = seg.substring(0, seg.length() - 1).trim(); + seg = seg.substring(seg.length() - 1).trim(); + } else if (seg.indexOf(45) <= 0 && isCollectionWildcard) { + implicitWildcard = true; + } else { + varName = seg.substring(0, i).trim(); + seg = seg.substring(i + 1).trim(); + } + + builder.add(PathTemplate.Segment.create(PathTemplate.SegmentKind.BINDING, varName)); + } + } + + if (!complexDelimiterFound) { + boolean bindingEnds = seg.endsWith("}"); + if (bindingEnds) { + seg = seg.substring(0, seg.length() - 1).trim(); + } + + switch (seg) { + case "**": + case "*": + if ("**".equals(seg)) { + ++pathWildCardBound; + } + + Segment wildcard = seg.length() == 2 ? PathTemplate.Segment.PATH_WILDCARD : PathTemplate.Segment.WILDCARD; + if (varName == null) { + builder.add(PathTemplate.Segment.create(PathTemplate.SegmentKind.BINDING, "$" + freeWildcardCounter)); + ++freeWildcardCounter; + builder.add(wildcard); + builder.add(PathTemplate.Segment.END_BINDING); + } else { + builder.add(wildcard); + } + break; + case "": + if (!bindingEnds) { + throw new ValidationException("parse error: empty segment not allowed in '%s'", new Object[]{template}); + } + break; + case "-": + builder.add(PathTemplate.Segment.WILDCARD); + implicitWildcard = false; + break; + default: + builder.add(PathTemplate.Segment.create(PathTemplate.SegmentKind.LITERAL, seg)); + } + + if (bindingEnds && !complexDelimiterFound) { + varName = null; + if (implicitWildcard) { + builder.add(PathTemplate.Segment.WILDCARD); + } + + builder.add(PathTemplate.Segment.END_BINDING); + } + + if (pathWildCardBound > 1) { + throw new ValidationException("parse error: pattern must not contain more than one path wildcard ('**') in '%s'", new Object[]{template}); + } + } + } else { + builder.add(PathTemplate.Segment.create(PathTemplate.SegmentKind.LITERAL, seg)); + } + } + + if (customVerb != null) { + builder.add(PathTemplate.Segment.create(PathTemplate.SegmentKind.CUSTOM_VERB, customVerb)); + } + + return builder.build(); + } + } + + private static boolean isSegmentBeginOrEndInvalid(String seg) { + if (seg.length() == 1 && COMPLEX_DELIMITER_PATTERN.matcher(seg).find()) { + return true; + } else { + return COMPLEX_DELIMITER_PATTERN.matcher(seg.substring(0, 1)).find() && seg.charAt(1) == '{' || COMPLEX_DELIMITER_PATTERN.matcher(seg.substring(seg.length() - 1)).find() && seg.charAt(seg.length() - 2) == '}'; + } + } + + private static List parseComplexResourceId(String seg) { + List segments = new ArrayList(); + List separatorIndices = new ArrayList(); + Matcher complexPatternDelimiterMatcher = END_SEGMENT_COMPLEX_DELIMITER_PATTERN.matcher(seg); + + int delimiterIndex; + for(boolean delimiterFound = complexPatternDelimiterMatcher.find(); delimiterFound; delimiterFound = complexPatternDelimiterMatcher.find(delimiterIndex + 1)) { + delimiterIndex = complexPatternDelimiterMatcher.start(); + if (seg.substring(delimiterIndex).startsWith("}")) { + ++delimiterIndex; + } + + String currDelimiter = seg.substring(delimiterIndex, delimiterIndex + 1); + if (!COMPLEX_DELIMITER_PATTERN.matcher(currDelimiter).find()) { + throw new ValidationException("parse error: invalid complex ID delimiter '%s' in '%s'", new Object[]{currDelimiter, seg}); + } + + separatorIndices.add(currDelimiter); + } + + separatorIndices.add(""); + String subVarName = null; + Iterable complexSubsegments = Splitter.onPattern("\\}[_\\-\\.~]").trimResults().split(seg); + boolean complexSegImplicitWildcard = false; + int currIteratorIndex = 0; + + for(Iterator var9 = complexSubsegments.iterator(); var9.hasNext(); ++currIteratorIndex) { + String complexSeg = (String)var9.next(); + boolean subsegmentBindingStarts = complexSeg.startsWith("{"); + if (subsegmentBindingStarts) { + if (subVarName != null) { + throw new ValidationException("parse error: nested binding in '%s'", new Object[]{complexSeg}); + } + + complexSeg = complexSeg.substring(1); + } + + subVarName = complexSeg.trim(); + boolean subBindingEnds = complexSeg.endsWith("}"); + int i = complexSeg.indexOf(61); + if (i <= 0) { + if (subBindingEnds) { + complexSegImplicitWildcard = true; + subVarName = complexSeg.substring(0, complexSeg.length() - 1).trim(); + complexSeg = complexSeg.substring(complexSeg.length() - 1).trim(); + } + } else { + subVarName = complexSeg.substring(0, i).trim(); + complexSeg = complexSeg.substring(i + 1).trim(); + if (complexSeg.equals("**")) { + throw new ValidationException("parse error: wildcard path not allowed in complex ID resource '%s'", new Object[]{subVarName}); + } + } + + String complexDelimiter = currIteratorIndex < separatorIndices.size() ? (String)separatorIndices.get(currIteratorIndex) : ""; + segments.add(PathTemplate.Segment.create(PathTemplate.SegmentKind.BINDING, subVarName, complexDelimiter)); + segments.add(PathTemplate.Segment.wildcardCreate(complexDelimiter)); + segments.add(PathTemplate.Segment.END_BINDING); + subVarName = null; + } + + return segments; + } + + private String encodeUrl(String text) { + if (this.urlEncoding) { + try { + return URLEncoder.encode(text, "UTF-8"); + } catch (UnsupportedEncodingException var3) { + throw new ValidationException("UTF-8 encoding is not supported on this platform", new Object[0]); + } + } else { + String INVALID_CHAR = "/"; + if (text.contains("/")) { + throw new ValidationException("Invalid character \"/\" in path section \"" + text + "\".", new Object[0]); + } else { + return text; + } + } + } + + private String decodeUrl(String url) { + if (this.urlEncoding) { + try { + return URLDecoder.decode(url, "UTF-8"); + } catch (UnsupportedEncodingException var3) { + throw new ValidationException("UTF-8 encoding is not supported on this platform", new Object[0]); + } + } else { + return url; + } + } + + private static boolean peek(ListIterator segments, SegmentKind... kinds) { + int start = segments.nextIndex(); + boolean success = false; + SegmentKind[] var4 = kinds; + int var5 = kinds.length; + + for(int var6 = 0; var6 < var5; ++var6) { + SegmentKind kind = var4[var6]; + if (!segments.hasNext() || ((Segment)segments.next()).kind() != kind) { + success = false; + break; + } + } + + if (success) { + return true; + } else { + restore(segments, start); + return false; + } + } + + private static void restore(ListIterator segments, int index) { + while(segments.nextIndex() > index) { + segments.previous(); + } + + } + + public String toString() { + return toSyntax(this.segments, true); + } + + public String toRawString() { + return toSyntax(this.segments, false); + } + + private static String toSyntax(List segments, boolean pretty) { + StringBuilder result = new StringBuilder(); + boolean continueLast = true; + ListIterator iterator = segments.listIterator(); + + while(true) { + while(true) { + while(iterator.hasNext()) { + Segment seg = (Segment)iterator.next(); + if (!continueLast) { + result.append(seg.separator()); + } + + continueLast = false; + switch (seg.kind()) { + case END_BINDING: + result.append('}'); + break; + case BINDING: + if (pretty && seg.value().startsWith("$")) { + seg = (Segment)iterator.next(); + result.append(seg.value()); + iterator.next(); + } else { + result.append('{'); + result.append(seg.value()); + if (pretty && peek(iterator, PathTemplate.SegmentKind.WILDCARD, PathTemplate.SegmentKind.END_BINDING)) { + result.append('}'); + } else { + result.append('='); + continueLast = true; + } + } + break; + default: + result.append(seg.value()); + } + } + + return result.toString(); + } + } + } + + public boolean equals(Object obj) { + if (!(obj instanceof PathTemplate)) { + return false; + } else { + PathTemplate other = (PathTemplate)obj; + return Objects.equals(this.segments, other.segments); + } + } + + public int hashCode() { + return this.segments.hashCode(); + } + + @AutoValue + abstract static class Segment { + private static final Segment WILDCARD; + private static final Segment PATH_WILDCARD; + private static final Segment END_BINDING; + + Segment() { + } + + private static Segment create(SegmentKind kind, String value) { + return new AutoValue_PathTemplate_Segment(kind, value, ""); + } + + private static Segment create(SegmentKind kind, String value, String complexSeparator) { + return new AutoValue_PathTemplate_Segment(kind, value, complexSeparator); + } + + private static Segment wildcardCreate(String complexSeparator) { + return new AutoValue_PathTemplate_Segment(PathTemplate.SegmentKind.WILDCARD, "*", !complexSeparator.isEmpty() && PathTemplate.COMPLEX_DELIMITER_PATTERN.matcher(complexSeparator).find() ? complexSeparator : ""); + } + + abstract SegmentKind kind(); + + abstract String value(); + + abstract String complexSeparator(); + + boolean isAnyWildcard() { + return this.kind() == PathTemplate.SegmentKind.WILDCARD || this.kind() == PathTemplate.SegmentKind.PATH_WILDCARD; + } + + String separator() { + switch (this.kind()) { + case CUSTOM_VERB: + return ":"; + case END_BINDING: + return ""; + default: + return "/"; + } + } + + static { + WILDCARD = create(PathTemplate.SegmentKind.WILDCARD, "*"); + PATH_WILDCARD = create(PathTemplate.SegmentKind.PATH_WILDCARD, "**"); + END_BINDING = create(PathTemplate.SegmentKind.END_BINDING, ""); + } + } + + static enum SegmentKind { + LITERAL, + CUSTOM_VERB, + WILDCARD, + PATH_WILDCARD, + BINDING, + END_BINDING; + + private SegmentKind() { + } + } +} diff --git a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/utils/TemplatedResourceName.java b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/utils/TemplatedResourceName.java new file mode 100644 index 00000000..ebb593c5 --- /dev/null +++ b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/utils/TemplatedResourceName.java @@ -0,0 +1,170 @@ +package com.clearblade.cloud.iot.v1.utils; + +import com.google.common.base.Preconditions; +import com.google.common.collect.ImmutableMap; +import com.google.common.collect.Sets; + +import javax.annotation.Nullable; +import java.util.Collection; +import java.util.Map; +import java.util.Objects; +import java.util.Set; + +public class TemplatedResourceName implements Map { + private static volatile Resolver resourceNameResolver = new Resolver() { + public T resolve(Class resourceType, TemplatedResourceName name, String version) { + throw new IllegalStateException("No resource name resolver is registered in ResourceName class."); + } + }; + private final PathTemplate template; + private final ImmutableMap values; + private final String endpoint; + private volatile String stringRepr; + + public static void registerResourceNameResolver(Resolver resolver) { + resourceNameResolver = resolver; + } + + public static TemplatedResourceName create(PathTemplate template, String path) { + Map values = template.match(path); + if (values == null) { + throw new ValidationException("path '%s' does not match template '%s'", new Object[]{path, template}); + } else { + return new TemplatedResourceName(template, values, (String)null); + } + } + + public static TemplatedResourceName create(PathTemplate template, Map values) { + if (!values.keySet().containsAll(template.vars())) { + Set unbound = Sets.newLinkedHashSet(template.vars()); + unbound.removeAll(values.keySet()); + throw new ValidationException("unbound variables: %s", new Object[]{unbound}); + } else { + return new TemplatedResourceName(template, values, (String)null); + } + } + + @Nullable + public static TemplatedResourceName createFromFullName(PathTemplate template, String path) { + Map values = template.matchFromFullName(path); + return values == null ? null : new TemplatedResourceName(template, values, (String)null); + } + + private TemplatedResourceName(PathTemplate template, Map values, String endpoint) { + this.template = template; + this.values = ImmutableMap.copyOf(values); + this.endpoint = endpoint; + } + + public String toString() { + if (this.stringRepr == null) { + this.stringRepr = this.template.instantiate(this.values); + } + + return this.stringRepr; + } + + public boolean equals(Object obj) { + if (!(obj instanceof TemplatedResourceName)) { + return false; + } else { + TemplatedResourceName other = (TemplatedResourceName)obj; + return Objects.equals(this.template, other.template) && Objects.equals(this.endpoint, other.endpoint) && Objects.equals(this.values, other.values); + } + } + + public int hashCode() { + return Objects.hash(new Object[]{this.template, this.endpoint, this.values}); + } + + public PathTemplate template() { + return this.template; + } + + public boolean hasEndpoint() { + return this.endpoint != null; + } + + @Nullable + public String endpoint() { + return this.endpoint; + } + + public TemplatedResourceName withEndpoint(String endpoint) { + return new TemplatedResourceName(this.template, this.values, (String) Preconditions.checkNotNull(endpoint)); + } + + public TemplatedResourceName parentName() { + PathTemplate parentTemplate = this.template.parentTemplate(); + return new TemplatedResourceName(parentTemplate, this.values, this.endpoint); + } + + public boolean startsWith(TemplatedResourceName parentName) { + return this.toString().startsWith(parentName.toString()); + } + + public T resolve(Class resourceType, @Nullable String version) { + Preconditions.checkArgument(this.hasEndpoint(), "Resource name must have an endpoint."); + return resourceNameResolver.resolve(resourceType, this, version); + } + + public int size() { + return this.values.size(); + } + + public boolean isEmpty() { + return this.values.isEmpty(); + } + + public boolean containsKey(Object key) { + return this.values.containsKey(key); + } + + public boolean containsValue(Object value) { + return this.values.containsValue(value); + } + + public String get(Object key) { + return (String)this.values.get(key); + } + + /** @deprecated */ + @Deprecated + public String put(String key, String value) { + return (String)this.values.put(key, value); + } + + /** @deprecated */ + @Deprecated + public String remove(Object key) { + return (String)this.values.remove(key); + } + + /** @deprecated */ + @Deprecated + public void putAll(Map m) { + this.values.putAll(m); + } + + /** @deprecated */ + @Deprecated + public void clear() { + this.values.clear(); + } + + public Set keySet() { + return this.values.keySet(); + } + + public Collection values() { + return this.values.values(); + } + + public Set> entrySet() { + return this.values.entrySet(); + } + + public interface Resolver { + T resolve(Class var1, TemplatedResourceName var2, @Nullable String var3); + } +} \ No newline at end of file diff --git a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/utils/ValidationException.java b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/utils/ValidationException.java new file mode 100644 index 00000000..4d4f77b2 --- /dev/null +++ b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/utils/ValidationException.java @@ -0,0 +1,58 @@ +package com.clearblade.cloud.iot.v1.utils; + +import java.util.Iterator; +import java.util.Stack; + +public class ValidationException extends IllegalArgumentException { + private static ThreadLocal>> contextLocal = new ThreadLocal(); + + public static void pushCurrentThreadValidationContext(Supplier supplier) { + Stack> stack = (Stack)contextLocal.get(); + if (stack == null) { + stack = new Stack(); + contextLocal.set(stack); + } + + stack.push(supplier); + } + + public static void pushCurrentThreadValidationContext(final String context) { + pushCurrentThreadValidationContext(new Supplier() { + public String get() { + return context; + } + }); + } + + public static void popCurrentThreadValidationContext() { + Stack stack = (Stack)contextLocal.get(); + if (stack != null) { + stack.pop(); + } + + } + + public ValidationException(String format, Object... args) { + super(message((Stack)contextLocal.get(), format, args)); + } + + private static String message(Stack> context, String format, Object... args) { + if (context != null && !context.isEmpty()) { + StringBuilder result = new StringBuilder(); + Iterator var4 = context.iterator(); + + while(var4.hasNext()) { + Supplier supplier = (Supplier)var4.next(); + result.append((String)supplier.get() + ": "); + } + + return result.toString() + String.format(format, args); + } else { + return String.format(format, args); + } + } + + public interface Supplier { + T get(); + } +} \ No newline at end of file From dcd29276f5983f08f47e5348446d9e3aa82872ef Mon Sep 17 00:00:00 2001 From: ronak-ingress Date: Mon, 15 May 2023 22:15:29 +0530 Subject: [PATCH 076/151] - Added test cases. --- clearblade-cloud-iot/pom.xml | 6 + .../clearblade/cloud/iot/v1/AsyncClient.java | 4 +- .../clearblade/cloud/iot/v1/SyncClient.java | 4 +- .../cloud/iot/v1/utils/AuthParams.java | 5 +- .../iot/v1/test/DeviceManagerClientTest.java | 322 ++++++++++++++ .../iot/v1/test/ExpectedResponseTest.java | 400 ++++++++++++++++++ .../cloud/iot/v1/test/package-info.java | 2 +- .../iot/v1/test/DeviceManagerClientTest.java | 340 --------------- .../iot/v1/test/ExpectedResponseTest.java | 383 ----------------- 9 files changed, 735 insertions(+), 731 deletions(-) create mode 100644 clearblade-cloud-iot/src/test/com/clearblade/cloud/iot/v1/test/DeviceManagerClientTest.java create mode 100644 clearblade-cloud-iot/src/test/com/clearblade/cloud/iot/v1/test/ExpectedResponseTest.java rename clearblade-cloud-iot/{ => src}/test/com/clearblade/cloud/iot/v1/test/package-info.java (96%) delete mode 100644 clearblade-cloud-iot/test/com/clearblade/cloud/iot/v1/test/DeviceManagerClientTest.java delete mode 100644 clearblade-cloud-iot/test/com/clearblade/cloud/iot/v1/test/ExpectedResponseTest.java diff --git a/clearblade-cloud-iot/pom.xml b/clearblade-cloud-iot/pom.xml index 14063329..9ab68626 100644 --- a/clearblade-cloud-iot/pom.xml +++ b/clearblade-cloud-iot/pom.xml @@ -214,5 +214,11 @@ guava 31.1-jre + + org.junit.jupiter + junit-jupiter-api + 5.8.2 + compile + \ No newline at end of file diff --git a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/AsyncClient.java b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/AsyncClient.java index aece175f..7669d9e8 100644 --- a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/AsyncClient.java +++ b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/AsyncClient.java @@ -121,7 +121,7 @@ public String[] get(String apiName, String params, ListDeviceStatesRequest reque return get(finalURL, token); } - public String[] get(String apiName, String params, GetDeviceRegistryRequest request) throws IOException, ParseException { + public String[] get(String apiName, String params, GetDeviceRegistryRequest request) { authParams.setRegistryCredentials(request.getName().getProject(), request.getName().getRegistry(), request.getName().getLocation()); String finalURL = generateURL(authParams, apiName, params); String token = authParams.getUserToken(); @@ -277,7 +277,7 @@ public String[] update(String apiName, String params, String body, UpdateDeviceR authParams.setRegistryCredentials(request.getParent().getProject(), request.getParent().getRegistry(), request.getParent().getLocation()); String finalURL = generateURL(authParams, apiName, params); String token = authParams.getUserToken(); - return post(finalURL, body, token); + return update(finalURL, body, token); } public String[] update(String apiName, String params, String body, UpdateDeviceRequest request) throws IOException, ParseException { diff --git a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/SyncClient.java b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/SyncClient.java index 424086bc..b6827f98 100644 --- a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/SyncClient.java +++ b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/SyncClient.java @@ -313,11 +313,11 @@ public String[] update(String apiName, String params, String body, UpdateDeviceR return update(finalURL, body, token); } - public String[] update(String apiName, String params, String body, UpdateDeviceRegistryRequest request) { + public String[] update(String apiName, String params, String body, UpdateDeviceRegistryRequest request) throws InterruptedException { authParams.setRegistryCredentials(request.getParent().getProject(), request.getParent().getRegistry(), request.getParent().getLocation()); String finalURL = generateURL(authParams, apiName, params); String token = authParams.getUserToken(); - return post(finalURL, body, token); + return update(finalURL, body, token); } /** diff --git a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/utils/AuthParams.java b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/utils/AuthParams.java index 4b0b034d..80d02654 100644 --- a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/utils/AuthParams.java +++ b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/utils/AuthParams.java @@ -189,12 +189,11 @@ public void setRegistryCredentials(String project, String registry, String locat } } else { log.log(Level.INFO, () -> "Response code " + responseCode + " received with message::" + responseMessage); + throw new ApplicationException(responseMessage); } - } catch (ApplicationException e) { - log.log(Level.SEVERE, e.getMessage()); - Thread.currentThread().interrupt(); } catch (Exception ec) { log.log(Level.SEVERE, ec.getMessage()); + throw new ApplicationException(ec.getMessage()); } } } diff --git a/clearblade-cloud-iot/src/test/com/clearblade/cloud/iot/v1/test/DeviceManagerClientTest.java b/clearblade-cloud-iot/src/test/com/clearblade/cloud/iot/v1/test/DeviceManagerClientTest.java new file mode 100644 index 00000000..715a73f3 --- /dev/null +++ b/clearblade-cloud-iot/src/test/com/clearblade/cloud/iot/v1/test/DeviceManagerClientTest.java @@ -0,0 +1,322 @@ +/* + * Copyright 2023 ClearBlade Inc. + * + * 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. + * + * 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 test.com.clearblade.cloud.iot.v1.test; + + +import java.util.ArrayList; +import java.util.HashMap; + +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.MethodOrderer; +import org.junit.jupiter.api.Order; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.TestMethodOrder; + +import com.clearblade.cloud.iot.v1.DeviceManagerClient; +import com.clearblade.cloud.iot.v1.binddevicetogateway.BindDeviceToGatewayRequest; +import com.clearblade.cloud.iot.v1.binddevicetogateway.BindDeviceToGatewayResponse; +import com.clearblade.cloud.iot.v1.createdevice.CreateDeviceRequest; +import com.clearblade.cloud.iot.v1.createdeviceregistry.CreateDeviceRegistryRequest; +import com.clearblade.cloud.iot.v1.deletedevice.DeleteDeviceRequest; +import com.clearblade.cloud.iot.v1.deletedeviceregistry.DeleteDeviceRegistryRequest; +import com.clearblade.cloud.iot.v1.devicetypes.Device; +import com.clearblade.cloud.iot.v1.devicetypes.DeviceConfig; +import com.clearblade.cloud.iot.v1.devicetypes.DeviceName; +import com.clearblade.cloud.iot.v1.devicetypes.FieldMask; +import com.clearblade.cloud.iot.v1.devicetypes.GatewayConfig; +import com.clearblade.cloud.iot.v1.devicetypes.GatewayType; +import com.clearblade.cloud.iot.v1.devicetypes.Status; +import com.clearblade.cloud.iot.v1.getdevice.GetDeviceRequest; +import com.clearblade.cloud.iot.v1.getdeviceregistry.GetDeviceRegistryRequest; +import com.clearblade.cloud.iot.v1.registrytypes.DeviceRegistry; +import com.clearblade.cloud.iot.v1.registrytypes.LocationName; +import com.clearblade.cloud.iot.v1.registrytypes.RegistryName; +import com.clearblade.cloud.iot.v1.sendcommandtodevice.SendCommandToDeviceRequest; +import com.clearblade.cloud.iot.v1.sendcommandtodevice.SendCommandToDeviceResponse; +import com.clearblade.cloud.iot.v1.unbinddevicefromgateway.UnbindDeviceFromGatewayRequest; +import com.clearblade.cloud.iot.v1.unbinddevicefromgateway.UnbindDeviceFromGatewayResponse; +import com.clearblade.cloud.iot.v1.updatedevice.UpdateDeviceRequest; +import com.clearblade.cloud.iot.v1.updatedeviceregistry.UpdateDeviceRegistryRequest; +import com.clearblade.cloud.iot.v1.utils.ByteString; +import com.clearblade.cloud.iot.v1.utils.LogLevel; + +@TestMethodOrder(MethodOrderer.OrderAnnotation.class) +public class DeviceManagerClientTest { + + private static DeviceManagerClient client; + private static ExpectedResponseTest testResponse; + private String project = "xxx"; + private String location = "xxx"; + private String registryId = "xxx"; + private String failedRegistryId = "xxx"; + private String deviceId = "xxx"; + private String gatewayId = "xxx"; + private String numDeviceId = "xxx"; + private String numGatewayId = "xxx"; + + @BeforeAll + public static void setUp() { + client = new DeviceManagerClient(); + testResponse = new ExpectedResponseTest(); + } + + @Test + @Order(1) + public void testCreateRegistrySuccess() { + DeviceRegistry expectedResponse = testResponse.getResponseTest2(registryId); + CreateDeviceRegistryRequest request = CreateDeviceRegistryRequest.Builder.newBuilder() + .setParent(LocationName.of(project, location).toString()) + .setDeviceRegistry( + DeviceRegistry.newBuilder().setId(registryId).setLogLevel(LogLevel.DEBUG).build()) + .build(); + DeviceRegistry actualResponse = client.createDeviceRegistry(request); + testResponse.assertEquals(expectedResponse, actualResponse); + } + + @Test + @Order(2) + public void testGetRegistrySuccess() { + DeviceRegistry expectedResponse = testResponse.getResponseTest3(registryId); + GetDeviceRegistryRequest request = GetDeviceRegistryRequest.Builder.newBuilder() + .setName(RegistryName.of(project, location, registryId).getRegistryFullName()) + .build(); + DeviceRegistry actualResponse = client.getDeviceRegistry(request); + testResponse.assertEquals(expectedResponse, actualResponse); + + } + + @Test + @Order(3) + public void testGetRegistryFail() { + GetDeviceRegistryRequest request = GetDeviceRegistryRequest.Builder.newBuilder() + .setName(RegistryName.of(project, location, failedRegistryId).getRegistryFullName()) + .build(); + DeviceRegistry actualResponse = null; + try { + actualResponse = client.getDeviceRegistry(request); + } catch (Exception e) { + testResponse.assertException(e); + testResponse.assertContains(e.getMessage(), "No systems found matching that combination of project, region and registry:"); + } + testResponse.assertEqualsNull(actualResponse); + } + + @Test + @Order(4) + public void testUpdateDeviceRegistrySuccess() { + RegistryName name = RegistryName.of(project, location, registryId); + DeviceRegistry expectedResponse = testResponse.getResponseTest5(registryId); + UpdateDeviceRegistryRequest request = UpdateDeviceRegistryRequest.Builder.newBuilder() + .setDeviceRegistry(DeviceRegistry.newBuilder().setId(registryId) + .setName(name.getRegistryFullName()) + .setLogLevel(LogLevel.ERROR) + .build()) + .setName(name.getRegistryFullName()).setUpdateMask("logLevel").build(); + + DeviceRegistry actualResponse = client.updateDeviceRegistry(request); + testResponse.assertEquals(expectedResponse, actualResponse); + } + + @Test + @Order(5) + public void testCreateDeviceSuccess() { + RegistryName parent = RegistryName.of(project, location, registryId); + Device expectedResponse = testResponse.getResponseTest7(deviceId, numDeviceId); + GatewayConfig gatewayCfg = new GatewayConfig(); + gatewayCfg.setGatewayType(GatewayType.NON_GATEWAY); + Device device = Device.newBuilder() + .setId(deviceId) + .setName(deviceId) + .setNumId(numDeviceId) + .setBlocked(false) + .setGatewayConfig(gatewayCfg) + .setLogLevel(LogLevel.DEBUG) + .setCredentials(new ArrayList<>()) + .setLastErrorStatus(new Status()) + .setConfig(new DeviceConfig()) + .setMetadata(new HashMap<>()) + .build(); + CreateDeviceRequest request = CreateDeviceRequest.Builder.newBuilder().setParent(parent).setDevice(device) + .build(); + Device actualResponse = client.createDevice(request); + testResponse.assertEqual(expectedResponse, actualResponse); + + } + + @Test + @Order(6) + public void testCreateDeviceAsAGatewaySuccess() { + RegistryName parent = RegistryName.of(project, location, registryId); + Device expectedResponse = testResponse.getResponseTest8(gatewayId, numGatewayId); + GatewayConfig gatewayCfg = new GatewayConfig(); + gatewayCfg.setGatewayType(GatewayType.GATEWAY); + Device device = Device.newBuilder() + .setId(gatewayId) + .setName(gatewayId) + .setNumId(numGatewayId) + .setBlocked(false) + .setGatewayConfig(gatewayCfg) + .setLogLevel(LogLevel.DEBUG) + .setCredentials(new ArrayList<>()) + .setLastErrorStatus(new Status()) + .setConfig(new DeviceConfig()) + .setMetadata(new HashMap<>()) + .build(); + CreateDeviceRequest request = CreateDeviceRequest.Builder.newBuilder().setParent(parent).setDevice(device) + .build(); + Device actualResponse = client.createDevice(request); + testResponse.assertEqual(expectedResponse, actualResponse); + + } + + @Test + @Order(7) + public void testGetDeviceFail() { + DeviceName name = DeviceName.of(project, location, registryId, "test_device02"); + Device expectedResponse = testResponse.getResponseTest9(deviceId, numDeviceId); + GetDeviceRequest request = GetDeviceRequest.Builder.newBuilder().setName(name) + .setFieldMask(FieldMask.newBuilder().build()).build(); + Device actualResponse = null; + try { + actualResponse = client.getDevice(request); + } catch (Exception e) { + testResponse.assertException(e); + testResponse.assertContains(e.getMessage(), "doesn't exist"); + } + testResponse.assertEqualsNull(actualResponse); + } + + @Test + @Order(8) + public void testGetDeviceSuccess() { + DeviceName name = DeviceName.of(project, location, registryId, deviceId); + Device expectedResponse = testResponse.getResponseTest10(deviceId, numDeviceId); + GetDeviceRequest request = GetDeviceRequest.Builder.newBuilder().setName(name) + .setFieldMask(FieldMask.newBuilder().build()).build(); + Device actualResponse = client.getDevice(request); + testResponse.assertEqual(expectedResponse, actualResponse); + } + + @Test + @Order(9) + public void testGetDeviceAsAGatewaySuccess() { + DeviceName name = DeviceName.of(project, location, registryId, gatewayId); + Device expectedResponse = testResponse.getResponseTest11(gatewayId, numGatewayId); + GetDeviceRequest request = GetDeviceRequest.Builder.newBuilder().setName(name) + .setFieldMask(FieldMask.newBuilder().build()).build(); + Device actualResponse = client.getDevice(request); + testResponse.assertEqual(expectedResponse, actualResponse); + } + + @Test + @Order(10) + public void testUpdateDevice() { + Device expectedResponse = testResponse.getResponseTest12(deviceId); + Device device = Device.patch(deviceId, deviceId, LogLevel.ERROR, true); + DeviceName deviceName = DeviceName.of(project, location, registryId, deviceId); + String updateMask = "logLevel"; + UpdateDeviceRequest request = UpdateDeviceRequest.Builder.newBuilder().setName(deviceName.toString()).setDevice(device) + .setUpdateMask(updateMask).build(); + Device actualResponse = client.updateDevice(request); + testResponse.assertEqual(expectedResponse, actualResponse); + + } + + @Test + @Order(11) + public void testBindDeviceToGateway() { + BindDeviceToGatewayResponse expectedResponse = testResponse.getResponseTest13(); + BindDeviceToGatewayRequest request = BindDeviceToGatewayRequest.Builder.newBuilder() + .setParent(RegistryName.of(project, location, registryId).toString()) + .setGateway(gatewayId).setDevice(deviceId).build(); + BindDeviceToGatewayResponse actualResponse = client.bindDeviceToGateway(request); + testResponse.assertEqualResponse(expectedResponse, actualResponse); + + } + + @Test + @Order(12) + public void testUnbindDeviceFromGateway() { + UnbindDeviceFromGatewayResponse expectedResponse = testResponse.getResponseTest14(); + UnbindDeviceFromGatewayRequest request = UnbindDeviceFromGatewayRequest.Builder.newBuilder() + .setParent(RegistryName.of(project, location, registryId).toString()) + .setGateway(gatewayId).setDevice(deviceId).build(); + UnbindDeviceFromGatewayResponse actualResponse = client.unbindDeviceFromGateway(request); + testResponse.assertEqualsResponse(expectedResponse, actualResponse); + } + + @Test + @Order(13) + public void testSendCommandToDevice() { + String byteData = "c2VuZEZ1bm55TWVzc2FnZVRvRGV2aWNl"; + SendCommandToDeviceRequest request = SendCommandToDeviceRequest.Builder.newBuilder() + .setName(DeviceName + .of(project, location, registryId, deviceId) + .toString()) + .setBinaryData(new ByteString(byteData)).build(); + SendCommandToDeviceResponse actualResponse = null; + try { + actualResponse = client.sendCommandToDevice(request); + } catch (Exception e) { + testResponse.assertException(e); + testResponse.assertContains(e.getMessage(), " is not connected."); + } + testResponse.assertEqualsNull(actualResponse); + } + + @Test + @Order(14) + public void testDeleteDevice() { + DeviceName deviceName = DeviceName.of(project, location, registryId, deviceId); + DeleteDeviceRequest request = DeleteDeviceRequest.Builder.newBuilder().setName(deviceName).build(); + client.deleteDevice(request); + } + + @Test + @Order(15) + public void testDeleteDeviceAsAGateway() { + DeviceName deviceName = DeviceName.of(project, location, registryId, gatewayId); + DeleteDeviceRequest request = DeleteDeviceRequest.Builder.newBuilder().setName(deviceName).build(); + client.deleteDevice(request); + } + + @Test + @Order(16) + public void testDeleteDeviceRegistry() { + DeleteDeviceRegistryRequest request = DeleteDeviceRegistryRequest.Builder.newBuilder() + .setName(RegistryName.of(project, location, registryId) + .getRegistryFullName()) + .build(); + client.deleteDeviceRegistry(request); + + } + +} diff --git a/clearblade-cloud-iot/src/test/com/clearblade/cloud/iot/v1/test/ExpectedResponseTest.java b/clearblade-cloud-iot/src/test/com/clearblade/cloud/iot/v1/test/ExpectedResponseTest.java new file mode 100644 index 00000000..199fb2f2 --- /dev/null +++ b/clearblade-cloud-iot/src/test/com/clearblade/cloud/iot/v1/test/ExpectedResponseTest.java @@ -0,0 +1,400 @@ +/* + * Copyright 2023 ClearBlade Inc. + * + * 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. + * + * 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 test.com.clearblade.cloud.iot.v1.test; + +import java.util.ArrayList; +import java.util.HashMap; + +import com.clearblade.cloud.iot.v1.binddevicetogateway.BindDeviceToGatewayResponse; +import com.clearblade.cloud.iot.v1.devicetypes.Device; +import com.clearblade.cloud.iot.v1.devicetypes.DeviceConfig; +import com.clearblade.cloud.iot.v1.devicetypes.GatewayConfig; +import com.clearblade.cloud.iot.v1.devicetypes.GatewayType; +import com.clearblade.cloud.iot.v1.devicetypes.Status; +import com.clearblade.cloud.iot.v1.exception.ApplicationException; +import com.clearblade.cloud.iot.v1.registrytypes.DeviceRegistry; +import com.clearblade.cloud.iot.v1.registrytypes.HttpConfig; +import com.clearblade.cloud.iot.v1.registrytypes.HttpState; +import com.clearblade.cloud.iot.v1.registrytypes.MqttConfig; +import com.clearblade.cloud.iot.v1.registrytypes.MqttState; +import com.clearblade.cloud.iot.v1.registrytypes.StateNotificationConfig; +import com.clearblade.cloud.iot.v1.sendcommandtodevice.SendCommandToDeviceResponse; +import com.clearblade.cloud.iot.v1.unbinddevicefromgateway.UnbindDeviceFromGatewayResponse; +import com.clearblade.cloud.iot.v1.utils.LogLevel; +import org.junit.Assert; +import org.junit.jupiter.api.Assertions; + +import static org.junit.matchers.JUnitMatchers.containsString; + +public class ExpectedResponseTest { + + public boolean assertEquals(DeviceRegistry obj1, DeviceRegistry obj2) { + boolean flag = true; + if (!obj1.toBuilder().getId().equals(obj2.toBuilder().getId()) + || obj1.toBuilder().getHttpConfig().equals(obj2.toBuilder().getHttpConfig()) + || obj1.toBuilder().getMqttConfig().equals(obj2.toBuilder().getMqttConfig()) + || obj1.toBuilder().getLogLevel().equals(obj2.toBuilder().getLogLevel()) + || obj1.toBuilder().getStateNotificationConfig().equals(obj2.toBuilder().getStateNotificationConfig())) + flag = false; + return flag; + } + + public boolean assertNotEquals(DeviceRegistry obj1, DeviceRegistry obj2) { + boolean flag = true; + if (obj2 == null) + return flag; + else if (obj1.toBuilder().getId().equals(obj2.toBuilder().getId()) + || obj1.toBuilder().getHttpConfig().equals(obj2.toBuilder().getHttpConfig()) + || obj1.toBuilder().getMqttConfig().equals(obj2.toBuilder().getMqttConfig()) + || obj1.toBuilder().getLogLevel().equals(obj2.toBuilder().getLogLevel()) + || obj1.toBuilder().getStateNotificationConfig().equals(obj2.toBuilder().getStateNotificationConfig())) + flag = false; + return flag; + } + + public boolean assertEqual(Device obj1, Device obj2) { + boolean flag = true; + if (obj2 == null) + return flag; + else if (!obj1.toBuilder().getId().equals(obj2.toBuilder().getId()) + || obj1.toBuilder().getLogLevel().equals(obj2.toBuilder().getLogLevel()) + || obj1.toBuilder().getCredentials().equals(obj2.toBuilder().getCredentials())) + flag = false; + return flag; + } + + public void assertException(Throwable e) { + Assertions.assertInstanceOf(ApplicationException.class, e); + } + + public void assertContains(String actual, String expected) { + Assert.assertThat(actual, containsString(expected)); + } + + public void assertEqualsNull(Object obj) { + Assertions.assertNull(obj); + } + + public boolean assertNotEqual(Device obj1, Device obj2) { + boolean flag = true; + if (obj2 == null) + return flag; + else if (obj1.toBuilder().getId().equals(obj2.toBuilder().getId()) + || obj1.toBuilder().getName().equals(obj2.toBuilder().getName()) + || obj1.toBuilder().getNumId().equals(obj2.toBuilder().getNumId()) + || obj1.toBuilder().getGatewayConfig().equals(obj2.toBuilder().getGatewayConfig()) + || obj1.toBuilder().getLogLevel().equals(obj2.toBuilder().getLogLevel()) + || obj1.toBuilder().getCredentials().equals(obj2.toBuilder().getCredentials())) + flag = false; + return flag; + } + + public boolean assertEqualResponse(BindDeviceToGatewayResponse obj1, BindDeviceToGatewayResponse obj2) { + boolean flag = true; + if (obj1.getHttpStatusCode() != obj2.getHttpStatusCode() || !(obj1.getHttpStatusResponse().equals(obj2.getHttpStatusResponse()))) + flag = false; + return flag; + } + + public boolean assertEqualsResponse(UnbindDeviceFromGatewayResponse obj1, UnbindDeviceFromGatewayResponse obj2) { + boolean flag = true; + if (obj1.getHttpStatusCode() != obj2.getHttpStatusCode() || !(obj1.getHttpStatusResponse().equals(obj2.getHttpStatusResponse()))) + flag = false; + return flag; + } + + public boolean assertEqualsResponses(SendCommandToDeviceResponse obj1, SendCommandToDeviceResponse obj2) { + boolean flag = true; + if (obj1.getHttpStatusCode() != obj2.getHttpStatusCode() || !(obj1.getHttpStatusResponse().equals(obj2.getHttpStatusResponse()))) + flag = false; + return flag; + } + + public DeviceRegistry getResponseTest1(String registryId) { + + HttpConfig httpConfig = new HttpConfig(); + httpConfig.setHttpEnabledState(HttpState.HTTP_ENABLED); + + MqttConfig mqttConfig = new MqttConfig(); + mqttConfig.setMqttEnabledState(MqttState.MQTT_ENABLED); + + StateNotificationConfig stateConfig = new StateNotificationConfig(); + stateConfig.setPubsubTopicName(""); + + return DeviceRegistry.newBuilder() + .setId(registryId) + .setHttpConfig(httpConfig) + .setMqttConfig(mqttConfig) + .setLogLevel(LogLevel.DEBUG) + .setStateNotificationConfig(stateConfig) + .build(); + } + + public DeviceRegistry getResponseTest2(String registryId) { + + HttpConfig httpConfig = new HttpConfig(); + httpConfig.setHttpEnabledState(HttpState.HTTP_ENABLED); + + MqttConfig mqttConfig = new MqttConfig(); + mqttConfig.setMqttEnabledState(MqttState.MQTT_ENABLED); + + StateNotificationConfig stateConfig = new StateNotificationConfig(); + stateConfig.setPubsubTopicName(""); + + return DeviceRegistry.newBuilder() + .setId(registryId) + .setCredentials(new ArrayList<>()) + .setHttpConfig(httpConfig) + .setMqttConfig(mqttConfig) + .setLogLevel(LogLevel.DEBUG) + .setEventNotificationConfigs(new ArrayList<>()) + .setStateNotificationConfig(stateConfig) + .build(); + } + + + public DeviceRegistry getResponseTest3(String registryId) { + + HttpConfig httpConfig = new HttpConfig(); + httpConfig.setHttpEnabledState(HttpState.HTTP_ENABLED); + + MqttConfig mqttConfig = new MqttConfig(); + mqttConfig.setMqttEnabledState(MqttState.MQTT_ENABLED); + + StateNotificationConfig stateConfig = new StateNotificationConfig(); + stateConfig.setPubsubTopicName(""); + + return DeviceRegistry.newBuilder() + .setId(registryId) + .setHttpConfig(httpConfig) + .setMqttConfig(mqttConfig) + .setLogLevel(LogLevel.DEBUG) + .setStateNotificationConfig(stateConfig) + .build(); + } + + public DeviceRegistry getResponseTest4(String registryId) { + + HttpConfig httpConfig = new HttpConfig(); + httpConfig.setHttpEnabledState(HttpState.HTTP_ENABLED); + + MqttConfig mqttConfig = new MqttConfig(); + mqttConfig.setMqttEnabledState(MqttState.MQTT_ENABLED); + + StateNotificationConfig stateConfig = new StateNotificationConfig(); + stateConfig.setPubsubTopicName(""); + + return DeviceRegistry.newBuilder() + .setId(registryId) + .setHttpConfig(httpConfig) + .setMqttConfig(mqttConfig) + .setLogLevel(LogLevel.DEBUG) + .setStateNotificationConfig(stateConfig) + .build(); + } + + + public DeviceRegistry getResponseTest5(String registryId) { + + HttpConfig httpConfig = new HttpConfig(); + httpConfig.setHttpEnabledState(HttpState.HTTP_ENABLED); + + MqttConfig mqttConfig = new MqttConfig(); + mqttConfig.setMqttEnabledState(MqttState.MQTT_ENABLED); + + StateNotificationConfig stateConfig = new StateNotificationConfig(); + stateConfig.setPubsubTopicName(""); + + return DeviceRegistry.newBuilder() + .setId(registryId) + .setHttpConfig(httpConfig) + .setMqttConfig(mqttConfig) + .setLogLevel(LogLevel.ERROR) + .setStateNotificationConfig(stateConfig) + .build(); + } + + + public Device getResponseTest6(String deviceId, String numId) { + + GatewayConfig gatewayConfig = new GatewayConfig(); + gatewayConfig.setGatewayType(GatewayType.NON_GATEWAY); + + return Device.newBuilder() + .setId(deviceId) + .setName(deviceId) + .setNumId(numId) + .setBlocked(false) + .setGatewayConfig(gatewayConfig) + .setLogLevel(LogLevel.DEBUG) + .setCredentials(new ArrayList<>()) + .setLastErrorStatus(new Status()) + .setConfig(new DeviceConfig()) + .setMetadata(new HashMap<>()) + .build(); + + } + + public Device getResponseTest7(String deviceId, String numId) { + + GatewayConfig gatewayConfig = new GatewayConfig(); + gatewayConfig.setGatewayType(GatewayType.NON_GATEWAY); + + return Device.newBuilder() + .setId(deviceId) + .setName(deviceId) + .setNumId(numId) + .setBlocked(false) + .setGatewayConfig(gatewayConfig) + .setLogLevel(LogLevel.DEBUG) + .setCredentials(new ArrayList<>()) + .setLastErrorStatus(new Status()) + .setConfig(new DeviceConfig()) + .setMetadata(new HashMap<>()) + .build(); + + } + + public Device getResponseTest8(String deviceId, String numId) { + + GatewayConfig gatewayConfig = new GatewayConfig(); + gatewayConfig.setGatewayType(GatewayType.GATEWAY); + + return Device.newBuilder() + .setId(deviceId) + .setName(deviceId) + .setNumId(numId) + .setBlocked(false) + .setGatewayConfig(gatewayConfig) + .setLogLevel(LogLevel.DEBUG) + .setCredentials(new ArrayList<>()) + .setLastErrorStatus(new Status()) + .setConfig(new DeviceConfig()) + .setMetadata(new HashMap<>()) + .build(); + + } + + public Device getResponseTest9(String deviceId, String numId) { + + GatewayConfig gatewayConfig = new GatewayConfig(); + gatewayConfig.setGatewayType(GatewayType.NON_GATEWAY); + + return Device.newBuilder() + .setId(deviceId) + .setName(deviceId) + .setNumId(numId) + .setBlocked(false) + .setGatewayConfig(gatewayConfig) + .setLogLevel(LogLevel.DEBUG) + .setCredentials(new ArrayList<>()) + .setLastErrorStatus(new Status()) + .setConfig(new DeviceConfig()) + .setMetadata(new HashMap<>()) + .build(); + + } + + public Device getResponseTest10(String deviceId, String numId) { + + GatewayConfig gatewayConfig = new GatewayConfig(); + gatewayConfig.setGatewayType(GatewayType.NON_GATEWAY); + + return Device.newBuilder() + .setId(deviceId) + .setName(deviceId) + .setNumId(numId) + .setBlocked(false) + .setGatewayConfig(gatewayConfig) + .setLogLevel(LogLevel.DEBUG) + .setCredentials(new ArrayList<>()) + .setLastErrorStatus(new Status()) + .setConfig(new DeviceConfig()) + .setMetadata(new HashMap<>()) + .build(); + + } + + public Device getResponseTest11(String deviceId, String numId) { + + GatewayConfig gatewayConfig = new GatewayConfig(); + gatewayConfig.setGatewayType(GatewayType.GATEWAY); + + return Device.newBuilder() + .setId(deviceId) + .setName(deviceId) + .setNumId(numId) + .setBlocked(false) + .setGatewayConfig(gatewayConfig) + .setLogLevel(LogLevel.DEBUG) + .setCredentials(new ArrayList<>()) + .setLastErrorStatus(new Status()) + .setConfig(new DeviceConfig()) + .setMetadata(new HashMap<>()) + .build(); + + } + + public Device getResponseTest12(String deviceId) { + GatewayConfig gatewayConfig = new GatewayConfig(); + gatewayConfig.setGatewayType(GatewayType.NON_GATEWAY); + return Device.newBuilder() + .setId(deviceId) + .setName(deviceId) + .setBlocked(false) + .setLogLevel(LogLevel.ERROR) + .build(); + } + + public BindDeviceToGatewayResponse getResponseTest13() { + + BindDeviceToGatewayResponse response = BindDeviceToGatewayResponse.Builder.newBuilder().build(); + response.setHttpStatusCode(200); + response.setHttpStatusResponse("OK"); + return response; + } + + public UnbindDeviceFromGatewayResponse getResponseTest14() { + + UnbindDeviceFromGatewayResponse response = UnbindDeviceFromGatewayResponse.Builder.newBuilder().build(); + response.setHttpStatusCode(200); + response.setHttpStatusResponse("OK"); + return response; + } + + public SendCommandToDeviceResponse getResponseTest15() { + + SendCommandToDeviceResponse response = SendCommandToDeviceResponse.Builder.newBuilder().build(); + response.setHttpStatusCode(200); + response.setHttpStatusResponse("OK"); + return response; + } +} diff --git a/clearblade-cloud-iot/test/com/clearblade/cloud/iot/v1/test/package-info.java b/clearblade-cloud-iot/src/test/com/clearblade/cloud/iot/v1/test/package-info.java similarity index 96% rename from clearblade-cloud-iot/test/com/clearblade/cloud/iot/v1/test/package-info.java rename to clearblade-cloud-iot/src/test/com/clearblade/cloud/iot/v1/test/package-info.java index 6d011c40..d9cea184 100644 --- a/clearblade-cloud-iot/test/com/clearblade/cloud/iot/v1/test/package-info.java +++ b/clearblade-cloud-iot/src/test/com/clearblade/cloud/iot/v1/test/package-info.java @@ -28,4 +28,4 @@ * limitations under the License. */ -package com.clearblade.cloud.iot.v1.test; \ No newline at end of file +package test.com.clearblade.cloud.iot.v1.test; \ No newline at end of file diff --git a/clearblade-cloud-iot/test/com/clearblade/cloud/iot/v1/test/DeviceManagerClientTest.java b/clearblade-cloud-iot/test/com/clearblade/cloud/iot/v1/test/DeviceManagerClientTest.java deleted file mode 100644 index dd0b5e08..00000000 --- a/clearblade-cloud-iot/test/com/clearblade/cloud/iot/v1/test/DeviceManagerClientTest.java +++ /dev/null @@ -1,340 +0,0 @@ -/* - * Copyright 2023 ClearBlade Inc. - * - * 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. - * - * 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.clearblade.cloud.iot.v1.test; - - -import java.util.ArrayList; -import java.util.HashMap; - -import org.junit.jupiter.api.BeforeAll; -import org.junit.jupiter.api.Disabled; -import org.junit.jupiter.api.MethodOrderer; -import org.junit.jupiter.api.Order; -import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.TestMethodOrder; - -import com.clearblade.cloud.iot.v1.DeviceManagerClient; -import com.clearblade.cloud.iot.v1.binddevicetogateway.BindDeviceToGatewayRequest; -import com.clearblade.cloud.iot.v1.binddevicetogateway.BindDeviceToGatewayResponse; -import com.clearblade.cloud.iot.v1.createdevice.CreateDeviceRequest; -import com.clearblade.cloud.iot.v1.createdeviceregistry.CreateDeviceRegistryRequest; -import com.clearblade.cloud.iot.v1.deletedevice.DeleteDeviceRequest; -import com.clearblade.cloud.iot.v1.deletedeviceregistry.DeleteDeviceRegistryRequest; -import com.clearblade.cloud.iot.v1.devicetypes.Device; -import com.clearblade.cloud.iot.v1.devicetypes.DeviceConfig; -import com.clearblade.cloud.iot.v1.devicetypes.DeviceName; -import com.clearblade.cloud.iot.v1.devicetypes.FieldMask; -import com.clearblade.cloud.iot.v1.devicetypes.GatewayConfig; -import com.clearblade.cloud.iot.v1.devicetypes.GatewayType; -import com.clearblade.cloud.iot.v1.devicetypes.Status; -import com.clearblade.cloud.iot.v1.getdevice.GetDeviceRequest; -import com.clearblade.cloud.iot.v1.getdeviceregistry.GetDeviceRegistryRequest; -import com.clearblade.cloud.iot.v1.registrytypes.DeviceRegistry; -import com.clearblade.cloud.iot.v1.registrytypes.LocationName; -import com.clearblade.cloud.iot.v1.registrytypes.RegistryName; -import com.clearblade.cloud.iot.v1.sendcommandtodevice.SendCommandToDeviceRequest; -import com.clearblade.cloud.iot.v1.sendcommandtodevice.SendCommandToDeviceResponse; -import com.clearblade.cloud.iot.v1.unbinddevicefromgateway.UnbindDeviceFromGatewayRequest; -import com.clearblade.cloud.iot.v1.unbinddevicefromgateway.UnbindDeviceFromGatewayResponse; -import com.clearblade.cloud.iot.v1.updatedevice.UpdateDeviceRequest; -import com.clearblade.cloud.iot.v1.updatedeviceregistry.UpdateDeviceRegistryRequest; -import com.clearblade.cloud.iot.v1.utils.ByteString; -import com.clearblade.cloud.iot.v1.utils.LogLevel; - -@TestMethodOrder(MethodOrderer.OrderAnnotation.class) -public class DeviceManagerClientTest { - - private static DeviceManagerClient client; - private static ExpectedResponseTest testResponse; - private String project = "ingressdevelopmentenv"; - private String location = "us-central1"; - - - @BeforeAll - public static void setUp() { - client = new DeviceManagerClient(); - testResponse = new ExpectedResponseTest(); - } - - @Test - @Order(1) - public void testCreateRegistrySuccess() { - String registryId = "testCreate_reg03"; - DeviceRegistry expectedResponse = testResponse.getResponseTest2(registryId); - CreateDeviceRegistryRequest request = CreateDeviceRegistryRequest.Builder.newBuilder() - .setParent(LocationName.of(project, location).toString()) - .setDeviceRegistry( - DeviceRegistry.newBuilder().setId(registryId).setLogLevel(LogLevel.DEBUG).build()) - .build(); - DeviceRegistry actualResponse = client.createDeviceRegistry(request); - testResponse.assertEquals(expectedResponse, actualResponse); - } - - @Test - @Order(2) - public void testGetRegistrySuccess() { - String registryId = "testCreate_reg03"; - DeviceRegistry expectedResponse = testResponse.getResponseTest3(registryId); - GetDeviceRegistryRequest request = GetDeviceRegistryRequest.Builder.newBuilder() - .setName(RegistryName.of(project, location, registryId).getRegistryFullName()) - .build(); - DeviceRegistry actualResponse = client.getDeviceRegistry(request); - testResponse.assertEquals(expectedResponse, actualResponse); - - } - - @Test - @Order(3) - public void testGetRegistryFail() { - String registryId = "testCreate_reg01"; - DeviceRegistry expectedResponse = testResponse.getResponseTest4(registryId); - GetDeviceRegistryRequest request = GetDeviceRegistryRequest.Builder.newBuilder() - .setName(RegistryName.of(project, location, registryId).getRegistryFullName()) - .build(); - DeviceRegistry actualResponse = client.getDeviceRegistry(request); - testResponse.assertNotEquals(expectedResponse, actualResponse); - - } - - @Test - @Order(4) - public void testUpdateDeviceRegistrySuccess() { - String registryId = "Rashmi_Registry_Test"; - RegistryName name = RegistryName.of(project, location, registryId); - DeviceRegistry expectedResponse = testResponse.getResponseTest5(registryId); - UpdateDeviceRegistryRequest request = UpdateDeviceRegistryRequest.Builder.newBuilder() - .setDeviceRegistry(DeviceRegistry.newBuilder().setId(registryId) - .setName(name.getRegistryFullName()) - .setLogLevel(LogLevel.ERROR) - .build()) - .setName(name.getRegistryFullName()).setUpdateMask("logLevel").build(); - - DeviceRegistry actualResponse = client.updateDeviceRegistry(request); - testResponse.assertEquals(expectedResponse, actualResponse); - } - - @Test - @Order(5) - public void testCreateDeviceSuccess() { - String registryId = "Rashmi_Registry_Test"; - String deviceId = "test_device01"; - String numId = "1211"; - RegistryName parent = RegistryName.of(project, location, registryId); - Device expectedResponse = testResponse.getResponseTest7(deviceId,numId); - GatewayConfig gatewayCfg = new GatewayConfig(); - gatewayCfg.setGatewayType(GatewayType.NON_GATEWAY); - Device device = Device.newBuilder() - .setId(deviceId) - .setName(deviceId) - .setNumId(numId) - .setBlocked(false) - .setGatewayConfig(gatewayCfg) - .setLogLevel(LogLevel.DEBUG) - .setCredentials(new ArrayList<>()) - .setLastErrorStatus(new Status()) - .setConfig(new DeviceConfig()) - .setMetadata(new HashMap<>()) - .build(); - CreateDeviceRequest request = CreateDeviceRequest.Builder.newBuilder().setParent(parent).setDevice(device) - .build(); - Device actualResponse = client.createDevice(request); - testResponse.assertEqual(expectedResponse, actualResponse); - - } - - @Test - @Order(6) - public void testCreateDeviceAsAGatewaySuccess() { - String registryId = "Rashmi_Registry_Test"; - String deviceId = "test_device03"; - String numId = "1112"; - RegistryName parent = RegistryName.of(project, location, registryId); - Device expectedResponse = testResponse.getResponseTest8(deviceId,numId); - GatewayConfig gatewayCfg = new GatewayConfig(); - gatewayCfg.setGatewayType(GatewayType.GATEWAY); - Device device = Device.newBuilder() - .setId(deviceId) - .setName(deviceId) - .setNumId(numId) - .setBlocked(false) - .setGatewayConfig(gatewayCfg) - .setLogLevel(LogLevel.DEBUG) - .setCredentials(new ArrayList<>()) - .setLastErrorStatus(new Status()) - .setConfig(new DeviceConfig()) - .setMetadata(new HashMap<>()) - .build(); - CreateDeviceRequest request = CreateDeviceRequest.Builder.newBuilder().setParent(parent).setDevice(device) - .build(); - Device actualResponse = client.createDevice(request); - testResponse.assertEqual(expectedResponse, actualResponse); - - } - - @Test - @Order(7) - public void testGetDeviceFail() { - String registryId = "Rashmi_Registry_Test"; - String deviceId = "test_device01"; - String numId= "1211"; - DeviceName name = DeviceName.of(project, location, registryId, "test_device02"); - Device expectedResponse = testResponse.getResponseTest9(deviceId,numId); - GetDeviceRequest request = GetDeviceRequest.Builder.newBuilder().setName(name) - .setFieldMask(FieldMask.newBuilder().build()).build(); - Device actualResponse = client.getDevice(request); - testResponse.assertNotEqual(expectedResponse, actualResponse); - } - - @Test - @Order(8) - public void testGetDeviceSuccess() { - String registryId = "Rashmi_Registry_Test"; - String deviceId = "test_device01"; - String numId= "1211"; - DeviceName name = DeviceName.of(project, location, registryId, deviceId); - Device expectedResponse = testResponse.getResponseTest10(deviceId,numId); - GetDeviceRequest request = GetDeviceRequest.Builder.newBuilder().setName(name) - .setFieldMask(FieldMask.newBuilder().build()).build(); - Device actualResponse = client.getDevice(request); - testResponse.assertEqual(expectedResponse, actualResponse); - } - - @Test - @Order(9) - public void testGetDeviceAsAGatewaySuccess() { - String registryId = "Rashmi_Registry_Test"; - String deviceId = "test_device03"; - String numId= "1112"; - DeviceName name = DeviceName.of(project, location, registryId, deviceId); - Device expectedResponse = testResponse.getResponseTest11(deviceId,numId); - GetDeviceRequest request = GetDeviceRequest.Builder.newBuilder().setName(name) - .setFieldMask(FieldMask.newBuilder().build()).build(); - Device actualResponse = client.getDevice(request); - testResponse.assertEqual(expectedResponse, actualResponse); - } - - @Test - @Order(10) - @Disabled - public void testUpdateDevice() { - String deviceId = "myOldDevice"; - Device expectedResponse = testResponse.getResponseTest12(deviceId); - Device device = Device.patch(deviceId, deviceId, LogLevel.ERROR, true); - String updateMask = "logLevel"; - UpdateDeviceRequest request = UpdateDeviceRequest.Builder.newBuilder().setName(deviceId).setDevice(device) - .setUpdateMask(updateMask).build(); - Device actualResponse = client.updateDevice(request); - testResponse.assertEqual(expectedResponse, actualResponse); - - } - - @Test - @Order(11) - public void testBindDeviceToGateway() { - String registryId = "Rashmi_Registry_Test"; - String gatewayId = "Rashmi_Gateway_Test"; - String deviceId = "test_device01"; - - BindDeviceToGatewayResponse expectedResponse = testResponse.getResponseTest13(); - BindDeviceToGatewayRequest request = BindDeviceToGatewayRequest.Builder.newBuilder() - .setParent(RegistryName.of(project, location, registryId).toString()) - .setGateway(gatewayId).setDevice(deviceId).build(); - BindDeviceToGatewayResponse actualResponse = client.bindDeviceToGateway(request); - testResponse.assertEqualResponse(expectedResponse, actualResponse); - - } - - @Test - @Order(12) - public void testUnbindDeviceFromGateway() { - String registryId = "Rashmi_Registry_Test"; - String gatewayId = "Rashmi_Gateway_Test"; - String deviceId = "test_device01"; - - UnbindDeviceFromGatewayResponse expectedResponse = testResponse.getResponseTest14(); - UnbindDeviceFromGatewayRequest request = UnbindDeviceFromGatewayRequest.Builder.newBuilder() - .setParent(RegistryName.of(project, location, registryId).toString()) - .setGateway(gatewayId).setDevice(deviceId).build(); - UnbindDeviceFromGatewayResponse actualResponse = client.unbindDeviceFromGateway(request); - testResponse.assertEqualsResponse(expectedResponse, actualResponse); - } - - @Test - @Order(13) - public void testSendCommandToDevice() { - String registryId = "Rashmi_Registry_Test"; - String deviceId = "test_device01"; - String byteData = "c2VuZEZ1bm55TWVzc2FnZVRvRGV2aWNl"; - - SendCommandToDeviceResponse expectedResponse = testResponse.getResponseTest15(); - SendCommandToDeviceRequest request = SendCommandToDeviceRequest.Builder.newBuilder() - .setName(DeviceName - .of(project, location, registryId, deviceId) - .toString()) - .setBinaryData(new ByteString(byteData)).build(); - SendCommandToDeviceResponse actualResponse = client.sendCommandToDevice(request); - testResponse.assertEqualsResponses(expectedResponse, actualResponse); - - } - - @Test - @Order(14) - public void testDeleteDevice() { - String registryId = "Rashmi_Registry_Test"; - String deviceId = "test_device01"; - DeviceName deviceName = DeviceName.of(project, location, registryId, deviceId); - DeleteDeviceRequest request = DeleteDeviceRequest.Builder.newBuilder().setName(deviceName).build(); - client.deleteDevice(request); - } - - @Test - @Order(15) - public void testDeleteDeviceAsAGateway() { - String registryId = "Rashmi_Registry_Test"; - String deviceId = "test_device03"; - DeviceName deviceName = DeviceName.of(project, location, registryId, deviceId); - DeleteDeviceRequest request = DeleteDeviceRequest.Builder.newBuilder().setName(deviceName).build(); - client.deleteDevice(request); - } - - @Test - @Order(16) - public void testDeleteDeviceRegistry() { - String registryId = "testCreate_reg03"; - DeleteDeviceRegistryRequest request = DeleteDeviceRegistryRequest.Builder.newBuilder() - .setName(RegistryName.of(project, location, registryId) - .getRegistryFullName()) - .build(); - client.deleteDeviceRegistry(request); - - } - -} diff --git a/clearblade-cloud-iot/test/com/clearblade/cloud/iot/v1/test/ExpectedResponseTest.java b/clearblade-cloud-iot/test/com/clearblade/cloud/iot/v1/test/ExpectedResponseTest.java deleted file mode 100644 index 7b86b2ff..00000000 --- a/clearblade-cloud-iot/test/com/clearblade/cloud/iot/v1/test/ExpectedResponseTest.java +++ /dev/null @@ -1,383 +0,0 @@ -/* - * Copyright 2023 ClearBlade Inc. - * - * 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. - * - * 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.clearblade.cloud.iot.v1.test; - -import java.util.ArrayList; -import java.util.HashMap; - -import com.clearblade.cloud.iot.v1.binddevicetogateway.BindDeviceToGatewayResponse; -import com.clearblade.cloud.iot.v1.devicetypes.Device; -import com.clearblade.cloud.iot.v1.devicetypes.DeviceConfig; -import com.clearblade.cloud.iot.v1.devicetypes.GatewayConfig; -import com.clearblade.cloud.iot.v1.devicetypes.GatewayType; -import com.clearblade.cloud.iot.v1.devicetypes.Status; -import com.clearblade.cloud.iot.v1.registrytypes.DeviceRegistry; -import com.clearblade.cloud.iot.v1.registrytypes.HttpConfig; -import com.clearblade.cloud.iot.v1.registrytypes.HttpState; -import com.clearblade.cloud.iot.v1.registrytypes.MqttConfig; -import com.clearblade.cloud.iot.v1.registrytypes.MqttState; -import com.clearblade.cloud.iot.v1.registrytypes.StateNotificationConfig; -import com.clearblade.cloud.iot.v1.sendcommandtodevice.SendCommandToDeviceResponse; -import com.clearblade.cloud.iot.v1.unbinddevicefromgateway.UnbindDeviceFromGatewayResponse; -import com.clearblade.cloud.iot.v1.utils.LogLevel; - -public class ExpectedResponseTest { - - public boolean assertEquals(DeviceRegistry obj1, DeviceRegistry obj2) { - boolean flag = true; - if(!obj1.toBuilder().getId().equals(obj2.toBuilder().getId()) - || obj1.toBuilder().getHttpConfig().equals(obj2.toBuilder().getHttpConfig()) - || obj1.toBuilder().getMqttConfig().equals(obj2.toBuilder().getMqttConfig()) - || obj1.toBuilder().getLogLevel().equals(obj2.toBuilder().getLogLevel()) - || obj1.toBuilder().getStateNotificationConfig().equals(obj2.toBuilder().getStateNotificationConfig())) - flag = false; - return flag; - } - - public boolean assertNotEquals(DeviceRegistry obj1, DeviceRegistry obj2) { - boolean flag = true; - if(obj2 == null) - return flag; - else if(obj1.toBuilder().getId().equals(obj2.toBuilder().getId()) - || obj1.toBuilder().getHttpConfig().equals(obj2.toBuilder().getHttpConfig()) - || obj1.toBuilder().getMqttConfig().equals(obj2.toBuilder().getMqttConfig()) - || obj1.toBuilder().getLogLevel().equals(obj2.toBuilder().getLogLevel()) - || obj1.toBuilder().getStateNotificationConfig().equals(obj2.toBuilder().getStateNotificationConfig())) - flag = false; - return flag; - } - - public boolean assertEqual(Device obj1, Device obj2) { - boolean flag = true; - if(obj2 == null) - return flag; - else if(!obj1.toBuilder().getId().equals(obj2.toBuilder().getId()) - || obj1.toBuilder().getGatewayConfig().equals(obj2.toBuilder().getGatewayConfig()) - || obj1.toBuilder().getLogLevel().equals(obj2.toBuilder().getLogLevel()) - || obj1.toBuilder().getCredentials().equals(obj2.toBuilder().getCredentials())) - flag = false; - return flag; - } - - public boolean assertNotEqual(Device obj1, Device obj2) { - boolean flag = true; - if(obj2 == null) - return flag; - else if(obj1.toBuilder().getId().equals(obj2.toBuilder().getId()) - || obj1.toBuilder().getName().equals(obj2.toBuilder().getName()) - || obj1.toBuilder().getNumId().equals(obj2.toBuilder().getNumId()) - || obj1.toBuilder().getGatewayConfig().equals(obj2.toBuilder().getGatewayConfig()) - || obj1.toBuilder().getLogLevel().equals(obj2.toBuilder().getLogLevel()) - || obj1.toBuilder().getCredentials().equals(obj2.toBuilder().getCredentials())) - flag = false; - return flag; - } - - public boolean assertEqualResponse(BindDeviceToGatewayResponse obj1, BindDeviceToGatewayResponse obj2) { - boolean flag = true; - if(obj1.getHttpStatusCode() != obj2.getHttpStatusCode() || !(obj1.getHttpStatusResponse().equals(obj2.getHttpStatusResponse()))) - flag = false; - return flag; - } - - public boolean assertEqualsResponse(UnbindDeviceFromGatewayResponse obj1, UnbindDeviceFromGatewayResponse obj2) { - boolean flag = true; - if(obj1.getHttpStatusCode() != obj2.getHttpStatusCode() || !(obj1.getHttpStatusResponse().equals(obj2.getHttpStatusResponse()))) - flag = false; - return flag; - } - - public boolean assertEqualsResponses(SendCommandToDeviceResponse obj1, SendCommandToDeviceResponse obj2) { - boolean flag = true; - if(obj1.getHttpStatusCode() != obj2.getHttpStatusCode() || !(obj1.getHttpStatusResponse().equals(obj2.getHttpStatusResponse()))) - flag = false; - return flag; - } - - public DeviceRegistry getResponseTest1(String registryId) { - - HttpConfig httpConfig = new HttpConfig(); - httpConfig.setHttpEnabledState(HttpState.HTTP_ENABLED); - - MqttConfig mqttConfig = new MqttConfig(); - mqttConfig.setMqttEnabledState(MqttState.MQTT_ENABLED); - - StateNotificationConfig stateConfig = new StateNotificationConfig(); - stateConfig.setPubsubTopicName(""); - - return DeviceRegistry.newBuilder() - .setId(registryId) - .setHttpConfig(httpConfig) - .setMqttConfig(mqttConfig) - .setLogLevel(LogLevel.DEBUG) - .setStateNotificationConfig(stateConfig) - .build(); - } - - public DeviceRegistry getResponseTest2(String registryId) { - - HttpConfig httpConfig = new HttpConfig(); - httpConfig.setHttpEnabledState(HttpState.HTTP_ENABLED); - - MqttConfig mqttConfig = new MqttConfig(); - mqttConfig.setMqttEnabledState(MqttState.MQTT_ENABLED); - - StateNotificationConfig stateConfig = new StateNotificationConfig(); - stateConfig.setPubsubTopicName(""); - - return DeviceRegistry.newBuilder() - .setId(registryId) - .setCredentials(new ArrayList<>()) - .setHttpConfig(httpConfig) - .setMqttConfig(mqttConfig) - .setLogLevel(LogLevel.DEBUG) - .setEventNotificationConfigs(new ArrayList<>()) - .setStateNotificationConfig(stateConfig) - .build(); - } - - - public DeviceRegistry getResponseTest3(String registryId) { - - HttpConfig httpConfig = new HttpConfig(); - httpConfig.setHttpEnabledState(HttpState.HTTP_ENABLED); - - MqttConfig mqttConfig = new MqttConfig(); - mqttConfig.setMqttEnabledState(MqttState.MQTT_ENABLED); - - StateNotificationConfig stateConfig = new StateNotificationConfig(); - stateConfig.setPubsubTopicName(""); - - return DeviceRegistry.newBuilder() - .setId(registryId) - .setHttpConfig(httpConfig) - .setMqttConfig(mqttConfig) - .setLogLevel(LogLevel.DEBUG) - .setStateNotificationConfig(stateConfig) - .build(); - } - - public DeviceRegistry getResponseTest4(String registryId) { - - HttpConfig httpConfig = new HttpConfig(); - httpConfig.setHttpEnabledState(HttpState.HTTP_ENABLED); - - MqttConfig mqttConfig = new MqttConfig(); - mqttConfig.setMqttEnabledState(MqttState.MQTT_ENABLED); - - StateNotificationConfig stateConfig = new StateNotificationConfig(); - stateConfig.setPubsubTopicName(""); - - return DeviceRegistry.newBuilder() - .setId(registryId) - .setHttpConfig(httpConfig) - .setMqttConfig(mqttConfig) - .setLogLevel(LogLevel.DEBUG) - .setStateNotificationConfig(stateConfig) - .build(); - } - - - public DeviceRegistry getResponseTest5(String registryId) { - - HttpConfig httpConfig = new HttpConfig(); - httpConfig.setHttpEnabledState(HttpState.HTTP_ENABLED); - - MqttConfig mqttConfig = new MqttConfig(); - mqttConfig.setMqttEnabledState(MqttState.MQTT_ENABLED); - - StateNotificationConfig stateConfig = new StateNotificationConfig(); - stateConfig.setPubsubTopicName(""); - - return DeviceRegistry.newBuilder() - .setId(registryId) - .setHttpConfig(httpConfig) - .setMqttConfig(mqttConfig) - .setLogLevel(LogLevel.ERROR) - .setStateNotificationConfig(stateConfig) - .build(); - } - - - public Device getResponseTest6(String deviceId,String numId) { - - GatewayConfig gatewayConfig = new GatewayConfig(); - gatewayConfig.setGatewayType(GatewayType.NON_GATEWAY); - - return Device.newBuilder() - .setId(deviceId) - .setName(deviceId) - .setNumId(numId) - .setBlocked(false) - .setGatewayConfig(gatewayConfig) - .setLogLevel(LogLevel.DEBUG) - .setCredentials(new ArrayList<>()) - .setLastErrorStatus(new Status()) - .setConfig(new DeviceConfig()) - .setMetadata(new HashMap<>()) - .build(); - - } - - public Device getResponseTest7(String deviceId,String numId) { - - GatewayConfig gatewayConfig = new GatewayConfig(); - gatewayConfig.setGatewayType(GatewayType.NON_GATEWAY); - - return Device.newBuilder() - .setId(deviceId) - .setName(deviceId) - .setNumId(numId) - .setBlocked(false) - .setGatewayConfig(gatewayConfig) - .setLogLevel(LogLevel.DEBUG) - .setCredentials(new ArrayList<>()) - .setLastErrorStatus(new Status()) - .setConfig(new DeviceConfig()) - .setMetadata(new HashMap<>()) - .build(); - - } - - public Device getResponseTest8(String deviceId,String numId) { - - GatewayConfig gatewayConfig = new GatewayConfig(); - gatewayConfig.setGatewayType(GatewayType.GATEWAY); - - return Device.newBuilder() - .setId(deviceId) - .setName(deviceId) - .setNumId(numId) - .setBlocked(false) - .setGatewayConfig(gatewayConfig) - .setLogLevel(LogLevel.DEBUG) - .setCredentials(new ArrayList<>()) - .setLastErrorStatus(new Status()) - .setConfig(new DeviceConfig()) - .setMetadata(new HashMap<>()) - .build(); - - } - - public Device getResponseTest9(String deviceId,String numId) { - - GatewayConfig gatewayConfig = new GatewayConfig(); - gatewayConfig.setGatewayType(GatewayType.NON_GATEWAY); - - return Device.newBuilder() - .setId(deviceId) - .setName(deviceId) - .setNumId(numId) - .setBlocked(false) - .setGatewayConfig(gatewayConfig) - .setLogLevel(LogLevel.DEBUG) - .setCredentials(new ArrayList<>()) - .setLastErrorStatus(new Status()) - .setConfig(new DeviceConfig()) - .setMetadata(new HashMap<>()) - .build(); - - } - - public Device getResponseTest10(String deviceId,String numId) { - - GatewayConfig gatewayConfig = new GatewayConfig(); - gatewayConfig.setGatewayType(GatewayType.NON_GATEWAY); - - return Device.newBuilder() - .setId(deviceId) - .setName(deviceId) - .setNumId(numId) - .setBlocked(false) - .setGatewayConfig(gatewayConfig) - .setLogLevel(LogLevel.DEBUG) - .setCredentials(new ArrayList<>()) - .setLastErrorStatus(new Status()) - .setConfig(new DeviceConfig()) - .setMetadata(new HashMap<>()) - .build(); - - } - - public Device getResponseTest11(String deviceId,String numId) { - - GatewayConfig gatewayConfig = new GatewayConfig(); - gatewayConfig.setGatewayType(GatewayType.GATEWAY); - - return Device.newBuilder() - .setId(deviceId) - .setName(deviceId) - .setNumId(numId) - .setBlocked(false) - .setGatewayConfig(gatewayConfig) - .setLogLevel(LogLevel.DEBUG) - .setCredentials(new ArrayList<>()) - .setLastErrorStatus(new Status()) - .setConfig(new DeviceConfig()) - .setMetadata(new HashMap<>()) - .build(); - - } - - public Device getResponseTest12(String deviceId) { - - return Device.newBuilder() - .setId(deviceId) - .setName(deviceId) - .setBlocked(false) - .setLogLevel(LogLevel.ERROR) - .build(); - } - - public BindDeviceToGatewayResponse getResponseTest13() { - - BindDeviceToGatewayResponse response = BindDeviceToGatewayResponse.Builder.newBuilder().build(); - response.setHttpStatusCode(200); - response.setHttpStatusResponse("OK"); - return response; - } - - public UnbindDeviceFromGatewayResponse getResponseTest14() { - - UnbindDeviceFromGatewayResponse response = UnbindDeviceFromGatewayResponse.Builder.newBuilder().build(); - response.setHttpStatusCode(200); - response.setHttpStatusResponse("OK"); - return response; - } - - public SendCommandToDeviceResponse getResponseTest15() { - - SendCommandToDeviceResponse response = SendCommandToDeviceResponse.Builder.newBuilder().build(); - response.setHttpStatusCode(200); - response.setHttpStatusResponse("OK"); - return response; - } -} From 45f7cbefa6845bb5c245613f4a2f66d4d726f87d Mon Sep 17 00:00:00 2001 From: mikoaro Date: Tue, 16 May 2023 06:46:46 -0500 Subject: [PATCH 077/151] Set version to 1.0.0-rc.1 --- clearblade-cloud-iot/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/clearblade-cloud-iot/pom.xml b/clearblade-cloud-iot/pom.xml index 9ab68626..71b13c0b 100644 --- a/clearblade-cloud-iot/pom.xml +++ b/clearblade-cloud-iot/pom.xml @@ -3,7 +3,7 @@ io.github.clearblade clearblade-cloud-iot - 0.1.5 + 1.0.0-rc.1 jar Java Client Library for ClearBlade IoT Core From b4403ec9db833476749188fd4394dcf4001778e0 Mon Sep 17 00:00:00 2001 From: ronak-ingress Date: Thu, 18 May 2023 11:15:17 +0530 Subject: [PATCH 078/151] - Added few more try catch and fix of device credentials. --- .../clearblade/cloud/iot/v1/AsyncClient.java | 130 +- .../clearblade/cloud/iot/v1/SyncClient.java | 119 +- .../cloud/iot/v1/devicetypes/Device.java | 1081 ++++++++--------- 3 files changed, 720 insertions(+), 610 deletions(-) diff --git a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/AsyncClient.java b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/AsyncClient.java index 7669d9e8..85bd3b0d 100644 --- a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/AsyncClient.java +++ b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/AsyncClient.java @@ -101,35 +101,55 @@ private String generateAdminURL(AuthParams authParams, String apiName, String pa * @throws ApplicationException */ public String[] get(String apiName, GetDeviceRequest request) throws IOException, ParseException { - authParams.setRegistryCredentials(request.getName().getProject(), request.getName().getRegistry(), request.getName().getLocation()); + try { + authParams.setRegistryCredentials(request.getName().getProject(), request.getName().getRegistry(), request.getName().getLocation()); + } catch (Exception e) { + throw new ApplicationException(e); + } String finalURL = generateURL(authParams, apiName, request.toString()); String token = authParams.getUserToken(); return get(finalURL, token); } public String[] get(String apiName, String params, DevicesListRequest request) throws IOException, ParseException { - authParams.setRegistryCredentials(request.getParent().getProject(), request.getParent().getRegistry(), request.getParent().getLocation()); + try { + authParams.setRegistryCredentials(request.getParent().getProject(), request.getParent().getRegistry(), request.getParent().getLocation()); + } catch (Exception e) { + throw new ApplicationException(e); + } String finalURL = generateURL(authParams, apiName, params); String token = authParams.getUserToken(); return get(finalURL, token); } public String[] get(String apiName, String params, ListDeviceStatesRequest request) throws IOException, ParseException { - authParams.setRegistryCredentials(request.getName().getProject(), request.getName().getRegistry(), request.getName().getLocation()); + try { + authParams.setRegistryCredentials(request.getName().getProject(), request.getName().getRegistry(), request.getName().getLocation()); + } catch (Exception e) { + throw new ApplicationException(e); + } String finalURL = generateURL(authParams, apiName, params); String token = authParams.getUserToken(); return get(finalURL, token); } public String[] get(String apiName, String params, GetDeviceRegistryRequest request) { - authParams.setRegistryCredentials(request.getName().getProject(), request.getName().getRegistry(), request.getName().getLocation()); + try { + authParams.setRegistryCredentials(request.getName().getProject(), request.getName().getRegistry(), request.getName().getLocation()); + } catch (Exception e) { + throw new ApplicationException(e); + } String finalURL = generateURL(authParams, apiName, params); String token = authParams.getUserToken(); return get(finalURL, token); } public String[] get(String apiName, String params, ListDeviceConfigVersionsRequest request) throws IOException, ParseException { - authParams.setRegistryCredentials(request.getName().getProject(), request.getName().getRegistry(), request.getName().getLocation()); + try { + authParams.setRegistryCredentials(request.getName().getProject(), request.getName().getRegistry(), request.getName().getLocation()); + } catch (Exception e) { + throw new ApplicationException(e); + } String finalURL = generateURL(authParams, apiName, params); String token = authParams.getUserToken(); return get(finalURL, token); @@ -148,47 +168,68 @@ public String[] get(String finalURL, String token) { } catch (ApplicationException e) { log.log(Level.SEVERE, e.getMessage()); + throw new ApplicationException(e); } catch (InterruptedException ex) { log.log(Level.SEVERE, ex.getMessage()); Thread.currentThread().interrupt(); + throw new ApplicationException(ex); } catch (Exception ec) { log.log(Level.SEVERE, ec.getMessage()); + throw new ApplicationException(ec); } return responseArray; } public String[] post(String apiName, String params, String body, CreateDeviceRequest request) throws IOException, ParseException { - authParams.setRegistryCredentials(request.getParent().getProject(), request.getParent().getRegistry(), request.getParent().getLocation()); + try { + authParams.setRegistryCredentials(request.getParent().getProject(), request.getParent().getRegistry(), request.getParent().getLocation()); + } catch (Exception e) { + throw new ApplicationException(e); + } String finalURL = generateURL(authParams, apiName, params); String token = authParams.getUserToken(); return post(finalURL, body, token); } public String[] post(String apiName, String params, String body, SendCommandToDeviceRequest request) throws IOException, ParseException { - String finalURL = ""; - String token = ""; - authParams.setRegistryCredentials(request.getDeviceName().getProject(), request.getDeviceName().getRegistry(), request.getDeviceName().getLocation()); - finalURL = generateURL(authParams, apiName, params); - token = authParams.getUserToken(); + try { + authParams.setRegistryCredentials(request.getDeviceName().getProject(), request.getDeviceName().getRegistry(), request.getDeviceName().getLocation()); + } catch (Exception e) { + throw new ApplicationException(e); + } + String finalURL = generateURL(authParams, apiName, params); + String token = authParams.getUserToken(); return post(finalURL, body, token); } public String[] post(String apiName, String params, String body, BindDeviceToGatewayRequest request) throws IOException, ParseException { - authParams.setRegistryCredentials(request.getParent().getProject(), request.getParent().getRegistry(), request.getParent().getLocation()); + try { + authParams.setRegistryCredentials(request.getParent().getProject(), request.getParent().getRegistry(), request.getParent().getLocation()); + } catch (Exception e) { + throw new ApplicationException(e); + } String finalURL = generateURL(authParams, apiName, params); String token = authParams.getUserToken(); return post(finalURL, body, token); } public String[] post(String apiName, String params, String body, ModifyCloudToDeviceConfigRequest request) throws IOException, ParseException { - authParams.setRegistryCredentials(request.getDeviceName().getProject(), request.getDeviceName().getRegistry(), request.getDeviceName().getLocation()); + try { + authParams.setRegistryCredentials(request.getDeviceName().getProject(), request.getDeviceName().getRegistry(), request.getDeviceName().getLocation()); + } catch (Exception e) { + throw new ApplicationException(e); + } String finalURL = generateURL(authParams, apiName, params); String token = authParams.getUserToken(); return post(finalURL, body, token); } public String[] post(String apiName, String params, String body, UnbindDeviceFromGatewayRequest request) throws IOException, ParseException { - authParams.setRegistryCredentials(request.getParent().getProject(), request.getParent().getRegistry(), request.getParent().getLocation()); + try { + authParams.setRegistryCredentials(request.getParent().getProject(), request.getParent().getRegistry(), request.getParent().getLocation()); + } catch (Exception e) { + throw new ApplicationException(e); + } String finalURL = generateURL(authParams, apiName, params); String token = authParams.getUserToken(); return post(finalURL, body, token); @@ -216,26 +257,36 @@ public String[] post(String finalURL, String body, String token) { } catch (ApplicationException e) { log.log(Level.SEVERE, e.getMessage()); + throw new ApplicationException(e); } catch (InterruptedException ex) { log.log(Level.SEVERE, ex.getMessage()); Thread.currentThread().interrupt(); + throw new ApplicationException(ex); } catch (Exception ec) { log.log(Level.SEVERE, ec.getMessage()); + throw new ApplicationException(ec); } - return responseArray; } - public String[] delete(String apiName, String params, DeleteDeviceRequest request) throws IOException, ParseException { + public String[] delete(String apiName, String params, DeleteDeviceRequest request) throws IOException { String finalURL = ""; String token = ""; if (isAdmin) { - authParams.setAdminCredentials(); + try { + authParams.setAdminCredentials(); + } catch (Exception e) { + throw new ApplicationException(e); + } finalURL = generateAdminURL(authParams, apiName, params); token = authParams.getAdminToken(); } else { - authParams.setRegistryCredentials(request.getName().getProject(), request.getName().getRegistry(), request.getName().getLocation()); + try { + authParams.setRegistryCredentials(request.getName().getProject(), request.getName().getRegistry(), request.getName().getLocation()); + } catch (Exception e) { + throw new ApplicationException(e); + } finalURL = generateURL(authParams, apiName, params); token = authParams.getUserToken(); } @@ -262,30 +313,38 @@ public String[] delete(String finalURL, String token) { } catch (ApplicationException e) { log.log(Level.SEVERE, e.getMessage()); + throw new ApplicationException(e); } catch (InterruptedException ex) { log.log(Level.SEVERE, ex.getMessage()); Thread.currentThread().interrupt(); + throw new ApplicationException(ex); } catch (Exception ec) { log.log(Level.SEVERE, ec.getMessage()); + throw new ApplicationException(ec); } - return responseArray; } public String[] update(String apiName, String params, String body, UpdateDeviceRegistryRequest request) throws IOException, ParseException { - authParams.setRegistryCredentials(request.getParent().getProject(), request.getParent().getRegistry(), request.getParent().getLocation()); + try { + authParams.setRegistryCredentials(request.getParent().getProject(), request.getParent().getRegistry(), request.getParent().getLocation()); + } catch (Exception e) { + throw new ApplicationException(e); + } String finalURL = generateURL(authParams, apiName, params); String token = authParams.getUserToken(); return update(finalURL, body, token); } public String[] update(String apiName, String params, String body, UpdateDeviceRequest request) throws IOException, ParseException { - String finalURL = ""; - String token = ""; - authParams.setRegistryCredentials(request.getDeviceName().getProject(), request.getDeviceName().getRegistry(), request.getDeviceName().getLocation()); - finalURL = generateURL(authParams, apiName, params); - token = authParams.getUserToken(); + try { + authParams.setRegistryCredentials(request.getDeviceName().getProject(), request.getDeviceName().getRegistry(), request.getDeviceName().getLocation()); + } catch (Exception e) { + throw new ApplicationException(e); + } + String finalURL = generateURL(authParams, apiName, params); + String token = authParams.getUserToken(); return update(finalURL, body, token); } @@ -310,11 +369,14 @@ public String[] update(String finalURL, String body, String token) { } catch (ApplicationException e) { log.log(Level.SEVERE, e.getMessage()); + throw new ApplicationException(e); } catch (InterruptedException ex) { log.log(Level.SEVERE, ex.getMessage()); Thread.currentThread().interrupt(); + throw new ApplicationException(ex); } catch (Exception ec) { log.log(Level.SEVERE, ec.getMessage()); + throw new ApplicationException(ec); } return responseArray; @@ -326,7 +388,11 @@ public String[] asyncCreateDeviceRegistry(String apiName, String params, String String finalURL = ""; String token = ""; if (isAdmin) { - authParams.setAdminCredentials(); + try { + authParams.setAdminCredentials(); + } catch (Exception e) { + throw new ApplicationException(e); + } finalURL = generateAdminURL(authParams, apiName, params); token = authParams.getAdminToken(); } @@ -335,7 +401,11 @@ public String[] asyncCreateDeviceRegistry(String apiName, String params, String public String[] asyncDeleteDeviceRegistry(String apiName, String params, boolean isAdmin) throws IOException { - authParams.setAdminCredentials(); + try { + authParams.setAdminCredentials(); + } catch (Exception e) { + throw new ApplicationException(e); + } String finalURL = generateAdminURL(authParams, apiName, params); String token = authParams.getAdminToken(); return this.delete(finalURL, token); @@ -346,7 +416,11 @@ public String[] asyncListDeviceRegistries(String apiName, String params, boolean String finalURL = ""; String token = ""; if (isAdmin) { - authParams.setAdminCredentials(); + try { + authParams.setAdminCredentials(); + } catch (Exception e) { + throw new ApplicationException(e); + } finalURL = generateAdminURL(authParams, apiName, params); token = authParams.getAdminToken(); } diff --git a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/SyncClient.java b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/SyncClient.java index b6827f98..4e5d8a8d 100644 --- a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/SyncClient.java +++ b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/SyncClient.java @@ -89,40 +89,59 @@ private String generateURL(AuthParams authParams, String apiName, String params) * @return URL formed and to be used */ private String generateAdminURL(AuthParams authParams, String apiName, String params) { - return authParams.getBaseURL().concat(configParameters.getWebhook()).concat(authParams.getAdminSystemKey()).concat(apiName).concat("?" + params); } public String[] get(String apiName, GetDeviceRequest request) { - authParams.setRegistryCredentials(request.getName().getProject(), request.getName().getRegistry(), request.getName().getLocation()); + try { + authParams.setRegistryCredentials(request.getName().getProject(), request.getName().getRegistry(), request.getName().getLocation()); + } catch (Exception e) { + throw new ApplicationException(e); + } String finalURL = generateURL(authParams, apiName, request.toString()); String token = authParams.getUserToken(); return get(finalURL, token); } public String[] get(String apiName, String params, DevicesListRequest request) { - authParams.setRegistryCredentials(request.getParent().getProject(), request.getParent().getRegistry(), request.getParent().getLocation()); + try { + authParams.setRegistryCredentials(request.getParent().getProject(), request.getParent().getRegistry(), request.getParent().getLocation()); + } catch (Exception e) { + throw new ApplicationException(e); + } String finalURL = generateURL(authParams, apiName, params); String token = authParams.getUserToken(); return get(finalURL, token); } public String[] get(String apiName, String params, ListDeviceStatesRequest request) { - authParams.setRegistryCredentials(request.getName().getProject(), request.getName().getRegistry(), request.getName().getLocation()); + try { + authParams.setRegistryCredentials(request.getName().getProject(), request.getName().getRegistry(), request.getName().getLocation()); + } catch (Exception e) { + throw new ApplicationException(e); + } String finalURL = generateURL(authParams, apiName, params); String token = authParams.getUserToken(); return get(finalURL, token); } public String[] get(String apiName, String params, GetDeviceRegistryRequest request) { - authParams.setRegistryCredentials(request.getName().getProject(), request.getName().getRegistry(), request.getName().getLocation()); + try { + authParams.setRegistryCredentials(request.getName().getProject(), request.getName().getRegistry(), request.getName().getLocation()); + } catch (Exception e) { + throw new ApplicationException(e); + } String finalURL = generateURL(authParams, apiName, params); String token = authParams.getUserToken(); return get(finalURL, token); } public String[] get(String apiName, String params, ListDeviceConfigVersionsRequest request) { - authParams.setRegistryCredentials(request.getName().getProject(), request.getName().getRegistry(), request.getName().getLocation()); + try { + authParams.setRegistryCredentials(request.getName().getProject(), request.getName().getRegistry(), request.getName().getLocation()); + } catch (Exception e) { + throw new ApplicationException(e); + } String finalURL = generateURL(authParams, apiName, params); String token = authParams.getUserToken(); return get(finalURL, token); @@ -146,8 +165,6 @@ public String[] get(String apiName, String params, boolean isAdmin) { /** * Method used to Calls HTTP Get request * - * @param apiName - * @param params * @return String[] containing responseCode, responseMessage and response object * @throws IOException * @throws ApplicationException @@ -162,50 +179,67 @@ public String[] get(String finalURL, String token) { responseArray[0] = String.valueOf(response.statusCode()); responseArray[1] = ""; responseArray[2] = response.body(); - - } catch (InterruptedException e) { log.log(Level.SEVERE, e.getMessage()); Thread.currentThread().interrupt(); + throw new ApplicationException(e); } catch (Exception ex) { log.log(Level.SEVERE, ex.getMessage()); + throw new ApplicationException(ex); } - return responseArray; } public String[] post(String apiName, String params, String body, CreateDeviceRequest request) { - authParams.setRegistryCredentials(request.getParent().getProject(), request.getParent().getRegistry(), request.getParent().getLocation()); + try { + authParams.setRegistryCredentials(request.getParent().getProject(), request.getParent().getRegistry(), request.getParent().getLocation()); + } catch (Exception e) { + throw new ApplicationException(e); + } String finalURL = generateURL(authParams, apiName, params); String token = authParams.getUserToken(); return post(finalURL, body, token); } public String[] post(String apiName, String params, String body, SendCommandToDeviceRequest request) { - String finalURL = ""; - String token = ""; - authParams.setRegistryCredentials(request.getDeviceName().getProject(), request.getDeviceName().getRegistry(), request.getDeviceName().getLocation()); - finalURL = generateURL(authParams, apiName, params); - token = authParams.getUserToken(); + try { + authParams.setRegistryCredentials(request.getDeviceName().getProject(), request.getDeviceName().getRegistry(), request.getDeviceName().getLocation()); + } catch (Exception e) { + throw new ApplicationException(e); + } + String finalURL = generateURL(authParams, apiName, params); + String token = authParams.getUserToken(); return post(finalURL, body, token); } public String[] post(String apiName, String params, String body, BindDeviceToGatewayRequest request) { - authParams.setRegistryCredentials(request.getParent().getProject(), request.getParent().getRegistry(), request.getParent().getLocation()); + try { + authParams.setRegistryCredentials(request.getParent().getProject(), request.getParent().getRegistry(), request.getParent().getLocation()); + } catch (Exception e) { + throw new ApplicationException(e); + } String finalURL = generateURL(authParams, apiName, params); String token = authParams.getUserToken(); return post(finalURL, body, token); } public String[] post(String apiName, String params, String body, ModifyCloudToDeviceConfigRequest request) { - authParams.setRegistryCredentials(request.getDeviceName().getProject(), request.getDeviceName().getRegistry(), request.getDeviceName().getLocation()); + try { + authParams.setRegistryCredentials(request.getDeviceName().getProject(), request.getDeviceName().getRegistry(), request.getDeviceName().getLocation()); + } catch (Exception e) { + throw new ApplicationException(e); + } String finalURL = generateURL(authParams, apiName, params); String token = authParams.getUserToken(); return post(finalURL, body, token); } public String[] post(String apiName, String params, String body, UnbindDeviceFromGatewayRequest request) { - authParams.setRegistryCredentials(request.getParent().getProject(), request.getParent().getRegistry(), request.getParent().getLocation()); + try { + authParams.setRegistryCredentials(request.getParent().getProject(), request.getParent().getRegistry(), request.getParent().getLocation()); + } catch (Exception e) { + throw new ApplicationException(e); + } String finalURL = generateURL(authParams, apiName, params); String token = authParams.getUserToken(); return post(finalURL, body, token); @@ -229,8 +263,6 @@ public String[] post(String apiName, String params, String body, boolean isAdmin /** * Method used to call HTTP Post request * - * @param apiName - * @param params * @param body * @return String[] containing responseCode, responseMessage and response object * @throws IOException @@ -247,18 +279,23 @@ public String[] post(String finalURL, String body, String token) { responseArray[0] = String.valueOf(response.statusCode()); responseArray[1] = ""; responseArray[2] = response.body(); - } catch (ApplicationException e) { log.log(Level.SEVERE, e.getMessage()); Thread.currentThread().interrupt(); + throw new ApplicationException(e); } catch (Exception ec) { log.log(Level.SEVERE, ec.getMessage()); + throw new ApplicationException(ec); } return responseArray; } public String[] delete(String apiName, String params, boolean isAdmin, DeleteDeviceRequest request) { - authParams.setRegistryCredentials(request.getName().getProject(), request.getName().getRegistry(), request.getName().getLocation()); + try { + authParams.setRegistryCredentials(request.getName().getProject(), request.getName().getRegistry(), request.getName().getLocation()); + } catch (Exception e) { + throw new ApplicationException(e); + } String finalURL = generateURL(authParams, apiName, params); String token = authParams.getUserToken(); return this.delete(finalURL, token); @@ -267,7 +304,7 @@ public String[] delete(String apiName, String params, boolean isAdmin, DeleteDev public String[] delete(String apiName, String params, boolean isAdmin) { try { authParams.setAdminCredentials(); - } catch (IOException e) { + } catch (Exception e) { throw new ApplicationException(e); } String finalURL = generateAdminURL(authParams, apiName, params); @@ -292,42 +329,41 @@ public String[] delete(String finalURL, String token) { responseArray[0] = String.valueOf(response.statusCode()); responseArray[1] = ""; responseArray[2] = response.body(); - - } catch (InterruptedException e) { log.log(Level.SEVERE, e.getMessage()); Thread.currentThread().interrupt(); + throw new ApplicationException(e); } catch (Exception ex) { log.log(Level.SEVERE, ex.getMessage()); + throw new ApplicationException(ex); } return responseArray; } public String[] update(String apiName, String params, String body, UpdateDeviceRequest request) throws InterruptedException { - String finalURL = ""; - String token = ""; - authParams.setRegistryCredentials(request.getDeviceName().getProject(), request.getDeviceName().getRegistry(), request.getDeviceName().getLocation()); - finalURL = generateURL(authParams, apiName, params); - token = authParams.getUserToken(); + try { + authParams.setRegistryCredentials(request.getDeviceName().getProject(), request.getDeviceName().getRegistry(), request.getDeviceName().getLocation()); + } catch (Exception e) { + throw new ApplicationException(e); + } + String finalURL = generateURL(authParams, apiName, params); + String token = authParams.getUserToken(); return update(finalURL, body, token); } public String[] update(String apiName, String params, String body, UpdateDeviceRegistryRequest request) throws InterruptedException { - authParams.setRegistryCredentials(request.getParent().getProject(), request.getParent().getRegistry(), request.getParent().getLocation()); + try { + authParams.setRegistryCredentials(request.getParent().getProject(), request.getParent().getRegistry(), request.getParent().getLocation()); + } catch (Exception e) { + throw new ApplicationException(e); + } String finalURL = generateURL(authParams, apiName, params); String token = authParams.getUserToken(); return update(finalURL, body, token); } - /** - * Method used to call HTTP Patch request - * - * @param apiName - * @param params - * @param body - * @return String[] containing responseCode, responseMessage and response object - */ + public String[] update(String finalURL, String body, String token) throws InterruptedException { String[] responseArray = new String[3]; try { @@ -342,6 +378,7 @@ public String[] update(String finalURL, String body, String token) throws Interr } catch (Exception ex) { log.log(Level.SEVERE, ex.getMessage()); + throw new ApplicationException(ex); } return responseArray; } diff --git a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/devicetypes/Device.java b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/devicetypes/Device.java index 800d5a5f..375ae120 100644 --- a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/devicetypes/Device.java +++ b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/devicetypes/Device.java @@ -46,546 +46,545 @@ import com.clearblade.cloud.iot.v1.utils.LogLevel; public class Device { - static Logger log = Logger.getLogger(Device.class.getName()); - - private String id; - private String name; - private String numId; - private List credentials; - private String lastHeartbeatTime; - private String lastEventTime; - private String lastStateTime; - private String lastConfigAckTime; - private String lastConfigSendTime; - private boolean blocked; - private String lastErrorTime; - private Status lastErrorStatus; - private DeviceConfig config; - private DeviceState state; - private LogLevel logLevel; - private Map metadata; - private GatewayConfig gatewayConfig; - - public Device() { - id = null; - name = null; - numId = null; - credentials = new ArrayList<>(); - lastHeartbeatTime = null; - lastEventTime = null; - lastStateTime = null; - lastConfigAckTime = null; - lastConfigSendTime = null; - blocked = false; - lastErrorTime = null; - lastErrorStatus = new Status(); - lastErrorStatus.setCode(0); - lastErrorStatus.setMessage(""); - config = new DeviceConfig(); - config.setCloudUpdateTime(""); - config.setBinaryData(""); - config.setDeviceAckTime(""); - config.setVersion(""); - state = new DeviceState(); - state.setBinaryData(""); - state.setUpdateTime(""); - logLevel = LogLevel.NONE; - metadata = new HashMap<>(); - gatewayConfig = new GatewayConfig(); - gatewayConfig.setGatewayAuthMethod(GatewayAuthMethod.UNRECOGNIZED); - gatewayConfig.setGatewayType(GatewayType.NON_GATEWAY); - gatewayConfig.setLastAccessedGatewayId(""); - gatewayConfig.setLastAccessedGatewayTime(""); - } - - private Device(Builder builder) { - id = builder.getId(); - name = builder.getName(); - numId = builder.getNumId(); - credentials = builder.getCredentials(); - lastHeartbeatTime = builder.getLastHeartbeatTime(); - lastEventTime = builder.getLastEventTime(); - lastStateTime = builder.getLastStateTime(); - lastConfigAckTime = builder.getLastConfigAckTime(); - lastConfigSendTime = builder.getLastConfigSendTime(); - blocked = builder.isBlocked(); - lastErrorTime = builder.getLastErrorTime(); - lastErrorStatus = builder.getLastErrorStatus(); - config = builder.getConfig(); - state = builder.getState(); - logLevel = builder.getLogLevel(); - metadata = builder.getMetadata(); - gatewayConfig = builder.getGatewayConfig(); - } - - public static Builder newBuilder() { - return new Builder(); - } - - public Builder toBuilder() { - return new Builder(this); - } - - public static Device of(String id, String name, String numId, List credentials, - String lastHeartbeatTime, String lastEventTime, String lastStateTime, String lastConfigAckTime, - String lastConfigSendTime, boolean blocked, String lastErrorTime, Status lastErrorStatus, - DeviceConfig config, DeviceState state, LogLevel logLevel, Map metadata, - GatewayConfig gatewayConfig) { - - return newBuilder().setId(id).setName(name).setNumId(numId).setCredentials(credentials) - .setLastHeartbeatTime(lastHeartbeatTime).setLastEventTime(lastEventTime).setLastStateTime(lastStateTime) - .setLastConfigAckTime(lastConfigAckTime).setLastConfigSendTime(lastConfigSendTime).setBlocked(blocked) - .setLastErrorTime(lastErrorTime).setLastErrorStatus(lastErrorStatus).setConfig(config).setState(state) - .setLogLevel(logLevel).setMetadata(metadata).setGatewayConfig(gatewayConfig).build(); - } - - public static Device patch(String id, String name, LogLevel logLevel, boolean blocked) { - return newBuilder().setId(id).setName(name).setLogLevel(logLevel).setBlocked(blocked).build(); - } - - public static String format(String id, String name, String numId, List credentials, - String lastHeartbeatTime, String lastEventTime, String lastStateTime, String lastConfigAckTime, - String lastConfigSendTime, boolean blocked, String lastErrorTime, Status lastErrorStatus, - DeviceConfig config, DeviceState state, LogLevel logLevel, Map metadata, - GatewayConfig gatewayConfig) { - - return newBuilder().setId(id).setName(name).setNumId(numId).setCredentials(credentials) - .setLastHeartbeatTime(lastHeartbeatTime).setLastEventTime(lastEventTime).setLastStateTime(lastStateTime) - .setLastConfigAckTime(lastConfigAckTime).setLastConfigSendTime(lastConfigSendTime).setBlocked(blocked) - .setLastErrorTime(lastErrorTime).setLastErrorStatus(lastErrorStatus).setConfig(config).setState(state) - .setLogLevel(logLevel).setMetadata(metadata).setGatewayConfig(gatewayConfig).build().toString(); - } - - /** - * Builder for setting Device - id, name, credentials and logLevel - */ - public static class Builder { - private String id; - private String name; - private String numId; - private List credentials; - private String lastHeartbeatTime; - private String lastEventTime; - private String lastStateTime; - private String lastConfigAckTime; - private String lastConfigSendTime; - private boolean blocked; - private String lastErrorTime; - private Status lastErrorStatus; - private DeviceConfig config; - private DeviceState state; - private LogLevel logLevel; - private Map metadata; - private GatewayConfig gatewayConfig; - - protected Builder() { - - } - - public String getId() { - return id; - } - - public String getName() { - return name; - } - - public String getNumId() { - return numId; - } - - public List getCredentials() { - return credentials; - } - - public String getLastHeartbeatTime() { - return lastHeartbeatTime; - } - - public String getLastEventTime() { - return lastEventTime; - } - - public String getLastStateTime() { - return lastStateTime; - } - - public String getLastConfigAckTime() { - return lastConfigAckTime; - } - - public String getLastConfigSendTime() { - return lastConfigSendTime; - } - - public boolean isBlocked() { - return blocked; - } - - public String getLastErrorTime() { - return lastErrorTime; - } - - public Status getLastErrorStatus() { - return lastErrorStatus; - } - - public DeviceConfig getConfig() { - return config; - } - - public DeviceState getState() { - return state; - } - - public Map getMetadata() { - return metadata; - } - - public GatewayConfig getGatewayConfig() { - return gatewayConfig; - } - - public LogLevel getLogLevel() { - return logLevel; - } - - public static Builder newBuilder() { - return newBuilder(); - } - - public Builder setId(String id) { - this.id = id; - return this; - } - - public Builder setName(String name) { - this.name = name; - return this; - } - - public Builder setNumId(String numId) { - this.numId = numId; - return this; - } - - public Builder setCredentials(List credentials) { - this.credentials = credentials; - return this; - } - - public Builder setLastErrorStatus(Status lastErrorStatus) { - this.lastErrorStatus = lastErrorStatus; - return this; - } - - public Builder setConfig(DeviceConfig config) { - this.config = config; - return this; - } - - public Builder setLogLevel(LogLevel logLevel) { - this.logLevel = logLevel; - return this; - } - - public Builder setState(DeviceState state) { - this.state = state; - return this; - } - - public Builder setMetadata(Map metadata) { - this.metadata = metadata; - return this; - } - - public Builder setGatewayConfig(GatewayConfig gatewayConfig) { - this.gatewayConfig = gatewayConfig; - return this; - } - - public Builder setBlocked(boolean blocked) { - this.blocked = blocked; - return this; - } - - public Builder setLastHeartbeatTime(String lastHeartbeatTime) { - this.lastHeartbeatTime = lastHeartbeatTime; - return this; - } - - public Builder setLastEventTime(String lastEventTime) { - this.lastEventTime = lastEventTime; - return this; - } - - public Builder setLastStateTime(String lastStateTime) { - this.lastStateTime = lastStateTime; - return this; - } - - public Builder setLastConfigAckTime(String lastConfigAckTime) { - this.lastConfigAckTime = lastConfigAckTime; - return this; - } - - public Builder setLastConfigSendTime(String lastConfigSendTime) { - this.lastConfigSendTime = lastConfigSendTime; - return this; - } - - public Builder setLastErrorTime(String lastErrorTime) { - this.lastErrorTime = lastErrorTime; - return this; - } - - private Builder(Device device) { - this.id = device.id; - this.name = device.name; - this.numId = device.numId; - this.credentials = device.credentials; - this.lastHeartbeatTime = device.lastHeartbeatTime; - this.lastEventTime = device.lastEventTime; - this.lastStateTime = device.lastStateTime; - this.lastConfigAckTime = device.lastConfigAckTime; - this.lastConfigSendTime = device.lastConfigSendTime; - this.blocked = device.blocked; - this.lastErrorTime = device.lastErrorTime; - this.lastErrorStatus = device.lastErrorStatus; - this.config = device.config; - this.state = device.state; - this.logLevel = device.logLevel; - this.metadata = device.metadata; - this.gatewayConfig = device.gatewayConfig; - } - - public Device build() { - return new Device(this); - } - } - - @Override - public String toString() { - String deviceStr = ""; - deviceStr = deviceStr.concat("id=" + this.id + ",name=" + this.name + ",numId=" + this.numId + ",credentials=" - + this.credentials + ",lastHeartbeatTime=" + this.lastHeartbeatTime + ",lastEventTime=" - + this.lastEventTime + ",lastStateTime=" + this.lastStateTime + ",lastConfigAckTime=" - + this.lastConfigAckTime + ",lastConfigSendTime=" + this.lastConfigSendTime + ",blocked=" + this.blocked - + ",lastErrorTime=" + this.lastErrorTime + ",lastErrorStatus=" + this.lastErrorStatus + ",config=" - + this.config + ",state=" + this.state + ",logLevel=" + this.logLevel + ",metadata=" + this.metadata - + ",gatewayConfig=" + this.gatewayConfig); - return deviceStr; - } - - @SuppressWarnings({ "unchecked", "rawtypes" }) - public String createDeviceJSONObject() { - String bodyStr = ""; - JSONObject deviceObj = new JSONObject(); - deviceObj.put("id", this.id); - deviceObj.put("name", this.name); - if (this.numId != null) { - deviceObj.put("numId", this.numId); - } - JSONArray jsonArray = new JSONArray(); - if (this.credentials.size() > 0) { - - for (int i = 0; i < this.credentials.size(); i++) { - if (!this.credentials.get(i).isEmpty()) { - DeviceCredential credentialObj = this.credentials.get(i); - jsonArray.add(credentialObj.toJSONObject()); - } - } - } - deviceObj.put("credentials", jsonArray); - deviceObj.put("gatewayConfig", this.gatewayConfig.toJSONObject()); - deviceObj.put("logLevel", this.logLevel.name()); - - if (this.lastHeartbeatTime != null) { - deviceObj.put("lastHeartbeatTime", this.lastHeartbeatTime); - } - - if (this.lastEventTime != null) { - deviceObj.put("lastEventTime", this.lastEventTime); - } - - if (this.lastStateTime != null) { - deviceObj.put("lastStateTime", this.lastStateTime); - } - - if (this.lastConfigAckTime != null) { - deviceObj.put("lastConfigAckTime", this.lastConfigAckTime); - } - - if (this.lastConfigSendTime != null) { - deviceObj.put("lastConfigSendTime", this.lastConfigSendTime); - } - - deviceObj.put("blocked", this.blocked); - - if (this.lastErrorTime != null) - deviceObj.put("lastErrorTime", this.lastErrorTime); - - if (this.metadata != null && this.metadata.size() > 0) { - Set metaSet = this.metadata.keySet(); - Iterator itr = metaSet.iterator(); - JSONObject jsonObject = new JSONObject(); - while (itr.hasNext()) { - String key = (String) itr.next(); - String value = this.metadata.get(key).toString(); - jsonObject.put(key, value); - } - deviceObj.put("metadata", jsonObject); - } - - if (this.lastErrorStatus != null && this.lastErrorStatus.getCode() != 0) { - deviceObj.put("lastErrorStatus", this.lastErrorStatus.toJSONObject()); - } - - String lastEventTime = ""; - if (this.lastEventTime != null) { - lastEventTime = this.lastEventTime.toString(); - deviceObj.put("lastEventTime", lastEventTime); - } - - if (this.config != null) { - deviceObj.put("config", this.config.toJSONObject()); - } - - if (this.state != null) { - deviceObj.put("state", this.state.toJSONObject()); - } - - bodyStr = deviceObj.toString(); - return bodyStr; - } - - @SuppressWarnings("rawtypes") - public void loadFromString(String inputStr) { - try { - JSONParser parser = new JSONParser(); - JSONObject deviceObj = (JSONObject) parser.parse(inputStr); - - if (deviceObj != null && deviceObj.size() > 0) { - - Set deviceSet = deviceObj.keySet(); - Iterator itr = deviceSet.iterator(); - while (itr.hasNext()) { - String key = (String) itr.next(); - Object value = deviceObj.get(key); - - if (key.equals("id")) { - this.id = value.toString(); - } - if (key.equals("name")) { - this.name = value.toString(); - } - if (key.equals("numId")) { - this.numId = value.toString(); - } - if (key.equals("lastHeartbeatTime")) { - this.lastHeartbeatTime = value.toString(); - } - if (key.equals("lastEventTime")) { - this.lastEventTime = value.toString(); - } - if (key.equals("lastStateTime")) { - this.lastStateTime = value.toString(); - } - if (key.equals("lastConfigAckTime")) { - this.lastConfigAckTime = value.toString(); - } - if (key.equals("lastConfigSendTime")) { - this.lastConfigSendTime = value.toString(); - } - if (key.equals("blocked")) { - this.blocked = Boolean.valueOf(value.toString()); - } - if (key.equals("lastErrorTime")) { - this.lastErrorTime = value.toString(); - } - if (key.equals("lastErrorStatus")) { - JSONObject errorStatus = (JSONObject) value; - Status status = new Status(); - if (errorStatus.containsKey("code")) - status.setCode(errorStatus.get("code")); - if (errorStatus.containsKey("message")) - status.setMessage((String) errorStatus.get("message")); - this.lastErrorStatus = status; - } - - if (key.equals("config")) { - JSONObject configJsonObject = (JSONObject) value; - DeviceConfig deviceCfg = new DeviceConfig(); - if (configJsonObject.containsKey("version")) - deviceCfg.setVersion((String) configJsonObject.get("version")); - if (configJsonObject.containsKey("cloudUpdateTime")) - deviceCfg.setCloudUpdateTime((String) configJsonObject.get("cloudUpdateTime")); - if (configJsonObject.containsKey("deviceAckTime")) - deviceCfg.setDeviceAckTime((String) configJsonObject.get("deviceAckTime")); - if (configJsonObject.containsKey("binaryData")) - deviceCfg.setBinaryData((String) configJsonObject.get("binaryData")); - this.config = deviceCfg; - } - - if (key.equals("state")) { - JSONObject stateJsonObject = (JSONObject) value; - DeviceState deviceState = new DeviceState(); - if (stateJsonObject.containsKey("binaryData")) - deviceState.setBinaryData((String) stateJsonObject.get("binaryData")); - if (stateJsonObject.containsKey("updateTime")) - deviceState.setUpdateTime((String) stateJsonObject.get("updateTime")); - this.state = deviceState; - } - - if (key.equals("logLevel")) { - if (value != null) { - this.logLevel = LogLevel.valueOf(value.toString()); - } - } - - if (key.equals("metadata")) { - JSONObject metadataJsonObject = (JSONObject) value; - if (metadataJsonObject != null) { - Map metadataMap = new HashMap<>(); - Set metadataSet = metadataJsonObject.keySet(); - if (metadataSet.size() > 0) { - Iterator metadIterator = metadataSet.iterator(); - while (metadIterator.hasNext()) { - String metadataKey = (String) metadIterator.next(); - String metatdataValue = (String) metadataJsonObject.get(metadataKey); - metadataMap.put(metadataKey, metatdataValue); - } - } - - this.metadata = metadataMap; - } - } - if (key.equals("gatewayConfig")) { - JSONObject gatewayConfigJsonObject = (JSONObject) value; - if (gatewayConfigJsonObject != null) { - GatewayConfig gatewayConfig = new GatewayConfig(); - if (gatewayConfigJsonObject.containsKey("gatewayType")) - gatewayConfig.setGatewayType( - GatewayType.valueOf((String) gatewayConfigJsonObject.get("gatewayType"))); - if (gatewayConfigJsonObject.containsKey("gatewayAuthMethod")) - gatewayConfig.setGatewayAuthMethod(GatewayAuthMethod - .valueOf((String) gatewayConfigJsonObject.get("gatewayAuthMethod"))); - if (gatewayConfigJsonObject.containsKey("lastAccessedGatewayId")) - gatewayConfig.setLastAccessedGatewayId( - (String) gatewayConfigJsonObject.get("lastAccessedGatewayId")); - if (gatewayConfigJsonObject.containsKey("lastAccessedGatewayTime")) - gatewayConfig.setLastAccessedGatewayTime( - (String) gatewayConfigJsonObject.get("lastAccessedGatewayTime")); - - this.gatewayConfig = gatewayConfig; - } - } - } - } - - } catch (Exception e) { - log.log(Level.SEVERE, e.getMessage()); - } - } + static Logger log = Logger.getLogger(Device.class.getName()); + + private String id; + private String name; + private String numId; + private List credentials; + private String lastHeartbeatTime; + private String lastEventTime; + private String lastStateTime; + private String lastConfigAckTime; + private String lastConfigSendTime; + private boolean blocked; + private String lastErrorTime; + private Status lastErrorStatus; + private DeviceConfig config; + private DeviceState state; + private LogLevel logLevel; + private Map metadata; + private GatewayConfig gatewayConfig; + + public Device() { + id = null; + name = null; + numId = null; + credentials = new ArrayList<>(); + lastHeartbeatTime = null; + lastEventTime = null; + lastStateTime = null; + lastConfigAckTime = null; + lastConfigSendTime = null; + blocked = false; + lastErrorTime = null; + lastErrorStatus = new Status(); + lastErrorStatus.setCode(0); + lastErrorStatus.setMessage(""); + config = new DeviceConfig(); + config.setCloudUpdateTime(""); + config.setBinaryData(""); + config.setDeviceAckTime(""); + config.setVersion(""); + state = new DeviceState(); + state.setBinaryData(""); + state.setUpdateTime(""); + logLevel = LogLevel.NONE; + metadata = new HashMap<>(); + gatewayConfig = new GatewayConfig(); + gatewayConfig.setGatewayAuthMethod(GatewayAuthMethod.UNRECOGNIZED); + gatewayConfig.setGatewayType(GatewayType.NON_GATEWAY); + gatewayConfig.setLastAccessedGatewayId(""); + gatewayConfig.setLastAccessedGatewayTime(""); + } + + private Device(Builder builder) { + id = builder.getId(); + name = builder.getName(); + numId = builder.getNumId(); + credentials = builder.getCredentials(); + lastHeartbeatTime = builder.getLastHeartbeatTime(); + lastEventTime = builder.getLastEventTime(); + lastStateTime = builder.getLastStateTime(); + lastConfigAckTime = builder.getLastConfigAckTime(); + lastConfigSendTime = builder.getLastConfigSendTime(); + blocked = builder.isBlocked(); + lastErrorTime = builder.getLastErrorTime(); + lastErrorStatus = builder.getLastErrorStatus(); + config = builder.getConfig(); + state = builder.getState(); + logLevel = builder.getLogLevel(); + metadata = builder.getMetadata(); + gatewayConfig = builder.getGatewayConfig(); + } + + public static Builder newBuilder() { + return new Builder(); + } + + public Builder toBuilder() { + return new Builder(this); + } + + public static Device of(String id, String name, String numId, List credentials, + String lastHeartbeatTime, String lastEventTime, String lastStateTime, String lastConfigAckTime, + String lastConfigSendTime, boolean blocked, String lastErrorTime, Status lastErrorStatus, + DeviceConfig config, DeviceState state, LogLevel logLevel, Map metadata, + GatewayConfig gatewayConfig) { + + return newBuilder().setId(id).setName(name).setNumId(numId).setCredentials(credentials) + .setLastHeartbeatTime(lastHeartbeatTime).setLastEventTime(lastEventTime).setLastStateTime(lastStateTime) + .setLastConfigAckTime(lastConfigAckTime).setLastConfigSendTime(lastConfigSendTime).setBlocked(blocked) + .setLastErrorTime(lastErrorTime).setLastErrorStatus(lastErrorStatus).setConfig(config).setState(state) + .setLogLevel(logLevel).setMetadata(metadata).setGatewayConfig(gatewayConfig).build(); + } + + public static Device patch(String id, String name, LogLevel logLevel, boolean blocked) { + return newBuilder().setId(id).setName(name).setLogLevel(logLevel).setBlocked(blocked).build(); + } + + public static String format(String id, String name, String numId, List credentials, + String lastHeartbeatTime, String lastEventTime, String lastStateTime, String lastConfigAckTime, + String lastConfigSendTime, boolean blocked, String lastErrorTime, Status lastErrorStatus, + DeviceConfig config, DeviceState state, LogLevel logLevel, Map metadata, + GatewayConfig gatewayConfig) { + + return newBuilder().setId(id).setName(name).setNumId(numId).setCredentials(credentials) + .setLastHeartbeatTime(lastHeartbeatTime).setLastEventTime(lastEventTime).setLastStateTime(lastStateTime) + .setLastConfigAckTime(lastConfigAckTime).setLastConfigSendTime(lastConfigSendTime).setBlocked(blocked) + .setLastErrorTime(lastErrorTime).setLastErrorStatus(lastErrorStatus).setConfig(config).setState(state) + .setLogLevel(logLevel).setMetadata(metadata).setGatewayConfig(gatewayConfig).build().toString(); + } + + /** + * Builder for setting Device - id, name, credentials and logLevel + */ + public static class Builder { + private String id; + private String name; + private String numId; + private List credentials; + private String lastHeartbeatTime; + private String lastEventTime; + private String lastStateTime; + private String lastConfigAckTime; + private String lastConfigSendTime; + private boolean blocked; + private String lastErrorTime; + private Status lastErrorStatus; + private DeviceConfig config; + private DeviceState state; + private LogLevel logLevel; + private Map metadata; + private GatewayConfig gatewayConfig; + + protected Builder() { + + } + + public String getId() { + return id; + } + + public String getName() { + return name; + } + + public String getNumId() { + return numId; + } + + public List getCredentials() { + return credentials; + } + + public String getLastHeartbeatTime() { + return lastHeartbeatTime; + } + + public String getLastEventTime() { + return lastEventTime; + } + + public String getLastStateTime() { + return lastStateTime; + } + + public String getLastConfigAckTime() { + return lastConfigAckTime; + } + + public String getLastConfigSendTime() { + return lastConfigSendTime; + } + + public boolean isBlocked() { + return blocked; + } + + public String getLastErrorTime() { + return lastErrorTime; + } + + public Status getLastErrorStatus() { + return lastErrorStatus; + } + + public DeviceConfig getConfig() { + return config; + } + + public DeviceState getState() { + return state; + } + + public Map getMetadata() { + return metadata; + } + + public GatewayConfig getGatewayConfig() { + return gatewayConfig; + } + + public LogLevel getLogLevel() { + return logLevel; + } + + public static Builder newBuilder() { + return newBuilder(); + } + + public Builder setId(String id) { + this.id = id; + return this; + } + + public Builder setName(String name) { + this.name = name; + return this; + } + + public Builder setNumId(String numId) { + this.numId = numId; + return this; + } + + public Builder setCredentials(List credentials) { + this.credentials = credentials; + return this; + } + + public Builder setLastErrorStatus(Status lastErrorStatus) { + this.lastErrorStatus = lastErrorStatus; + return this; + } + + public Builder setConfig(DeviceConfig config) { + this.config = config; + return this; + } + + public Builder setLogLevel(LogLevel logLevel) { + this.logLevel = logLevel; + return this; + } + + public Builder setState(DeviceState state) { + this.state = state; + return this; + } + + public Builder setMetadata(Map metadata) { + this.metadata = metadata; + return this; + } + + public Builder setGatewayConfig(GatewayConfig gatewayConfig) { + this.gatewayConfig = gatewayConfig; + return this; + } + + public Builder setBlocked(boolean blocked) { + this.blocked = blocked; + return this; + } + + public Builder setLastHeartbeatTime(String lastHeartbeatTime) { + this.lastHeartbeatTime = lastHeartbeatTime; + return this; + } + + public Builder setLastEventTime(String lastEventTime) { + this.lastEventTime = lastEventTime; + return this; + } + + public Builder setLastStateTime(String lastStateTime) { + this.lastStateTime = lastStateTime; + return this; + } + + public Builder setLastConfigAckTime(String lastConfigAckTime) { + this.lastConfigAckTime = lastConfigAckTime; + return this; + } + + public Builder setLastConfigSendTime(String lastConfigSendTime) { + this.lastConfigSendTime = lastConfigSendTime; + return this; + } + + public Builder setLastErrorTime(String lastErrorTime) { + this.lastErrorTime = lastErrorTime; + return this; + } + + private Builder(Device device) { + this.id = device.id; + this.name = device.name; + this.numId = device.numId; + this.credentials = device.credentials; + this.lastHeartbeatTime = device.lastHeartbeatTime; + this.lastEventTime = device.lastEventTime; + this.lastStateTime = device.lastStateTime; + this.lastConfigAckTime = device.lastConfigAckTime; + this.lastConfigSendTime = device.lastConfigSendTime; + this.blocked = device.blocked; + this.lastErrorTime = device.lastErrorTime; + this.lastErrorStatus = device.lastErrorStatus; + this.config = device.config; + this.state = device.state; + this.logLevel = device.logLevel; + this.metadata = device.metadata; + this.gatewayConfig = device.gatewayConfig; + } + + public Device build() { + return new Device(this); + } + } + + @Override + public String toString() { + String deviceStr = ""; + deviceStr = deviceStr.concat("id=" + this.id + ",name=" + this.name + ",numId=" + this.numId + ",credentials=" + + this.credentials + ",lastHeartbeatTime=" + this.lastHeartbeatTime + ",lastEventTime=" + + this.lastEventTime + ",lastStateTime=" + this.lastStateTime + ",lastConfigAckTime=" + + this.lastConfigAckTime + ",lastConfigSendTime=" + this.lastConfigSendTime + ",blocked=" + this.blocked + + ",lastErrorTime=" + this.lastErrorTime + ",lastErrorStatus=" + this.lastErrorStatus + ",config=" + + this.config + ",state=" + this.state + ",logLevel=" + this.logLevel + ",metadata=" + this.metadata + + ",gatewayConfig=" + this.gatewayConfig); + return deviceStr; + } + + @SuppressWarnings({"unchecked", "rawtypes"}) + public String createDeviceJSONObject() { + String bodyStr = ""; + JSONObject deviceObj = new JSONObject(); + deviceObj.put("id", this.id); + deviceObj.put("name", this.name); + if (this.numId != null) { + deviceObj.put("numId", this.numId); + } + JSONArray jsonArray = new JSONArray(); + if (this.credentials != null && this.credentials.size() > 0) { + for (int i = 0; i < this.credentials.size(); i++) { + if (!this.credentials.get(i).isEmpty()) { + DeviceCredential credentialObj = this.credentials.get(i); + jsonArray.add(credentialObj.toJSONObject()); + } + } + } + deviceObj.put("credentials", jsonArray); + deviceObj.put("gatewayConfig", this.gatewayConfig.toJSONObject()); + deviceObj.put("logLevel", this.logLevel.name()); + + if (this.lastHeartbeatTime != null) { + deviceObj.put("lastHeartbeatTime", this.lastHeartbeatTime); + } + + if (this.lastEventTime != null) { + deviceObj.put("lastEventTime", this.lastEventTime); + } + + if (this.lastStateTime != null) { + deviceObj.put("lastStateTime", this.lastStateTime); + } + + if (this.lastConfigAckTime != null) { + deviceObj.put("lastConfigAckTime", this.lastConfigAckTime); + } + + if (this.lastConfigSendTime != null) { + deviceObj.put("lastConfigSendTime", this.lastConfigSendTime); + } + + deviceObj.put("blocked", this.blocked); + + if (this.lastErrorTime != null) + deviceObj.put("lastErrorTime", this.lastErrorTime); + + if (this.metadata != null && this.metadata.size() > 0) { + Set metaSet = this.metadata.keySet(); + Iterator itr = metaSet.iterator(); + JSONObject jsonObject = new JSONObject(); + while (itr.hasNext()) { + String key = (String) itr.next(); + String value = this.metadata.get(key).toString(); + jsonObject.put(key, value); + } + deviceObj.put("metadata", jsonObject); + } + + if (this.lastErrorStatus != null && this.lastErrorStatus.getCode() != 0) { + deviceObj.put("lastErrorStatus", this.lastErrorStatus.toJSONObject()); + } + + String lastEventTime = ""; + if (this.lastEventTime != null) { + lastEventTime = this.lastEventTime.toString(); + deviceObj.put("lastEventTime", lastEventTime); + } + + if (this.config != null) { + deviceObj.put("config", this.config.toJSONObject()); + } + + if (this.state != null) { + deviceObj.put("state", this.state.toJSONObject()); + } + + bodyStr = deviceObj.toString(); + return bodyStr; + } + + @SuppressWarnings("rawtypes") + public void loadFromString(String inputStr) { + try { + JSONParser parser = new JSONParser(); + JSONObject deviceObj = (JSONObject) parser.parse(inputStr); + + if (deviceObj != null && deviceObj.size() > 0) { + + Set deviceSet = deviceObj.keySet(); + Iterator itr = deviceSet.iterator(); + while (itr.hasNext()) { + String key = (String) itr.next(); + Object value = deviceObj.get(key); + + if (key.equals("id")) { + this.id = value.toString(); + } + if (key.equals("name")) { + this.name = value.toString(); + } + if (key.equals("numId")) { + this.numId = value.toString(); + } + if (key.equals("lastHeartbeatTime")) { + this.lastHeartbeatTime = value.toString(); + } + if (key.equals("lastEventTime")) { + this.lastEventTime = value.toString(); + } + if (key.equals("lastStateTime")) { + this.lastStateTime = value.toString(); + } + if (key.equals("lastConfigAckTime")) { + this.lastConfigAckTime = value.toString(); + } + if (key.equals("lastConfigSendTime")) { + this.lastConfigSendTime = value.toString(); + } + if (key.equals("blocked")) { + this.blocked = Boolean.valueOf(value.toString()); + } + if (key.equals("lastErrorTime")) { + this.lastErrorTime = value.toString(); + } + if (key.equals("lastErrorStatus")) { + JSONObject errorStatus = (JSONObject) value; + Status status = new Status(); + if (errorStatus.containsKey("code")) + status.setCode(errorStatus.get("code")); + if (errorStatus.containsKey("message")) + status.setMessage((String) errorStatus.get("message")); + this.lastErrorStatus = status; + } + + if (key.equals("config")) { + JSONObject configJsonObject = (JSONObject) value; + DeviceConfig deviceCfg = new DeviceConfig(); + if (configJsonObject.containsKey("version")) + deviceCfg.setVersion((String) configJsonObject.get("version")); + if (configJsonObject.containsKey("cloudUpdateTime")) + deviceCfg.setCloudUpdateTime((String) configJsonObject.get("cloudUpdateTime")); + if (configJsonObject.containsKey("deviceAckTime")) + deviceCfg.setDeviceAckTime((String) configJsonObject.get("deviceAckTime")); + if (configJsonObject.containsKey("binaryData")) + deviceCfg.setBinaryData((String) configJsonObject.get("binaryData")); + this.config = deviceCfg; + } + + if (key.equals("state")) { + JSONObject stateJsonObject = (JSONObject) value; + DeviceState deviceState = new DeviceState(); + if (stateJsonObject.containsKey("binaryData")) + deviceState.setBinaryData((String) stateJsonObject.get("binaryData")); + if (stateJsonObject.containsKey("updateTime")) + deviceState.setUpdateTime((String) stateJsonObject.get("updateTime")); + this.state = deviceState; + } + + if (key.equals("logLevel")) { + if (value != null) { + this.logLevel = LogLevel.valueOf(value.toString()); + } + } + + if (key.equals("metadata")) { + JSONObject metadataJsonObject = (JSONObject) value; + if (metadataJsonObject != null) { + Map metadataMap = new HashMap<>(); + Set metadataSet = metadataJsonObject.keySet(); + if (metadataSet.size() > 0) { + Iterator metadIterator = metadataSet.iterator(); + while (metadIterator.hasNext()) { + String metadataKey = (String) metadIterator.next(); + String metatdataValue = (String) metadataJsonObject.get(metadataKey); + metadataMap.put(metadataKey, metatdataValue); + } + } + + this.metadata = metadataMap; + } + } + if (key.equals("gatewayConfig")) { + JSONObject gatewayConfigJsonObject = (JSONObject) value; + if (gatewayConfigJsonObject != null) { + GatewayConfig gatewayConfig = new GatewayConfig(); + if (gatewayConfigJsonObject.containsKey("gatewayType")) + gatewayConfig.setGatewayType( + GatewayType.valueOf((String) gatewayConfigJsonObject.get("gatewayType"))); + if (gatewayConfigJsonObject.containsKey("gatewayAuthMethod")) + gatewayConfig.setGatewayAuthMethod(GatewayAuthMethod + .valueOf((String) gatewayConfigJsonObject.get("gatewayAuthMethod"))); + if (gatewayConfigJsonObject.containsKey("lastAccessedGatewayId")) + gatewayConfig.setLastAccessedGatewayId( + (String) gatewayConfigJsonObject.get("lastAccessedGatewayId")); + if (gatewayConfigJsonObject.containsKey("lastAccessedGatewayTime")) + gatewayConfig.setLastAccessedGatewayTime( + (String) gatewayConfigJsonObject.get("lastAccessedGatewayTime")); + + this.gatewayConfig = gatewayConfig; + } + } + } + } + + } catch (Exception e) { + log.log(Level.SEVERE, e.getMessage()); + } + } } From 341f2d6e8b16843f316f794c1273ddbcfe586c54 Mon Sep 17 00:00:00 2001 From: ronak-ingress Date: Fri, 19 May 2023 01:06:42 +0530 Subject: [PATCH 079/151] - Updated GatewayConfig.java to support builder. Also added condition for expiration time if its empty. --- .../iot/v1/devicetypes/DeviceCredential.java | 150 +++++++------ .../iot/v1/devicetypes/GatewayConfig.java | 211 ++++++++++-------- 2 files changed, 196 insertions(+), 165 deletions(-) diff --git a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/devicetypes/DeviceCredential.java b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/devicetypes/DeviceCredential.java index af58f873..7668ccb2 100644 --- a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/devicetypes/DeviceCredential.java +++ b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/devicetypes/DeviceCredential.java @@ -30,83 +30,87 @@ package com.clearblade.cloud.iot.v1.devicetypes; +import com.clearblade.cloud.iot.v1.utils.Utils; import org.json.simple.JSONObject; import com.clearblade.cloud.iot.v1.registrytypes.PublicKeyCredential; public class DeviceCredential { - private String expirationTime = ""; - private PublicKeyCredential publicKey; - - public DeviceCredential() { - } - - private DeviceCredential(Builder builder) { - expirationTime = builder.expirationTime; - publicKey = builder.publicKey; - } - - public static Builder newBuilder() { - return new Builder(); - } - - public Builder toBuilder() { - return new Builder(this); - } - - public static class Builder { - private String expirationTime; - private PublicKeyCredential publicKey; - - protected Builder() { - - } - - public String getExpirationTime() { - return expirationTime; - } - - public Builder setExpirationTime(String expirationTime) { - this.expirationTime = expirationTime; - return this; - } - - public PublicKeyCredential getPublicKey() { - return publicKey; - } - - public Builder setPublicKey(PublicKeyCredential publicKey) { - this.publicKey = publicKey; - return this; - } - - private Builder(DeviceCredential deviceCredential) { - this.expirationTime = deviceCredential.expirationTime; - this.publicKey = deviceCredential.publicKey; - } - - public DeviceCredential build() { - return new DeviceCredential(this); - } - } - - public void setExpirationTime(String expirationTime) { - this.expirationTime = expirationTime; - } - - public void setPublicKey(PublicKeyCredential publicKey) { - this.publicKey = publicKey; - } - - public boolean isEmpty() { - return publicKey == null; - } - - public JSONObject toJSONObject() { - JSONObject jsonObject = new JSONObject(); - jsonObject.put("expirationTime", this.expirationTime); - jsonObject.put("publicKey", this.publicKey.toJSONObject()); - return jsonObject; - } + private String expirationTime; + ; + private PublicKeyCredential publicKey; + + public DeviceCredential() { + } + + private DeviceCredential(Builder builder) { + expirationTime = builder.expirationTime; + publicKey = builder.publicKey; + } + + public static Builder newBuilder() { + return new Builder(); + } + + public Builder toBuilder() { + return new Builder(this); + } + + public static class Builder { + private String expirationTime; + private PublicKeyCredential publicKey; + + protected Builder() { + + } + + public String getExpirationTime() { + return expirationTime; + } + + public Builder setExpirationTime(String expirationTime) { + this.expirationTime = expirationTime; + return this; + } + + public PublicKeyCredential getPublicKey() { + return publicKey; + } + + public Builder setPublicKey(PublicKeyCredential publicKey) { + this.publicKey = publicKey; + return this; + } + + private Builder(DeviceCredential deviceCredential) { + this.expirationTime = deviceCredential.expirationTime; + this.publicKey = deviceCredential.publicKey; + } + + public DeviceCredential build() { + return new DeviceCredential(this); + } + } + + public void setExpirationTime(String expirationTime) { + this.expirationTime = expirationTime; + } + + public void setPublicKey(PublicKeyCredential publicKey) { + this.publicKey = publicKey; + } + + public boolean isEmpty() { + return publicKey == null; + } + + public JSONObject toJSONObject() { + JSONObject jsonObject = new JSONObject(); + if (!Utils.isEmpty(this.expirationTime)) { + jsonObject.put("expirationTime", this.expirationTime); + } + jsonObject.put("publicKey", this.publicKey.toJSONObject()); + return jsonObject; + } } diff --git a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/devicetypes/GatewayConfig.java b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/devicetypes/GatewayConfig.java index bc1f0cb6..29e27b70 100644 --- a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/devicetypes/GatewayConfig.java +++ b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/devicetypes/GatewayConfig.java @@ -34,97 +34,124 @@ public class GatewayConfig { - private GatewayType gatewayType; - private GatewayAuthMethod gatewayAuthMethod; - private String lastAccessedGatewayId; - private String lastAccessedGatewayTime; - - public GatewayConfig() { - } - - public GatewayType getGatewayType() { - return gatewayType; - } - - public GatewayAuthMethod getGatewayAuthMethod() { - return gatewayAuthMethod; - } - - public String getLastAccessedGatewayId() { - return lastAccessedGatewayId; - } - - public String getLastAccessedGatewayTime() { - return lastAccessedGatewayTime; - } - - public void setGatewayType(GatewayType gatewayType) { - this.gatewayType = gatewayType; - } - - public void setGatewayAuthMethod(GatewayAuthMethod gatewayAuthMethod) { - this.gatewayAuthMethod = gatewayAuthMethod; - } - - public void setLastAccessedGatewayId(String lastAccessedGatewayId) { - this.lastAccessedGatewayId = lastAccessedGatewayId; - } - - public void setLastAccessedGatewayTime(String lastAccessedGatewayTime) { - this.lastAccessedGatewayTime = lastAccessedGatewayTime; - } - - private GatewayConfig(Builder builder) { - gatewayType = builder.gatewayType; - gatewayAuthMethod = builder.gatewayAuthMethod; - lastAccessedGatewayId = builder.lastAccessedGatewayId; - lastAccessedGatewayTime = builder.lastAccessedGatewayTime; - } - - public static Builder newBuilder() { - return new Builder(); - } - - public Builder toBuilder() { - return new Builder(this); - } - - public static class Builder { - private GatewayType gatewayType; - private GatewayAuthMethod gatewayAuthMethod; - private String lastAccessedGatewayId; - private String lastAccessedGatewayTime; - - protected Builder() { - } - - private Builder(GatewayConfig gatewayConfig) { - this.gatewayType = gatewayConfig.gatewayType; - this.gatewayAuthMethod = gatewayConfig.gatewayAuthMethod; - this.lastAccessedGatewayId = gatewayConfig.lastAccessedGatewayId; - this.lastAccessedGatewayTime = gatewayConfig.lastAccessedGatewayTime; - } - - public GatewayConfig build() { - return new GatewayConfig(this); - } - } - - public JSONObject toJSONObject() { - final JSONObject jsonObject = new JSONObject(); - if (this.getGatewayAuthMethod() != null) { - jsonObject.put("gatewayAuthMethod", this.getGatewayAuthMethod().name()); - } - if (this.getGatewayType() != null) { - jsonObject.put("gatewayType", this.getGatewayType().name()); - } - if (this.getLastAccessedGatewayId() != null) { - jsonObject.put("gatewayAuthMethod", this.getLastAccessedGatewayId()); - } - if (this.getLastAccessedGatewayTime() != null) { - jsonObject.put("lastAccessedGatewayTime", this.getLastAccessedGatewayTime()); - } - return jsonObject; - } + private GatewayType gatewayType; + private GatewayAuthMethod gatewayAuthMethod; + private String lastAccessedGatewayId; + private String lastAccessedGatewayTime; + + private static final GatewayConfig DEFAULT_INSTANCE = new GatewayConfig(); + + public GatewayConfig() { + } + + public GatewayType getGatewayType() { + return gatewayType; + } + + public GatewayAuthMethod getGatewayAuthMethod() { + return gatewayAuthMethod; + } + + public String getLastAccessedGatewayId() { + return lastAccessedGatewayId; + } + + public String getLastAccessedGatewayTime() { + return lastAccessedGatewayTime; + } + + public void setGatewayType(GatewayType gatewayType) { + this.gatewayType = gatewayType; + } + + public void setGatewayAuthMethod(GatewayAuthMethod gatewayAuthMethod) { + this.gatewayAuthMethod = gatewayAuthMethod; + } + + public void setLastAccessedGatewayId(String lastAccessedGatewayId) { + this.lastAccessedGatewayId = lastAccessedGatewayId; + } + + public void setLastAccessedGatewayTime(String lastAccessedGatewayTime) { + this.lastAccessedGatewayTime = lastAccessedGatewayTime; + } + + private GatewayConfig(Builder builder) { + gatewayType = builder.gatewayType; + gatewayAuthMethod = builder.gatewayAuthMethod; + lastAccessedGatewayId = builder.lastAccessedGatewayId; + lastAccessedGatewayTime = builder.lastAccessedGatewayTime; + } + + public static Builder newBuilder() { + return new GatewayConfig.Builder(); + } + + public Builder toBuilder() { + return new GatewayConfig.Builder(); + } + + public static GatewayConfig getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + public static class Builder { + private GatewayType gatewayType; + private GatewayAuthMethod gatewayAuthMethod; + private String lastAccessedGatewayId; + private String lastAccessedGatewayTime; + + protected Builder() { + } + + private Builder(GatewayConfig gatewayConfig) { + this.gatewayType = gatewayConfig.gatewayType; + this.gatewayAuthMethod = gatewayConfig.gatewayAuthMethod; + this.lastAccessedGatewayId = gatewayConfig.lastAccessedGatewayId; + this.lastAccessedGatewayTime = gatewayConfig.lastAccessedGatewayTime; + } + + public Builder setGatewayType(GatewayType gatewayType) { + this.gatewayType = gatewayType; + return this; + } + + public Builder setGatewayAuthMethod(GatewayAuthMethod gatewayAuthMethod) { + this.gatewayAuthMethod = gatewayAuthMethod; + return this; + } + + public Builder setLastAccessedGatewayId(String lastAccessedGatewayId) { + this.lastAccessedGatewayId = lastAccessedGatewayId; + return this; + } + + + public Builder setLastAccessedGatewayTime(String lastAccessedGatewayTime) { + this.lastAccessedGatewayTime = lastAccessedGatewayTime; + return this; + } + + public GatewayConfig build() { + return new GatewayConfig(this); + } + } + + public JSONObject toJSONObject() { + final JSONObject jsonObject = new JSONObject(); + if (this.getGatewayAuthMethod() != null) { + jsonObject.put("gatewayAuthMethod", this.getGatewayAuthMethod().name()); + } + if (this.getGatewayType() != null) { + jsonObject.put("gatewayType", this.getGatewayType().name()); + } + if (this.getLastAccessedGatewayId() != null) { + jsonObject.put("gatewayAuthMethod", this.getLastAccessedGatewayId()); + } + if (this.getLastAccessedGatewayTime() != null) { + jsonObject.put("lastAccessedGatewayTime", this.getLastAccessedGatewayTime()); + } + return jsonObject; + } } From c6908b8993b83b1817e33124565cedb3bfa3f4b7 Mon Sep 17 00:00:00 2001 From: mikoaro Date: Thu, 18 May 2023 15:27:57 -0500 Subject: [PATCH 080/151] Set version to 1.0.0-rc.2 --- clearblade-cloud-iot/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/clearblade-cloud-iot/pom.xml b/clearblade-cloud-iot/pom.xml index 71b13c0b..34695252 100644 --- a/clearblade-cloud-iot/pom.xml +++ b/clearblade-cloud-iot/pom.xml @@ -3,7 +3,7 @@ io.github.clearblade clearblade-cloud-iot - 1.0.0-rc.1 + 1.0.0-rc.2 jar Java Client Library for ClearBlade IoT Core From 7487ebeaf48f94e2f2b40dcb14e8e737e76acb60 Mon Sep 17 00:00:00 2001 From: ronak-ingress Date: Wed, 24 May 2023 00:01:58 +0530 Subject: [PATCH 081/151] - Updated logic in DevicesListRequest.java to get parent list. - Minor fixes in Sync and Async client. --- .../src/com/clearblade/cloud/iot/v1/AsyncClient.java | 12 ------------ .../src/com/clearblade/cloud/iot/v1/SyncClient.java | 2 +- .../cloud/iot/v1/deviceslist/DevicesListRequest.java | 8 ++++---- 3 files changed, 5 insertions(+), 17 deletions(-) diff --git a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/AsyncClient.java b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/AsyncClient.java index 85bd3b0d..1decbf56 100644 --- a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/AsyncClient.java +++ b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/AsyncClient.java @@ -166,9 +166,6 @@ public String[] get(String finalURL, String token) { responseArray[1] = ""; responseArray[2] = httpResponse.body(); - } catch (ApplicationException e) { - log.log(Level.SEVERE, e.getMessage()); - throw new ApplicationException(e); } catch (InterruptedException ex) { log.log(Level.SEVERE, ex.getMessage()); Thread.currentThread().interrupt(); @@ -255,9 +252,6 @@ public String[] post(String finalURL, String body, String token) { responseArray[1] = ""; responseArray[2] = httpResponse.body(); - } catch (ApplicationException e) { - log.log(Level.SEVERE, e.getMessage()); - throw new ApplicationException(e); } catch (InterruptedException ex) { log.log(Level.SEVERE, ex.getMessage()); Thread.currentThread().interrupt(); @@ -311,9 +305,6 @@ public String[] delete(String finalURL, String token) { responseArray[1] = ""; responseArray[2] = httpResponse.body(); - } catch (ApplicationException e) { - log.log(Level.SEVERE, e.getMessage()); - throw new ApplicationException(e); } catch (InterruptedException ex) { log.log(Level.SEVERE, ex.getMessage()); Thread.currentThread().interrupt(); @@ -367,9 +358,6 @@ public String[] update(String finalURL, String body, String token) { responseArray[1] = ""; responseArray[2] = httpResponse.body(); - } catch (ApplicationException e) { - log.log(Level.SEVERE, e.getMessage()); - throw new ApplicationException(e); } catch (InterruptedException ex) { log.log(Level.SEVERE, ex.getMessage()); Thread.currentThread().interrupt(); diff --git a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/SyncClient.java b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/SyncClient.java index 4e5d8a8d..3c8e4f1c 100644 --- a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/SyncClient.java +++ b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/SyncClient.java @@ -279,7 +279,7 @@ public String[] post(String finalURL, String body, String token) { responseArray[0] = String.valueOf(response.statusCode()); responseArray[1] = ""; responseArray[2] = response.body(); - } catch (ApplicationException e) { + } catch (InterruptedException e) { log.log(Level.SEVERE, e.getMessage()); Thread.currentThread().interrupt(); throw new ApplicationException(e); diff --git a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/deviceslist/DevicesListRequest.java b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/deviceslist/DevicesListRequest.java index aeac253b..f0f48b8f 100644 --- a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/deviceslist/DevicesListRequest.java +++ b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/deviceslist/DevicesListRequest.java @@ -141,16 +141,16 @@ public String getParamsForList() { if (this.gatewayListOptions != null) { if (this.gatewayListOptions.getGatewayType() != null) { params += "&gatewayListOptions.gatewayType=" + this.gatewayListOptions.getGatewayType().name(); - } else if (this.gatewayListOptions.getAssociationsDeviceId() != null) { + } + if (this.gatewayListOptions.getAssociationsDeviceId() != null) { params += "&gatewayListOptions.associationsDeviceId=" + this.gatewayListOptions.getAssociationsDeviceId(); - } else if (this.gatewayListOptions.getAssociationsGatewayId() != null) { + } + if (this.gatewayListOptions.getAssociationsGatewayId() != null) { params += "&gatewayListOptions.associationsGatewayId=" + this.gatewayListOptions.getAssociationsGatewayId(); } - } - return params; } From 8927598a33143f373080c871936ed5c2b32c61f7 Mon Sep 17 00:00:00 2001 From: ronak-ingress Date: Wed, 24 May 2023 00:23:08 +0530 Subject: [PATCH 082/151] Added change log --- clearblade-cloud-iot/CHANGELOG.md | 46 +++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 clearblade-cloud-iot/CHANGELOG.md diff --git a/clearblade-cloud-iot/CHANGELOG.md b/clearblade-cloud-iot/CHANGELOG.md new file mode 100644 index 00000000..df747c8c --- /dev/null +++ b/clearblade-cloud-iot/CHANGELOG.md @@ -0,0 +1,46 @@ +# Changelog + +## [1.1.1](https://github.com/clearblade/nodejs-iot/compare/v1.1.0..v1.1.1) (2023-05-16) + +- Add error handling to internal method + +## [1.1.0](https://github.com/clearblade/nodejs-iot/compare/v1.0.9..v1.1.0) (2023-04-10) + +- Add support for retrying requests on error + +## [1.0.9](https://github.com/clearblade/nodejs-iot/compare/v1.0.8..v1.0.9) (2023-04-06) + +- Fix incorrect decoding of state binaryData when using `BINARYDATA_AND_TIME_GOOGLE_FORMAT` flag + +## [1.0.8](https://github.com/clearblade/nodejs-iot/compare/v1.0.7..v1.0.8) (2023-04-04) + +- Fix incorrect timestamp format when using `BINARYDATA_AND_TIME_GOOGLE_FORMAT` flag +- Fix issue with binaryData when using `BINARYDATA_AND_TIME_GOOGLE_FORMAT` flag + +## [1.0.7](https://github.com/clearblade/nodejs-iot/compare/v1.0.4..v1.0.7) (2023-03-13) + +- Add support for `BINARYDATA_AND_TIME_GOOGLE_FORMAT` flag + +## [1.0.4](https://github.com/clearblade/nodejs-iot/compare/v1.0.3..v1.0.4) (2022-11-10) + +- fix binaryData Buffer not encoded for sendCommandToDevice and modifyCloudToDeviceConfig +- add error handling for HTTP requests +- fix fieldMasks not encoded for multiple methods +- Miscellaneous bug fixes + +## [1.0.3](https://github.com/clearblade/nodejs-iot/compare/v1.0.2..v1.0.3) (2022-11-04) + +- Bug fix for regional URLs + +## [1.0.2](https://github.com/clearblade/nodejs-iot/compare/v1.0.1..v1.0.2) (2022-11-04) + +- Bug fix for unbindDeviceFromGateway +- non-200 status code handling for `sendCommandToDevice` and modify `modifyCloudToDeviceConfig` + +## 1.0.1 + +- Minor fixes + +## 1.0.0 + +- Initial release of @clearblade/iot From 1d11c6001c68130b46562db255b1f15454bcf15d Mon Sep 17 00:00:00 2001 From: ronak-ingress <114172748+ronak-ingress@users.noreply.github.com> Date: Wed, 24 May 2023 00:24:19 +0530 Subject: [PATCH 083/151] Update CHANGELOG.md --- clearblade-cloud-iot/CHANGELOG.md | 45 ++++++++++++------------------- 1 file changed, 17 insertions(+), 28 deletions(-) diff --git a/clearblade-cloud-iot/CHANGELOG.md b/clearblade-cloud-iot/CHANGELOG.md index df747c8c..a78b8b2d 100644 --- a/clearblade-cloud-iot/CHANGELOG.md +++ b/clearblade-cloud-iot/CHANGELOG.md @@ -1,46 +1,35 @@ # Changelog -## [1.1.1](https://github.com/clearblade/nodejs-iot/compare/v1.1.0..v1.1.1) (2023-05-16) - -- Add error handling to internal method - -## [1.1.0](https://github.com/clearblade/nodejs-iot/compare/v1.0.9..v1.1.0) (2023-04-10) - -- Add support for retrying requests on error - -## [1.0.9](https://github.com/clearblade/nodejs-iot/compare/v1.0.8..v1.0.9) (2023-04-06) +## 1.0.0 -- Fix incorrect decoding of state binaryData when using `BINARYDATA_AND_TIME_GOOGLE_FORMAT` flag +- Updated UpdateDeviceRequest, to set name as DeviceName instead of only device_id. See below example, + UpdateDeviceRequest.Builder.newBuilder().setName(**DeviceName.of(PROJECT,LOCATION,REGISTRY,DEVICE).toString()**).setDevice(device.build()) +- Removed static variables from ConfigParameters and it's dependency. -## [1.0.8](https://github.com/clearblade/nodejs-iot/compare/v1.0.7..v1.0.8) (2023-04-04) +## 0.1.5 -- Fix incorrect timestamp format when using `BINARYDATA_AND_TIME_GOOGLE_FORMAT` flag -- Fix issue with binaryData when using `BINARYDATA_AND_TIME_GOOGLE_FORMAT` flag +- Minor fixes -## [1.0.7](https://github.com/clearblade/nodejs-iot/compare/v1.0.4..v1.0.7) (2023-03-13) +## 0.1.4 -- Add support for `BINARYDATA_AND_TIME_GOOGLE_FORMAT` flag +- Minor fixes -## [1.0.4](https://github.com/clearblade/nodejs-iot/compare/v1.0.3..v1.0.4) (2022-11-10) +## 0.1.3 -- fix binaryData Buffer not encoded for sendCommandToDevice and modifyCloudToDeviceConfig -- add error handling for HTTP requests -- fix fieldMasks not encoded for multiple methods -- Miscellaneous bug fixes +- Minor fixes -## [1.0.3](https://github.com/clearblade/nodejs-iot/compare/v1.0.2..v1.0.3) (2022-11-04) +## 0.1.2 -- Bug fix for regional URLs +- Minor fixes -## [1.0.2](https://github.com/clearblade/nodejs-iot/compare/v1.0.1..v1.0.2) (2022-11-04) +## 0.1.1 -- Bug fix for unbindDeviceFromGateway -- non-200 status code handling for `sendCommandToDevice` and modify `modifyCloudToDeviceConfig` +- Minor fixes -## 1.0.1 +## 0.1.0 - Minor fixes -## 1.0.0 +## 0.0.1 -- Initial release of @clearblade/iot +- Initial release of clearblade-cloud-iot From 857fb2de0e5a593d9ffecad4b19ec14cbf35a2f0 Mon Sep 17 00:00:00 2001 From: ronak-ingress Date: Wed, 24 May 2023 00:33:05 +0530 Subject: [PATCH 084/151] - Updated CreateDeviceRequest.java to support parent as String instead of RegistryName - Updated test cases accordingly. - Updated Timestamp.java to support builder pattern. --- .../v1/createdevice/CreateDeviceRequest.java | 10 ++-- .../cloud/iot/v1/utils/Timestamp.java | 55 +++++++++++++++++++ .../iot/v1/test/DeviceManagerClientTest.java | 10 ++-- 3 files changed, 64 insertions(+), 11 deletions(-) diff --git a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/createdevice/CreateDeviceRequest.java b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/createdevice/CreateDeviceRequest.java index 130d8827..18021626 100644 --- a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/createdevice/CreateDeviceRequest.java +++ b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/createdevice/CreateDeviceRequest.java @@ -34,7 +34,7 @@ import com.clearblade.cloud.iot.v1.registrytypes.RegistryName; public class CreateDeviceRequest { - private final RegistryName parent; + private final String parent; private final Device device; private CreateDeviceRequest(Builder builder) { @@ -46,7 +46,7 @@ private CreateDeviceRequest(Builder builder) { public static class Builder { /// instance fields - private RegistryName parent; + private String parent; private Device device; public static Builder newBuilder() { @@ -57,7 +57,7 @@ private Builder() { } // Setter methods - public Builder setParent(RegistryName parent) { + public Builder setParent(String parent) { this.parent = parent; return this; } @@ -75,12 +75,12 @@ public CreateDeviceRequest build() { } public RegistryName getParent() { - return parent; + return RegistryName.parse(this.parent); } public String[] getParams() { String[] params = new String[2]; - params[0] = "parent=" + this.parent.getRegistryFullName(); + params[0] = "parent=" + getParent().getRegistryFullName(); params[1] = this.device.createDeviceJSONObject(); return params; } diff --git a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/utils/Timestamp.java b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/utils/Timestamp.java index 7e0dccd7..49f22157 100644 --- a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/utils/Timestamp.java +++ b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/utils/Timestamp.java @@ -1,5 +1,11 @@ package com.clearblade.cloud.iot.v1.utils; +import com.clearblade.cloud.iot.v1.devicetypes.GatewayAuthMethod; +import com.clearblade.cloud.iot.v1.devicetypes.GatewayConfig; +import com.clearblade.cloud.iot.v1.devicetypes.GatewayType; + +import java.sql.Time; + public class Timestamp implements TimestampOrBuilder { public static final int SECONDS_FIELD_NUMBER = 1; @@ -21,6 +27,55 @@ public Timestamp(long seconds, int nanos) { this.memoizedIsInitialized = -1; } + public Timestamp(Builder builder) { + this.seconds_ = builder.seconds_; + this.nanos_ = builder.nanos_; + this.memoizedIsInitialized = builder.memoizedIsInitialized; + } + + public static Builder newBuilder() { + return new Timestamp.Builder(); + } + + public Builder toBuilder() { + return new Timestamp.Builder(); + } + + + public static class Builder { + private long seconds_; + private int nanos_; + private byte memoizedIsInitialized; + + protected Builder() { + } + + private Builder(Timestamp timestamp) { + this.seconds_ = timestamp.seconds_; + this.nanos_ = timestamp.nanos_; + this.memoizedIsInitialized = timestamp.memoizedIsInitialized; + } + + public Builder setSeconds(long seconds_) { + this.seconds_ = seconds_; + return this; + } + + public Builder setNanos(int nanos_) { + this.nanos_ = nanos_; + return this; + } + + public Builder setMemoizedIsInitialized(byte memoizedIsInitialized) { + this.memoizedIsInitialized = memoizedIsInitialized; + return this; + } + + public Timestamp build() { + return new Timestamp(this); + } + } + public long getSeconds() { return this.seconds_; } diff --git a/clearblade-cloud-iot/src/test/com/clearblade/cloud/iot/v1/test/DeviceManagerClientTest.java b/clearblade-cloud-iot/src/test/com/clearblade/cloud/iot/v1/test/DeviceManagerClientTest.java index 715a73f3..7e8bd01a 100644 --- a/clearblade-cloud-iot/src/test/com/clearblade/cloud/iot/v1/test/DeviceManagerClientTest.java +++ b/clearblade-cloud-iot/src/test/com/clearblade/cloud/iot/v1/test/DeviceManagerClientTest.java @@ -150,8 +150,7 @@ public void testUpdateDeviceRegistrySuccess() { public void testCreateDeviceSuccess() { RegistryName parent = RegistryName.of(project, location, registryId); Device expectedResponse = testResponse.getResponseTest7(deviceId, numDeviceId); - GatewayConfig gatewayCfg = new GatewayConfig(); - gatewayCfg.setGatewayType(GatewayType.NON_GATEWAY); + GatewayConfig gatewayCfg = GatewayConfig.newBuilder().setGatewayType(GatewayType.NON_GATEWAY).build(); Device device = Device.newBuilder() .setId(deviceId) .setName(deviceId) @@ -164,7 +163,7 @@ public void testCreateDeviceSuccess() { .setConfig(new DeviceConfig()) .setMetadata(new HashMap<>()) .build(); - CreateDeviceRequest request = CreateDeviceRequest.Builder.newBuilder().setParent(parent).setDevice(device) + CreateDeviceRequest request = CreateDeviceRequest.Builder.newBuilder().setParent(parent.toString()).setDevice(device) .build(); Device actualResponse = client.createDevice(request); testResponse.assertEqual(expectedResponse, actualResponse); @@ -176,8 +175,7 @@ public void testCreateDeviceSuccess() { public void testCreateDeviceAsAGatewaySuccess() { RegistryName parent = RegistryName.of(project, location, registryId); Device expectedResponse = testResponse.getResponseTest8(gatewayId, numGatewayId); - GatewayConfig gatewayCfg = new GatewayConfig(); - gatewayCfg.setGatewayType(GatewayType.GATEWAY); + GatewayConfig gatewayCfg = GatewayConfig.newBuilder().setGatewayType(GatewayType.GATEWAY).build(); Device device = Device.newBuilder() .setId(gatewayId) .setName(gatewayId) @@ -190,7 +188,7 @@ public void testCreateDeviceAsAGatewaySuccess() { .setConfig(new DeviceConfig()) .setMetadata(new HashMap<>()) .build(); - CreateDeviceRequest request = CreateDeviceRequest.Builder.newBuilder().setParent(parent).setDevice(device) + CreateDeviceRequest request = CreateDeviceRequest.Builder.newBuilder().setParent(parent.toString()).setDevice(device) .build(); Device actualResponse = client.createDevice(request); testResponse.assertEqual(expectedResponse, actualResponse); From 209b4f4add78a0079214ee915ee0b624bca94c4e Mon Sep 17 00:00:00 2001 From: ronak-ingress <114172748+ronak-ingress@users.noreply.github.com> Date: Wed, 24 May 2023 00:39:36 +0530 Subject: [PATCH 085/151] Update CHANGELOG.md --- clearblade-cloud-iot/CHANGELOG.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/clearblade-cloud-iot/CHANGELOG.md b/clearblade-cloud-iot/CHANGELOG.md index a78b8b2d..0b4f3d52 100644 --- a/clearblade-cloud-iot/CHANGELOG.md +++ b/clearblade-cloud-iot/CHANGELOG.md @@ -5,6 +5,9 @@ - Updated UpdateDeviceRequest, to set name as DeviceName instead of only device_id. See below example, UpdateDeviceRequest.Builder.newBuilder().setName(**DeviceName.of(PROJECT,LOCATION,REGISTRY,DEVICE).toString()**).setDevice(device.build()) - Removed static variables from ConfigParameters and it's dependency. +- Updated CreateDeviceRequest.java to support parent as String instead of RegistryName. See below example, + +CreateDeviceRequest.Builder.newBuilder()**.setParent(RegistryName.of(PROJECT, LOCATION, REGISTRY).toString())**.setDevice(device).build(); ## 0.1.5 From d5175d1be09d7172ca2037c75dd7e49442d89345 Mon Sep 17 00:00:00 2001 From: mikoaro Date: Tue, 23 May 2023 14:20:21 -0500 Subject: [PATCH 086/151] Set version to 1.0.0-rc.3 --- clearblade-cloud-iot/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/clearblade-cloud-iot/pom.xml b/clearblade-cloud-iot/pom.xml index 34695252..02a96d53 100644 --- a/clearblade-cloud-iot/pom.xml +++ b/clearblade-cloud-iot/pom.xml @@ -3,7 +3,7 @@ io.github.clearblade clearblade-cloud-iot - 1.0.0-rc.2 + 1.0.0-rc.3 jar Java Client Library for ClearBlade IoT Core From 10643d5442848c9846f054983dbd3dcc09e04069 Mon Sep 17 00:00:00 2001 From: ronak-ingress Date: Wed, 24 May 2023 11:07:22 +0530 Subject: [PATCH 087/151] - Updated sample code. --- .../iot/v1/samples/createdevice/AsyncCreateDevice.java | 2 +- .../iot/v1/samples/createdevice/SyncCreateDevice.java | 2 +- .../iot/v1/samples/updatedevice/AsyncUpdateDevice.java | 5 ++++- .../iot/v1/samples/updatedevice/SyncUpdateDevice.java | 8 +++++--- 4 files changed, 11 insertions(+), 6 deletions(-) diff --git a/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/createdevice/AsyncCreateDevice.java b/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/createdevice/AsyncCreateDevice.java index 3f14f855..07619383 100644 --- a/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/createdevice/AsyncCreateDevice.java +++ b/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/createdevice/AsyncCreateDevice.java @@ -112,7 +112,7 @@ public static void asyncCreateDevice() { .setLogLevel(LogLevel.ERROR).setCredentials(List.of(devCredential)).setConfig(deviceConfig) .setMetadata(metadata).build(); - CreateDeviceRequest request = CreateDeviceRequest.Builder.newBuilder().setParent(parent).setDevice(device) + CreateDeviceRequest request = CreateDeviceRequest.Builder.newBuilder().setParent(parent.toString()).setDevice(device) .build(); Device response = null; try { diff --git a/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/createdevice/SyncCreateDevice.java b/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/createdevice/SyncCreateDevice.java index 36a5123a..00469f33 100644 --- a/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/createdevice/SyncCreateDevice.java +++ b/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/createdevice/SyncCreateDevice.java @@ -84,7 +84,7 @@ public static void syncCreateDevice() { .setConfig(new DeviceConfig()) .setMetadata(new HashMap<>()) .build(); - CreateDeviceRequest request = CreateDeviceRequest.Builder.newBuilder().setParent(parent).setDevice(device) + CreateDeviceRequest request = CreateDeviceRequest.Builder.newBuilder().setParent(parent.toString()).setDevice(device) .build(); Device response = deviceManagerClient.createDevice(request); if(response != null) { diff --git a/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/updatedevice/AsyncUpdateDevice.java b/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/updatedevice/AsyncUpdateDevice.java index fbc5d904..c5b1ec02 100644 --- a/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/updatedevice/AsyncUpdateDevice.java +++ b/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/updatedevice/AsyncUpdateDevice.java @@ -38,6 +38,7 @@ import com.clearblade.cloud.iot.v1.DeviceManagerAsyncClient; import com.clearblade.cloud.iot.v1.devicetypes.Device; import com.clearblade.cloud.iot.v1.devicetypes.Device.Builder; +import com.clearblade.cloud.iot.v1.devicetypes.DeviceName; import com.clearblade.cloud.iot.v1.exception.ApplicationException; import com.clearblade.cloud.iot.v1.devicetypes.DeviceCredential; import com.clearblade.cloud.iot.v1.registrytypes.PublicKeyCredential; @@ -47,6 +48,7 @@ import com.clearblade.cloud.iot.v1.utils.LogLevel; public class AsyncUpdateDevice { + public static String PROJECT = ""; public static String LOCATION = ""; public static String REGISTRY = ""; public static String DEVICE = ""; @@ -58,6 +60,7 @@ public class AsyncUpdateDevice { static ConfigParameters configParameters = ConfigParameters.getInstance(); public static void main(String[] args) { + PROJECT = System.getProperty("projectName"); LOCATION = System.getProperty("location"); REGISTRY = System.getProperty("registryName"); DEVICE = System.getProperty("deviceName"); @@ -104,7 +107,7 @@ public static void asyncUpdateDevice() { listCredentials.add(credential); device.setCredentials(listCredentials); } - UpdateDeviceRequest request = UpdateDeviceRequest.Builder.newBuilder().setName(DEVICE).setDevice(device.build()) + UpdateDeviceRequest request = UpdateDeviceRequest.Builder.newBuilder().setName(DeviceName.of(PROJECT,LOCATION,REGISTRY,DEVICE).toString()).setDevice(device.build()) .setUpdateMask(UPDATEMASK).build(); Device response = null; try { diff --git a/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/updatedevice/SyncUpdateDevice.java b/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/updatedevice/SyncUpdateDevice.java index 128be72a..5f58c4ec 100644 --- a/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/updatedevice/SyncUpdateDevice.java +++ b/clearblade-cloud-iot/samples/com/clearblade/cloud/iot/v1/samples/updatedevice/SyncUpdateDevice.java @@ -38,6 +38,7 @@ import com.clearblade.cloud.iot.v1.DeviceManagerClient; import com.clearblade.cloud.iot.v1.devicetypes.Device; import com.clearblade.cloud.iot.v1.devicetypes.DeviceCredential; +import com.clearblade.cloud.iot.v1.devicetypes.DeviceName; import com.clearblade.cloud.iot.v1.registrytypes.PublicKeyCredential; import com.clearblade.cloud.iot.v1.registrytypes.PublicKeyFormat; import com.clearblade.cloud.iot.v1.updatedevice.UpdateDeviceRequest; @@ -45,7 +46,7 @@ import com.clearblade.cloud.iot.v1.utils.LogLevel; public class SyncUpdateDevice { - + public static String PROJECT = ""; public static String LOCATION = ""; public static String REGISTRY = ""; public static String DEVICE = ""; @@ -56,7 +57,8 @@ public class SyncUpdateDevice { public static String KEYVAL = ""; static ConfigParameters configParameters = ConfigParameters.getInstance(); - public static void main(String[] args) { + public static void main(String[] args) { + PROJECT = System.getProperty("projectName"); LOCATION = System.getProperty("location"); REGISTRY = System.getProperty("registryName"); DEVICE = System.getProperty("deviceName"); @@ -106,7 +108,7 @@ public static void syncUpdateDevice() { device.toBuilder().setCredentials(listCredentials); } - UpdateDeviceRequest request = UpdateDeviceRequest.Builder.newBuilder().setName(DEVICE).setDevice(device) + UpdateDeviceRequest request = UpdateDeviceRequest.Builder.newBuilder().setName(DeviceName.of(PROJECT,LOCATION,REGISTRY,DEVICE).toString()).setDevice(device) .setUpdateMask(UPDATEMASK).build(); Device response = deviceManagerClient.updateDevice(request); if(response != null) { From 4bc854ecec0287db1871850a2abb200bfb72caee Mon Sep 17 00:00:00 2001 From: mikoaro Date: Thu, 1 Jun 2023 14:29:51 -0500 Subject: [PATCH 088/151] Set version to 1.0.0 --- README.md | 2 +- clearblade-cloud-iot/pom.xml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index bf063124..93a4fbe6 100644 --- a/README.md +++ b/README.md @@ -21,7 +21,7 @@ If you are using Maven artifact, simply add the following dependency to your pom io.github.clearblade clearblade-cloud-iot - 0.1.5 + 1.0.0 ``` diff --git a/clearblade-cloud-iot/pom.xml b/clearblade-cloud-iot/pom.xml index 02a96d53..7b6ff89f 100644 --- a/clearblade-cloud-iot/pom.xml +++ b/clearblade-cloud-iot/pom.xml @@ -3,7 +3,7 @@ io.github.clearblade clearblade-cloud-iot - 1.0.0-rc.3 + 1.0.0 jar Java Client Library for ClearBlade IoT Core From 451a9353b26355eb22f2278a874525670cb89a5a Mon Sep 17 00:00:00 2001 From: mikoaro Date: Fri, 2 Jun 2023 08:31:01 -0500 Subject: [PATCH 089/151] Update README with java quickstart --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index 93a4fbe6..0d32e9ec 100644 --- a/README.md +++ b/README.md @@ -4,6 +4,7 @@ Java library and samples for [ClearBlade Internet of Things (IoT) Core][product- - [Product Documentation][product-docs] - [Client Library Documentation][javasdk] +- [Quickstart for Java][quickstart] ## Supported Java Versions @@ -151,3 +152,4 @@ Run device example: [product-docs]: https://clearblade.atlassian.net/wiki/spaces/IC/overview [javasdk]: https://clearblade.atlassian.net/wiki/spaces/IC/pages/2231173185/Java +[quickstart]: https://clearblade.atlassian.net/wiki/spaces/IC/pages/2352611329/Java+SDK+quick+start From 23ebe8a265e08146c5dd0388014258162a4599d2 Mon Sep 17 00:00:00 2001 From: jslavin-clearblade <116581763+jslavin-clearblade@users.noreply.github.com> Date: Wed, 14 Jun 2023 16:24:47 -0400 Subject: [PATCH 090/151] Update README.md I improved the readability and grammar of the documentation. Please merge if there are no semantic changes. --- README.md | 50 +++++++++++++++++++++----------------------------- 1 file changed, 21 insertions(+), 29 deletions(-) diff --git a/README.md b/README.md index 0d32e9ec..9075f190 100644 --- a/README.md +++ b/README.md @@ -1,22 +1,22 @@ -# ClearBlade Internet of Things (IoT) Core Client for Java +# ClearBlade IoT Core Java Client -Java library and samples for [ClearBlade Internet of Things (IoT) Core][product-docs]. +Java library and samples for [ClearBlade IoT Core][product-docs]. - [Product Documentation][product-docs] - [Client Library Documentation][javasdk] - [Quickstart for Java][quickstart] -## Supported Java Versions +## Supported Java versions Java 11 or above is required for using this client. Java 17 is the best choice for new development. # Usage -You can either use the Maven artifact or do a local installation and setup of Maven. +You can use the Maven artifact or do a Maven local installation and setup. ## Maven artifact -If you are using Maven artifact, simply add the following dependency to your pom.xml file in a newly created/generated Maven App: +If you are using the Maven artifact, add the following dependency to your pom.xml file in a newly created/generated Maven app: ```xml @@ -26,23 +26,20 @@ If you are using Maven artifact, simply add the following dependency to your pom ``` -## Local Installation and setup +## Local installation and setup -For local installation of Maven: +For Maven local installation: -In the [clearblade-cloud-iot](./clearblade-cloud-iot) folder, run the following command to install the libraries and build the sample with -Maven: +In the [clearblade-cloud-iot](./clearblade-cloud-iot) folder, run the following command to install the libraries and build the Maven sample: mvn clean install ## Quickstart 1. From the [ClearBlade Migration from Google IoT Core section](https://clearblade.atlassian.net/wiki/spaces/IC/pages/2202664969/Migration+from+Google+IoT+Core) - migrate your existing Google IoT Core registries and/or devices into ClearBlade IoT Core or using the - ClearBlade IoT Core Console, [create a device registry and devices](https://clearblade.atlassian.net/wiki/spaces/IC/pages/2202206388/Creating+registries+and+devices). + migrate your existing Google IoT Core registries and devices into ClearBlade IoT Core or use the ClearBlade IoT Core Console, [create a device registry and devices](https://clearblade.atlassian.net/wiki/spaces/IC/pages/2202206388/Creating+registries+and+devices). -2. [Add service accounts to a project](https://clearblade.atlassian.net/wiki/spaces/IC/pages/2240675843/Add+service+accounts+to+a+project) and download the json file with your service - account’s credentials. +2. [Add service accounts to a project](https://clearblade.atlassian.net/wiki/spaces/IC/pages/2240675843/Add+service+accounts+to+a+project) and download the JSON file with your service account’s credentials. 3. Use the following to set your environment variables keys in your terminal or IDE environment configurations: @@ -55,25 +52,20 @@ Maven: ``` export CLEARBLADE_REGISTRY=[your-registry] export CLEARBLADE_REGION=[your-region] - export BINARYDATA_AND_TIME_GOOGLE_FORMAT=true + export BINARYDATA_AND_TIME_GOOGLE_FORMAT=true ``` 4. Use the HTTP or MQTT samples in the [samples](./clearblade-cloud-iot/samples) folder. -## ClearBlade IoT Core Samples Java +## ClearBlade IoT Core Java samples -The sample apps demonstrates registry and device creation for ClearBlade IoT Core. The [samples](./clearblade-cloud-iot/samples) folder contains all the Java samples that demonstrate an overview of the ClearBlade IoT Core platform. +The sample apps demonstrate registry and device creation for ClearBlade IoT Core. The [samples](./clearblade-cloud-iot/samples) folder contains all the Java samples demonstrating an overview of the ClearBlade IoT Core Platform. -Note that before you can run the sample, you must configure your development environment -and terminal as described in the Quickstart above or the [samples](./clearblade-cloud-iot/samples) folder. +Before running the sample, you must configure your development environment and terminal as described in the Quickstart above or the [samples](./clearblade-cloud-iot/samples) folder. -Before running the samples, you must set the `CLEARBLADE_CONFIGURATION`. Optionally set the `CLEARBLADE_REGISTRY` and -`CLEARBLADE_REGION` environment variables to avoid changing them in the the sample app every time you run it. +Before running the samples, you must set the `CLEARBLADE_CONFIGURATION`. Optionally, set the `CLEARBLADE_REGISTRY` and `CLEARBLADE_REGION` environment variables to avoid changing them in the sample app every time you run it. -If you set `BINARYDATA_AND_TIME_GOOGLE_FORMAT` environment variable then it will give binaryData object's response in binary -form and time in Timestamp format which will have seconds and nanos in it which is following google's structure. Basically -it's applicable on get device state list, modify config, device config versions methods. To get the data in proper format -it should be cast in proper format. +If you set the `BINARYDATA_AND_TIME_GOOGLE_FORMAT` environment variable, then it will give the binaryData object's response in binary form and time in timestamp format, which will have seconds and nanoseconds, following Google's structure. It's applicable on the get device state list and modify and device config version methods. Cast the data in the proper format. ``` ListDeviceStatesResponse response = deviceManagerClient.listDeviceStates(request); @@ -87,12 +79,12 @@ it should be cast in proper format. } ``` -When switching to use new registries and/or regions, either: +When switching to use new registries and regions, either: 1. Update the `CLEARBLADE_REGISTRY` and `CLEARBLADE_REGION` environment variables; or -2. Change the `REGISTRY` and/or `REGION` variables in the sample code/app. +2. Change the `REGISTRY` and `REGION` variables in the sample code/app. -## Using the client library within an Example app +## Using the client library within an example app ``` public class App { @@ -125,11 +117,11 @@ public class App { DevicesListResponse response = deviceManagerAsyncClient.listDevices(request); ``` -## Running the sample - Command Line +## Running the sample: command line The following command summarizes the sample usage: -First compile the sample. +First, compile the sample. Run registry example: From d74fae5ac8c9acc72033d900cbfef80a677a765a Mon Sep 17 00:00:00 2001 From: jslavin-clearblade <116581763+jslavin-clearblade@users.noreply.github.com> Date: Thu, 13 Jul 2023 12:58:15 -0400 Subject: [PATCH 091/151] Update README.md Miko, For your review/approval. Thanks, Jeff --- clearblade-cloud-iot/samples/README.md | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/clearblade-cloud-iot/samples/README.md b/clearblade-cloud-iot/samples/README.md index 49289cdd..3844b1d4 100644 --- a/clearblade-cloud-iot/samples/README.md +++ b/clearblade-cloud-iot/samples/README.md @@ -1,15 +1,11 @@ -# Java Samples - -This folder contains Java samples that demonstrate an overview of the -ClearBlade IoT Core platform. +# ClearBlade IoT Core Platform Java samples ## Quickstart -1. From the [ClearBlade Migration from Google IoT Core section](https://clearblade.atlassian.net/wiki/spaces/IC/pages/2202664969/Migration+from+Google+IoT+Core) - migrate your existing Google IoT Core registries and/or devices into ClearBlade IoT Core or using the - ClearBlade IoT Core Console, [create a device registry and devices](https://clearblade.atlassian.net/wiki/spaces/IC/pages/2202206388/Creating+registries+and+devices). +1. Migrate your Google IoT Core registries and devices into ClearBlade IoT Core from the [ClearBlade Migration from Google IoT Core section](https://clearblade.atlassian.net/wiki/spaces/IC/pages/2202664969/Migration+from+Google+IoT+Core) or + [Creating registries and devices section](https://clearblade.atlassian.net/wiki/spaces/IC/pages/2202206388/Creating+registries+and+devices). -2. [Add service accounts to a project](https://clearblade.atlassian.net/wiki/spaces/IC/pages/2240675843/Add+service+accounts+to+a+project) and download the json file with your service +2. [Add service accounts to a project](https://clearblade.atlassian.net/wiki/spaces/IC/pages/2240675843/Add+service+accounts+to+a+project) and download the JSON file with your service account’s credentials. 3. Use the following to set your environment variables keys: From e5145815f24d34e0b9b54179783600ba18b1e6fc Mon Sep 17 00:00:00 2001 From: ronak-ingress Date: Wed, 11 Oct 2023 10:37:21 +0530 Subject: [PATCH 092/151] - Converted URL string to URLEncoded to support % in device name. --- .../cloud/iot/v1/deletedevice/DeleteDeviceRequest.java | 8 +++++++- .../cloud/iot/v1/getdevice/GetDeviceRequest.java | 10 +++++++++- .../SendCommandToDeviceRequest.java | 9 ++++++++- .../cloud/iot/v1/updatedevice/UpdateDeviceRequest.java | 6 ++++-- 4 files changed, 28 insertions(+), 5 deletions(-) diff --git a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/deletedevice/DeleteDeviceRequest.java b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/deletedevice/DeleteDeviceRequest.java index 3845b09b..700a3fa4 100644 --- a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/deletedevice/DeleteDeviceRequest.java +++ b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/deletedevice/DeleteDeviceRequest.java @@ -31,6 +31,8 @@ package com.clearblade.cloud.iot.v1.deletedevice; import com.clearblade.cloud.iot.v1.devicetypes.DeviceName; +import com.clearblade.cloud.iot.v1.exception.ApplicationException; +import java.net.URLEncoder; public class DeleteDeviceRequest { private DeviceName name; @@ -77,7 +79,11 @@ public Builder setName(DeviceName name) { @Override public String toString() { String params = ""; - params = "name="+this.name.toString(); + try { + params = "name="+ URLEncoder.encode(this.name.toString(),"UTF-8"); + } catch (Exception e) { + throw new ApplicationException(e); + } return params; } diff --git a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/getdevice/GetDeviceRequest.java b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/getdevice/GetDeviceRequest.java index d42fafec..f610d115 100644 --- a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/getdevice/GetDeviceRequest.java +++ b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/getdevice/GetDeviceRequest.java @@ -32,6 +32,10 @@ import com.clearblade.cloud.iot.v1.devicetypes.DeviceName; import com.clearblade.cloud.iot.v1.devicetypes.FieldMask; +import com.clearblade.cloud.iot.v1.exception.ApplicationException; + +import java.io.UnsupportedEncodingException; +import java.net.URLEncoder; public class GetDeviceRequest { @@ -90,7 +94,11 @@ public DeviceName getName() { @Override public String toString() { String params = ""; - params = "name=" + this.name.toString(); + try { + params = "name=" + URLEncoder.encode(this.name.toString(),"UTF-8") ; + } catch (Exception e) { + throw new ApplicationException(e); + } if (this.fieldMask.toString() != "") { params += "&fieldMask=" + this.fieldMask.toString(); } diff --git a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/sendcommandtodevice/SendCommandToDeviceRequest.java b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/sendcommandtodevice/SendCommandToDeviceRequest.java index 6e98eb78..cafdb934 100644 --- a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/sendcommandtodevice/SendCommandToDeviceRequest.java +++ b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/sendcommandtodevice/SendCommandToDeviceRequest.java @@ -30,8 +30,10 @@ package com.clearblade.cloud.iot.v1.sendcommandtodevice; +import java.net.URLEncoder; import java.util.Arrays; +import com.clearblade.cloud.iot.v1.exception.ApplicationException; import org.json.simple.JSONObject; import com.clearblade.cloud.iot.v1.devicetypes.DeviceName; @@ -148,7 +150,12 @@ public String toString() { @SuppressWarnings("unchecked") public String[] getBodyAndParams() { String[] output = new String[2]; - String params = "name=" + this.deviceName + "&method=sendCommandToDevice"; + String params = null; + try { + params = "name=" + URLEncoder.encode(this.deviceName,"UTF-8") + "&method=sendCommandToDevice"; + } catch (Exception e) { + throw new ApplicationException(e); + } String bData = null; if (this.binaryData != null) { bData = new String(this.binaryData.toByteArray()); diff --git a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/updatedevice/UpdateDeviceRequest.java b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/updatedevice/UpdateDeviceRequest.java index 23a2a70d..3ddae3a9 100644 --- a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/updatedevice/UpdateDeviceRequest.java +++ b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/updatedevice/UpdateDeviceRequest.java @@ -30,6 +30,8 @@ package com.clearblade.cloud.iot.v1.updatedevice; +import java.io.UnsupportedEncodingException; +import java.net.URLEncoder; import java.util.ArrayList; import java.util.Iterator; import java.util.List; @@ -129,10 +131,10 @@ public DeviceName getDeviceName() { } @SuppressWarnings("unchecked") - public String[] getBodyAndParams() { + public String[] getBodyAndParams() throws UnsupportedEncodingException { String[] output = new String[2]; - String params = "name=" + this.name + "&updateMask=" + this.updateMask; + String params = "name=" + URLEncoder.encode(this.name,"UTF-8") + "&updateMask=" + this.updateMask; bodyParams = new JSONObject(); bodyParams.put("id", this.device.toBuilder().getId()); From feb196d72ee0e2cdaa3ac96aa74341868002cd36 Mon Sep 17 00:00:00 2001 From: mikoaro Date: Wed, 11 Oct 2023 06:51:19 -0500 Subject: [PATCH 093/151] Remove unused import --- .../com/clearblade/cloud/iot/v1/getdevice/GetDeviceRequest.java | 1 - 1 file changed, 1 deletion(-) diff --git a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/getdevice/GetDeviceRequest.java b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/getdevice/GetDeviceRequest.java index f610d115..4e889225 100644 --- a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/getdevice/GetDeviceRequest.java +++ b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/getdevice/GetDeviceRequest.java @@ -34,7 +34,6 @@ import com.clearblade.cloud.iot.v1.devicetypes.FieldMask; import com.clearblade.cloud.iot.v1.exception.ApplicationException; -import java.io.UnsupportedEncodingException; import java.net.URLEncoder; public class GetDeviceRequest { From a35c57fd8a50940dc0b0b4a526859116553f456b Mon Sep 17 00:00:00 2001 From: mikoaro Date: Wed, 11 Oct 2023 08:32:13 -0500 Subject: [PATCH 094/151] Remove unused import --- .../com/clearblade/cloud/iot/v1/getdevice/GetDeviceRequest.java | 1 - 1 file changed, 1 deletion(-) diff --git a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/getdevice/GetDeviceRequest.java b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/getdevice/GetDeviceRequest.java index 4e889225..36e9dfd3 100644 --- a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/getdevice/GetDeviceRequest.java +++ b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/getdevice/GetDeviceRequest.java @@ -33,7 +33,6 @@ import com.clearblade.cloud.iot.v1.devicetypes.DeviceName; import com.clearblade.cloud.iot.v1.devicetypes.FieldMask; import com.clearblade.cloud.iot.v1.exception.ApplicationException; - import java.net.URLEncoder; public class GetDeviceRequest { From 248168c6447fc2c6d0a324d0d2dc831401642cec Mon Sep 17 00:00:00 2001 From: mikoaro Date: Wed, 11 Oct 2023 08:40:16 -0500 Subject: [PATCH 095/151] Set version to 1.0.1 --- clearblade-cloud-iot/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/clearblade-cloud-iot/pom.xml b/clearblade-cloud-iot/pom.xml index 7b6ff89f..5522330a 100644 --- a/clearblade-cloud-iot/pom.xml +++ b/clearblade-cloud-iot/pom.xml @@ -3,7 +3,7 @@ io.github.clearblade clearblade-cloud-iot - 1.0.0 + 1.0.1 jar Java Client Library for ClearBlade IoT Core From cfb8d5c439fe4d24ad01ff127517bb0d7059ef84 Mon Sep 17 00:00:00 2001 From: mikoaro Date: Wed, 11 Oct 2023 08:56:01 -0500 Subject: [PATCH 096/151] Update CHANGELOG --- clearblade-cloud-iot/CHANGELOG.md | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/clearblade-cloud-iot/CHANGELOG.md b/clearblade-cloud-iot/CHANGELOG.md index 0b4f3d52..dc61147a 100644 --- a/clearblade-cloud-iot/CHANGELOG.md +++ b/clearblade-cloud-iot/CHANGELOG.md @@ -1,9 +1,13 @@ # Changelog +## 1.0.1 + +- Convert URL string to URLEncoded to support % in a device name. + ## 1.0.0 -- Updated UpdateDeviceRequest, to set name as DeviceName instead of only device_id. See below example, - UpdateDeviceRequest.Builder.newBuilder().setName(**DeviceName.of(PROJECT,LOCATION,REGISTRY,DEVICE).toString()**).setDevice(device.build()) +- Updated UpdateDeviceRequest, to set name as DeviceName instead of only device_id. See below example, + UpdateDeviceRequest.Builder.newBuilder().setName(**DeviceName.of(PROJECT,LOCATION,REGISTRY,DEVICE).toString()**).setDevice(device.build()) - Removed static variables from ConfigParameters and it's dependency. - Updated CreateDeviceRequest.java to support parent as String instead of RegistryName. See below example, From d47572b9701167438610822675c6e29717ba80a5 Mon Sep 17 00:00:00 2001 From: mikoaro Date: Wed, 11 Oct 2023 08:57:34 -0500 Subject: [PATCH 097/151] Update README --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 9075f190..33572745 100644 --- a/README.md +++ b/README.md @@ -22,7 +22,7 @@ If you are using the Maven artifact, add the following dependency to your pom.xm io.github.clearblade clearblade-cloud-iot - 1.0.0 + 1.0.1 ``` From c3ecab152081fdffcfaa830dfc485dc3162286f5 Mon Sep 17 00:00:00 2001 From: ronak-ingress Date: Tue, 17 Oct 2023 11:42:23 +0530 Subject: [PATCH 098/151] - Converted URL string to URLEncoded to support % in device name. --- .../ListDeviceConfigVersionsRequest.java | 10 +++++++++- .../ModifyCloudToDeviceConfigRequest.java | 10 +++++++++- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/listdeviceconfigversions/ListDeviceConfigVersionsRequest.java b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/listdeviceconfigversions/ListDeviceConfigVersionsRequest.java index 999c6783..1654e868 100644 --- a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/listdeviceconfigversions/ListDeviceConfigVersionsRequest.java +++ b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/listdeviceconfigversions/ListDeviceConfigVersionsRequest.java @@ -31,9 +31,13 @@ package com.clearblade.cloud.iot.v1.listdeviceconfigversions; import com.clearblade.cloud.iot.v1.devicetypes.DeviceName; +import com.clearblade.cloud.iot.v1.exception.ApplicationException; import com.clearblade.cloud.iot.v1.registrytypes.LocationName; import org.json.simple.JSONObject; +import java.io.UnsupportedEncodingException; +import java.net.URLEncoder; + public class ListDeviceConfigVersionsRequest { private final String name; private final String numVersions; @@ -101,7 +105,11 @@ public String toString() { public String getParamsForList() { String params = ""; - params = "name=" + this.name; + try { + params = "name=" + URLEncoder.encode(this.name,"UTF-8"); + } catch (UnsupportedEncodingException e) { + throw new ApplicationException(e); + } params += "&numVersions=" + this.numVersions; return params; diff --git a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/modifycloudtodeviceconfig/ModifyCloudToDeviceConfigRequest.java b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/modifycloudtodeviceconfig/ModifyCloudToDeviceConfigRequest.java index 61324ac5..73359f88 100644 --- a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/modifycloudtodeviceconfig/ModifyCloudToDeviceConfigRequest.java +++ b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/modifycloudtodeviceconfig/ModifyCloudToDeviceConfigRequest.java @@ -30,9 +30,12 @@ package com.clearblade.cloud.iot.v1.modifycloudtodeviceconfig; +import java.io.UnsupportedEncodingException; +import java.net.URLEncoder; import java.util.Arrays; import com.clearblade.cloud.iot.v1.devicetypes.DeviceName; +import com.clearblade.cloud.iot.v1.exception.ApplicationException; import com.clearblade.cloud.iot.v1.registrytypes.LocationName; import org.json.simple.JSONObject; @@ -108,7 +111,12 @@ public String toString() { @SuppressWarnings("unchecked") public String[] getBodyAndParams() { String[] output = new String[2]; - String params = "name=" + this.deviceName + "&method=modifyCloudToDeviceConfig"; + String params = null; + try { + params = "name=" + URLEncoder.encode(this.deviceName,"UTF-8") + "&method=modifyCloudToDeviceConfig"; + } catch (UnsupportedEncodingException e) { + throw new ApplicationException(e); + } String bData = "EMPTY"; if (this.binaryData != null) { bData = new String(this.binaryData.toByteArray()); From 42059da869fae6a1b756374da7941eaa175fcaed Mon Sep 17 00:00:00 2001 From: mikoaro Date: Tue, 17 Oct 2023 08:21:44 -0500 Subject: [PATCH 099/151] Set version to 1.0.2 --- clearblade-cloud-iot/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/clearblade-cloud-iot/pom.xml b/clearblade-cloud-iot/pom.xml index 5522330a..c8d46511 100644 --- a/clearblade-cloud-iot/pom.xml +++ b/clearblade-cloud-iot/pom.xml @@ -3,7 +3,7 @@ io.github.clearblade clearblade-cloud-iot - 1.0.1 + 1.0.2 jar Java Client Library for ClearBlade IoT Core From 2f674ebe523d9b3bb098737aec866da52e21d53f Mon Sep 17 00:00:00 2001 From: mikoaro Date: Tue, 17 Oct 2023 08:22:14 -0500 Subject: [PATCH 100/151] Update changelog --- clearblade-cloud-iot/CHANGELOG.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/clearblade-cloud-iot/CHANGELOG.md b/clearblade-cloud-iot/CHANGELOG.md index dc61147a..ba59b805 100644 --- a/clearblade-cloud-iot/CHANGELOG.md +++ b/clearblade-cloud-iot/CHANGELOG.md @@ -1,5 +1,9 @@ # Changelog +## 1.0.2 + +- Convert URL string to URLEncoded to support % in a device name. + ## 1.0.1 - Convert URL string to URLEncoded to support % in a device name. From 03df9aa25f6cf1a2e50c930e77d5a4b93ea9c570 Mon Sep 17 00:00:00 2001 From: mikoaro Date: Tue, 17 Oct 2023 08:37:19 -0500 Subject: [PATCH 101/151] Update README --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 33572745..53d044ab 100644 --- a/README.md +++ b/README.md @@ -22,7 +22,7 @@ If you are using the Maven artifact, add the following dependency to your pom.xm io.github.clearblade clearblade-cloud-iot - 1.0.1 + 1.0.2 ``` From 72a7df9e03f69ecba1031ad9c20ae3217394d30b Mon Sep 17 00:00:00 2001 From: mikoaro Date: Tue, 17 Oct 2023 08:37:58 -0500 Subject: [PATCH 102/151] Update Changelog --- clearblade-cloud-iot/CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/clearblade-cloud-iot/CHANGELOG.md b/clearblade-cloud-iot/CHANGELOG.md index ba59b805..9195b20e 100644 --- a/clearblade-cloud-iot/CHANGELOG.md +++ b/clearblade-cloud-iot/CHANGELOG.md @@ -2,7 +2,7 @@ ## 1.0.2 -- Convert URL string to URLEncoded to support % in a device name. +- Replace URL string with URLEncoded to support % in a device name. ## 1.0.1 From 973f62d05279926f18083b98d3d0c63856ae4681 Mon Sep 17 00:00:00 2001 From: ronak-ingress Date: Sat, 21 Oct 2023 21:28:21 +0530 Subject: [PATCH 103/151] - Converted URL string to URLEncoded to support % in device name. - Added env variable for testing. --- .../BindDeviceToGatewayRequest.java | 14 +++------- .../v1/createdevice/CreateDeviceRequest.java | 5 +++- .../CreateDeviceRegistryRequest.java | 10 ++++--- .../DeleteDeviceRegistryRequest.java | 7 +++-- .../GetDeviceRegistryRequest.java | 5 +++- .../UnbindDeviceFromGatewayRequest.java | 13 +++------ .../UpdateDeviceRegistryRequest.java | 27 +++++-------------- .../iot/v1/test/DeviceManagerClientTest.java | 18 ++++++------- 8 files changed, 43 insertions(+), 56 deletions(-) diff --git a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/binddevicetogateway/BindDeviceToGatewayRequest.java b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/binddevicetogateway/BindDeviceToGatewayRequest.java index 19ec8286..bdd8e20a 100644 --- a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/binddevicetogateway/BindDeviceToGatewayRequest.java +++ b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/binddevicetogateway/BindDeviceToGatewayRequest.java @@ -31,9 +31,11 @@ package com.clearblade.cloud.iot.v1.binddevicetogateway; import com.clearblade.cloud.iot.v1.registrytypes.RegistryName; -import com.clearblade.cloud.iot.v1.utils.PathTemplate; import org.json.simple.JSONObject; +import java.net.URLEncoder; +import java.nio.charset.StandardCharsets; + public class BindDeviceToGatewayRequest { private final String parent; private final String gateway; @@ -85,18 +87,10 @@ public BindDeviceToGatewayRequest build() { } } - public JSONObject getRequestParams() { - return requestParams; - } - public void setRequestParams(JSONObject requestParams) { this.requestParams = requestParams; } - public JSONObject getBodyParams() { - return bodyParams; - } - public void setBodyParams(JSONObject bodyParams) { this.bodyParams = bodyParams; } @@ -127,7 +121,7 @@ public String toString() { @SuppressWarnings("unchecked") public String[] getBodyAndParams() { String[] output = new String[2]; - String params = "parent=" + this.parent + "&method=" + "bindDeviceToGateway"; + String params = "parent=" + URLEncoder.encode(this.parent, StandardCharsets.UTF_8) + "&method=" + "bindDeviceToGateway"; bodyParams = new JSONObject(); bodyParams.put("gatewayId", this.gateway); bodyParams.put("deviceId", this.device); diff --git a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/createdevice/CreateDeviceRequest.java b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/createdevice/CreateDeviceRequest.java index 18021626..e30db49b 100644 --- a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/createdevice/CreateDeviceRequest.java +++ b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/createdevice/CreateDeviceRequest.java @@ -33,6 +33,9 @@ import com.clearblade.cloud.iot.v1.devicetypes.Device; import com.clearblade.cloud.iot.v1.registrytypes.RegistryName; +import java.net.URLEncoder; +import java.nio.charset.StandardCharsets; + public class CreateDeviceRequest { private final String parent; private final Device device; @@ -80,7 +83,7 @@ public RegistryName getParent() { public String[] getParams() { String[] params = new String[2]; - params[0] = "parent=" + getParent().getRegistryFullName(); + params[0] = "parent=" + URLEncoder.encode(getParent().getRegistryFullName(), StandardCharsets.UTF_8); params[1] = this.device.createDeviceJSONObject(); return params; } diff --git a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/createdeviceregistry/CreateDeviceRegistryRequest.java b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/createdeviceregistry/CreateDeviceRegistryRequest.java index 8c16120b..2114486e 100644 --- a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/createdeviceregistry/CreateDeviceRegistryRequest.java +++ b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/createdeviceregistry/CreateDeviceRegistryRequest.java @@ -32,11 +32,13 @@ import com.clearblade.cloud.iot.v1.registrytypes.DeviceRegistry; import com.clearblade.cloud.iot.v1.registrytypes.LocationName; -import com.clearblade.cloud.iot.v1.registrytypes.RegistryName; + +import java.net.URLEncoder; +import java.nio.charset.StandardCharsets; public class CreateDeviceRegistryRequest { - private String parent; - private DeviceRegistry deviceRegistry; + private final String parent; + private final DeviceRegistry deviceRegistry; private CreateDeviceRegistryRequest(Builder builder) { this.parent = builder.parent; @@ -81,7 +83,7 @@ public LocationName getParent() { public String[] getBodyAndParams() { String[] output = new String[2]; - output[0] = "parent=" + this.parent; + output[0] = "parent=" + URLEncoder.encode(this.parent, StandardCharsets.UTF_8); output[1] = this.deviceRegistry.createDeviceJSONObject(parent); return output; } diff --git a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/deletedeviceregistry/DeleteDeviceRegistryRequest.java b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/deletedeviceregistry/DeleteDeviceRegistryRequest.java index fb0cbf05..6adaad5a 100644 --- a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/deletedeviceregistry/DeleteDeviceRegistryRequest.java +++ b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/deletedeviceregistry/DeleteDeviceRegistryRequest.java @@ -30,8 +30,11 @@ package com.clearblade.cloud.iot.v1.deletedeviceregistry; +import java.net.URLEncoder; +import java.nio.charset.StandardCharsets; + public class DeleteDeviceRegistryRequest { - private String name; + private final String name; private DeleteDeviceRegistryRequest(Builder builder) { this.name = builder.name; @@ -64,7 +67,7 @@ public DeleteDeviceRegistryRequest build() { } public String getParams() { - return "name=" + this.name; + return "name=" + URLEncoder.encode(this.name, StandardCharsets.UTF_8); } diff --git a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/getdeviceregistry/GetDeviceRegistryRequest.java b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/getdeviceregistry/GetDeviceRegistryRequest.java index 2ab4c9e8..d8ecc042 100644 --- a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/getdeviceregistry/GetDeviceRegistryRequest.java +++ b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/getdeviceregistry/GetDeviceRegistryRequest.java @@ -32,6 +32,9 @@ import com.clearblade.cloud.iot.v1.registrytypes.RegistryName; +import java.net.URLEncoder; +import java.nio.charset.StandardCharsets; + public class GetDeviceRegistryRequest { private final String name; @@ -72,7 +75,7 @@ public RegistryName getName() { @Override public String toString() { - return "name=" + this.name; + return "name=" + URLEncoder.encode(this.name, StandardCharsets.UTF_8); } } diff --git a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/unbinddevicefromgateway/UnbindDeviceFromGatewayRequest.java b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/unbinddevicefromgateway/UnbindDeviceFromGatewayRequest.java index e6f52068..c5906eac 100644 --- a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/unbinddevicefromgateway/UnbindDeviceFromGatewayRequest.java +++ b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/unbinddevicefromgateway/UnbindDeviceFromGatewayRequest.java @@ -30,10 +30,12 @@ package com.clearblade.cloud.iot.v1.unbinddevicefromgateway; -import com.clearblade.cloud.iot.v1.devicetypes.DeviceName; import com.clearblade.cloud.iot.v1.registrytypes.RegistryName; import org.json.simple.JSONObject; +import java.net.URLEncoder; +import java.nio.charset.StandardCharsets; + public class UnbindDeviceFromGatewayRequest { private final String parent; private final String gateway; @@ -90,17 +92,10 @@ public RegistryName getParent() { } - public JSONObject getRequestParams() { - return requestParams; - } - public void setRequestParams(JSONObject requestParams) { this.requestParams = requestParams; } - public JSONObject getBodyParams() { - return bodyParams; - } public void setBodyParams(JSONObject bodyParams) { this.bodyParams = bodyParams; @@ -127,7 +122,7 @@ public String toString() { @SuppressWarnings("unchecked") public String[] getBodyAndParams() { String[] output = new String[2]; - String params = "parent=" + this.parent + "&method=unbindDeviceFromGateway"; + String params = "parent=" + URLEncoder.encode(this.parent, StandardCharsets.UTF_8) + "&method=unbindDeviceFromGateway"; bodyParams = new JSONObject(); bodyParams.put("gatewayId", this.gateway); bodyParams.put("deviceId", this.device); diff --git a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/updatedeviceregistry/UpdateDeviceRegistryRequest.java b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/updatedeviceregistry/UpdateDeviceRegistryRequest.java index 505139cb..7eaca767 100644 --- a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/updatedeviceregistry/UpdateDeviceRegistryRequest.java +++ b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/updatedeviceregistry/UpdateDeviceRegistryRequest.java @@ -35,11 +35,14 @@ import com.clearblade.cloud.iot.v1.registrytypes.DeviceRegistry; +import java.net.URLEncoder; +import java.nio.charset.StandardCharsets; + public class UpdateDeviceRegistryRequest { - private String name; - private String updateMask; - private DeviceRegistry deviceRegistry; + private final String name; + private final String updateMask; + private final DeviceRegistry deviceRegistry; JSONObject requestParams; JSONObject bodyParams; @@ -49,22 +52,6 @@ private UpdateDeviceRegistryRequest(Builder builder) { this.deviceRegistry = builder.deviceRegistry; } - public JSONObject getRequestParams() { - return requestParams; - } - - public void setRequestParams(JSONObject requestParams) { - this.requestParams = requestParams; - } - - public JSONObject getBodyParams() { - return bodyParams; - } - - public void setBodyParams(JSONObject bodyParams) { - this.bodyParams = bodyParams; - } - // Static class Builder public static class Builder { @@ -124,7 +111,7 @@ public String toString() { public String[] getBodyAndParams() { String[] output = new String[2]; - String params = "name=" + this.name + "&updateMask=" + this.updateMask; + String params = "name=" + URLEncoder.encode(this.name, StandardCharsets.UTF_8)+ "&updateMask=" + this.updateMask; output[0] = params; output[1] = this.deviceRegistry.createDeviceJSONObject(""); diff --git a/clearblade-cloud-iot/src/test/com/clearblade/cloud/iot/v1/test/DeviceManagerClientTest.java b/clearblade-cloud-iot/src/test/com/clearblade/cloud/iot/v1/test/DeviceManagerClientTest.java index 7e8bd01a..07758501 100644 --- a/clearblade-cloud-iot/src/test/com/clearblade/cloud/iot/v1/test/DeviceManagerClientTest.java +++ b/clearblade-cloud-iot/src/test/com/clearblade/cloud/iot/v1/test/DeviceManagerClientTest.java @@ -73,14 +73,14 @@ public class DeviceManagerClientTest { private static DeviceManagerClient client; private static ExpectedResponseTest testResponse; - private String project = "xxx"; - private String location = "xxx"; - private String registryId = "xxx"; - private String failedRegistryId = "xxx"; - private String deviceId = "xxx"; - private String gatewayId = "xxx"; - private String numDeviceId = "xxx"; - private String numGatewayId = "xxx"; + private final String project = System.getenv("PROJECT_ID"); + private final String location = System.getenv("REGION"); + private final String registryId = System.getenv("REGISTRY"); + private final String failedRegistryId = System.getenv("FAIL_REGISTRY"); + private final String deviceId = System.getenv("DEVICE"); + private final String gatewayId = System.getenv("GATEWAY_ID"); + private final String numDeviceId = System.getenv("NUM_DEVICE_ID"); + private final String numGatewayId = System.getenv("NUM_GATEWAY_ID"); @BeforeAll public static void setUp() { @@ -91,6 +91,7 @@ public static void setUp() { @Test @Order(1) public void testCreateRegistrySuccess() { + System.out.println("ENV VARIABLE : " + project); DeviceRegistry expectedResponse = testResponse.getResponseTest2(registryId); CreateDeviceRegistryRequest request = CreateDeviceRegistryRequest.Builder.newBuilder() .setParent(LocationName.of(project, location).toString()) @@ -199,7 +200,6 @@ public void testCreateDeviceAsAGatewaySuccess() { @Order(7) public void testGetDeviceFail() { DeviceName name = DeviceName.of(project, location, registryId, "test_device02"); - Device expectedResponse = testResponse.getResponseTest9(deviceId, numDeviceId); GetDeviceRequest request = GetDeviceRequest.Builder.newBuilder().setName(name) .setFieldMask(FieldMask.newBuilder().build()).build(); Device actualResponse = null; From cc80cc245978de0dfeb71d18fa445bc26029b67b Mon Sep 17 00:00:00 2001 From: ronak-ingress Date: Sun, 22 Oct 2023 17:59:43 +0530 Subject: [PATCH 104/151] - Converted URL string to URLEncoded to support % in device name. - Added env variable for testing. - Added Github yml file. --- clearblade-cloud-iot/.github/test.yml | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 clearblade-cloud-iot/.github/test.yml diff --git a/clearblade-cloud-iot/.github/test.yml b/clearblade-cloud-iot/.github/test.yml new file mode 100644 index 00000000..158072b8 --- /dev/null +++ b/clearblade-cloud-iot/.github/test.yml @@ -0,0 +1,15 @@ +on: + pull_request: + branches: + - master +jobs: + test: + runs-on: ubuntu-latest + env: + SECRET_NAME: ${{ secrets.PROJECT_ID }} + steps: + - name: Checkout code + uses: actions/checkout@v2 + + - name: Run tests + run: mvn test \ No newline at end of file From e3781d4b5571b73fed361489dcf3a15f1b03ef3e Mon Sep 17 00:00:00 2001 From: ronak-ingress Date: Sun, 22 Oct 2023 18:13:41 +0530 Subject: [PATCH 105/151] - Converted URL string to URLEncoded to support % in device name. - Added env variable for testing. - Added Github yml file. --- clearblade-cloud-iot/.github/test.yml | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/clearblade-cloud-iot/.github/test.yml b/clearblade-cloud-iot/.github/test.yml index 158072b8..c8f13375 100644 --- a/clearblade-cloud-iot/.github/test.yml +++ b/clearblade-cloud-iot/.github/test.yml @@ -1,15 +1,24 @@ on: pull_request: branches: - - master + - main jobs: test: runs-on: ubuntu-latest env: SECRET_NAME: ${{ secrets.PROJECT_ID }} steps: - - name: Checkout code + - name: Checkout the repository uses: actions/checkout@v2 - - - name: Run tests - run: mvn test \ No newline at end of file + - name: Set up JDK 14 + uses: actions/setup-java@v1 + with: + java-version: 14 + - name: Cache Maven packages + uses: actions/cache@v2 + with: + path: ~/.m2 + key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }} + restore-keys: ${{ runner.os }}-m2 + - name: Run tests with Maven + run: mvn -B test --file pom.xml From bc42c442dcbfd7ae03fbe35c20aceb474734692a Mon Sep 17 00:00:00 2001 From: ronak-ingress <114172748+ronak-ingress@users.noreply.github.com> Date: Sun, 22 Oct 2023 18:28:52 +0530 Subject: [PATCH 106/151] Update ci.yaml commenting .kokoro for now --- .github/workflows/ci.yaml | 92 +++++++++++++++++++-------------------- 1 file changed, 46 insertions(+), 46 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index e3bb26e3..5eabbd94 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -16,7 +16,7 @@ on: push: branches: - - main + - main pull_request: name: ci jobs: @@ -27,63 +27,63 @@ jobs: matrix: java: [8, 11, 17] steps: - - uses: actions/checkout@v3 - - uses: actions/setup-java@v3 - with: - distribution: zulu - java-version: ${{matrix.java}} - - run: java -version - - run: .kokoro/build.sh - env: - JOB_TYPE: test + - uses: actions/checkout@v3 + - uses: actions/setup-java@v3 + with: + distribution: zulu + java-version: ${{matrix.java}} + - run: java -version +# - run: .kokoro/build.sh + env: + JOB_TYPE: test windows: runs-on: windows-latest steps: - - name: Support longpaths - run: git config --system core.longpaths true - - uses: actions/checkout@v3 - - uses: actions/setup-java@v3 - with: - distribution: zulu - java-version: 8 - - run: java -version - - run: .kokoro/build.bat - env: - JOB_TYPE: test + - name: Support longpaths + run: git config --system core.longpaths true + - uses: actions/checkout@v3 + - uses: actions/setup-java@v3 + with: + distribution: zulu + java-version: 8 + - run: java -version +# - run: .kokoro/build.bat + env: + JOB_TYPE: test dependencies: runs-on: ubuntu-latest strategy: matrix: java: [8, 11, 17] steps: - - uses: actions/checkout@v3 - - uses: actions/setup-java@v3 - with: - distribution: zulu - java-version: ${{matrix.java}} - - run: java -version - - run: .kokoro/dependencies.sh + - uses: actions/checkout@v3 + - uses: actions/setup-java@v3 + with: + distribution: zulu + java-version: ${{matrix.java}} + - run: java -version +# - run: .kokoro/dependencies.sh lint: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 - - uses: actions/setup-java@v3 - with: - distribution: zulu - java-version: 11 - - run: java -version - - run: .kokoro/build.sh - env: - JOB_TYPE: lint + - uses: actions/checkout@v3 + - uses: actions/setup-java@v3 + with: + distribution: zulu + java-version: 11 + - run: java -version +# - run: .kokoro/build.sh + env: + JOB_TYPE: lint clirr: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 - - uses: actions/setup-java@v3 - with: - distribution: zulu - java-version: 8 - - run: java -version - - run: .kokoro/build.sh - env: - JOB_TYPE: clirr + - uses: actions/checkout@v3 + - uses: actions/setup-java@v3 + with: + distribution: zulu + java-version: 8 + - run: java -version +# - run: .kokoro/build.sh + env: + JOB_TYPE: clirr From 424c497f27a7d4ebe6d232518925c038bb0f78d0 Mon Sep 17 00:00:00 2001 From: ronak-ingress Date: Sun, 22 Oct 2023 18:38:13 +0530 Subject: [PATCH 107/151] - Converted URL string to URLEncoded to support % in device name. - Added env variable for testing. - Added Github yml file. --- clearblade-cloud-iot/.github/test.yml | 24 ------------------------ 1 file changed, 24 deletions(-) delete mode 100644 clearblade-cloud-iot/.github/test.yml diff --git a/clearblade-cloud-iot/.github/test.yml b/clearblade-cloud-iot/.github/test.yml deleted file mode 100644 index c8f13375..00000000 --- a/clearblade-cloud-iot/.github/test.yml +++ /dev/null @@ -1,24 +0,0 @@ -on: - pull_request: - branches: - - main -jobs: - test: - runs-on: ubuntu-latest - env: - SECRET_NAME: ${{ secrets.PROJECT_ID }} - steps: - - name: Checkout the repository - uses: actions/checkout@v2 - - name: Set up JDK 14 - uses: actions/setup-java@v1 - with: - java-version: 14 - - name: Cache Maven packages - uses: actions/cache@v2 - with: - path: ~/.m2 - key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }} - restore-keys: ${{ runner.os }}-m2 - - name: Run tests with Maven - run: mvn -B test --file pom.xml From 48129d4c9e3006a06b05a168606928bcd65fde42 Mon Sep 17 00:00:00 2001 From: ronak-ingress <114172748+ronak-ingress@users.noreply.github.com> Date: Sun, 22 Oct 2023 18:50:06 +0530 Subject: [PATCH 108/151] Update samples.yaml updating src path --- .github/workflows/samples.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/samples.yaml b/.github/workflows/samples.yaml index 912ed8b2..76a2f515 100644 --- a/.github/workflows/samples.yaml +++ b/.github/workflows/samples.yaml @@ -27,4 +27,4 @@ jobs: java-version: 8 - name: Run checkstyle run: mvn -P lint --quiet --batch-mode checkstyle:check - working-directory: samples/snippets + working-directory: src/com.clearblade.cloud.iot.v1 From 03aa73724d86f580c245538b68e06f86e62b9f20 Mon Sep 17 00:00:00 2001 From: ronak-ingress <114172748+ronak-ingress@users.noreply.github.com> Date: Sun, 22 Oct 2023 18:53:56 +0530 Subject: [PATCH 109/151] Update samples.yaml commenting checkstyle for now --- .github/workflows/samples.yaml | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/.github/workflows/samples.yaml b/.github/workflows/samples.yaml index 76a2f515..a107c16f 100644 --- a/.github/workflows/samples.yaml +++ b/.github/workflows/samples.yaml @@ -13,18 +13,18 @@ # limitations under the License. # Github action job to test core java library features on # downstream client libraries before they are released. -on: - pull_request: -name: samples -jobs: - checkstyle: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v3 - - uses: actions/setup-java@v3 - with: - distribution: zulu - java-version: 8 - - name: Run checkstyle - run: mvn -P lint --quiet --batch-mode checkstyle:check - working-directory: src/com.clearblade.cloud.iot.v1 +# on: +# pull_request: +# name: samples +# jobs: +# checkstyle: +# runs-on: ubuntu-latest +# steps: +# - uses: actions/checkout@v3 +# - uses: actions/setup-java@v3 +# with: +# distribution: zulu +# java-version: 8 +# - name: Run checkstyle +# run: mvn -P lint --quiet --batch-mode checkstyle:check +# working-directory: src/com.clearblade.cloud.iot.v1 From 51e8b280390f099e195794384185d319f48408cb Mon Sep 17 00:00:00 2001 From: ronak-ingress <114172748+ronak-ingress@users.noreply.github.com> Date: Sun, 22 Oct 2023 18:57:12 +0530 Subject: [PATCH 110/151] Delete .github/workflows/approve-readme.yaml deleting this step --- .github/workflows/approve-readme.yaml | 69 --------------------------- 1 file changed, 69 deletions(-) delete mode 100644 .github/workflows/approve-readme.yaml diff --git a/.github/workflows/approve-readme.yaml b/.github/workflows/approve-readme.yaml deleted file mode 100644 index f5fc7d51..00000000 --- a/.github/workflows/approve-readme.yaml +++ /dev/null @@ -1,69 +0,0 @@ -# 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 -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# Github action job to test core java library features on -# downstream client libraries before they are released. -on: - pull_request: -name: auto-merge-readme -jobs: - approve: - runs-on: ubuntu-latest - if: github.repository_owner == 'googleapis' && github.head_ref == 'autosynth-readme' - steps: - - uses: actions/github-script@v6 - with: - github-token: ${{secrets.YOSHI_APPROVER_TOKEN}} - script: | - // only approve PRs from yoshi-automation - if (context.payload.pull_request.user.login !== "yoshi-automation") { - return; - } - - // only approve PRs like "chore: release " - if (!context.payload.pull_request.title === "chore: regenerate README") { - return; - } - - // only approve PRs with README.md and synth.metadata changes - const files = new Set( - ( - await github.paginate( - github.pulls.listFiles.endpoint({ - owner: context.repo.owner, - repo: context.repo.repo, - pull_number: context.payload.pull_request.number, - }) - ) - ).map(file => file.filename) - ); - if (files.size != 2 || !files.has("README.md") || !files.has(".github/readme/synth.metadata/synth.metadata")) { - return; - } - - // approve README regeneration PR - await github.pulls.createReview({ - owner: context.repo.owner, - repo: context.repo.repo, - body: 'Rubber stamped PR!', - pull_number: context.payload.pull_request.number, - event: 'APPROVE' - }); - - // attach automerge label - await github.issues.addLabels({ - owner: context.repo.owner, - repo: context.repo.repo, - issue_number: context.payload.pull_request.number, - labels: ['automerge'] - }); From cba1d262e33664ab852c6612af923b13026ad7af Mon Sep 17 00:00:00 2001 From: ronak-ingress <114172748+ronak-ingress@users.noreply.github.com> Date: Sun, 22 Oct 2023 18:57:26 +0530 Subject: [PATCH 111/151] Delete .github/workflows/auto-release.yaml deleting this step --- .github/workflows/auto-release.yaml | 103 ---------------------------- 1 file changed, 103 deletions(-) delete mode 100644 .github/workflows/auto-release.yaml diff --git a/.github/workflows/auto-release.yaml b/.github/workflows/auto-release.yaml deleted file mode 100644 index 7a106d00..00000000 --- a/.github/workflows/auto-release.yaml +++ /dev/null @@ -1,103 +0,0 @@ -# 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 -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# Github action job to test core java library features on -# downstream client libraries before they are released. -on: - pull_request: -name: auto-release -jobs: - approve: - runs-on: ubuntu-latest - if: contains(github.head_ref, 'release-please') - steps: - - uses: actions/github-script@v6 - with: - github-token: ${{secrets.YOSHI_APPROVER_TOKEN}} - debug: true - script: | - // only approve PRs from release-please[bot] - if (context.payload.pull_request.user.login !== "release-please[bot]") { - return; - } - - // only approve PRs like "chore(main): release " - if ( !context.payload.pull_request.title.startsWith("chore(main): release") ) { - return; - } - - // only approve PRs with pom.xml and versions.txt changes - const filesPromise = github.rest.pulls.listFiles.endpoint({ - owner: context.repo.owner, - repo: context.repo.repo, - pull_number: context.payload.pull_request.number, - }); - const changed_files = await github.paginate(filesPromise) - - if ( changed_files.length < 1 ) { - console.log( "Not proceeding since PR is empty!" ) - return; - } - - if ( !changed_files.some(v => v.filename.includes("pom")) || !changed_files.some(v => v.filename.includes("versions.txt")) ) { - console.log( "PR file changes do not have pom.xml or versions.txt -- something is wrong. PTAL!" ) - return; - } - - // trigger auto-release when - // 1) it is a SNAPSHOT release (auto-generated post regular release) - // 2) there are dependency updates only - // 3) there are no open dependency update PRs in this repo (to avoid multiple releases) - if ( - context.payload.pull_request.body.includes("Fix") || - context.payload.pull_request.body.includes("Build") || - context.payload.pull_request.body.includes("Documentation") || - context.payload.pull_request.body.includes("BREAKING CHANGES") || - context.payload.pull_request.body.includes("Features") - ) { - console.log( "Not auto-releasing since it is not a dependency-update-only release." ); - return; - } - - const promise = github.rest.pulls.list.endpoint({ - owner: context.repo.owner, - repo: context.repo.repo, - state: 'open' - }); - const open_pulls = await github.paginate(promise) - - if ( open_pulls.length > 1 && !context.payload.pull_request.title.includes("SNAPSHOT") ) { - for ( const pull of open_pulls ) { - if ( pull.title.startsWith("deps: update dependency") ) { - console.log( "Not auto-releasing yet since there are dependency update PRs open in this repo." ); - return; - } - } - } - - // approve release PR - await github.rest.pulls.createReview({ - owner: context.repo.owner, - repo: context.repo.repo, - body: 'Rubber stamped release!', - pull_number: context.payload.pull_request.number, - event: 'APPROVE' - }); - - // attach kokoro:force-run and automerge labels - await github.rest.issues.addLabels({ - owner: context.repo.owner, - repo: context.repo.repo, - issue_number: context.payload.pull_request.number, - labels: ['kokoro:force-run', 'automerge'] - }); From 6455b77be0e62efeb6eea5a9a18b71cd9f2bcfaa Mon Sep 17 00:00:00 2001 From: ronak-ingress <114172748+ronak-ingress@users.noreply.github.com> Date: Sun, 22 Oct 2023 18:57:59 +0530 Subject: [PATCH 112/151] Delete .github/workflows/samples.yaml deleting this step --- .github/workflows/samples.yaml | 30 ------------------------------ 1 file changed, 30 deletions(-) delete mode 100644 .github/workflows/samples.yaml diff --git a/.github/workflows/samples.yaml b/.github/workflows/samples.yaml deleted file mode 100644 index a107c16f..00000000 --- a/.github/workflows/samples.yaml +++ /dev/null @@ -1,30 +0,0 @@ -# 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 -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# Github action job to test core java library features on -# downstream client libraries before they are released. -# on: -# pull_request: -# name: samples -# jobs: -# checkstyle: -# runs-on: ubuntu-latest -# steps: -# - uses: actions/checkout@v3 -# - uses: actions/setup-java@v3 -# with: -# distribution: zulu -# java-version: 8 -# - name: Run checkstyle -# run: mvn -P lint --quiet --batch-mode checkstyle:check -# working-directory: src/com.clearblade.cloud.iot.v1 From 40acae22ac4b8d03fcbdd3ac8599f53a3e1e0851 Mon Sep 17 00:00:00 2001 From: ronak-ingress Date: Sun, 22 Oct 2023 18:59:25 +0530 Subject: [PATCH 113/151] - Converted URL string to URLEncoded to support % in device name. - Added env variable for testing. - Added Github yml file. --- .../clearblade/cloud/iot/v1/test/DeviceManagerClientTest.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/clearblade-cloud-iot/src/test/com/clearblade/cloud/iot/v1/test/DeviceManagerClientTest.java b/clearblade-cloud-iot/src/test/com/clearblade/cloud/iot/v1/test/DeviceManagerClientTest.java index 07758501..07669d80 100644 --- a/clearblade-cloud-iot/src/test/com/clearblade/cloud/iot/v1/test/DeviceManagerClientTest.java +++ b/clearblade-cloud-iot/src/test/com/clearblade/cloud/iot/v1/test/DeviceManagerClientTest.java @@ -76,7 +76,7 @@ public class DeviceManagerClientTest { private final String project = System.getenv("PROJECT_ID"); private final String location = System.getenv("REGION"); private final String registryId = System.getenv("REGISTRY"); - private final String failedRegistryId = System.getenv("FAIL_REGISTRY"); + private final String failedRegistryId = System.getenv("FAILED_REGISTRY"); private final String deviceId = System.getenv("DEVICE"); private final String gatewayId = System.getenv("GATEWAY_ID"); private final String numDeviceId = System.getenv("NUM_DEVICE_ID"); From d4aefcd244d70a940d26a20123725a20e8303ca6 Mon Sep 17 00:00:00 2001 From: ronak-ingress <114172748+ronak-ingress@users.noreply.github.com> Date: Sun, 22 Oct 2023 19:09:26 +0530 Subject: [PATCH 114/151] Update ci.yaml added - name: Run tests run: mvn test --- .github/workflows/ci.yaml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 5eabbd94..58fe39cb 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -33,6 +33,8 @@ jobs: distribution: zulu java-version: ${{matrix.java}} - run: java -version + - name: Run tests + run: mvn test # - run: .kokoro/build.sh env: JOB_TYPE: test From 8db70d82d5ff8d66d75d6cb6b1ab1cb06416680c Mon Sep 17 00:00:00 2001 From: ronak-ingress Date: Sun, 22 Oct 2023 19:10:24 +0530 Subject: [PATCH 115/151] - Converted URL string to URLEncoded to support % in device name. - Added env variable for testing. - Added Github yml file. --- .../clearblade/cloud/iot/v1/test/DeviceManagerClientTest.java | 1 - 1 file changed, 1 deletion(-) diff --git a/clearblade-cloud-iot/src/test/com/clearblade/cloud/iot/v1/test/DeviceManagerClientTest.java b/clearblade-cloud-iot/src/test/com/clearblade/cloud/iot/v1/test/DeviceManagerClientTest.java index 07669d80..539c2307 100644 --- a/clearblade-cloud-iot/src/test/com/clearblade/cloud/iot/v1/test/DeviceManagerClientTest.java +++ b/clearblade-cloud-iot/src/test/com/clearblade/cloud/iot/v1/test/DeviceManagerClientTest.java @@ -314,7 +314,6 @@ public void testDeleteDeviceRegistry() { .getRegistryFullName()) .build(); client.deleteDeviceRegistry(request); - } } From dd4b358afe5fe192369d108a6bb6532e5cdcb6ca Mon Sep 17 00:00:00 2001 From: ronak-ingress <114172748+ronak-ingress@users.noreply.github.com> Date: Sun, 22 Oct 2023 19:32:52 +0530 Subject: [PATCH 116/151] Update ci.yaml --- .github/workflows/ci.yaml | 104 +++++++++++++++++++------------------- 1 file changed, 52 insertions(+), 52 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 58fe39cb..7170ba51 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -34,58 +34,58 @@ jobs: java-version: ${{matrix.java}} - run: java -version - name: Run tests - run: mvn test + run: mvn test -Dtest=test.com.clearblade.cloud.iot.v1.test.DeviceManagerClientTest # - run: .kokoro/build.sh env: JOB_TYPE: test - windows: - runs-on: windows-latest - steps: - - name: Support longpaths - run: git config --system core.longpaths true - - uses: actions/checkout@v3 - - uses: actions/setup-java@v3 - with: - distribution: zulu - java-version: 8 - - run: java -version -# - run: .kokoro/build.bat - env: - JOB_TYPE: test - dependencies: - runs-on: ubuntu-latest - strategy: - matrix: - java: [8, 11, 17] - steps: - - uses: actions/checkout@v3 - - uses: actions/setup-java@v3 - with: - distribution: zulu - java-version: ${{matrix.java}} - - run: java -version -# - run: .kokoro/dependencies.sh - lint: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v3 - - uses: actions/setup-java@v3 - with: - distribution: zulu - java-version: 11 - - run: java -version -# - run: .kokoro/build.sh - env: - JOB_TYPE: lint - clirr: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v3 - - uses: actions/setup-java@v3 - with: - distribution: zulu - java-version: 8 - - run: java -version -# - run: .kokoro/build.sh - env: - JOB_TYPE: clirr + # windows: + # runs-on: windows-latest + # steps: + # - name: Support longpaths + # run: git config --system core.longpaths true + # - uses: actions/checkout@v3 + # - uses: actions/setup-java@v3 + # with: + # distribution: zulu + # java-version: 8 + # - run: java -version + # - run: .kokoro/build.bat + # env: + # JOB_TYPE: test + # dependencies: + # runs-on: ubuntu-latest + # strategy: + # matrix: + # java: [8, 11, 17] + # steps: + # - uses: actions/checkout@v3 + # - uses: actions/setup-java@v3 + # with: + # distribution: zulu + # java-version: ${{matrix.java}} + # - run: java -version + # - run: .kokoro/dependencies.sh + # lint: + # runs-on: ubuntu-latest + # steps: + # - uses: actions/checkout@v3 + # - uses: actions/setup-java@v3 + # with: + # distribution: zulu + # java-version: 11 + # - run: java -version + # - run: .kokoro/build.sh + # env: + # JOB_TYPE: lint + # clirr: + # runs-on: ubuntu-latest + # steps: + # - uses: actions/checkout@v3 + # - uses: actions/setup-java@v3 + # with: + # distribution: zulu + # java-version: 8 + # - run: java -version + # - run: .kokoro/build.sh + # env: + # JOB_TYPE: clirr From 9d6f246c59965a5a2e3269aef960d70934d581c4 Mon Sep 17 00:00:00 2001 From: ronak-ingress Date: Sun, 22 Oct 2023 19:33:06 +0530 Subject: [PATCH 117/151] - Converted URL string to URLEncoded to support % in device name. - Added env variable for testing. - Added Github yml file. --- .../clearblade/cloud/iot/v1/test/DeviceManagerClientTest.java | 1 + 1 file changed, 1 insertion(+) diff --git a/clearblade-cloud-iot/src/test/com/clearblade/cloud/iot/v1/test/DeviceManagerClientTest.java b/clearblade-cloud-iot/src/test/com/clearblade/cloud/iot/v1/test/DeviceManagerClientTest.java index 539c2307..07669d80 100644 --- a/clearblade-cloud-iot/src/test/com/clearblade/cloud/iot/v1/test/DeviceManagerClientTest.java +++ b/clearblade-cloud-iot/src/test/com/clearblade/cloud/iot/v1/test/DeviceManagerClientTest.java @@ -314,6 +314,7 @@ public void testDeleteDeviceRegistry() { .getRegistryFullName()) .build(); client.deleteDeviceRegistry(request); + } } From 42791804e4041c8e70dbf70bab3e88050b0d8e51 Mon Sep 17 00:00:00 2001 From: ronak-ingress <114172748+ronak-ingress@users.noreply.github.com> Date: Sun, 22 Oct 2023 19:35:36 +0530 Subject: [PATCH 118/151] Update ci.yaml --- .github/workflows/ci.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 7170ba51..c1ba8dcd 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -34,7 +34,7 @@ jobs: java-version: ${{matrix.java}} - run: java -version - name: Run tests - run: mvn test -Dtest=test.com.clearblade.cloud.iot.v1.test.DeviceManagerClientTest + run: mvn -f clearblade-cloud-iot/pom.xml test -Dtest=test.com.clearblade.cloud.iot.v1.test.DeviceManagerClientTest # - run: .kokoro/build.sh env: JOB_TYPE: test From 5ab9c0ac51f3123188a7dfec40a298c7e414a53a Mon Sep 17 00:00:00 2001 From: ronak-ingress Date: Sun, 22 Oct 2023 19:35:48 +0530 Subject: [PATCH 119/151] - Converted URL string to URLEncoded to support % in device name. - Added env variable for testing. - Added Github yml file. --- .../clearblade/cloud/iot/v1/test/DeviceManagerClientTest.java | 1 - 1 file changed, 1 deletion(-) diff --git a/clearblade-cloud-iot/src/test/com/clearblade/cloud/iot/v1/test/DeviceManagerClientTest.java b/clearblade-cloud-iot/src/test/com/clearblade/cloud/iot/v1/test/DeviceManagerClientTest.java index 07669d80..539c2307 100644 --- a/clearblade-cloud-iot/src/test/com/clearblade/cloud/iot/v1/test/DeviceManagerClientTest.java +++ b/clearblade-cloud-iot/src/test/com/clearblade/cloud/iot/v1/test/DeviceManagerClientTest.java @@ -314,7 +314,6 @@ public void testDeleteDeviceRegistry() { .getRegistryFullName()) .build(); client.deleteDeviceRegistry(request); - } } From efb7610dfb1303890f71e334a32c44b1a62ab550 Mon Sep 17 00:00:00 2001 From: ronak-ingress <114172748+ronak-ingress@users.noreply.github.com> Date: Sun, 22 Oct 2023 19:40:53 +0530 Subject: [PATCH 120/151] Update ci.yaml --- .github/workflows/ci.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index c1ba8dcd..e1bcb37d 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -25,7 +25,7 @@ jobs: strategy: fail-fast: false matrix: - java: [8, 11, 17] + java: [11, 17] steps: - uses: actions/checkout@v3 - uses: actions/setup-java@v3 From 9e87a3c2a89c8e440ecb1637b8447cc138fb958c Mon Sep 17 00:00:00 2001 From: ronak-ingress Date: Sun, 22 Oct 2023 19:41:48 +0530 Subject: [PATCH 121/151] - Converted URL string to URLEncoded to support % in device name. - Added env variable for testing. - Added Github yml file. --- .../clearblade/cloud/iot/v1/test/DeviceManagerClientTest.java | 1 + 1 file changed, 1 insertion(+) diff --git a/clearblade-cloud-iot/src/test/com/clearblade/cloud/iot/v1/test/DeviceManagerClientTest.java b/clearblade-cloud-iot/src/test/com/clearblade/cloud/iot/v1/test/DeviceManagerClientTest.java index 539c2307..07669d80 100644 --- a/clearblade-cloud-iot/src/test/com/clearblade/cloud/iot/v1/test/DeviceManagerClientTest.java +++ b/clearblade-cloud-iot/src/test/com/clearblade/cloud/iot/v1/test/DeviceManagerClientTest.java @@ -314,6 +314,7 @@ public void testDeleteDeviceRegistry() { .getRegistryFullName()) .build(); client.deleteDeviceRegistry(request); + } } From 909240300a547cd14473cd72b394c810a657da00 Mon Sep 17 00:00:00 2001 From: ronak-ingress Date: Mon, 23 Oct 2023 00:47:33 +0530 Subject: [PATCH 122/151] - Converted URL string to URLEncoded to support % in device name. - Added env variable for testing. - Added Github yml file. --- .../cloud/iot/v1/test => }/DeviceManagerClientTest.java | 6 ++---- .../cloud/iot/v1/test => }/ExpectedResponseTest.java | 4 +--- 2 files changed, 3 insertions(+), 7 deletions(-) rename clearblade-cloud-iot/src/test/{com/clearblade/cloud/iot/v1/test => }/DeviceManagerClientTest.java (99%) rename clearblade-cloud-iot/src/test/{com/clearblade/cloud/iot/v1/test => }/ExpectedResponseTest.java (99%) diff --git a/clearblade-cloud-iot/src/test/com/clearblade/cloud/iot/v1/test/DeviceManagerClientTest.java b/clearblade-cloud-iot/src/test/DeviceManagerClientTest.java similarity index 99% rename from clearblade-cloud-iot/src/test/com/clearblade/cloud/iot/v1/test/DeviceManagerClientTest.java rename to clearblade-cloud-iot/src/test/DeviceManagerClientTest.java index 07669d80..8f2e9893 100644 --- a/clearblade-cloud-iot/src/test/com/clearblade/cloud/iot/v1/test/DeviceManagerClientTest.java +++ b/clearblade-cloud-iot/src/test/DeviceManagerClientTest.java @@ -27,10 +27,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - -package test.com.clearblade.cloud.iot.v1.test; - - +package test; import java.util.ArrayList; import java.util.HashMap; @@ -67,6 +64,7 @@ import com.clearblade.cloud.iot.v1.updatedeviceregistry.UpdateDeviceRegistryRequest; import com.clearblade.cloud.iot.v1.utils.ByteString; import com.clearblade.cloud.iot.v1.utils.LogLevel; +import test.ExpectedResponseTest; @TestMethodOrder(MethodOrderer.OrderAnnotation.class) public class DeviceManagerClientTest { diff --git a/clearblade-cloud-iot/src/test/com/clearblade/cloud/iot/v1/test/ExpectedResponseTest.java b/clearblade-cloud-iot/src/test/ExpectedResponseTest.java similarity index 99% rename from clearblade-cloud-iot/src/test/com/clearblade/cloud/iot/v1/test/ExpectedResponseTest.java rename to clearblade-cloud-iot/src/test/ExpectedResponseTest.java index 199fb2f2..70d36a2a 100644 --- a/clearblade-cloud-iot/src/test/com/clearblade/cloud/iot/v1/test/ExpectedResponseTest.java +++ b/clearblade-cloud-iot/src/test/ExpectedResponseTest.java @@ -27,9 +27,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - -package test.com.clearblade.cloud.iot.v1.test; - +package test; import java.util.ArrayList; import java.util.HashMap; From b0648c813cfde3499f1510ed0313fa86d0b3ae6b Mon Sep 17 00:00:00 2001 From: ronak-ingress <114172748+ronak-ingress@users.noreply.github.com> Date: Tue, 28 Nov 2023 20:34:28 +0530 Subject: [PATCH 123/151] Update ci.yaml commenting out test case execution, will find a way to execute it --- .github/workflows/ci.yaml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index e1bcb37d..9568148a 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -33,11 +33,11 @@ jobs: distribution: zulu java-version: ${{matrix.java}} - run: java -version - - name: Run tests - run: mvn -f clearblade-cloud-iot/pom.xml test -Dtest=test.com.clearblade.cloud.iot.v1.test.DeviceManagerClientTest +# - name: Run tests +# run: mvn -f clearblade-cloud-iot/pom.xml test -Dtest=test.com.clearblade.cloud.iot.v1.test.DeviceManagerClientTest # - run: .kokoro/build.sh - env: - JOB_TYPE: test +# env: +# JOB_TYPE: test # windows: # runs-on: windows-latest # steps: From 30babedeb61b6ea50e16ef1b96d111add8df1826 Mon Sep 17 00:00:00 2001 From: ronak-ingress <114172748+ronak-ingress@users.noreply.github.com> Date: Fri, 1 Dec 2023 11:17:48 +0530 Subject: [PATCH 124/151] Update DeviceManagerClientTest.java removed print statement --- clearblade-cloud-iot/src/test/DeviceManagerClientTest.java | 1 - 1 file changed, 1 deletion(-) diff --git a/clearblade-cloud-iot/src/test/DeviceManagerClientTest.java b/clearblade-cloud-iot/src/test/DeviceManagerClientTest.java index 8f2e9893..fd993d09 100644 --- a/clearblade-cloud-iot/src/test/DeviceManagerClientTest.java +++ b/clearblade-cloud-iot/src/test/DeviceManagerClientTest.java @@ -89,7 +89,6 @@ public static void setUp() { @Test @Order(1) public void testCreateRegistrySuccess() { - System.out.println("ENV VARIABLE : " + project); DeviceRegistry expectedResponse = testResponse.getResponseTest2(registryId); CreateDeviceRegistryRequest request = CreateDeviceRegistryRequest.Builder.newBuilder() .setParent(LocationName.of(project, location).toString()) From 9a6d229c91465b70541eff4a233150b2046487be Mon Sep 17 00:00:00 2001 From: mikoaro Date: Fri, 1 Dec 2023 08:38:31 -0600 Subject: [PATCH 125/151] Set version to 1.0.3 --- README.md | 2 +- clearblade-cloud-iot/CHANGELOG.md | 3 +++ clearblade-cloud-iot/pom.xml | 2 +- 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 53d044ab..1bf3e7c2 100644 --- a/README.md +++ b/README.md @@ -22,7 +22,7 @@ If you are using the Maven artifact, add the following dependency to your pom.xm io.github.clearblade clearblade-cloud-iot - 1.0.2 + 1.0.3 ``` diff --git a/clearblade-cloud-iot/CHANGELOG.md b/clearblade-cloud-iot/CHANGELOG.md index 9195b20e..63c1cbce 100644 --- a/clearblade-cloud-iot/CHANGELOG.md +++ b/clearblade-cloud-iot/CHANGELOG.md @@ -1,5 +1,8 @@ # Changelog +## 1.0.3 +- Support % in character in device Id + ## 1.0.2 - Replace URL string with URLEncoded to support % in a device name. diff --git a/clearblade-cloud-iot/pom.xml b/clearblade-cloud-iot/pom.xml index c8d46511..076eac04 100644 --- a/clearblade-cloud-iot/pom.xml +++ b/clearblade-cloud-iot/pom.xml @@ -3,7 +3,7 @@ io.github.clearblade clearblade-cloud-iot - 1.0.2 + 1.0.3 jar Java Client Library for ClearBlade IoT Core From e42927a4a671561ba5670fb0776b8d50c1c37910 Mon Sep 17 00:00:00 2001 From: jslavin-clearblade <116581763+jslavin-clearblade@users.noreply.github.com> Date: Wed, 6 Dec 2023 13:34:16 -0500 Subject: [PATCH 126/151] Update CHANGELOG.md --- clearblade-cloud-iot/CHANGELOG.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/clearblade-cloud-iot/CHANGELOG.md b/clearblade-cloud-iot/CHANGELOG.md index 63c1cbce..7cf03ff5 100644 --- a/clearblade-cloud-iot/CHANGELOG.md +++ b/clearblade-cloud-iot/CHANGELOG.md @@ -1,7 +1,7 @@ # Changelog ## 1.0.3 -- Support % in character in device Id +- Support % in character in device ID ## 1.0.2 @@ -15,7 +15,7 @@ - Updated UpdateDeviceRequest, to set name as DeviceName instead of only device_id. See below example, UpdateDeviceRequest.Builder.newBuilder().setName(**DeviceName.of(PROJECT,LOCATION,REGISTRY,DEVICE).toString()**).setDevice(device.build()) -- Removed static variables from ConfigParameters and it's dependency. +- Removed static variables from ConfigParameters and its dependency. - Updated CreateDeviceRequest.java to support parent as String instead of RegistryName. See below example, CreateDeviceRequest.Builder.newBuilder()**.setParent(RegistryName.of(PROJECT, LOCATION, REGISTRY).toString())**.setDevice(device).build(); From 2654149724ff91845ca7be350738963a65bfd082 Mon Sep 17 00:00:00 2001 From: ronak-ingress Date: Sat, 10 Feb 2024 11:51:10 +0530 Subject: [PATCH 127/151] - Added fieldMask parameter in ListDeviceRegistriesRequest - Updated fieldMask to support URL encoding. --- .../iot/v1/deviceslist/DevicesListRequest.java | 5 ++++- .../cloud/iot/v1/getdevice/GetDeviceRequest.java | 5 ++++- .../ListDeviceRegistriesRequest.java | 13 +++++++++++++ 3 files changed, 21 insertions(+), 2 deletions(-) diff --git a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/deviceslist/DevicesListRequest.java b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/deviceslist/DevicesListRequest.java index f0f48b8f..ea015b99 100644 --- a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/deviceslist/DevicesListRequest.java +++ b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/deviceslist/DevicesListRequest.java @@ -33,6 +33,9 @@ import com.clearblade.cloud.iot.v1.devicetypes.GatewayListOptions; import com.clearblade.cloud.iot.v1.registrytypes.RegistryName; +import java.net.URLEncoder; +import java.nio.charset.StandardCharsets; + public class DevicesListRequest { private String parent; @@ -133,7 +136,7 @@ public String getParamsForList() { if (this.deviceIds != null) params += "&deviceIds=" + this.deviceIds; if (this.fieldMask != null) - params += "&fieldMask=" + this.fieldMask; + params += "&fieldMask=" + URLEncoder.encode(this.fieldMask, StandardCharsets.UTF_8); if (this.pageSize > 0) params += "&pageSize=" + String.valueOf(this.pageSize); if (this.pageToken != null) diff --git a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/getdevice/GetDeviceRequest.java b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/getdevice/GetDeviceRequest.java index d42fafec..6197ee26 100644 --- a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/getdevice/GetDeviceRequest.java +++ b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/getdevice/GetDeviceRequest.java @@ -33,6 +33,9 @@ import com.clearblade.cloud.iot.v1.devicetypes.DeviceName; import com.clearblade.cloud.iot.v1.devicetypes.FieldMask; +import java.net.URLEncoder; +import java.nio.charset.StandardCharsets; + public class GetDeviceRequest { private final DeviceName name; @@ -92,7 +95,7 @@ public String toString() { String params = ""; params = "name=" + this.name.toString(); if (this.fieldMask.toString() != "") { - params += "&fieldMask=" + this.fieldMask.toString(); + params += "&fieldMask=" + URLEncoder.encode(this.fieldMask.toString(), StandardCharsets.UTF_8); } return params; } diff --git a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/listdeviceregistries/ListDeviceRegistriesRequest.java b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/listdeviceregistries/ListDeviceRegistriesRequest.java index 14b50981..f8a24a34 100644 --- a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/listdeviceregistries/ListDeviceRegistriesRequest.java +++ b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/listdeviceregistries/ListDeviceRegistriesRequest.java @@ -30,9 +30,12 @@ package com.clearblade.cloud.iot.v1.listdeviceregistries; +import com.clearblade.cloud.iot.v1.deviceslist.DevicesListRequest; import com.clearblade.cloud.iot.v1.devicetypes.DeviceName; import com.clearblade.cloud.iot.v1.registrytypes.LocationName; +import java.net.URLEncoder; +import java.nio.charset.StandardCharsets; import java.util.Locale; public class ListDeviceRegistriesRequest { @@ -40,12 +43,14 @@ public class ListDeviceRegistriesRequest { private String parent; private int pageSize = -1; private String pageToken; + private String fieldMask; private ListDeviceRegistriesRequest(Builder builder) { this.parent = builder.parent; this.pageSize = builder.pageSize; this.pageToken = builder.pageToken; + this.fieldMask = builder.fieldMask; } // Static class Builder @@ -55,6 +60,7 @@ public static class Builder { private String parent; private int pageSize; private String pageToken; + private String fieldMask; public static Builder newBuilder() { return new Builder(); @@ -79,6 +85,11 @@ public Builder setPageToken(String pageToken) { return this; } + public Builder setFieldMask(String fieldMask) { + this.fieldMask = fieldMask; + return this; + } + // build method to deal with outer class // to return outer instance public ListDeviceRegistriesRequest build() { @@ -99,6 +110,8 @@ public String toString() { public String getParamsForList() { String params = ""; params = "parent=" + this.parent; + if (this.fieldMask != null) + params += "&fieldMask=" + URLEncoder.encode(this.fieldMask, StandardCharsets.UTF_8); if (this.pageSize > 0) params += "&pageSize=" + String.valueOf(this.pageSize); if (this.pageToken != null) From 5866f10f2522ea426cae40457714b4578cfbca34 Mon Sep 17 00:00:00 2001 From: ronak-ingress Date: Sat, 10 Feb 2024 11:51:10 +0530 Subject: [PATCH 128/151] - Added fieldMask parameter in ListDeviceRegistriesRequest - Updated fieldMask to support URL encoding. --- .../iot/v1/deviceslist/DevicesListRequest.java | 5 ++++- .../cloud/iot/v1/getdevice/GetDeviceRequest.java | 5 ++++- .../ListDeviceRegistriesRequest.java | 13 +++++++++++++ 3 files changed, 21 insertions(+), 2 deletions(-) diff --git a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/deviceslist/DevicesListRequest.java b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/deviceslist/DevicesListRequest.java index f0f48b8f..ea015b99 100644 --- a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/deviceslist/DevicesListRequest.java +++ b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/deviceslist/DevicesListRequest.java @@ -33,6 +33,9 @@ import com.clearblade.cloud.iot.v1.devicetypes.GatewayListOptions; import com.clearblade.cloud.iot.v1.registrytypes.RegistryName; +import java.net.URLEncoder; +import java.nio.charset.StandardCharsets; + public class DevicesListRequest { private String parent; @@ -133,7 +136,7 @@ public String getParamsForList() { if (this.deviceIds != null) params += "&deviceIds=" + this.deviceIds; if (this.fieldMask != null) - params += "&fieldMask=" + this.fieldMask; + params += "&fieldMask=" + URLEncoder.encode(this.fieldMask, StandardCharsets.UTF_8); if (this.pageSize > 0) params += "&pageSize=" + String.valueOf(this.pageSize); if (this.pageToken != null) diff --git a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/getdevice/GetDeviceRequest.java b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/getdevice/GetDeviceRequest.java index 36e9dfd3..1cdb7bd1 100644 --- a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/getdevice/GetDeviceRequest.java +++ b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/getdevice/GetDeviceRequest.java @@ -35,6 +35,9 @@ import com.clearblade.cloud.iot.v1.exception.ApplicationException; import java.net.URLEncoder; +import java.net.URLEncoder; +import java.nio.charset.StandardCharsets; + public class GetDeviceRequest { private final DeviceName name; @@ -98,7 +101,7 @@ public String toString() { throw new ApplicationException(e); } if (this.fieldMask.toString() != "") { - params += "&fieldMask=" + this.fieldMask.toString(); + params += "&fieldMask=" + URLEncoder.encode(this.fieldMask.toString(), StandardCharsets.UTF_8); } return params; } diff --git a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/listdeviceregistries/ListDeviceRegistriesRequest.java b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/listdeviceregistries/ListDeviceRegistriesRequest.java index 14b50981..f8a24a34 100644 --- a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/listdeviceregistries/ListDeviceRegistriesRequest.java +++ b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/listdeviceregistries/ListDeviceRegistriesRequest.java @@ -30,9 +30,12 @@ package com.clearblade.cloud.iot.v1.listdeviceregistries; +import com.clearblade.cloud.iot.v1.deviceslist.DevicesListRequest; import com.clearblade.cloud.iot.v1.devicetypes.DeviceName; import com.clearblade.cloud.iot.v1.registrytypes.LocationName; +import java.net.URLEncoder; +import java.nio.charset.StandardCharsets; import java.util.Locale; public class ListDeviceRegistriesRequest { @@ -40,12 +43,14 @@ public class ListDeviceRegistriesRequest { private String parent; private int pageSize = -1; private String pageToken; + private String fieldMask; private ListDeviceRegistriesRequest(Builder builder) { this.parent = builder.parent; this.pageSize = builder.pageSize; this.pageToken = builder.pageToken; + this.fieldMask = builder.fieldMask; } // Static class Builder @@ -55,6 +60,7 @@ public static class Builder { private String parent; private int pageSize; private String pageToken; + private String fieldMask; public static Builder newBuilder() { return new Builder(); @@ -79,6 +85,11 @@ public Builder setPageToken(String pageToken) { return this; } + public Builder setFieldMask(String fieldMask) { + this.fieldMask = fieldMask; + return this; + } + // build method to deal with outer class // to return outer instance public ListDeviceRegistriesRequest build() { @@ -99,6 +110,8 @@ public String toString() { public String getParamsForList() { String params = ""; params = "parent=" + this.parent; + if (this.fieldMask != null) + params += "&fieldMask=" + URLEncoder.encode(this.fieldMask, StandardCharsets.UTF_8); if (this.pageSize > 0) params += "&pageSize=" + String.valueOf(this.pageSize); if (this.pageToken != null) From f7a7bff2655a2bcea4744122ba5be27fefee6c14 Mon Sep 17 00:00:00 2001 From: mikoaro Date: Wed, 14 Feb 2024 07:13:27 -0600 Subject: [PATCH 129/151] Set target version to 1.0.4 --- clearblade-cloud-iot/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/clearblade-cloud-iot/pom.xml b/clearblade-cloud-iot/pom.xml index 076eac04..61eff541 100644 --- a/clearblade-cloud-iot/pom.xml +++ b/clearblade-cloud-iot/pom.xml @@ -3,7 +3,7 @@ io.github.clearblade clearblade-cloud-iot - 1.0.3 + 1.0.4 jar Java Client Library for ClearBlade IoT Core From 2bb053b53f0fb5bbfb2fabeb7d255fc8c9f30bf4 Mon Sep 17 00:00:00 2001 From: mikoaro Date: Wed, 14 Feb 2024 07:14:10 -0600 Subject: [PATCH 130/151] Update version to 1.0.4 --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 1bf3e7c2..874acc30 100644 --- a/README.md +++ b/README.md @@ -22,7 +22,7 @@ If you are using the Maven artifact, add the following dependency to your pom.xm io.github.clearblade clearblade-cloud-iot - 1.0.3 + 1.0.4 ``` From 6920a35c5bbaf87dc82dd483939b018ee8601a1f Mon Sep 17 00:00:00 2001 From: mikoaro Date: Wed, 14 Feb 2024 07:14:58 -0600 Subject: [PATCH 131/151] Update CHANGELOG --- clearblade-cloud-iot/CHANGELOG.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/clearblade-cloud-iot/CHANGELOG.md b/clearblade-cloud-iot/CHANGELOG.md index 7cf03ff5..722d94d2 100644 --- a/clearblade-cloud-iot/CHANGELOG.md +++ b/clearblade-cloud-iot/CHANGELOG.md @@ -1,5 +1,9 @@ # Changelog +## 1.0.4 +- Added fieldMask parameter in ListDeviceRegistriesRequest +- Updated fieldMask to support URL encoding + ## 1.0.3 - Support % in character in device ID From c6dafa57b8cf1074808f9acb45438940c7980b54 Mon Sep 17 00:00:00 2001 From: ronak-ingress Date: Tue, 20 Feb 2024 11:13:38 +0530 Subject: [PATCH 132/151] - Added interface beyond of DeviceManagerClient --- .../cloud/iot/v1/DeviceManagerClient.java | 17 +++-- .../cloud/iot/v1/DeviceManagerInterface.java | 68 +++++++++++++++++++ 2 files changed, 76 insertions(+), 9 deletions(-) create mode 100644 clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/DeviceManagerInterface.java diff --git a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/DeviceManagerClient.java b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/DeviceManagerClient.java index 5a4c28a1..ee1e6605 100644 --- a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/DeviceManagerClient.java +++ b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/DeviceManagerClient.java @@ -61,13 +61,12 @@ import com.clearblade.cloud.iot.v1.updatedevice.UpdateDeviceRequest; import com.clearblade.cloud.iot.v1.updatedeviceregistry.UpdateDeviceRegistryRequest; -public class DeviceManagerClient { +public class DeviceManagerClient implements DeviceManagerInterface{ static Logger log = Logger.getLogger(DeviceManagerClient.class.getName()); - /** * Calling getDevice api - * + * * @param request * @return Device object * @throws IOException @@ -81,7 +80,7 @@ public Device getDevice(GetDeviceRequest request) { /** * Calling createDevice api - * + * * @param request * @return Device object * @throws IOException @@ -94,7 +93,7 @@ public Device createDevice(CreateDeviceRequest request) { /** * Calling bindDeviceToGateway api - * + * * @param request * @return * @throws IOException @@ -107,7 +106,7 @@ public BindDeviceToGatewayResponse bindDeviceToGateway(BindDeviceToGatewayReques /** * Calling unbindDeviceFromGateway api - * + * * @param request * @return * @throws IOException @@ -120,7 +119,7 @@ public UnbindDeviceFromGatewayResponse unbindDeviceFromGateway(UnbindDeviceFromG /** * Calling deleteDevice api - * + * * @param request * @throws IOException * @throws ApplicationException @@ -132,7 +131,7 @@ public void deleteDevice(DeleteDeviceRequest request) { /** * Calling updateDevice api - * + * * @param request * @return Device object */ @@ -172,7 +171,7 @@ public ListDeviceConfigVersionsResponse listDeviceConfigVersions(ListDeviceConfi // Registry Apis /** * Calling getDeviceRegistry api - * + * * @param request * @return DeviceRegistry object * @throws IOException diff --git a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/DeviceManagerInterface.java b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/DeviceManagerInterface.java new file mode 100644 index 00000000..b359aec2 --- /dev/null +++ b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/DeviceManagerInterface.java @@ -0,0 +1,68 @@ +package com.clearblade.cloud.iot.v1; + +import com.clearblade.cloud.iot.v1.binddevicetogateway.BindDeviceToGatewayRequest; +import com.clearblade.cloud.iot.v1.binddevicetogateway.BindDeviceToGatewayResponse; +import com.clearblade.cloud.iot.v1.createdevice.CreateDeviceRequest; +import com.clearblade.cloud.iot.v1.createdeviceregistry.CreateDeviceRegistryRequest; +import com.clearblade.cloud.iot.v1.deletedevice.DeleteDeviceRequest; +import com.clearblade.cloud.iot.v1.deletedeviceregistry.DeleteDeviceRegistryRequest; +import com.clearblade.cloud.iot.v1.deviceslist.DevicesListRequest; +import com.clearblade.cloud.iot.v1.deviceslist.DevicesListResponse; +import com.clearblade.cloud.iot.v1.devicestateslist.ListDeviceStatesRequest; +import com.clearblade.cloud.iot.v1.devicestateslist.ListDeviceStatesResponse; +import com.clearblade.cloud.iot.v1.devicetypes.Device; +import com.clearblade.cloud.iot.v1.devicetypes.DeviceConfig; +import com.clearblade.cloud.iot.v1.getdevice.GetDeviceRequest; +import com.clearblade.cloud.iot.v1.getdeviceregistry.GetDeviceRegistryRequest; +import com.clearblade.cloud.iot.v1.listdeviceconfigversions.ListDeviceConfigVersionsRequest; +import com.clearblade.cloud.iot.v1.listdeviceconfigversions.ListDeviceConfigVersionsResponse; +import com.clearblade.cloud.iot.v1.listdeviceregistries.ListDeviceRegistriesRequest; +import com.clearblade.cloud.iot.v1.listdeviceregistries.ListDeviceRegistriesResponse; +import com.clearblade.cloud.iot.v1.modifycloudtodeviceconfig.ModifyCloudToDeviceConfigRequest; +import com.clearblade.cloud.iot.v1.registrytypes.DeviceRegistry; +import com.clearblade.cloud.iot.v1.sendcommandtodevice.SendCommandToDeviceRequest; +import com.clearblade.cloud.iot.v1.sendcommandtodevice.SendCommandToDeviceResponse; +import com.clearblade.cloud.iot.v1.unbinddevicefromgateway.UnbindDeviceFromGatewayRequest; +import com.clearblade.cloud.iot.v1.unbinddevicefromgateway.UnbindDeviceFromGatewayResponse; +import com.clearblade.cloud.iot.v1.updatedevice.UpdateDeviceRequest; +import com.clearblade.cloud.iot.v1.updatedeviceregistry.UpdateDeviceRegistryRequest; + + +/** + * Manager interface for device management actions. + */ +public interface DeviceManagerInterface { + + Device getDevice(GetDeviceRequest request); + + Device createDevice(CreateDeviceRequest request); + + BindDeviceToGatewayResponse bindDeviceToGateway(BindDeviceToGatewayRequest request); + + UnbindDeviceFromGatewayResponse unbindDeviceFromGateway(UnbindDeviceFromGatewayRequest request); + + void deleteDevice(DeleteDeviceRequest request); + + Device updateDevice(UpdateDeviceRequest request); + + SendCommandToDeviceResponse sendCommandToDevice(SendCommandToDeviceRequest request); + + DevicesListResponse listDevices(DevicesListRequest request); + + DeviceConfig modifyCloudToDeviceConfig(ModifyCloudToDeviceConfigRequest request); + + ListDeviceStatesResponse listDeviceStates(ListDeviceStatesRequest request); + + ListDeviceConfigVersionsResponse listDeviceConfigVersions( + ListDeviceConfigVersionsRequest request); + + DeviceRegistry getDeviceRegistry(GetDeviceRegistryRequest request); + + DeviceRegistry createDeviceRegistry(CreateDeviceRegistryRequest request); + + DeviceRegistry updateDeviceRegistry(UpdateDeviceRegistryRequest request); + + void deleteDeviceRegistry(DeleteDeviceRegistryRequest request); + + ListDeviceRegistriesResponse listDeviceRegistries(ListDeviceRegistriesRequest request); +} \ No newline at end of file From 871cfabfe3d91ff987cdc386a021679ada75de53 Mon Sep 17 00:00:00 2001 From: mikoaro Date: Wed, 21 Feb 2024 03:10:04 -0500 Subject: [PATCH 133/151] Update README --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 874acc30..5a3fe585 100644 --- a/README.md +++ b/README.md @@ -22,7 +22,7 @@ If you are using the Maven artifact, add the following dependency to your pom.xm io.github.clearblade clearblade-cloud-iot - 1.0.4 + 1.0.5 ``` From 36489c14cb46efcfd86b3ed00fc5005b62c5b9f4 Mon Sep 17 00:00:00 2001 From: mikoaro Date: Wed, 21 Feb 2024 03:10:28 -0500 Subject: [PATCH 134/151] Update CHANGELOG --- clearblade-cloud-iot/CHANGELOG.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/clearblade-cloud-iot/CHANGELOG.md b/clearblade-cloud-iot/CHANGELOG.md index 722d94d2..355cc875 100644 --- a/clearblade-cloud-iot/CHANGELOG.md +++ b/clearblade-cloud-iot/CHANGELOG.md @@ -1,5 +1,8 @@ # Changelog +## 1.0.5 +- Added interface for DeviceManagerClient + ## 1.0.4 - Added fieldMask parameter in ListDeviceRegistriesRequest - Updated fieldMask to support URL encoding From 10a22b588047870a89d3d09d1cfb3e83821f11ee Mon Sep 17 00:00:00 2001 From: mikoaro Date: Wed, 21 Feb 2024 03:11:14 -0500 Subject: [PATCH 135/151] Set target to 1.0.5 --- clearblade-cloud-iot/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/clearblade-cloud-iot/pom.xml b/clearblade-cloud-iot/pom.xml index 61eff541..981ad788 100644 --- a/clearblade-cloud-iot/pom.xml +++ b/clearblade-cloud-iot/pom.xml @@ -3,7 +3,7 @@ io.github.clearblade clearblade-cloud-iot - 1.0.4 + 1.0.5 jar Java Client Library for ClearBlade IoT Core From 876a132cfb550c9d17f41734954eb5ebaf907377 Mon Sep 17 00:00:00 2001 From: ronak-ingress Date: Tue, 16 Jul 2024 23:39:35 +0530 Subject: [PATCH 136/151] - Added env variables to support to be cached. --- .../src/com/clearblade/cloud/iot/v1/utils/AuthParams.java | 6 ++++++ .../src/com/clearblade/cloud/iot/v1/utils/Constants.java | 3 +++ 2 files changed, 9 insertions(+) diff --git a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/utils/AuthParams.java b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/utils/AuthParams.java index 80d02654..ffb9cc36 100644 --- a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/utils/AuthParams.java +++ b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/utils/AuthParams.java @@ -50,6 +50,7 @@ import com.clearblade.cloud.iot.v1.exception.ApplicationException; import org.json.simple.parser.ParseException; +import org.junit.platform.commons.util.StringUtils; public class AuthParams { static Logger log = Logger.getLogger(AuthParams.class.getName()); @@ -146,6 +147,11 @@ public void setRegistryCredentials(String project, String registry, String locat apiBaseURL = responseJSONObject.get(Constants.API_BASE_URL).toString(); } return; + } else if(StringUtils.isNotBlank(System.getenv(Constants.REGISTRY_URL)) && StringUtils.isNotBlank(System.getenv(Constants.REGISTRY_URL)) && StringUtils.isNotBlank(System.getenv(Constants.REGISTRY_URL))) { + apiBaseURL = System.getenv(Constants.REGISTRY_URL); + userSystemKey = System.getenv(Constants.REGISTRY_SYSKEY); + userToken = System.getenv(Constants.REGISTRY_TOKEN); + return; } try { setAdminCredentials(); diff --git a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/utils/Constants.java b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/utils/Constants.java index 56c1caaa..95999cb1 100644 --- a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/utils/Constants.java +++ b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/utils/Constants.java @@ -41,6 +41,9 @@ private Constants() { public static final String AUTH_REGION = "CLEARBLADE_REGION"; public static final String BINARYDATA = "BINARYDATA_AND_TIME_GOOGLE_FORMAT"; + public static final String REGISTRY_URL = "REGISTRY_URL"; + public static final String REGISTRY_SYSKEY = "REGISTRY_SYSKEY"; + public static final String REGISTRY_TOKEN = "REGISTRY_TOKEN"; public static final String ADMIN_SYSTEM_KEY = "systemKey"; public static final String ADMIN_TOKEN = "token"; public static final String BASE_URL = "url"; From 8f59fa1bad664821df5121313aabb085f5aae8ca Mon Sep 17 00:00:00 2001 From: ronak-ingress Date: Tue, 16 Jul 2024 23:43:56 +0530 Subject: [PATCH 137/151] - Added env variables to support to be cached. --- .../src/com/clearblade/cloud/iot/v1/utils/AuthParams.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/utils/AuthParams.java b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/utils/AuthParams.java index ffb9cc36..afa6f335 100644 --- a/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/utils/AuthParams.java +++ b/clearblade-cloud-iot/src/com/clearblade/cloud/iot/v1/utils/AuthParams.java @@ -147,7 +147,7 @@ public void setRegistryCredentials(String project, String registry, String locat apiBaseURL = responseJSONObject.get(Constants.API_BASE_URL).toString(); } return; - } else if(StringUtils.isNotBlank(System.getenv(Constants.REGISTRY_URL)) && StringUtils.isNotBlank(System.getenv(Constants.REGISTRY_URL)) && StringUtils.isNotBlank(System.getenv(Constants.REGISTRY_URL))) { + } else if(StringUtils.isNotBlank(System.getenv(Constants.REGISTRY_URL)) && StringUtils.isNotBlank(System.getenv(Constants.REGISTRY_SYSKEY)) && StringUtils.isNotBlank(System.getenv(Constants.REGISTRY_TOKEN))) { apiBaseURL = System.getenv(Constants.REGISTRY_URL); userSystemKey = System.getenv(Constants.REGISTRY_SYSKEY); userToken = System.getenv(Constants.REGISTRY_TOKEN); From 48778b9c28799332ad0379472a3cda6806449d64 Mon Sep 17 00:00:00 2001 From: ronak-ingress Date: Wed, 17 Jul 2024 00:33:53 +0530 Subject: [PATCH 138/151] - Added env variables to support to be cached. --- clearblade-cloud-iot/CHANGELOG.md | 3 +++ clearblade-cloud-iot/pom.xml | 2 +- clearblade-cloud-iot/samples/README.md | 12 +++++++++++- 3 files changed, 15 insertions(+), 2 deletions(-) diff --git a/clearblade-cloud-iot/CHANGELOG.md b/clearblade-cloud-iot/CHANGELOG.md index 722d94d2..b9c2cabc 100644 --- a/clearblade-cloud-iot/CHANGELOG.md +++ b/clearblade-cloud-iot/CHANGELOG.md @@ -1,5 +1,8 @@ # Changelog +## 1.0.5 +- Added environment variables to improve performance as the REST call can be prevented by passing the API keys as environment variables. + ## 1.0.4 - Added fieldMask parameter in ListDeviceRegistriesRequest - Updated fieldMask to support URL encoding diff --git a/clearblade-cloud-iot/pom.xml b/clearblade-cloud-iot/pom.xml index 61eff541..981ad788 100644 --- a/clearblade-cloud-iot/pom.xml +++ b/clearblade-cloud-iot/pom.xml @@ -3,7 +3,7 @@ io.github.clearblade clearblade-cloud-iot - 1.0.4 + 1.0.5 jar Java Client Library for ClearBlade IoT Core diff --git a/clearblade-cloud-iot/samples/README.md b/clearblade-cloud-iot/samples/README.md index 3844b1d4..c99ef69b 100644 --- a/clearblade-cloud-iot/samples/README.md +++ b/clearblade-cloud-iot/samples/README.md @@ -11,7 +11,7 @@ 3. Use the following to set your environment variables keys: ``` - export CLEARBLADE_CONFIGURATION=/path/to/file.json + export CLEARBLADE_CONFIGURATION=/path/to/configuration_file.json ``` @@ -21,3 +21,13 @@ export CLEARBLADE_REGISTRY=[your-registry] export CLEARBLADE_REGION=[your-region] ``` + +## Note about performance: + +By default, calls to some SDK functions cause a REST request to be sent to acquire the registry API keys found on the IoTCore UI Registry Details page. Those keys are cached for subsequent operations to improve performance. However, these caches do not persist if the application is stopped and restarted, as would be the case with typical serverless functions (e.g., Google Cloud Functions, AWS Lambda, etc.). To improve those functions' performance, the REST call can be prevented by passing the API keys as environment variables: + + ``` + REGISTRY_URL: string + REGISTRY_SYSKEY: string + REGISTRY_TOKEN: string + ``` From f2c65bae05560092c5ed14e5a11a07e89ee590d7 Mon Sep 17 00:00:00 2001 From: ronak-ingress Date: Wed, 17 Jul 2024 00:36:33 +0530 Subject: [PATCH 139/151] - Added env variables to support to be cached. --- clearblade-cloud-iot/CHANGELOG.md | 5 ++++- clearblade-cloud-iot/pom.xml | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/clearblade-cloud-iot/CHANGELOG.md b/clearblade-cloud-iot/CHANGELOG.md index b9c2cabc..44822973 100644 --- a/clearblade-cloud-iot/CHANGELOG.md +++ b/clearblade-cloud-iot/CHANGELOG.md @@ -1,8 +1,11 @@ # Changelog -## 1.0.5 +## 1.0.6 - Added environment variables to improve performance as the REST call can be prevented by passing the API keys as environment variables. +## 1.0.5 +- Added interface for DeviceManagerClient + ## 1.0.4 - Added fieldMask parameter in ListDeviceRegistriesRequest - Updated fieldMask to support URL encoding diff --git a/clearblade-cloud-iot/pom.xml b/clearblade-cloud-iot/pom.xml index 981ad788..8c757e4c 100644 --- a/clearblade-cloud-iot/pom.xml +++ b/clearblade-cloud-iot/pom.xml @@ -3,7 +3,7 @@ io.github.clearblade clearblade-cloud-iot - 1.0.5 + 1.0.6 jar Java Client Library for ClearBlade IoT Core From 7f43048382c2305d4868f3ac8674faabe9631544 Mon Sep 17 00:00:00 2001 From: ronak-ingress Date: Sun, 22 Jun 2025 18:49:20 +0530 Subject: [PATCH 140/151] - updated pom reference to maven central --- clearblade-cloud-iot/pom.xml | 29 +++++++++-------------------- 1 file changed, 9 insertions(+), 20 deletions(-) diff --git a/clearblade-cloud-iot/pom.xml b/clearblade-cloud-iot/pom.xml index 8c757e4c..91153976 100644 --- a/clearblade-cloud-iot/pom.xml +++ b/clearblade-cloud-iot/pom.xml @@ -32,17 +32,6 @@ https://github.com/ClearBlade/java-iot - - - ossrh - https://s01.oss.sonatype.org/content/repositories/snapshots - - - ossrh - https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/ - - - java8-doclint-disabled @@ -68,15 +57,15 @@ - org.sonatype.plugins - nexus-staging-maven-plugin - 1.6.13 - true - - ossrh - https://s01.oss.sonatype.org/ - true - + org.sonatype.central + central-publishing-maven-plugin + 0.7.0 + true + + central + true + published + org.codehaus.mojo From 28c03f8252f4a1bd662e8d3de452279416d4a98d Mon Sep 17 00:00:00 2001 From: ronak-ingress Date: Sun, 22 Jun 2025 18:53:03 +0530 Subject: [PATCH 141/151] - updated pom reference to maven central --- clearblade-cloud-iot/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/clearblade-cloud-iot/pom.xml b/clearblade-cloud-iot/pom.xml index 91153976..d0c0928e 100644 --- a/clearblade-cloud-iot/pom.xml +++ b/clearblade-cloud-iot/pom.xml @@ -3,7 +3,7 @@ io.github.clearblade clearblade-cloud-iot - 1.0.6 + 1.0.7 jar Java Client Library for ClearBlade IoT Core From 42d4adad886f5c60b2b698906cad466374ea4b2d Mon Sep 17 00:00:00 2001 From: ronak-ingress <114172748+ronak-ingress@users.noreply.github.com> Date: Sun, 22 Jun 2025 18:53:29 +0530 Subject: [PATCH 142/151] updated github action --- .github/workflows/ci.yaml | 97 +++++++++++---------------------------- 1 file changed, 27 insertions(+), 70 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 9568148a..bbccfcb8 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -13,79 +13,36 @@ # limitations under the License. # Github action job to test core java library features on # downstream client libraries before they are released. +name: ci + on: push: - branches: - - main - pull_request: -name: ci + tags: + - 'v*' + jobs: - units: + publish: runs-on: ubuntu-latest - strategy: - fail-fast: false - matrix: - java: [11, 17] steps: - - uses: actions/checkout@v3 - - uses: actions/setup-java@v3 + - uses: actions/checkout@v2 + + - id: install-secret-key + name: Install GPG secret key + run: | + cat <(echo -e "${{ secrets.OSSRH_GPG_SECRET_KEY }}") | gpg --batch --import + gpg --list-secret-keys --keyid-format LONG + + - name: Set up Maven Central Repository + uses: actions/setup-java@v2 with: - distribution: zulu - java-version: ${{matrix.java}} - - run: java -version -# - name: Run tests -# run: mvn -f clearblade-cloud-iot/pom.xml test -Dtest=test.com.clearblade.cloud.iot.v1.test.DeviceManagerClientTest -# - run: .kokoro/build.sh -# env: -# JOB_TYPE: test - # windows: - # runs-on: windows-latest - # steps: - # - name: Support longpaths - # run: git config --system core.longpaths true - # - uses: actions/checkout@v3 - # - uses: actions/setup-java@v3 - # with: - # distribution: zulu - # java-version: 8 - # - run: java -version - # - run: .kokoro/build.bat - # env: - # JOB_TYPE: test - # dependencies: - # runs-on: ubuntu-latest - # strategy: - # matrix: - # java: [8, 11, 17] - # steps: - # - uses: actions/checkout@v3 - # - uses: actions/setup-java@v3 - # with: - # distribution: zulu - # java-version: ${{matrix.java}} - # - run: java -version - # - run: .kokoro/dependencies.sh - # lint: - # runs-on: ubuntu-latest - # steps: - # - uses: actions/checkout@v3 - # - uses: actions/setup-java@v3 - # with: - # distribution: zulu - # java-version: 11 - # - run: java -version - # - run: .kokoro/build.sh - # env: - # JOB_TYPE: lint - # clirr: - # runs-on: ubuntu-latest - # steps: - # - uses: actions/checkout@v3 - # - uses: actions/setup-java@v3 - # with: - # distribution: zulu - # java-version: 8 - # - run: java -version - # - run: .kokoro/build.sh - # env: - # JOB_TYPE: clirr + java-version: '20' + distribution: 'adopt' + server-id: central + server-username: MAVEN_USERNAME + server-password: MAVEN_PASSWORD + + - name: Publish package + run: mvn --batch-mode -Dgpg.passphrase= deploy -DskipTests + env: + MAVEN_USERNAME: ${{ secrets.MAVEN_USERNAME }} + MAVEN_PASSWORD: ${{ secrets.MAVEN_SECRET }} From fd05f93edb38e290e86c4c22f9a031ba3cc0b1b9 Mon Sep 17 00:00:00 2001 From: ronak-ingress <114172748+ronak-ingress@users.noreply.github.com> Date: Sun, 22 Jun 2025 19:02:45 +0530 Subject: [PATCH 143/151] update github action --- .github/workflows/ci.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index bbccfcb8..ff49905f 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -18,7 +18,7 @@ name: ci on: push: tags: - - 'v*' + - '[0-9]+.[0-9]+.[0-9]+' jobs: publish: From 9974f4025dca1682f74163c4a2159e04882797f7 Mon Sep 17 00:00:00 2001 From: ronak-ingress <114172748+ronak-ingress@users.noreply.github.com> Date: Sun, 22 Jun 2025 19:22:15 +0530 Subject: [PATCH 144/151] updated github action --- .github/workflows/ci.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index ff49905f..d7844343 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -29,7 +29,7 @@ jobs: - id: install-secret-key name: Install GPG secret key run: | - cat <(echo -e "${{ secrets.OSSRH_GPG_SECRET_KEY }}") | gpg --batch --import + cat <(echo -e "${{ secrets.GPG_SECRET_KEY }}") | gpg --batch --import gpg --list-secret-keys --keyid-format LONG - name: Set up Maven Central Repository From 86e85f169b9dc2869918269c30a93a351a281378 Mon Sep 17 00:00:00 2001 From: ronak-ingress <114172748+ronak-ingress@users.noreply.github.com> Date: Sun, 22 Jun 2025 19:27:18 +0530 Subject: [PATCH 145/151] updated github action --- .github/workflows/ci.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index d7844343..250de0cc 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -43,6 +43,7 @@ jobs: - name: Publish package run: mvn --batch-mode -Dgpg.passphrase= deploy -DskipTests + working-directory: clearblade-cloud-iot env: MAVEN_USERNAME: ${{ secrets.MAVEN_USERNAME }} MAVEN_PASSWORD: ${{ secrets.MAVEN_SECRET }} From 77905f3610fdb0ee9f024b9fe6668855aff259c2 Mon Sep 17 00:00:00 2001 From: ronak-ingress <114172748+ronak-ingress@users.noreply.github.com> Date: Sun, 22 Jun 2025 19:32:10 +0530 Subject: [PATCH 146/151] updated github action --- .github/workflows/ci.yaml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 250de0cc..55f4e571 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -26,11 +26,11 @@ jobs: steps: - uses: actions/checkout@v2 - - id: install-secret-key - name: Install GPG secret key - run: | - cat <(echo -e "${{ secrets.GPG_SECRET_KEY }}") | gpg --batch --import - gpg --list-secret-keys --keyid-format LONG + - name: Import GPG key + uses: crazy-max/ghaction-import-gpg@v5 + with: + gpg_private_key: ${{ secrets.GPG_SECRET_KEY }} + passphrase: ${{ secrets.GPG_PASSPHRASE }} - name: Set up Maven Central Repository uses: actions/setup-java@v2 @@ -42,7 +42,7 @@ jobs: server-password: MAVEN_PASSWORD - name: Publish package - run: mvn --batch-mode -Dgpg.passphrase= deploy -DskipTests + run: mvn --batch-mode -Dgpg.passphrase=${{ secrets.GPG_PASSPHRASE }} deploy -DskipTests working-directory: clearblade-cloud-iot env: MAVEN_USERNAME: ${{ secrets.MAVEN_USERNAME }} From 270d0c29c090fe449c834bfd40e60663ba8c260e Mon Sep 17 00:00:00 2001 From: ronak-ingress <114172748+ronak-ingress@users.noreply.github.com> Date: Tue, 1 Jul 2025 22:10:35 +0530 Subject: [PATCH 147/151] update mvn command --- .github/workflows/ci.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 55f4e571..ef070ada 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -42,7 +42,7 @@ jobs: server-password: MAVEN_PASSWORD - name: Publish package - run: mvn --batch-mode -Dgpg.passphrase=${{ secrets.GPG_PASSPHRASE }} deploy -DskipTests + run: mvn --batch-mode -Dgpg.passphrase=${{ secrets.GPG_PASSPHRASE }} -Dgpg.keyname=${{ secrets.GPG_SECRET_KEY }} deploy -DskipTests working-directory: clearblade-cloud-iot env: MAVEN_USERNAME: ${{ secrets.MAVEN_USERNAME }} From 30a46df14fe392f44a28613e6ed054988702d68e Mon Sep 17 00:00:00 2001 From: ronak-ingress <114172748+ronak-ingress@users.noreply.github.com> Date: Tue, 1 Jul 2025 22:18:04 +0530 Subject: [PATCH 148/151] update mvn command --- .github/workflows/ci.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index ef070ada..20fd4b9b 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -42,7 +42,7 @@ jobs: server-password: MAVEN_PASSWORD - name: Publish package - run: mvn --batch-mode -Dgpg.passphrase=${{ secrets.GPG_PASSPHRASE }} -Dgpg.keyname=${{ secrets.GPG_SECRET_KEY }} deploy -DskipTests + run: mvn --batch-mode -Dgpg.passphrase=${{ secrets.GPG_PASSPHRASE }} -Dgpg.keyname=${{ secrets.GPG_KEY_ID }} deploy -DskipTests working-directory: clearblade-cloud-iot env: MAVEN_USERNAME: ${{ secrets.MAVEN_USERNAME }} From c0c5a990a02d8c592397fc0e00f40a50f1fdb097 Mon Sep 17 00:00:00 2001 From: ronak-ingress <114172748+ronak-ingress@users.noreply.github.com> Date: Tue, 1 Jul 2025 22:31:00 +0530 Subject: [PATCH 149/151] updating mvn command --- .github/workflows/ci.yaml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 20fd4b9b..e3e68d44 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -31,6 +31,9 @@ jobs: with: gpg_private_key: ${{ secrets.GPG_SECRET_KEY }} passphrase: ${{ secrets.GPG_PASSPHRASE }} + + - name: Show GPG keys + run: gpg --list-secret-keys --keyid-format LONG - name: Set up Maven Central Repository uses: actions/setup-java@v2 @@ -42,7 +45,7 @@ jobs: server-password: MAVEN_PASSWORD - name: Publish package - run: mvn --batch-mode -Dgpg.passphrase=${{ secrets.GPG_PASSPHRASE }} -Dgpg.keyname=${{ secrets.GPG_KEY_ID }} deploy -DskipTests + run: mvn --batch-mode -Dgpg.passphrase=${{ secrets.GPG_PASSPHRASE }} -Dgpg.keyname=6A09E667F3BCC908 deploy -DskipTests working-directory: clearblade-cloud-iot env: MAVEN_USERNAME: ${{ secrets.MAVEN_USERNAME }} From cba413a757acc2fbc8b01aae6fea92f7633e1823 Mon Sep 17 00:00:00 2001 From: ronak-ingress <114172748+ronak-ingress@users.noreply.github.com> Date: Tue, 1 Jul 2025 22:34:23 +0530 Subject: [PATCH 150/151] updating mvn command --- .github/workflows/ci.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index e3e68d44..a9dbb821 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -45,7 +45,7 @@ jobs: server-password: MAVEN_PASSWORD - name: Publish package - run: mvn --batch-mode -Dgpg.passphrase=${{ secrets.GPG_PASSPHRASE }} -Dgpg.keyname=6A09E667F3BCC908 deploy -DskipTests + run: mvn --batch-mode -Dgpg.passphrase=${{ secrets.GPG_PASSPHRASE }} -Dgpg.keyname=01893BE7159F5EBD deploy -DskipTests working-directory: clearblade-cloud-iot env: MAVEN_USERNAME: ${{ secrets.MAVEN_USERNAME }} From f34cee537de18ac1c6d6c5699bea65a0cfc04d18 Mon Sep 17 00:00:00 2001 From: ronak-ingress <114172748+ronak-ingress@users.noreply.github.com> Date: Thu, 3 Jul 2025 00:40:08 +0530 Subject: [PATCH 151/151] updating mvn --- .github/workflows/ci.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index a9dbb821..2ae29898 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -45,7 +45,7 @@ jobs: server-password: MAVEN_PASSWORD - name: Publish package - run: mvn --batch-mode -Dgpg.passphrase=${{ secrets.GPG_PASSPHRASE }} -Dgpg.keyname=01893BE7159F5EBD deploy -DskipTests + run: mvn --batch-mode -Dgpg.passphrase=${{ secrets.GPG_PASSPHRASE }} -Dgpg.keyname=0F48235998CCAAB1 deploy -DskipTests working-directory: clearblade-cloud-iot env: MAVEN_USERNAME: ${{ secrets.MAVEN_USERNAME }}