
    W0                         S r SSKJr  SSKJr  SSKJr  SSK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r " S S\5      rg)z7Base class for Anthos GKE On-Prem API client resources.    )absolute_import)division)unicode_literalsN)apis)arg_parsers)parser_extensions)gkeonprem_v1_client)gkeonprem_v1_messagesc                      \ rS rSrSrS(S jrS\R                  4S jrS(S\	R                  4S jjrS	 rS
 rS\	R                  4S jrS\	R                  4S jrS\	R                  4S jrS\	R                  4S jrS\	R                  4S jrS\	R                  4S jrS\	R                  4S jrS\	R                  4S jrS\	R                  4S jrS\	R                  4S jrS\	R                  4S jrS\	R                  4S jrS\	R                  4S jrS\	R                  4S jrS\	R                  4S jrS\	R                  4S jrS rS\	R                  4S jrS\	R                  4S jr S\	R                  4S jr!S\	R                  4S jr"S\	R                  4S  jr#S\	R                  4S! jr$S\	R                  4S" jr%S\	R                  SS4S# jr&S\	R                  4S$ jr'S\	R                  4S% jr(S\	R                  4S& jr)S'r*g))
ClientBase    z.Base class for Anthos GKE On-Prem API clients.Nc                 :    U R                  5       U l        Xl        g N)_get_client_instance_client_service)selfservices     8lib/googlecloudsdk/api_lib/container/gkeonprem/client.py__init__ClientBase.__init__#   s    ,,.DLM    returnc                 0    [         R                  " SS5      $ )zReturns the client instance.

Function created for IDE type hint only, inline type annotation is not
supported due to gcloud using a low Python3 version.
	gkeonpremv1)r   GetClientInstance)r   s    r   r   ClientBase._get_client_instance'   s     !!+t44r   argsc                 B    X!R                  5       ;   a  [        X5      $ U$ )a  Returns the flag value if it's set, otherwise returns None.

Args:
  args: An argparser Namespace class instance.
  flag: A string type flag name.
  default: The default value to return if not found in the argparser
    namespace.

Returns:
  The flag value if it is set by the user. If the flag is not added to the
  interface, or it is added by not specified by the user, returns the
  default value.
)GetSpecifiedArgsDictgetattr)r   r   flagdefaults       r   GetFlagClientBase.GetFlag/   s#     ((**T  nr   c                 r    UR                  5        H#  n[        U[        5      (       a    gU(       d  M#    g   g)a  Returns True if any of the kwargs is set to not None value.

The added condition handles the case when user specified boolean False
for the given args, and it should return True, which does not work with
normal Python identity comparison.

Args:
  kwargs: dict, a mapping from proto field to its respective constructor
    function.

Returns:
  True if there exists a field that contains a user specified argument.
TF)values
isinstancebool)r   kwargsvalues      r   IsSetClientBase.IsSetB   s1     	E4	 	 5	 !
 r   c                     U R                   R                  S5      " UR                  5       S9nU R                   R                  U5      $ )zGets a gkeonprem API resource.Get)name)r   GetRequestTypeRelativeNamer0   )r   resource_refreqs      r   DescribeClientBase.DescribeW   s9    
--
&
&u
-<3L3L3N
OC==S!!r   c                     [        UR                  SS5      (       a$  UR                  R                  R                  5       $ g)z@Parses user cluster resource argument and returns its reference.clusterN)r"   CONCEPTSr9   Parser   r   s     r   _user_cluster_refClientBase._user_cluster_ref\   s1    t}}i..]]""((**r   c                     [        UR                  SS5      (       a$  UR                  R                  R                  5       $ g)AParses admin cluster resource argument and returns its reference.admin_clusterN)r"   r:   rA   r;   r<   s     r   _admin_cluster_refClientBase._admin_cluster_refb   s1    t}}ot44]]((..00r   c                     [        UR                  SS5      (       a$  UR                  R                  R                  5       $ g)z<Parses location resource argument and returns its reference.locationN)r"   r:   rE   r;   r<   s     r   _location_refClientBase._location_refh   s1    t}}j$//]]##))++r   c                 T    U R                  U5      nU(       a  UR                  5       $ g)z/Parses location from args and returns its name.N)rF   r3   )r   r   location_refs      r   _location_nameClientBase._location_namen   s'    %%d+L&&((r   c                 T    U R                  U5      nU(       a  UR                  5       $ g)z3Parses user cluster from args and returns its name.N)r=   r3   r   r   user_cluster_refs      r   _user_cluster_nameClientBase._user_cluster_nameu   s(    --d3**,,r   c                 p    U R                  U5      nU(       a  UR                  5       R                  5       $ g)z:Parses user cluster from args and returns its parent name.N)r=   Parentr3   rM   s      r   _user_cluster_parentClientBase._user_cluster_parent|   s1    --d3$$&3355r   c                 T    U R                  U5      nU(       a  UR                  5       $ g)z1Parses user cluster from args and returns its ID.N)r=   NamerM   s      r   _user_cluster_idClientBase._user_cluster_id   s(    --d3""$$r   c                 T    U R                  U5      nU(       a  UR                  5       $ gz4Parses admin cluster from args and returns its name.N)rB   r3   r   r   admin_cluster_refs      r   _admin_cluster_nameClientBase._admin_cluster_name   s(    //5++--r   c                 p    U R                  U5      nU(       a  UR                  5       R                  5       $ g)z;Parses admin cluster from args and returns its parent name.N)rB   rR   r3   r[   s      r   _admin_cluster_parent ClientBase._admin_cluster_parent   s1    //5%%'4466r   c                 T    U R                  U5      nU(       a  UR                  5       $ g)z2Parses admin cluster from args and returns its ID.N)rB   rV   r[   s      r   _admin_cluster_idClientBase._admin_cluster_id   s(    //5##%%r   c                     [        UR                  SS5      (       a$  UR                  R                  R                  5       $ g)r@   admin_cluster_membershipN)r"   r:   rf   r;   r<   s     r   _admin_cluster_membership_ref(ClientBase._admin_cluster_membership_ref   s2    t}}8$??]]3399;;r   c                 T    U R                  U5      nU(       a  UR                  5       $ grZ   )rg   r3   r[   s      r   _admin_cluster_membership_name)ClientBase._admin_cluster_membership_name   s(    ::4@++--r   c                     [        UR                  SS5      (       a$  UR                  R                  R                  5       $ gz=Parses node pool resource argument and returns its reference.	node_poolNr"   r:   rn   r;   r<   s     r   _node_pool_refClientBase._node_pool_ref   s1    t}}k400]]$$**,,r   c                 T    U R                  U5      nU(       a  UR                  5       $ gz0Parses node pool from args and returns its name.N)rp   r3   r   r   node_pool_refs      r   _node_pool_nameClientBase._node_pool_name   s'    ''-M''))r   c                 T    U R                  U5      nU(       a  UR                  5       $ gz.Parses node pool from args and returns its ID.N)rp   rV   rt   s      r   _node_pool_idClientBase._node_pool_id   s)    ''-M!! r   c                 p    U R                  U5      nU(       a  UR                  5       R                  5       $ gz7Parses node pool from args and returns its parent name.N)rp   rR   r3   rt   s      r   _node_pool_parentClientBase._node_pool_parent   s0    ''-M!!#0022r   c                 .   [         R                  R                  nUR                  UR                  UR
                  S.nSR                  U5      nSR                  S [        UR                  5       5       5       5      n[        R                  " S5      nUR                  U5      nU(       d%  [        R                  " SR                  U5      5      eUR                  5       u  pn
X;  a%  [        R                  " SR                  XE5      5      eUU	X:   S.$ )	az  Validates and parses a node taint object.

Args:
  node_taint: tuple, of format (TAINT_KEY, value), where value is a string
    of format TAINT_VALUE:EFFECT.

Returns:
  If taint is valid, returns a dict mapping message NodeTaint to its value;
  otherwise, raise ArgumentTypeError.
  For example,
  {
      'key': TAINT_KEY
      'value': TAINT_VALUE
      'effect': EFFECT
  }
)
NoSchedulePreferNoSchedule	NoExecute=z, c              3   N   #    U  H  n[         R                  " U5      v   M     g 7fr   )six	text_type).0keys     r   	<genexpr>/ClientBase._parse_node_taint.<locals>.<genexpr>   s       )&Isc&Is   #%z2([a-zA-Z0-9-_]*)=([a-zA-Z0-9-_]*):([a-zA-Z0-9-_]*)z?Node taint [{}] not in correct format, expect KEY=VALUE:EFFECT.z1Invalid taint effect in [{}] , expect one of [{}])r   r,   effect)messages	NodeTaintEffectValueValuesEnumNO_SCHEDULEPREFER_NO_SCHEDULE
NO_EXECUTEjoinsortedkeysrecompile	fullmatchr   ArgumentTypeErrorformatgroups)r   
node_tainttaint_effect_enumtaint_effect_mappinginput_node_taintvalid_node_taint_effectstaint_patterntaint_match	taint_keytaint_valuetaint_effects              r   _parse_node_taintClientBase._parse_node_taint   s   " !**@@'33-@@&11 xx
+#yy )&,-A-F-F-H&I)   JJ=M  ))*:;K))
K6"#  ,7+=+=+?(IL/))
=
D
D  &4 r   c                     [        UR                  SS5      (       a$  UR                  R                  R                  5       $ g)FParses standalone cluster resource argument and returns its reference.standalone_clusterN)r"   r:   r   r;   r<   s     r   _standalone_cluster_ref"ClientBase._standalone_cluster_ref   s2    t}}2D99]]--3355r   c                 T    U R                  U5      nU(       a  UR                  5       $ gz9Parses standalone cluster from args and returns its name.N)r   r3   r   r   standalone_cluster_refs      r   _standalone_cluster_name#ClientBase._standalone_cluster_name   s(    !99$?#0022r   c                 p    U R                  U5      nU(       a  UR                  5       R                  5       $ g)z@Parses standalone cluster from args and returns its parent name.N)r   rR   r3   r   s      r   _standalone_cluster_parent%ClientBase._standalone_cluster_parent  s1    !99$?#**,99;;r   c                 T    U R                  U5      nU(       a  UR                  5       $ g)zAParses standalone cluster from the given args and returns its ID.N)r   rV   r   s      r   _standalone_cluster_id!ClientBase._standalone_cluster_id  s(    !99$?#((**r   c                     [        UR                  SS5      (       a$  UR                  R                  R                  5       $ g)r   
membershipN)r"   r:   r   r;   r<   s     r   "_standalone_cluster_membership_ref-ClientBase._standalone_cluster_membership_ref  s3     t}}lD11]]%%++--r   c                 T    U R                  U5      nU(       a  UR                  5       $ gr   )r   r3   r   s      r   #_standalone_cluster_membership_name.ClientBase._standalone_cluster_membership_name  s*     "DDTJ#0022r   c                     [        UR                  SS5      (       a$  UR                  R                  R                  5       $ grm   ro   r<   s     r   _standalone_node_pool_ref$ClientBase._standalone_node_pool_ref&  s3    t}}k400]]$$**,, 1r   c                 T    U R                  U5      nU(       a  UR                  5       $ grs   )r   r3   rt   s      r   _standalone_node_pool_name%ClientBase._standalone_node_pool_name+  s)     2248M''))r   c                 T    U R                  U5      nU(       a  UR                  5       $ gry   )r   rV   rt   s      r   _standalone_node_pool_id#ClientBase._standalone_node_pool_id4  s)    2248M!! r   c                 p    U R                  U5      nU(       a  UR                  5       R                  5       $ gr}   )r   rR   r3   rt   s      r   _standalone_node_pool_parent'ClientBase._standalone_node_pool_parent:  s0    2248M!!#0022r   c                     U R                  US5      nUc  g[        R                  R                  U5      n[        R                  " US9$ )z<Parses binary authorization from args and returns its value.binauthz_evaluation_modeN)evaluationMode)r%   r   BinaryAuthorizationEvaluationModeValueValuesEnum)r   r   evaluation_modemodes       r   _binary_authorization ClientBase._binary_authorizationA  sH    ll4)CDO''EED ''t<<r   )r   r   r   )+__name__
__module____qualname____firstlineno____doc__r   clientGkeonpremV1r   r   	Namespacer%   r-   r6   r=   rB   rF   rJ   rO   rS   rW   r]   r`   rc   rg   rj   rp   rv   rz   r~   r   r   r   r   r   r   r   r   r   r   r   r   __static_attributes__ r   r   r   r       sH   65F$6$6 5+55 &*"
$5$?$? %6%@%@  1 ; ; !2!<!< %6%@%@ '8'B'B #4#>#> &7&A&A (9(C(C $5$?$? 0A0K0K 1B1L1L !2!<!< "3"="= " 1 ; ; "$5$?$? 2h*;*E*E +<+F+F ->-H-H ):)D)D #--#---,=,G,G -
#--"+<+F+F "/@/J/J =(9(C(C =r   r   )r   
__future__r   r   r   r   googlecloudsdk.api_lib.utilr   googlecloudsdk.callioper   r   2googlecloudsdk.generated_clients.apis.gkeonprem.v1r	   r   r
   r   r   objectr   r   r   r   <module>r      s6    > &  ' 	 , / 5 \ ` 
i= i=r   