예제 #1
0
파일: update.py 프로젝트: Akiho-Yasuda/wip
def _Run(args, supports_log_level=False):
    """Updates a Cloud IoT Device Registry."""
    client = registries.RegistriesClient()

    registry_ref = args.CONCEPTS.registry.Parse()
    mqtt_state = util.ParseEnableMqttConfig(args.enable_mqtt_config,
                                            client=client)
    http_state = util.ParseEnableHttpConfig(args.enable_http_config,
                                            client=client)

    event_notification_configs = util.ParseEventNotificationConfig(
        args.event_notification_configs)
    state_pubsub_topic_ref = util.ParsePubsubTopic(args.state_pubsub_topic)

    log_level = None
    if supports_log_level:
        log_level = util.ParseLogLevel(
            args.log_level,
            client.messages.DeviceRegistry.LogLevelValueValuesEnum)

    response = client.Patch(
        registry_ref,
        event_notification_configs=event_notification_configs,
        state_pubsub_topic=state_pubsub_topic_ref,
        mqtt_enabled_state=mqtt_state,
        http_enabled_state=http_state,
        log_level=log_level)
    log.UpdatedResource(registry_ref.Name(), 'registry')
    return response
예제 #2
0
    def Run(self, args):
        client = devices.DevicesClient()

        device_ref = args.CONCEPTS.device.Parse()

        metadata = util.ParseMetadata(args.metadata, args.metadata_from_file,
                                      client.messages)
        log_level = util.ParseLogLevel(
            args.log_level, client.messages.Device.LogLevelValueValuesEnum)

        device = client.Patch(device_ref,
                              blocked=args.blocked,
                              metadata=metadata,
                              log_level=log_level)
        log.UpdatedResource(device_ref.Name(), 'device')
        return device
예제 #3
0
    def Run(self, args):
        client = devices.DevicesClient()

        device_ref = args.CONCEPTS.device.Parse()

        metadata = util.ParseMetadata(args.metadata, args.metadata_from_file,
                                      client.messages)
        auth_method = flags.GATEWAY_AUTH_METHOD_ENUM_MAPPER.GetEnumForChoice(
            args.auth_method)
        log_level = util.ParseLogLevel(
            args.log_level, client.messages.Device.LogLevelValueValuesEnum)

        device = client.Patch(device_ref,
                              blocked=args.blocked,
                              metadata=metadata,
                              auth_method=auth_method,
                              log_level=log_level)
        log.UpdatedResource(device_ref.Name(), 'device')
        return device