esp_sdk 2.0.0 → 2.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.travis.yml +1 -0
- data/CHANGELOG.md +6 -1
- data/Gemfile.lock +11 -1
- data/README.md +287 -28
- data/bin/esp +15 -0
- data/esp_sdk.gemspec +2 -0
- data/lib/esp/aws_clients.rb +60 -0
- data/lib/esp/commands/add_external_account.rb +57 -0
- data/lib/esp/commands/commands_tasks.rb +106 -0
- data/lib/esp/commands/console.rb +68 -0
- data/lib/esp/extensions/active_resource/formats/json_api_format.rb +12 -4
- data/lib/esp/extensions/active_resource/paginated_collection.rb +5 -5
- data/lib/esp/extensions/active_resource/validations.rb +1 -1
- data/lib/esp/external_account_creator.rb +77 -0
- data/lib/esp/resources/alert.rb +30 -34
- data/lib/esp/resources/cloud_trail_event.rb +5 -0
- data/lib/esp/resources/contact_request.rb +6 -5
- data/lib/esp/resources/custom_signature.rb +32 -56
- data/lib/esp/resources/dashboard.rb +8 -1
- data/lib/esp/resources/external_account.rb +27 -19
- data/lib/esp/resources/organization.rb +27 -3
- data/lib/esp/resources/region.rb +15 -3
- data/lib/esp/resources/report.rb +28 -24
- data/lib/esp/resources/resource.rb +26 -10
- data/lib/esp/resources/service.rb +5 -0
- data/lib/esp/resources/signature.rb +28 -12
- data/lib/esp/resources/stat.rb +21 -2
- data/lib/esp/resources/stat_custom_signature.rb +30 -4
- data/lib/esp/resources/stat_region.rb +29 -3
- data/lib/esp/resources/stat_service.rb +29 -3
- data/lib/esp/resources/stat_signature.rb +29 -3
- data/lib/esp/resources/sub_organization.rb +27 -3
- data/lib/esp/resources/suppression/region.rb +14 -32
- data/lib/esp/resources/suppression/signature.rb +14 -40
- data/lib/esp/resources/suppression/unique_identifier.rb +8 -6
- data/lib/esp/resources/suppression.rb +43 -5
- data/lib/esp/resources/tag.rb +5 -0
- data/lib/esp/resources/team.rb +33 -9
- data/lib/esp/resources/user.rb +29 -3
- data/lib/esp/version.rb +1 -1
- data/lib/esp.rb +25 -5
- data/test/esp/aws_clients_test.rb +101 -0
- data/test/esp/extensions/active_resource/formats/json_api_format_test.rb +26 -12
- data/test/esp/extensions/active_resource/paginated_collection_test.rb +93 -72
- data/test/esp/extensions/active_resource/validations_test.rb +2 -12
- data/test/esp/external_account_creator_test.rb +153 -0
- data/test/esp/resources/alert_test.rb +71 -33
- data/test/esp/resources/cloud_trail_event_test.rb +9 -1
- data/test/esp/resources/contact_request_test.rb +8 -0
- data/test/esp/resources/custom_signature_test.rb +8 -0
- data/test/esp/resources/dashboard_test.rb +8 -0
- data/test/esp/resources/external_account_test.rb +8 -0
- data/test/esp/resources/metadata_test.rb +1 -1
- data/test/esp/resources/organization_test.rb +8 -0
- data/test/esp/resources/region_test.rb +12 -4
- data/test/esp/resources/report_test.rb +13 -4
- data/test/esp/resources/resource_test.rb +208 -64
- data/test/esp/resources/service_test.rb +8 -0
- data/test/esp/resources/signature_test.rb +15 -9
- data/test/esp/resources/stat_custom_signature_test.rb +9 -1
- data/test/esp/resources/stat_region_test.rb +23 -1
- data/test/esp/resources/stat_service_test.rb +23 -1
- data/test/esp/resources/stat_signature_test.rb +23 -1
- data/test/esp/resources/stat_test.rb +52 -8
- data/test/esp/resources/sub_organization_test.rb +8 -0
- data/test/esp/resources/suppression/region_test.rb +10 -2
- data/test/esp/resources/suppression/signature_test.rb +10 -2
- data/test/esp/resources/suppression/unique_identifier_test.rb +10 -2
- data/test/esp/resources/suppression_test.rb +74 -14
- data/test/esp/resources/tag_test.rb +9 -1
- data/test/esp/resources/team_test.rb +8 -0
- data/test/esp/resources/user_test.rb +49 -19
- data/test/esp_test.rb +19 -1
- data/test/factories/alerts.rb +70 -0
- data/test/factories/organizations.rb +2 -2
- data/test/factories/regions.rb +1 -1
- data/test/factories/sub_organizations.rb +1 -1
- data/test/factories/suppressions.rb +109 -3
- data/test/factories/users.rb +65 -2
- data/test/test_helper.rb +9 -8
- metadata +41 -69
- data/bin/esp_console +0 -67
- data/rdoc/ActiveResource/Formats.html +0 -178
- data/rdoc/ActiveResource/PaginatedCollection.html +0 -912
- data/rdoc/ActiveResource.html +0 -182
- data/rdoc/ESP/Alert.html +0 -808
- data/rdoc/ESP/CloudTrailEvent.html +0 -377
- data/rdoc/ESP/ContactRequest.html +0 -368
- data/rdoc/ESP/CustomSignature.html +0 -748
- data/rdoc/ESP/Dashboard.html +0 -357
- data/rdoc/ESP/ExternalAccount.html +0 -567
- data/rdoc/ESP/Metadata.html +0 -411
- data/rdoc/ESP/Organization.html +0 -592
- data/rdoc/ESP/Region.html +0 -401
- data/rdoc/ESP/Report.html +0 -624
- data/rdoc/ESP/Service.html +0 -382
- data/rdoc/ESP/Signature.html +0 -557
- data/rdoc/ESP/Stat.html +0 -1780
- data/rdoc/ESP/StatCustomSignature.html +0 -1601
- data/rdoc/ESP/StatRegion.html +0 -1600
- data/rdoc/ESP/StatService.html +0 -1600
- data/rdoc/ESP/StatSignature.html +0 -1600
- data/rdoc/ESP/SubOrganization.html +0 -542
- data/rdoc/ESP/Suppression/Region.html +0 -456
- data/rdoc/ESP/Suppression/Signature.html +0 -472
- data/rdoc/ESP/Suppression/UniqueIdentifier.html +0 -419
- data/rdoc/ESP/Suppression.html +0 -651
- data/rdoc/ESP/Tag.html +0 -373
- data/rdoc/ESP/Team.html +0 -586
- data/rdoc/ESP/User.html +0 -485
- data/rdoc/ESP.html +0 -549
- data/rdoc/README_md.html +0 -503
- data/rdoc/created.rid +0 -31
- data/rdoc/images/add.png +0 -0
- data/rdoc/images/arrow_up.png +0 -0
- data/rdoc/images/brick.png +0 -0
- data/rdoc/images/brick_link.png +0 -0
- data/rdoc/images/bug.png +0 -0
- data/rdoc/images/bullet_black.png +0 -0
- data/rdoc/images/bullet_toggle_minus.png +0 -0
- data/rdoc/images/bullet_toggle_plus.png +0 -0
- data/rdoc/images/date.png +0 -0
- data/rdoc/images/delete.png +0 -0
- data/rdoc/images/find.png +0 -0
- data/rdoc/images/loadingAnimation.gif +0 -0
- data/rdoc/images/macFFBgHack.png +0 -0
- data/rdoc/images/package.png +0 -0
- data/rdoc/images/page_green.png +0 -0
- data/rdoc/images/page_white_text.png +0 -0
- data/rdoc/images/page_white_width.png +0 -0
- data/rdoc/images/plugin.png +0 -0
- data/rdoc/images/ruby.png +0 -0
- data/rdoc/images/tag_blue.png +0 -0
- data/rdoc/images/tag_green.png +0 -0
- data/rdoc/images/transparent.png +0 -0
- data/rdoc/images/wrench.png +0 -0
- data/rdoc/images/wrench_orange.png +0 -0
- data/rdoc/images/zoom.png +0 -0
- data/rdoc/index.html +0 -136
- data/rdoc/js/darkfish.js +0 -155
- data/rdoc/js/jquery.js +0 -4
- data/rdoc/js/navigation.js +0 -142
- data/rdoc/js/search.js +0 -94
- data/rdoc/js/search_index.js +0 -1
- data/rdoc/js/searcher.js +0 -228
- data/rdoc/rdoc.css +0 -595
- data/rdoc/table_of_contents.html +0 -942
data/lib/esp/resources/region.rb
CHANGED
|
@@ -18,9 +18,7 @@ module ESP
|
|
|
18
18
|
#
|
|
19
19
|
# ===== Valid Arguments
|
|
20
20
|
#
|
|
21
|
-
#
|
|
22
|
-
#
|
|
23
|
-
# +reason+ | Required | The reason for creating the suppression.
|
|
21
|
+
# See {API documentation}[http://api-docs.evident.io?ruby#suppression-create] for valid arguments
|
|
24
22
|
#
|
|
25
23
|
# ==== Example
|
|
26
24
|
# suppress(external_account_ids: [5], reason: 'My very good reason for creating this suppression')
|
|
@@ -29,6 +27,20 @@ module ESP
|
|
|
29
27
|
ESP::Suppression::Region.create(regions: [code], external_account_ids: Array(arguments[:external_account_ids]), reason: arguments[:reason])
|
|
30
28
|
end
|
|
31
29
|
|
|
30
|
+
# :singleton-method: where
|
|
31
|
+
# Return a paginated Region list filtered by search parameters
|
|
32
|
+
#
|
|
33
|
+
# ==== Parameters
|
|
34
|
+
#
|
|
35
|
+
# +clauses+ | Hash of attributes with appended predicates to search and sort by.
|
|
36
|
+
#
|
|
37
|
+
# ===== Valid Clauses
|
|
38
|
+
#
|
|
39
|
+
# See {API documentation}[http://api-docs.evident.io?ruby#region-attributes] for valid arguments
|
|
40
|
+
#
|
|
41
|
+
# :call-seq:
|
|
42
|
+
# where(clauses = {})
|
|
43
|
+
|
|
32
44
|
##
|
|
33
45
|
# :singleton-method: find
|
|
34
46
|
# Find a Region by id
|
data/lib/esp/resources/report.rb
CHANGED
|
@@ -26,7 +26,7 @@ module ESP
|
|
|
26
26
|
# Returns a Report object with a status of 'queued' and an id
|
|
27
27
|
# ==== Attribute
|
|
28
28
|
#
|
|
29
|
-
#
|
|
29
|
+
# See {API documentation}[http://api-docs.evident.io?ruby#report-create] for valid arguments
|
|
30
30
|
#
|
|
31
31
|
# Periodically check the API
|
|
32
32
|
# ESP::Report.find(<id>)
|
|
@@ -48,34 +48,14 @@ module ESP
|
|
|
48
48
|
#
|
|
49
49
|
# ===== Valid Arguments
|
|
50
50
|
#
|
|
51
|
-
#
|
|
52
|
-
#
|
|
53
|
-
# +status+ | Not Required | Return only alerts for the give status(es). Valid values are fail, warn, error, pass, info
|
|
54
|
-
#
|
|
55
|
-
# +first_seen+ | Not Required | Return only alerts that have started within a number of hours of the report. For example, first_seen of 3 will return alerts that started showing up within the last 3 hours of the report.
|
|
56
|
-
#
|
|
57
|
-
# +suppressed+ | Not Required | Return only suppressed alerts
|
|
58
|
-
#
|
|
59
|
-
# +team_id+ | Not Required | Return only alerts for the given team.
|
|
60
|
-
#
|
|
61
|
-
# +external_account_id+ | Not Required | Return only alerts for the given external id.
|
|
62
|
-
#
|
|
63
|
-
# +service_id+ | Not Required | Return only alerts on signatures with the given service.
|
|
64
|
-
#
|
|
65
|
-
# +signature_severity+ | Not Required | Return only alerts for signatures with the given risk_level. Valid values are Low, Medium, High
|
|
66
|
-
#
|
|
67
|
-
# +signature_name+ | Not Required | Return only alerts for signatures with the given name.
|
|
68
|
-
#
|
|
69
|
-
# +resource+ | Not Required | Return only alerts for the given resource or tag.
|
|
70
|
-
#
|
|
71
|
-
# +signature_identifier+ | Not Required | Return only alerts for signatures with the given identifier.
|
|
51
|
+
# See {API documentation}[http://api-docs.evident.io?ruby#alert-attributes] for valid arguments
|
|
72
52
|
#
|
|
73
53
|
# ==== Example
|
|
74
54
|
#
|
|
75
55
|
# report = ESP::Report.find(345)
|
|
76
56
|
# alerts = report.alerts(status: 'fail', signature_severity: 'High')
|
|
77
57
|
def alerts(arguments = {})
|
|
78
|
-
ESP::Alert.
|
|
58
|
+
ESP::Alert.where(arguments.merge(report_id: id))
|
|
79
59
|
end
|
|
80
60
|
|
|
81
61
|
# Returns the stats for this report
|
|
@@ -83,6 +63,20 @@ module ESP
|
|
|
83
63
|
ESP::Stat.for_report(id)
|
|
84
64
|
end
|
|
85
65
|
|
|
66
|
+
# :singleton-method: where
|
|
67
|
+
# Return a paginated Report list filtered by search parameters
|
|
68
|
+
#
|
|
69
|
+
# ==== Parameters
|
|
70
|
+
#
|
|
71
|
+
# +clauses+ | Hash of attributes with appended predicates to search, sort and include.
|
|
72
|
+
#
|
|
73
|
+
# ===== Valid Clauses
|
|
74
|
+
#
|
|
75
|
+
# See {API documentation}[http://api-docs.evident.io?ruby#report-attributes] for valid arguments
|
|
76
|
+
#
|
|
77
|
+
# :call-seq:
|
|
78
|
+
# where(clauses = {})
|
|
79
|
+
|
|
86
80
|
##
|
|
87
81
|
# :singleton-method: find
|
|
88
82
|
# Find a Report by id
|
|
@@ -91,8 +85,18 @@ module ESP
|
|
|
91
85
|
#
|
|
92
86
|
# +id+ | Required | The ID of the report to retrieve
|
|
93
87
|
#
|
|
88
|
+
# +options+ | Optional | A hash of options
|
|
89
|
+
#
|
|
90
|
+
# ===== Valid Options
|
|
91
|
+
#
|
|
92
|
+
# +include+ | The list of associated objects to return on the initial request.
|
|
93
|
+
#
|
|
94
|
+
# ===== Valid Includable Associations
|
|
95
|
+
#
|
|
96
|
+
# See {API documentation}[http://api-docs.evident.io?ruby#report-attributes] for valid arguments
|
|
97
|
+
#
|
|
94
98
|
# :call-seq:
|
|
95
|
-
# find(id)
|
|
99
|
+
# find(id, options = {})
|
|
96
100
|
|
|
97
101
|
# :singleton-method: all
|
|
98
102
|
# Return a paginated Report list
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
module ESP
|
|
2
2
|
class Resource < ActiveResource::Base # :nodoc:
|
|
3
3
|
self.site = ESP.site
|
|
4
|
+
self.proxy = ESP.http_proxy
|
|
4
5
|
self.format = ActiveResource::Formats::JsonAPIFormat
|
|
5
6
|
with_api_auth(ESP.access_key_id, ESP.secret_access_key)
|
|
6
7
|
headers["Content-Type"] = format.mime_type
|
|
@@ -8,9 +9,8 @@ module ESP
|
|
|
8
9
|
|
|
9
10
|
self.collection_parser = ActiveResource::PaginatedCollection
|
|
10
11
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
end
|
|
12
|
+
# List of predicates that can be used for searching
|
|
13
|
+
PREDICATES = %w(sorts m eq eq_any eq_all not_eq not_eq_any not_eq_all matches matches_any matches_all does_not_match does_not_match_any does_not_match_all lt lt_any lt_all lteq lteq_any lteq_all gt gt_any gt_all gteq gteq_any gteq_all in in_any in_all not_in not_in_any not_in_all cont cont_any cont_all not_cont not_cont_any not_cont_all start start_any start_all not_start not_start_any not_start_all end end_any end_all not_end not_end_any not_end_all true false present blank null not_null).join('|').freeze
|
|
14
14
|
|
|
15
15
|
# Pass a json api compliant hash to the api.
|
|
16
16
|
def serializable_hash(*)
|
|
@@ -21,6 +21,17 @@ module ESP
|
|
|
21
21
|
h
|
|
22
22
|
end
|
|
23
23
|
|
|
24
|
+
def self.where(clauses = {})
|
|
25
|
+
fail ArgumentError, "expected a clauses Hash, got #{clauses.inspect}" unless clauses.is_a? Hash
|
|
26
|
+
from = clauses.delete(:from) || "#{prefix}#{name.demodulize.pluralize.underscore}"
|
|
27
|
+
clauses = { params: clauses }
|
|
28
|
+
arrange_options(clauses)
|
|
29
|
+
prefix_options, query_options = split_options(clauses)
|
|
30
|
+
instantiate_collection((format.decode(connection.put("#{from}.json", clauses[:params].to_json).body) || []), query_options, prefix_options).tap do |collection|
|
|
31
|
+
make_pageable collection, clauses.merge(from: from)
|
|
32
|
+
end
|
|
33
|
+
end
|
|
34
|
+
|
|
24
35
|
def self.find(*arguments)
|
|
25
36
|
scope = arguments.slice!(0)
|
|
26
37
|
options = (arguments.slice!(0) || {}).with_indifferent_access
|
|
@@ -30,20 +41,24 @@ module ESP
|
|
|
30
41
|
end
|
|
31
42
|
end
|
|
32
43
|
|
|
33
|
-
def self.filters(params)
|
|
44
|
+
def self.filters(params) # rubocop:disable Metrics/MethodLength
|
|
34
45
|
h = {}.tap do |filters|
|
|
35
46
|
params.each do |attr, value|
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
47
|
+
unless attr =~ /(#{PREDICATES})$/
|
|
48
|
+
attr = if value.is_a? Enumerable
|
|
49
|
+
"#{attr}_in"
|
|
50
|
+
else
|
|
51
|
+
"#{attr}_eq"
|
|
52
|
+
end
|
|
40
53
|
end
|
|
54
|
+
filters[attr] = value
|
|
41
55
|
end
|
|
42
56
|
end
|
|
43
57
|
{ filter: h }
|
|
44
58
|
end
|
|
45
59
|
|
|
46
|
-
def self.make_pageable(object, options)
|
|
60
|
+
def self.make_pageable(object, options = {}) # rubocop:disable Style/OptionHash
|
|
61
|
+
options = options.with_indifferent_access
|
|
47
62
|
return object unless object.is_a? ActiveResource::PaginatedCollection
|
|
48
63
|
# Need to set from so paginated collection can use it for page calls.
|
|
49
64
|
object.tap do |collection|
|
|
@@ -55,8 +70,9 @@ module ESP
|
|
|
55
70
|
def self.arrange_options(options)
|
|
56
71
|
if options[:params].present?
|
|
57
72
|
page = options[:params][:page] ? { page: options[:params].delete(:page) } : {}
|
|
73
|
+
include = options[:params][:include] ? { include: options[:params].delete(:include) } : {}
|
|
58
74
|
options[:params].merge!(options[:params].delete(:filter)) if options[:params][:filter]
|
|
59
|
-
options[:params] = filters(options[:params]).merge!(page)
|
|
75
|
+
options[:params] = filters(options[:params]).merge!(page).merge!(include)
|
|
60
76
|
end
|
|
61
77
|
if options[:include].present?
|
|
62
78
|
options[:params] ||= {}
|
|
@@ -4,6 +4,11 @@ module ESP
|
|
|
4
4
|
# The collection of signatures associated with this service.
|
|
5
5
|
has_many :signatures, class_name: 'ESP::Signature'
|
|
6
6
|
|
|
7
|
+
# Not Implemented. You cannot search for a Tag.
|
|
8
|
+
def self.where(*)
|
|
9
|
+
fail ESP::NotImplementedError
|
|
10
|
+
end
|
|
11
|
+
|
|
7
12
|
# Not Implemented. You cannot create or update a Service.
|
|
8
13
|
def save
|
|
9
14
|
fail ESP::NotImplementedError
|
|
@@ -24,9 +24,7 @@ module ESP
|
|
|
24
24
|
#
|
|
25
25
|
# ===== Valid Arguments
|
|
26
26
|
#
|
|
27
|
-
#
|
|
28
|
-
#
|
|
29
|
-
# +region+ | Required | Region name to run this custom signature against
|
|
27
|
+
# See {API documentation}[http://api-docs.evident.io?ruby#signature-run] for valid arguments
|
|
30
28
|
#
|
|
31
29
|
# ==== Example
|
|
32
30
|
# signature = ESP::Signature.find(3)
|
|
@@ -48,9 +46,7 @@ module ESP
|
|
|
48
46
|
#
|
|
49
47
|
# ===== Valid Arguments
|
|
50
48
|
#
|
|
51
|
-
#
|
|
52
|
-
#
|
|
53
|
-
# +region+ | Required | Region name to run this custom signature against
|
|
49
|
+
# See {API documentation}[http://api-docs.evident.io?ruby#signature-run] for valid arguments
|
|
54
50
|
#
|
|
55
51
|
# ==== Example
|
|
56
52
|
# signature = ESP::Signature.find(3)
|
|
@@ -76,11 +72,7 @@ module ESP
|
|
|
76
72
|
#
|
|
77
73
|
# ===== Valid Arguments
|
|
78
74
|
#
|
|
79
|
-
#
|
|
80
|
-
#
|
|
81
|
-
# +external_account_ids+ | Required | An Array of the external accounts identified by +external_account_id+ to suppress the signature or custom signature on.
|
|
82
|
-
#
|
|
83
|
-
# +reason+ | Required | The reason for creating the suppression.
|
|
75
|
+
# See {API documentation}[http://api-docs.evident.io?ruby#suppression-create] for valid arguments
|
|
84
76
|
#
|
|
85
77
|
# ==== Example
|
|
86
78
|
# suppress(regions: ['us_east_1'], external_account_ids: [5], reason: 'My very good reason for creating this suppression')
|
|
@@ -89,6 +81,20 @@ module ESP
|
|
|
89
81
|
ESP::Suppression::Signature.create(signature_ids: [id], regions: Array(arguments[:regions]), external_account_ids: Array(arguments[:external_account_ids]), reason: arguments[:reason])
|
|
90
82
|
end
|
|
91
83
|
|
|
84
|
+
# :singleton-method: where
|
|
85
|
+
# Return a paginated Signature list filtered by search parameters
|
|
86
|
+
#
|
|
87
|
+
# ==== Parameters
|
|
88
|
+
#
|
|
89
|
+
# +clauses+ | Hash of attributes with appended predicates to search, sort and include.
|
|
90
|
+
#
|
|
91
|
+
# ===== Valid Clauses
|
|
92
|
+
#
|
|
93
|
+
# See {API documentation}[http://api-docs.evident.io?ruby#signature-attributes] for valid arguments
|
|
94
|
+
#
|
|
95
|
+
# :call-seq:
|
|
96
|
+
# where(clauses = {})
|
|
97
|
+
|
|
92
98
|
##
|
|
93
99
|
# :singleton-method: find
|
|
94
100
|
# Find a Signature by id
|
|
@@ -97,8 +103,18 @@ module ESP
|
|
|
97
103
|
#
|
|
98
104
|
# +id+ | Required | The ID of the signature to retrieve
|
|
99
105
|
#
|
|
106
|
+
# +options+ | Optional | A hash of options
|
|
107
|
+
#
|
|
108
|
+
# ===== Valid Options
|
|
109
|
+
#
|
|
110
|
+
# +include+ | The list of associated objects to return on the initial request.
|
|
111
|
+
#
|
|
112
|
+
# ===== Valid Includable Associations
|
|
113
|
+
#
|
|
114
|
+
# See {API documentation}[http://api-docs.evident.io?ruby#signature-attributes] for valid arguments
|
|
115
|
+
#
|
|
100
116
|
# :call-seq:
|
|
101
|
-
# find(id)
|
|
117
|
+
# find(id, options = {})
|
|
102
118
|
|
|
103
119
|
# :singleton-method: all
|
|
104
120
|
# Return a paginated Signature list
|
data/lib/esp/resources/stat.rb
CHANGED
|
@@ -22,6 +22,11 @@ module ESP
|
|
|
22
22
|
# The stats for each custom signature associated with this stat object.
|
|
23
23
|
has_many :custom_signatures, class_name: 'ESP::StatCustomSignature'
|
|
24
24
|
|
|
25
|
+
# Not Implemented. You cannot search for a Stat.
|
|
26
|
+
def self.where(*)
|
|
27
|
+
fail ESP::NotImplementedError
|
|
28
|
+
end
|
|
29
|
+
|
|
25
30
|
# Not Implemented. You cannot search for a Stat.
|
|
26
31
|
def self.find(*)
|
|
27
32
|
fail ESP::NotImplementedError, 'Regular ARELlike methods are disabled. Use either the ESP::Stat.for_report or ESP::Stat.latest_for_teams method.'
|
|
@@ -37,10 +42,24 @@ module ESP
|
|
|
37
42
|
# Not Implemented. You cannot delete a Stat.
|
|
38
43
|
|
|
39
44
|
# Returns all the stats of all the alerts for a report identified by the report_id parameter. Said report contains all statistics for this alert triggered from signatures contained in all regions for the selected hour.
|
|
40
|
-
|
|
45
|
+
#
|
|
46
|
+
# ==== Parameters
|
|
47
|
+
#
|
|
48
|
+
# +report_id+ | Required | The ID of the report to retrieve stats for
|
|
49
|
+
#
|
|
50
|
+
# +options+ | Optional | A hash of options
|
|
51
|
+
#
|
|
52
|
+
# ===== Valid Options
|
|
53
|
+
#
|
|
54
|
+
# +include+ | The list of associated objects to return on the initial request.
|
|
55
|
+
#
|
|
56
|
+
# ===== valid Includable Associations
|
|
57
|
+
#
|
|
58
|
+
# See {API documentation}[http://api-docs.evident.io?ruby#alert-attributes] for valid arguments
|
|
59
|
+
def self.for_report(report_id = nil, options = {}) # rubocop:disable Style/OptionHash
|
|
41
60
|
fail ArgumentError, "You must supply a report id." unless report_id.present?
|
|
42
61
|
# call find_one directly since find is overriden/not implemented
|
|
43
|
-
find_one(from: "#{prefix}reports/#{report_id}/stats.json")
|
|
62
|
+
find_one(from: "#{prefix}reports/#{report_id}/stats.json", params: options)
|
|
44
63
|
end
|
|
45
64
|
|
|
46
65
|
# Returns all the stats for the most recent report of each team accessible by the given API key.
|
|
@@ -2,22 +2,38 @@ module ESP
|
|
|
2
2
|
class StatCustomSignature < ESP::Resource
|
|
3
3
|
include ESP::StatTotals
|
|
4
4
|
|
|
5
|
+
##
|
|
5
6
|
# The custom_signature these stats are for.
|
|
6
7
|
belongs_to :custom_signature, class_name: 'ESP::CustomSignature'
|
|
7
8
|
|
|
9
|
+
# Not Implemented. You cannot search for a StatSignature.
|
|
10
|
+
def self.where(*)
|
|
11
|
+
fail ESP::NotImplementedError
|
|
12
|
+
end
|
|
13
|
+
|
|
8
14
|
# Returns a paginated collection of custom_signature stats for the given stat_id
|
|
9
15
|
# Convenience method to use instead of ::find since a stat_id is required to return custom_signature stats.
|
|
10
16
|
#
|
|
11
|
-
# ====
|
|
17
|
+
# ==== Parameters
|
|
12
18
|
#
|
|
13
19
|
# +stat_id+ | Required | The ID of the stat to list custom_signature stats for
|
|
14
20
|
#
|
|
21
|
+
# +options+ | Optional | A hash of options
|
|
22
|
+
#
|
|
23
|
+
# ===== Valid Options
|
|
24
|
+
#
|
|
25
|
+
# +include+ | The list of associated objects to return on the initial request.
|
|
26
|
+
#
|
|
27
|
+
# ===== valid Includable Associations
|
|
28
|
+
#
|
|
29
|
+
# See {API documentation}[http://api-docs.evident.io?ruby#stat-custom-signature-attributes] for valid arguments
|
|
30
|
+
#
|
|
15
31
|
# ==== Example
|
|
16
32
|
# stats = ESP::StatCustomSignature.for_stat(1194)
|
|
17
|
-
def self.for_stat(stat_id = nil)
|
|
33
|
+
def self.for_stat(stat_id = nil, options = {}) # rubocop:disable Style/OptionHash
|
|
18
34
|
fail ArgumentError, "You must supply a stat id." unless stat_id.present?
|
|
19
35
|
from = "#{prefix}stats/#{stat_id}/custom_signatures.json"
|
|
20
|
-
find(:all, from: from)
|
|
36
|
+
find(:all, from: from, params: options)
|
|
21
37
|
end
|
|
22
38
|
|
|
23
39
|
# Find a StatRegion by id
|
|
@@ -26,8 +42,18 @@ module ESP
|
|
|
26
42
|
#
|
|
27
43
|
# +id+ | Required | The ID of the custom_signature stat to retrieve
|
|
28
44
|
#
|
|
45
|
+
# +options+ | Optional | A hash of options
|
|
46
|
+
#
|
|
47
|
+
# ===== Valid Options
|
|
48
|
+
#
|
|
49
|
+
# +include+ | The list of associated objects to return on the initial request.
|
|
50
|
+
#
|
|
51
|
+
# ===== valid Includable Associations
|
|
52
|
+
#
|
|
53
|
+
# See {API documentation}[http://api-docs.evident.io?ruby#stat-custom-signature-attributes] for valid arguments
|
|
54
|
+
#
|
|
29
55
|
# :call-seq:
|
|
30
|
-
# find(id)
|
|
56
|
+
# find(id, options = {})
|
|
31
57
|
def self.find(*arguments)
|
|
32
58
|
scope = arguments.slice!(0)
|
|
33
59
|
options = (arguments.slice!(0) || {}).with_indifferent_access
|
|
@@ -2,9 +2,15 @@ module ESP
|
|
|
2
2
|
class StatRegion < ESP::Resource
|
|
3
3
|
include ESP::StatTotals
|
|
4
4
|
|
|
5
|
+
##
|
|
5
6
|
# The region these stats are for.
|
|
6
7
|
belongs_to :region, class_name: 'ESP::Region'
|
|
7
8
|
|
|
9
|
+
# Not Implemented. You cannot search for a StatSignature.
|
|
10
|
+
def self.where(*)
|
|
11
|
+
fail ESP::NotImplementedError
|
|
12
|
+
end
|
|
13
|
+
|
|
8
14
|
# Returns a paginated collection of region stats for the given stat_id
|
|
9
15
|
# Convenience method to use instead of ::find since a stat_id is required to return region stats.
|
|
10
16
|
#
|
|
@@ -12,12 +18,22 @@ module ESP
|
|
|
12
18
|
#
|
|
13
19
|
# +stat_id+ | Required | The ID of the stat to list region stats for
|
|
14
20
|
#
|
|
21
|
+
# +options+ | Optional | A hash of options
|
|
22
|
+
#
|
|
23
|
+
# ===== Valid Options
|
|
24
|
+
#
|
|
25
|
+
# +include+ | The list of associated objects to return on the initial request.
|
|
26
|
+
#
|
|
27
|
+
# ===== valid Includable Associations
|
|
28
|
+
#
|
|
29
|
+
# See {API documentation}[http://api-docs.evident.io?ruby#stat-region-attributes] for valid arguments
|
|
30
|
+
#
|
|
15
31
|
# ==== Example
|
|
16
32
|
# stats = ESP::StatRegion.for_stat(1194)
|
|
17
|
-
def self.for_stat(stat_id = nil)
|
|
33
|
+
def self.for_stat(stat_id = nil, options = {}) # rubocop:disable Style/OptionHash
|
|
18
34
|
fail ArgumentError, "You must supply a stat id." unless stat_id.present?
|
|
19
35
|
from = "#{prefix}stats/#{stat_id}/regions.json"
|
|
20
|
-
find(:all, from: from)
|
|
36
|
+
find(:all, from: from, params: options)
|
|
21
37
|
end
|
|
22
38
|
|
|
23
39
|
# Find a StatRegion by id
|
|
@@ -26,8 +42,18 @@ module ESP
|
|
|
26
42
|
#
|
|
27
43
|
# +id+ | Required | The ID of the region stat to retrieve
|
|
28
44
|
#
|
|
45
|
+
# +options+ | Optional | A hash of options
|
|
46
|
+
#
|
|
47
|
+
# ===== Valid Options
|
|
48
|
+
#
|
|
49
|
+
# +include+ | The list of associated objects to return on the initial request.
|
|
50
|
+
#
|
|
51
|
+
# ===== valid Includable Associations
|
|
52
|
+
#
|
|
53
|
+
# See {API documentation}[http://api-docs.evident.io?ruby#stat-region-attributes] for valid arguments
|
|
54
|
+
#
|
|
29
55
|
# :call-seq:
|
|
30
|
-
# find(id)
|
|
56
|
+
# find(id, options = {})
|
|
31
57
|
def self.find(*arguments)
|
|
32
58
|
scope = arguments.slice!(0)
|
|
33
59
|
options = (arguments.slice!(0) || {}).with_indifferent_access
|
|
@@ -2,9 +2,15 @@ module ESP
|
|
|
2
2
|
class StatService < ESP::Resource
|
|
3
3
|
include ESP::StatTotals
|
|
4
4
|
|
|
5
|
+
##
|
|
5
6
|
# The service these stats are for.
|
|
6
7
|
belongs_to :service, class_name: 'ESP::Service'
|
|
7
8
|
|
|
9
|
+
# Not Implemented. You cannot search for a StatSignature.
|
|
10
|
+
def self.where(*)
|
|
11
|
+
fail ESP::NotImplementedError
|
|
12
|
+
end
|
|
13
|
+
|
|
8
14
|
# Returns a paginated collection of service stats for the given stat_id
|
|
9
15
|
# Convenience method to use instead of ::find since a stat_id is required to return service stats.
|
|
10
16
|
#
|
|
@@ -12,12 +18,22 @@ module ESP
|
|
|
12
18
|
#
|
|
13
19
|
# +stat_id+ | Required | The ID of the stat to list service stats for
|
|
14
20
|
#
|
|
21
|
+
# +options+ | Optional | A hash of options
|
|
22
|
+
#
|
|
23
|
+
# ===== Valid Options
|
|
24
|
+
#
|
|
25
|
+
# +include+ | The list of associated objects to return on the initial request.
|
|
26
|
+
#
|
|
27
|
+
# ===== valid Includable Associations
|
|
28
|
+
#
|
|
29
|
+
# See {API documentation}[http://api-docs.evident.io?ruby#stat-service-attributes] for valid arguments
|
|
30
|
+
#
|
|
15
31
|
# ==== Example
|
|
16
32
|
# stats = ESP::StatService.for_stat(1194)
|
|
17
|
-
def self.for_stat(stat_id = nil)
|
|
33
|
+
def self.for_stat(stat_id = nil, options = {}) # rubocop:disable Style/OptionHash
|
|
18
34
|
fail ArgumentError, "You must supply a stat id." unless stat_id.present?
|
|
19
35
|
from = "#{prefix}stats/#{stat_id}/services.json"
|
|
20
|
-
find(:all, from: from)
|
|
36
|
+
find(:all, from: from, params: options)
|
|
21
37
|
end
|
|
22
38
|
|
|
23
39
|
# Find a StatService by id
|
|
@@ -26,8 +42,18 @@ module ESP
|
|
|
26
42
|
#
|
|
27
43
|
# +id+ | Required | The ID of the service stat to retrieve
|
|
28
44
|
#
|
|
45
|
+
# +options+ | Optional | A hash of options
|
|
46
|
+
#
|
|
47
|
+
# ===== Valid Options
|
|
48
|
+
#
|
|
49
|
+
# +include+ | The list of associated objects to return on the initial request.
|
|
50
|
+
#
|
|
51
|
+
# ===== valid Includable Associations
|
|
52
|
+
#
|
|
53
|
+
# See {API documentation}[http://api-docs.evident.io?ruby#stat-service-attributes] for valid arguments
|
|
54
|
+
#
|
|
29
55
|
# :call-seq:
|
|
30
|
-
# find(id)
|
|
56
|
+
# find(id, options = {})
|
|
31
57
|
def self.find(*arguments)
|
|
32
58
|
scope = arguments.slice!(0)
|
|
33
59
|
options = (arguments.slice!(0) || {}).with_indifferent_access
|
|
@@ -2,9 +2,15 @@ module ESP
|
|
|
2
2
|
class StatSignature < ESP::Resource
|
|
3
3
|
include ESP::StatTotals
|
|
4
4
|
|
|
5
|
+
##
|
|
5
6
|
# The signature these stats are for.
|
|
6
7
|
belongs_to :signature, class_name: 'ESP::Signature'
|
|
7
8
|
|
|
9
|
+
# Not Implemented. You cannot search for a StatSignature.
|
|
10
|
+
def self.where(*)
|
|
11
|
+
fail ESP::NotImplementedError
|
|
12
|
+
end
|
|
13
|
+
|
|
8
14
|
# Returns a paginated collection of signature stats for the given stat_id
|
|
9
15
|
# Convenience method to use instead of ::find since a stat_id is required to return signature stats.
|
|
10
16
|
#
|
|
@@ -12,12 +18,22 @@ module ESP
|
|
|
12
18
|
#
|
|
13
19
|
# +stat_id+ | Required | The ID of the stat to list signature stats for
|
|
14
20
|
#
|
|
21
|
+
# +options+ | Optional | A hash of options
|
|
22
|
+
#
|
|
23
|
+
# ===== Valid Options
|
|
24
|
+
#
|
|
25
|
+
# +include+ | The list of associated objects to return on the initial request.
|
|
26
|
+
#
|
|
27
|
+
# ===== valid Includable Associations
|
|
28
|
+
#
|
|
29
|
+
# See {API documentation}[http://api-docs.evident.io?ruby#stat-signature-attributes] for valid arguments
|
|
30
|
+
#
|
|
15
31
|
# ==== Example
|
|
16
32
|
# stats = ESP::StatSignature.for_stat(1194)
|
|
17
|
-
def self.for_stat(stat_id = nil)
|
|
33
|
+
def self.for_stat(stat_id = nil, options = {}) # rubocop:disable Style/OptionHash
|
|
18
34
|
fail ArgumentError, "You must supply a stat id." unless stat_id.present?
|
|
19
35
|
from = "#{prefix}stats/#{stat_id}/signatures.json"
|
|
20
|
-
find(:all, from: from)
|
|
36
|
+
find(:all, from: from, params: options)
|
|
21
37
|
end
|
|
22
38
|
|
|
23
39
|
# Find a StatRegion by id
|
|
@@ -26,8 +42,18 @@ module ESP
|
|
|
26
42
|
#
|
|
27
43
|
# +id+ | Required | The ID of the signature stat to retrieve
|
|
28
44
|
#
|
|
45
|
+
# +options+ | Optional | A hash of options
|
|
46
|
+
#
|
|
47
|
+
# ===== Valid Options
|
|
48
|
+
#
|
|
49
|
+
# +include+ | The list of associated objects to return on the initial request.
|
|
50
|
+
#
|
|
51
|
+
# ===== valid Includable Associations
|
|
52
|
+
#
|
|
53
|
+
# See {API documentation}[http://api-docs.evident.io?ruby#stat-signature-attributes] for valid arguments
|
|
54
|
+
#
|
|
29
55
|
# :call-seq:
|
|
30
|
-
# find(id)
|
|
56
|
+
# find(id, options = {})
|
|
31
57
|
def self.find(*arguments)
|
|
32
58
|
scope = arguments.slice!(0)
|
|
33
59
|
options = (arguments.slice!(0) || {}).with_indifferent_access
|
|
@@ -16,6 +16,20 @@ module ESP
|
|
|
16
16
|
# The collection of reports that belong to the sub organization.
|
|
17
17
|
has_many :reports, class_name: 'ESP::Report'
|
|
18
18
|
|
|
19
|
+
# :singleton-method: where
|
|
20
|
+
# Return a paginated SubOrganization list filtered by search parameters
|
|
21
|
+
#
|
|
22
|
+
# ==== Parameters
|
|
23
|
+
#
|
|
24
|
+
# +clauses+ | Hash of attributes with appended predicates to search, sort and include.
|
|
25
|
+
#
|
|
26
|
+
# ===== Valid Clauses
|
|
27
|
+
#
|
|
28
|
+
# See {API documentation}[http://api-docs.evident.io?ruby#sub-organization-attributes] for valid arguments
|
|
29
|
+
#
|
|
30
|
+
# :call-seq:
|
|
31
|
+
# where(clauses = {})
|
|
32
|
+
|
|
19
33
|
##
|
|
20
34
|
# :singleton-method: find
|
|
21
35
|
# Find a SubOrganization by id
|
|
@@ -24,8 +38,18 @@ module ESP
|
|
|
24
38
|
#
|
|
25
39
|
# +id+ | Required | The ID of the sub organization to retrieve
|
|
26
40
|
#
|
|
41
|
+
# +options+ | Optional | A hash of options
|
|
42
|
+
#
|
|
43
|
+
# ===== Valid Options
|
|
44
|
+
#
|
|
45
|
+
# +include+ | The list of associated objects to return on the initial request.
|
|
46
|
+
#
|
|
47
|
+
# ===== Valid Includable Associations
|
|
48
|
+
#
|
|
49
|
+
# See {API documentation}[http://api-docs.evident.io?ruby#sub-organization-attributes] for valid arguments
|
|
50
|
+
#
|
|
27
51
|
# :call-seq:
|
|
28
|
-
# find(id)
|
|
52
|
+
# find(id, options = {})
|
|
29
53
|
|
|
30
54
|
# :singleton-method: all
|
|
31
55
|
# Return a paginated SubOrganization list
|
|
@@ -41,7 +65,7 @@ module ESP
|
|
|
41
65
|
#
|
|
42
66
|
# ===== Valid Attributes
|
|
43
67
|
#
|
|
44
|
-
#
|
|
68
|
+
# See {API documentation}[http://api-docs.evident.io?ruby#sub-organization-create] for valid arguments
|
|
45
69
|
#
|
|
46
70
|
# ==== Example
|
|
47
71
|
#
|
|
@@ -56,7 +80,7 @@ module ESP
|
|
|
56
80
|
#
|
|
57
81
|
# ===== Valid Attributes
|
|
58
82
|
#
|
|
59
|
-
#
|
|
83
|
+
# See {API documentation}[http://api-docs.evident.io?ruby#sub-organization-create] for valid arguments
|
|
60
84
|
#
|
|
61
85
|
# ==== Example
|
|
62
86
|
#
|