Class: OCI::UsageApi::Models::UsageCarbonEmissionSummary

Inherits:
Object
  • Object
show all
Defined in:
lib/oci/usage_api/models/usage_carbon_emission_summary.rb

Overview

The carbon emission usage store result.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(attributes = {}) ⇒ UsageCarbonEmissionSummary

Initializes the object

Parameters:

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

    Model attributes in the form of hash

Options Hash (attributes):

  • :tenant_id (String)

    The value to assign to the #tenant_id property

  • :tenant_name (String)

    The value to assign to the #tenant_name property

  • :compartment_id (String)

    The value to assign to the #compartment_id property

  • :compartment_path (String)

    The value to assign to the #compartment_path property

  • :compartment_name (String)

    The value to assign to the #compartment_name property

  • :service (String)

    The value to assign to the #service property

  • :resource_name (String)

    The value to assign to the #resource_name property

  • :resource_id (String)

    The value to assign to the #resource_id property

  • :region (String)

    The value to assign to the #region property

  • :ad (String)

    The value to assign to the #ad property

  • :sku_part_number (String)

    The value to assign to the #sku_part_number property

  • :sku_name (String)

    The value to assign to the #sku_name property

  • :platform (String)

    The value to assign to the #platform property

  • :time_usage_started (DateTime)

    The value to assign to the #time_usage_started property

  • :time_usage_ended (DateTime)

    The value to assign to the #time_usage_ended property

  • :computed_carbon_emission (Float)

    The value to assign to the #computed_carbon_emission property

  • :emission_calculation_method (String)

    The value to assign to the #emission_calculation_method property

  • :emission_type (String)

    The value to assign to the #emission_type property

  • :subscription_id (String)

    The value to assign to the #subscription_id property

  • :tags (Array<OCI::UsageApi::Models::Tag>)

    The value to assign to the #tags property



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
# File 'lib/oci/usage_api/models/usage_carbon_emission_summary.rb', line 173

def initialize(attributes = {})
  return unless attributes.is_a?(Hash)

  # convert string to symbol for hash key
  attributes = attributes.each_with_object({}) { |(k, v), h| h[k.to_sym] = v }

  self.tenant_id = attributes[:'tenantId'] if attributes[:'tenantId']

  raise 'You cannot provide both :tenantId and :tenant_id' if attributes.key?(:'tenantId') && attributes.key?(:'tenant_id')

  self.tenant_id = attributes[:'tenant_id'] if attributes[:'tenant_id']

  self.tenant_name = attributes[:'tenantName'] if attributes[:'tenantName']

  raise 'You cannot provide both :tenantName and :tenant_name' if attributes.key?(:'tenantName') && attributes.key?(:'tenant_name')

  self.tenant_name = attributes[:'tenant_name'] if attributes[:'tenant_name']

  self.compartment_id = attributes[:'compartmentId'] if attributes[:'compartmentId']

  raise 'You cannot provide both :compartmentId and :compartment_id' if attributes.key?(:'compartmentId') && attributes.key?(:'compartment_id')

  self.compartment_id = attributes[:'compartment_id'] if attributes[:'compartment_id']

  self.compartment_path = attributes[:'compartmentPath'] if attributes[:'compartmentPath']

  raise 'You cannot provide both :compartmentPath and :compartment_path' if attributes.key?(:'compartmentPath') && attributes.key?(:'compartment_path')

  self.compartment_path = attributes[:'compartment_path'] if attributes[:'compartment_path']

  self.compartment_name = attributes[:'compartmentName'] if attributes[:'compartmentName']

  raise 'You cannot provide both :compartmentName and :compartment_name' if attributes.key?(:'compartmentName') && attributes.key?(:'compartment_name')

  self.compartment_name = attributes[:'compartment_name'] if attributes[:'compartment_name']

  self.service = attributes[:'service'] if attributes[:'service']

  self.resource_name = attributes[:'resourceName'] if attributes[:'resourceName']

  raise 'You cannot provide both :resourceName and :resource_name' if attributes.key?(:'resourceName') && attributes.key?(:'resource_name')

  self.resource_name = attributes[:'resource_name'] if attributes[:'resource_name']

  self.resource_id = attributes[:'resourceId'] if attributes[:'resourceId']

  raise 'You cannot provide both :resourceId and :resource_id' if attributes.key?(:'resourceId') && attributes.key?(:'resource_id')

  self.resource_id = attributes[:'resource_id'] if attributes[:'resource_id']

  self.region = attributes[:'region'] if attributes[:'region']

  self.ad = attributes[:'ad'] if attributes[:'ad']

  self.sku_part_number = attributes[:'skuPartNumber'] if attributes[:'skuPartNumber']

  raise 'You cannot provide both :skuPartNumber and :sku_part_number' if attributes.key?(:'skuPartNumber') && attributes.key?(:'sku_part_number')

  self.sku_part_number = attributes[:'sku_part_number'] if attributes[:'sku_part_number']

  self.sku_name = attributes[:'skuName'] if attributes[:'skuName']

  raise 'You cannot provide both :skuName and :sku_name' if attributes.key?(:'skuName') && attributes.key?(:'sku_name')

  self.sku_name = attributes[:'sku_name'] if attributes[:'sku_name']

  self.platform = attributes[:'platform'] if attributes[:'platform']

  self.time_usage_started = attributes[:'timeUsageStarted'] if attributes[:'timeUsageStarted']

  raise 'You cannot provide both :timeUsageStarted and :time_usage_started' if attributes.key?(:'timeUsageStarted') && attributes.key?(:'time_usage_started')

  self.time_usage_started = attributes[:'time_usage_started'] if attributes[:'time_usage_started']

  self.time_usage_ended = attributes[:'timeUsageEnded'] if attributes[:'timeUsageEnded']

  raise 'You cannot provide both :timeUsageEnded and :time_usage_ended' if attributes.key?(:'timeUsageEnded') && attributes.key?(:'time_usage_ended')

  self.time_usage_ended = attributes[:'time_usage_ended'] if attributes[:'time_usage_ended']

  self.computed_carbon_emission = attributes[:'computedCarbonEmission'] if attributes[:'computedCarbonEmission']

  raise 'You cannot provide both :computedCarbonEmission and :computed_carbon_emission' if attributes.key?(:'computedCarbonEmission') && attributes.key?(:'computed_carbon_emission')

  self.computed_carbon_emission = attributes[:'computed_carbon_emission'] if attributes[:'computed_carbon_emission']

  self.emission_calculation_method = attributes[:'emissionCalculationMethod'] if attributes[:'emissionCalculationMethod']

  raise 'You cannot provide both :emissionCalculationMethod and :emission_calculation_method' if attributes.key?(:'emissionCalculationMethod') && attributes.key?(:'emission_calculation_method')

  self.emission_calculation_method = attributes[:'emission_calculation_method'] if attributes[:'emission_calculation_method']

  self.emission_type = attributes[:'emissionType'] if attributes[:'emissionType']
  self.emission_type = "MARKET_BASED" if emission_type.nil? && !attributes.key?(:'emissionType') # rubocop:disable Style/StringLiterals

  raise 'You cannot provide both :emissionType and :emission_type' if attributes.key?(:'emissionType') && attributes.key?(:'emission_type')

  self.emission_type = attributes[:'emission_type'] if attributes[:'emission_type']
  self.emission_type = "MARKET_BASED" if emission_type.nil? && !attributes.key?(:'emissionType') && !attributes.key?(:'emission_type') # rubocop:disable Style/StringLiterals

  self.subscription_id = attributes[:'subscriptionId'] if attributes[:'subscriptionId']

  raise 'You cannot provide both :subscriptionId and :subscription_id' if attributes.key?(:'subscriptionId') && attributes.key?(:'subscription_id')

  self.subscription_id = attributes[:'subscription_id'] if attributes[:'subscription_id']

  self.tags = attributes[:'tags'] if attributes[:'tags']
end

Instance Attribute Details

#adString

The availability domain of the usage.

Returns:

  • (String)


49
50
51
# File 'lib/oci/usage_api/models/usage_carbon_emission_summary.rb', line 49

def ad
  @ad
end

#compartment_idString

The compartment OCID.

Returns:

  • (String)


21
22
23
# File 'lib/oci/usage_api/models/usage_carbon_emission_summary.rb', line 21

def compartment_id
  @compartment_id
end

#compartment_nameString

The compartment name.

Returns:

  • (String)


29
30
31
# File 'lib/oci/usage_api/models/usage_carbon_emission_summary.rb', line 29

def compartment_name
  @compartment_name
end

#compartment_pathString

The compartment path, starting from root.

Returns:

  • (String)


25
26
27
# File 'lib/oci/usage_api/models/usage_carbon_emission_summary.rb', line 25

def compartment_path
  @compartment_path
end

#computed_carbon_emissionFloat

[Required] The carbon emission usage in MTCO2 units.

Returns:

  • (Float)


73
74
75
# File 'lib/oci/usage_api/models/usage_carbon_emission_summary.rb', line 73

def computed_carbon_emission
  @computed_carbon_emission
end

#emission_calculation_methodString

[Required] Specifies the approach for calculating carbon emissions, supports both SPEND_BASED (based on expenditure data) and POWER_BASED (based on power consumption, newly introduced in the metering pipeline)

Returns:

  • (String)


77
78
79
# File 'lib/oci/usage_api/models/usage_carbon_emission_summary.rb', line 77

def emission_calculation_method
  @emission_calculation_method
end

#emission_typeString

The emission type, such as MARKET_BASED or LOCATION_BASED.

Returns:

  • (String)


81
82
83
# File 'lib/oci/usage_api/models/usage_carbon_emission_summary.rb', line 81

def emission_type
  @emission_type
end

#platformString

Platform for the cost.

Returns:

  • (String)


61
62
63
# File 'lib/oci/usage_api/models/usage_carbon_emission_summary.rb', line 61

def platform
  @platform
end

#regionString

The region of the usage.

Returns:

  • (String)


45
46
47
# File 'lib/oci/usage_api/models/usage_carbon_emission_summary.rb', line 45

def region
  @region
end

#resource_idString

The resource OCID that is incurring the cost.

Returns:

  • (String)


41
42
43
# File 'lib/oci/usage_api/models/usage_carbon_emission_summary.rb', line 41

def resource_id
  @resource_id
end

#resource_nameString

The resource name that is incurring the cost.

Returns:

  • (String)


37
38
39
# File 'lib/oci/usage_api/models/usage_carbon_emission_summary.rb', line 37

def resource_name
  @resource_name
end

#serviceString

The service name that is incurring the cost.

Returns:

  • (String)


33
34
35
# File 'lib/oci/usage_api/models/usage_carbon_emission_summary.rb', line 33

def service
  @service
end

#sku_nameString

The SKU friendly name.

Returns:

  • (String)


57
58
59
# File 'lib/oci/usage_api/models/usage_carbon_emission_summary.rb', line 57

def sku_name
  @sku_name
end

#sku_part_numberString

The SKU part number.

Returns:

  • (String)


53
54
55
# File 'lib/oci/usage_api/models/usage_carbon_emission_summary.rb', line 53

def sku_part_number
  @sku_part_number
end

#subscription_idString

The subscription ID.

Returns:

  • (String)


85
86
87
# File 'lib/oci/usage_api/models/usage_carbon_emission_summary.rb', line 85

def subscription_id
  @subscription_id
end

#tagsArray<OCI::UsageApi::Models::Tag>

For grouping, a tag definition. For filtering, a definition and key.

Returns:



89
90
91
# File 'lib/oci/usage_api/models/usage_carbon_emission_summary.rb', line 89

def tags
  @tags
end

#tenant_idString

The tenancy OCID.

Returns:

  • (String)


13
14
15
# File 'lib/oci/usage_api/models/usage_carbon_emission_summary.rb', line 13

def tenant_id
  @tenant_id
end

#tenant_nameString

The tenancy name.

Returns:

  • (String)


17
18
19
# File 'lib/oci/usage_api/models/usage_carbon_emission_summary.rb', line 17

def tenant_name
  @tenant_name
end

#time_usage_endedDateTime

[Required] The usage end time.

Returns:

  • (DateTime)


69
70
71
# File 'lib/oci/usage_api/models/usage_carbon_emission_summary.rb', line 69

def time_usage_ended
  @time_usage_ended
end

#time_usage_startedDateTime

[Required] The usage start time.

Returns:

  • (DateTime)


65
66
67
# File 'lib/oci/usage_api/models/usage_carbon_emission_summary.rb', line 65

def time_usage_started
  @time_usage_started
end

Class Method Details

.attribute_mapObject

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



92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
# File 'lib/oci/usage_api/models/usage_carbon_emission_summary.rb', line 92

def self.attribute_map
  {
    # rubocop:disable Style/SymbolLiteral
    'tenant_id': :'tenantId',
    'tenant_name': :'tenantName',
    'compartment_id': :'compartmentId',
    'compartment_path': :'compartmentPath',
    'compartment_name': :'compartmentName',
    'service': :'service',
    'resource_name': :'resourceName',
    'resource_id': :'resourceId',
    'region': :'region',
    'ad': :'ad',
    'sku_part_number': :'skuPartNumber',
    'sku_name': :'skuName',
    'platform': :'platform',
    'time_usage_started': :'timeUsageStarted',
    'time_usage_ended': :'timeUsageEnded',
    'computed_carbon_emission': :'computedCarbonEmission',
    'emission_calculation_method': :'emissionCalculationMethod',
    'emission_type': :'emissionType',
    'subscription_id': :'subscriptionId',
    'tags': :'tags'
    # rubocop:enable Style/SymbolLiteral
  }
end

.swagger_typesObject

Attribute type mapping.



120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
# File 'lib/oci/usage_api/models/usage_carbon_emission_summary.rb', line 120

def self.swagger_types
  {
    # rubocop:disable Style/SymbolLiteral
    'tenant_id': :'String',
    'tenant_name': :'String',
    'compartment_id': :'String',
    'compartment_path': :'String',
    'compartment_name': :'String',
    'service': :'String',
    'resource_name': :'String',
    'resource_id': :'String',
    'region': :'String',
    'ad': :'String',
    'sku_part_number': :'String',
    'sku_name': :'String',
    'platform': :'String',
    'time_usage_started': :'DateTime',
    'time_usage_ended': :'DateTime',
    'computed_carbon_emission': :'Float',
    'emission_calculation_method': :'String',
    'emission_type': :'String',
    'subscription_id': :'String',
    'tags': :'Array<OCI::UsageApi::Models::Tag>'
    # rubocop:enable Style/SymbolLiteral
  }
end

Instance Method Details

#==(other) ⇒ Object

Checks equality by comparing each attribute.

Parameters:

  • other (Object)

    the other object to be compared



289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
# File 'lib/oci/usage_api/models/usage_carbon_emission_summary.rb', line 289

def ==(other)
  return true if equal?(other)

  self.class == other.class &&
    tenant_id == other.tenant_id &&
    tenant_name == other.tenant_name &&
    compartment_id == other.compartment_id &&
    compartment_path == other.compartment_path &&
    compartment_name == other.compartment_name &&
    service == other.service &&
    resource_name == other.resource_name &&
    resource_id == other.resource_id &&
    region == other.region &&
    ad == other.ad &&
    sku_part_number == other.sku_part_number &&
    sku_name == other.sku_name &&
    platform == other.platform &&
    time_usage_started == other.time_usage_started &&
    time_usage_ended == other.time_usage_ended &&
    computed_carbon_emission == other.computed_carbon_emission &&
    emission_calculation_method == other.emission_calculation_method &&
    emission_type == other.emission_type &&
    subscription_id == other.subscription_id &&
    tags == other.tags
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



338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
# File 'lib/oci/usage_api/models/usage_carbon_emission_summary.rb', line 338

def build_from_hash(attributes)
  return nil unless attributes.is_a?(Hash)

  self.class.swagger_types.each_pair do |key, type|
    if type =~ /^Array<(.*)>/i
      # check to ensure the input is an array given that the the attribute
      # is documented as an array but the input is not
      if attributes[self.class.attribute_map[key]].is_a?(Array)
        public_method("#{key}=").call(
          attributes[self.class.attribute_map[key]]
            .map { |v| OCI::Internal::Util.convert_to_type(Regexp.last_match(1), v) }
        )
      end
    elsif !attributes[self.class.attribute_map[key]].nil?
      public_method("#{key}=").call(
        OCI::Internal::Util.convert_to_type(type, attributes[self.class.attribute_map[key]])
      )
    end
    # or else data not found in attributes(hash), not an issue as the data can be optional
  end

  self
end

#eql?(other) ⇒ Boolean

Parameters:

  • other (Object)

    the other object to be compared

Returns:

  • (Boolean)

See Also:

  • `==` method


318
319
320
# File 'lib/oci/usage_api/models/usage_carbon_emission_summary.rb', line 318

def eql?(other)
  self == other
end

#hashFixnum

Calculates hash code according to all attributes.

Returns:

  • (Fixnum)

    Hash code



327
328
329
# File 'lib/oci/usage_api/models/usage_carbon_emission_summary.rb', line 327

def hash
  [tenant_id, tenant_name, compartment_id, compartment_path, compartment_name, service, resource_name, resource_id, region, ad, sku_part_number, sku_name, platform, time_usage_started, time_usage_ended, computed_carbon_emission, emission_calculation_method, emission_type, subscription_id, tags].hash
end

#to_hashHash

Returns the object in the form of hash

Returns:

  • (Hash)

    Returns the object in the form of hash



371
372
373
374
375
376
377
378
379
380
# File 'lib/oci/usage_api/models/usage_carbon_emission_summary.rb', line 371

def to_hash
  hash = {}
  self.class.attribute_map.each_pair do |attr, param|
    value = public_method(attr).call
    next if value.nil? && !instance_variable_defined?("@#{attr}")

    hash[param] = _to_hash(value)
  end
  hash
end

#to_sString

Returns the string representation of the object

Returns:

  • (String)

    String presentation of the object



365
366
367
# File 'lib/oci/usage_api/models/usage_carbon_emission_summary.rb', line 365

def to_s
  to_hash.to_s
end