Class: ApiReference::MeteredAllowanceConfig1

Inherits:
BaseModel
  • Object
show all
Defined in:
lib/api_reference/models/metered_allowance_config1.rb

Overview

Configuration for metered_allowance pricing

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from BaseModel

#check_for_conflict, #process_additional_properties, #process_array, #process_basic_value, #process_hash, #to_hash, #to_json

Constructor Details

#initialize(grouping_key:, consumption_grouping_value:, allowance_grouping_value:, unit_amount:, consumption_display_name: 'Consumption', allowance_display_name: 'Allowance credit') ⇒ MeteredAllowanceConfig1

Returns a new instance of MeteredAllowanceConfig1.



66
67
68
69
70
71
72
73
74
75
76
# File 'lib/api_reference/models/metered_allowance_config1.rb', line 66

def initialize(grouping_key:, consumption_grouping_value:,
               allowance_grouping_value:, unit_amount:,
               consumption_display_name: 'Consumption',
               allowance_display_name: 'Allowance credit')
  @grouping_key = grouping_key
  @consumption_grouping_value = consumption_grouping_value
  @allowance_grouping_value = allowance_grouping_value
  @unit_amount = unit_amount
  @consumption_display_name = consumption_display_name unless consumption_display_name == SKIP
  @allowance_display_name = allowance_display_name unless allowance_display_name == SKIP
end

Instance Attribute Details

#allowance_display_nameString

Sub-line label for the credit row (e.g. 'Up to 3x free egress').

Returns:

  • (String)


39
40
41
# File 'lib/api_reference/models/metered_allowance_config1.rb', line 39

def allowance_display_name
  @allowance_display_name
end

#allowance_grouping_valueString

The grouping_key value whose summed quantity represents the allowance for this period (e.g. 'storage_snapshot' emitting 3 × avg storage). Capped at consumption — credit can never exceed actual usage.

Returns:

  • (String)


27
28
29
# File 'lib/api_reference/models/metered_allowance_config1.rb', line 27

def allowance_grouping_value
  @allowance_grouping_value
end

#consumption_display_nameString

Sub-line label for the gross consumption row (e.g. 'bytes gotten').

Returns:

  • (String)


35
36
37
# File 'lib/api_reference/models/metered_allowance_config1.rb', line 35

def consumption_display_name
  @consumption_display_name
end

#consumption_grouping_valueString

The grouping_key value whose summed quantity represents consumption (e.g. 'download'). Charged at unit_amount.

Returns:

  • (String)


21
22
23
# File 'lib/api_reference/models/metered_allowance_config1.rb', line 21

def consumption_grouping_value
  @consumption_grouping_value
end

#grouping_keyString

Event property used to partition the metric into consumption and allowance quantities (e.g. 'event_name'). The metric is queried with this key and the two values below select which partition is which.

Returns:

  • (String)


16
17
18
# File 'lib/api_reference/models/metered_allowance_config1.rb', line 16

def grouping_key
  @grouping_key
end

#unit_amountString

Per-unit price applied to gross consumption and to the allowance credit.

Returns:

  • (String)


31
32
33
# File 'lib/api_reference/models/metered_allowance_config1.rb', line 31

def unit_amount
  @unit_amount
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
# File 'lib/api_reference/models/metered_allowance_config1.rb', line 79

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  grouping_key = hash.key?('grouping_key') ? hash['grouping_key'] : nil
  consumption_grouping_value =
    hash.key?('consumption_grouping_value') ? hash['consumption_grouping_value'] : nil
  allowance_grouping_value =
    hash.key?('allowance_grouping_value') ? hash['allowance_grouping_value'] : nil
  unit_amount = hash.key?('unit_amount') ? hash['unit_amount'] : nil
  consumption_display_name =
    hash['consumption_display_name'] ||= 'Consumption'
  allowance_display_name =
    hash['allowance_display_name'] ||= 'Allowance credit'

  # Create object from extracted values.
  MeteredAllowanceConfig1.new(grouping_key: grouping_key,
                              consumption_grouping_value: consumption_grouping_value,
                              allowance_grouping_value: allowance_grouping_value,
                              unit_amount: unit_amount,
                              consumption_display_name: consumption_display_name,
                              allowance_display_name: allowance_display_name)
end

.namesObject

A mapping from model property names to API property names.



42
43
44
45
46
47
48
49
50
51
# File 'lib/api_reference/models/metered_allowance_config1.rb', line 42

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['grouping_key'] = 'grouping_key'
  @_hash['consumption_grouping_value'] = 'consumption_grouping_value'
  @_hash['allowance_grouping_value'] = 'allowance_grouping_value'
  @_hash['unit_amount'] = 'unit_amount'
  @_hash['consumption_display_name'] = 'consumption_display_name'
  @_hash['allowance_display_name'] = 'allowance_display_name'
  @_hash
end

.nullablesObject

An array for nullable fields



62
63
64
# File 'lib/api_reference/models/metered_allowance_config1.rb', line 62

def self.nullables
  []
end

.optionalsObject

An array for optional fields



54
55
56
57
58
59
# File 'lib/api_reference/models/metered_allowance_config1.rb', line 54

def self.optionals
  %w[
    consumption_display_name
    allowance_display_name
  ]
end

.validate(value) ⇒ Object

Validates an instance of the object from a given value.

Parameters:



105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
# File 'lib/api_reference/models/metered_allowance_config1.rb', line 105

def self.validate(value)
  if value.instance_of? self
    return (
      APIHelper.valid_type?(value.grouping_key,
                            ->(val) { val.instance_of? String }) and
        APIHelper.valid_type?(value.consumption_grouping_value,
                              ->(val) { val.instance_of? String }) and
        APIHelper.valid_type?(value.allowance_grouping_value,
                              ->(val) { val.instance_of? String }) and
        APIHelper.valid_type?(value.unit_amount,
                              ->(val) { val.instance_of? String })
    )
  end

  return false unless value.instance_of? Hash

  (
    APIHelper.valid_type?(value['grouping_key'],
                          ->(val) { val.instance_of? String }) and
      APIHelper.valid_type?(value['consumption_grouping_value'],
                            ->(val) { val.instance_of? String }) and
      APIHelper.valid_type?(value['allowance_grouping_value'],
                            ->(val) { val.instance_of? String }) and
      APIHelper.valid_type?(value['unit_amount'],
                            ->(val) { val.instance_of? String })
  )
end

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



143
144
145
146
147
148
149
150
# File 'lib/api_reference/models/metered_allowance_config1.rb', line 143

def inspect
  class_name = self.class.name.split('::').last
  "<#{class_name} grouping_key: #{@grouping_key.inspect}, consumption_grouping_value:"\
  " #{@consumption_grouping_value.inspect}, allowance_grouping_value:"\
  " #{@allowance_grouping_value.inspect}, unit_amount: #{@unit_amount.inspect},"\
  " consumption_display_name: #{@consumption_display_name.inspect}, allowance_display_name:"\
  " #{@allowance_display_name.inspect}>"
end

#to_sObject

Provides a human-readable string representation of the object.



134
135
136
137
138
139
140
# File 'lib/api_reference/models/metered_allowance_config1.rb', line 134

def to_s
  class_name = self.class.name.split('::').last
  "<#{class_name} grouping_key: #{@grouping_key}, consumption_grouping_value:"\
  " #{@consumption_grouping_value}, allowance_grouping_value: #{@allowance_grouping_value},"\
  " unit_amount: #{@unit_amount}, consumption_display_name: #{@consumption_display_name},"\
  " allowance_display_name: #{@allowance_display_name}>"
end