- release_tracks: [ALPHA, BETA]

  help_text:
    brief: Create a new policy-based route.
    description: Create a new policy-based route with the given name.
    examples: |
      To create a policy-based route with the name ``my-pbr'' to route all traffic in ``default''
      network to an internal load balancer with IP 10.0.0.1, run:

        $ {command} my-pbr --network="projects/my-project/global/networks/default"
          --next-hop-ilb-ip=10.0.0.1

  arguments:
    resource:
      spec: !REF googlecloudsdk.command_lib.network_connectivity.resources:policyBasedRoute
      help_text: Name of the policy-based route to be created.
    params:
    - arg_name: network
      required: true
      api_field: googleCloudNetworkconnectivityV1betaPolicyBasedRoute.network
      help_text: Fully-qualified URL of the network that this route applies to. E.g. `projects/my-project/global/networks/my-network`
    - group:
        mutex: true
        params:
        - arg_name: tags
          api_field: googleCloudNetworkconnectivityV1betaPolicyBasedRoute.virtualMachine.tags
          type: arg_list
          help_text: List of VM instance tags that this route applies to. VM instances that have ANY of tags specified here installs this route. Note if both `--tags` and `--interconnect-attachment-region` are not set, then the policy-based route will be installed in all endpoints, including VMs, VPNs, and Interconnect attachements, in the network.
        - arg_name: interconnect-attachment-region
          api_field: googleCloudNetworkconnectivityV1betaPolicyBasedRoute.interconnectAttachment.region
          help_text: Cloud region to install this policy-based route on interconnect attachment. Use `all` to install it on all interconnect attachments. Note if both `--tags` and `--interconnect-attachment-region` are not set, then the policy-based route will be installed in all network endpoints, including VMs, VPNs, and Interconnect attachements, in the network.
    - arg_name: priority
      api_field: googleCloudNetworkconnectivityV1betaPolicyBasedRoute.priority
      help_text: Priority of this policy-based route. Priority is used to break ties in cases where there are more than one matching policy-based routes found. In cases where multiple policy-based routes are matched, the one with the lowest-numbered priority value wins. The default value is 1000. The priority value must be from 1 to 65535, inclusive. Note the priority of policy-based route is always higher than other types of route (e.g. static routes/advanced routes)
    - arg_name: ip-protocol
      api_field: googleCloudNetworkconnectivityV1betaPolicyBasedRoute.filter.ipProtocol
      help_text: IP protocol that this policy-based route applies to. Valid values are `TCP`, `UDP`, and `ALL`. Default is `ALL`.
    - arg_name: source-range
      api_field: googleCloudNetworkconnectivityV1betaPolicyBasedRoute.filter.srcRange
      help_text: Source IP range of outgoing packets that this policy-based route applies to.
    - arg_name: destination-range
      api_field: googleCloudNetworkconnectivityV1betaPolicyBasedRoute.filter.destRange
      help_text: Destination IP range of outgoing packets that this policy-based route applies to.
    - arg_name: protocol-version
      api_field: googleCloudNetworkconnectivityV1betaPolicyBasedRoute.filter.protocolVersion
      help_text: Internet protocol versions that this policy-based route applies to. Valid values are `IPV4`, and `IPV6`. Default is `IPV4'.
      default: IPV4
    - group:
        mutex: true
        params:
        - arg_name: next-hop-ilb-ip
          api_field: googleCloudNetworkconnectivityV1betaPolicyBasedRoute.nextHopIlbIp
          help_text: IP of a global access enabled L4 ILB that should be the next hop to handle packets.
        - arg_name: next-hop-other-routes
          api_field: googleCloudNetworkconnectivityV1betaPolicyBasedRoute.nextHopOtherRoutes
          help_text: Next hop should be other routes that handle packets. This effectively excludes matching packets being applied on other policy-based routes with a lower priority.
    - arg_name: description
      api_field: googleCloudNetworkconnectivityV1betaPolicyBasedRoute.description
      help_text: Optional description of this resource. Provide this field when you create the resource.
    labels:
      api_field: googleCloudNetworkconnectivityV1betaPolicyBasedRoute.labels

  async:
    collection: networkconnectivity.projects.locations.operations

  request:
    ALPHA:
      api_version: v1beta
    BETA:
      api_version: v1beta
    collection: networkconnectivity.projects.locations.global.policyBasedRoutes
    method: create
    modify_request_hooks:
    - googlecloudsdk.command_lib.network_connectivity.util:AppendLocationsGlobalToParent

- release_tracks: [GA]

  help_text:
    brief: Create a new policy-based route.
    description: Create a new policy-based route with the given name.
    examples: |
      To create a policy-based route with the name ``my-pbr'' to route all traffic in ``default''
      network to an internal load balancer with IP 10.0.0.1, run:

        $ {command} my-pbr --network="projects/my-project/global/networks/default"
          --next-hop-ilb-ip=10.0.0.1

  arguments:
    resource:
      spec: !REF googlecloudsdk.command_lib.network_connectivity.resources:policyBasedRoute
      help_text: Name of the policy-based route to be created.
    params:
    - arg_name: network
      required: true
      api_field: policyBasedRoute.network
      help_text: Fully-qualified URL of the network that this route applies to. E.g. `projects/my-project/global/networks/my-network`
    - group:
        mutex: true
        params:
        - arg_name: tags
          api_field: policyBasedRoute.virtualMachine.tags
          type: arg_list
          help_text: List of VM instance tags that this route applies to. VM instances that have ANY of tags specified here installs this route. Note if both `--tags` and `--interconnect-attachment-region` are not set, then the policy-based route will be installed in all endpoints, including VMs, VPNs, and Interconnect attachements, in the network.
        - arg_name: interconnect-attachment-region
          api_field: policyBasedRoute.interconnectAttachment.region
          help_text: Cloud region to install this policy-based route on interconnect attachment. Use `all` to install it on all interconnect attachments. Note if both `--tags` and `--interconnect-attachment-region` are not set, then the policy-based route will be installed in all network endpoints, including VMs, VPNs, and Interconnect attachements, in the network.
    - arg_name: priority
      api_field: policyBasedRoute.priority
      help_text: Priority of this policy-based route. Priority is used to break ties in cases where there are more than one matching policy-based routes found. In cases where multiple policy-based routes are matched, the one with the lowest-numbered priority value wins. The default value is 1000. The priority value must be from 1 to 65535, inclusive. Note the priority of policy-based route is always higher than other types of route (e.g. static routes/advanced routes)
    - arg_name: ip-protocol
      api_field: policyBasedRoute.filter.ipProtocol
      help_text: IP protocol that this policy-based route applies to. Valid values are `TCP`, `UDP`, and `ALL`. Default is `ALL`.
    - arg_name: source-range
      api_field: policyBasedRoute.filter.srcRange
      help_text: Source IP range of outgoing packets that this policy-based route applies to.
    - arg_name: destination-range
      api_field: policyBasedRoute.filter.destRange
      help_text: Destination IP range of outgoing packets that this policy-based route applies to.
    - arg_name: protocol-version
      api_field: policyBasedRoute.filter.protocolVersion
      help_text: Internet protocol versions that this policy-based route applies to. For this version, only `IPV4` is supported.
      default: IPV4
    - group:
        mutex: true
        params:
        - arg_name: next-hop-ilb-ip
          api_field: policyBasedRoute.nextHopIlbIp
          help_text: IP of a global access enabled L4 ILB that should be the next hop to handle packets.
        - arg_name: next-hop-other-routes
          api_field: policyBasedRoute.nextHopOtherRoutes
          help_text: Next hop should be other routes that handle packets. This effectively excludes matching packets being applied on other policy-based routes with a lower priority.
    - arg_name: description
      api_field: policyBasedRoute.description
      help_text: Optional description of this resource. Provide this field when you create the resource.
    labels:
      api_field: policyBasedRoute.labels

  async:
    collection: networkconnectivity.projects.locations.operations

  request:
    GA:
      api_version: v1
    collection: networkconnectivity.projects.locations.global.policyBasedRoutes
    method: create
    modify_request_hooks:
    - googlecloudsdk.command_lib.network_connectivity.util:AppendLocationsGlobalToParent
