Class: Intrinsic::ViolatedPolicyObject

Inherits:
Object
  • Object
show all
Defined in:
lib/intrinsic/types/violated_policy_object.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(object:, id:, name:, explanation:, version_id: nil, additional_properties: nil) ⇒ ViolatedPolicyObject

Parameters:

  • object (String)
  • id (String)

    ID of the policy that was violated

  • version_id (String) (defaults to: nil)

    Version of the policy that was violated

  • name (String)

    Name of the policy

  • explanation (String)

    Explanation for why policy was violated

  • additional_properties (OpenStruct) (defaults to: nil)

    Additional properties unmapped to the current class definition



16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/intrinsic/types/violated_policy_object.rb', line 16

def initialize(object:, id:, name:, explanation:, version_id: nil, additional_properties: nil)
  # @type [String]
  @object = object
  # @type [String] ID of the policy that was violated
  @id = id
  # @type [String] Version of the policy that was violated
  @version_id = version_id
  # @type [String] Name of the policy
  @name = name
  # @type [String] Explanation for why policy was violated
  @explanation = explanation
  # @type [OpenStruct] Additional properties unmapped to the current class definition
  @additional_properties = additional_properties
end

Instance Attribute Details

#additional_propertiesObject (readonly)

Returns the value of attribute additional_properties.



7
8
9
# File 'lib/intrinsic/types/violated_policy_object.rb', line 7

def additional_properties
  @additional_properties
end

#explanationObject (readonly)

Returns the value of attribute explanation.



7
8
9
# File 'lib/intrinsic/types/violated_policy_object.rb', line 7

def explanation
  @explanation
end

#idObject (readonly)

Returns the value of attribute id.



7
8
9
# File 'lib/intrinsic/types/violated_policy_object.rb', line 7

def id
  @id
end

#nameObject (readonly)

Returns the value of attribute name.



7
8
9
# File 'lib/intrinsic/types/violated_policy_object.rb', line 7

def name
  @name
end

#objectObject (readonly)

Returns the value of attribute object.



7
8
9
# File 'lib/intrinsic/types/violated_policy_object.rb', line 7

def object
  @object
end

#version_idObject (readonly)

Returns the value of attribute version_id.



7
8
9
# File 'lib/intrinsic/types/violated_policy_object.rb', line 7

def version_id
  @version_id
end

Class Method Details

.from_json(json_object:) ⇒ ViolatedPolicyObject

Deserialize a JSON object to an instance of ViolatedPolicyObject

Parameters:

  • json_object (JSON)

Returns:



35
36
37
38
39
40
41
42
43
44
45
# File 'lib/intrinsic/types/violated_policy_object.rb', line 35

def self.from_json(json_object:)
  struct = JSON.parse(json_object, object_class: OpenStruct)
  JSON.parse(json_object)
  object = struct.object
  id = struct.id
  version_id = struct.version_id
  name = struct.name
  explanation = struct.explanation
  new(object: object, id: id, version_id: version_id, name: name, explanation: explanation,
      additional_properties: struct)
end

.validate_raw(obj:) ⇒ Void

Leveraged for Union-type generation, validate_raw attempts to parse the given hash and check each fields type against the current object’s property definitions.

Parameters:

  • obj (Object)

Returns:

  • (Void)


58
59
60
61
62
63
64
# File 'lib/intrinsic/types/violated_policy_object.rb', line 58

def self.validate_raw(obj:)
  obj.object.is_a?(String) != false || raise("Passed value for field obj.object is not the expected type, validation failed.")
  obj.id.is_a?(String) != false || raise("Passed value for field obj.id is not the expected type, validation failed.")
  obj.version_id&.is_a?(String) != false || raise("Passed value for field obj.version_id is not the expected type, validation failed.")
  obj.name.is_a?(String) != false || raise("Passed value for field obj.name is not the expected type, validation failed.")
  obj.explanation.is_a?(String) != false || raise("Passed value for field obj.explanation is not the expected type, validation failed.")
end

Instance Method Details

#to_json(*_args) ⇒ JSON

Serialize an instance of ViolatedPolicyObject to a JSON object

Returns:

  • (JSON)


50
51
52
# File 'lib/intrinsic/types/violated_policy_object.rb', line 50

def to_json(*_args)
  { "object": @object, "id": @id, "version_id": @version_id, "name": @name, "explanation": @explanation }.to_json
end