class Google::Cloud::Logging::Resource
# 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 {Google::Cloud::Logging::Entry#resource}, {Google::Cloud::Logging::Project#resource}, and {Google::Cloud::Logging::Project#write_entries}.
@example
require "google/cloud/logging" logging = Google::Cloud::Logging.new resource = logging.resource "gae_app", "module_id" => "1", "version_id" => "20150925t173233"
Attributes
A set of labels that can be used to describe instances of this monitored resource type.
The type of resource, as represented by a {ResourceDescriptor}.
Public Class Methods
@private New Resource
from a Google::Api::MonitoredResource object.
# File lib/google/cloud/logging/resource.rb, line 75 def self.from_grpc grpc return new if grpc.nil? new.tap do |r| r.type = grpc.type r.labels = Convert.map_to_hash grpc.labels end end
Create an empty Resource
object.
# File lib/google/cloud/logging/resource.rb, line 43 def initialize @labels = {} end
Public Instance Methods
@private Determines if the Resource
has any data.
# File lib/google/cloud/logging/resource.rb, line 58 def empty? type.nil? && (labels.nil? || labels.empty?) end
@private Exports the Resource
to a Google::Api::MonitoredResource object.
# File lib/google/cloud/logging/resource.rb, line 65 def to_grpc return nil if empty? Google::Api::MonitoredResource.new( type: type, labels: Hash[labels.map { |k, v| [String(k), String(v)] }] ) end