Class: BillingApi::PublicSubnetRecord

Inherits:
ApiModelBase 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

Methods inherited from ApiModelBase

_deserialize, #_to_hash, #to_body, #to_s

Constructor Details

#initialize(attributes = {}) ⇒ PublicSubnetRecord

Initializes the object

Parameters:

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

    Model attributes in the form of hash



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
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
# File 'lib/pnap_billing_api/models/public_subnet_record.rb', line 181

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
  acceptable_attribute_map = self.class.acceptable_attribute_map
  attributes = attributes.each_with_object({}) { |(k, v), h|
    if (!acceptable_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: " + acceptable_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']
  end

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

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

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

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

  if attributes.key?(:'credit_details')
    if (value = attributes[:'credit_details']).is_a?(Array)
      self.credit_details = value
    end
  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.



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

def active
  @active
end

#correlation_idObject

Holds usage record id



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

def correlation_id
  @correlation_id
end

#costObject

The rated usage in cents.



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

def cost
  @cost
end

#cost_before_discountObject

The cost in cents before discount.



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

def cost_before_discount
  @cost_before_discount
end

#cost_descriptionObject

The rated usage cost description.



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

def cost_description
  @cost_description
end

#credit_detailsObject

Returns the value of attribute credit_details.



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

def credit_details
  @credit_details
end

#discount_detailsObject

Returns the value of attribute discount_details.



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

def discount_details
  @discount_details
end

#end_date_timeObject

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



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

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.



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

def location
  @location
end

#metadataObject

Returns the value of attribute metadata.



76
77
78
# File 'lib/pnap_billing_api/models/public_subnet_record.rb', line 76

def 
  @metadata
end

#price_modelObject

The price model applied to this usage record.



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

def price_model
  @price_model
end

#product_categoryObject

Returns the value of attribute product_category.



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

def product_category
  @product_category
end

#product_codeObject

The code identifying the product associated to this usage record.



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

def product_code
  @product_code
end

#quantityObject

The number of units being charged.



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

def quantity
  @quantity
end

#reservation_detailsObject

Returns the value of attribute reservation_details.



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

def reservation_details
  @reservation_details
end

#reservation_idObject

Reservation id associated with this rated usage record.



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

def reservation_id
  @reservation_id
end

#start_date_timeObject

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



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

def start_date_time
  @start_date_time
end

#unit_priceObject

The unit price.



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

def unit_price
  @unit_price
end

#unit_price_descriptionObject

User friendly description of the unit price.



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

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.



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

def usage_session_id
  @usage_session_id
end

#year_monthObject

Year and month of the usage record.



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

def year_month
  @year_month
end

Class Method Details

.acceptable_attribute_mapObject

Returns attribute mapping this model knows about



129
130
131
# File 'lib/pnap_billing_api/models/public_subnet_record.rb', line 129

def self.acceptable_attribute_map
  attribute_map
end

.acceptable_attributesObject

Returns all the JSON keys this model knows about



134
135
136
# File 'lib/pnap_billing_api/models/public_subnet_record.rb', line 134

def self.acceptable_attributes
  acceptable_attribute_map.values
end

.attribute_mapObject

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



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

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',
    :'reservation_details' => :'reservationDetails',
    :'discount_details' => :'discountDetails',
    :'credit_details' => :'creditDetails',
    :'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



566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
# File 'lib/pnap_billing_api/models/public_subnet_record.rb', line 566

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)



173
174
175
176
177
# File 'lib/pnap_billing_api/models/public_subnet_record.rb', line 173

def self.openapi_all_of
  [
  :'RatedUsageRecord'
  ]
end

.openapi_nullableObject

List of attributes with nullable: true



167
168
169
170
# File 'lib/pnap_billing_api/models/public_subnet_record.rb', line 167

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

.openapi_typesObject

Attribute type mapping.



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
# File 'lib/pnap_billing_api/models/public_subnet_record.rb', line 139

def self.openapi_types
  {
    :'id' => :'String',
    :'product_category' => :'RatedUsageProductCategoryEnum',
    :'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',
    :'reservation_details' => :'ReservationDetails',
    :'discount_details' => :'ApplicableDiscountDetails',
    :'credit_details' => :'Array<CreditDetails>',
    :'metadata' => :'PublicSubnetDetails'
  }
end

Instance Method Details

#==(o) ⇒ Object

Checks equality by comparing each attribute.

Parameters:

  • Object (Object)

    to be compared



524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
# File 'lib/pnap_billing_api/models/public_subnet_record.rb', line 524

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 &&
      reservation_details == o.reservation_details &&
      discount_details == o.discount_details &&
      credit_details == o.credit_details &&
       == o.
end

#eql?(o) ⇒ Boolean

Parameters:

  • Object (Object)

    to be compared

Returns:

  • (Boolean)

See Also:

  • `==` method


553
554
555
# File 'lib/pnap_billing_api/models/public_subnet_record.rb', line 553

def eql?(o)
  self == o
end

#hashInteger

Calculates hash code according to all attributes.

Returns:

  • (Integer)

    Hash code



559
560
561
# File 'lib/pnap_billing_api/models/public_subnet_record.rb', line 559

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, reservation_details, discount_details, credit_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



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
360
361
362
363
364
365
366
367
368
369
370
# File 'lib/pnap_billing_api/models/public_subnet_record.rb', line 314

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

  invalid_properties
end

#to_hashHash

Returns the object in the form of hash

Returns:

  • (Hash)

    Returns the object in the form of hash



588
589
590
591
592
593
594
595
596
597
598
599
600
# File 'lib/pnap_billing_api/models/public_subnet_record.rb', line 588

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

#valid?Boolean

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

Returns:

  • (Boolean)

    true if the model is valid



374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
# File 'lib/pnap_billing_api/models/public_subnet_record.rb', line 374

def valid?
  warn '[DEPRECATED] the `valid?` method is obsolete'
  return false if @id.nil?
  return false if @product_category.nil?
  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 @metadata.nil?
  true
end