google-cloud-resource_manager
Google Cloud Resource Manager (docs) enables you to programmatically manage container resources such as Organizations and Projects, that allow you to group and hierarchically organize other Cloud Platform resources. This hierarchical organization lets you easily manage common aspects of your resources such as access control and configuration settings. You may be familiar with managing projects in the Developers Console. With this API you can do the following:
- Get a list of all projects associated with an account
- Create new projects
- Update existing projects
- Delete projects
- Undelete, or recover, projects that you don't want to delete
The Resource Manager API is a Beta release and is not covered by any SLA or deprecation policy and may be subject to backward-incompatible changes.
- google-cloud-resource_manager API documentation
- google-cloud-resource_manager on RubyGems
- Google Cloud Resource Manager documentation
Accessing the Service
Currently, the full functionality of the Resource Manager API is available only to white-listed users. (Contact your account manager or a member of the Google Cloud sales team if you are interested in access.) Read-only methods such as ResourceManager::Manager#projects and ResourceManager::Manager#project are accessible to any user who enables the Resource Manager API in the Developers Console.
Quick Start
$ gem install google-cloud-resource_manager
Authentication
The Resource Manager API currently requires authentication of a User Account, and cannot currently be accessed with a Service Account. To use a User Account install the Google Cloud SDK and authenticate with the following:
$ gcloud auth login
Also make sure all environment variables are cleared of any service account credentials. Then google-cloud-resource_manager will be able to detect the user authentication and connect with those credentials.
Instructions and configuration options are covered in the Authentication Guide.
Example
require "google/cloud/resource_manager"
resource_manager = Google::Cloud::ResourceManager.new
# List all projects
resource_manager.projects.each do |project|
puts projects.project_id
end
# Label a project as production
project = resource_manager.project "tokyo-rain-123"
project.update do |p|
p.labels["env"] = "production"
end
# List only projects with the "production" label
projects = resource_manager.projects filter: "labels.env:production"
Supported Ruby Versions
This library is supported on Ruby 2.0+.
Versioning
This library follows Semantic Versioning.
It is currently in major version zero (0.y.z), which means that anything may change at any time and the public API should not be considered stable.
Contributing
Contributions to this library are always welcome and highly encouraged.
See the Contributing Guide for more information on how to get started.
Please note that this project is released with a Contributor Code of Conduct. By participating in this project you agree to abide by its terms. See Code of Conduct for more information.
License
This library is licensed under Apache 2.0. Full license text is available in LICENSE.
Support
Please report bugs at the project on Github. Don't hesitate to ask questions about the client or APIs on StackOverflow.