def list_topics(self, page_size=None, page_token=None): """List topics for the project associated with this client. See: https://cloud.google.com/pubsub/docs/reference/rest/v1/projects.topics/list Example: .. literalinclude:: pubsub_snippets.py :start-after: [START client_list_topics] :end-before: [END client_list_topics] :type page_size: int :param page_size: maximum number of topics to return, If not passed, defaults to a value set by the API. :type page_token: string :param page_token: opaque marker for the next "page" of topics. If not passed, the API will return the first page of topics. :rtype: tuple, (list, str) :returns: list of :class:`google.cloud.pubsub.topic.Topic`, plus a "next page token" string: if not None, indicates that more topics can be retrieved with another call (pass that value as ``page_token``). """ api = self.publisher_api resources, next_token = api.list_topics(self.project, page_size, page_token) topics = [ Topic.from_api_repr(resource, self) for resource in resources ] return topics, next_token
def list_topics(self, page_size=None, page_token=None): """List topics for the project associated with this client. See: https://cloud.google.com/pubsub/reference/rest/v1/projects.topics/list Example: .. literalinclude:: pubsub_snippets.py :start-after: [START client_list_topics] :end-before: [END client_list_topics] :type page_size: int :param page_size: maximum number of topics to return, If not passed, defaults to a value set by the API. :type page_token: string :param page_token: opaque marker for the next "page" of topics. If not passed, the API will return the first page of topics. :rtype: tuple, (list, str) :returns: list of :class:`google.cloud.pubsub.topic.Topic`, plus a "next page token" string: if not None, indicates that more topics can be retrieved with another call (pass that value as ``page_token``). """ api = self.publisher_api resources, next_token = api.list_topics( self.project, page_size, page_token) topics = [Topic.from_api_repr(resource, self) for resource in resources] return topics, next_token
def _item_to_topic(iterator, resource): """Convert a JSON topic to the native object. :type iterator: :class:`~google.cloud.iterator.Iterator` :param iterator: The iterator that is currently in use. :type resource: dict :param resource: A topic returned from the API. :rtype: :class:`~google.cloud.pubsub.topic.Topic` :returns: The next topic in the page. """ return Topic.from_api_repr(resource, iterator.client)
def _item_to_topic(iterator, resource): """Convert a protobuf topic to the native object. :type iterator: :class:`~google.api.core.page_iterator.Iterator` :param iterator: The iterator that is currently in use. :type resource: :class:`.pubsub_pb2.Topic` :param resource: A topic returned from the API. :rtype: :class:`~google.cloud.pubsub.topic.Topic` :returns: The next topic in the page. """ return Topic.from_api_repr({'name': resource.name}, iterator.client)