
    x                         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 Z
d	 Zd
 Zd ZddZddZ	 ddZddZddZ	 	 	 	 ddZddZ	 	 	 	 ddZd Zy)z1Shared resource flags for Cloud Pub/Sub commands.    )absolute_import)division)unicode_literals)concepts)concept_parsers)presentation_specsc                  0    t        j                  dd      S )NsubscriptionzName of the subscription.name	help_textr    ResourceParameterAttributeConfig     6lib/googlecloudsdk/command_lib/pubsub/resource_args.pySubscriptionAttributeConfigr      s    		2	2+
- -r   c                  0    t        j                  dd      S )NtopiczName of the topic.r   r   r   r   r   TopicAttributeConfigr   !   s    		2	2$
& &r   c                  0    t        j                  dd      S )NschemazName of the schema.r   r   r   r   r   SchemaAttributeConfigr   '   s    		2	24
6 6r   c                  `    t        j                  ddt               t         j                        S )Nzpubsub.projects.subscriptionsr
   )resource_namesubscriptionsId
projectsId)r   ResourceSpecr    DEFAULT_PROJECT_ATTRIBUTE_CONFIGr   r   r   GetSubscriptionResourceSpecr    ,   s*    			%"13::	
< <r   c                 `    t        j                  d| t               t         j                        S )Nzpubsub.projects.topics)r   topicsIdr   )r   r   r   r   r   s    r   GetTopicResourceSpecr$   4   s*    			#%::	
< <r   c                 `    t        j                  d| t               t         j                        S )Nzpubsub.projects.schemas)r   	schemasIdr   )r   r   r   r   r#   s    r   GetSchemaResourceSpecr'   <   s*    			%'::	
< <r   c                     |rd}nd}|rd}nd}t        j                  |t               dj                  ||       ||d      S )a  Create a resource argument for a Cloud Pub/Sub Subscription.

  Args:
    verb: str, the verb to describe the resource, such as 'to update'.
    plural: bool, if True, use a resource argument that returns a list.
    required: bool, if True, create subscription resource arg will be required.
    positional: bool, if True, means that the subscription ID is a positional
      rather than a flag.

  Returns:
    the PresentationSpec for the resource argument.
  r
   z--subscriptionzOne or more subscriptionszName of the subscription{} {}T)requiredpluralprefixes)r   ResourcePresentationSpecr    format)verbr+   r*   
positionalr   	help_stems         r   CreateSubscriptionResourceArgr2   D   sQ     DD+I*I		4	4
!#nnY%
 r   c                 d    t        j                  t        ||      g      j                  |        y)zAdd a resource argument for a Cloud Pub/Sub Subscription.

  Args:
    parser: the parser for the command.
    verb: str, the verb to describe the resource, such as 'to update'.
    plural: bool, if True, use a resource argument that returns a list.
  r+   N)r   ConceptParserr2   AddToParserparserr/   r+   s      r   AddSubscriptionResourceArgr9   e   s)     $T&9:Kr   c                 d    t        j                  t        ||      g      j                  |        y)zAdd a resource argument for a Cloud Pub/Sub Schema.

  Args:
    parser: the parser for the command.
    verb: str, the verb to describe the resource, such as 'to update'.
    plural: bool, if True, use a resource argument that returns a list.
  r4   N)r   r5   CreateSchemaResourceArgr6   r7   s      r   AddSchemaResourceArgr<   r   s+     !8f!M !" ##.;v#6r   c           	          |r|}i }n|sd|z   nd|z   dz   }dd|z   dz   i}d}|rd}t        j                  |t        |      dj                  ||       |||d	      S )
a  Create a resource argument for a Cloud Pub/Sub Topic.

  Args:
    verb: str, the verb to describe the resource, such as 'to update'.
    positional: bool, if True, means that the topic ID is a positional rather
      than a flag. If not positional, this also creates a '--topic-project' flag
      as subscriptions and topics do not need to be in the same project.
    plural: bool, if True, use a resource argument that returns a list.
    required: bool, if True, create topic resource arg will be required.
    flag_name: str, name of the topic resource arg (singular).

  Returns:
    the PresentationSpec for the resource argument.
  --sproject-projectzName of the topiczOne or more topicsr)   Tr*   flag_name_overridesr+   r,   )r   r-   r$   r.   r/   r0   r+   r*   	flag_namer   rC   r1   s           r   CreateTopicResourceArgrF   ~   s    & D#)4)ti/?#/ED$dY&6&CD!)$I		4	4
9%nnY%-
 r   c                 f    t        j                  t        |||      g      j                  |        y)a  Add a resource argument for a Cloud Pub/Sub Topic.

  Args:
    parser: the parser for the command.
    verb: str, the verb to describe the resource, such as 'to update'.
    positional: bool, if True, means that the topic ID is a positional rather
      than a flag. If not positional, this also creates a '--topic-project' flag
      as subscriptions and topics do not need to be in the same project.
    plural: bool, if True, use a resource argument that returns a list.
  )r0   r+   N)r   r5   rF   r6   )r8   r/   r0   r+   s       r   AddTopicResourceArgrH      s+     dz&IJKr   c           	          |r|}i }n|sd|z   nd|z   dz   }dd|z   dz   i}d}|rd}t        j                  |t        |      dj                  ||       |||d	      S )
ax  Create a resource argument for a Cloud Pub/Sub Schema.

  Args:
    verb: str, the verb to describe the resource, such as 'to update'.
    positional: bool, if True, means that the schema ID is a positional rather
      than a flag. If not positional, this also creates a '--schema-project'
      flag as schemas and topics do not need to be in the same project.
    plural: bool, if True, use a resource argument that returns a list.
    required: bool, if True, schema resource arg will be required.
    flag_name: str, name of the schema resource arg (singular).

  Returns:
    the PresentationSpec for the resource argument.
  r>   r?   r@   rA   zName of the schemazOne or more schemasr)   TrB   )r   r-   r'   r.   rD   s           r   r;   r;      s    & D#)4)ti/?#/ED$dY&6&CD")%I		4	4
I&nnY%-
 r   c                 L    t        j                  |      j                  |        y)zAdd resource arguments for commands that have topic and subscriptions.

  Args:
    parser: the parser for the command.
    resources: a list of resource args to add.
  N)r   r5   r6   )r8   	resourcess     r   AddResourceArgsrL      s     	*66v>r   N)r   )r   )FTT)F)TFTr   )TF)TFTr   )__doc__
__future__r   r   r    googlecloudsdk.calliope.conceptsr   (googlecloudsdk.command_lib.util.conceptsr   r   r   r   r   r    r$   r'   r2   r9   r<   rF   rH   r;   rL   r   r   r   <module>rQ      s     8 &  ' 5 D G-&6
<<< 37B
	7 '+"'$(%,	#L" (,#(%)&.	#L?r   