Class: ApiReference::LicenseUsage

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

Overview

The LicenseUsage resource represents usage and remaining credits for a license over a date range. When grouped by 'day' only, license_id and external_license_id will be null as the data is aggregated across all licenses.

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(subscription_id:, license_type_id:, start_date:, end_date:, allocated_credits:, consumed_credits:, remaining_credits:, pricing_unit:, license_id: SKIP, external_license_id: SKIP, allocation_eligible_credits: SKIP, shared_pool_credits: SKIP, additional_properties: nil) ⇒ LicenseUsage

Returns a new instance of LicenseUsage.



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

def initialize(subscription_id:, license_type_id:, start_date:, end_date:,
               allocated_credits:, consumed_credits:, remaining_credits:,
               pricing_unit:, license_id: SKIP, external_license_id: SKIP,
               allocation_eligible_credits: SKIP, shared_pool_credits: SKIP,
               additional_properties: nil)
  # Add additional model properties to the instance
  additional_properties = {} if additional_properties.nil?

  @license_id = license_id unless license_id == SKIP
  @subscription_id = subscription_id
  @license_type_id = license_type_id
  @external_license_id = external_license_id unless external_license_id == SKIP
  @start_date = start_date
  @end_date = end_date
  @allocated_credits = allocated_credits
  @consumed_credits = consumed_credits
  @remaining_credits = remaining_credits
  @pricing_unit = pricing_unit
  unless allocation_eligible_credits == SKIP
    @allocation_eligible_credits =
      allocation_eligible_credits
  end
  @shared_pool_credits = shared_pool_credits unless shared_pool_credits == SKIP
  @additional_properties = additional_properties
end

Instance Attribute Details

#allocated_creditsFloat

The total credits allocated to this license for the period.

Returns:

  • (Float)


41
42
43
# File 'lib/api_reference/models/license_usage.rb', line 41

def allocated_credits
  @allocated_credits
end

#allocation_eligible_creditsFloat

Credits consumed while the license was active (eligible for individual allocation deduction).

Returns:

  • (Float)


58
59
60
# File 'lib/api_reference/models/license_usage.rb', line 58

def allocation_eligible_credits
  @allocation_eligible_credits
end

#consumed_creditsFloat

The credits consumed by this license for the period.

Returns:

  • (Float)


45
46
47
# File 'lib/api_reference/models/license_usage.rb', line 45

def consumed_credits
  @consumed_credits
end

#end_dateDate

The end date of the usage period.

Returns:

  • (Date)


37
38
39
# File 'lib/api_reference/models/license_usage.rb', line 37

def end_date
  @end_date
end

#external_license_idString

The external identifier for the license. Null when grouped by day only.

Returns:

  • (String)


29
30
31
# File 'lib/api_reference/models/license_usage.rb', line 29

def external_license_id
  @external_license_id
end

#license_idString

The unique identifier for the license. Null when grouped by day only.

Returns:

  • (String)


17
18
19
# File 'lib/api_reference/models/license_usage.rb', line 17

def license_id
  @license_id
end

#license_type_idString

The unique identifier for the license type.

Returns:

  • (String)


25
26
27
# File 'lib/api_reference/models/license_usage.rb', line 25

def license_type_id
  @license_type_id
end

#pricing_unitString

The pricing unit for the credits (e.g., 'credits').

Returns:

  • (String)


53
54
55
# File 'lib/api_reference/models/license_usage.rb', line 53

def pricing_unit
  @pricing_unit
end

#remaining_creditsFloat

The remaining credits available for this license (allocated - consumed).

Returns:

  • (Float)


49
50
51
# File 'lib/api_reference/models/license_usage.rb', line 49

def remaining_credits
  @remaining_credits
end

#shared_pool_creditsFloat

Credits consumed while the license was inactive (draws from shared pool, not individual allocation).

Returns:

  • (Float)


63
64
65
# File 'lib/api_reference/models/license_usage.rb', line 63

def shared_pool_credits
  @shared_pool_credits
end

#start_dateDate

The start date of the usage period.

Returns:

  • (Date)


33
34
35
# File 'lib/api_reference/models/license_usage.rb', line 33

def start_date
  @start_date
end

#subscription_idString

The unique identifier for the subscription.

Returns:

  • (String)


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

def subscription_id
  @subscription_id
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



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
# File 'lib/api_reference/models/license_usage.rb', line 130

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  subscription_id =
    hash.key?('subscription_id') ? hash['subscription_id'] : nil
  license_type_id =
    hash.key?('license_type_id') ? hash['license_type_id'] : nil
  start_date = hash.key?('start_date') ? hash['start_date'] : nil
  end_date = hash.key?('end_date') ? hash['end_date'] : nil
  allocated_credits =
    hash.key?('allocated_credits') ? hash['allocated_credits'] : nil
  consumed_credits =
    hash.key?('consumed_credits') ? hash['consumed_credits'] : nil
  remaining_credits =
    hash.key?('remaining_credits') ? hash['remaining_credits'] : nil
  pricing_unit = hash.key?('pricing_unit') ? hash['pricing_unit'] : nil
  license_id = hash.key?('license_id') ? hash['license_id'] : SKIP
  external_license_id =
    hash.key?('external_license_id') ? hash['external_license_id'] : SKIP
  allocation_eligible_credits =
    hash.key?('allocation_eligible_credits') ? hash['allocation_eligible_credits'] : SKIP
  shared_pool_credits =
    hash.key?('shared_pool_credits') ? hash['shared_pool_credits'] : SKIP

  # Create a new hash for additional properties, removing known properties.
  new_hash = hash.reject { |k, _| names.value?(k) }

  additional_properties = APIHelper.get_additional_properties(
    new_hash, proc { |value| value }
  )

  # Create object from extracted values.
  LicenseUsage.new(subscription_id: subscription_id,
                   license_type_id: license_type_id,
                   start_date: start_date,
                   end_date: end_date,
                   allocated_credits: allocated_credits,
                   consumed_credits: consumed_credits,
                   remaining_credits: remaining_credits,
                   pricing_unit: pricing_unit,
                   license_id: license_id,
                   external_license_id: external_license_id,
                   allocation_eligible_credits: allocation_eligible_credits,
                   shared_pool_credits: shared_pool_credits,
                   additional_properties: additional_properties)
end

.namesObject

A mapping from model property names to API property names.



66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
# File 'lib/api_reference/models/license_usage.rb', line 66

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['license_id'] = 'license_id'
  @_hash['subscription_id'] = 'subscription_id'
  @_hash['license_type_id'] = 'license_type_id'
  @_hash['external_license_id'] = 'external_license_id'
  @_hash['start_date'] = 'start_date'
  @_hash['end_date'] = 'end_date'
  @_hash['allocated_credits'] = 'allocated_credits'
  @_hash['consumed_credits'] = 'consumed_credits'
  @_hash['remaining_credits'] = 'remaining_credits'
  @_hash['pricing_unit'] = 'pricing_unit'
  @_hash['allocation_eligible_credits'] = 'allocation_eligible_credits'
  @_hash['shared_pool_credits'] = 'shared_pool_credits'
  @_hash
end

.nullablesObject

An array for nullable fields



94
95
96
97
98
99
100
101
# File 'lib/api_reference/models/license_usage.rb', line 94

def self.nullables
  %w[
    license_id
    external_license_id
    allocation_eligible_credits
    shared_pool_credits
  ]
end

.optionalsObject

An array for optional fields



84
85
86
87
88
89
90
91
# File 'lib/api_reference/models/license_usage.rb', line 84

def self.optionals
  %w[
    license_id
    external_license_id
    allocation_eligible_credits
    shared_pool_credits
  ]
end

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



191
192
193
194
195
196
197
198
199
200
201
# File 'lib/api_reference/models/license_usage.rb', line 191

def inspect
  class_name = self.class.name.split('::').last
  "<#{class_name} license_id: #{@license_id.inspect}, subscription_id:"\
  " #{@subscription_id.inspect}, license_type_id: #{@license_type_id.inspect},"\
  " external_license_id: #{@external_license_id.inspect}, start_date: #{@start_date.inspect},"\
  " end_date: #{@end_date.inspect}, allocated_credits: #{@allocated_credits.inspect},"\
  " consumed_credits: #{@consumed_credits.inspect}, remaining_credits:"\
  " #{@remaining_credits.inspect}, pricing_unit: #{@pricing_unit.inspect},"\
  " allocation_eligible_credits: #{@allocation_eligible_credits.inspect}, shared_pool_credits:"\
  " #{@shared_pool_credits.inspect}, additional_properties: #{@additional_properties}>"
end

#to_sObject

Provides a human-readable string representation of the object.



179
180
181
182
183
184
185
186
187
188
# File 'lib/api_reference/models/license_usage.rb', line 179

def to_s
  class_name = self.class.name.split('::').last
  "<#{class_name} license_id: #{@license_id}, subscription_id: #{@subscription_id},"\
  " license_type_id: #{@license_type_id}, external_license_id: #{@external_license_id},"\
  " start_date: #{@start_date}, end_date: #{@end_date}, allocated_credits:"\
  " #{@allocated_credits}, consumed_credits: #{@consumed_credits}, remaining_credits:"\
  " #{@remaining_credits}, pricing_unit: #{@pricing_unit}, allocation_eligible_credits:"\
  " #{@allocation_eligible_credits}, shared_pool_credits: #{@shared_pool_credits},"\
  " additional_properties: #{@additional_properties}>"
end