intrinsic-sdk 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/lib/environment.rb +7 -0
- data/lib/gemconfig.rb +14 -0
- data/lib/intrinsic/detections/client.rb +55 -0
- data/lib/intrinsic/event_types/client.rb +91 -0
- data/lib/intrinsic/events/client.rb +100 -0
- data/lib/intrinsic/types/create_event_async_request.rb +5 -0
- data/lib/intrinsic/types/create_event_async_response.rb +94 -0
- data/lib/intrinsic/types/create_event_sync_request.rb +5 -0
- data/lib/intrinsic/types/create_event_sync_response.rb +94 -0
- data/lib/intrinsic/types/detection_object.rb +91 -0
- data/lib/intrinsic/types/detection_object_status.rb +6 -0
- data/lib/intrinsic/types/error_schema.rb +51 -0
- data/lib/intrinsic/types/error_schema_error.rb +67 -0
- data/lib/intrinsic/types/error_schema_error_code.rb +13 -0
- data/lib/intrinsic/types/error_schema_error_type.rb +13 -0
- data/lib/intrinsic/types/event_type_field.rb +56 -0
- data/lib/intrinsic/types/event_type_field_type.rb +12 -0
- data/lib/intrinsic/types/event_type_object.rb +64 -0
- data/lib/intrinsic/types/fired_rule_object.rb +66 -0
- data/lib/intrinsic/types/list_event_types_response.rb +54 -0
- data/lib/intrinsic/types/violated_policy_object.rb +66 -0
- data/lib/intrinsic.rb +44 -0
- data/lib/requests.rb +87 -0
- data/lib/types_export.rb +18 -0
- metadata +148 -0
@@ -0,0 +1,67 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative "error_schema_error_type"
|
4
|
+
require_relative "error_schema_error_code"
|
5
|
+
require "json"
|
6
|
+
|
7
|
+
module Intrinsic
|
8
|
+
class ErrorSchemaError
|
9
|
+
attr_reader :type, :message, :code, :param, :additional_properties
|
10
|
+
|
11
|
+
# @param type [ERROR_SCHEMA_ERROR_TYPE]
|
12
|
+
# @param message [String]
|
13
|
+
# @param code [ERROR_SCHEMA_ERROR_CODE]
|
14
|
+
# @param param [String]
|
15
|
+
# @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition
|
16
|
+
# @return [ErrorSchemaError]
|
17
|
+
def initialize(type:, message:, code:, param: nil, additional_properties: nil)
|
18
|
+
# @type [ERROR_SCHEMA_ERROR_TYPE]
|
19
|
+
@type = type
|
20
|
+
# @type [String]
|
21
|
+
@message = message
|
22
|
+
# @type [ERROR_SCHEMA_ERROR_CODE]
|
23
|
+
@code = code
|
24
|
+
# @type [String]
|
25
|
+
@param = param
|
26
|
+
# @type [OpenStruct] Additional properties unmapped to the current class definition
|
27
|
+
@additional_properties = additional_properties
|
28
|
+
end
|
29
|
+
|
30
|
+
# Deserialize a JSON object to an instance of ErrorSchemaError
|
31
|
+
#
|
32
|
+
# @param json_object [JSON]
|
33
|
+
# @return [ErrorSchemaError]
|
34
|
+
def self.from_json(json_object:)
|
35
|
+
struct = JSON.parse(json_object, object_class: OpenStruct)
|
36
|
+
parsed_json = JSON.parse(json_object)
|
37
|
+
type = ERROR_SCHEMA_ERROR_TYPE.key(parsed_json["type"]) || parsed_json["type"]
|
38
|
+
message = struct.message
|
39
|
+
code = ERROR_SCHEMA_ERROR_CODE.key(parsed_json["code"]) || parsed_json["code"]
|
40
|
+
param = struct.param
|
41
|
+
new(type: type, message: message, code: code, param: param, additional_properties: struct)
|
42
|
+
end
|
43
|
+
|
44
|
+
# Serialize an instance of ErrorSchemaError to a JSON object
|
45
|
+
#
|
46
|
+
# @return [JSON]
|
47
|
+
def to_json(*_args)
|
48
|
+
{
|
49
|
+
"type": ERROR_SCHEMA_ERROR_TYPE[@type] || @type,
|
50
|
+
"message": @message,
|
51
|
+
"code": ERROR_SCHEMA_ERROR_CODE[@code] || @code,
|
52
|
+
"param": @param
|
53
|
+
}.to_json
|
54
|
+
end
|
55
|
+
|
56
|
+
# 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.
|
57
|
+
#
|
58
|
+
# @param obj [Object]
|
59
|
+
# @return [Void]
|
60
|
+
def self.validate_raw(obj:)
|
61
|
+
obj.type.is_a?(ERROR_SCHEMA_ERROR_TYPE) != false || raise("Passed value for field obj.type is not the expected type, validation failed.")
|
62
|
+
obj.message.is_a?(String) != false || raise("Passed value for field obj.message is not the expected type, validation failed.")
|
63
|
+
obj.code.is_a?(ERROR_SCHEMA_ERROR_CODE) != false || raise("Passed value for field obj.code is not the expected type, validation failed.")
|
64
|
+
obj.param&.is_a?(String) != false || raise("Passed value for field obj.param is not the expected type, validation failed.")
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Intrinsic
|
4
|
+
# @type [ERROR_SCHEMA_ERROR_CODE]
|
5
|
+
ERROR_SCHEMA_ERROR_CODE = {
|
6
|
+
four_hundred: "400",
|
7
|
+
four_hundred_one: "401",
|
8
|
+
four_hundred_three: "403",
|
9
|
+
four_hundred_four: "404",
|
10
|
+
five_hundred: "500",
|
11
|
+
five_hundred_one: "501"
|
12
|
+
}.freeze
|
13
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Intrinsic
|
4
|
+
# @type [ERROR_SCHEMA_ERROR_TYPE]
|
5
|
+
ERROR_SCHEMA_ERROR_TYPE = {
|
6
|
+
invalid_request_error: "invalid_request_error",
|
7
|
+
not_enabled_error: "not_enabled_error",
|
8
|
+
rate_limit_error: "rate_limit_error",
|
9
|
+
authentication_error: "authentication_error",
|
10
|
+
not_found_error: "not_found_error",
|
11
|
+
internal_server_error: "internal_server_error"
|
12
|
+
}.freeze
|
13
|
+
end
|
@@ -0,0 +1,56 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative "event_type_field_type"
|
4
|
+
require "json"
|
5
|
+
|
6
|
+
module Intrinsic
|
7
|
+
class EventTypeField
|
8
|
+
attr_reader :field_name, :type, :optional, :additional_properties
|
9
|
+
|
10
|
+
# @param field_name [String] Name of the field. Must be unique, and can only contain alphanumeric characters and underscores, and be up to 255 characters
|
11
|
+
# @param type [EVENT_TYPE_FIELD_TYPE] Type of the field. Can be either strings, numbers, links to JPEG images, or links to video files
|
12
|
+
# @param optional [Boolean] Whether the field is optional or not
|
13
|
+
# @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition
|
14
|
+
# @return [EventTypeField]
|
15
|
+
def initialize(field_name:, type:, optional:, additional_properties: nil)
|
16
|
+
# @type [String] Name of the field. Must be unique, and can only contain alphanumeric characters and underscores, and be up to 255 characters
|
17
|
+
@field_name = field_name
|
18
|
+
# @type [EVENT_TYPE_FIELD_TYPE] Type of the field. Can be either strings, numbers, links to JPEG images, or links to video files
|
19
|
+
@type = type
|
20
|
+
# @type [Boolean] Whether the field is optional or not
|
21
|
+
@optional = optional
|
22
|
+
# @type [OpenStruct] Additional properties unmapped to the current class definition
|
23
|
+
@additional_properties = additional_properties
|
24
|
+
end
|
25
|
+
|
26
|
+
# Deserialize a JSON object to an instance of EventTypeField
|
27
|
+
#
|
28
|
+
# @param json_object [JSON]
|
29
|
+
# @return [EventTypeField]
|
30
|
+
def self.from_json(json_object:)
|
31
|
+
struct = JSON.parse(json_object, object_class: OpenStruct)
|
32
|
+
parsed_json = JSON.parse(json_object)
|
33
|
+
field_name = struct.field_name
|
34
|
+
type = EVENT_TYPE_FIELD_TYPE.key(parsed_json["type"]) || parsed_json["type"]
|
35
|
+
optional = struct.optional
|
36
|
+
new(field_name: field_name, type: type, optional: optional, additional_properties: struct)
|
37
|
+
end
|
38
|
+
|
39
|
+
# Serialize an instance of EventTypeField to a JSON object
|
40
|
+
#
|
41
|
+
# @return [JSON]
|
42
|
+
def to_json(*_args)
|
43
|
+
{ "field_name": @field_name, "type": EVENT_TYPE_FIELD_TYPE[@type] || @type, "optional": @optional }.to_json
|
44
|
+
end
|
45
|
+
|
46
|
+
# 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.
|
47
|
+
#
|
48
|
+
# @param obj [Object]
|
49
|
+
# @return [Void]
|
50
|
+
def self.validate_raw(obj:)
|
51
|
+
obj.field_name.is_a?(String) != false || raise("Passed value for field obj.field_name is not the expected type, validation failed.")
|
52
|
+
obj.type.is_a?(EVENT_TYPE_FIELD_TYPE) != false || raise("Passed value for field obj.type is not the expected type, validation failed.")
|
53
|
+
obj.optional.is_a?(Boolean) != false || raise("Passed value for field obj.optional is not the expected type, validation failed.")
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
@@ -0,0 +1,64 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative "event_type_field"
|
4
|
+
require "json"
|
5
|
+
|
6
|
+
module Intrinsic
|
7
|
+
class EventTypeObject
|
8
|
+
attr_reader :id, :name, :fields, :object, :additional_properties
|
9
|
+
|
10
|
+
# @param id [String] ID of the event type
|
11
|
+
# @param name [String] Name of the event type. Must be unique, and can only contain alphanumeric characters and underscores, and be up to 255 characters
|
12
|
+
# @param fields [Array<EventTypeField>] Fields of the event type
|
13
|
+
# @param object [String]
|
14
|
+
# @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition
|
15
|
+
# @return [EventTypeObject]
|
16
|
+
def initialize(id:, name:, fields:, object:, additional_properties: nil)
|
17
|
+
# @type [String] ID of the event type
|
18
|
+
@id = id
|
19
|
+
# @type [String] Name of the event type. Must be unique, and can only contain alphanumeric characters and underscores, and be up to 255 characters
|
20
|
+
@name = name
|
21
|
+
# @type [Array<EventTypeField>] Fields of the event type
|
22
|
+
@fields = fields
|
23
|
+
# @type [String]
|
24
|
+
@object = object
|
25
|
+
# @type [OpenStruct] Additional properties unmapped to the current class definition
|
26
|
+
@additional_properties = additional_properties
|
27
|
+
end
|
28
|
+
|
29
|
+
# Deserialize a JSON object to an instance of EventTypeObject
|
30
|
+
#
|
31
|
+
# @param json_object [JSON]
|
32
|
+
# @return [EventTypeObject]
|
33
|
+
def self.from_json(json_object:)
|
34
|
+
struct = JSON.parse(json_object, object_class: OpenStruct)
|
35
|
+
parsed_json = JSON.parse(json_object)
|
36
|
+
id = struct.id
|
37
|
+
name = struct.name
|
38
|
+
fields = parsed_json["fields"]&.map do |v|
|
39
|
+
v = v.to_json
|
40
|
+
EventTypeField.from_json(json_object: v)
|
41
|
+
end
|
42
|
+
object = struct.object
|
43
|
+
new(id: id, name: name, fields: fields, object: object, additional_properties: struct)
|
44
|
+
end
|
45
|
+
|
46
|
+
# Serialize an instance of EventTypeObject to a JSON object
|
47
|
+
#
|
48
|
+
# @return [JSON]
|
49
|
+
def to_json(*_args)
|
50
|
+
{ "id": @id, "name": @name, "fields": @fields, "object": @object }.to_json
|
51
|
+
end
|
52
|
+
|
53
|
+
# 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.
|
54
|
+
#
|
55
|
+
# @param obj [Object]
|
56
|
+
# @return [Void]
|
57
|
+
def self.validate_raw(obj:)
|
58
|
+
obj.id.is_a?(String) != false || raise("Passed value for field obj.id is not the expected type, validation failed.")
|
59
|
+
obj.name.is_a?(String) != false || raise("Passed value for field obj.name is not the expected type, validation failed.")
|
60
|
+
obj.fields.is_a?(Array) != false || raise("Passed value for field obj.fields is not the expected type, validation failed.")
|
61
|
+
obj.object.is_a?(String) != false || raise("Passed value for field obj.object is not the expected type, validation failed.")
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
@@ -0,0 +1,66 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "json"
|
4
|
+
|
5
|
+
module Intrinsic
|
6
|
+
class FiredRuleObject
|
7
|
+
attr_reader :object, :rule_id, :rule_name, :triggered_action_name, :additional_properties
|
8
|
+
|
9
|
+
# @param object [String]
|
10
|
+
# @param rule_id [String] ID of the fired rule
|
11
|
+
# @param rule_name [String] Name of the fired rule
|
12
|
+
# @param triggered_action_name [String] Name of the triggered action
|
13
|
+
# @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition
|
14
|
+
# @return [FiredRuleObject]
|
15
|
+
def initialize(object:, rule_id:, rule_name:, triggered_action_name:, additional_properties: nil)
|
16
|
+
# @type [String]
|
17
|
+
@object = object
|
18
|
+
# @type [String] ID of the fired rule
|
19
|
+
@rule_id = rule_id
|
20
|
+
# @type [String] Name of the fired rule
|
21
|
+
@rule_name = rule_name
|
22
|
+
# @type [String] Name of the triggered action
|
23
|
+
@triggered_action_name = triggered_action_name
|
24
|
+
# @type [OpenStruct] Additional properties unmapped to the current class definition
|
25
|
+
@additional_properties = additional_properties
|
26
|
+
end
|
27
|
+
|
28
|
+
# Deserialize a JSON object to an instance of FiredRuleObject
|
29
|
+
#
|
30
|
+
# @param json_object [JSON]
|
31
|
+
# @return [FiredRuleObject]
|
32
|
+
def self.from_json(json_object:)
|
33
|
+
struct = JSON.parse(json_object, object_class: OpenStruct)
|
34
|
+
JSON.parse(json_object)
|
35
|
+
object = struct.object
|
36
|
+
rule_id = struct.rule_id
|
37
|
+
rule_name = struct.rule_name
|
38
|
+
triggered_action_name = struct.triggered_action_name
|
39
|
+
new(object: object, rule_id: rule_id, rule_name: rule_name, triggered_action_name: triggered_action_name,
|
40
|
+
additional_properties: struct)
|
41
|
+
end
|
42
|
+
|
43
|
+
# Serialize an instance of FiredRuleObject to a JSON object
|
44
|
+
#
|
45
|
+
# @return [JSON]
|
46
|
+
def to_json(*_args)
|
47
|
+
{
|
48
|
+
"object": @object,
|
49
|
+
"rule_id": @rule_id,
|
50
|
+
"rule_name": @rule_name,
|
51
|
+
"triggered_action_name": @triggered_action_name
|
52
|
+
}.to_json
|
53
|
+
end
|
54
|
+
|
55
|
+
# 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.
|
56
|
+
#
|
57
|
+
# @param obj [Object]
|
58
|
+
# @return [Void]
|
59
|
+
def self.validate_raw(obj:)
|
60
|
+
obj.object.is_a?(String) != false || raise("Passed value for field obj.object is not the expected type, validation failed.")
|
61
|
+
obj.rule_id.is_a?(String) != false || raise("Passed value for field obj.rule_id is not the expected type, validation failed.")
|
62
|
+
obj.rule_name.is_a?(String) != false || raise("Passed value for field obj.rule_name is not the expected type, validation failed.")
|
63
|
+
obj.triggered_action_name.is_a?(String) != false || raise("Passed value for field obj.triggered_action_name is not the expected type, validation failed.")
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end
|
@@ -0,0 +1,54 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative "event_type_object"
|
4
|
+
require "json"
|
5
|
+
|
6
|
+
module Intrinsic
|
7
|
+
class ListEventTypesResponse
|
8
|
+
attr_reader :data, :object, :additional_properties
|
9
|
+
|
10
|
+
# @param data [Array<EventTypeObject>]
|
11
|
+
# @param object [String]
|
12
|
+
# @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition
|
13
|
+
# @return [ListEventTypesResponse]
|
14
|
+
def initialize(data:, object:, additional_properties: nil)
|
15
|
+
# @type [Array<EventTypeObject>]
|
16
|
+
@data = data
|
17
|
+
# @type [String]
|
18
|
+
@object = object
|
19
|
+
# @type [OpenStruct] Additional properties unmapped to the current class definition
|
20
|
+
@additional_properties = additional_properties
|
21
|
+
end
|
22
|
+
|
23
|
+
# Deserialize a JSON object to an instance of ListEventTypesResponse
|
24
|
+
#
|
25
|
+
# @param json_object [JSON]
|
26
|
+
# @return [ListEventTypesResponse]
|
27
|
+
def self.from_json(json_object:)
|
28
|
+
struct = JSON.parse(json_object, object_class: OpenStruct)
|
29
|
+
parsed_json = JSON.parse(json_object)
|
30
|
+
data = parsed_json["data"]&.map do |v|
|
31
|
+
v = v.to_json
|
32
|
+
EventTypeObject.from_json(json_object: v)
|
33
|
+
end
|
34
|
+
object = struct.object
|
35
|
+
new(data: data, object: object, additional_properties: struct)
|
36
|
+
end
|
37
|
+
|
38
|
+
# Serialize an instance of ListEventTypesResponse to a JSON object
|
39
|
+
#
|
40
|
+
# @return [JSON]
|
41
|
+
def to_json(*_args)
|
42
|
+
{ "data": @data, "object": @object }.to_json
|
43
|
+
end
|
44
|
+
|
45
|
+
# 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.
|
46
|
+
#
|
47
|
+
# @param obj [Object]
|
48
|
+
# @return [Void]
|
49
|
+
def self.validate_raw(obj:)
|
50
|
+
obj.data.is_a?(Array) != false || raise("Passed value for field obj.data is not the expected type, validation failed.")
|
51
|
+
obj.object.is_a?(String) != false || raise("Passed value for field obj.object is not the expected type, validation failed.")
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
@@ -0,0 +1,66 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "json"
|
4
|
+
|
5
|
+
module Intrinsic
|
6
|
+
class ViolatedPolicyObject
|
7
|
+
attr_reader :object, :id, :version_id, :name, :explanation, :additional_properties
|
8
|
+
|
9
|
+
# @param object [String]
|
10
|
+
# @param id [String] ID of the policy that was violated
|
11
|
+
# @param version_id [String] Version of the policy that was violated
|
12
|
+
# @param name [String] Name of the policy
|
13
|
+
# @param explanation [String] Explanation for why policy was violated
|
14
|
+
# @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition
|
15
|
+
# @return [ViolatedPolicyObject]
|
16
|
+
def initialize(object:, id:, name:, explanation:, version_id: nil, additional_properties: nil)
|
17
|
+
# @type [String]
|
18
|
+
@object = object
|
19
|
+
# @type [String] ID of the policy that was violated
|
20
|
+
@id = id
|
21
|
+
# @type [String] Version of the policy that was violated
|
22
|
+
@version_id = version_id
|
23
|
+
# @type [String] Name of the policy
|
24
|
+
@name = name
|
25
|
+
# @type [String] Explanation for why policy was violated
|
26
|
+
@explanation = explanation
|
27
|
+
# @type [OpenStruct] Additional properties unmapped to the current class definition
|
28
|
+
@additional_properties = additional_properties
|
29
|
+
end
|
30
|
+
|
31
|
+
# Deserialize a JSON object to an instance of ViolatedPolicyObject
|
32
|
+
#
|
33
|
+
# @param json_object [JSON]
|
34
|
+
# @return [ViolatedPolicyObject]
|
35
|
+
def self.from_json(json_object:)
|
36
|
+
struct = JSON.parse(json_object, object_class: OpenStruct)
|
37
|
+
JSON.parse(json_object)
|
38
|
+
object = struct.object
|
39
|
+
id = struct.id
|
40
|
+
version_id = struct.version_id
|
41
|
+
name = struct.name
|
42
|
+
explanation = struct.explanation
|
43
|
+
new(object: object, id: id, version_id: version_id, name: name, explanation: explanation,
|
44
|
+
additional_properties: struct)
|
45
|
+
end
|
46
|
+
|
47
|
+
# Serialize an instance of ViolatedPolicyObject to a JSON object
|
48
|
+
#
|
49
|
+
# @return [JSON]
|
50
|
+
def to_json(*_args)
|
51
|
+
{ "object": @object, "id": @id, "version_id": @version_id, "name": @name, "explanation": @explanation }.to_json
|
52
|
+
end
|
53
|
+
|
54
|
+
# 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.
|
55
|
+
#
|
56
|
+
# @param obj [Object]
|
57
|
+
# @return [Void]
|
58
|
+
def self.validate_raw(obj:)
|
59
|
+
obj.object.is_a?(String) != false || raise("Passed value for field obj.object is not the expected type, validation failed.")
|
60
|
+
obj.id.is_a?(String) != false || raise("Passed value for field obj.id is not the expected type, validation failed.")
|
61
|
+
obj.version_id&.is_a?(String) != false || raise("Passed value for field obj.version_id is not the expected type, validation failed.")
|
62
|
+
obj.name.is_a?(String) != false || raise("Passed value for field obj.name is not the expected type, validation failed.")
|
63
|
+
obj.explanation.is_a?(String) != false || raise("Passed value for field obj.explanation is not the expected type, validation failed.")
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end
|
data/lib/intrinsic.rb
ADDED
@@ -0,0 +1,44 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative "environment"
|
4
|
+
require_relative "types_export"
|
5
|
+
require_relative "requests"
|
6
|
+
require_relative "intrinsic/detections/client"
|
7
|
+
require_relative "intrinsic/events/client"
|
8
|
+
require_relative "intrinsic/event_types/client"
|
9
|
+
|
10
|
+
module Intrinsic
|
11
|
+
class Client
|
12
|
+
attr_reader :detections, :events, :event_types
|
13
|
+
|
14
|
+
# @param environment [Environment]
|
15
|
+
# @param max_retries [Long] The number of times to retry a failed request, defaults to 2.
|
16
|
+
# @param timeout_in_seconds [Long]
|
17
|
+
# @param api_key [String]
|
18
|
+
# @return [Client]
|
19
|
+
def initialize(api_key:, environment: Environment::DEFAULT, max_retries: nil, timeout_in_seconds: nil)
|
20
|
+
@request_client = RequestClient.new(environment: environment, max_retries: max_retries,
|
21
|
+
timeout_in_seconds: timeout_in_seconds, api_key: api_key)
|
22
|
+
@detections = DetectionsClient.new(request_client: @request_client)
|
23
|
+
@events = EventsClient.new(request_client: @request_client)
|
24
|
+
@event_types = EventTypesClient.new(request_client: @request_client)
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
class AsyncClient
|
29
|
+
attr_reader :detections, :events, :event_types
|
30
|
+
|
31
|
+
# @param environment [Environment]
|
32
|
+
# @param max_retries [Long] The number of times to retry a failed request, defaults to 2.
|
33
|
+
# @param timeout_in_seconds [Long]
|
34
|
+
# @param api_key [String]
|
35
|
+
# @return [AsyncClient]
|
36
|
+
def initialize(api_key:, environment: Environment::DEFAULT, max_retries: nil, timeout_in_seconds: nil)
|
37
|
+
@async_request_client = AsyncRequestClient.new(environment: environment, max_retries: max_retries,
|
38
|
+
timeout_in_seconds: timeout_in_seconds, api_key: api_key)
|
39
|
+
@detections = AsyncDetectionsClient.new(request_client: @async_request_client)
|
40
|
+
@events = AsyncEventsClient.new(request_client: @async_request_client)
|
41
|
+
@event_types = AsyncEventTypesClient.new(request_client: @async_request_client)
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
data/lib/requests.rb
ADDED
@@ -0,0 +1,87 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative "environment"
|
4
|
+
require "faraday"
|
5
|
+
require "faraday/retry"
|
6
|
+
require "async/http/faraday"
|
7
|
+
|
8
|
+
module Intrinsic
|
9
|
+
class RequestClient
|
10
|
+
attr_reader :headers, :base_url, :conn
|
11
|
+
|
12
|
+
# @param environment [Environment]
|
13
|
+
# @param max_retries [Long] The number of times to retry a failed request, defaults to 2.
|
14
|
+
# @param timeout_in_seconds [Long]
|
15
|
+
# @param api_key [String]
|
16
|
+
# @return [RequestClient]
|
17
|
+
def initialize(api_key:, environment: Environment::DEFAULT, max_retries: nil, timeout_in_seconds: nil)
|
18
|
+
@default_environment = environment
|
19
|
+
@base_url = environment
|
20
|
+
@headers = {
|
21
|
+
"X-Fern-Language": "Ruby",
|
22
|
+
"X-Fern-SDK-Name": "Intrinsic",
|
23
|
+
"X-Fern-SDK-Version": "0.0.2",
|
24
|
+
"X-API-Key": api_key.to_s
|
25
|
+
}
|
26
|
+
@conn = Faraday.new(@base_url, headers: @headers) do |faraday|
|
27
|
+
faraday.request :json
|
28
|
+
faraday.response :raise_error, include_request: true
|
29
|
+
faraday.request :retry, { max: max_retries } unless max_retries.nil?
|
30
|
+
faraday.options.timeout = timeout_in_seconds unless timeout_in_seconds.nil?
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
class AsyncRequestClient
|
36
|
+
attr_reader :headers, :base_url, :conn
|
37
|
+
|
38
|
+
# @param environment [Environment]
|
39
|
+
# @param max_retries [Long] The number of times to retry a failed request, defaults to 2.
|
40
|
+
# @param timeout_in_seconds [Long]
|
41
|
+
# @param api_key [String]
|
42
|
+
# @return [AsyncRequestClient]
|
43
|
+
def initialize(api_key:, environment: Environment::DEFAULT, max_retries: nil, timeout_in_seconds: nil)
|
44
|
+
@default_environment = environment
|
45
|
+
@base_url = environment
|
46
|
+
@headers = {
|
47
|
+
"X-Fern-Language": "Ruby",
|
48
|
+
"X-Fern-SDK-Name": "Intrinsic",
|
49
|
+
"X-Fern-SDK-Version": "0.0.2",
|
50
|
+
"X-API-Key": api_key.to_s
|
51
|
+
}
|
52
|
+
@conn = Faraday.new(@base_url, headers: @headers) do |faraday|
|
53
|
+
faraday.request :json
|
54
|
+
faraday.response :raise_error, include_request: true
|
55
|
+
faraday.adapter :async_http
|
56
|
+
faraday.request :retry, { max: max_retries } unless max_retries.nil?
|
57
|
+
faraday.options.timeout = timeout_in_seconds unless timeout_in_seconds.nil?
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
# Additional options for request-specific configuration when calling APIs via the SDK.
|
63
|
+
class RequestOptions
|
64
|
+
attr_reader :api_key, :additional_headers, :additional_query_parameters, :additional_body_parameters,
|
65
|
+
:timeout_in_seconds
|
66
|
+
|
67
|
+
# @param api_key [String]
|
68
|
+
# @param additional_headers [Hash{String => Object}]
|
69
|
+
# @param additional_query_parameters [Hash{String => Object}]
|
70
|
+
# @param additional_body_parameters [Hash{String => Object}]
|
71
|
+
# @param timeout_in_seconds [Long]
|
72
|
+
# @return [RequestOptions]
|
73
|
+
def initialize(api_key: nil, additional_headers: nil, additional_query_parameters: nil,
|
74
|
+
additional_body_parameters: nil, timeout_in_seconds: nil)
|
75
|
+
# @type [String]
|
76
|
+
@api_key = api_key
|
77
|
+
# @type [Hash{String => Object}]
|
78
|
+
@additional_headers = additional_headers
|
79
|
+
# @type [Hash{String => Object}]
|
80
|
+
@additional_query_parameters = additional_query_parameters
|
81
|
+
# @type [Hash{String => Object}]
|
82
|
+
@additional_body_parameters = additional_body_parameters
|
83
|
+
# @type [Long]
|
84
|
+
@timeout_in_seconds = timeout_in_seconds
|
85
|
+
end
|
86
|
+
end
|
87
|
+
end
|
data/lib/types_export.rb
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative "intrinsic/types/list_event_types_response"
|
4
|
+
require_relative "intrinsic/types/event_type_object"
|
5
|
+
require_relative "intrinsic/types/event_type_field_type"
|
6
|
+
require_relative "intrinsic/types/event_type_field"
|
7
|
+
require_relative "intrinsic/types/create_event_sync_request"
|
8
|
+
require_relative "intrinsic/types/create_event_sync_response"
|
9
|
+
require_relative "intrinsic/types/create_event_async_request"
|
10
|
+
require_relative "intrinsic/types/create_event_async_response"
|
11
|
+
require_relative "intrinsic/types/fired_rule_object"
|
12
|
+
require_relative "intrinsic/types/detection_object_status"
|
13
|
+
require_relative "intrinsic/types/detection_object"
|
14
|
+
require_relative "intrinsic/types/violated_policy_object"
|
15
|
+
require_relative "intrinsic/types/error_schema_error_type"
|
16
|
+
require_relative "intrinsic/types/error_schema_error_code"
|
17
|
+
require_relative "intrinsic/types/error_schema_error"
|
18
|
+
require_relative "intrinsic/types/error_schema"
|