Class: Google::Cloud::Logging::Resource
- Inherits:
-
Object
- Object
- Google::Cloud::Logging::Resource
- Defined in:
- lib/google/cloud/logging/resource.rb
Overview
# Resource
A monitored resource is an abstraction used to characterize many kinds of objects in your cloud infrastructure, including Google Cloud SQL databases, Google App Engine apps, Google Compute Engine virtual machine instances, and so forth. Each of those kinds of objects is described by an instance of ResourceDescriptor.
For use with Entry#resource, Project#resource, and Project#write_entries.
Instance Attribute Summary collapse
-
#labels ⇒ Object
A set of labels that can be used to describe instances of this monitored resource type.
-
#type ⇒ Object
The type of resource, as represented by a ResourceDescriptor.
Class Method Summary collapse
Instance Method Summary collapse
- #empty? ⇒ Boolean
-
#initialize ⇒ Resource
constructor
Create an empty Resource object.
-
#to_grpc ⇒ Object
object.
Constructor Details
#initialize ⇒ Resource
Create an empty Resource object.
44 45 46 |
# File 'lib/google/cloud/logging/resource.rb', line 44 def initialize @labels = {} end |
Instance Attribute Details
#labels ⇒ Object
A set of labels that can be used to describe instances of this monitored resource type.
55 56 57 |
# File 'lib/google/cloud/logging/resource.rb', line 55 def labels @labels end |
#type ⇒ Object
The type of resource, as represented by a Google::Cloud::Logging::ResourceDescriptor.
50 51 52 |
# File 'lib/google/cloud/logging/resource.rb', line 50 def type @type end |
Class Method Details
.from_grpc(grpc) ⇒ Object
76 77 78 79 80 81 82 |
# File 'lib/google/cloud/logging/resource.rb', line 76 def self.from_grpc grpc return new if grpc.nil? new.tap do |r| r.type = grpc.type r.labels = Core::GRPCUtils.map_to_hash(grpc.labels) end end |
Instance Method Details
#empty? ⇒ Boolean
59 60 61 |
# File 'lib/google/cloud/logging/resource.rb', line 59 def empty? type.nil? && (labels.nil? || labels.empty?) end |
#to_grpc ⇒ Object
object.
66 67 68 69 70 71 72 |
# File 'lib/google/cloud/logging/resource.rb', line 66 def to_grpc return nil if empty? Google::Api::MonitoredResource.new( type: type, labels: Hash[labels.map { |k, v| [String(k), String(v)] }] ) end |