
    "                         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
 r " S S\
R                  5      rSS0\l        g)zCommand for deprecating images.    )absolute_import)division)unicode_literalsN)base_classes)arg_parsers)base)flagsc                     U (       a  U $ U(       a2  U[         R                  " US9-   R                  SS9R                  5       $ g)zFGet the RFC 3339 time string for a provided absolute or relative time.)secondsr   )microsecondN)datetime	timedeltareplace	isoformat)absoluterelative_seccurrent_times      'lib/surface/compute/images/deprecate.py_ResolveTimer      s>     Ox)),??g!gYY[)     c                   .    \ rS rSrSr\S 5       rS rSrg)DeprecateImages.   z^Manage deprecation status of Compute Engine images.

*{command}* is used to deprecate images.
c           	         [         R                  " 5       [        l        [        R                  R	                  U 5        [         R
                  R	                  U 5        SSSSS.nU R                  SUSS S	S
S9  U R                  5       nUR                  SSS9  UR                  S[        R                  " 5       SS9  U R                  5       nUR                  SSS9  UR                  S[        R                  " 5       SS9  U R                  5       nUR                  SSS9  UR                  S[        R                  " 5       SS9  g )Nz!The image is currently supported.zNew uses result in an error. Setting this state will not automatically delete the image. You must still make a request to delete the image to remove it from the image list.zOperations which create a new *DEPRECATED* resource return successfully, but with a warning indicating that the image is deprecated and recommending its replacement.zNew uses result in an error.)ACTIVEDELETED
DEPRECATEDOBSOLETEz--stater   c                 "    U R                  5       $ )N)upper)xs    r   <lambda>&DeprecateImages.Args.<locals>.<lambda>K   s
    qwwyr   Tz*The deprecation state to set on the image.)choicesdefaulttyperequiredhelpz--deprecate-ona          Specifies a date when the image should be marked as DEPRECATED.

        Note: This is only informational and the image will not be deprecated unless you manually deprecate it.

        This flag is mutually exclusive with *--deprecate-in*.

        The date and time specified must be valid RFC 3339 full-date or date-time.
        For times in UTC, this looks like ``YYYY-MM-DDTHH:MM:SSZ''.
        For example: 2020-01-02T00:00:00Z for midnight on January 2, 2020 in UTC.
        )r(   z--deprecate-ina/          Specifies a time duration in which the image should be marked as ``DEPRECATED''.

        Note: This is only informational and the image will not be deprecated unless you manually deprecate it.

        This flag is mutually exclusive with *--deprecate-on*.

        For example, specifying ``30d'' sets the planned ``DEPRECATED'' date to 30 days from the current system time,
        but does not deprecate the image. You must manually deprecate the image in 30 days.
        See $ gcloud topic datetimes for information on duration formats.

       )r&   r(   z--delete-ona          Specifies a date when the image should be marked as ``DELETED''.

        Note: This is only informational and the image will not be deleted unless you manually delete it.

        This flag is mutually exclusive with *--delete-in*.

        The date and time specified must be valid RFC 3339 full-date or date-time.
        For times in UTC, this looks like ``YYYY-MM-DDTHH:MM:SSZ''.
        For example: 2020-01-02T00:00:00Z for midnight on January 2, 2020 in UTC.

        z--delete-ina          Specifies a time duration in which the image should be marked as ``DELETED''.

        Note: This is only informational and the image will not be deleted unless you manually delete it.

        For example, specifying ``30d'' sets the planned ``DELETED'' time to 30 days from the current system time,
        but does not delete the image. You must manually delete the image in 30 days.
        See $ gcloud topic datetimes for information on duration formats.

        This flag is mutually exclusive with *--delete-on*.
       z--obsolete-ona          Specifies a date when the image should be marked as ``OBSOLETE''.

        Note: This is only informational and the image will not be obsoleted unless you manually obsolete it.

        This flag is mutually exclusive with *--obsolete-in*.

        The date and time specified must be valid RFC 3339 full-date or date-time.
        For times in UTC, this looks like ``YYYY-MM-DDTHH:MM:SSZ''.
        For example: 2020-01-02T00:00:00Z for midnight on January 2, 2020 in UTC.
       z--obsolete-ina&          Specifies a time duration in which the image should be marked as ``OBSOLETE''.

        Note: This is only informational and the image will not be obsoleted unless you manually obsolete it.

        This flag is mutually exclusive with *--obsolete-on*.

        For example, specifying ``30d'' sets the planned ``OBSOLETE'' time to 30 days from the current system time,
        but does not obsolete the image. You must manually obsolete the image in 30 days.
        See $ gcloud topic datetimes for information on duration formats.
        )
r	   MakeDiskImageArgr   DISK_IMAGE_ARGAddArgumentREPLACEMENT_DISK_IMAGE_ARGadd_argumentadd_mutually_exclusive_groupr   Duration)parserdeprecation_statusesdeprecate_groupdelete_groupobsolete_groups        r   ArgsDeprecateImages.Args4   s{   %*%;%;%=O"""..v6	$$008 6A; 3 $ 9  ; 99;O  
 !    !!# !   668L   !!#
   88:N
    !!#
   r   c           
         [         R                  " U R                  5       5      nUR                  n[        R                  R                  5       n[        UR                  UR                  U5      n[        UR                  UR                  U5      n[        UR                  UR                  U5      nUR                  R                  R                  UR                   5      n["        R$                  R'                  XR(                  5      n	U	(       a  U	R+                  5       n
OSn
[,        R.                  R'                  XR(                  5      nUR                  R1                  UR                  R                  UUUUU
S9UR3                  5       UR4                  S9nUR7                  UR8                  R:                  SU4/5      $ )z2Invokes requests necessary for deprecating images.N)statedeletedobsolete
deprecatedreplacement)deprecationStatusimageproject	Deprecate)r   ComputeApiHolderReleaseTrackclientr   nowr   	delete_on	delete_inobsolete_onobsolete_indeprecate_ondeprecate_inmessagesDeprecationStatusStateValueValuesEnumr8   r	   r,   ResolveAsResource	resourcesSelfLinkr   r*   ComputeImagesDeprecateRequestNamer?   MakeRequestsapitools_clientimages)selfargsholderrC   r   delete_timeobsolete_timedeprecate_timer8   replacement_refreplacement_uri	image_refrequests                r   RunDeprecateImages.Run   s    **4+<+<+>?F]]F $$((*Lt~~t~~|LK $**L:M!4,,l<N OO--BB4::NE66HH O'002oo..@@ I oo;; //;;"%' < ) nn!! < #G !7!7!>!>!,g!7  8 9 9r    N)	__name__
__module____qualname____firstlineno____doc__staticmethodr5   r`   __static_attributes__rb   r   r   r   r   .   s#    
 w wr*9r   r   EXAMPLESaN  
To deprecate an image called 'IMAGE' immediately, mark it as
obsolete in one day, and mark it as deleted in two days, use:

  $ {command} IMAGE --state=DEPRECATED --obsolete-in=1d --delete-in=2d

To un-deprecate an image called 'IMAGE' and clear times for deprecated,
obsoleted, and deleted, use:

  $ {command} IMAGE --state=ACTIVE
)rg   
__future__r   r   r   r   googlecloudsdk.api_lib.computer   googlecloudsdk.callioper   r   )googlecloudsdk.command_lib.compute.imagesr	   r   SilentCommandr   detailed_helprb   r   r   <module>rq      sP    & &  '  7 / ( ;"j9d(( j9\  
! r   