def Run(self, args): client = registries.RegistriesClient() messages = apis.GetMessagesModule('cloudiot', 'v1beta1') policy = iam_util.ParsePolicyFile(args.policy_file, messages.Policy) registry_ref = util.ParseRegistry(args.id, region=args.region) return client.SetIamPolicy( registry_ref, set_iam_policy_request=messages.SetIamPolicyRequest(policy=policy))
def Run(self, args): """Run the list command.""" client = registries.RegistriesClient() registry_ref = util.ParseRegistry(args.registry, region=args.region) registry = client.Get(registry_ref) for idx, credential in enumerate(registry.credentials): serializable = resource_projector.MakeSerializable(credential) serializable['index'] = idx yield serializable
def Run(self, args): client = registries.RegistriesClient() registry_ref = util.ParseRegistry(args.id, region=args.region) mqtt_state = util.ParseEnableMqttConfig(args.enable_mqtt_config, client=client) pubsub_topic_ref = util.ParsePubsubTopic(args.pubsub_topic) return client.Patch(registry_ref, pubsub_topic=pubsub_topic_ref, mqtt_config_state=mqtt_state)
def Run(self, args): client = registries.RegistriesClient() registry_ref = util.ParseRegistry(args.registry, region=args.region) console_io.PromptContinue( message='This will delete ALL CREDENTIALS for registry [{}]'. format(registry_ref.Name()), cancel_on_no=True) response = client.Patch(registry_ref, credentials=[]) log.status.Print('Cleared all credentials for registry [{}].'.format( registry_ref.Name())) return response
def Run(self, args): """Run the list command.""" client = devices.DevicesClient() registry_ref = util.ParseRegistry(args.registry, args.region) return client.List(registry_ref, device_ids=args.device_ids, device_num_ids=args.device_num_ids, field_mask=['blocked', 'name'], limit=args.limit, page_size=args.page_size)
def Run(self, args): client = registries.RegistriesClient() registry_ref = util.ParseRegistry(args.registry, region=args.region) new_credential = util.ParseRegistryCredential(args.path, messages=client.messages) credentials = client.Get(registry_ref).credentials credentials.append(new_credential) response = client.Patch(registry_ref, credentials=credentials) log.CreatedResource(registry_ref.Name(), 'credentials for registry') return response
def Run(self, args): client = registries.RegistriesClient() registry_ref = util.ParseRegistry(args.registry, region=args.region) credentials = client.Get(registry_ref).credentials try: return credentials[args.index] except IndexError: raise util.BadCredentialIndexError(registry_ref.Name(), credentials, args.index, resource='registry')
def Run(self, args): client = registries.RegistriesClient() registry_ref = util.ParseRegistry(args.id, region=args.region) mqtt_state = util.ParseEnableMqttConfig(args.enable_mqtt_config, client=client) pubsub_topic_ref = util.ParsePubsubTopic(args.pubsub_topic) response = client.Patch(registry_ref, pubsub_topic=pubsub_topic_ref, mqtt_config_state=mqtt_state) log.UpdatedResource(registry_ref.Name(), 'registry') return response
def Run(self, args): client = devices.DevicesClient() registry_ref = util.ParseRegistry(args.registry, region=args.region) enabled_state = util.ParseEnableDevice(args.enable_device, client=client) credentials = util.ParseCredentials(args.public_keys, messages=client.messages) return client.Create(registry_ref, args.id, enabled_state=enabled_state, credentials=credentials)
def Run(self, args): client = registries.RegistriesClient() messages = client.messages policy = iam_util.ParsePolicyFile(args.policy_file, messages.Policy) registry_ref = util.ParseRegistry(args.id, region=args.region) response = client.SetIamPolicy( registry_ref, set_iam_policy_request=messages.SetIamPolicyRequest(policy=policy)) log.status.Print('Set IAM policy for registry [{}].'.format( registry_ref.Name())) return response
def Run(self, args): client = registries.RegistriesClient() registry_ref = util.ParseRegistry(args.id, region=args.region) mqtt_state = util.ParseEnableMqttConfig(args.enable_mqtt_config, client=client) http_state = util.ParseEnableHttpConfig(args.enable_http_config, client=client) event_pubsub_topic = args.pubsub_topic or args.event_pubsub_topic event_pubsub_topic_ref = util.ParsePubsubTopic(event_pubsub_topic) state_pubsub_topic_ref = util.ParsePubsubTopic(args.state_pubsub_topic) response = client.Patch(registry_ref, event_pubsub_topic=event_pubsub_topic_ref, state_pubsub_topic=state_pubsub_topic_ref, mqtt_enabled_state=mqtt_state, http_enabled_state=http_state) log.UpdatedResource(registry_ref.Name(), 'registry') return response
def Run(self, args): client = registries.RegistriesClient() registry_ref = util.ParseRegistry(args.registry, region=args.region) credentials = client.Get(registry_ref).credentials try: credential = credentials.pop(args.index) except IndexError: raise util.BadCredentialIndexError(registry_ref.Name(), credentials, args.index, resource='registry') console_io.PromptContinue( message='This will delete the following credential: {}'.format( credential), cancel_on_no=True) response = client.Patch(registry_ref, credentials=credentials) log.DeletedResource( registry_ref.Name(), 'credential at index [{}] for registry'.format(args.index)) return response
def Run(self, args): client = devices.DevicesClient() registry_ref = util.ParseRegistry(args.registry, region=args.region) # Defaults are set here because right now with nested groups, help text # isn't being generated correctly. args_blocked = False if args.blocked is None else args.blocked args_enabled = True if args.enable_device is None else args.enable_device blocked = util.ParseDeviceBlocked(args_blocked, args_enabled) credentials = util.ParseCredentials(args.public_keys, messages=client.messages) metadata = util.ParseMetadata(args.metadata, args.metadata_from_file, client.messages) response = client.Create( registry_ref, args.id, blocked=blocked, credentials=credentials, metadata=metadata ) log.CreatedResource(args.id, 'device') return response
def Run(self, args): client = registries.RegistriesClient() return client.Delete(util.ParseRegistry(args.id, region=args.region))
def Run(self, args): client = registries.RegistriesClient() registry_ref = util.ParseRegistry(args.id, region=args.region) return client.GetIamPolicy(registry_ref)
def Run(self, args): client = registries.RegistriesClient() registry_ref = util.ParseRegistry(args.id, region=args.region) response = client.Delete(registry_ref) log.DeletedResource(registry_ref.Name(), 'registry') return response