Class: Intrinsic::ViolatedPolicyObject
- Inherits:
-
Object
- Object
- Intrinsic::ViolatedPolicyObject
- Defined in:
- lib/intrinsic/types/violated_policy_object.rb
Instance Attribute Summary collapse
-
#additional_properties ⇒ Object
readonly
Returns the value of attribute additional_properties.
-
#explanation ⇒ Object
readonly
Returns the value of attribute explanation.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#object ⇒ Object
readonly
Returns the value of attribute object.
-
#version_id ⇒ Object
readonly
Returns the value of attribute version_id.
Class Method Summary collapse
-
.from_json(json_object:) ⇒ ViolatedPolicyObject
Deserialize a JSON object to an instance of ViolatedPolicyObject.
-
.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.
Instance Method Summary collapse
- #initialize(object:, id:, name:, explanation:, version_id: nil, additional_properties: nil) ⇒ ViolatedPolicyObject constructor
-
#to_json(*_args) ⇒ JSON
Serialize an instance of ViolatedPolicyObject to a JSON object.
Constructor Details
#initialize(object:, id:, name:, explanation:, version_id: nil, additional_properties: nil) ⇒ ViolatedPolicyObject
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_properties ⇒ Object (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 |
#explanation ⇒ Object (readonly)
Returns the value of attribute explanation.
7 8 9 |
# File 'lib/intrinsic/types/violated_policy_object.rb', line 7 def explanation @explanation end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
7 8 9 |
# File 'lib/intrinsic/types/violated_policy_object.rb', line 7 def id @id end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
7 8 9 |
# File 'lib/intrinsic/types/violated_policy_object.rb', line 7 def name @name end |
#object ⇒ Object (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_id ⇒ Object (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
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.
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
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 |