Class: OCI::UsageApi::Models::Forecast

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

Overview

Forecast configuration of usage/cost.

Constant Summary collapse

FORECAST_TYPE_ENUM =
[
  FORECAST_TYPE_BASIC = 'BASIC'.freeze,
  FORECAST_TYPE_UNKNOWN_ENUM_VALUE = 'UNKNOWN_ENUM_VALUE'.freeze
].freeze

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(attributes = {}) ⇒ Forecast

Initializes the object

Parameters:

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

    Model attributes in the form of hash

Options Hash (attributes):



60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
# File 'lib/oci/usage_api/models/forecast.rb', line 60

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

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

  self.forecast_type = attributes[:'forecast_type'] if attributes[:'forecast_type']
  self.forecast_type = "BASIC" if forecast_type.nil? && !attributes.key?(:'forecastType') && !attributes.key?(:'forecast_type') # rubocop:disable Style/StringLiterals

  self.time_forecast_started = attributes[:'timeForecastStarted'] if attributes[:'timeForecastStarted']

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

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

  self.time_forecast_ended = attributes[:'timeForecastEnded'] if attributes[:'timeForecastEnded']

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

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

Instance Attribute Details

#forecast_typeString

BASIC uses the exponential smoothing (ETS) model to project future usage/costs based on history data. The basis for projections is a periodic set of equivalent historical days for which the projection is being made.

Returns:

  • (String)


19
20
21
# File 'lib/oci/usage_api/models/forecast.rb', line 19

def forecast_type
  @forecast_type
end

#time_forecast_endedDateTime

[Required] The forecast end time.

Returns:

  • (DateTime)


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

def time_forecast_ended
  @time_forecast_ended
end

#time_forecast_startedDateTime

The forecast start time. Defaults to UTC-1 if not specified.

Returns:

  • (DateTime)


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

def time_forecast_started
  @time_forecast_started
end

Class Method Details

.attribute_mapObject

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



30
31
32
33
34
35
36
37
38
# File 'lib/oci/usage_api/models/forecast.rb', line 30

def self.attribute_map
  {
    # rubocop:disable Style/SymbolLiteral
    'forecast_type': :'forecastType',
    'time_forecast_started': :'timeForecastStarted',
    'time_forecast_ended': :'timeForecastEnded'
    # rubocop:enable Style/SymbolLiteral
  }
end

.swagger_typesObject

Attribute type mapping.



41
42
43
44
45
46
47
48
49
# File 'lib/oci/usage_api/models/forecast.rb', line 41

def self.swagger_types
  {
    # rubocop:disable Style/SymbolLiteral
    'forecast_type': :'String',
    'time_forecast_started': :'DateTime',
    'time_forecast_ended': :'DateTime'
    # 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



107
108
109
110
111
112
113
114
# File 'lib/oci/usage_api/models/forecast.rb', line 107

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

  self.class == other.class &&
    forecast_type == other.forecast_type &&
    time_forecast_started == other.time_forecast_started &&
    time_forecast_ended == other.time_forecast_ended
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



139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
# File 'lib/oci/usage_api/models/forecast.rb', line 139

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


119
120
121
# File 'lib/oci/usage_api/models/forecast.rb', line 119

def eql?(other)
  self == other
end

#hashFixnum

Calculates hash code according to all attributes.

Returns:

  • (Fixnum)

    Hash code



128
129
130
# File 'lib/oci/usage_api/models/forecast.rb', line 128

def hash
  [forecast_type, time_forecast_started, time_forecast_ended].hash
end

#to_hashHash

Returns the object in the form of hash

Returns:

  • (Hash)

    Returns the object in the form of hash



172
173
174
175
176
177
178
179
180
181
# File 'lib/oci/usage_api/models/forecast.rb', line 172

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



166
167
168
# File 'lib/oci/usage_api/models/forecast.rb', line 166

def to_s
  to_hash.to_s
end