Class: OCI::CloudGuard::Models::ResourceRiskScoreAggregation

Inherits:
Object
  • Object
show all
Defined in:
lib/oci/cloud_guard/models/resource_risk_score_aggregation.rb

Overview

Risk score of a resource.

Constant Summary collapse

RISK_LEVEL_ENUM =
[
  RISK_LEVEL_CRITICAL = 'CRITICAL'.freeze,
  RISK_LEVEL_HIGH = 'HIGH'.freeze,
  RISK_LEVEL_MEDIUM = 'MEDIUM'.freeze,
  RISK_LEVEL_LOW = 'LOW'.freeze,
  RISK_LEVEL_MINOR = 'MINOR'.freeze,
  RISK_LEVEL_UNKNOWN_ENUM_VALUE = 'UNKNOWN_ENUM_VALUE'.freeze
].freeze

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(attributes = {}) ⇒ ResourceRiskScoreAggregation

Initializes the object

Parameters:

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

    Model attributes in the form of hash

Options Hash (attributes):

  • :tactics (Array<String>)

    The value to assign to the #tactics property

  • :score_timestamp (Float)

    The value to assign to the #score_timestamp property

  • :risk_score (Float)

    The value to assign to the #risk_score property

  • :risk_level (String)

    The value to assign to the #risk_level property



71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
# File 'lib/oci/cloud_guard/models/resource_risk_score_aggregation.rb', line 71

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.tactics = attributes[:'tactics'] if attributes[:'tactics']

  self.score_timestamp = attributes[:'scoreTimestamp'] if attributes[:'scoreTimestamp']

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

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

  self.risk_score = attributes[:'riskScore'] if attributes[:'riskScore']

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

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

  self.risk_level = attributes[:'riskLevel'] if attributes[:'riskLevel']

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

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

Instance Attribute Details

#risk_levelString

[Required] The risk level

Returns:

  • (String)


35
36
37
# File 'lib/oci/cloud_guard/models/resource_risk_score_aggregation.rb', line 35

def risk_level
  @risk_level
end

#risk_scoreFloat

[Required] The risk score

Returns:

  • (Float)


31
32
33
# File 'lib/oci/cloud_guard/models/resource_risk_score_aggregation.rb', line 31

def risk_score
  @risk_score
end

#score_timestampFloat

[Required] The date and time for which the score is calculated. Format defined by RFC3339.

Returns:

  • (Float)


27
28
29
# File 'lib/oci/cloud_guard/models/resource_risk_score_aggregation.rb', line 27

def score_timestamp
  @score_timestamp
end

#tacticsArray<String>

[Required] List of tactics used for evaluating the risk score

Returns:

  • (Array<String>)


23
24
25
# File 'lib/oci/cloud_guard/models/resource_risk_score_aggregation.rb', line 23

def tactics
  @tactics
end

Class Method Details

.attribute_mapObject

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



38
39
40
41
42
43
44
45
46
47
# File 'lib/oci/cloud_guard/models/resource_risk_score_aggregation.rb', line 38

def self.attribute_map
  {
    # rubocop:disable Style/SymbolLiteral
    'tactics': :'tactics',
    'score_timestamp': :'scoreTimestamp',
    'risk_score': :'riskScore',
    'risk_level': :'riskLevel'
    # rubocop:enable Style/SymbolLiteral
  }
end

.swagger_typesObject

Attribute type mapping.



50
51
52
53
54
55
56
57
58
59
# File 'lib/oci/cloud_guard/models/resource_risk_score_aggregation.rb', line 50

def self.swagger_types
  {
    # rubocop:disable Style/SymbolLiteral
    'tactics': :'Array<String>',
    'score_timestamp': :'Float',
    'risk_score': :'Float',
    'risk_level': :'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



118
119
120
121
122
123
124
125
126
# File 'lib/oci/cloud_guard/models/resource_risk_score_aggregation.rb', line 118

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

  self.class == other.class &&
    tactics == other.tactics &&
    score_timestamp == other.score_timestamp &&
    risk_score == other.risk_score &&
    risk_level == other.risk_level
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



151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
# File 'lib/oci/cloud_guard/models/resource_risk_score_aggregation.rb', line 151

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


131
132
133
# File 'lib/oci/cloud_guard/models/resource_risk_score_aggregation.rb', line 131

def eql?(other)
  self == other
end

#hashFixnum

Calculates hash code according to all attributes.

Returns:

  • (Fixnum)

    Hash code



140
141
142
# File 'lib/oci/cloud_guard/models/resource_risk_score_aggregation.rb', line 140

def hash
  [tactics, score_timestamp, risk_score, risk_level].hash
end

#to_hashHash

Returns the object in the form of hash

Returns:

  • (Hash)

    Returns the object in the form of hash



184
185
186
187
188
189
190
191
192
193
# File 'lib/oci/cloud_guard/models/resource_risk_score_aggregation.rb', line 184

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



178
179
180
# File 'lib/oci/cloud_guard/models/resource_risk_score_aggregation.rb', line 178

def to_s
  to_hash.to_s
end