
    A                        d Z ddlmZ ddlmZ ddlmZ ddlZddlmZ ddlmZ ddl	m
Z
 dd	l	mZ dd
lmZ ddlmZ ddlmZ ddlmZ dZdZd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Z d8dZ!d Z"d Z#d Z$d  Z%d! Z&d" Z'd# Z(	 	 	 d9d$Z)d% Z*d& Z+d' Z,d( Z-d) Z.d* Z/d+ Z0d8d,Z1d- Z2d. Z3d/ Z4ejj                   G d0 d1ejl                               Z7e7jp                  fd2Z9e7jp                  fd3Z:d4 Z;d5 Z<d6 Z=d7 Z>y):z/Common flags for network connectivity commands.    )absolute_import)division)unicode_literalsN)arg_parsers)base)concepts)deps)util)	arg_utils)concept_parsers)presentation_specsz--globalz--regionc           	      X    | j                  ddt        j                         g d|d       y)z>Adds the --exclude-export-ranges argument to the given parser.--exclude-export-rangesF
CIDR_RANGEzzSubnet IP address range(s) to hide from other VPC networks that are
        connected through Network Connectivity Center.requiredtypedefaultmetavarhiddenhelpNadd_argumentr   ArgListparserhide_exclude_export_ranges_flags     <lib/googlecloudsdk/command_lib/network_connectivity/flags.pyAddExcludeExportRangesFlagr   %   s5     ,:  ;    c           	      X    | j                  ddt        j                         g d|d       y)z>Adds the --include-export-ranges argument to the given parser.--include-export-rangesFr   zzSubnet IP address range(s) to export to other VPC networks that are
        connected through Network Connectivity Center.r   Nr   r   hide_include_export_ranges_flags     r   AddIncludeExportRangesFlagr%   2   s7     	 ,:  	r    c           	      X    | j                  ddt        j                         dd|d       y)zIAdds the --include-export-ranges argument to the update operation parser.r"   FNr   z'New include export ranges of the spoke.r   r   r#   s     r    AddUpdateIncludeExportRangesFlagr'   A   5    
 	 ,8  r    c           	      X    | j                  ddt        j                         dd|d       y)zIAdds the --exclude-export-ranges argument to the update operation parser.r   FNr   z'New exclude export ranges of the spoke.r   r   r   s     r    AddUpdateExcludeExportRangesFlagr*   Q   r(   r    c                 R    t        j                  d| j                  dddddd      S )	Nz
--capacity)1gz$Gateway will have capacity of 1 Gbps)10gz%Gateway will have capacity of 10 Gbps)100gz&Gateway will have capacity of 100 Gbps)CAPACITY_1_GBPSCAPACITY_10_GBPSCAPACITY_100_GBPSz(Set the capacity of the gateway in Gbps.T)arg_namemessage_enumcustom_mappingshelp_strr   )r   ChoiceEnumMapperCapacityValueValuesEnum)gateway_messages    r   GetCapacityArgr9   a   s9    		#	#"::KN  :
 r    c                 L    t        |       j                  j                  |       y N)r9   
choice_argAddToParser)r8   r   s     r   AddCapacityFlagr>   r   s    !,,88@r    c                 V    | j                  ddt        j                         g dd       y)z=Adds the --ip-range-reservation argument to the given parser.z--ip-range-reservationsTr   z'The IP range reservation for the spoke.)r   r   r   r   r   Nr   r   s    r   AddIpRangeReservationsFlagrA   v   s0     8  r    c                 *    | j                  dd       y)z8Adds the --landing-network argument to the given parser.z--landing-networkzHThe landing network for the spoke. The network must already
      exist.)r   Nr   r@   s    r   AddLandingNetworkFlagrD      s     	  r    c                 B    t         j                  j                  |        y)z-Add the --async argument to the given parser.N)r   
ASYNC_FLAGr=   r@   s    r   AddAsyncFlagrG      s    //f%r    c                 ,    | j                  ddd       y)z,Adds the --hub argument to the given parser.z--hubTz>Hub that the spoke will attach to. The hub must already exist.r   r   NrC   r@   s    r   
AddHubFlagrJ      s!     	K  Mr    c                 ,    | j                  dd|       y)z*Adds the --spoke flag to the given parser.z--spokeTrI   NrC   r   	help_texts     r   AddSpokeFlagrN      s      r    c                 ,    | j                  dd|       y)z/Adds the --spoke-etag flag to the given parser.z--spoke-etagTrI   NrC   rL   s     r   AddSpokeEtagFlagrP      s      r    c                 ^    |r| j                  dddd       y| j                  dddd       y)z.Adds the --group argument to the given parser.z--groupTFzCGroup that the spoke will be part of. The group must already exist.)r   r   r   NrC   )r   r   s     r   AddGroupFlagrR      sK     
     r    c                 ,    | j                  ddd       y)z0Adds the --network argument to the given parser.z	--networkTzYour VPC network that contains the peering to the Producer VPC,
      which this spoke connects to the Hub. The peering must already exist and
      be in the ACTIVE state.rI   NrC   r@   s    r   AddNetworkFlagrT      s     !  "r    c                 ,    | j                  ddd       y)z0Adds the --peering argument to the given parser.z	--peeringTzPeering between your network and the Producer VPC, which this
      spoke connects to the Hub. The peering must already exist and be in the
      ACTIVATE state.rI   NrC   r@   s    r   AddPeeringFlagrV      s       r    c                 ,    | j                  ddd       y)z4Adds the --vpc-network argument to the given parser.z--vpc-networkTz[VPC network that the spoke provides connectivity to.
      The resource must already exist.rI   NrC   r@   s    r   AddVPCNetworkFlagrX      s"     	*  +r    c                 ,    | j                  dd|       y)z0Adds the --description flag to the given parser.z--descriptionFrI   NrC   rL   s     r   AddDescriptionFlagrZ      s      r    c                 ,    | j                  ddd       y)z,Adds the --details flag to the given parser.z	--detailsFz'Additional details behind the rejectionrI   NrC   r@   s    r   AddRejectionDetailsFlagr\      s    8  :r    c                 R    | j                  t        d|t        j                         y)z.Add the --global argument to the given parser.z#Indicates that the spoke is global.)r   r   actionN)r   GLOBAL_ARGUMENTr
   StoreGlobalAction)r   r   s     r   AddGlobalFlagra      s'    0##	  %r    c                 H    d}|r|dz  }| j                  t        |||       y)z.Add the --region argument to the given parser.z         A Google Cloud region. To see the names of regions, see [Viewing a list of available regions](https://cloud.google.com/compute/docs/regions-zones/viewing-regions-zones#viewing_a_list_of_available_regions).z" Use ``-`` to specify all regions.)r   r   r   N)r   REGION_ARGUMENT)r   supports_region_wildcardr   r   region_help_texts        r   AddRegionFlagrf      s7    Y<<fx>N  r    c                 `    | j                  dd      }t        ||       t        |||d       y)zOAdd a group which contains the global and region arguments to the given parser.FTr   mutex)r   N)	add_groupra   rf   )r   rd   hide_global_arghide_region_argregion_groups        r   AddRegionGrouprn     s5    
 !!5!=,o.,or    c                 Z    d}| j                  dd|t        j                         g d       y)z7Add the --spoke-locations argument to the given parser.a@           A comma separated list of locations. The locations can be set to 'global'
        and/or Google Cloud supported regions. To see the names of regions, see
        [Viewing a list of available regions](https://cloud.google.com/compute/docs/regions-zones/viewing-regions-zones#viewing_a_list_of_available_regions).z--spoke-locationsFLOCATION)r   r   r   r   r   Nr   )r   spoke_locations_help_texts     r   AddSpokeLocationsFlagrr     s;    a 	$   r    c                 8    d}| j                  ddddgd|       y)z,Add the --view argument to the given parser.zO        Enumeration to control which spoke fields are included in the response.z--viewFbasicdetailed)r   choicesr   r   NrC   )r   view_help_texts     r   AddViewFlagrx      s1    R.
#  r    c                     t        j                  ddt               t         j                  d      }t	        j
                  d|ddj                  |            }t        j                  |g      j                  |        y)	zAdd a resource argument for a hub.

  Args:
    parser: the parser for the command.
    desc: the string to describe the resource, such as 'to create'.
  z2networkconnectivity.projects.locations.global.hubshubF)resource_namehubsId
projectsIddisable_auto_completersTzName of the hub {}.nameconcept_specr   
group_helpN)
r   ResourceSpecHubAttributeConfig DEFAULT_PROJECT_ATTRIBUTE_CONFIGr   ResourcePresentationSpecformatr   ConceptParserr=   )r   deschub_concept_specpresentation_specs       r   AddHubResourceArgr   ,  sv     **:!::#% )AA#&--d3	5
 !2 34@@Hr    c           	         t        j                  dddt               t               t         j                  d      }t        j                  d|ddj                  |            }t        j                  |g      j                  |        y	)
zAdd a resource argument for a group.

  Args:
    parser: the parser for the command.
    desc: the string to describe the resource, such as 'to create'.
  z9networkconnectivity.projects.locations.global.hubs.groupsgroupv1F)r{   api_versiongroupsIdr|   r}   r~   TzName of the group {}.r   N)r   r   GroupAttributeConfigr   r   r   r   r   r   r   r=   )r   r   group_concept_specr   s       r   AddGroupResourceArgr   B  s      ,,A#%!::#% )AA%(//5	7
 !2 34@@Hr    c                  0    t        j                  dd      S )NspokezThe spoke Id.r   rM   r    ResourceParameterAttributeConfig r    r   SpokeAttributeConfigr   Z  s    		2	2o
/ /r    c                  0    t        j                  dd      S )Nrz   zThe hub Id.r   r   r   r    r   r   r   _  s    		2	2M
 r    c                  0    t        j                  dd      S )Nr   zThe group Id.r   r   r   r    r   r   r   e  s    		2	2o
 r    c                     | D cg c]  }t        j                  |       }}|r'|j                  t        j                  d d             t	        j
                  dd|      S c c}w )z:Get a location argument with the appropriate fallthroughs.c                       y)N-r   r   r    r   <lambda>z)LocationAttributeConfig.<locals>.<lambda>u  s    Sr    z(defaults to all regions if not specified)functionhintlocationzThe location Id.)r   rM   fallthroughs)r	   ArgFallthroughappendFallthroughr   r   )location_argumentsregion_resource_commandarglocation_fallthroughss       r   LocationAttributeConfigr   k  sv     +=*<3d#*<  
    ;	=> 
	2	2"(
* *s   A$c                 v    t        j                  ddt               t        |       t         j                  d      S )Nz-networkconnectivity.projects.locations.spokesr   F)r{   spokesIdlocationsIdr}   r~   )r   r   r   r   r   r   s    r   GetSpokeResourceSpecr   }  s6    			5#%)*<=::#
% %r    c                 h    t        j                  ddt        | d      t         j                  d      S )Nz&networkconnectivity.projects.locationsregionT)r   F)r{   r   r}   r~   )r   r   r   r   r   s    r   GetRegionResourceSpecr     s6    			.)
d ::#
 r    c                     t         j                  t        gt         j                  t        gt         j
                  t        t        gi}||    S r;   )ResourceLocationTypeGLOBAL_ONLYr_   REGION_ONLYrc   REGION_AND_GLOBAL)resource_location_typemappings     r   GetResourceLocationArgumentsr     sG    &&(9&&(9,,

/' 
'	((r    c                   v    e Zd ZdZ ej
                         Z ej
                         Z ej
                         Zy)r   z*Type of locations supported by a resource.N)	__name__
__module____qualname____doc__enumautor   r   r   r   r    r   r   r     s-    2		+		+diikr    r   c           	          t        |      }t        j                  dt        |      dddidj	                  |            }t        j                  |g      j                  |        y)aQ  Add a resource argument for a spoke.

  NOTE: Must be used only if it's the only resource arg in the command.

  Args:
    parser: the parser for the command.
    verb: str, the verb to describe the resource, such as 'to update'.
    resource_location_type: ResourceLocationType, the type of locations
      supported by the resource.
  r   Tr    zName of the spoke {}.r   r   r   flag_name_overridesr   N)r   r   r   r   r   r   r   r=   r   verbr   r   r   s        r   AddSpokeResourceArgr     se     44JK(AA'(:;%r*(//5 !2 34@@Hr    c           	          t        |      }t        j                  dt        |      dddidj	                  |            }t        j                  |g      j                  |        y)aR  Add a resource argument for a region.

  NOTE: Must be used only if it's the only resource arg in the command.

  Args:
    parser: the parser for the command.
    verb: str, the verb to describe the resource, such as 'to update'.
    resource_location_type: ResourceLocationType, the type of locations
      supported by the resource.
  r   Tr   r   zThe region of the spokes {}.r   N)r   r   r   r   r   r   r   r=   r   s        r   AddRegionResourceArgr     se     44JK(AA();<%r*/66t< !2 34@@Hr    c                     | j                  dd      }t        |       |j                  ddd      }t        |       t        |       y)zIAdd a group which contains the PSC-related arguments to the given parser.FTrh   )r   ri   r   N)rj   AddExportPscFlag6AddExportPscPublishedServicesAndRegionalGoogleApisFlag AddExportPscGlobalGoogleApisFlag)r   	psc_grouppsc_gapi_groups      r   AddPscGroupr     sF    T:)9&&U4&P.8H">2r    c                 J    | j                  dt        j                  dd       y)z.Add the --export-psc flag to the given parser.z--export-pscFzCWhether Private Service Connect propagation is enabled for the hub.)r^   r   r   Nr   r   StoreTrueFalseActionr@   s    r   r   r     s'    --T	  r    c                 L    | j                  dt        j                  ddd       y)zZAdd the --export-psc-published-services-and-regional-google-apis flag to the given parser.z8--export-psc-published-services-and-regional-google-apisFTzwWhether propagation for Private Service Connect for published services and regional Google APIs is enabled for the hub.r^   r   r   r   Nr   r@   s    r   r   r     s-    @-- I  r    c                 L    | j                  dt        j                  ddd       y)zAAdd the --export-psc-global-google-apis flag to the given parser.z--export-psc-global-google-apisFTz^Whether propagation for Private Service Connect for global Google APIs is enabled for the hub.r   Nr   r@   s    r   r   r     s*    '--o  r    )F)FFF)?r   
__future__r   r   r   r   googlecloudsdk.callioper   r    googlecloudsdk.calliope.conceptsr   r	   /googlecloudsdk.command_lib.network_connectivityr
   $googlecloudsdk.command_lib.util.apisr   (googlecloudsdk.command_lib.util.conceptsr   r   r_   rc   r   r%   r'   r*   r9   r>   rA   rD   rG   rJ   rN   rP   rR   rT   rV   rX   rZ   r\   ra   rf   rn   rr   rx   r   r   r   r   r   r   r   r   r   uniqueEnumr   r   r   r   r   r   r   r   r   r    r   <module>r      sB   6 &  '  / ( 5 1 @ : D G 
;  "A	&
M2"+:% -2#(#(		I,I0/
*$%		) "499 " " *>)O)OI2 *>)O)OI23r    