
    o                        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	Z	dZ
ej                  j                  d	ej                  j                  d	ej                  j                  d
iZddZddZdej                  j                  fdZy)z0General utilties for Service Directory commands.    )absolute_import)division)unicode_literals)apis)baseNservicedirectoryv1beta1v1c                    | syt        j                  t        t        j	                  t
        j                  j                              }g }|dk(  r|j                  j                  }n|dk(  r|j                  j                  }nyt        j                  |       D ]'  \  }}|j                  |j                  ||             )  ||      S )a  Parses and creates the annotations object from the parsed arguments.

  Args:
    annotations: dict, key-value pairs passed in from the --annotations flag.
    resource_type: string, the type of the resource to be created or updated.

  Returns:
    A message object depending on resource_type.

    Service.AnnotationsValue message when resource_type='service' and
    Endpoint.AnnotationsValue message when resource_type='endpoint'.
  NendpointservicekeyvalueadditionalProperties)r   GetMessagesModule	_API_NAME_VERSION_MAPgetr   ReleaseTrackGAEndpointAnnotationsValueServicesix	iteritemsappendAdditionalProperty)annotationsresource_typemsgsadditional_propertiesannotations_value_msgr   r   s          8lib/googlecloudsdk/command_lib/service_directory/util.pyParseAnnotationsArgr&   !   s     
				 , 0 01B1B1E1E F
H$ j  MM::	! LL99MM+.jc5  00S0FH / 
4I	JJ    c                    | syt        j                  t        t        j	                  t
        j                  j                              }g }|dk(  r|j                  j                  }n|dk(  r|j                  j                  }nyt        j                  |       D ]'  \  }}|j                  |j                  ||             )  ||      S )a  Parses and creates the metadata object from the parsed arguments.

  Args:
    metadata: dict, key-value pairs passed in from the --metadata flag.
    resource_type: string, the type of the resource to be created or updated.

  Returns:
    A message object depending on resource_type.

    Service.MetadataValue message when resource_type='service' and
    Endpoint.MetadataValue message when resource_type='endpoint'.
  Nr   r   r   r   )r   r   r   r   r   r   r   BETAr   MetadataValuer   r   r   r   r   )metadatar!   r"   r#   metadata_value_msgr   r   s          r%   ParseMetadataArgr-   D   s     
				 , 0 01B1B1G1G H
J$ j 44	!33MM(+jc5  --#U-CE , 
1F	GGr'   c                 "   | syt        j                  t        t        j	                  |            }g }|j
                  j                  }t        j                  |       D ]'  \  }}|j                  |j                  ||             )  ||      S )zParses and creates the labels object from the parsed arguments.

  Args:
    labels: dict, key-value pairs passed in from the --labels flag.
    release_track: base.ReleaseTrack value

  Returns:
    A message object.
  Nr   r   )r   r   r   r   r   	NamespaceLabelsValuer   r   r   r   )labelsrelease_trackr"   r#   labels_value_msgr   r   s          r%   ParseLabelsArgr4   g   s     
				<+;+;M+J	K$ ^^//MM&)jc5  ++5+AC * 
/D	EEr'   )NN)__doc__
__future__r   r   r   googlecloudsdk.api_lib.utilr   googlecloudsdk.callioper   r   r   r   ALPHAr)   r   r   r&   r-   r4    r'   r%   <module>r;      s    7 &  ' , ( 
	YI$ KF HF d.?.?.B.B Fr'   