|
319 | 319 | ); |
320 | 320 | }); |
321 | 321 |
|
| 322 | +// Beta features |
| 323 | +$application->add(new Command('create-gateway')) |
| 324 | + ->addOption('project', '', InputOption::VALUE_REQUIRED, 'The Google Cloud project ID', getenv('GCLOUD_PROJECT')) |
| 325 | + ->addOption('location', '', InputOption::VALUE_REQUIRED, 'The location of your device registries', 'us-central1') |
| 326 | + ->addArgument('registry', InputArgument::REQUIRED, 'the registry ID') |
| 327 | + ->addArgument('gateway', InputArgument::REQUIRED, 'the gateway ID') |
| 328 | + ->addArgument('certificate-file', InputArgument::REQUIRED, 'Path to public key file') |
| 329 | + ->addArgument('algorithm', InputArgument::REQUIRED, 'The algorithm (RS256|ES256) used for the public key') |
| 330 | + ->setDescription('(Beta feature) Create a new gateway with the given id.') |
| 331 | + ->setCode(function ($input, $output) { |
| 332 | + create_gateway( |
| 333 | + $input->getOption('project'), |
| 334 | + $input->getOption('location'), |
| 335 | + $input->getArgument('registry'), |
| 336 | + $input->getArgument('gateway'), |
| 337 | + $input->getArgument('certificate-file'), |
| 338 | + $input->getArgument('algorithm') |
| 339 | + ); |
| 340 | + }); |
| 341 | + |
| 342 | +$application->add(new Command('delete-gateway')) |
| 343 | + ->addOption('project', '', InputOption::VALUE_REQUIRED, 'The Google Cloud project ID', getenv('GCLOUD_PROJECT')) |
| 344 | + ->addOption('location', '', InputOption::VALUE_REQUIRED, 'The location of your device registries', 'us-central1') |
| 345 | + ->addArgument('registry', InputArgument::REQUIRED, 'the registry ID') |
| 346 | + ->addArgument('gateway', InputArgument::REQUIRED, 'the gateway ID') |
| 347 | + ->setDescription('(Beta feature) Delete the gateway with the given id.') |
| 348 | + ->setCode(function ($input, $output) { |
| 349 | + delete_gateway( |
| 350 | + $input->getOption('project'), |
| 351 | + $input->getOption('location'), |
| 352 | + $input->getArgument('registry'), |
| 353 | + $input->getArgument('gateway') |
| 354 | + ); |
| 355 | + }); |
| 356 | + |
| 357 | +$application->add(new Command('list-gateways')) |
| 358 | + ->addArgument('registry', InputArgument::REQUIRED, 'the registry ID') |
| 359 | + ->addOption('project', '', InputOption::VALUE_REQUIRED, 'The Google Cloud project ID', getenv('GCLOUD_PROJECT')) |
| 360 | + ->addOption('location', '', InputOption::VALUE_REQUIRED, 'The location of your device registries', 'us-central1') |
| 361 | + ->setDescription('(Beta feature) List gateways for the given registry.') |
| 362 | + ->setCode(function ($input, $output) { |
| 363 | + list_gateways( |
| 364 | + $input->getOption('project'), |
| 365 | + $input->getOption('location'), |
| 366 | + $input->getArgument('registry') |
| 367 | + ); |
| 368 | + }); |
| 369 | + |
| 370 | +$application->add(new Command('list-devices-for-gateway')) |
| 371 | + ->addOption('project', '', InputOption::VALUE_REQUIRED, 'The Google Cloud project ID', getenv('GCLOUD_PROJECT')) |
| 372 | + ->addOption('location', '', InputOption::VALUE_REQUIRED, 'The location of your device registries', 'us-central1') |
| 373 | + ->addArgument('registry', InputArgument::REQUIRED, 'the registry ID') |
| 374 | + ->addArgument('gateway', InputArgument::REQUIRED, 'the gateway ID') |
| 375 | + ->setDescription('(Beta feature) List devices for the given gateway.') |
| 376 | + ->setCode(function ($input, $output) { |
| 377 | + list_devices_for_gateway( |
| 378 | + $input->getOption('project'), |
| 379 | + $input->getOption('location'), |
| 380 | + $input->getArgument('registry'), |
| 381 | + $input->getArgument('gateway') |
| 382 | + ); |
| 383 | + }); |
| 384 | + |
| 385 | +$application->add(new Command('bind-device-to-gateway')) |
| 386 | + ->addOption('project', '', InputOption::VALUE_REQUIRED, 'The Google Cloud project ID', getenv('GCLOUD_PROJECT')) |
| 387 | + ->addOption('location', '', InputOption::VALUE_REQUIRED, 'The location of your device registries', 'us-central1') |
| 388 | + ->addArgument('registry', InputArgument::REQUIRED, 'the registry ID') |
| 389 | + ->addArgument('device', InputArgument::REQUIRED, 'the device ID') |
| 390 | + ->addArgument('gateway', InputArgument::REQUIRED, 'the gateway ID') |
| 391 | + ->setDescription('(Beta feature) Bind a device to a gateway.') |
| 392 | + ->setCode(function ($input, $output) { |
| 393 | + bind_device_to_gateway( |
| 394 | + $input->getOption('project'), |
| 395 | + $input->getOption('location'), |
| 396 | + $input->getArgument('registry'), |
| 397 | + $input->getArgument('gateway'), |
| 398 | + $input->getArgument('device') |
| 399 | + ); |
| 400 | + }); |
| 401 | + |
| 402 | +$application->add(new Command('unbind-device-from-gateway')) |
| 403 | + ->addArgument('registry', InputArgument::REQUIRED, 'the registry ID') |
| 404 | + ->addArgument('device', InputArgument::REQUIRED, 'the device ID') |
| 405 | + ->addArgument('gateway', InputArgument::REQUIRED, 'the gateway ID') |
| 406 | + ->addOption('project', '', InputOption::VALUE_REQUIRED, 'The Google Cloud project ID', getenv('GCLOUD_PROJECT')) |
| 407 | + ->addOption('location', '', InputOption::VALUE_REQUIRED, 'The location of your device registries', 'us-central1') |
| 408 | + ->setDescription('(Beta feature) Unbind a device from a gateway.') |
| 409 | + ->setCode(function ($input, $output) { |
| 410 | + unbind_device_from_gateway( |
| 411 | + $input->getOption('project'), |
| 412 | + $input->getOption('location'), |
| 413 | + $input->getArgument('registry'), |
| 414 | + $input->getArgument('gateway'), |
| 415 | + $input->getArgument('device') |
| 416 | + ); |
| 417 | + }); |
| 418 | + |
322 | 419 | // for testing |
323 | 420 | if (getenv('PHPUNIT_TESTS') === '1') { |
324 | 421 | return $application; |
|
0 commit comments