
                             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 the EkmConfig.    )absolute_import)division)unicode_literals)base)
exceptions)flags)resource_argsc                   ,    e Zd ZdZed        Zd Zd Zy)UpdateaP  Update the EkmConfig.

  {command} can be used to update the EkmConfig. Applies to all CryptoKeys and
  CryptoKeyVersions with a `protection level` of `external vpc`.

  ## EXAMPLES

  The following command sets the default ekm-connection to `laplace` for its
  project `foo` and location `us-east1`:

    $ {command} --location=us-east1
    --default-ekm-connection="projects/foo/locations/us-east1/ekmConnections/laplace"

  The following command removes the default-ekm-connection in `us-east1` for the
  current project:

  $ {command} --location=us-east1 --default-ekm-connection=""


  c                 \    t        j                  |        t        j                  | dd       y )NTz
--location)r   AddDefaultEkmConnectionFlagr	   AddKmsLocationResourceArgForKMS)parsers    $lib/surface/kms/ekm_config/update.pyArgszUpdate.Args2   s"    	%%f-11&$M    c                 `    |}||_         |j                  |j                  |      }d|_        |S )N)name	ekmConfigdefaultEkmConnection)r   /CloudkmsProjectsLocationsUpdateEkmConfigRequestr   
updateMask)selfmessagesec_name
ekm_configekm_config_to_updatereqs         r   CreateRequestzUpdate.CreateRequest7   s?    %07-

B
B__(< C >C ,CNJr   c                    t        j                         }t        j                         }|j                  j                  j                         }|j                  t        j                  dd      dj                  |j                  |j                        }|j                  j                  |j                  |            }| j                  ||j                  |      }|j                  j!                  |      S )Nz--default-ekm-connectionzMust be specified.z$projects/{0}/locations/{1}/ekmConfig)r   )cloudkms_baseGetClientInstanceGetMessagesModuleCONCEPTSlocationParsedefault_ekm_connectionr   RequiredArgumentExceptionformat
projectsIdlocationsIdprojects_locationsGetEkmConfig,CloudkmsProjectsLocationsGetEkmConfigRequestr   UpdateEkmConfig)r   argsclientr   loc_refekm_config_namer   
update_reqs           r   Runz
Update.RunA   s    ,,.F..0Hmm$$**,G ""*001K1EG G =CCG//1O**77==  	> 	"#J
 ##Hd.I.I$.0J $$44Z@@r   N)__name__
__module____qualname____doc__staticmethodr   r   r5    r   r   r   r      s(    * N NAr   r   N)r9   
__future__r   r   r   googlecloudsdk.api_lib.cloudkmsr   r!   googlecloudsdk.callioper   googlecloudsdk.command_lib.kmsr   r	   UpdateCommandr   r;   r   r   <module>rA      s6     &  ' A ( . 0 8;AT ;Ar   