Class: Google::Cloud::ResourceManager::Resource
- Inherits:
-
Object
- Object
- Google::Cloud::ResourceManager::Resource
- Defined in:
- lib/google/cloud/resource_manager/resource.rb
Overview
Resource
A container to reference an id for any resource type. A resource
in
Google Cloud Platform is a generic term for something a developer may
want to interact with through an API. Some examples are an App Engine
app, a Compute Engine instance, a Cloud SQL database, and so on. (See
Manager#resource.)
Instance Attribute Summary collapse
-
#id ⇒ String
Required field for the type-specific id.
-
#type ⇒ String
Required field representing the resource type this id is for.
Class Method Summary collapse
-
.folder(id) ⇒ Resource
Create a Resource object with type
folder
. -
.organization(id) ⇒ Resource
Create a Resource object with type
organization
.
Instance Method Summary collapse
-
#folder? ⇒ Boolean
Checks if the type is
folder
. -
#initialize(type, id) ⇒ Resource
constructor
Create a Resource object.
-
#organization? ⇒ Boolean
Checks if the type is
organization
.
Constructor Details
#initialize(type, id) ⇒ Resource
Create a Resource object.
44 45 46 47 48 49 50 |
# File 'lib/google/cloud/resource_manager/resource.rb', line 44 def initialize type, id raise ArgumentError, "type is required" if type.nil? raise ArgumentError, "id is required" if id.nil? @type = type @id = id end |
Instance Attribute Details
#id ⇒ String
Required field for the type-specific id. This should correspond to the id used in the type-specific API's.
62 63 64 |
# File 'lib/google/cloud/resource_manager/resource.rb', line 62 def id @id end |
#type ⇒ String
Required field representing the resource type this id is for. At present, the valid types are: "organization" and "folder".
56 57 58 |
# File 'lib/google/cloud/resource_manager/resource.rb', line 56 def type @type end |
Class Method Details
.folder(id) ⇒ Resource
Create a Resource object with type folder
.
86 87 88 |
# File 'lib/google/cloud/resource_manager/resource.rb', line 86 def self.folder id new "folder", id end |
.organization(id) ⇒ Resource
Create a Resource object with type organization
.
96 97 98 |
# File 'lib/google/cloud/resource_manager/resource.rb', line 96 def self.organization id new "organization", id end |
Instance Method Details
#folder? ⇒ Boolean
Checks if the type is folder
.
67 68 69 70 |
# File 'lib/google/cloud/resource_manager/resource.rb', line 67 def folder? return false if type.nil? "folder".casecmp(type).zero? end |
#organization? ⇒ Boolean
Checks if the type is organization
.
75 76 77 78 |
# File 'lib/google/cloud/resource_manager/resource.rb', line 75 def organization? return false if type.nil? "organization".casecmp(type).zero? end |