- release_tracks: [BETA, GA]
  help_text:
    brief: Create a new Cloud TPU.
    description: Create a new Cloud TPU.
    examples: |
      The following command creates a TPU with ID `my-tpu` in the default user project,
      network and compute/region (with other defaults supplied by API):

        $ {command} my-tpu


      The following command creates a TPU with ID `my-tpu` with explicit values
      for all required and optional parameters:

        $ {command} my-tpu \
            --zone=us-central1-a \
            --range='10.240.0.0/29' \
            --accelerator-type='v2-8' \
            --network=my-tf-network \
            --description='My TF Node' \
            --version='1.1'

  request:
    _COMMON_: create_request
    BETA:
      modify_request_hooks:
      - googlecloudsdk.command_lib.util.hooks.request_modifiers:SetParentRequestHook
      - googlecloudsdk.command_lib.compute.tpus.util:CreateValidateVPCHook

  async:
    collection: tpu.projects.locations.operations
    result_attribute: response
    extract_resource_result: false

  arguments:
    resource:
      help_text: The Cloud TPU you want to create.
      spec: !REF googlecloudsdk.command_lib.compute.tpus.resources:tpu

    params:
    - _REF_: googlecloudsdk.command_lib.compute.tpus.flags:accelerator_type
    - _REF_: googlecloudsdk.command_lib.compute.tpus.flags:description
    - _REF_: googlecloudsdk.command_lib.compute.tpus.flags:network
    - _REF_: googlecloudsdk.command_lib.compute.tpus.flags:version
    - _REF_: googlecloudsdk.command_lib.compute.tpus.flags:range
    - _REF_: googlecloudsdk.command_lib.compute.tpus.flags:preemptible
    - _REF_: googlecloudsdk.command_lib.compute.tpus.flags:reserved
      release_tracks: [BETA]
    - _REF_: googlecloudsdk.command_lib.compute.tpus.flags:service_networking
      release_tracks: [BETA]


- release_tracks: [ALPHA]
  help_text:
    brief: Create a new Cloud TPU.
    description: Create a new Cloud TPU.
    examples: |
      The following command creates a TPU with ID `my-tpu` in the default user project,
      network and compute/region (with other defaults supplied by API):

        $ {command} my-tpu


      The following command creates a TPU with ID `my-tpu` with explicit values
      for all required and optional parameters:

        $ {command} my-tpu \
            --zone=us-central1-a \
            --range='10.240.0.0/29' \
            --accelerator-type='v2-8' \
            --network=my-tf-network \
            --description='My TF Node' \
            --version='1.1'

  request:
    _COMMON_: create_request
    api_version: v1alpha1
    modify_request_hooks:
    - googlecloudsdk.command_lib.util.hooks.request_modifiers:SetParentRequestHook
    - googlecloudsdk.command_lib.compute.tpus.util:CreateValidateVPCHook

  async:
    collection: tpu.projects.locations.operations
    result_attribute: response
    extract_resource_result: false

  arguments:
    resource:
      help_text: The Cloud TPU you want to create.
      spec: !REF googlecloudsdk.command_lib.compute.tpus.resources:tpu

    params:
    - _REF_: googlecloudsdk.command_lib.compute.tpus.flags:accelerator_type
    - _REF_: googlecloudsdk.command_lib.compute.tpus.flags:description
    - _REF_: googlecloudsdk.command_lib.compute.tpus.flags:network
    - _REF_: googlecloudsdk.command_lib.compute.tpus.flags:version
    - _REF_: googlecloudsdk.command_lib.compute.tpus.flags:preemptible
    - _REF_: googlecloudsdk.command_lib.compute.tpus.flags:reserved
    - _REF_: googlecloudsdk.command_lib.compute.tpus.flags:range
    - _REF_: googlecloudsdk.command_lib.compute.tpus.flags:service_networking
    - group:
        mutex: true
        params:
        - group:
            params:
            - arg_name: model-config-file
              api_field: node.modelConfigFile
              help_text: |
                Google Cloud Storage URI of the configuration file for models to serve. For example:
                'gs://my_bucket/path/to/config.pbtxt'.

                The contents of the model configuration file should look something like the
                following:

                model_config_list: {
                  config: {
                    name: "Model1",
                    base_path: "gs://my_bucket/path/to/model1",
                    model_platform: "tensorflow"
                  },
                  config: {
                    name: "Model2",
                    base_path: "gs://my_other_bucket/path/to/model2",
                    model_platform: "tensorflow"
                  },
                }
            - arg_name: platform-config-file
              api_field: node.platformConfigFile
              help_text: |
                Google Cloud Storage URI of configuration file for platform requirements. For example:
                'gs://my_bucket/path/to/platform.pbtxt'.

                The contents of the platform configuration file should look something like the following:

                platform_configs {
                  key: "tensorflow"
                  value {
                    source_adapter_config {
                      [type.googleapis.com/tensorflow.serving.SavedModelBundleSourceAdapterConfig] {
                        legacy_config {
                          saved_model_tags: "tpu"
                          saved_model_tags: "serve"
                          batching_parameters {
                            max_batch_size { value: 8 }
                            batch_timeout_micros { value: 50000 }
                            max_enqueued_batches { value: 10000 }
                            num_batch_threads { value: 8 }
                          }
                        }
                      }
                    }
                  }
                }
        - group:
            params:
            - arg_name: model-base-path
              api_field: node.modelBasePath
              help_text: |
                Base path to exported saved model. This flag can be used instead of
                '--model-config-file' directly to specify the exported saved model's base path
                (excluding timestamp), whereas '--model-config-file' points to a Google Cloud
                Storage path to a ModelServerConfig proto.
            - arg_name: model-name
              api_field: node.modelName
              help_text: |
                Model name for tensorflow serving to serve to incoming requests. If not provided,
                'serving_default' will be used.
