def list_changes(self, max_results=None, page_token=None, client=None): """List change sets for this zone. See: https://cloud.google.com/dns/api/v1/resourceRecordSets/list :type max_results: int :param max_results: maximum number of zones 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 zones. If not passed, the API will return the first page of zones. :type client: :class:`google.cloud.dns.client.Client` or ``NoneType`` :param client: the client to use. If not passed, falls back to the ``client`` stored on the current zone. :rtype: :class:`~google.cloud.iterator.Iterator` :returns: Iterator of :class:`~.changes.Changes` belonging to this zone. """ client = self._require_client(client) path = '/projects/%s/managedZones/%s/changes' % (self.project, self.name) iterator = Iterator(client=client, path=path, items_key='changes', item_to_value=_item_to_changes, page_token=page_token, max_results=max_results) iterator.zone = self return iterator
def list_zones(self, max_results=None, page_token=None): """List zones for the project associated with this client. See: https://cloud.google.com/dns/api/v1/managedZones/list :type max_results: int :param max_results: maximum number of zones to return, If not passed, defaults to a value set by the API. :type page_token: str :param page_token: opaque marker for the next "page" of zones. If not passed, the API will return the first page of zones. :rtype: :class:`~google.cloud.iterator.Iterator` :returns: Iterator of :class:`~google.cloud.dns.zone.ManagedZone` belonging to this project. """ path = '/projects/%s/managedZones' % (self.project, ) return Iterator(client=self, path=path, items_key='managedZones', item_to_value=_item_to_zone, page_token=page_token, max_results=max_results)
def list_projects(self, max_results=None, page_token=None): """List projects for the project associated with this client. See: https://cloud.google.com/bigquery/docs/reference/v2/projects/list :type max_results: int :param max_results: maximum number of projects to return, If not passed, defaults to a value set by the API. :type page_token: str :param page_token: opaque marker for the next "page" of projects. If not passed, the API will return the first page of projects. :rtype: :class:`~google.cloud.iterator.Iterator` :returns: Iterator of :class:`~google.cloud.bigquery.client.Project` accessible to the current client. """ return Iterator(client=self, path='/projects', items_key='projects', item_to_value=_item_to_project, page_token=page_token, max_results=max_results)
def list_topics(self, project, page_size=0, page_token=None): """List topics for the project associated with this API. See: https://cloud.google.com/pubsub/docs/reference/rest/v1/projects.topics/list :type project: str :param project: project ID :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: str :param page_token: opaque marker for the next "page" of topics. If not passed, the API will return the first page of topics. :rtype: :class:`~google.cloud.iterator.Iterator` :returns: Iterator of :class:`~google.cloud.pubsub.topic.Topic` accessible to the current API. """ if page_token is None: page_token = INITIAL_PAGE options = CallOptions(page_token=page_token) path = 'projects/%s' % (project,) page_iter = self._gax_api.list_topics( path, page_size=page_size, options=options) page_iter = functools.partial(_recast_page_iterator, page_iter) return Iterator(client=self._client, path=path, item_to_value=_item_to_topic, page_iter=page_iter)
def list_topics(self, project, page_size=None, page_token=None): """API call: list topics for a given project See: https://cloud.google.com/pubsub/docs/reference/rest/v1/projects.topics/list :type project: str :param project: project ID :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: str :param page_token: opaque marker for the next "page" of topics. If not passed, the API will return the first page of topics. :rtype: :class:`~google.cloud.iterator.Iterator` :returns: Iterator of :class:`~google.cloud.pubsub.topic.Topic` accessible to the current connection. """ extra_params = {} if page_size is not None: extra_params['pageSize'] = page_size path = '/projects/%s/topics' % (project, ) return Iterator(client=self._client, path=path, items_key='topics', item_to_value=_item_to_topic, page_token=page_token, extra_params=extra_params)
def list_buckets(self, max_results=None, page_token=None, prefix=None, projection='noAcl', fields=None): """Get all buckets in the project associated to the client. This will not populate the list of blobs available in each bucket. >>> for bucket in client.list_buckets(): ... print(bucket) This implements "storage.buckets.list". :type max_results: integer or ``NoneType`` :param max_results: Optional. Maximum number of buckets to return. :type page_token: string or ``NoneType`` :param page_token: Optional. Opaque marker for the next "page" of buckets. If not passed, will return the first page of buckets. :type prefix: string or ``NoneType`` :param prefix: Optional. Filter results to buckets whose names begin with this prefix. :type projection: string or ``NoneType`` :param projection: If used, must be 'full' or 'noAcl'. Defaults to 'noAcl'. Specifies the set of properties to return. :type fields: string or ``NoneType`` :param fields: Selector specifying which fields to include in a partial response. Must be a list of fields. For example to get a partial response with just the next page token and the language of each bucket returned: 'items/id,nextPageToken' :rtype: :class:`~google.cloud.iterator.Iterator` :returns: Iterator of all :class:`~google.cloud.storage.bucket.Bucket` belonging to this project. """ extra_params = {'project': self.project} if prefix is not None: extra_params['prefix'] = prefix extra_params['projection'] = projection if fields is not None: extra_params['fields'] = fields return Iterator( client=self, path='/b', item_to_value=_item_to_bucket, page_token=page_token, max_results=max_results, extra_params=extra_params)
def list_jobs(self, max_results=None, page_token=None, all_users=None, state_filter=None): """List jobs for the project associated with this client. See: https://cloud.google.com/bigquery/docs/reference/v2/jobs/list :type max_results: int :param max_results: maximum number of jobs to return, If not passed, defaults to a value set by the API. :type page_token: str :param page_token: opaque marker for the next "page" of jobs. If not passed, the API will return the first page of jobs. :type all_users: boolean :param all_users: if true, include jobs owned by all users in the project. :type state_filter: str :param state_filter: if passed, include only jobs matching the given state. One of * ``"done"`` * ``"pending"`` * ``"running"`` :rtype: :class:`~google.cloud.iterator.Iterator` :returns: Iterable of job instances. """ extra_params = {'projection': 'full'} if all_users is not None: extra_params['allUsers'] = all_users if state_filter is not None: extra_params['stateFilter'] = state_filter path = '/projects/%s/jobs' % (self.project, ) return Iterator(client=self, path=path, items_key='jobs', item_to_value=_item_to_job, page_token=page_token, max_results=max_results, extra_params=extra_params)
def list_datasets(self, include_all=False, max_results=None, page_token=None): """List datasets for the project associated with this client. See: https://cloud.google.com/bigquery/docs/reference/v2/datasets/list :type include_all: boolean :param include_all: True if results include hidden datasets. :type max_results: int :param max_results: maximum number of datasets to return, If not passed, defaults to a value set by the API. :type page_token: str :param page_token: opaque marker for the next "page" of datasets. If not passed, the API will return the first page of datasets. :rtype: :class:`~google.cloud.iterator.Iterator` :returns: Iterator of :class:`~google.cloud.bigquery.dataset.Dataset`. accessible to the current client. """ extra_params = {} if include_all: extra_params['all'] = True path = '/projects/%s/datasets' % (self.project, ) return Iterator(client=self, path=path, items_key='datasets', item_to_value=_item_to_dataset, page_token=page_token, max_results=max_results, extra_params=extra_params)
def list_variables(self, page_size=None, page_token=None, client=None): """API call: list variables for this config. This only lists variable names, not the values. See: https://cloud.google.com/deployment-manager/runtime-configurator/reference/rest/v1beta1/projects.configs.variables/list :type page_size: int :param page_size: (Optional) Maximum number of variables to return per page. :type page_token: str :param page_token: opaque marker for the next "page" of variables. If not passed, will return the first page of variables. :type client: :class:`~google.cloud.runtimeconfig.client.Client` :param client: (Optional) The client to use. If not passed, falls back to the ``client`` stored on the current config. :rtype: :class:`~google.cloud.iterator.Iterator` :returns: Iterator of :class:`~google.cloud.runtimeconfig.variable.Variable` belonging to this project. """ path = '%s/variables' % (self.path, ) iterator = Iterator(client=self._require_client(client), path=path, items_key='variables', item_to_value=_item_to_variable, page_token=page_token, max_results=page_size) iterator._MAX_RESULTS = 'pageSize' iterator.config = self return iterator
def list_blobs(self, max_results=None, page_token=None, prefix=None, delimiter=None, versions=None, projection='noAcl', fields=None, client=None): """Return an iterator used to find blobs in the bucket. :type max_results: int :param max_results: (Optional) Maximum number of blobs to return. :type page_token: str :param page_token: (Optional) Opaque marker for the next "page" of blobs. If not passed, will return the first page of blobs. :type prefix: str :param prefix: (Optional) prefix used to filter blobs. :type delimiter: str :param delimiter: (Optional) Delimiter, used with ``prefix`` to emulate hierarchy. :type versions: bool :param versions: (Optional) Whether object versions should be returned as separate blobs. :type projection: str :param projection: (Optional) If used, must be 'full' or 'noAcl'. Defaults to ``'noAcl'``. Specifies the set of properties to return. :type fields: str :param fields: (Optional) Selector specifying which fields to include in a partial response. Must be a list of fields. For example to get a partial response with just the next page token and the language of each blob returned: ``'items/contentLanguage,nextPageToken'``. :type client: :class:`~google.cloud.storage.client.Client` :param client: (Optional) The client to use. If not passed, falls back to the ``client`` stored on the current bucket. :rtype: :class:`~google.cloud.iterator.Iterator` :returns: Iterator of all :class:`~google.cloud.storage.blob.Blob` in this bucket matching the arguments. """ extra_params = {} if prefix is not None: extra_params['prefix'] = prefix if delimiter is not None: extra_params['delimiter'] = delimiter if versions is not None: extra_params['versions'] = versions extra_params['projection'] = projection if fields is not None: extra_params['fields'] = fields client = self._require_client(client) path = self.path + '/o' iterator = Iterator(client=client, path=path, item_to_value=_item_to_blob, page_token=page_token, max_results=max_results, extra_params=extra_params, page_start=_blobs_page_start) iterator.bucket = self iterator.prefixes = set() return iterator
def list_projects(self, filter_params=None, page_size=None): """List the projects visible to this client. Example:: >>> from google.cloud import resource_manager >>> client = resource_manager.Client() >>> for project in client.list_projects(): ... print(project.project_id) List all projects with label ``'environment'`` set to ``'prod'`` (filtering by labels):: >>> from google.cloud import resource_manager >>> client = resource_manager.Client() >>> env_filter = {'labels.environment': 'prod'} >>> for project in client.list_projects(env_filter): ... print(project.project_id) See: https://cloud.google.com/resource-manager/reference/rest/v1beta1/projects/list Complete filtering example:: >>> project_filter = { # Return projects with... ... 'name': 'My Project', # name set to 'My Project'. ... 'id': 'my-project-id', # id set to 'my-project-id'. ... 'labels.stage': 'prod', # the label 'stage' set to 'prod' ... 'labels.color': '*' # a label 'color' set to anything. ... } >>> client.list_projects(project_filter) :type filter_params: dict :param filter_params: (Optional) A dictionary of filter options where each key is a property to filter on, and each value is the (case-insensitive) value to check (or the glob ``*`` to check for existence of the property). See the example above for more details. :type page_size: int :param page_size: (Optional) Maximum number of projects to return in a single page. If not passed, defaults to a value set by the API. :rtype: :class:`~google.cloud.iterator.Iterator` :returns: Iterator of all :class:`~google.cloud.resource_manager.project.Project`. that the current user has access to. """ extra_params = {} if page_size is not None: extra_params['pageSize'] = page_size if filter_params is not None: extra_params['filter'] = filter_params return Iterator(client=self, path='/projects', item_to_value=_item_to_project, items_key='projects', extra_params=extra_params)