Class: Gcloud::Logging::ResourceDescriptor::LabelDescriptor

Inherits:
Object
  • Object
show all
Defined in:
lib/gcloud/logging/resource_descriptor.rb

Overview

# LabelDescriptor

A definition of a label that can be used to describe instances of a Gcloud::Logging::Resource. For example, Cloud SQL databases must be labeled with their ‘database_id`. See #labels.

Examples:

require "gcloud"

gcloud = Gcloud.new
logging = gcloud.logging
resource_descriptor = logging.resource_descriptors.first
label_descriptor = resource_descriptor.labels.first
label_descriptor.key #=> "database_id"
label_descriptor.description #=> "The ID of the database."

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Attribute Details

#descriptionObject (readonly)

A human-readable description for the label.



120
121
122
# File 'lib/gcloud/logging/resource_descriptor.rb', line 120

def description
  @description
end

#keyObject (readonly)

The key (name) of the label.



108
109
110
# File 'lib/gcloud/logging/resource_descriptor.rb', line 108

def key
  @key
end

#typeSymbol? (readonly)

The type of data that can be assigned to the label.

Returns:

  • (Symbol, nil)

    Returns ‘:string`, `:boolean`, `:integer`, or `nil` if there is no type.



116
117
118
# File 'lib/gcloud/logging/resource_descriptor.rb', line 116

def type
  @type
end

Class Method Details

.from_grpc(grpc) ⇒ Object

object.



125
126
127
128
129
130
131
132
133
134
135
136
# File 'lib/gcloud/logging/resource_descriptor.rb', line 125

def self.from_grpc grpc
  type_sym = { STRING: :string,
               BOOL:   :boolean,
               INT64:  :integer }[grpc.value_type]
  l = new
  l.instance_eval do
    @key         = grpc.key
    @type        = type_sym
    @description = grpc.description
  end
  l
end