Class: OCI::UsageApi::Models::UsageCarbonEmissionsReportQuery

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

Overview

The request of the generated carbon emissions usage report.

Constant Summary collapse

DATE_RANGE_NAME_ENUM =
[
  DATE_RANGE_NAME_LAST_TWO_MONTHS = 'LAST_TWO_MONTHS'.freeze,
  DATE_RANGE_NAME_LAST_THREE_MONTHS = 'LAST_THREE_MONTHS'.freeze,
  DATE_RANGE_NAME_LAST_SIX_MONTHS = 'LAST_SIX_MONTHS'.freeze,
  DATE_RANGE_NAME_LAST_ONE_YEAR = 'LAST_ONE_YEAR'.freeze,
  DATE_RANGE_NAME_CUSTOM = 'CUSTOM'.freeze,
  DATE_RANGE_NAME_UNKNOWN_ENUM_VALUE = 'UNKNOWN_ENUM_VALUE'.freeze
].freeze

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(attributes = {}) ⇒ UsageCarbonEmissionsReportQuery

Initializes the object

Parameters:

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

    Model attributes in the form of hash

Options Hash (attributes):



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

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.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.emission_calculation_method = attributes[:'emissionCalculationMethod'] if attributes[:'emissionCalculationMethod']
  self.emission_calculation_method = "SPEND_BASED" if emission_calculation_method.nil? && !attributes.key?(:'emissionCalculationMethod') # rubocop:disable Style/StringLiterals

  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_calculation_method = "SPEND_BASED" if emission_calculation_method.nil? && !attributes.key?(:'emissionCalculationMethod') && !attributes.key?(:'emission_calculation_method') # rubocop:disable Style/StringLiterals

  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.granularity = attributes[:'granularity'] if attributes[:'granularity']
  self.granularity = "MONTHLY" if granularity.nil? && !attributes.key?(:'granularity') # rubocop:disable Style/StringLiterals

  self.is_aggregate_by_time = attributes[:'isAggregateByTime'] unless attributes[:'isAggregateByTime'].nil?
  self.is_aggregate_by_time = false if is_aggregate_by_time.nil? && !attributes.key?(:'isAggregateByTime') # rubocop:disable Style/StringLiterals

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

  self.is_aggregate_by_time = attributes[:'is_aggregate_by_time'] unless attributes[:'is_aggregate_by_time'].nil?
  self.is_aggregate_by_time = false if is_aggregate_by_time.nil? && !attributes.key?(:'isAggregateByTime') && !attributes.key?(:'is_aggregate_by_time') # rubocop:disable Style/StringLiterals

  self.group_by = attributes[:'groupBy'] if attributes[:'groupBy']

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

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

  self.group_by_tag = attributes[:'groupByTag'] if attributes[:'groupByTag']

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

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

  self.compartment_depth = attributes[:'compartmentDepth'] if attributes[:'compartmentDepth']

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

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

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

  self.date_range_name = attributes[:'dateRangeName'] if attributes[:'dateRangeName']

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

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

Instance Attribute Details

#compartment_depthInteger

The compartment depth level.

Returns:

  • (Integer)


67
68
69
# File 'lib/oci/usage_api/models/usage_carbon_emissions_report_query.rb', line 67

def compartment_depth
  @compartment_depth
end

#date_range_nameString

The user interface date range, for example, LAST_THREE_MONTHS. Overrides the timeUsageStarted and timeUsageEnded properties.

Returns:

  • (String)


74
75
76
# File 'lib/oci/usage_api/models/usage_carbon_emissions_report_query.rb', line 74

def date_range_name
  @date_range_name
end

#emission_calculation_methodString

Specifies the method used for emission calculation, such as POWER_BASED or SPEND_BASED

Returns:

  • (String)


35
36
37
# File 'lib/oci/usage_api/models/usage_carbon_emissions_report_query.rb', line 35

def emission_calculation_method
  @emission_calculation_method
end

#emission_typeString

Specifies the type of emission, such as MARKET_BASED or LOCATION_BASED.

Returns:

  • (String)


39
40
41
# File 'lib/oci/usage_api/models/usage_carbon_emissions_report_query.rb', line 39

def emission_type
  @emission_type
end

#filterOCI::UsageApi::Models::Filter



70
71
72
# File 'lib/oci/usage_api/models/usage_carbon_emissions_report_query.rb', line 70

def filter
  @filter
end

#granularityString

The carbon emission granularity. DAILY - Daily data aggregation. MONTHLY - Monthly data aggregation.

Returns:

  • (String)


43
44
45
# File 'lib/oci/usage_api/models/usage_carbon_emissions_report_query.rb', line 43

def granularity
  @granularity
end

#group_byArray<String>

Specifies what to aggregate the result by. For example: [\"tagNamespace\", \"tagKey\", \"tagValue\", \"service\", \"skuName\", \"skuPartNumber\", \"unit\", \"compartmentName\", \"compartmentPath\", \"compartmentId\", \"platform\", \"region\", \"logicalAd\", \"resourceId\", \"tenantId\", \"tenantName\"]

Returns:

  • (Array<String>)


56
57
58
# File 'lib/oci/usage_api/models/usage_carbon_emissions_report_query.rb', line 56

def group_by
  @group_by
end

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

GroupBy a specific tagKey. Provide the tagNamespace and tagKey in the tag object. Only supports one tag in the list. For example: [{\"namespace\":\"oracle\", \"key\":\"createdBy\"]

Returns:



63
64
65
# File 'lib/oci/usage_api/models/usage_carbon_emissions_report_query.rb', line 63

def group_by_tag
  @group_by_tag
end

#is_aggregate_by_timeBOOLEAN

Specifies whether aggregated by time. If isAggregateByTime is true, all usage or costs over the query time period are summed.

Returns:

  • (BOOLEAN)


47
48
49
# File 'lib/oci/usage_api/models/usage_carbon_emissions_report_query.rb', line 47

def is_aggregate_by_time
  @is_aggregate_by_time
end

#tenant_idString

[Required] Tenant ID.

Returns:

  • (String)


23
24
25
# File 'lib/oci/usage_api/models/usage_carbon_emissions_report_query.rb', line 23

def tenant_id
  @tenant_id
end

#time_usage_endedDateTime

The usage end time.

Returns:

  • (DateTime)


31
32
33
# File 'lib/oci/usage_api/models/usage_carbon_emissions_report_query.rb', line 31

def time_usage_ended
  @time_usage_ended
end

#time_usage_startedDateTime

The usage start time.

Returns:

  • (DateTime)


27
28
29
# File 'lib/oci/usage_api/models/usage_carbon_emissions_report_query.rb', line 27

def time_usage_started
  @time_usage_started
end

Class Method Details

.attribute_mapObject

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



77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
# File 'lib/oci/usage_api/models/usage_carbon_emissions_report_query.rb', line 77

def self.attribute_map
  {
    # rubocop:disable Style/SymbolLiteral
    'tenant_id': :'tenantId',
    'time_usage_started': :'timeUsageStarted',
    'time_usage_ended': :'timeUsageEnded',
    'emission_calculation_method': :'emissionCalculationMethod',
    'emission_type': :'emissionType',
    'granularity': :'granularity',
    'is_aggregate_by_time': :'isAggregateByTime',
    'group_by': :'groupBy',
    'group_by_tag': :'groupByTag',
    'compartment_depth': :'compartmentDepth',
    'filter': :'filter',
    'date_range_name': :'dateRangeName'
    # rubocop:enable Style/SymbolLiteral
  }
end

.swagger_typesObject

Attribute type mapping.



97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
# File 'lib/oci/usage_api/models/usage_carbon_emissions_report_query.rb', line 97

def self.swagger_types
  {
    # rubocop:disable Style/SymbolLiteral
    'tenant_id': :'String',
    'time_usage_started': :'DateTime',
    'time_usage_ended': :'DateTime',
    'emission_calculation_method': :'String',
    'emission_type': :'String',
    'granularity': :'String',
    'is_aggregate_by_time': :'BOOLEAN',
    'group_by': :'Array<String>',
    'group_by_tag': :'Array<OCI::UsageApi::Models::Tag>',
    'compartment_depth': :'Integer',
    'filter': :'OCI::UsageApi::Models::Filter',
    'date_range_name': :'String'
    # 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



232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
# File 'lib/oci/usage_api/models/usage_carbon_emissions_report_query.rb', line 232

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

  self.class == other.class &&
    tenant_id == other.tenant_id &&
    time_usage_started == other.time_usage_started &&
    time_usage_ended == other.time_usage_ended &&
    emission_calculation_method == other.emission_calculation_method &&
    emission_type == other.emission_type &&
    granularity == other.granularity &&
    is_aggregate_by_time == other.is_aggregate_by_time &&
    group_by == other.group_by &&
    group_by_tag == other.group_by_tag &&
    compartment_depth == other.compartment_depth &&
    filter == other.filter &&
    date_range_name == other.date_range_name
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



273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
# File 'lib/oci/usage_api/models/usage_carbon_emissions_report_query.rb', line 273

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


253
254
255
# File 'lib/oci/usage_api/models/usage_carbon_emissions_report_query.rb', line 253

def eql?(other)
  self == other
end

#hashFixnum

Calculates hash code according to all attributes.

Returns:

  • (Fixnum)

    Hash code



262
263
264
# File 'lib/oci/usage_api/models/usage_carbon_emissions_report_query.rb', line 262

def hash
  [tenant_id, time_usage_started, time_usage_ended, emission_calculation_method, emission_type, granularity, is_aggregate_by_time, group_by, group_by_tag, compartment_depth, filter, date_range_name].hash
end

#to_hashHash

Returns the object in the form of hash

Returns:

  • (Hash)

    Returns the object in the form of hash



306
307
308
309
310
311
312
313
314
315
# File 'lib/oci/usage_api/models/usage_carbon_emissions_report_query.rb', line 306

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



300
301
302
# File 'lib/oci/usage_api/models/usage_carbon_emissions_report_query.rb', line 300

def to_s
  to_hash.to_s
end