Class: ApiReference::MeteredAllowanceConfig
- Inherits:
-
BaseModel
- Object
- CoreLibrary::BaseModel
- BaseModel
- ApiReference::MeteredAllowanceConfig
- Defined in:
- lib/api_reference/models/metered_allowance_config.rb
Overview
Charges a per-unit rate on consumption above an allowance whose size is
itself metered from usage in the same period. Both quantities come from a
single billable metric, partitioned by grouping_key. The line item shows
two sub-lines under one parent: the gross consumption row and a (negative)
allowance credit row. The parent line equals the net charge, never negative
— so adjustments, tax, prepaid credits, and rev rec all behave like any
other usage line. Use cases: free egress proportional to bytes stored; free
outbound bandwidth proportional to compute hours; free messages proportional
to seat count; free output tokens proportional to input tokens.
Instance Attribute Summary collapse
-
#allowance_display_name ⇒ String
Sub-line label for the credit row (e.g. 'Up to 3x free egress').
-
#allowance_grouping_value ⇒ String
The grouping_key value whose summed quantity represents the allowance for this period (e.g. 'storage_snapshot' emitting 3 × avg storage).
-
#consumption_display_name ⇒ String
Sub-line label for the gross consumption row (e.g. 'bytes gotten').
-
#consumption_grouping_value ⇒ String
The grouping_key value whose summed quantity represents consumption (e.g. 'download').
-
#grouping_key ⇒ String
Event property used to partition the metric into consumption and allowance quantities (e.g. 'event_name').
-
#unit_amount ⇒ String
Per-unit price applied to gross consumption and to the allowance credit.
Class Method Summary collapse
-
.from_hash(hash) ⇒ Object
Creates an instance of the object from a hash.
-
.names ⇒ Object
A mapping from model property names to API property names.
-
.nullables ⇒ Object
An array for nullable fields.
-
.optionals ⇒ Object
An array for optional fields.
Instance Method Summary collapse
-
#initialize(grouping_key:, consumption_grouping_value:, allowance_grouping_value:, unit_amount:, consumption_display_name: 'Consumption', allowance_display_name: 'Allowance credit') ⇒ MeteredAllowanceConfig
constructor
A new instance of MeteredAllowanceConfig.
-
#inspect ⇒ Object
Provides a debugging-friendly string with detailed object information.
-
#to_s ⇒ Object
Provides a human-readable string representation of the object.
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') ⇒ MeteredAllowanceConfig
Returns a new instance of MeteredAllowanceConfig.
74 75 76 77 78 79 80 81 82 83 84 |
# File 'lib/api_reference/models/metered_allowance_config.rb', line 74 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_name ⇒ String
Sub-line label for the credit row (e.g. 'Up to 3x free egress').
47 48 49 |
# File 'lib/api_reference/models/metered_allowance_config.rb', line 47 def allowance_display_name @allowance_display_name end |
#allowance_grouping_value ⇒ String
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.
35 36 37 |
# File 'lib/api_reference/models/metered_allowance_config.rb', line 35 def allowance_grouping_value @allowance_grouping_value end |
#consumption_display_name ⇒ String
Sub-line label for the gross consumption row (e.g. 'bytes gotten').
43 44 45 |
# File 'lib/api_reference/models/metered_allowance_config.rb', line 43 def consumption_display_name @consumption_display_name end |
#consumption_grouping_value ⇒ String
The grouping_key value whose summed quantity represents consumption (e.g. 'download'). Charged at unit_amount.
29 30 31 |
# File 'lib/api_reference/models/metered_allowance_config.rb', line 29 def consumption_grouping_value @consumption_grouping_value end |
#grouping_key ⇒ String
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.
24 25 26 |
# File 'lib/api_reference/models/metered_allowance_config.rb', line 24 def grouping_key @grouping_key end |
#unit_amount ⇒ String
Per-unit price applied to gross consumption and to the allowance credit.
39 40 41 |
# File 'lib/api_reference/models/metered_allowance_config.rb', line 39 def unit_amount @unit_amount end |
Class Method Details
.from_hash(hash) ⇒ Object
Creates an instance of the object from a hash.
87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 |
# File 'lib/api_reference/models/metered_allowance_config.rb', line 87 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. MeteredAllowanceConfig.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 |
.names ⇒ Object
A mapping from model property names to API property names.
50 51 52 53 54 55 56 57 58 59 |
# File 'lib/api_reference/models/metered_allowance_config.rb', line 50 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 |
.nullables ⇒ Object
An array for nullable fields
70 71 72 |
# File 'lib/api_reference/models/metered_allowance_config.rb', line 70 def self.nullables [] end |
.optionals ⇒ Object
An array for optional fields
62 63 64 65 66 67 |
# File 'lib/api_reference/models/metered_allowance_config.rb', line 62 def self.optionals %w[ consumption_display_name allowance_display_name ] end |
Instance Method Details
#inspect ⇒ Object
Provides a debugging-friendly string with detailed object information.
121 122 123 124 125 126 127 128 |
# File 'lib/api_reference/models/metered_allowance_config.rb', line 121 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_s ⇒ Object
Provides a human-readable string representation of the object.
112 113 114 115 116 117 118 |
# File 'lib/api_reference/models/metered_allowance_config.rb', line 112 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 |