コード例 #1
0
def _Run(args, supports_deprecated_event_config_flags=False):
  """Creates a new Cloud IoT Device Registry."""
  client = registries.RegistriesClient()

  registry_ref = args.CONCEPTS.registry.Parse()
  location_ref = registry_ref.Parent()

  mqtt_state = util.ParseEnableMqttConfig(args.enable_mqtt_config,
                                          client=client)
  http_state = util.ParseEnableHttpConfig(args.enable_http_config,
                                          client=client)

  event_pubsub_topic = None
  if supports_deprecated_event_config_flags:
    event_pubsub_topic = args.event_pubsub_topic
  event_notification_configs = util.ParseEventNotificationConfig(
      args.event_notification_configs, event_pubsub_topic)

  state_pubsub_topic_ref = util.ParsePubsubTopic(args.state_pubsub_topic)
  credentials = []
  if args.public_key_path:
    credentials.append(util.ParseRegistryCredential(args.public_key_path))

  response = client.Create(
      location_ref, registry_ref.registriesId,
      credentials=credentials,
      event_notification_configs=event_notification_configs,
      state_pubsub_topic=state_pubsub_topic_ref,
      mqtt_enabled_state=mqtt_state,
      http_enabled_state=http_state)
  log.CreatedResource(registry_ref.registriesId, 'registry')
  return response
コード例 #2
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
コード例 #3
0
def _Run(args, supports_deprecated_event_config_flags=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_pubsub_topic = None
    if supports_deprecated_event_config_flags:
        event_pubsub_topic = args.event_pubsub_topic
    event_notification_configs = util.ParseEventNotificationConfig(
        args.event_notification_configs, event_pubsub_topic)
    state_pubsub_topic_ref = util.ParsePubsubTopic(args.state_pubsub_topic)

    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.UpdatedResource(registry_ref.Name(), 'registry')
    return response