
                             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 d
ddZdZ G d de	j                         Zy)z!Searches the protected resources.    )absolute_import)division)unicode_literals)	inventory)arg_parsers)base)resource_args)
completersz}
         *{command}* returns a list of the resources a key is protecting
         within the specified organization.
       z
         To view the protected resources for the key `puppy` and organization
         number `1234` run:

           $ {command} --keyname=puppy --scope=1234
       )DESCRIPTIONEXAMPLESa  A list of resource types that this request searches for. If empty, it will
search all the [trackable resource types](https://cloud.google.com/kms/docs/view-key-usage#tracked-resource-types).

Regular expressions are also supported. For example:

  * ``compute.googleapis.com.*'' snapshots resources whose type
    starts with ``compute.googleapis.com''.
  * ``.*Image'' snapshots resources whose type ends with
    ``Image''.
  * ``.*Image.*'' snapshots resources whose type contains
    ``Image''.

See [RE2](https://github.com/google/re2/wiki/Syntax) for all supported
regular expression syntax. If the regular expression does not match any
supported resource type, an ``INVALID_ARGUMENT'' error will be returned.
c                   *    e Zd ZdZeZed        Zd Zy)SearchProtectedResourcesz*Searches the resources protected by a key.c                     t        j                  | dd       | j                  ddt        j                  dd       | j                  ddt        j                         t        	       y )
NTz	--keynamez--scopeORGANIZATION_IDzOrganization ID.)metavar	completerrequiredhelpz--resource-typesRESOURCE_TYPES)r   typer   )r	   AddKmsKeyResourceArgForKMSadd_argumentr
   OrganizationCompleterr   ArgListRESOURCE_TYPE_HELP)parsers    7lib/surface/kms/inventory/search_protected_resources.pyArgszSearchProtectedResources.Args@   sf    ,,VT;G
!22  !    "	      c                     |j                   }|j                  }|j                  }|sg }t        j                  ||||      S )N)scopekey_nameresource_typesargs)keynamer!   r#   r   r   )selfr$   r"   orgr#   s        r   RunzSearchProtectedResources.RunP   sC    ||H
**C((Nn--H^$ r   N)	__name__
__module____qualname____doc__DETAILED_HELPdetailed_helpstaticmethodr   r(    r   r   r   r   <   s!    2- r   r   N)r,   
__future__r   r   r   #googlecloudsdk.api_lib.kmsinventoryr   googlecloudsdk.callioper   r   googlecloudsdk.command_lib.kmsr	   +googlecloudsdk.command_lib.resource_managerr
   r-   r   ListCommandr   r0   r   r   <module>r7      sM    ( &  ' 9 / ( 8 B &t// r   