
    r                     J   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  ej                  ej                  j                  ej                  j                  ej                  j                         ej"                   G d	 d
ej$                                      Zy)z5Command to compute Essential Contacts for a resource.    )absolute_import)division)unicode_literals)contacts)base)flags)utilc                   6    e Zd ZdZed        Zed        Zd Zy)Computea5  Compute the essential contacts that are subscribed to the specified notification categories for a resource.

  This command will return the contacts subscribed to any of the notification
  categories that have been set on the requested resource or any of its
  ancestors.

  ## EXAMPLES

  To compute contacts subscribed to the technical category for the current
  project, run:

        $ {command} --notification-categories=technical

  To compute contacts subscribed to the product-updates or billing categories
  for the folder with id ``123'', run:

        $ {command} --notification-categories=product-updates,billing
        --folder=123

  To compute contacts subscribed to the legal category for the organization with
  id ``456'', run:

        $ {command} --notification-categories=legal --organization=456
  c                 6   | j                  d      r(t        j                         j                  j                  S | j                  d      r(t        j                         j
                  j                  S t        j                         j                  j                  S )z`Gets the NotificationCategory enum to cast the args as based on the type of parent resource arg.foldersorganizations)
startswithr   GetMessages.EssentialcontactsFoldersContactsComputeRequest%NotificationCategoriesValueValuesEnum4EssentialcontactsOrganizationsContactsComputeRequest/EssentialcontactsProjectsContactsComputeRequest)parent_names    )lib/surface/essential_contacts/compute.py(_GetNotificationCategoryEnumByParentTypez0Compute._GetNotificationCategoryEnumByParentType8   s     i(!! 667\7\] o.!! <<=b=bc  556[6[\    c                     t        j                  | t        j                         d       t        j                  |        t
        j                  j                  |        y)zAdds command-specific args.T)requiredN)r   AddNotificationCategoriesArgr   "GetContactNotificationCategoryEnumAddParentArgsr   URI_FLAGRemoveFromParser)parsers    r   ArgszCompute.ArgsF   sC     
&&;;=N	MM""6*r   c                     t        j                  |      }| j                  |      }t        j                  ||      }t	        j
                         }|j                  |||j                  |j                        S )z"Runs the compute contacts command.)limit	page_size)	r	   	GetParentr   GetNotificationCategoriesr   ContactsClientr   r#   r$   )selfargsr   notification_category_enum
categoriesclients         r   RunzCompute.RunN   ss    ..&K!%!N!N"//0JLJ $$&F>>ZtzzT^^  M Mr   N)__name__
__module____qualname____doc__staticmethodr   r!   r-    r   r   r   r      s7    2 \ \ + +
Mr   r   N)r1   
__future__r   r   r   )googlecloudsdk.api_lib.essential_contactsr   googlecloudsdk.callioper   -googlecloudsdk.command_lib.essential_contactsr   r	   ReleaseTracksReleaseTrackALPHABETAGAUniverseCompatibleListCommandr   r3   r   r   <module>r?      s    < &  ' > ( ? > D%%++T->->-C-C%%((*:Md :M *:Mr   