
    ,                         S r SSKJr  SSKJr  SSKJr  SSKJr  SSKJr	  SSK
Jr  SSK
Jr  SS	KJr  S
 rS rS rS rS rg)z%Utils for Fleet memberships commands.    )absolute_import)division)unicode_literals)base)
exceptions)api_util)	resources)errorsc                 2    A AUR                   S-   Ul         U$ )zSet the appropriate request path in project attribute for initializeHub requests.

Args:
  ref: reference to the membership object.
  args: command line arguments.
  request: API request to be issued

Returns:
  modified request
z/locations/global/memberships)projectrefargsrequests      Blib/googlecloudsdk/command_lib/container/fleet/memberships/util.pySetInitProjectPathr      s     
4OO&EE'/	.    c                     A UR                   R                  S5      nUS:X  a  [        SUR                   -  5      eUR                  S5      (       a&  UR                   SU S-   UR                  -   Ul         U$ UR                   SU S-   Ul         U$ )zSet parent collection with location for created resources.

Args:
  ref: reference to the membership object.
  args: command line arguments.
  request: API request to be issued

Returns:
  modified request
/zInvalid parent collection: %slocationNz/-)parentrfind
ValueErrorIsKnownAndSpecifiedr   )r   r   r   indexs       r   SetParentCollectionr   +   s     

..

s
#%
b[
4w~~E
FF	j))^^FU+c1DMMAGN 
. ^^FU+d2GN	.r   c                 
   A UR                  S5      (       aV  [        R                  " U5      (       a  [        R                  " U5      Ul        U$ [        R
                  " U5      Ul         U$ [        R                  " SS5      e)zSet membership location for requested resource.

Args:
  ref: reference to the membership object.
  args: command line arguments.
  request: API request to be issued

Returns:
  modified request

membership
MEMBERSHIPz(membership is required for this command.)r   r	   MembershipLocationSpecifiedMembershipResourceNamenameSearchMembershipResourcecalliope_exceptionsRequiredArgumentExceptionr   s      r   SetMembershipLocationr'   C   sz     
	l++,,T2255d;gl 
. 77=gl
 
. 
7
7@B Br   c                    A [         R                  " U5      (       a  [         R                  " U5      nO[         R                  " U5      nUR                  R                  5       n[        R                  " X#5      n/ nS=pgUR                  S5      (       a"  UR                  S5        UR                  S5      nU[        R
                  R                  :w  a8  UR                  S5      (       a"  UR                  S5        UR                  S5      nUR                  S5      (       d,  UR                  S5      (       d  UR                  S5      (       a  UR                  S	5        S
R                  U5      n[        R                  " UUUUUUUR                  S5      UR                  S5      UR                  S5      SSSUR                  S5      S9n	U	$ )zExecute update membership request.

Args:
  ref: API response from update membership call
  args: command line arguments.

Returns:
  response
Nexternal_id
externalId
infra_typeinfrastructureTypeclear_labelsupdate_labelsremove_labelslabels,async)	r)   r+   r-   r.   r/   
issuer_url	oidc_jwksapi_server_version
async_flag)r	   r!   r"   r$   calliope_commandReleaseTrackr   GetMembershipGetValueappendcalliope_baseGAjoinUpdateMembership)
r   r   r#   release_trackobjupdate_fieldsr)   r+   update_maskresponses
             r   ExecuteUpdateMembershipRequestrE   \   s    
**400++D1D--d3D ''446-t3#-!!+	]]=!!&--.Km003339 9-.|,J	]]>""dmm' '--88"'+&&
	==0MM/2MM/2w')( 
/r   c                     US;   a  SOSR                  U5      nU (       a  U S:X  a  SR                  U5      $ SU ;   a  SR                  U5      $ SU ;   a  S	R                  U5      $ [        R                  " S
5      e)a  Get the appropriate Connect Gateway endpoint.

This function checks the environment endpoint overide configuration for
Fleet and uses it to determine which Connect Gateway endpoint to use.
The overridden Fleet value will look like
https://autopush-gkehub.sandbox.googleapis.com/.

When there is no override set, this command will return a Connect Gateway
prod endpoint. When an override is set, an appropriate non-prod endpoint
will be provided instead.

For example, when the overridden value looks like
https://autopush-gkehub.sandbox.googleapis.com/,
the function will return
autopush-connectgateway.sandbox.googleapis.com.

Regional prefixes are supported via the location argument. For example, when
the overridden value looks like
https://autopush-gkehub.sandbox.googleapis.com/ and location is passed in as
"us-west1", the function will return
us-west1-autopush-connectgateway.sandbox.googleapis.com.

Args:
  endpoint_override: The URL set as the API endpoint override for 'gkehub'.
    None if the override is not set.
  location: The location against which the command is supposed to run. This
    will be used to dynamically modify the service name to a location-specific
    value. If this is the value 'global' or None, a global service name is
    returned.

Returns:
  The service name to use for this command invocation, optionally modified
  to target a specific location.

Raises:
  UnknownApiEndpointOverrideError if the Fleet API endpoint override is not
  one of the standard values.
)globalN z{}-zhttps://gkehub.googleapis.com/z{}connectgateway.googleapis.comzautopush-gkehubz0{}autopush-connectgateway.sandbox.googleapis.comzstaging-gkehubz/{}staging-connectgateway.sandbox.googleapis.comgkehub)formatr
   UnknownApiEndpointOverrideError)endpoint_overrider   prefixs      r   GetConnectGatewayServiceNamerN      s    R --25<<3I&
	>	> -33F;;--=DDVLL,,<CCFKK

0
0
::r   N)__doc__
__future__r   r   r   googlecloudsdk.callioper   r<   r   r%   *googlecloudsdk.command_lib.container.fleetr   r	   6googlecloudsdk.command_lib.container.fleet.membershipsr
   r   r   r'   rE   rN    r   r   <module>rU      s<    , &  ' 9 E ? @ I 020f5;r   