
    [                         d 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  G d	 d
ej                        Zy)z$Update a rotation schedule on a key.    )absolute_import)division)unicode_literals)base)
exceptions)flags)resource_argsc                   &    e Zd ZdZed        Zd Zy)SetRotationSchedulea  Update the rotation schedule for a key.

  Updates the rotation schedule for the given key. The schedule
  automatically creates a new primary version for the key
  according to the `--next-rotation-time` and `--rotation-period` flags.

  The flag `--next-rotation-time` must be in ISO or RFC3339 format,
  and `--rotation-period` must be in the form INTEGER[UNIT], where units
  can be one of seconds (s), minutes (m), hours (h) or days (d).

  Key rotations performed manually via `update-primary-version` and the
  version `create` do not affect the stored `--next-rotation-time`.

  ## EXAMPLES

  The following command sets a 30 day rotation period for the key
  named `frodo` within the keyring `fellowship` and location `global`
  starting at the specified time:

    $ {command} frodo \
        --location=global \
        --keyring=fellowship \
        --rotation-period=30d \
        --next-rotation-time=2017-10-12T12:34:56.1234Z
  c                     t        j                  | dd       t        j                  |        t        j                  |        y )NTkey)r	   AddKmsKeyResourceArgForKMSr   AddRotationPeriodFlagAddNextRotationTimeFlag)parsers    -lib/surface/kms/keys/set_rotation_schedule.pyArgszSetRotationSchedule.Args7   s0    ,,VT5A	'	!!&)    c                 b   t        j                         }t        j                         }t        j                  |      }|j                  |j                         |j                               }t        j                  ||j                         t        j                  ||j                         g }|j                  |j                  d       |j                  |j                  d       |st        j                  d      dj!                  |      |_        |j$                  j'                  |      S )N)name	cryptoKeyrotationPeriodnextRotationTimezLAt least one of --next-rotation-time or --rotation-period must be specified.,)cloudkms_baseGetClientInstanceGetMessagesModuler   ParseCryptoKeyName7CloudkmsProjectsLocationsKeyRingsCryptoKeysPatchRequestRelativeName	CryptoKeySetNextRotationTimer   SetRotationPeriodrotation_periodappendnext_rotation_timer   ArgumentErrorjoin
updateMask&projects_locations_keyRings_cryptoKeysPatch)selfargsclientmessagescrypto_key_refreqfields_to_updates          r   RunzSetRotationSchedule.Run=   s   ,,.F..0H--d3N

J
J((*$$& K (C 
dCMM2	D#--0'./*01$$  XX./CN88>>sCCr   N)__name__
__module____qualname____doc__staticmethodr   r3    r   r   r   r      s!    4 * *
Dr   r   N)r7   
__future__r   r   r   googlecloudsdk.api_lib.cloudkmsr   r   googlecloudsdk.calliopegooglecloudsdk.command_lib.kmsr   r   r	   UpdateCommandr   r9   r   r   <module>r?      s6    + &  ' A ( 5 0 89D$,, 9Dr   