Class: Google::Cloud::ResourceManager::Project::Updater

Inherits:
Google::Cloud::ResourceManager::Project show all
Defined in:
lib/google/cloud/resource_manager/project/updater.rb

Overview

Project Updater

This object is used by Project#update when passed a block. These methods are used to update the project data in a single API call.

Examples:

require "google/cloud/resource_manager"

resource_manager = Google::Cloud::ResourceManager.new
project = resource_manager.project "tokyo-rain-123"
project.update do |p|
  p.name = "My Project"
  p.labels["env"] = "production"
end

Instance Method Summary collapse

Methods inherited from Google::Cloud::ResourceManager::Project

#active?, #created_at, #delete, #delete_in_progress?, #delete_requested?, #name, #parent, #policy, #project_id, #project_number, #reload!, #state, #test_permissions, #undelete, #unspecified?, #update, #update_policy

Instance Method Details

#labelsObject

The labels associated with this project.

Label keys must be between 1 and 63 characters long and must conform to the following regular expression: [a-z]([-a-z0-9]*[a-z0-9])?.

Label values must be between 0 and 63 characters long and must conform to the regular expression ([a-z]([-a-z0-9]*[a-z0-9])?)?.

No more than 256 labels can be associated with a given resource. (Hash)

Examples:

require "google/cloud/resource_manager"

resource_manager = Google::Cloud::ResourceManager.new
project = resource_manager.project "tokyo-rain-123"
project.update do |p|
  p.labels["env"] = "production"
end


83
84
85
# File 'lib/google/cloud/resource_manager/project/updater.rb', line 83

def labels
  gapi.labels
end

#labels=(new_labels) ⇒ Object

Updates the labels associated with this project.

Label keys must be between 1 and 63 characters long and must conform to the following regular expression: [a-z]([-a-z0-9]*[a-z0-9])?.

Label values must be between 0 and 63 characters long and must conform to the regular expression ([a-z]([-a-z0-9]*[a-z0-9])?)?.

No more than 256 labels can be associated with a given resource. (Hash)

Examples:

require "google/cloud/resource_manager"

resource_manager = Google::Cloud::ResourceManager.new
project = resource_manager.project "tokyo-rain-123"
project.update do |p|
  p.labels = { "env" => "production" }
end


110
111
112
# File 'lib/google/cloud/resource_manager/project/updater.rb', line 110

def labels= new_labels
  gapi.labels = new_labels
end

#name=(new_name) ⇒ Object

Updates the user-assigned name of the project. This field is optional and can remain unset.

Allowed characters are: lowercase and uppercase letters, numbers, hyphen, single-quote, double-quote, space, and exclamation point.

Examples:

require "google/cloud/resource_manager"

resource_manager = Google::Cloud::ResourceManager.new
project = resource_manager.project "tokyo-rain-123"
project.update do |p|
  p.name = "My Project"
end


56
57
58
# File 'lib/google/cloud/resource_manager/project/updater.rb', line 56

def name= new_name
  gapi.name = new_name
end

#parent=(new_parent) ⇒ Object

Updates the reference to a parent with a new Resource.

Supported parent types include "organization" and "folder". Once set, the parent can be updated but cannot be cleared.

The end user must have the resourcemanager.projects.create permission on the parent.

(See Resource and Manager#resource.)

Examples:

require "google/cloud/resource_manager"

resource_manager = Google::Cloud::ResourceManager.new
project = resource_manager.project "tokyo-rain-123"
folder = resource_manager.resource "folder", "1234"
project.parent = folder

Parameters:

  • new_parent (Resource)

    A new parent Resource.

Raises:

  • (ArgumentError)


135
136
137
138
# File 'lib/google/cloud/resource_manager/project/updater.rb', line 135

def parent= new_parent
  raise ArgumentError, "new_parent is required" if new_parent.nil?
  gapi.parent = new_parent.to_gapi
end