- release_tracks: [GA, BETA]
  help_text:
    brief: |
      Create a new connectivity test.
    description: |
      Create a new connectivity test with the given name.
    examples: |
      The following command creates a connectivity test with the name my-test,
      and the test between a source VM and a destination IP address in a peering
      network.

        $ {command} my-test \
            --source-instance=projects/my-project/zones/us-west-1/instances/my-instance
            --destination-ip-address=10.142.0.2 --destination-network=projects/my-project/global/networks/peering-network
  arguments:
    resource:
      spec: !REF googlecloudsdk.command_lib.network_management.resources:connectivityTest
      help_text: |
        Name of the connectivity test you want to create.
    params:
    - group:
        required: true
        params:
        - arg_name: source-instance
          api_field: connectivityTest.source.instance
          help_text: |
            A Compute Engine instance URI as the source endpoint.
        - arg_name: source-ip-address
          api_field: connectivityTest.source.ipAddress
          help_text: |
            The IP address of the source which can be an external or internal IP.
        - arg_name: source-gke-master-cluster
          api_field: connectivityTest.source.gkeMasterCluster
          help_text: |
            A cluster URI for Google Kubernetes Engine master as the source endpoint.
        - arg_name: source-cloud-sql-instance
          api_field: connectivityTest.source.cloudSqlInstance
          help_text: |
            A Cloud SQL instance URI as the source endpoint.
        - arg_name: source-cloud-function
          api_field: connectivityTest.source.cloudFunction.uri
          help_text: |
            A Cloud function URI as the source endpoint.
        - arg_name: source-app-engine-version
          api_field: connectivityTest.source.appEngineVersion.uri
          help_text: |
            App Engine version URI as the source endpoint.
        - arg_name: source-cloud-run-revision
          api_field: connectivityTest.source.cloudRunRevision.uri
          help_text: |
            Cloud Run revision URI as the source endpoint.
    - arg_name: source-network
      api_field: connectivityTest.source.network
      help_text: |
        A VPC network URI where the source is located.
    - arg_name: source-network-type
      api_field: connectivityTest.source.networkType
      help_text: |
        Type of the network where the source is located.
      choices:
      - enum_value: gcp-network
        arg_value: gcp-network
        help_text: Network in Google Cloud Platform.
      - enum_value: non-gcp-network
        arg_value: non-gcp-network
        help_text: Network outside Google Cloud Platform.
      default: gcp-network
    - arg_name: source-project
      api_field: connectivityTest.source.projectId
      help_text: |
        Project ID of the source endpoint.
    - group:
        required: true
        params:
        - arg_name: destination-instance
          api_field: connectivityTest.destination.instance
          help_text: |
            A Compute Engine instance URI as the destination endpoint.
        - arg_name: destination-ip-address
          api_field: connectivityTest.destination.ipAddress
          help_text: |
            The IP address of the destination which can be an external or internal IP.
        - arg_name: destination-gke-master-cluster
          api_field: connectivityTest.destination.gkeMasterCluster
          help_text: |
            A cluster URI for Google Kubernetes Engine master as the destination endpoint.
        - arg_name: destination-cloud-sql-instance
          api_field: connectivityTest.destination.cloudSqlInstance
          help_text: |
            A Cloud SQL instance URI as the destination endpoint.
        - arg_name: destination-forwarding-rule
          api_field: connectivityTest.destination.forwardingRule
          help_text: |
            A forwarding rule URI as the destination endpoint.
        - arg_name: destination-redis-instance
          api_field: connectivityTest.destination.redisInstance
          help_text: |
            A Redis instance URI as the destination endpoint.
        - arg_name: destination-redis-cluster
          api_field: connectivityTest.destination.redisCluster
          help_text: |
            A Redis cluster URI as the destination endpoint.
    - arg_name: destination-network
      api_field: connectivityTest.destination.network
      help_text: |
        A VPC network URI where the destination is located.
    - arg_name: destination-port
      api_field: connectivityTest.destination.port
      help_text: |
        The IP protocol port of the destination. Only applicable when protocol is
        TCP or UDP.
    - arg_name: destination-project
      api_field: connectivityTest.destination.projectId
      help_text: |
        Project ID of the destination endpoint.
    - arg_name: destination-fqdn
      api_field: connectivityTest.destination.fqdn
      help_text: |
        A hostname as the destination endpoint. Only applicable for Google Kubernetes Engine.
    - arg_name: description
      api_field: connectivityTest.description
      help_text: |
        The description of the connectivity test.
    - arg_name: protocol
      api_field: connectivityTest.protocol
      help_text: |
        Type of protocol for the test. When not provided, "TCP" is assumed.
    - arg_name: round-trip
      type: bool
      api_field: connectivityTest.roundTrip
      help_text: |
        This boolean controls whether return traces (from the destination to the
        source) will be additionally calculated if packet successfully reaches
        the destination from the source.
    - arg_name: bypass-firewall-checks
      type: bool
      api_field: connectivityTest.bypassFirewallChecks
      help_text: |
        This boolean controls whether to skip firewall checking.
    - arg_name: other-projects
      api_field: connectivityTest.relatedProjects
      repeated: true
      help_text: |
        IDs of other projects involved in the connectivity test, besides
        the source and destination project.
    - arg_name: labels
      api_field: connectivityTest.labels.additionalProperties
      metavar: KEY=VALUE
      help_text: |
        List of label KEY=VALUE pairs to add.
      type:
        arg_dict:
          spec:
          - api_field: key
          - api_field: value

  async:
    collection: networkmanagement.projects.locations.global.operations

  request:
    BETA:
      api_version: v1beta1
      modify_request_hooks:
      - googlecloudsdk.command_lib.network_management.util:ValidateInstanceNames
      - googlecloudsdk.command_lib.network_management.util:ValidateNetworkURIs
      - googlecloudsdk.command_lib.network_management.util:AppendLocationsGlobalToParent
      - googlecloudsdk.command_lib.network_management.util:ValidateGKEMasterClustersURIs
      - googlecloudsdk.command_lib.network_management.util:ValidateCloudSQLInstancesURIs
      - googlecloudsdk.command_lib.network_management.util:ValidateCloudFunctionsURIs
      - googlecloudsdk.command_lib.network_management.util:ValidateAppEngineVersionsURIs
      - googlecloudsdk.command_lib.network_management.util:ValidateCloudRunRevisionsURIs
      - googlecloudsdk.command_lib.network_management.util:ValidateForwardingRulesURIs
      - googlecloudsdk.command_lib.network_management.util:ValidateRedisInstancesURIs
      - googlecloudsdk.command_lib.network_management.util:ValidateRedisClustersURIs
      - googlecloudsdk.command_lib.network_management.util:ValidateFqdn
    GA:
      api_version: v1
      modify_request_hooks:
      - googlecloudsdk.command_lib.network_management.util:ValidateInstanceNames
      - googlecloudsdk.command_lib.network_management.util:ValidateNetworkURIs
      - googlecloudsdk.command_lib.network_management.util:AppendLocationsGlobalToParent
      - googlecloudsdk.command_lib.network_management.util:ValidateGKEMasterClustersURIs
      - googlecloudsdk.command_lib.network_management.util:ValidateCloudSQLInstancesURIs
      - googlecloudsdk.command_lib.network_management.util:ValidateCloudFunctionsURIs
      - googlecloudsdk.command_lib.network_management.util:ValidateAppEngineVersionsURIs
      - googlecloudsdk.command_lib.network_management.util:ValidateCloudRunRevisionsURIs
      - googlecloudsdk.command_lib.network_management.util:ValidateForwardingRulesURIs
      - googlecloudsdk.command_lib.network_management.util:ValidateRedisInstancesURIs
      - googlecloudsdk.command_lib.network_management.util:ValidateRedisClustersURIs
      - googlecloudsdk.command_lib.network_management.util:ValidateFqdn
    collection: networkmanagement.projects.locations.global.connectivityTests
    method: create
