Class: TogaiClient::UsageMeter
- Inherits:
-
Object
- Object
- TogaiClient::UsageMeter
- Defined in:
- lib/togai_client/models/usage_meter.rb
Overview
Structure of usage meter
Defined Under Namespace
Classes: EnumAttributeValidator
Instance Attribute Summary collapse
-
#aggregation ⇒ Object
Returns the value of attribute aggregation.
-
#billable_name ⇒ Object
Billable name of addon.
-
#computations ⇒ Object
Returns the value of attribute computations.
-
#created_at ⇒ Object
Returns the value of attribute created_at.
-
#description ⇒ Object
Returns the value of attribute description.
-
#display_name ⇒ Object
Display name of usage meter.
-
#event_schema ⇒ Object
Returns the value of attribute event_schema.
-
#filters ⇒ Object
Returns the value of attribute filters.
-
#id ⇒ Object
Identifier of the usage meter.
-
#last_activated_at ⇒ Object
Returns the value of attribute last_activated_at.
-
#name ⇒ Object
Name of the usage meter.
-
#status ⇒ Object
Status of usage meter.
-
#type ⇒ Object
Type of usage meter.
-
#updated_at ⇒ Object
Returns the value of attribute updated_at.
Class Method Summary collapse
-
._deserialize(type, value) ⇒ Object
Deserializes the data based on type.
-
.acceptable_attributes ⇒ Object
Returns all the JSON keys this model knows about.
-
.attribute_map ⇒ Object
Attribute mapping from ruby-style variable name to JSON key.
-
.build_from_hash(attributes) ⇒ Object
Builds the object from hash.
-
.openapi_nullable ⇒ Object
List of attributes with nullable: true.
-
.openapi_types ⇒ Object
Attribute type mapping.
Instance Method Summary collapse
-
#==(o) ⇒ Object
Checks equality by comparing each attribute.
-
#_to_hash(value) ⇒ Hash
Outputs non-array value in the form of hash For object, use to_hash.
- #eql?(o) ⇒ Boolean
-
#hash ⇒ Integer
Calculates hash code according to all attributes.
-
#initialize(attributes = {}) ⇒ UsageMeter
constructor
Initializes the object.
-
#list_invalid_properties ⇒ Object
Show invalid properties with the reasons.
-
#to_body ⇒ Hash
to_body is an alias to to_hash (backward compatibility).
-
#to_hash ⇒ Hash
Returns the object in the form of hash.
-
#to_s ⇒ String
Returns the string representation of the object.
-
#valid? ⇒ Boolean
Check to see if the all the properties in the model are valid.
Constructor Details
#initialize(attributes = {}) ⇒ UsageMeter
Initializes the object
128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 |
# File 'lib/togai_client/models/usage_meter.rb', line 128 def initialize(attributes = {}) if (!attributes.is_a?(Hash)) fail ArgumentError, "The input argument (attributes) must be a hash in `TogaiClient::UsageMeter` initialize method" end # check to see if the attribute exists and convert string to symbol for hash key attributes = attributes.each_with_object({}) { |(k, v), h| if (!self.class.attribute_map.key?(k.to_sym)) fail ArgumentError, "`#{k}` is not a valid attribute in `TogaiClient::UsageMeter`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect end h[k.to_sym] = v } if attributes.key?(:'id') self.id = attributes[:'id'] else self.id = nil end if attributes.key?(:'name') self.name = attributes[:'name'] else self.name = nil end if attributes.key?(:'billable_name') self.billable_name = attributes[:'billable_name'] end if attributes.key?(:'display_name') self.display_name = attributes[:'display_name'] else self.display_name = nil end if attributes.key?(:'description') self.description = attributes[:'description'] end if attributes.key?(:'filters') if (value = attributes[:'filters']).is_a?(Array) self.filters = value end end if attributes.key?(:'type') self.type = attributes[:'type'] else self.type = nil end if attributes.key?(:'status') self.status = attributes[:'status'] end if attributes.key?(:'aggregation') self.aggregation = attributes[:'aggregation'] else self.aggregation = nil end if attributes.key?(:'computations') if (value = attributes[:'computations']).is_a?(Array) self.computations = value end end if attributes.key?(:'event_schema') self.event_schema = attributes[:'event_schema'] end if attributes.key?(:'created_at') self.created_at = attributes[:'created_at'] end if attributes.key?(:'last_activated_at') self.last_activated_at = attributes[:'last_activated_at'] end if attributes.key?(:'updated_at') self.updated_at = attributes[:'updated_at'] end end |
Instance Attribute Details
#aggregation ⇒ Object
Returns the value of attribute aggregation.
41 42 43 |
# File 'lib/togai_client/models/usage_meter.rb', line 41 def aggregation @aggregation end |
#billable_name ⇒ Object
Billable name of addon. Billable name takes precedence over name to display in invoice.
26 27 28 |
# File 'lib/togai_client/models/usage_meter.rb', line 26 def billable_name @billable_name end |
#computations ⇒ Object
Returns the value of attribute computations.
43 44 45 |
# File 'lib/togai_client/models/usage_meter.rb', line 43 def computations @computations end |
#created_at ⇒ Object
Returns the value of attribute created_at.
47 48 49 |
# File 'lib/togai_client/models/usage_meter.rb', line 47 def created_at @created_at end |
#description ⇒ Object
Returns the value of attribute description.
31 32 33 |
# File 'lib/togai_client/models/usage_meter.rb', line 31 def description @description end |
#display_name ⇒ Object
Display name of usage meter. This is an auto-generated field which contains billableName of usage meter. If billableName is not provided, name will be used as display name.
29 30 31 |
# File 'lib/togai_client/models/usage_meter.rb', line 29 def display_name @display_name end |
#event_schema ⇒ Object
Returns the value of attribute event_schema.
45 46 47 |
# File 'lib/togai_client/models/usage_meter.rb', line 45 def event_schema @event_schema end |
#filters ⇒ Object
Returns the value of attribute filters.
33 34 35 |
# File 'lib/togai_client/models/usage_meter.rb', line 33 def filters @filters end |
#id ⇒ Object
Identifier of the usage meter
20 21 22 |
# File 'lib/togai_client/models/usage_meter.rb', line 20 def id @id end |
#last_activated_at ⇒ Object
Returns the value of attribute last_activated_at.
49 50 51 |
# File 'lib/togai_client/models/usage_meter.rb', line 49 def last_activated_at @last_activated_at end |
#name ⇒ Object
Name of the usage meter
23 24 25 |
# File 'lib/togai_client/models/usage_meter.rb', line 23 def name @name end |
#status ⇒ Object
Status of usage meter
39 40 41 |
# File 'lib/togai_client/models/usage_meter.rb', line 39 def status @status end |
#type ⇒ Object
Type of usage meter
36 37 38 |
# File 'lib/togai_client/models/usage_meter.rb', line 36 def type @type end |
#updated_at ⇒ Object
Returns the value of attribute updated_at.
51 52 53 |
# File 'lib/togai_client/models/usage_meter.rb', line 51 def updated_at @updated_at end |
Class Method Details
._deserialize(type, value) ⇒ Object
Deserializes the data based on type
470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 |
# File 'lib/togai_client/models/usage_meter.rb', line 470 def self._deserialize(type, value) case type.to_sym when :Time Time.parse(value) when :Date Date.parse(value) when :String value.to_s when :Integer value.to_i when :Float value.to_f when :Boolean if value.to_s =~ /\A(true|t|yes|y|1)\z/i true else false end when :Object # generic object (usually a Hash), return directly value when /\AArray<(?<inner_type>.+)>\z/ inner_type = Regexp.last_match[:inner_type] value.map { |v| _deserialize(inner_type, v) } when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/ k_type = Regexp.last_match[:k_type] v_type = Regexp.last_match[:v_type] {}.tap do |hash| value.each do |k, v| hash[_deserialize(k_type, k)] = _deserialize(v_type, v) end end else # model # models (e.g. Pet) or oneOf klass = TogaiClient.const_get(type) klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) end end |
.acceptable_attributes ⇒ Object
Returns all the JSON keys this model knows about
96 97 98 |
# File 'lib/togai_client/models/usage_meter.rb', line 96 def self.acceptable_attributes attribute_map.values end |
.attribute_map ⇒ Object
Attribute mapping from ruby-style variable name to JSON key.
76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 |
# File 'lib/togai_client/models/usage_meter.rb', line 76 def self.attribute_map { :'id' => :'id', :'name' => :'name', :'billable_name' => :'billableName', :'display_name' => :'displayName', :'description' => :'description', :'filters' => :'filters', :'type' => :'type', :'status' => :'status', :'aggregation' => :'aggregation', :'computations' => :'computations', :'event_schema' => :'eventSchema', :'created_at' => :'createdAt', :'last_activated_at' => :'lastActivatedAt', :'updated_at' => :'updatedAt' } end |
.build_from_hash(attributes) ⇒ Object
Builds the object from hash
446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 |
# File 'lib/togai_client/models/usage_meter.rb', line 446 def self.build_from_hash(attributes) return nil unless attributes.is_a?(Hash) attributes = attributes.transform_keys(&:to_sym) transformed_hash = {} openapi_types.each_pair do |key, type| if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? transformed_hash["#{key}"] = nil elsif type =~ /\AArray<(.*)>/i # check to ensure the input is an array given that the attribute # is documented as an array but the input is not if attributes[attribute_map[key]].is_a?(Array) transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } end elsif !attributes[attribute_map[key]].nil? transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) end end new(transformed_hash) end |
.openapi_nullable ⇒ Object
List of attributes with nullable: true
121 122 123 124 |
# File 'lib/togai_client/models/usage_meter.rb', line 121 def self.openapi_nullable Set.new([ ]) end |
.openapi_types ⇒ Object
Attribute type mapping.
101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 |
# File 'lib/togai_client/models/usage_meter.rb', line 101 def self.openapi_types { :'id' => :'String', :'name' => :'String', :'billable_name' => :'String', :'display_name' => :'String', :'description' => :'String', :'filters' => :'Array<UsageMeterFilterEntry>', :'type' => :'String', :'status' => :'String', :'aggregation' => :'UsageMeterAggregation', :'computations' => :'Array<Computation>', :'event_schema' => :'EventSchema', :'created_at' => :'Time', :'last_activated_at' => :'Time', :'updated_at' => :'Time' } end |
Instance Method Details
#==(o) ⇒ Object
Checks equality by comparing each attribute.
412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 |
# File 'lib/togai_client/models/usage_meter.rb', line 412 def ==(o) return true if self.equal?(o) self.class == o.class && id == o.id && name == o.name && billable_name == o.billable_name && display_name == o.display_name && description == o.description && filters == o.filters && type == o.type && status == o.status && aggregation == o.aggregation && computations == o.computations && event_schema == o.event_schema && created_at == o.created_at && last_activated_at == o.last_activated_at && updated_at == o.updated_at end |
#_to_hash(value) ⇒ Hash
Outputs non-array value in the form of hash For object, use to_hash. Otherwise, just return the value
541 542 543 544 545 546 547 548 549 550 551 552 553 |
# File 'lib/togai_client/models/usage_meter.rb', line 541 def _to_hash(value) if value.is_a?(Array) value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) {}.tap do |hash| value.each { |k, v| hash[k] = _to_hash(v) } end elsif value.respond_to? :to_hash value.to_hash else value end end |
#eql?(o) ⇒ Boolean
433 434 435 |
# File 'lib/togai_client/models/usage_meter.rb', line 433 def eql?(o) self == o end |
#hash ⇒ Integer
Calculates hash code according to all attributes.
439 440 441 |
# File 'lib/togai_client/models/usage_meter.rb', line 439 def hash [id, name, billable_name, display_name, description, filters, type, status, aggregation, computations, event_schema, created_at, last_activated_at, updated_at].hash end |
#list_invalid_properties ⇒ Object
Show invalid properties with the reasons. Usually used together with valid?
214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 |
# File 'lib/togai_client/models/usage_meter.rb', line 214 def list_invalid_properties warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' invalid_properties = Array.new if @id.nil? invalid_properties.push('invalid value for "id", id cannot be nil.') end if @id.to_s.length > 20 invalid_properties.push('invalid value for "id", the character length must be smaller than or equal to 20.') end if @name.nil? invalid_properties.push('invalid value for "name", name cannot be nil.') end if @name.to_s.length > 50 invalid_properties.push('invalid value for "name", the character length must be smaller than or equal to 50.') end pattern = Regexp.new(/^[\sa-zA-Z0-9_-]*$/) if @name !~ pattern invalid_properties.push("invalid value for \"name\", must conform to the pattern #{pattern}.") end if !@billable_name.nil? && @billable_name.to_s.length > 255 invalid_properties.push('invalid value for "billable_name", the character length must be smaller than or equal to 255.') end if @display_name.nil? invalid_properties.push('invalid value for "display_name", display_name cannot be nil.') end if @display_name.to_s.length > 255 invalid_properties.push('invalid value for "display_name", the character length must be smaller than or equal to 255.') end if !@description.nil? && @description.to_s.length > 255 invalid_properties.push('invalid value for "description", the character length must be smaller than or equal to 255.') end if @type.nil? invalid_properties.push('invalid value for "type", type cannot be nil.') end if @aggregation.nil? invalid_properties.push('invalid value for "aggregation", aggregation cannot be nil.') end if !@computations.nil? && @computations.length > 1 invalid_properties.push('invalid value for "computations", number of items must be less than or equal to 1.') end if !@computations.nil? && @computations.length < 0 invalid_properties.push('invalid value for "computations", number of items must be greater than or equal to 0.') end invalid_properties end |
#to_body ⇒ Hash
to_body is an alias to to_hash (backward compatibility)
517 518 519 |
# File 'lib/togai_client/models/usage_meter.rb', line 517 def to_body to_hash end |
#to_hash ⇒ Hash
Returns the object in the form of hash
523 524 525 526 527 528 529 530 531 532 533 534 535 |
# File 'lib/togai_client/models/usage_meter.rb', line 523 def to_hash hash = {} self.class.attribute_map.each_pair do |attr, param| value = self.send(attr) if value.nil? is_nullable = self.class.openapi_nullable.include?(attr) next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) end hash[param] = _to_hash(value) end hash end |
#to_s ⇒ String
Returns the string representation of the object
511 512 513 |
# File 'lib/togai_client/models/usage_meter.rb', line 511 def to_s to_hash.to_s end |
#valid? ⇒ Boolean
Check to see if the all the properties in the model are valid
275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 |
# File 'lib/togai_client/models/usage_meter.rb', line 275 def valid? warn '[DEPRECATED] the `valid?` method is obsolete' return false if @id.nil? return false if @id.to_s.length > 20 return false if @name.nil? return false if @name.to_s.length > 50 return false if @name !~ Regexp.new(/^[\sa-zA-Z0-9_-]*$/) return false if !@billable_name.nil? && @billable_name.to_s.length > 255 return false if @display_name.nil? return false if @display_name.to_s.length > 255 return false if !@description.nil? && @description.to_s.length > 255 return false if @type.nil? type_validator = EnumAttributeValidator.new('String', ["COUNTER"]) return false unless type_validator.valid?(@type) status_validator = EnumAttributeValidator.new('String', ["DRAFT", "ACTIVE", "INACTIVE", "ARCHIVED"]) return false unless status_validator.valid?(@status) return false if @aggregation.nil? return false if !@computations.nil? && @computations.length > 1 return false if !@computations.nil? && @computations.length < 0 true end |