@@ -10,7 +10,7 @@ PubSub topic for Cloud IoT as described in [the parent README](../README.md).
10
10
Manually install [ the provided client library] ( https://cloud.google.com/iot/resources/java/cloud-iot-core-library.jar )
11
11
for Cloud IoT Core to Maven:
12
12
13
- mvn install:install-file -Dfile=cloud-iot-core-library.jar -DgroupId=com.google .apis \
13
+ mvn install:install-file -Dfile=cloud-iot-core-library.jar -DgroupId=com.example .apis \
14
14
-DartifactId=google-api-services-cloudiot -Dversion=v1beta1-rev20170418-1.22.0-SNAPSHOT \
15
15
-Dpackaging=jar
16
16
@@ -21,23 +21,116 @@ mvn clean compile assembly:single
21
21
22
22
## Running the sample
23
23
24
- The following command summarizes the sample usage:
24
+ The following description summarizes the sample usage:
25
25
26
- mvn exec:java \
27
- -Dexec.mainClass="com.google.cloud.iot.examples.DeviceRegistryExample" \
28
- -Dexec.args="-project_id=my-project-id \
29
- -pubsub_topic=projects/my-project-id/topics/my-topic-id \
30
- -ec_public_key_file=/path/to/ec_public.pem \
31
- -rsa_certificate_file=/path/to/rsa_cert.pem"
26
+ usage: DeviceRegistryExample [--cloud_region <arg>] --command <arg>
27
+ [--ec_public_key_file <arg>] --project_id <arg> --pubsub_topic
28
+ <arg> --registry_name <arg> [--rsa_certificate_file <arg>]
29
+
30
+ Cloud IoT Core Commandline Example (Device / Registry management):
31
+
32
+ --cloud_region <arg> GCP cloud region.
33
+ --command <arg> Command to run:
34
+ create-iot-topic
35
+ create-rsa
36
+ create-es
37
+ create-unauth
38
+ create-registry
39
+ delete-device
40
+ delete-registry
41
+ get-device
42
+ get-registry
43
+ list-devices
44
+ list-registries
45
+ patch-device-es
46
+ patch-device-rsa
47
+ --ec_public_key_file <arg> Path to ES256 public key file.
48
+ --project_id <arg> GCP cloud project name.
49
+ --pubsub_topic <arg> Pub/Sub topic to create registry in.
50
+ --registry_name <arg> Name for your Device Registry.
51
+ --rsa_certificate_file <arg> Path to RS256 certificate file.
52
+
53
+ https://cloud.google.com/iot-core
32
54
33
55
For example, if your project ID is ` blue-jet-123 ` , your service account
34
56
credentials are stored in your home folder in creds.json and you have generated
35
57
your credentials using the shell script provided in the parent folder, you can
36
58
run the sample as:
37
59
38
- mvn exec:java \
39
- -Dexec.mainClass="com.google.cloud.iot.examples.DeviceRegistryExample" \
40
- -Dexec.args="-project_id=blue-jet-123 \
41
- -pubsub_topic=projects/blue-jet-123/topics/device-events \
42
- -ec_public_key_file=../ec_public.pem \
43
- -rsa_certificate_file=../rsa_cert.pem"
60
+
61
+ ## Usage Examples
62
+
63
+ Create a PubSub topic, ` hello-java ` , for the project, ` blue-jet-123 ` :
64
+
65
+ java -cp target/cloudiot-manager-demo-1.0-jar-with-dependencies.jar \
66
+ com.example.cloud.iot.examples.DeviceRegistryExample \
67
+ -project_id=blue-jet-123 -pubsub_topic=hello-java
68
+ -command=create-iot-topic
69
+
70
+ Create an ES device:
71
+
72
+ java -cp target/cloudiot-manager-demo-1.0-jar-with-dependencies.jar \
73
+ com.example.cloud.iot.examples.DeviceRegistryExample \
74
+ -project_id=blue-jet-123 -pubsub_topic=hello-java \
75
+ -registry_name=hello-java -ec_public_key_file ../ec_public.pem \
76
+ -device_id="java-device-0" -command=create-es
77
+
78
+ Create an RSA device:
79
+
80
+ java -cp target/cloudiot-manager-demo-1.0-jar-with-dependencies.jar \
81
+ com.example.cloud.iot.examples.DeviceRegistryExample \
82
+ -project_id=blue-jet-123 -pubsub_topic=hello-java \
83
+ -registry_name=hello-java -rsa_certificate_file ../rsa_cert.pem \
84
+ -device_id="java-device-1" -command=create-rsa
85
+
86
+ Create a device without authorization:
87
+
88
+ java -cp target/cloudiot-manager-demo-1.0-jar-with-dependencies.jar \
89
+ com.example.cloud.iot.examples.DeviceRegistryExample \
90
+ -project_id=blue-jet-123 -pubsub_topic=hello-java \
91
+ -registry_name=hello-java -device_id="java-device-3" \
92
+ -command=create-unauth
93
+
94
+ Create a device registry:
95
+
96
+ java -cp target/cloudiot-manager-demo-1.0-jar-with-dependencies.jar \
97
+ com.example.cloud.iot.examples.DeviceRegistryExample \
98
+ -project_id=blue-jet-123 -pubsub_topic=hello-java \
99
+ -registry_name=hello-java -command=create-registry \
100
+
101
+ Get a device registry:
102
+
103
+ java -cp target/cloudiot-manager-demo-1.0-jar-with-dependencies.jar \
104
+ com.example.cloud.iot.examples.DeviceRegistryExample \
105
+ -project_id=blue-jet-123 -pubsub_topic=hello-java \
106
+ -registry_name=hello-java -command=get-registry
107
+
108
+ List devices:
109
+
110
+ java -cp target/cloudiot-manager-demo-1.0-jar-with-dependencies.jar \
111
+ com.example.cloud.iot.examples.DeviceRegistryExample \
112
+ -project_id=blue-jet-123 -pubsub_topic=hello-java \
113
+ -registry_name=hello-java -command=list-devices
114
+
115
+ List device registries:
116
+
117
+ java -cp target/cloudiot-manager-demo-1.0-jar-with-dependencies.jar \
118
+ com.example.cloud.iot.examples.DeviceRegistryExample \
119
+ -project_id=blue-jet-123 -pubsub_topic=hello-java \
120
+ -registry_name=hello-java -command=list-registries
121
+
122
+ Patch a device with ES:
123
+
124
+ java -cp target/cloudiot-manager-demo-1.0-jar-with-dependencies.jar \
125
+ com.example.cloud.iot.examples.DeviceRegistryExample \
126
+ -project_id=blue-jet-123 -pubsub_topic=hello-java \
127
+ -registry_name=hello-java -ec_public_key_file ../ec_public.pem \
128
+ -device_id="java-device-1" -command=patch-device-es
129
+
130
+ Patch a device with RSA:
131
+
132
+ java -cp target/cloudiot-manager-demo-1.0-jar-with-dependencies.jar \
133
+ com.example.cloud.iot.examples.DeviceRegistryExample \
134
+ -project_id=blue-jet-123 -pubsub_topic=hello-java \
135
+ -registry_name=hello-java -rsa_certificate_file ../rsa_cert.pem \
136
+ -device_id="java-device-0" -command=patch-device-rsa
0 commit comments