26
26
27
27
/** Command line options for the Device Manager example. */
28
28
public class DeviceRegistryExampleOptions {
29
- String algorithm ;
29
+ static final Options options = new Options () ;
30
30
String projectId ;
31
31
String ecPublicKeyFile = "ec_public.pem" ;
32
32
String rsaCertificateFile = "rsa_cert.pem" ;
@@ -35,14 +35,11 @@ public class DeviceRegistryExampleOptions {
35
35
String commandData = "Specify with --data" ;
36
36
String configuration = "Specify with -configuration" ;
37
37
String deviceId ; // Default to UUID?
38
- String gatewayId ;
39
38
String pubsubTopic ;
40
- String publicKeyFile ;
41
39
String registryName ;
42
40
String member ;
43
41
String role ;
44
42
long version = 0 ;
45
- static final Options options = new Options ();
46
43
47
44
/** Construct an DeviceRegistryExampleOptions class from command line flags. */
48
45
public static DeviceRegistryExampleOptions fromFlags (String [] args ) {
@@ -54,8 +51,6 @@ public static DeviceRegistryExampleOptions fromFlags(String[] args) {
54
51
.hasArg ()
55
52
.desc (
56
53
"Command to run:"
57
- + "\n \t bind-device-to-gateway"
58
- + "\n \t create-gateway"
59
54
+ "\n \t create-iot-topic" // TODO: Descriptions or too verbose?
60
55
+ "\n \t create-rsa"
61
56
+ "\n \t create-es"
@@ -69,25 +64,15 @@ public static DeviceRegistryExampleOptions fromFlags(String[] args) {
69
64
+ "\n \t get-registry"
70
65
+ "\n \t list-devices"
71
66
+ "\n \t list-registries"
72
- + "\n \t list-gateways"
73
- + "\n \t list-devices-for-gateway"
74
67
+ "\n \t patch-device-es"
75
68
+ "\n \t patch-device-rsa"
76
69
+ "\n \t set-config"
77
70
+ "\n \t set-iam-permissions"
78
- + "\n \t send-command"
79
- + "\n \t unbind-device-from-gateway" )
71
+ + "\n \t send-command" )
80
72
.required ()
81
73
.build ());
82
74
83
75
// Optional arguments.
84
- options .addOption (
85
- Option .builder ()
86
- .type (String .class )
87
- .longOpt ("algorithm" )
88
- .hasArg ()
89
- .desc ("Algorithm used for public/private keys." )
90
- .build ());
91
76
options .addOption (
92
77
Option .builder ()
93
78
.type (String .class )
@@ -123,13 +108,6 @@ public static DeviceRegistryExampleOptions fromFlags(String[] args) {
123
108
.hasArg ()
124
109
.desc ("GCP cloud project name." )
125
110
.build ());
126
- options .addOption (
127
- Option .builder ()
128
- .type (String .class )
129
- .longOpt ("public_key_file" )
130
- .hasArg ()
131
- .desc ("Public key file used for registering devices and gateways." )
132
- .build ());
133
111
options .addOption (
134
112
Option .builder ()
135
113
.type (String .class )
@@ -144,13 +122,6 @@ public static DeviceRegistryExampleOptions fromFlags(String[] args) {
144
122
.hasArg ()
145
123
.desc ("Name for your Device." )
146
124
.build ());
147
- options .addOption (
148
- Option .builder ()
149
- .type (String .class )
150
- .longOpt ("gateway_id" )
151
- .hasArg ()
152
- .desc ("The identifier for the Gateway." )
153
- .build ());
154
125
options .addOption (
155
126
Option .builder ()
156
127
.type (String .class )
@@ -199,9 +170,6 @@ public static DeviceRegistryExampleOptions fromFlags(String[] args) {
199
170
throw new ParseException ("Invalid command, showing help." );
200
171
}
201
172
202
- if (commandLine .hasOption ("algorithm" )) {
203
- res .algorithm = commandLine .getOptionValue ("algorithm" );
204
- }
205
173
if (commandLine .hasOption ("cloud_region" )) {
206
174
res .cloudRegion = commandLine .getOptionValue ("cloud_region" );
207
175
}
@@ -211,9 +179,7 @@ public static DeviceRegistryExampleOptions fromFlags(String[] args) {
211
179
if (commandLine .hasOption ("device_id" )) {
212
180
res .deviceId = commandLine .getOptionValue ("device_id" );
213
181
}
214
- if (commandLine .hasOption ("gateway_id" )) {
215
- res .gatewayId = commandLine .getOptionValue ("gateway_id" );
216
- }
182
+
217
183
if (commandLine .hasOption ("project_id" )) {
218
184
res .projectId = commandLine .getOptionValue ("project_id" );
219
185
} else {
@@ -229,9 +195,7 @@ public static DeviceRegistryExampleOptions fromFlags(String[] args) {
229
195
} else {
230
196
// TODO: Get from environment variable
231
197
}
232
- if (commandLine .hasOption ("public_key_file" )) {
233
- res .publicKeyFile = commandLine .getOptionValue ("public_key_file" );
234
- }
198
+
235
199
if (commandLine .hasOption ("ec_public_key_file" )) {
236
200
res .ecPublicKeyFile = commandLine .getOptionValue ("ec_public_key_file" );
237
201
}
@@ -266,7 +230,8 @@ public static DeviceRegistryExampleOptions fromFlags(String[] args) {
266
230
String footer = "\n https://cloud.google.com/iot-core" ;
267
231
268
232
HelpFormatter formatter = new HelpFormatter ();
269
- formatter .printHelp ("DeviceRegistryExample" , header , options , footer , true );
233
+ formatter .printHelp (
234
+ "DeviceRegistryExample" , header , options , footer , true );
270
235
271
236
System .err .println (e .getMessage ());
272
237
return null ;
0 commit comments