2626
2727/** Command line options for the Device Manager example. */
2828public class DeviceRegistryExampleOptions {
29- String algorithm ;
29+ static final Options options = new Options () ;
3030 String projectId ;
3131 String ecPublicKeyFile = "ec_public.pem" ;
3232 String rsaCertificateFile = "rsa_cert.pem" ;
@@ -35,14 +35,11 @@ public class DeviceRegistryExampleOptions {
3535 String commandData = "Specify with --data" ;
3636 String configuration = "Specify with -configuration" ;
3737 String deviceId ; // Default to UUID?
38- String gatewayId ;
3938 String pubsubTopic ;
40- String publicKeyFile ;
4139 String registryName ;
4240 String member ;
4341 String role ;
4442 long version = 0 ;
45- static final Options options = new Options ();
4643
4744 /** Construct an DeviceRegistryExampleOptions class from command line flags. */
4845 public static DeviceRegistryExampleOptions fromFlags (String [] args ) {
@@ -54,8 +51,6 @@ public static DeviceRegistryExampleOptions fromFlags(String[] args) {
5451 .hasArg ()
5552 .desc (
5653 "Command to run:"
57- + "\n \t bind-device-to-gateway"
58- + "\n \t create-gateway"
5954 + "\n \t create-iot-topic" // TODO: Descriptions or too verbose?
6055 + "\n \t create-rsa"
6156 + "\n \t create-es"
@@ -69,25 +64,15 @@ public static DeviceRegistryExampleOptions fromFlags(String[] args) {
6964 + "\n \t get-registry"
7065 + "\n \t list-devices"
7166 + "\n \t list-registries"
72- + "\n \t list-gateways"
73- + "\n \t list-devices-for-gateway"
7467 + "\n \t patch-device-es"
7568 + "\n \t patch-device-rsa"
7669 + "\n \t set-config"
7770 + "\n \t set-iam-permissions"
78- + "\n \t send-command"
79- + "\n \t unbind-device-from-gateway" )
71+ + "\n \t send-command" )
8072 .required ()
8173 .build ());
8274
8375 // 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 ());
9176 options .addOption (
9277 Option .builder ()
9378 .type (String .class )
@@ -123,13 +108,6 @@ public static DeviceRegistryExampleOptions fromFlags(String[] args) {
123108 .hasArg ()
124109 .desc ("GCP cloud project name." )
125110 .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 ());
133111 options .addOption (
134112 Option .builder ()
135113 .type (String .class )
@@ -144,13 +122,6 @@ public static DeviceRegistryExampleOptions fromFlags(String[] args) {
144122 .hasArg ()
145123 .desc ("Name for your Device." )
146124 .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 ());
154125 options .addOption (
155126 Option .builder ()
156127 .type (String .class )
@@ -199,9 +170,6 @@ public static DeviceRegistryExampleOptions fromFlags(String[] args) {
199170 throw new ParseException ("Invalid command, showing help." );
200171 }
201172
202- if (commandLine .hasOption ("algorithm" )) {
203- res .algorithm = commandLine .getOptionValue ("algorithm" );
204- }
205173 if (commandLine .hasOption ("cloud_region" )) {
206174 res .cloudRegion = commandLine .getOptionValue ("cloud_region" );
207175 }
@@ -211,9 +179,7 @@ public static DeviceRegistryExampleOptions fromFlags(String[] args) {
211179 if (commandLine .hasOption ("device_id" )) {
212180 res .deviceId = commandLine .getOptionValue ("device_id" );
213181 }
214- if (commandLine .hasOption ("gateway_id" )) {
215- res .gatewayId = commandLine .getOptionValue ("gateway_id" );
216- }
182+
217183 if (commandLine .hasOption ("project_id" )) {
218184 res .projectId = commandLine .getOptionValue ("project_id" );
219185 } else {
@@ -229,9 +195,7 @@ public static DeviceRegistryExampleOptions fromFlags(String[] args) {
229195 } else {
230196 // TODO: Get from environment variable
231197 }
232- if (commandLine .hasOption ("public_key_file" )) {
233- res .publicKeyFile = commandLine .getOptionValue ("public_key_file" );
234- }
198+
235199 if (commandLine .hasOption ("ec_public_key_file" )) {
236200 res .ecPublicKeyFile = commandLine .getOptionValue ("ec_public_key_file" );
237201 }
@@ -266,7 +230,8 @@ public static DeviceRegistryExampleOptions fromFlags(String[] args) {
266230 String footer = "\n https://cloud.google.com/iot-core" ;
267231
268232 HelpFormatter formatter = new HelpFormatter ();
269- formatter .printHelp ("DeviceRegistryExample" , header , options , footer , true );
233+ formatter .printHelp (
234+ "DeviceRegistryExample" , header , options , footer , true );
270235
271236 System .err .println (e .getMessage ());
272237 return null ;
0 commit comments