Class: BillingApi::PublicSubnetRecord

Inherits:
Object
  • Object
show all
Defined in:
lib/pnap_billing_api/models/public_subnet_record.rb

Defined Under Namespace

Classes: EnumAttributeValidator

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(attributes = {}) ⇒ PublicSubnetRecord

Initializes the object

Parameters:

  • attributes (Hash) (defaults to: {})

    Model attributes in the form of hash



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
211
212
213
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
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
# File 'lib/pnap_billing_api/models/public_subnet_record.rb', line 169

def initialize(attributes = {})
  if (!attributes.is_a?(Hash))
    fail ArgumentError, "The input argument (attributes) must be a hash in `BillingApi::PublicSubnetRecord` 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 `BillingApi::PublicSubnetRecord`. 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?(:'product_category')
    self.product_category = attributes[:'product_category']
  else
    self.product_category = nil
  end

  if attributes.key?(:'product_code')
    self.product_code = attributes[:'product_code']
  else
    self.product_code = nil
  end

  if attributes.key?(:'location')
    self.location = attributes[:'location']
  else
    self.location = nil
  end

  if attributes.key?(:'year_month')
    self.year_month = attributes[:'year_month']
  end

  if attributes.key?(:'start_date_time')
    self.start_date_time = attributes[:'start_date_time']
  else
    self.start_date_time = nil
  end

  if attributes.key?(:'end_date_time')
    self.end_date_time = attributes[:'end_date_time']
  else
    self.end_date_time = nil
  end

  if attributes.key?(:'cost')
    self.cost = attributes[:'cost']
  else
    self.cost = nil
  end

  if attributes.key?(:'cost_before_discount')
    self.cost_before_discount = attributes[:'cost_before_discount']
  end

  if attributes.key?(:'cost_description')
    self.cost_description = attributes[:'cost_description']
  end

  if attributes.key?(:'price_model')
    self.price_model = attributes[:'price_model']
  else
    self.price_model = nil
  end

  if attributes.key?(:'unit_price')
    self.unit_price = attributes[:'unit_price']
  else
    self.unit_price = nil
  end

  if attributes.key?(:'unit_price_description')
    self.unit_price_description = attributes[:'unit_price_description']
  else
    self.unit_price_description = nil
  end

  if attributes.key?(:'quantity')
    self.quantity = attributes[:'quantity']
  else
    self.quantity = nil
  end

  if attributes.key?(:'active')
    self.active = attributes[:'active']
  else
    self.active = nil
  end

  if attributes.key?(:'usage_session_id')
    self.usage_session_id = attributes[:'usage_session_id']
  else
    self.usage_session_id = nil
  end

  if attributes.key?(:'correlation_id')
    self.correlation_id = attributes[:'correlation_id']
  else
    self.correlation_id = nil
  end

  if attributes.key?(:'reservation_id')
    self.reservation_id = attributes[:'reservation_id']
  end

  if attributes.key?(:'discount_details')
    self.discount_details = attributes[:'discount_details']
  end

  if attributes.key?(:'metadata')
    self. = attributes[:'metadata']
  else
    self. = nil
  end
end

Instance Attribute Details

#activeObject

A flag indicating whether the rated usage record is still active.



60
61
62
# File 'lib/pnap_billing_api/models/public_subnet_record.rb', line 60

def active
  @active
end

#correlation_idObject

Holds usage record id



66
67
68
# File 'lib/pnap_billing_api/models/public_subnet_record.rb', line 66

def correlation_id
  @correlation_id
end

#costObject

The rated usage in cents.



39
40
41
# File 'lib/pnap_billing_api/models/public_subnet_record.rb', line 39

def cost
  @cost
end

#cost_before_discountObject

The cost in cents before discount.



42
43
44
# File 'lib/pnap_billing_api/models/public_subnet_record.rb', line 42

def cost_before_discount
  @cost_before_discount
end

#cost_descriptionObject

The rated usage cost description.



45
46
47
# File 'lib/pnap_billing_api/models/public_subnet_record.rb', line 45

def cost_description
  @cost_description
end

#discount_detailsObject

Returns the value of attribute discount_details.



71
72
73
# File 'lib/pnap_billing_api/models/public_subnet_record.rb', line 71

def discount_details
  @discount_details
end

#end_date_timeObject

The point in time (in UTC) until usage has been rated.



36
37
38
# File 'lib/pnap_billing_api/models/public_subnet_record.rb', line 36

def end_date_time
  @end_date_time
end

#idObject

The unique identifier of the rated usage record.



19
20
21
# File 'lib/pnap_billing_api/models/public_subnet_record.rb', line 19

def id
  @id
end

#locationObject

Returns the value of attribute location.



27
28
29
# File 'lib/pnap_billing_api/models/public_subnet_record.rb', line 27

def location
  @location
end

#metadataObject

Returns the value of attribute metadata.



73
74
75
# File 'lib/pnap_billing_api/models/public_subnet_record.rb', line 73

def 
  @metadata
end

#price_modelObject

The price model applied to this usage record.



48
49
50
# File 'lib/pnap_billing_api/models/public_subnet_record.rb', line 48

def price_model
  @price_model
end

#product_categoryObject

The category of the product associated with this usage record.



22
23
24
# File 'lib/pnap_billing_api/models/public_subnet_record.rb', line 22

def product_category
  @product_category
end

#product_codeObject

The code identifying the product associated to this usage record.



25
26
27
# File 'lib/pnap_billing_api/models/public_subnet_record.rb', line 25

def product_code
  @product_code
end

#quantityObject

The number of units being charged.



57
58
59
# File 'lib/pnap_billing_api/models/public_subnet_record.rb', line 57

def quantity
  @quantity
end

#reservation_idObject

Reservation id associated with this rated usage record.



69
70
71
# File 'lib/pnap_billing_api/models/public_subnet_record.rb', line 69

def reservation_id
  @reservation_id
end

#start_date_timeObject

The point in time (in UTC) when usage has started.



33
34
35
# File 'lib/pnap_billing_api/models/public_subnet_record.rb', line 33

def start_date_time
  @start_date_time
end

#unit_priceObject

The unit price.



51
52
53
# File 'lib/pnap_billing_api/models/public_subnet_record.rb', line 51

def unit_price
  @unit_price
end

#unit_price_descriptionObject

User friendly description of the unit price.



54
55
56
# File 'lib/pnap_billing_api/models/public_subnet_record.rb', line 54

def unit_price_description
  @unit_price_description
end

#usage_session_idObject

The usage session ID is used to correlate rated usage records across periods of time. For example, a server used for over a month will generate multiple rated usage records. The entire usage session cost can be computed by aggregating the records having the same usage session ID. It is usual to have one rated usage record per month or invoice.



63
64
65
# File 'lib/pnap_billing_api/models/public_subnet_record.rb', line 63

def usage_session_id
  @usage_session_id
end

#year_monthObject

Year and month of the usage record.



30
31
32
# File 'lib/pnap_billing_api/models/public_subnet_record.rb', line 30

def year_month
  @year_month
end

Class Method Details

._deserialize(type, value) ⇒ Object

Deserializes the data based on type

Parameters:

  • string

    type Data type

  • string

    value Value to be deserialized

Returns:

  • (Object)

    Deserialized data



461
462
463
464
465
466
467
468
469
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
# File 'lib/pnap_billing_api/models/public_subnet_record.rb', line 461

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 = BillingApi.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_attributesObject

Returns all the JSON keys this model knows about



124
125
126
# File 'lib/pnap_billing_api/models/public_subnet_record.rb', line 124

def self.acceptable_attributes
  attribute_map.values
end

.attribute_mapObject

Attribute mapping from ruby-style variable name to JSON key.



98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
# File 'lib/pnap_billing_api/models/public_subnet_record.rb', line 98

def self.attribute_map
  {
    :'id' => :'id',
    :'product_category' => :'productCategory',
    :'product_code' => :'productCode',
    :'location' => :'location',
    :'year_month' => :'yearMonth',
    :'start_date_time' => :'startDateTime',
    :'end_date_time' => :'endDateTime',
    :'cost' => :'cost',
    :'cost_before_discount' => :'costBeforeDiscount',
    :'cost_description' => :'costDescription',
    :'price_model' => :'priceModel',
    :'unit_price' => :'unitPrice',
    :'unit_price_description' => :'unitPriceDescription',
    :'quantity' => :'quantity',
    :'active' => :'active',
    :'usage_session_id' => :'usageSessionId',
    :'correlation_id' => :'correlationId',
    :'reservation_id' => :'reservationId',
    :'discount_details' => :'discountDetails',
    :'metadata' => :'metadata'
  }
end

.build_from_hash(attributes) ⇒ Object

Builds the object from hash

Parameters:

  • attributes (Hash)

    Model attributes in the form of hash

Returns:

  • (Object)

    Returns the model itself



437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
# File 'lib/pnap_billing_api/models/public_subnet_record.rb', line 437

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_all_ofObject

List of class defined in allOf (OpenAPI v3)



161
162
163
164
165
# File 'lib/pnap_billing_api/models/public_subnet_record.rb', line 161

def self.openapi_all_of
  [
  :'RatedUsageRecord'
  ]
end

.openapi_nullableObject

List of attributes with nullable: true



155
156
157
158
# File 'lib/pnap_billing_api/models/public_subnet_record.rb', line 155

def self.openapi_nullable
  Set.new([
  ])
end

.openapi_typesObject

Attribute type mapping.



129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
# File 'lib/pnap_billing_api/models/public_subnet_record.rb', line 129

def self.openapi_types
  {
    :'id' => :'String',
    :'product_category' => :'String',
    :'product_code' => :'String',
    :'location' => :'LocationEnum',
    :'year_month' => :'String',
    :'start_date_time' => :'Time',
    :'end_date_time' => :'Time',
    :'cost' => :'Integer',
    :'cost_before_discount' => :'Integer',
    :'cost_description' => :'String',
    :'price_model' => :'String',
    :'unit_price' => :'Float',
    :'unit_price_description' => :'String',
    :'quantity' => :'Float',
    :'active' => :'Boolean',
    :'usage_session_id' => :'String',
    :'correlation_id' => :'String',
    :'reservation_id' => :'String',
    :'discount_details' => :'DiscountDetails',
    :'metadata' => :'PublicSubnetDetails'
  }
end

Instance Method Details

#==(o) ⇒ Object

Checks equality by comparing each attribute.

Parameters:

  • Object (Object)

    to be compared



397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
# File 'lib/pnap_billing_api/models/public_subnet_record.rb', line 397

def ==(o)
  return true if self.equal?(o)
  self.class == o.class &&
      id == o.id &&
      product_category == o.product_category &&
      product_code == o.product_code &&
      location == o.location &&
      year_month == o.year_month &&
      start_date_time == o.start_date_time &&
      end_date_time == o.end_date_time &&
      cost == o.cost &&
      cost_before_discount == o.cost_before_discount &&
      cost_description == o.cost_description &&
      price_model == o.price_model &&
      unit_price == o.unit_price &&
      unit_price_description == o.unit_price_description &&
      quantity == o.quantity &&
      active == o.active &&
      usage_session_id == o.usage_session_id &&
      correlation_id == o.correlation_id &&
      reservation_id == o.reservation_id &&
      discount_details == o.discount_details &&
       == o.
end

#_to_hash(value) ⇒ Hash

Outputs non-array value in the form of hash For object, use to_hash. Otherwise, just return the value

Parameters:

  • value (Object)

    Any valid value

Returns:

  • (Hash)

    Returns the value in the form of hash



532
533
534
535
536
537
538
539
540
541
542
543
544
# File 'lib/pnap_billing_api/models/public_subnet_record.rb', line 532

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

Parameters:

  • Object (Object)

    to be compared

Returns:

  • (Boolean)

See Also:

  • `==` method


424
425
426
# File 'lib/pnap_billing_api/models/public_subnet_record.rb', line 424

def eql?(o)
  self == o
end

#hashInteger

Calculates hash code according to all attributes.

Returns:

  • (Integer)

    Hash code



430
431
432
# File 'lib/pnap_billing_api/models/public_subnet_record.rb', line 430

def hash
  [id, product_category, product_code, location, year_month, start_date_time, end_date_time, cost, cost_before_discount, cost_description, price_model, unit_price, unit_price_description, quantity, active, usage_session_id, correlation_id, reservation_id, discount_details, ].hash
end

#list_invalid_propertiesObject

Show invalid properties with the reasons. Usually used together with valid?

Returns:

  • Array for valid properties with the reasons



295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
# File 'lib/pnap_billing_api/models/public_subnet_record.rb', line 295

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 @product_category.nil?
    invalid_properties.push('invalid value for "product_category", product_category cannot be nil.')
  end

  if @product_code.nil?
    invalid_properties.push('invalid value for "product_code", product_code cannot be nil.')
  end

  if @location.nil?
    invalid_properties.push('invalid value for "location", location cannot be nil.')
  end

  if @start_date_time.nil?
    invalid_properties.push('invalid value for "start_date_time", start_date_time cannot be nil.')
  end

  if @end_date_time.nil?
    invalid_properties.push('invalid value for "end_date_time", end_date_time cannot be nil.')
  end

  if @cost.nil?
    invalid_properties.push('invalid value for "cost", cost cannot be nil.')
  end

  if @price_model.nil?
    invalid_properties.push('invalid value for "price_model", price_model cannot be nil.')
  end

  if @unit_price.nil?
    invalid_properties.push('invalid value for "unit_price", unit_price cannot be nil.')
  end

  if @unit_price_description.nil?
    invalid_properties.push('invalid value for "unit_price_description", unit_price_description cannot be nil.')
  end

  if @quantity.nil?
    invalid_properties.push('invalid value for "quantity", quantity cannot be nil.')
  end

  if @active.nil?
    invalid_properties.push('invalid value for "active", active cannot be nil.')
  end

  if @usage_session_id.nil?
    invalid_properties.push('invalid value for "usage_session_id", usage_session_id cannot be nil.')
  end

  if @correlation_id.nil?
    invalid_properties.push('invalid value for "correlation_id", correlation_id cannot be nil.')
  end

  if @metadata.nil?
    invalid_properties.push('invalid value for "metadata", metadata cannot be nil.')
  end

  invalid_properties
end

#to_bodyHash

to_body is an alias to to_hash (backward compatibility)

Returns:

  • (Hash)

    Returns the object in the form of hash



508
509
510
# File 'lib/pnap_billing_api/models/public_subnet_record.rb', line 508

def to_body
  to_hash
end

#to_hashHash

Returns the object in the form of hash

Returns:

  • (Hash)

    Returns the object in the form of hash



514
515
516
517
518
519
520
521
522
523
524
525
526
# File 'lib/pnap_billing_api/models/public_subnet_record.rb', line 514

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_sString

Returns the string representation of the object

Returns:

  • (String)

    String presentation of the object



502
503
504
# File 'lib/pnap_billing_api/models/public_subnet_record.rb', line 502

def to_s
  to_hash.to_s
end

#valid?Boolean

Check to see if the all the properties in the model are valid

Returns:

  • (Boolean)

    true if the model is valid



363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
# File 'lib/pnap_billing_api/models/public_subnet_record.rb', line 363

def valid?
  warn '[DEPRECATED] the `valid?` method is obsolete'
  return false if @id.nil?
  return false if @product_category.nil?
  product_category_validator = EnumAttributeValidator.new('String', ["bmc-server", "bandwidth", "operating-system", "public-ip", "storage"])
  return false unless product_category_validator.valid?(@product_category)
  return false if @product_code.nil?
  return false if @location.nil?
  return false if @start_date_time.nil?
  return false if @end_date_time.nil?
  return false if @cost.nil?
  return false if @price_model.nil?
  return false if @unit_price.nil?
  return false if @unit_price_description.nil?
  return false if @quantity.nil?
  return false if @active.nil?
  return false if @usage_session_id.nil?
  return false if @correlation_id.nil?
  return false if @metadata.nil?
  true
end