esp_sdk 1.1.0 → 2.0.0.rc1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +0 -2
- data/.rubocop.yml +53 -6
- data/.ruby-version +1 -1
- data/.travis.yml +8 -2
- data/Gemfile.lock +171 -0
- data/Guardfile +47 -0
- data/README.md +230 -5
- data/Rakefile +14 -1
- data/assets/logo.png +0 -0
- data/bin/esp_console +71 -0
- data/esp_sdk.gemspec +27 -18
- data/lib/esp/exceptions.rb +3 -0
- data/lib/esp/extensions/active_resource/formats/json_api_format.rb +105 -0
- data/lib/esp/extensions/active_resource/paginated_collection.rb +198 -0
- data/lib/esp/extensions/active_resource/validations.rb +45 -0
- data/lib/esp/resources/alert.rb +135 -0
- data/lib/esp/resources/cloud_trail_event.rb +45 -0
- data/lib/esp/resources/concerns/stat_totals.rb +79 -0
- data/lib/esp/resources/contact_request.rb +42 -0
- data/lib/esp/resources/custom_signature.rb +224 -0
- data/lib/esp/resources/dashboard.rb +31 -0
- data/lib/esp/resources/external_account.rb +89 -0
- data/lib/esp/resources/organization.rb +61 -0
- data/lib/esp/resources/region.rb +46 -0
- data/lib/esp/resources/report.rb +100 -0
- data/lib/esp/resources/resource.rb +66 -0
- data/lib/esp/resources/service.rb +31 -0
- data/lib/esp/resources/signature.rb +106 -0
- data/lib/esp/resources/stat.rb +124 -0
- data/lib/esp/resources/stat_custom_signature.rb +121 -0
- data/lib/esp/resources/stat_region.rb +121 -0
- data/lib/esp/resources/stat_service.rb +121 -0
- data/lib/esp/resources/stat_signature.rb +121 -0
- data/lib/esp/resources/sub_organization.rb +69 -0
- data/lib/esp/resources/suppression/region.rb +99 -0
- data/lib/esp/resources/suppression/signature.rb +107 -0
- data/lib/esp/resources/suppression/unique_identifier.rb +60 -0
- data/lib/esp/resources/suppression.rb +86 -0
- data/lib/esp/resources/tag.rb +45 -0
- data/lib/esp/resources/team.rb +79 -0
- data/lib/esp/resources/user.rb +46 -0
- data/lib/esp/version.rb +3 -0
- data/lib/esp.rb +95 -0
- data/lib/esp_sdk.rb +9 -45
- data/lib/tasks/rubocop.rake +2 -0
- data/lib/tasks/testing.rake +3 -0
- data/rdoc/ActiveResource/Formats.html +176 -0
- data/rdoc/ActiveResource/PaginatedCollection.html +910 -0
- data/rdoc/ActiveResource.html +180 -0
- data/rdoc/ESP/Alert.html +771 -0
- data/rdoc/ESP/CloudTrailEvent.html +375 -0
- data/rdoc/ESP/ContactRequest.html +366 -0
- data/rdoc/ESP/CustomSignature.html +746 -0
- data/rdoc/ESP/Dashboard.html +355 -0
- data/rdoc/ESP/ExternalAccount.html +565 -0
- data/rdoc/ESP/Organization.html +590 -0
- data/rdoc/ESP/Region.html +399 -0
- data/rdoc/ESP/Report.html +622 -0
- data/rdoc/ESP/Service.html +380 -0
- data/rdoc/ESP/Signature.html +555 -0
- data/rdoc/ESP/Stat.html +1778 -0
- data/rdoc/ESP/StatCustomSignature.html +1599 -0
- data/rdoc/ESP/StatRegion.html +1598 -0
- data/rdoc/ESP/StatService.html +1598 -0
- data/rdoc/ESP/StatSignature.html +1598 -0
- data/rdoc/ESP/SubOrganization.html +540 -0
- data/rdoc/ESP/Suppression/Region.html +454 -0
- data/rdoc/ESP/Suppression/Signature.html +470 -0
- data/rdoc/ESP/Suppression/UniqueIdentifier.html +417 -0
- data/rdoc/ESP/Suppression.html +649 -0
- data/rdoc/ESP/Tag.html +371 -0
- data/rdoc/ESP/Team.html +584 -0
- data/rdoc/ESP/User.html +483 -0
- data/rdoc/ESP.html +546 -0
- data/rdoc/README_md.html +501 -0
- data/rdoc/created.rid +30 -0
- 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 +134 -0
- data/rdoc/js/darkfish.js +155 -0
- data/rdoc/js/jquery.js +4 -0
- data/rdoc/js/navigation.js +142 -0
- data/rdoc/js/search.js +94 -0
- data/rdoc/js/search_index.js +1 -0
- data/rdoc/js/searcher.js +228 -0
- data/rdoc/rdoc.css +595 -0
- data/rdoc/table_of_contents.html +927 -0
- data/test/esp/extensions/active_resource/formats/json_api_format_test.rb +109 -0
- data/test/esp/extensions/active_resource/paginated_collection_test.rb +435 -0
- data/test/esp/extensions/active_resource/validations_test.rb +59 -0
- data/test/esp/resources/alert_test.rb +263 -0
- data/test/esp/resources/cloud_trail_event_test.rb +98 -0
- data/test/esp/resources/contact_request_test.rb +73 -0
- data/test/esp/resources/custom_signature_test.rb +241 -0
- data/test/esp/resources/dashboard_test.rb +71 -0
- data/test/esp/resources/external_account_test.rb +125 -0
- data/test/esp/resources/organization_test.rb +175 -0
- data/test/esp/resources/region_test.rb +84 -0
- data/test/esp/resources/report_test.rb +180 -0
- data/test/esp/resources/resource_test.rb +183 -0
- data/test/esp/resources/service_test.rb +64 -0
- data/test/esp/resources/signature_test.rb +177 -0
- data/test/esp/resources/stat_custom_signature_test.rb +115 -0
- data/test/esp/resources/stat_region_test.rb +114 -0
- data/test/esp/resources/stat_service_test.rb +114 -0
- data/test/esp/resources/stat_signature_test.rb +115 -0
- data/test/esp/resources/stat_test.rb +159 -0
- data/test/esp/resources/sub_organization_test.rb +127 -0
- data/test/esp/resources/suppression/region_test.rb +115 -0
- data/test/esp/resources/suppression/signature_test.rb +117 -0
- data/test/esp/resources/suppression/unique_identifier_test.rb +79 -0
- data/test/esp/resources/suppression_test.rb +226 -0
- data/test/esp/resources/tag_test.rb +98 -0
- data/test/esp/resources/team_test.rb +140 -0
- data/test/esp/resources/user_test.rb +113 -0
- data/test/esp_test.rb +139 -0
- data/test/factories/alerts.rb +234 -0
- data/test/factories/cloud_trail_events.rb +16 -0
- data/test/factories/contact_requests.rb +14 -0
- data/test/factories/custom_signatures.rb +30 -0
- data/test/factories/dashboards.rb +91 -0
- data/test/factories/errors.rb +24 -0
- data/test/factories/external_accounts.rb +44 -0
- data/test/factories/organizations.rb +48 -0
- data/test/factories/regions.rb +9 -0
- data/test/factories/reports.rb +56 -0
- data/test/factories/services.rb +12 -0
- data/test/factories/signatures.rb +28 -0
- data/test/factories/stat_custom_signatures.rb +97 -0
- data/test/factories/stat_regions.rb +97 -0
- data/test/factories/stat_services.rb +97 -0
- data/test/factories/stat_signautures.rb +97 -0
- data/test/factories/stats.rb +129 -0
- data/test/factories/sub_organizations.rb +34 -0
- data/test/factories/suppression/regions.rb +90 -0
- data/test/factories/suppression/signatures.rb +117 -0
- data/test/factories/suppression/unique_identifiers.rb +111 -0
- data/test/factories/suppressions.rb +71 -0
- data/test/factories/tags.rb +12 -0
- data/test/factories/teams.rb +32 -0
- data/test/factories/users.rb +54 -0
- data/test/json_strategy.rb +25 -0
- data/test/test_helper.rb +44 -5
- metadata +387 -119
- data/bin/esp_repl +0 -60
- data/lib/esp_sdk/api.rb +0 -33
- data/lib/esp_sdk/client.rb +0 -62
- data/lib/esp_sdk/configure.rb +0 -40
- data/lib/esp_sdk/end_points/base.rb +0 -102
- data/lib/esp_sdk/end_points/contact_requests.rb +0 -6
- data/lib/esp_sdk/end_points/custom_signatures.rb +0 -41
- data/lib/esp_sdk/end_points/dashboard.rb +0 -35
- data/lib/esp_sdk/end_points/external_accounts.rb +0 -9
- data/lib/esp_sdk/end_points/organizations.rb +0 -6
- data/lib/esp_sdk/end_points/reports.rb +0 -6
- data/lib/esp_sdk/end_points/services.rb +0 -6
- data/lib/esp_sdk/end_points/signatures.rb +0 -39
- data/lib/esp_sdk/end_points/sub_organizations.rb +0 -6
- data/lib/esp_sdk/end_points/teams.rb +0 -6
- data/lib/esp_sdk/end_points/users.rb +0 -6
- data/lib/esp_sdk/exceptions.rb +0 -8
- data/lib/esp_sdk/extensions/rest_client/request.rb +0 -9
- data/lib/esp_sdk/repl.rb +0 -61
- data/lib/esp_sdk/version.rb +0 -3
- data/test/esp_sdk/api_test.rb +0 -36
- data/test/esp_sdk/client_test.rb +0 -129
- data/test/esp_sdk/configure_test.rb +0 -65
- data/test/esp_sdk/end_points/.keep +0 -0
- data/test/esp_sdk/end_points/base_test.rb +0 -230
- data/test/esp_sdk/end_points/custom_signatures_test.rb +0 -90
- data/test/esp_sdk/end_points/dashboard_test.rb +0 -55
- data/test/esp_sdk/end_points/external_accounts_test.rb +0 -20
- data/test/esp_sdk/end_points/signatures_test.rb +0 -83
- data/test/esp_sdk/exceptions_test.rb +0 -41
- data/test/esp_sdk_test.rb +0 -70
@@ -0,0 +1,121 @@
|
|
1
|
+
module ESP
|
2
|
+
class StatSignature < ESP::Resource
|
3
|
+
include ESP::StatTotals
|
4
|
+
|
5
|
+
# The signature these stats are for.
|
6
|
+
belongs_to :signature, class_name: 'ESP::Signature'
|
7
|
+
|
8
|
+
# Returns a paginated collection of signature stats for the given stat_id
|
9
|
+
# Convenience method to use instead of ::find since a stat_id is required to return signature stats.
|
10
|
+
#
|
11
|
+
# ==== Parameter
|
12
|
+
#
|
13
|
+
# +stat_id+ | Required | The ID of the stat to list signature stats for
|
14
|
+
#
|
15
|
+
# ==== Example
|
16
|
+
# stats = ESP::StatSignature.for_stat(1194)
|
17
|
+
def self.for_stat(stat_id = nil)
|
18
|
+
fail ArgumentError, "You must supply a stat id." unless stat_id.present?
|
19
|
+
from = "#{prefix}stats/#{stat_id}/signatures.json"
|
20
|
+
find(:all, from: from)
|
21
|
+
end
|
22
|
+
|
23
|
+
# Find a StatRegion by id
|
24
|
+
#
|
25
|
+
# ==== Parameter
|
26
|
+
#
|
27
|
+
# +id+ | Required | The ID of the signature stat to retrieve
|
28
|
+
#
|
29
|
+
# :call-seq:
|
30
|
+
# find(id)
|
31
|
+
def self.find(*arguments)
|
32
|
+
scope = arguments.slice!(0)
|
33
|
+
options = (arguments.slice!(0) || {}).with_indifferent_access
|
34
|
+
return super(scope, options) if scope.is_a?(Numeric) || options[:from].present?
|
35
|
+
params = options.fetch(:params, {}).with_indifferent_access
|
36
|
+
stat_id = params.delete(:stat_id)
|
37
|
+
for_stat(stat_id)
|
38
|
+
end
|
39
|
+
|
40
|
+
# :singleton-method: create
|
41
|
+
# Not Implemented. You cannot create a Stat.
|
42
|
+
|
43
|
+
# :method: save
|
44
|
+
# Not Implemented. You cannot create or update a Stat.
|
45
|
+
|
46
|
+
# :method: destroy
|
47
|
+
# Not Implemented. You cannot delete a Stat.
|
48
|
+
|
49
|
+
# :section: 'total' rollup methods
|
50
|
+
|
51
|
+
# :method: total
|
52
|
+
|
53
|
+
# :method: total_pass
|
54
|
+
|
55
|
+
# :method: total_fail
|
56
|
+
|
57
|
+
# :method: total_warn
|
58
|
+
|
59
|
+
# :method: total_error
|
60
|
+
|
61
|
+
# :method: total_info
|
62
|
+
|
63
|
+
# :method: total_new_1h_pass
|
64
|
+
|
65
|
+
# :method: total_new_1h_fail
|
66
|
+
|
67
|
+
# :method: total_new_1h_warn
|
68
|
+
|
69
|
+
# :method: total_new_1h_error
|
70
|
+
|
71
|
+
# :method: total_new_1h_info
|
72
|
+
|
73
|
+
# :method: total_new_1d_pass
|
74
|
+
|
75
|
+
# :method: total_new_1d_fail
|
76
|
+
|
77
|
+
# :method: total_new_1d_warn
|
78
|
+
|
79
|
+
# :method: total_new_1d_error
|
80
|
+
|
81
|
+
# :method: total_new_1d_info
|
82
|
+
|
83
|
+
# :method: total_new_1w_pass
|
84
|
+
|
85
|
+
# :method: total_new_1w_fail
|
86
|
+
|
87
|
+
# :method: total_new_1w_error
|
88
|
+
|
89
|
+
# :method: total_new_1w_info
|
90
|
+
|
91
|
+
# :method: total_new_1w_warn
|
92
|
+
|
93
|
+
# :method: total_old_fail
|
94
|
+
|
95
|
+
# :method: total_old_pass
|
96
|
+
|
97
|
+
# :method: total_old_warn
|
98
|
+
|
99
|
+
# :method: total_old_error
|
100
|
+
|
101
|
+
# :method: total_old_info
|
102
|
+
|
103
|
+
# :method: total_suppressed
|
104
|
+
|
105
|
+
# :method: total_suppressed_pass
|
106
|
+
|
107
|
+
# :method: total_suppressed_fail
|
108
|
+
|
109
|
+
# :method: total_suppressed_warn
|
110
|
+
|
111
|
+
# :method: total_suppressed_error
|
112
|
+
|
113
|
+
# :method: total_new_1h
|
114
|
+
|
115
|
+
# :method: total_new_1d
|
116
|
+
|
117
|
+
# :method: total_new_1w
|
118
|
+
|
119
|
+
# :method: total_old
|
120
|
+
end
|
121
|
+
end
|
@@ -0,0 +1,69 @@
|
|
1
|
+
module ESP
|
2
|
+
class SubOrganization < ESP::Resource
|
3
|
+
##
|
4
|
+
# The organization this sub organization belongs to.
|
5
|
+
belongs_to :organization, class_name: 'ESP::Organization'
|
6
|
+
|
7
|
+
##
|
8
|
+
# The collection of teams that belong to the sub organization.
|
9
|
+
has_many :teams, class_name: 'ESP::Team'
|
10
|
+
|
11
|
+
##
|
12
|
+
# The collection of external_accounts that belong to the sub organization.
|
13
|
+
has_many :external_accounts, class_name: 'ESP::ExternalAccount'
|
14
|
+
|
15
|
+
##
|
16
|
+
# The collection of reports that belong to the sub organization.
|
17
|
+
has_many :reports, class_name: 'ESP::Report'
|
18
|
+
|
19
|
+
##
|
20
|
+
# :singleton-method: find
|
21
|
+
# Find a SubOrganization by id
|
22
|
+
#
|
23
|
+
# ==== Parameter
|
24
|
+
#
|
25
|
+
# +id+ | Required | The ID of the sub organization to retrieve
|
26
|
+
#
|
27
|
+
# :call-seq:
|
28
|
+
# find(id)
|
29
|
+
|
30
|
+
# :singleton-method: all
|
31
|
+
# Return a paginated SubOrganization list
|
32
|
+
|
33
|
+
# :singleton-method: create
|
34
|
+
# Create a SubOrganization.
|
35
|
+
# :call-seq:
|
36
|
+
# create(attributes={})
|
37
|
+
#
|
38
|
+
# ==== Parameters
|
39
|
+
#
|
40
|
+
# +attributes+ | Required | A hash of run arguments
|
41
|
+
#
|
42
|
+
# ===== Valid Attributes
|
43
|
+
#
|
44
|
+
# +name+ | Required | The name of the sub organization
|
45
|
+
#
|
46
|
+
# ==== Example
|
47
|
+
#
|
48
|
+
# sub_organization = ESP::SubOrganization.create(name: "Sub Organization Name")
|
49
|
+
|
50
|
+
# :method: save
|
51
|
+
# Create and update a SubOrganization.
|
52
|
+
#
|
53
|
+
# ==== Parameters
|
54
|
+
#
|
55
|
+
# +attributes+ | Required | A hash of run arguments
|
56
|
+
#
|
57
|
+
# ===== Valid Attributes
|
58
|
+
#
|
59
|
+
# +name+ | Required | The name of the sub organization
|
60
|
+
#
|
61
|
+
# ==== Example
|
62
|
+
#
|
63
|
+
# sub_organization = ESP::SubOrganization.new(name: "Sub Organization Name")
|
64
|
+
# sub_organization.save
|
65
|
+
|
66
|
+
# :method: destroy
|
67
|
+
# Delete a SubOrganization.
|
68
|
+
end
|
69
|
+
end
|
@@ -0,0 +1,99 @@
|
|
1
|
+
module ESP
|
2
|
+
class Suppression
|
3
|
+
class Region < ESP::Resource
|
4
|
+
self.prefix += "suppressions/"
|
5
|
+
|
6
|
+
# Not Implemented. You cannot search for Suppression::Region.
|
7
|
+
#
|
8
|
+
# Regular ARELlike methods are disabled. Use the ESP::Suppression object to search suppressions.
|
9
|
+
def self.find(*)
|
10
|
+
fail ESP::NotImplementedError, 'Regular ARELlike methods are disabled. Use the ESP::Suppression object to search suppressions'
|
11
|
+
end
|
12
|
+
|
13
|
+
# Not Implemented. You cannot update a Suppression::Region.
|
14
|
+
def update
|
15
|
+
fail ESP::NotImplementedError
|
16
|
+
end
|
17
|
+
|
18
|
+
# Not Implemented. You cannot destroy a Suppression::Region.
|
19
|
+
def destroy
|
20
|
+
fail ESP::NotImplementedError
|
21
|
+
end
|
22
|
+
|
23
|
+
# This instance method is called by the #save method when new? is true.
|
24
|
+
def create # :nodoc:
|
25
|
+
original_prefix = self.class.prefix
|
26
|
+
if attributes[:alert_id]
|
27
|
+
self.class.prefix += "alert/:alert_id/"
|
28
|
+
prefix_options[:alert_id] = alert_id
|
29
|
+
end
|
30
|
+
super
|
31
|
+
ensure
|
32
|
+
self.class.prefix = original_prefix
|
33
|
+
end
|
34
|
+
|
35
|
+
# :singleton-method: create
|
36
|
+
# Create a suppression for a region.
|
37
|
+
#
|
38
|
+
# If you pass an +alert_id+, include the +reason+ and all other params will be ignored, and the suppression will be created based on that alert.
|
39
|
+
#
|
40
|
+
# :call-seq:
|
41
|
+
# create(attributes={})
|
42
|
+
#
|
43
|
+
# ==== Parameter
|
44
|
+
#
|
45
|
+
# +attributes+ | Required | A hash of region suppression attributes
|
46
|
+
#
|
47
|
+
# ===== Valid Attributes When Not Creating for Alert
|
48
|
+
#
|
49
|
+
# +regions+ | Required | An array of region names to suppress.
|
50
|
+
#
|
51
|
+
# +external_account_ids+ | Required | An Array of the external accounts identified by +external_account_id+ to suppress the signature or custom signature on.
|
52
|
+
#
|
53
|
+
# +resource+ | Not Required | The resource string this suppression will suppress alerts for.
|
54
|
+
#
|
55
|
+
# +reason+ | Required | The reason for creating the suppression.
|
56
|
+
#
|
57
|
+
# ==== Example
|
58
|
+
# create(regions: ['us_east_1'], external_account_ids: [5], reason: 'My very good reason for creating this suppression')
|
59
|
+
#
|
60
|
+
# ===== Valid Attributes When Creating for Alert
|
61
|
+
#
|
62
|
+
# +alert_id+ | Required | The id for the alert you want to create a suppression for.
|
63
|
+
#
|
64
|
+
# +reason+ | Required | The reason for creating the suppression.
|
65
|
+
#
|
66
|
+
# ==== Example
|
67
|
+
# create(alert_id: 5, reason: 'My very good reason for creating this suppression')
|
68
|
+
|
69
|
+
# :method: save
|
70
|
+
# Create a suppression for a region.
|
71
|
+
#
|
72
|
+
# If you set an +alert_id+, set the +reason+ and all other params will be ignored, and the suppression will be created based on that alert.
|
73
|
+
#
|
74
|
+
# ===== Valid Attributes When Not Creating for Alert
|
75
|
+
#
|
76
|
+
# +regions+ | Required | An array of region names to suppress.
|
77
|
+
#
|
78
|
+
# +external_account_ids+ | Required | An Array of the external accounts identified by +external_account_id+ to suppress the signature or custom signature on.
|
79
|
+
#
|
80
|
+
# +resource+ | Not Required | The resource string this suppression will suppress alerts for.
|
81
|
+
#
|
82
|
+
# +reason+ | Required | The reason for creating the suppression.
|
83
|
+
#
|
84
|
+
# ==== Example
|
85
|
+
# suppression = new(regions: ['us_east_1'], external_account_ids: [5], reason: 'My very good reason for creating this suppression')
|
86
|
+
# suppression.save
|
87
|
+
#
|
88
|
+
# ===== Valid Attributes When Creating for Alert
|
89
|
+
#
|
90
|
+
# +alert_id+ | Required | The id for the alert you want to create a suppression for.
|
91
|
+
#
|
92
|
+
# +reason+ | Required | The reason for creating the suppression.
|
93
|
+
#
|
94
|
+
# ==== Example
|
95
|
+
# suppression = new(alert_id: 5, reason: 'My very good reason for creating this suppression')
|
96
|
+
# suppression.save
|
97
|
+
end
|
98
|
+
end
|
99
|
+
end
|
@@ -0,0 +1,107 @@
|
|
1
|
+
module ESP
|
2
|
+
class Suppression
|
3
|
+
class Signature < ESP::Resource
|
4
|
+
self.prefix += "suppressions/"
|
5
|
+
|
6
|
+
# Not Implemented. You cannot search for Suppression::Signature.
|
7
|
+
#
|
8
|
+
# Regular ARELlike methods are disabled. Use the ESP::Suppression object to search suppressions.
|
9
|
+
def self.find(*)
|
10
|
+
fail ESP::NotImplementedError, 'Regular ARELlike methods are disabled. Use the ESP::Suppression object to search suppressions'
|
11
|
+
end
|
12
|
+
|
13
|
+
# Not Implemented. You cannot update a Suppression::Signature.
|
14
|
+
def update
|
15
|
+
fail ESP::NotImplementedError
|
16
|
+
end
|
17
|
+
|
18
|
+
# Not Implemented. You cannot destroy a Suppression::Signature.
|
19
|
+
def destroy
|
20
|
+
fail ESP::NotImplementedError
|
21
|
+
end
|
22
|
+
|
23
|
+
# This instance method is called by the #save method when new? is true.
|
24
|
+
def create # :nodoc:
|
25
|
+
original_prefix = self.class.prefix
|
26
|
+
if attributes[:alert_id]
|
27
|
+
self.class.prefix += "alert/:alert_id/"
|
28
|
+
prefix_options[:alert_id] = alert_id
|
29
|
+
end
|
30
|
+
super
|
31
|
+
ensure
|
32
|
+
self.class.prefix = original_prefix
|
33
|
+
end
|
34
|
+
|
35
|
+
# :singleton-method: create
|
36
|
+
# Create a suppression for a signature or custom signature.
|
37
|
+
#
|
38
|
+
# If you pass an +alert_id+, include the +reason+ and all other params will be ignored, and the suppression will be created based on that alert.
|
39
|
+
#
|
40
|
+
# :call-seq:
|
41
|
+
# create(attributes={})
|
42
|
+
#
|
43
|
+
# ==== Parameter
|
44
|
+
#
|
45
|
+
# +attributes+ | Required | A hash of signature suppression attributes
|
46
|
+
#
|
47
|
+
# ===== Valid Attributes When Not Creating for Alert
|
48
|
+
#
|
49
|
+
# +signature_ids+ | Conditionally Required | An array of signatures identified by +signature_id+ to suppress. Required if +custom_signature_ids+ is blank.
|
50
|
+
#
|
51
|
+
# +custom_signature_ids+ | Conditionally Required | An array of custom signatures identified by +custom_signature_id+ to suppress. Required if +signature_ids+ is blank.
|
52
|
+
#
|
53
|
+
# +regions+ | Required | An array of region names to suppress.
|
54
|
+
#
|
55
|
+
# +external_account_ids+ | Required | An Array of the external accounts identified by +external_account_id+ to suppress the signature or custom signature on.
|
56
|
+
#
|
57
|
+
# +resource+ | Not Required | The resource string this suppression will suppress alerts for.
|
58
|
+
#
|
59
|
+
# +reason+ | Required | The reason for creating the suppression.
|
60
|
+
#
|
61
|
+
# ==== Example
|
62
|
+
# create(signature_ids: [4, 2], regions: ['us_east_1'], external_account_ids: [5], reason: 'My very good reason for creating this suppression')
|
63
|
+
#
|
64
|
+
# ===== Valid Attributes When Creating for Alert
|
65
|
+
#
|
66
|
+
# +alert_id+ | Required | The id for the alert you want to create a suppression for.
|
67
|
+
#
|
68
|
+
# +reason+ | Required | The reason for creating the suppression.
|
69
|
+
#
|
70
|
+
# ==== Example
|
71
|
+
# create(alert_id: 5, reason: 'My very good reason for creating this suppression')
|
72
|
+
|
73
|
+
# :method: save
|
74
|
+
# Create a suppression for a signature or custom signature.
|
75
|
+
#
|
76
|
+
# If you set an +alert_id+, set the +reason+ and all other params will be ignored, and the suppression will be created based on that alert.
|
77
|
+
#
|
78
|
+
# ===== Valid Attributes When Not Creating for Alert
|
79
|
+
#
|
80
|
+
# +signature_ids+ | Conditionally Required | An array of signatures identified by +signature_id+ to suppress. Required if +custom_signature_ids+ is blank.
|
81
|
+
#
|
82
|
+
# +custom_signature_ids+ | Conditionally Required | An array of custom signatures identified by +custom_signature_id+ to suppress. Required if +signature_ids+ is blank.
|
83
|
+
#
|
84
|
+
# +regions+ | Required | An array of region names to suppress.
|
85
|
+
#
|
86
|
+
# +external_account_ids+ | Required | An Array of the external accounts identified by +external_account_id+ to suppress the signature or custom signature on.
|
87
|
+
#
|
88
|
+
# +resource+ | Not Required | The resource string this suppression will suppress alerts for.
|
89
|
+
#
|
90
|
+
# +reason+ | Required | The reason for creating the suppression.
|
91
|
+
#
|
92
|
+
# ==== Example
|
93
|
+
# suppression = new(signature_ids: [4, 2], regions: ['us_east_1'], external_account_ids: [5], reason: 'My very good reason for creating this suppression')
|
94
|
+
# suppression.save
|
95
|
+
#
|
96
|
+
# ===== Valid Attributes When Creating for Alert
|
97
|
+
#
|
98
|
+
# +alert_id+ | Required | The id for the alert you want to create a suppression for.
|
99
|
+
#
|
100
|
+
# +reason+ | Required | The reason for creating the suppression.
|
101
|
+
#
|
102
|
+
# ==== Example
|
103
|
+
# suppression = new(alert_id: 5, reason: 'My very good reason for creating this suppression')
|
104
|
+
# suppression.save
|
105
|
+
end
|
106
|
+
end
|
107
|
+
end
|
@@ -0,0 +1,60 @@
|
|
1
|
+
module ESP
|
2
|
+
class Suppression
|
3
|
+
class UniqueIdentifier < ESP::Resource
|
4
|
+
self.prefix += "suppressions/alert/:alert_id/"
|
5
|
+
|
6
|
+
# Not Implemented. You cannot search for Suppression::UniqueIdentifier.
|
7
|
+
#
|
8
|
+
# Regular ARELlike methods are disabled. Use the ESP::Suppression object to search suppressions.
|
9
|
+
def self.find(*)
|
10
|
+
fail ESP::NotImplementedError, 'Regular ARELlike methods are disabled. Use the ESP::Suppression object to search suppressions'
|
11
|
+
end
|
12
|
+
|
13
|
+
# Not Implemented. You cannot update a Suppression::UniqueIdentifier.
|
14
|
+
def update
|
15
|
+
fail ESP::NotImplementedError
|
16
|
+
end
|
17
|
+
|
18
|
+
# Not Implemented. You cannot destroy a Suppression::UniqueIdentifier.
|
19
|
+
def destroy
|
20
|
+
fail ESP::NotImplementedError
|
21
|
+
end
|
22
|
+
|
23
|
+
# :singleton-method: create
|
24
|
+
# Create a suppression for a unique identifier.
|
25
|
+
#
|
26
|
+
# Pass an +alert_id+, the suppression will be created based on that alert.
|
27
|
+
#
|
28
|
+
# :call-seq:
|
29
|
+
# create(attributes={})
|
30
|
+
#
|
31
|
+
# ==== Parameter
|
32
|
+
#
|
33
|
+
# +attributes+ | Required | A hash of unique identifier suppression attributes
|
34
|
+
#
|
35
|
+
# ==== Attributes
|
36
|
+
#
|
37
|
+
# +alert_id+ | Required | The id for the alert you want to create a suppression for.
|
38
|
+
#
|
39
|
+
# +reason+ | Required | The reason for creating the suppression.
|
40
|
+
#
|
41
|
+
# ==== Example
|
42
|
+
# create(alert_id: 5, reason: 'My very good reason for creating this suppression')
|
43
|
+
|
44
|
+
# :method: save
|
45
|
+
# Create a suppression for a unique identifier.
|
46
|
+
#
|
47
|
+
# Set an +alert_id+, the suppression will be created based on that alert.
|
48
|
+
#
|
49
|
+
# ==== Attributes
|
50
|
+
#
|
51
|
+
# +alert_id+ | Required | The id for the alert you want to create a suppression for.
|
52
|
+
#
|
53
|
+
# +reason+ | Required | The reason for creating the suppression.
|
54
|
+
#
|
55
|
+
# ==== Example
|
56
|
+
# suppression = new(alert_id: 5, reason: 'My very good reason for creating this suppression')
|
57
|
+
# suppression.save
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
@@ -0,0 +1,86 @@
|
|
1
|
+
module ESP
|
2
|
+
class Suppression < ESP::Resource
|
3
|
+
##
|
4
|
+
# The organization this sub organization belongs to.
|
5
|
+
belongs_to :organization, class_name: 'ESP::Organization'
|
6
|
+
|
7
|
+
##
|
8
|
+
# The user who created the suppression.
|
9
|
+
belongs_to :created_by, class_name: 'ESP::User'
|
10
|
+
|
11
|
+
##
|
12
|
+
# The regions affected by this suppression.
|
13
|
+
has_many :regions, class_name: 'ESP::Region'
|
14
|
+
|
15
|
+
##
|
16
|
+
# The external accounts affected by this suppression.
|
17
|
+
has_many :external_accounts, class_name: 'ESP::ExternalAccount'
|
18
|
+
|
19
|
+
##
|
20
|
+
# The signatures being suppressed.
|
21
|
+
def signatures
|
22
|
+
return [] unless respond_to? :signature_ids
|
23
|
+
ESP::Signature.find(:all, params: { id: signature_ids })
|
24
|
+
end
|
25
|
+
|
26
|
+
##
|
27
|
+
# The custom signatures being suppressed.
|
28
|
+
def custom_signatures
|
29
|
+
return [] unless respond_to? :custom_signature_ids
|
30
|
+
ESP::CustomSignature.find(:all, params: { id: custom_signature_ids })
|
31
|
+
end
|
32
|
+
|
33
|
+
# Overriden so the correct param is sent on the has_many relationships. API needs this one to be plural.
|
34
|
+
def self.element_name # :nodoc:
|
35
|
+
'suppressions'
|
36
|
+
end
|
37
|
+
|
38
|
+
# Not Implemented. You cannot create or update a Suppression.
|
39
|
+
def save
|
40
|
+
fail ESP::NotImplementedError
|
41
|
+
end
|
42
|
+
|
43
|
+
# Not Implemented. You cannot destroy a Suppression.
|
44
|
+
def destroy
|
45
|
+
fail ESP::NotImplementedError
|
46
|
+
end
|
47
|
+
|
48
|
+
# Deactivate the current suppression instance.
|
49
|
+
# The current object will be updated with the new status if successful.
|
50
|
+
# Throws an error if not successful.
|
51
|
+
# === Once deactivated the suppression cannot be reactivated.
|
52
|
+
def deactivate!
|
53
|
+
return self if deactivate
|
54
|
+
self.message = errors.full_messages.join(' ')
|
55
|
+
fail(ActiveResource::ResourceInvalid.new(self)) # rubocop:disable Style/RaiseArgs
|
56
|
+
end
|
57
|
+
|
58
|
+
# Deactivate the current suppression instance.
|
59
|
+
# The current object will be updated with the new status if successful.
|
60
|
+
# If not successful, populates its errors object.
|
61
|
+
# === Once deactivated the suppression cannot be reactivated.
|
62
|
+
def deactivate
|
63
|
+
patch(:deactivate).tap do |response|
|
64
|
+
load_attributes_from_response(response)
|
65
|
+
end
|
66
|
+
rescue ActiveResource::BadRequest, ActiveResource::ResourceInvalid, ActiveResource::UnauthorizedAccess => error
|
67
|
+
load_remote_errors(error, true)
|
68
|
+
self.code = error.response.code
|
69
|
+
false
|
70
|
+
end
|
71
|
+
|
72
|
+
##
|
73
|
+
# :singleton-method: find
|
74
|
+
# Find a Suppression by id
|
75
|
+
#
|
76
|
+
# ==== Parameter
|
77
|
+
#
|
78
|
+
# +id+ | Required | The ID of the suppression to retrieve
|
79
|
+
#
|
80
|
+
# :call-seq:
|
81
|
+
# find(id)
|
82
|
+
|
83
|
+
# :singleton-method: all
|
84
|
+
# Return a paginated Suppression list
|
85
|
+
end
|
86
|
+
end
|
@@ -0,0 +1,45 @@
|
|
1
|
+
module ESP
|
2
|
+
class Tag < ESP::Resource
|
3
|
+
# Not Implemented. You cannot create or update a Tag.
|
4
|
+
def save
|
5
|
+
fail ESP::NotImplementedError
|
6
|
+
end
|
7
|
+
|
8
|
+
# Not Implemented. You cannot destroy a Tag.
|
9
|
+
def destroy
|
10
|
+
fail ESP::NotImplementedError
|
11
|
+
end
|
12
|
+
|
13
|
+
# Returns a paginated collection of tags for the given alert_id
|
14
|
+
# Convenience method to use instead of ::find since an alert_id is required to return tags.
|
15
|
+
#
|
16
|
+
# ==== Parameter
|
17
|
+
#
|
18
|
+
# +alert_id+ | Required | The ID of the alert to list tags for
|
19
|
+
#
|
20
|
+
# ==== Example
|
21
|
+
# alerts = ESP::Tag.for_alert(1194)
|
22
|
+
def self.for_alert(alert_id = nil)
|
23
|
+
fail ArgumentError, "You must supply an alert id." unless alert_id.present?
|
24
|
+
from = "#{prefix}alerts/#{alert_id}/tags.json"
|
25
|
+
find(:all, from: from)
|
26
|
+
end
|
27
|
+
|
28
|
+
# Find a Tag by id
|
29
|
+
#
|
30
|
+
# ==== Parameter
|
31
|
+
#
|
32
|
+
# +id+ | Required | The ID of the tag to retrieve
|
33
|
+
#
|
34
|
+
# :call-seq:
|
35
|
+
# find(id)
|
36
|
+
def self.find(*arguments)
|
37
|
+
scope = arguments.slice!(0)
|
38
|
+
options = (arguments.slice!(0) || {}).with_indifferent_access
|
39
|
+
return super(scope, options) if scope.is_a?(Numeric) || options[:from].present?
|
40
|
+
params = options.fetch(:params, {}).with_indifferent_access
|
41
|
+
alert_id = params.delete(:alert_id)
|
42
|
+
for_alert(alert_id)
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
@@ -0,0 +1,79 @@
|
|
1
|
+
module ESP
|
2
|
+
class Team < ESP::Resource
|
3
|
+
##
|
4
|
+
# The organization this team belongs to.
|
5
|
+
belongs_to :organization, class_name: 'ESP::Organization'
|
6
|
+
|
7
|
+
##
|
8
|
+
# The sub organization this team belongs to.
|
9
|
+
belongs_to :sub_organization, class_name: 'ESP::SubOrganization'
|
10
|
+
|
11
|
+
##
|
12
|
+
# The collection of external_accounts that belong to the team.
|
13
|
+
has_many :external_accounts, class_name: 'ESP::ExternalAccount'
|
14
|
+
|
15
|
+
##
|
16
|
+
# The collection of reports that belong to the team.
|
17
|
+
has_many :reports, class_name: 'ESP::Report'
|
18
|
+
|
19
|
+
# Enqueue a report to be run for this team.
|
20
|
+
# Returns a Report object with a status of 'queued' and an id
|
21
|
+
# Periodically check the API
|
22
|
+
# ESP::Report.find(<id>)
|
23
|
+
# until status is 'complete'.
|
24
|
+
# If not successful, returns a Report object with the errors object populated.
|
25
|
+
def create_report
|
26
|
+
Report.create_for_team(id)
|
27
|
+
end
|
28
|
+
|
29
|
+
##
|
30
|
+
# :singleton-method: find
|
31
|
+
# Find a Team by id
|
32
|
+
#
|
33
|
+
# ==== Parameter
|
34
|
+
#
|
35
|
+
# +id+ | Required | The ID of the team to retrieve
|
36
|
+
#
|
37
|
+
# :call-seq:
|
38
|
+
# find(id)
|
39
|
+
|
40
|
+
# :singleton-method: all
|
41
|
+
# Return a paginated Team list
|
42
|
+
|
43
|
+
# :singleton-method: create
|
44
|
+
# Create a Team.
|
45
|
+
# :call-seq:
|
46
|
+
# create(attributes={})
|
47
|
+
#
|
48
|
+
# ==== Parameter
|
49
|
+
#
|
50
|
+
# +attributes+ | Required | A hash of team attributes
|
51
|
+
#
|
52
|
+
# ==== Valid Attributes
|
53
|
+
#
|
54
|
+
# +sub_organization_id+ | Required | The ID of the sub organization to attach this team to
|
55
|
+
#
|
56
|
+
# +name+ | Required | The name of the team
|
57
|
+
|
58
|
+
# :method: save
|
59
|
+
# Create and update a Team.
|
60
|
+
#
|
61
|
+
# ==== Valid Attributes when updating
|
62
|
+
#
|
63
|
+
# +name+ | Required | The new name of the team
|
64
|
+
#
|
65
|
+
# ==== Valid Attributes when creating
|
66
|
+
#
|
67
|
+
# +sub_organization_id+ | Required | The ID of the sub organization to attach this team to
|
68
|
+
#
|
69
|
+
# +name+ | Required | The name of the team
|
70
|
+
#
|
71
|
+
# ==== Example
|
72
|
+
#
|
73
|
+
# team = ESP::Team.new(name: "Team Name", sub_organization_id: 9)
|
74
|
+
# team.save
|
75
|
+
|
76
|
+
# :method: destroy
|
77
|
+
# Delete a Team.
|
78
|
+
end
|
79
|
+
end
|