A Client for interacting with the Resource Manager API.

class, http=None)[source]#


Client to bundle configuration needed for API requests.

See for more information on this API.

Automatically get credentials:

>>> from import resource_manager
>>> client = resource_manager.Client()
  • credentials (oauth2client.client.OAuth2Credentials or NoneType) – The OAuth2 Credentials to use for the connection owned by this client. If not passed (and if no http object is passed), falls back to the default inferred from the environment.
  • http (httplib2.Http or class that defines request().) – An optional HTTP object to make requests. If not passed, an http object is created that is bound to the credentials for the current object.

Fetch an existing project and it’s relevant metadata by ID.


If the project does not exist, this will raise a NotFound error.

Parameters:project_id (str) – The ID for this project.
Return type:Project
Returns:A Project with metadata fetched from the API.
list_projects(filter_params=None, page_size=None)[source]#

List the projects visible to this client.


>>> from 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 import resource_manager
>>> client = resource_manager.Client()
>>> env_filter = {'labels.environment': 'prod'}
>>> for project in client.list_projects(env_filter):
...     print(project.project_id)


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)
  • filter_params (dict) – (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.
  • page_size (int) – (Optional) Maximum number of projects to return in a single page. If not passed, defaults to a value set by the API.
Return type:



A project iterator. The iterator will make multiple API requests if you continue iterating and there are more pages of results. Each item returned will be a. Project.

new_project(project_id, name=None, labels=None)[source]#

Create a project bound to the current client.

Use Project.reload() to retrieve project metadata after creating a Project instance.

  • project_id (str) – The ID for this project.
  • name (string) – The display name of the project.
  • labels (dict) – A list of labels associated with the project.
Return type:



A new instance of a Project without any metadata loaded.


Create / interact with Google Cloud Resource Manager connections.

class, http=None)[source]#


A connection to Google Cloud Resource Manager via the JSON REST API.


The base of the API call URL.

API_URL_TEMPLATE = '{api_base_url}/{api_version}{path}'#

A template for the URL of a particular API call.

API_VERSION = 'v1beta1'#

The version of the API, used in building the API call’s URL.

SCOPE = ('',)#

The scopes required for authenticating as a Resouce Manager consumer.