
    8>                        S r SSKrSSKrSSKJrJr  SSKJr   \R                  r	\R                  S-   rSrSrSrS	rS
rSrSrSrSrSrSrSrSrSrSr " S S\R8                  5      r " S S\5      r " S S\	R@                  5      r! " S S\RD                  5      r# " S S\RD                  5      r$ " S S \RD                  5      r% " S! S"\RL                  5      r'g! \
 a    \r	 Nf = f)#zCWraps a resource message with a container with convenience methods.    N)MappingSequence)
k8s_objectz/cloudsql-instancesz'run.googleapis.com/vpc-access-connectorz(run.googleapis.com/execution-environmentz!run.googleapis.com/encryption-keyz2run.googleapis.com/post-key-revocation-action-typez0run.googleapis.com/encryption-key-shutdown-hourszrun.googleapis.com/secretsz!run.googleapis.com/cpu-throttlingz$run.googleapis.com/startup-cpu-boostz(run.googleapis.com/health-check-disabledz'run.googleapis.com/invoker-iam-disabledz'run.googleapis.com/default-url-disabledz$run.googleapis.com/vpc-access-egressallzall-trafficzprivate-ranges-onlyc                      \ rS rSrSr\S 5       r\S 5       r\R                  S 5       r\S 5       r	\S 5       r
\S 5       r\S	 5       r\S
 5       r\S\\\\   4   4S j5       r\R                  S\\\\   4   4S j5       rSrg)ContainerResource5   a  Wraps a resource message with a container, making fields more convenient.

Provides convience fields for Cloud Run resources that contain a container.
These resources also typically have other overlapping fields such as volumes
which are also handled by this wrapper.
c                 .    U R                   R                  $ zReturns a mutable, dict-like object to manage env vars.

The returned object can be used like a dictionary, and any modifications to
the returned object (i.e. setting and deleting keys) modify the underlying
nested env vars fields.
)	containerenv_varsselfs    4lib/googlecloudsdk/api_lib/run/container_resource.pyr   ContainerResource.env_vars=   s     >>"""    c                 .    U R                   R                  $ )zURL to container.r   imager   s    r   r   ContainerResource.imageG   s     >>r   c                 $    XR                   l        g Nr   )r   values     r   r   r   L   s     NNr   c                 .    U R                   R                  $ )z#command to be invoked by container.)r   commandr   s    r   r   ContainerResource.commandP   s     >>!!!r   c                 0   U R                   R                  5       nU(       d  U R                   S   $ [        U5      S:X  a  [        [	        U5      5      $ U R
                  S:X  a  [        S5      eU H  nUR                  (       d  M  Us  $    [        S5      e)z&The container in the revisionTemplate.    TaskTemplateSpecz_the target job has multiple containers, a container name must be specified via --container flagzmissing ingress container)
containersvalueslennextiterKIND
ValueErrorports)r   r!   r   s      r   r   ContainerResource.containerU   s     '')J__R  
:!$z"##yy&&, 
  		   0
11r   c                 l    [        U R                  R                  U R                  U R                  5      $ )z'The containers in the revisionTemplate.)ContainersAsDictionaryWrapperspecr!   volumes	_messagesr   s    r   r!   ContainerResource.containersk   s*     )		dllDNN r   c                 .    U R                   R                  $ )<The resource limits as a dictionary { resource name: limit}.)r   resource_limitsr   s    r   r2   !ContainerResource.resource_limitsr   s     >>)))r   c                 j    [        U R                  R                  U R                  R                  5      $ )aQ  Returns a dict-like object to manage volumes.

There are additional properties on the object (e.g. `.secrets`) that can
be used to access a mutable, dict-like object for managing volumes of a
given type. Any modifications to the returned object for these properties
(i.e. setting and deleting keys) modify the underlying nested volumes.
)VolumesAsDictionaryWrapperr,   r-   r.   Volumer   s    r   r-   ContainerResource.volumesw   s%     &dii&7&79N9NOOr   returnc                     0 n[         R                  U R                  ;   a1  [        R                  " U R                  [         R                     5      nU$ )al  Returns a dictionary of container dependencies.

Container dependencies are stored in the
'run.googleapis.com/container-dependencies' annotation. The returned
dictionary maps containers to a list of their dependencies by name. Note
that updates to the returned dictionary do not update the resource's
container dependencies unless the dependencies setter is used.
)r   !CONTAINER_DEPENDENCIES_ANNOTATIONannotationsjsonloads)r   dependenciess     r   r>   ContainerResource.dependencies   sG     L33t7G7GGZZ


:GG
Hl r   r>   c           
      P   U(       a_  [         R                  " UR                  5        VVs0 s H  u  p#U[        U5      _M     snn5      U R                  [
        R                  '   g[
        R                  U R                  ;   a  U R                  [
        R                  	 ggs  snnf )a;  Sets the resource's container dependencies.

Args:
  dependencies: A dictionary mapping containers to a list of their
    dependencies by name.

Container dependencies are stored in the
'run.googleapis.com/container-dependencies' annotation as json. Setting an
empty set of dependencies will clear this annotation.
N)r<   dumpsitemslistr;   r   r:   )r   r>   kvs       r   r>   r?      s     
**\-?-?-AB-ATQaaj-AB
C zCCD 
	5	59I9I	I


:GG
H 
J Cs   B"
 N)__name__
__module____qualname____firstlineno____doc__propertyr   r   setterr   r   r!   r2   r-   r   strr   r>   __static_attributes__rF   r   r   r   r   5   s    # #     	<<! ! " " 2 2*   * * P P GC#$67    IwsHSM/A'B I Ir   r   c                   ~    \ rS rSrSrSS jr\S 5       r\S 5       rS r	\S 5       r
S	 rS
 rS rSS jrSS jrSrg)	Container   zWraps a container message with dict-like wrappers for env_vars, volume_mounts, and resource_limits.

All other properties are delegated to the underlying container message.
Nc                     U(       d  UR                   " S0 UD6n[        R                  U SU5        [        R                  U SU5        [        R                  U SU5        g )N_volumesr.   _mrF   )rQ   object__setattr__)r   r-   messages_modr   kwargss        r   __init__Container.__init__   sN    ((262i
tZ1
t[,7
tT9-r   c                 j    [        U R                  R                  U R                  R                  5      $ r   )EnvVarsAsDictionaryWrapperrU   envr.   EnvVarr   s    r   r   Container.env_vars   s#     &dggkk4>>3H3HIIr   c                     [        U R                  U R                  R                  U R                  R
                  5      $ )a  Returns a mutable, dict-like object to manage volume mounts.

The returned object can be used like a dictionary, and any modifications to
the returned object (i.e. setting and deleting keys) modify the underlying
nested volume mounts. There are additional properties on the object
(e.g. `.secrets` that can be used to access a mutable dict-like object for
a volume mounts that mount volumes of a given type.
)VolumeMountsAsDictionaryWrapperrT   rU   volumeMountsr.   VolumeMountr   s    r   volume_mountsContainer.volume_mounts   s0     +tww++T^^-G-G r   c                 8   U R                   R                  R                  nU R                  b>  U R                  R                  c&  [
        R                  " U5      U R                  l        g g [
        R                  " U R                   R                  5      U l        g r   )r.   ResourceRequirementsLimitsValue	resourceslimitsr   InitializedInstance)r   
limits_clss     r   _EnsureResourcesContainer._EnsureResources   sn    44@@J~~!				& * > >z J 
' "55
..
-
-dnr   c                     U R                  5         [        R                  " U R                  R                  R
                  U R                  R                  R                  R                  SSS9$ )r1   keyr   	key_fieldvalue_field)
rn   r   KeyValueListAsDictionaryWrapperrj   rk   additionalPropertiesr.   rh   ri   AdditionalPropertyr   s    r   r2   Container.resource_limits   sU     	5522++77JJ	 r   c                     U R                   $ r   )rU   r   s    r   MakeSerializableContainer.MakeSerializable   s    77Nr   c                 .    [        U R                  U5      $ r   )getattrrU   )r   names     r   __getattr__Container.__getattr__   s    477D!!r   c                 0    [        U R                  X5        g r   )setattrrU   )r   r~   r   s      r   rW   Container.__setattr__   s    DGGT!r   c                     U R                   nU R                  nU(       a  [        X!5      n[        X15      nUR                  5        VVs0 s H  u  pEXBR	                  U5      _M     snn$ s  snnf r   rT   re   r}   rB   getr   subgroupvolsmountspathvols         r   MountedVolumeJoinContainer.MountedVolumeJoin   sX    ==DFT$dv(f17@IDD((3-@@@s   	A*c           	          U R                   nU R                  nU(       a  [        X!5      n[        X15      nUR                  5        VVs0 s H  u  pEXEUR	                  U5      4_M     snn$ s  snnf r   r   r   s         r   NamedMountedVolumeJoin Container.NamedMountedVolumeJoin   s]    ==DFT$dv(f8>G94D&&GGGs   	A,)rj   r   )rG   rH   rI   rJ   rK   rZ   rL   r   re   rn   r2   rz   r   rW   r   r   rO   rF   r   r   rQ   rQ      sj    
. J J    ""AHr   rQ   c                   P   ^  \ rS rSrSrU 4S jrS rS rS rS r	S r
S	 rS
rU =r$ )ContainerSequenceWrapper   zRWraps a list of containers wrapping each element with the Container wrapper class.c                 N   > [         [        U ]  5         Xl        X l        X0l        g r   )superr   rZ   _containersrT   r.   r   containers_to_wrapr-   rX   	__class__s       r   rZ   !ContainerSequenceWrapper.__init__   s!    	
"D24)M!Nr   c                 ^    [        U R                  U R                  U R                  U   5      $ r   )rQ   rT   r.   r   r   indexs     r   __getitem__$ContainerSequenceWrapper.__getitem__  s$    T]]DNND4D4DU4KLLr   c                 ,    [        U R                  5      $ r   )r#   r   r   s    r   __len__ ContainerSequenceWrapper.__len__  s    t  r   c                 >    UR                  5       U R                  U'   g r   )rz   r   )r   r   r   s      r   __setitem__$ContainerSequenceWrapper.__setitem__
  s    '88:DUr   c                     U R                   U	 g r   r   r   s     r   __delitem__$ContainerSequenceWrapper.__delitem__  s    r   c                 V    U R                   R                  XR                  5       5        g r   )r   insertrz   )r   r   r   s      r   r   ContainerSequenceWrapper.insert  s    E#9#9#;<r   c                     U R                   $ r   r   r   s    r   rz   )ContainerSequenceWrapper.MakeSerializable  s    r   )r   r.   rT   )rG   rH   rI   rJ   rK   rZ   r   r   r   r   r   rz   rO   __classcell__r   s   @r   r   r      s/    Z"M!; = r   r   c                   D   ^  \ rS rSrSrU 4S jrU 4S jrU 4S jrSrU =r	$ )r+   i  zWraps a list of containers in a mutable dict-like object mapping containers by name.

Accessing a container name that does not exist will automatically add a new
container with the specified name to the underlying list.
c                 X   > X l         X0l        [        [        U ]  [        XU5      5        g)a  Wraps a list of containers in a mutable dict-like object.

Args:
  containers_to_wrap: list[Container], list of containers to treat as a
    dict.
  volumes: the volumes defined in the containing resource used to classify
    volume mounts
  messages_mod: the messages module
N)rT   r.   r   r+   rZ   r   r   s       r   rZ   &ContainersAsDictionaryWrapper.__init__  s*     M!N	
'7 !3lKr   c                    >  [         [        U ]  U5      $ ! [         a?    [	        U R
                  U R                  US9nU R                  R                  U5        Us $ f = f)N)r~   )	r   r+   r   KeyErrorrQ   rT   r.   rU   append)r   rq   r   r   s      r   r   )ContainersAsDictionaryWrapper.__getitem__.  sV    0$CCHH DMM4>>Di
ggnnYs    AAAc                 D   > [         [        U ]  5       R                  5       $ r   )r   r+   rz   )r   r   s    r   rz   .ContainersAsDictionaryWrapper.MakeSerializable6  s!    +T 					r   )r.   rT   )
rG   rH   rI   rJ   rK   rZ   r   rz   rO   r   r   s   @r   r+   r+     s      r   r+   c                   \   ^  \ rS rSrSrU 4S jr\S 5       r\S 5       r\S 5       r	Sr
U =r$ )r]   i>  zWraps a list of env vars in a dict-like object.

Additionally provides properties to access env vars of specific type in a
mutable dict-like object.
c                 D   > [         [        U ]  U5        Xl        X l        g)zWraps a list of env vars in a dict-like object.

Args:
  env_vars_to_wrap: list[EnvVar], list of env vars to treat as a dict.
  env_var_class: type of the underlying EnvVar objects.
N)r   r]   rZ   	_env_vars_env_var_class)r   env_vars_to_wrapenv_var_classr   s      r   rZ   #EnvVarsAsDictionaryWrapper.__init__E  s!     

$d45EF%N'r   c                 X    [         R                  " U R                  U R                  S S9$ )zMutable dict-like object for env vars with a string literal.

Note that if neither value nor valueFrom is specified, the list entry will
be treated as a literal empty string.

Returns:
  A mutable, dict-like object for managing string literal env vars.
c                     U R                   S L $ r   )	valueFromenv_vars    r   <lambda>5EnvVarsAsDictionaryWrapper.literals.<locals>.<lambda>]  s    G$5$5$=r   )filter_funcr   ru   r   r   r   s    r   literals#EnvVarsAsDictionaryWrapper.literalsP  s*     55= r   c                 ^    S n[         R                  " U R                  U R                  SUS9$ )z<Mutable dict-like object for vars with a secret source type.c                 \    U R                   S L=(       a    U R                   R                  S L$ r   )r   secretKeyRefr   s    r   _FilterSecretEnvVars@EnvVarsAsDictionaryWrapper.secrets.<locals>._FilterSecretEnvVarsd  s.    


4
' 9,,D8r   r   rt   r   r   )r   r   s     r   secrets"EnvVarsAsDictionaryWrapper.secrets`  s2     55(	 r   c                 ^    S n[         R                  " U R                  U R                  SUS9$ )z@Mutable dict-like object for vars with a config map source type.c                 \    U R                   S L=(       a    U R                   R                  S L$ r   )r   configMapKeyRefr   s    r   _FilterConfigMapEnvVarsGEnvVarsAsDictionaryWrapper.config_maps.<locals>._FilterConfigMapEnvVarsu  s.    


4
' <//t;r   r   r   r   )r   r   s     r   config_maps&EnvVarsAsDictionaryWrapper.config_mapsq  s2     55+	 r   )r   r   )rG   rH   rI   rJ   rK   rZ   rL   r   r   r   rO   r   r   s   @r   r]   r]   >  sI    	(       r   r]   c                   L   ^  \ rS rSrSrU 4S jr\S 5       r\S 5       rSr	U =r
$ )r5   i  zWraps a list of volumes in a dict-like object.

Additionally provides properties to access volumes of specific type in a
mutable dict-like object.
c                 D   > [         [        U ]  U5        Xl        X l        g)zWraps a list of volumes in a dict-like object.

Args:
  volumes_to_wrap: list[Volume], list of volumes to treat as a dict.
  volume_class: type of the underlying Volume objects.
N)r   r5   rZ   rT   _volume_class)r   volumes_to_wrapvolume_classr   s      r   rZ   #VolumesAsDictionaryWrapper.__init__  s      

$d4_E#M%r   c                 Z    [         R                  " U R                  U R                  SS S9$ )z?Mutable dict-like object for volumes with a secret source type.secretc                     U R                   S L$ r   )r   volumes    r   r   4VolumesAsDictionaryWrapper.secrets.<locals>.<lambda>  s    6==#<r   r   r   ru   rT   r   r   s    r   r   "VolumesAsDictionaryWrapper.secrets  s-     55<	 r   c                 Z    [         R                  " U R                  U R                  SS S9$ )zCMutable dict-like object for volumes with a config map source type.	configMapc                     U R                   S L$ r   )r   r   s    r   r   8VolumesAsDictionaryWrapper.config_maps.<locals>.<lambda>  s    6#3#34#?r   r   r   r   s    r   r   &VolumesAsDictionaryWrapper.config_maps  s-     55?	 r   )r   rT   rG   rH   rI   rJ   rK   rZ   rL   r   r   rO   r   r   s   @r   r5   r5     s5    	&    r   r5   c                   L   ^  \ rS rSrSrU 4S jr\S 5       r\S 5       rSr	U =r
$ )rb   i  zWraps a list of volume mounts in a mutable dict-like object.

Additionally provides properties to access mounts that are mounting volumes
of specific type in a mutable dict-like object.
c                 :   > [         [        U ]  UUSSS9  Xl        g)zWraps a list of volume mounts in a mutable dict-like object.

Args:
  volumes: associated VolumesAsDictionaryWrapper obj
  mounts_to_wrap: list[VolumeMount], list of mounts to treat as a dict.
  mount_class: type of the underlying VolumeMount objects.
	mountPathr~   rr   N)r   rb   rZ   rT   )r   r-   mounts_to_wrapmount_classr   s       r   rZ   (VolumeMountsAsDictionaryWrapper.__init__  s-     

)49	 :  Mr   c                    ^  [         R                  " T R                  T R                  T R                  T R
                  U 4S jS9$ )zLMutable dict-like object for mounts whose volumes have a secret source type.c                 J   > U R                   TR                  R                  ;   $ r   )r~   rT   r   mountr   s    r   r   9VolumeMountsAsDictionaryWrapper.secrets.<locals>.<lambda>  s    %**0E0E"Er   rs   rt   r   r   ru   rU   _item_class
_key_field_value_fieldr   s   `r   r   'VolumeMountsAsDictionaryWrapper.secrets  s;     55//%%E r   c                    ^  [         R                  " T R                  T R                  T R                  T R
                  U 4S jS9$ )zPMutable dict-like object for mounts whose volumes have a config map source type.c                 J   > U R                   TR                  R                  ;   $ r   )r~   rT   r   r   s    r   r   =VolumeMountsAsDictionaryWrapper.config_maps.<locals>.<lambda>  s    %**0I0I"Ir   r   r   r   s   `r   r   +VolumeMountsAsDictionaryWrapper.config_maps  s;     55//%%I r   )rT   r   r   s   @r   rb   rb     s5         r   rb   )(rK   collectionsr<   typingr   r   googlecloudsdk.api_lib.runr   abccollections_abcAttributeError	RUN_GROUPCLOUDSQL_ANNOTATIONVPC_ACCESS_ANNOTATIONSANDBOX_ANNOTATIONCMEK_KEY_ANNOTATION/POST_CMEK_KEY_REVOCATION_ACTION_TYPE_ANNOTATION(ENCRYPTION_KEY_SHUTDOWN_HOURS_ANNOTATIONSECRETS_ANNOTATIONCPU_THROTTLE_ANNOTATIONCOLD_START_BOOST_ANNOTATIONDISABLE_HEALTH_CHECK_ANNOTATIONDISABLE_IAM_ANNOTATIONDISABLE_URL_ANNOTATIONEGRESS_SETTINGS_ANNOTATIONEGRESS_SETTINGS_ALLEGRESS_SETTINGS_ALL_TRAFFIC#EGRESS_SETTINGS_PRIVATE_RANGES_ONLYKubernetesObjectr   rV   rQ   MutableSequencer   ListAsDictionaryWrapperr+   r]   r5   ru   rb   rF   r   r   <module>r     s<   J   $ 1 OO/ !**-BB A ? 9 8 0 7 ) 2 = D "L B B C  + &; #oI
33 oIdQH QHh>> 8$J$F$F $NB!C!C BJ$!C!C $N-..-_   / s   C C('C(