
    -                     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  G d d      Z	y	)
z$Cloud Datastream stream objects API.    )absolute_import)division)unicode_literals)
list_pager)utilc                   *    e Zd ZdZddZd Zd Zd Zy)StreamObjectsClientz-Client for stream objects service in the API.Nc                     |xs t        j                         | _        |xs t        j                         | _        | j                  j
                  | _        t        j                         | _        y )N)	r   GetClientInstance_clientGetMessagesModule	_messages"projects_locations_streams_objects_serviceGetResourceParser_resource_parser)selfclientmessagess      7lib/googlecloudsdk/api_lib/datastream/stream_objects.py__init__zStreamObjectsClient.__init__   sN    5T335DL9!7!7!9DNLLCCDM 224D    c                     | j                   j                  d|||j                        }| j                  j                  } ||j                               }t        j                  | j                  ||j                  |j                  dd      S )zGet the list of objects in a stream.

    Args:
      project_id: The project ID to retrieve
      stream: The stream name to retrieve
      args: parsed command line arguments

    Returns:
      An iterator over all the matching stream objects.
    %datastream.projects.locations.streams
projectsId	streamsIdlocationsId)parentstreamObjectspageSize)servicerequestlimit
batch_sizefieldbatch_size_attribute)r   Createlocationr   4DatastreamProjectsLocationsStreamsObjectsListRequestRelativeNamer   YieldFromListr   r$   	page_size)r   
project_idstreamargs
stream_reflist_req_typelist_reqs          r   ListzStreamObjectsClient.List"   s     &&--/MM	 . #J NNWWMJ$;$;$=>H##jj>>') )r   c                 ^   | j                   j                         }|j                  r8| j                   j                  |j                  |j                        |_        nD|j                  r8| j                   j                  |j                  |j                        |_	        n |j                  r7| j                   j                  |j                  |j                        |_        n|j                  r7| j                   j                  |j                  |j                         |_        nz|j$                  r,| j                   j'                  |j$                        |_        nB|j*                  r6| j                   j-                  |j*                  |j.                        |_        | j2                  j5                  d|||j6                        }| j                   j8                  } || j                   j;                  |      |j=                               }| j>                  jA                  |      S )	zLookup a stream object.

    Args:
      project_id:
      stream_id:
      args: argparse.Namespace, The arguments that this command was invoked
        with.

    Returns:
      StreamObject: the looked up stream object.
    )schematable)databaser7   )
objectName)r8   
collectionr   r   )sourceObjectIdentifier)lookupStreamObjectRequestr   )!r   SourceObjectIdentifieroracle_schemaOracleObjectIdentifieroracle_tableoracleIdentifiermysql_databaseMysqlObjectIdentifiermysql_tablemysqlIdentifierpostgresql_schemaPostgresqlObjectIdentifierpostgresql_tablepostgresqlIdentifiersqlserver_schemaSqlServerObjectIdentifiersqlserver_tablesqlServerIdentifiersalesforce_object_nameSalesforceObjectIdentifiersalesforceIdentifiermongodb_databaseMongodbObjectIdentifiermongodb_collectionmongodbIdentifierr   r(   r)   6DatastreamProjectsLocationsStreamsObjectsLookupRequestLookupStreamObjectRequestr+   r   Lookup)r   r.   	stream_idr0   object_identifierr1   lookup_req_type
lookup_reqs           r   rW   zStreamObjectsClient.Lookup>   s    ==?
..
/
/''t/@/@ 0  (
 
		*...*N*N&&d.>.> +O +' 
		
..
3
3++43H3H 4  ,
 
		
..
2
2**$2F2F 3  +
 
	$	$
..
3
344 4  ,
 
		
..
0
0,,9P9P 1  ) &&--/MM	 . J 	MM  !"&.."J"J#4 #K #
 &&(	J ==
++r   c                 \    | j                   j                  |d      }|j                         S )zGet the URL string for a stream object.

    Args:
      name: stream object's full name.

    Returns:
      URL of the stream object resource
    z-datastream.projects.locations.streams.objects)r:   )r   ParseRelativeNameSelfLink)r   nameuris      r   GetUrizStreamObjectsClient.GetUri   s2     


1
1H 2 JC<<>r   )NN)__name__
__module____qualname____doc__r   r4   rW   ra    r   r   r	   r	      s    55)8@,Dr   r	   N)
re   
__future__r   r   r   apitools.base.pyr   !googlecloudsdk.api_lib.datastreamr   r	   rf   r   r   <module>rj      s%    + &  ' ' 2s sr   