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.
Files changed (199) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +0 -2
  3. data/.rubocop.yml +53 -6
  4. data/.ruby-version +1 -1
  5. data/.travis.yml +8 -2
  6. data/Gemfile.lock +171 -0
  7. data/Guardfile +47 -0
  8. data/README.md +230 -5
  9. data/Rakefile +14 -1
  10. data/assets/logo.png +0 -0
  11. data/bin/esp_console +71 -0
  12. data/esp_sdk.gemspec +27 -18
  13. data/lib/esp/exceptions.rb +3 -0
  14. data/lib/esp/extensions/active_resource/formats/json_api_format.rb +105 -0
  15. data/lib/esp/extensions/active_resource/paginated_collection.rb +198 -0
  16. data/lib/esp/extensions/active_resource/validations.rb +45 -0
  17. data/lib/esp/resources/alert.rb +135 -0
  18. data/lib/esp/resources/cloud_trail_event.rb +45 -0
  19. data/lib/esp/resources/concerns/stat_totals.rb +79 -0
  20. data/lib/esp/resources/contact_request.rb +42 -0
  21. data/lib/esp/resources/custom_signature.rb +224 -0
  22. data/lib/esp/resources/dashboard.rb +31 -0
  23. data/lib/esp/resources/external_account.rb +89 -0
  24. data/lib/esp/resources/organization.rb +61 -0
  25. data/lib/esp/resources/region.rb +46 -0
  26. data/lib/esp/resources/report.rb +100 -0
  27. data/lib/esp/resources/resource.rb +66 -0
  28. data/lib/esp/resources/service.rb +31 -0
  29. data/lib/esp/resources/signature.rb +106 -0
  30. data/lib/esp/resources/stat.rb +124 -0
  31. data/lib/esp/resources/stat_custom_signature.rb +121 -0
  32. data/lib/esp/resources/stat_region.rb +121 -0
  33. data/lib/esp/resources/stat_service.rb +121 -0
  34. data/lib/esp/resources/stat_signature.rb +121 -0
  35. data/lib/esp/resources/sub_organization.rb +69 -0
  36. data/lib/esp/resources/suppression/region.rb +99 -0
  37. data/lib/esp/resources/suppression/signature.rb +107 -0
  38. data/lib/esp/resources/suppression/unique_identifier.rb +60 -0
  39. data/lib/esp/resources/suppression.rb +86 -0
  40. data/lib/esp/resources/tag.rb +45 -0
  41. data/lib/esp/resources/team.rb +79 -0
  42. data/lib/esp/resources/user.rb +46 -0
  43. data/lib/esp/version.rb +3 -0
  44. data/lib/esp.rb +95 -0
  45. data/lib/esp_sdk.rb +9 -45
  46. data/lib/tasks/rubocop.rake +2 -0
  47. data/lib/tasks/testing.rake +3 -0
  48. data/rdoc/ActiveResource/Formats.html +176 -0
  49. data/rdoc/ActiveResource/PaginatedCollection.html +910 -0
  50. data/rdoc/ActiveResource.html +180 -0
  51. data/rdoc/ESP/Alert.html +771 -0
  52. data/rdoc/ESP/CloudTrailEvent.html +375 -0
  53. data/rdoc/ESP/ContactRequest.html +366 -0
  54. data/rdoc/ESP/CustomSignature.html +746 -0
  55. data/rdoc/ESP/Dashboard.html +355 -0
  56. data/rdoc/ESP/ExternalAccount.html +565 -0
  57. data/rdoc/ESP/Organization.html +590 -0
  58. data/rdoc/ESP/Region.html +399 -0
  59. data/rdoc/ESP/Report.html +622 -0
  60. data/rdoc/ESP/Service.html +380 -0
  61. data/rdoc/ESP/Signature.html +555 -0
  62. data/rdoc/ESP/Stat.html +1778 -0
  63. data/rdoc/ESP/StatCustomSignature.html +1599 -0
  64. data/rdoc/ESP/StatRegion.html +1598 -0
  65. data/rdoc/ESP/StatService.html +1598 -0
  66. data/rdoc/ESP/StatSignature.html +1598 -0
  67. data/rdoc/ESP/SubOrganization.html +540 -0
  68. data/rdoc/ESP/Suppression/Region.html +454 -0
  69. data/rdoc/ESP/Suppression/Signature.html +470 -0
  70. data/rdoc/ESP/Suppression/UniqueIdentifier.html +417 -0
  71. data/rdoc/ESP/Suppression.html +649 -0
  72. data/rdoc/ESP/Tag.html +371 -0
  73. data/rdoc/ESP/Team.html +584 -0
  74. data/rdoc/ESP/User.html +483 -0
  75. data/rdoc/ESP.html +546 -0
  76. data/rdoc/README_md.html +501 -0
  77. data/rdoc/created.rid +30 -0
  78. data/rdoc/images/add.png +0 -0
  79. data/rdoc/images/arrow_up.png +0 -0
  80. data/rdoc/images/brick.png +0 -0
  81. data/rdoc/images/brick_link.png +0 -0
  82. data/rdoc/images/bug.png +0 -0
  83. data/rdoc/images/bullet_black.png +0 -0
  84. data/rdoc/images/bullet_toggle_minus.png +0 -0
  85. data/rdoc/images/bullet_toggle_plus.png +0 -0
  86. data/rdoc/images/date.png +0 -0
  87. data/rdoc/images/delete.png +0 -0
  88. data/rdoc/images/find.png +0 -0
  89. data/rdoc/images/loadingAnimation.gif +0 -0
  90. data/rdoc/images/macFFBgHack.png +0 -0
  91. data/rdoc/images/package.png +0 -0
  92. data/rdoc/images/page_green.png +0 -0
  93. data/rdoc/images/page_white_text.png +0 -0
  94. data/rdoc/images/page_white_width.png +0 -0
  95. data/rdoc/images/plugin.png +0 -0
  96. data/rdoc/images/ruby.png +0 -0
  97. data/rdoc/images/tag_blue.png +0 -0
  98. data/rdoc/images/tag_green.png +0 -0
  99. data/rdoc/images/transparent.png +0 -0
  100. data/rdoc/images/wrench.png +0 -0
  101. data/rdoc/images/wrench_orange.png +0 -0
  102. data/rdoc/images/zoom.png +0 -0
  103. data/rdoc/index.html +134 -0
  104. data/rdoc/js/darkfish.js +155 -0
  105. data/rdoc/js/jquery.js +4 -0
  106. data/rdoc/js/navigation.js +142 -0
  107. data/rdoc/js/search.js +94 -0
  108. data/rdoc/js/search_index.js +1 -0
  109. data/rdoc/js/searcher.js +228 -0
  110. data/rdoc/rdoc.css +595 -0
  111. data/rdoc/table_of_contents.html +927 -0
  112. data/test/esp/extensions/active_resource/formats/json_api_format_test.rb +109 -0
  113. data/test/esp/extensions/active_resource/paginated_collection_test.rb +435 -0
  114. data/test/esp/extensions/active_resource/validations_test.rb +59 -0
  115. data/test/esp/resources/alert_test.rb +263 -0
  116. data/test/esp/resources/cloud_trail_event_test.rb +98 -0
  117. data/test/esp/resources/contact_request_test.rb +73 -0
  118. data/test/esp/resources/custom_signature_test.rb +241 -0
  119. data/test/esp/resources/dashboard_test.rb +71 -0
  120. data/test/esp/resources/external_account_test.rb +125 -0
  121. data/test/esp/resources/organization_test.rb +175 -0
  122. data/test/esp/resources/region_test.rb +84 -0
  123. data/test/esp/resources/report_test.rb +180 -0
  124. data/test/esp/resources/resource_test.rb +183 -0
  125. data/test/esp/resources/service_test.rb +64 -0
  126. data/test/esp/resources/signature_test.rb +177 -0
  127. data/test/esp/resources/stat_custom_signature_test.rb +115 -0
  128. data/test/esp/resources/stat_region_test.rb +114 -0
  129. data/test/esp/resources/stat_service_test.rb +114 -0
  130. data/test/esp/resources/stat_signature_test.rb +115 -0
  131. data/test/esp/resources/stat_test.rb +159 -0
  132. data/test/esp/resources/sub_organization_test.rb +127 -0
  133. data/test/esp/resources/suppression/region_test.rb +115 -0
  134. data/test/esp/resources/suppression/signature_test.rb +117 -0
  135. data/test/esp/resources/suppression/unique_identifier_test.rb +79 -0
  136. data/test/esp/resources/suppression_test.rb +226 -0
  137. data/test/esp/resources/tag_test.rb +98 -0
  138. data/test/esp/resources/team_test.rb +140 -0
  139. data/test/esp/resources/user_test.rb +113 -0
  140. data/test/esp_test.rb +139 -0
  141. data/test/factories/alerts.rb +234 -0
  142. data/test/factories/cloud_trail_events.rb +16 -0
  143. data/test/factories/contact_requests.rb +14 -0
  144. data/test/factories/custom_signatures.rb +30 -0
  145. data/test/factories/dashboards.rb +91 -0
  146. data/test/factories/errors.rb +24 -0
  147. data/test/factories/external_accounts.rb +44 -0
  148. data/test/factories/organizations.rb +48 -0
  149. data/test/factories/regions.rb +9 -0
  150. data/test/factories/reports.rb +56 -0
  151. data/test/factories/services.rb +12 -0
  152. data/test/factories/signatures.rb +28 -0
  153. data/test/factories/stat_custom_signatures.rb +97 -0
  154. data/test/factories/stat_regions.rb +97 -0
  155. data/test/factories/stat_services.rb +97 -0
  156. data/test/factories/stat_signautures.rb +97 -0
  157. data/test/factories/stats.rb +129 -0
  158. data/test/factories/sub_organizations.rb +34 -0
  159. data/test/factories/suppression/regions.rb +90 -0
  160. data/test/factories/suppression/signatures.rb +117 -0
  161. data/test/factories/suppression/unique_identifiers.rb +111 -0
  162. data/test/factories/suppressions.rb +71 -0
  163. data/test/factories/tags.rb +12 -0
  164. data/test/factories/teams.rb +32 -0
  165. data/test/factories/users.rb +54 -0
  166. data/test/json_strategy.rb +25 -0
  167. data/test/test_helper.rb +44 -5
  168. metadata +387 -119
  169. data/bin/esp_repl +0 -60
  170. data/lib/esp_sdk/api.rb +0 -33
  171. data/lib/esp_sdk/client.rb +0 -62
  172. data/lib/esp_sdk/configure.rb +0 -40
  173. data/lib/esp_sdk/end_points/base.rb +0 -102
  174. data/lib/esp_sdk/end_points/contact_requests.rb +0 -6
  175. data/lib/esp_sdk/end_points/custom_signatures.rb +0 -41
  176. data/lib/esp_sdk/end_points/dashboard.rb +0 -35
  177. data/lib/esp_sdk/end_points/external_accounts.rb +0 -9
  178. data/lib/esp_sdk/end_points/organizations.rb +0 -6
  179. data/lib/esp_sdk/end_points/reports.rb +0 -6
  180. data/lib/esp_sdk/end_points/services.rb +0 -6
  181. data/lib/esp_sdk/end_points/signatures.rb +0 -39
  182. data/lib/esp_sdk/end_points/sub_organizations.rb +0 -6
  183. data/lib/esp_sdk/end_points/teams.rb +0 -6
  184. data/lib/esp_sdk/end_points/users.rb +0 -6
  185. data/lib/esp_sdk/exceptions.rb +0 -8
  186. data/lib/esp_sdk/extensions/rest_client/request.rb +0 -9
  187. data/lib/esp_sdk/repl.rb +0 -61
  188. data/lib/esp_sdk/version.rb +0 -3
  189. data/test/esp_sdk/api_test.rb +0 -36
  190. data/test/esp_sdk/client_test.rb +0 -129
  191. data/test/esp_sdk/configure_test.rb +0 -65
  192. data/test/esp_sdk/end_points/.keep +0 -0
  193. data/test/esp_sdk/end_points/base_test.rb +0 -230
  194. data/test/esp_sdk/end_points/custom_signatures_test.rb +0 -90
  195. data/test/esp_sdk/end_points/dashboard_test.rb +0 -55
  196. data/test/esp_sdk/end_points/external_accounts_test.rb +0 -20
  197. data/test/esp_sdk/end_points/signatures_test.rb +0 -83
  198. data/test/esp_sdk/exceptions_test.rb +0 -41
  199. data/test/esp_sdk_test.rb +0 -70
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 9ae3ded6473c7dd46addd90c607bc9f9a33e6c56
4
- data.tar.gz: 4528c438187d057bb6a6062e6f9999968a3a0c92
3
+ metadata.gz: 375b1160781a13a88cefd9a083eff938b826902d
4
+ data.tar.gz: 16a16aefa8bec1cde0b74c74de232700ed77bbd1
5
5
  SHA512:
6
- metadata.gz: 5af81ffd9e432e288418a7e7fcb766b853f15e85e3f1079ee2526526d0eb520c5006f929ea36e6c3b96c410a33366371becfcc36329fd1851662b22cb1636a53
7
- data.tar.gz: d88b77ff17a2d27ce65b3f58ef6cd1affc06deb2e757db1f186355a8059b3e9c48c2fbd4ddf38d9001e3af639e80321786b8e339446c964c3f323be6920602fc
6
+ metadata.gz: 6f7342eb640fb5eb04e02e0bab60b7e7ed7b8073cccab9c9d5759faac55762c711191f4ce63581e64131be3b7ed8b47335da5e1f5091704993ce6de70e7b3908
7
+ data.tar.gz: 9da7a80cff4b9ee24e24a804f4a68191887bc73ec4f6a10f19763936209179fa802762608f27ce90ba9362b1688acba52f4aab010d29cb227f9e8a418604172c
data/.gitignore CHANGED
@@ -3,14 +3,12 @@
3
3
  .bundle
4
4
  .config
5
5
  .yardoc
6
- Gemfile.lock
7
6
  InstalledFiles
8
7
  _yardoc
9
8
  coverage
10
9
  doc/
11
10
  lib/bundler/man
12
11
  pkg
13
- rdoc
14
12
  spec/reports
15
13
  test/tmp
16
14
  test/version_tmp
data/.rubocop.yml CHANGED
@@ -89,7 +89,7 @@ Style/BlockComments:
89
89
  Style/BlockEndNewline:
90
90
  Enabled: true
91
91
 
92
- Style/Blocks:
92
+ Style/BlockDelimiters:
93
93
  Enabled: true
94
94
 
95
95
 
@@ -236,10 +236,10 @@ Style/EvenOdd:
236
236
  Enabled: true
237
237
 
238
238
  Style/ExtraSpacing:
239
- Enabled: false
239
+ Enabled: true
240
240
 
241
241
  Style/FileName:
242
- Enabled: false
242
+ Enabled: true
243
243
  Exclude:
244
244
  - '**/Rakefile'
245
245
  - '**/Gemfile'
@@ -308,6 +308,10 @@ Style/IndentHash:
308
308
  Style/InfiniteLoop:
309
309
  Enabled: true
310
310
 
311
+ Style/InitialIndentation:
312
+ Description: Checks the indentation of the first non-blank non-comment line in a file.
313
+ Enabled: true
314
+
311
315
  Style/Lambda:
312
316
  Enabled: true
313
317
 
@@ -405,6 +409,12 @@ Style/NumericLiterals:
405
409
  Style/OneLineConditional:
406
410
  Enabled: true
407
411
 
412
+ Style/OptionalArguments:
413
+ Enabled: true
414
+
415
+ Style/OptionHash:
416
+ Enabled: true
417
+
408
418
  Style/OpMethod:
409
419
  Enabled: true
410
420
 
@@ -412,6 +422,9 @@ Style/ParenthesesAroundCondition:
412
422
  Enabled: true
413
423
  AllowSafeAssignment: true
414
424
 
425
+ Style/ParallelAssignment:
426
+ Enabled: true
427
+
415
428
  Style/PercentLiteralDelimiters:
416
429
  Enabled: true
417
430
  PreferredDelimiters:
@@ -467,7 +480,10 @@ Style/RedundantSelf:
467
480
 
468
481
  Style/RegexpLiteral:
469
482
  Enabled: true
470
- MaxSlashes: 1
483
+
484
+ Style/RescueEnsureAlignment:
485
+ Description: 'Align rescues and ensures correctly.'
486
+ Enabled: true
471
487
 
472
488
  Style/RescueModifier:
473
489
  Enabled: true
@@ -479,6 +495,12 @@ Style/Semicolon:
479
495
  Enabled: true
480
496
  AllowAsExpressionSeparator: false
481
497
 
498
+ Style/Send:
499
+ Description: 'Prefer `Object#__send__` or `Object#public_send` to `send`, as `send` may overlap with existing methods.'
500
+ StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#prefer-public-send'
501
+ # TODO: enable this
502
+ Enabled: false
503
+
482
504
  Style/SignalException:
483
505
  Enabled: true
484
506
  EnforcedStyle: semantic
@@ -582,11 +604,14 @@ Style/SpaceInsideParens:
582
604
  Style/SpaceInsideRangeLiteral:
583
605
  Enabled: true
584
606
 
607
+ Style/SpaceInsideStringInterpolation:
608
+ Enabled: true
609
+
585
610
  Style/SpecialGlobalVars:
586
611
  Enabled: true
587
612
 
588
613
  Style/StringLiterals:
589
- Enabled: true
614
+ Enabled: false
590
615
  EnforcedStyle: single_quotes
591
616
  SupportedStyles:
592
617
  - single_quotes
@@ -618,6 +643,9 @@ Style/TrailingComma:
618
643
  - comma
619
644
  - no_comma
620
645
 
646
+ Style/TrailingUnderscoreVariable:
647
+ Enabled: true
648
+
621
649
  Style/TrailingWhitespace:
622
650
  Enabled: true
623
651
 
@@ -654,7 +682,7 @@ Style/UnneededCapitalW:
654
682
  Style/UnneededPercentQ:
655
683
  Enabled: true
656
684
 
657
- Style/UnneededPercentX:
685
+ Style/CommandLiteral:
658
686
  Enabled: true
659
687
 
660
688
  Style/VariableInterpolation:
@@ -722,6 +750,9 @@ Metrics/MethodLength:
722
750
  CountComments: false # count full line comments?
723
751
  Max: 10
724
752
 
753
+ Metrics/ModuleLength:
754
+ Enabled: true
755
+
725
756
  Metrics/ParameterLists:
726
757
  Enabled: true
727
758
  Max: 5
@@ -748,6 +779,9 @@ Lint/AssignmentInCondition:
748
779
  Lint/BlockAlignment:
749
780
  Enabled: true
750
781
 
782
+ Lint/CircularArgumentReference:
783
+ Enabled: true
784
+
751
785
  Lint/ConditionPosition:
752
786
  Enabled: true
753
787
 
@@ -767,6 +801,9 @@ Lint/DeprecatedClassMethods:
767
801
  Lint/DuplicateMethods:
768
802
  Enabled: true
769
803
 
804
+ Lint/EachWithObjectArgument:
805
+ Enabled: true
806
+
770
807
  Lint/ElseLayout:
771
808
  Enabled: true
772
809
 
@@ -792,6 +829,10 @@ Lint/EnsureReturn:
792
829
  Lint/Eval:
793
830
  Enabled: true
794
831
 
832
+ Lint/FormatParameterMismatch:
833
+ Description: 'The number of parameters to format/sprint must match the fields.'
834
+ Enabled: true
835
+
795
836
  Lint/HandleExceptions:
796
837
  Enabled: true
797
838
 
@@ -807,6 +848,9 @@ Lint/LiteralInInterpolation:
807
848
  Lint/Loop:
808
849
  Enabled: true
809
850
 
851
+ Lint/NestedMethodDefinition:
852
+ Enabled: true
853
+
810
854
  Lint/ParenthesesAsGroupedExpression:
811
855
  Enabled: true
812
856
 
@@ -828,6 +872,9 @@ Lint/StringConversionInInterpolation:
828
872
  Lint/UnderscorePrefixedVariableName:
829
873
  Enabled: true
830
874
 
875
+ Lint/UnneededDisable:
876
+ Enabled: true
877
+
831
878
  Lint/UnusedBlockArgument:
832
879
  Enabled: true
833
880
 
data/.ruby-version CHANGED
@@ -1 +1 @@
1
- 2.1.5
1
+ 2.0.0
data/.travis.yml CHANGED
@@ -1,9 +1,15 @@
1
+ sudo: false
2
+ cache: bundler
1
3
  language: ruby
2
4
  rvm:
3
- - 2.1.1
4
- cache: bundler
5
+ - 2.0.0
6
+ - 2.1
7
+ - 2.2
5
8
  script:
6
9
  - bundle exec rake test
10
+ - bundle exec rake coveralls:push
11
+ - bundle exec rubocop
12
+
7
13
  addons:
8
14
  code_climate:
9
15
  repo_token: 73b22e855ca36fc2ab337552731c44437923bdf96780beb01c04c0fe2775f7a1
data/Gemfile.lock ADDED
@@ -0,0 +1,171 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ esp_sdk (2.0.0.rc1)
5
+ activeresource (~> 4.0.0)
6
+ api-auth
7
+ artii
8
+ awesome_print
9
+ catpix
10
+ rack
11
+
12
+ GEM
13
+ remote: https://rubygems.org/
14
+ specs:
15
+ activemodel (4.2.1)
16
+ activesupport (= 4.2.1)
17
+ builder (~> 3.1)
18
+ activeresource (4.0.0)
19
+ activemodel (~> 4.0)
20
+ activesupport (~> 4.0)
21
+ rails-observers (~> 0.1.1)
22
+ activesupport (4.2.1)
23
+ i18n (~> 0.7)
24
+ json (~> 1.7, >= 1.7.7)
25
+ minitest (~> 5.1)
26
+ thread_safe (~> 0.3, >= 0.3.4)
27
+ tzinfo (~> 1.1)
28
+ addressable (2.3.8)
29
+ ansi (1.5.0)
30
+ api-auth (1.3.2)
31
+ artii (2.1.1)
32
+ ast (2.0.0)
33
+ astrolabe (1.3.1)
34
+ parser (~> 2.2)
35
+ awesome_print (1.6.1)
36
+ bourne (1.6.0)
37
+ mocha (~> 1.1)
38
+ builder (3.2.2)
39
+ catpix (0.2.0)
40
+ docopt (~> 0.5, >= 0.5.0)
41
+ rmagick (~> 2.15, >= 2.15.2)
42
+ ruby-terminfo (~> 0.1, >= 0.1.1)
43
+ tco (~> 0.1, >= 0.1.8)
44
+ coderay (1.1.0)
45
+ coveralls (0.8.0)
46
+ multi_json (~> 1.10)
47
+ rest-client (>= 1.6.8, < 2)
48
+ simplecov (~> 0.9.1)
49
+ term-ansicolor (~> 1.3)
50
+ thor (~> 0.19.1)
51
+ crack (0.4.2)
52
+ safe_yaml (~> 1.0.0)
53
+ docile (1.1.5)
54
+ docopt (0.5.0)
55
+ factory_girl (4.5.0)
56
+ activesupport (>= 3.0.0)
57
+ ffi (1.9.10)
58
+ formatador (0.2.5)
59
+ guard (2.13.0)
60
+ formatador (>= 0.2.4)
61
+ listen (>= 2.7, <= 4.0)
62
+ lumberjack (~> 1.0)
63
+ nenv (~> 0.1)
64
+ notiffany (~> 0.0)
65
+ pry (>= 0.9.12)
66
+ shellany (~> 0.0)
67
+ thor (>= 0.18.1)
68
+ guard-compat (1.2.1)
69
+ guard-minitest (2.4.4)
70
+ guard-compat (~> 1.2)
71
+ minitest (>= 3.0)
72
+ guard-rubocop (1.2.0)
73
+ guard (~> 2.0)
74
+ rubocop (~> 0.20)
75
+ i18n (0.7.0)
76
+ json (1.8.2)
77
+ listen (3.0.3)
78
+ rb-fsevent (>= 0.9.3)
79
+ rb-inotify (>= 0.9)
80
+ lumberjack (1.0.9)
81
+ metaclass (0.0.4)
82
+ method_source (0.8.2)
83
+ mime-types (2.4.3)
84
+ minitest (5.6.0)
85
+ minitest-reporters (1.0.11)
86
+ ansi
87
+ builder
88
+ minitest (>= 5.0)
89
+ ruby-progressbar
90
+ mocha (1.1.0)
91
+ metaclass (~> 0.0.1)
92
+ multi_json (1.11.0)
93
+ nenv (0.2.0)
94
+ netrc (0.10.3)
95
+ notiffany (0.0.8)
96
+ nenv (~> 0.1)
97
+ shellany (~> 0.0)
98
+ parser (2.2.2.5)
99
+ ast (>= 1.1, < 3.0)
100
+ powerpack (0.1.0)
101
+ pry (0.10.2)
102
+ coderay (~> 1.1.0)
103
+ method_source (~> 0.8.1)
104
+ slop (~> 3.4)
105
+ rack (1.6.4)
106
+ rails-observers (0.1.2)
107
+ activemodel (~> 4.0)
108
+ rainbow (2.0.0)
109
+ rake (10.4.2)
110
+ rb-fsevent (0.9.6)
111
+ rb-inotify (0.9.5)
112
+ ffi (>= 0.5.0)
113
+ rdoc (4.0.0)
114
+ rest-client (1.7.3)
115
+ mime-types (>= 1.16, < 3.0)
116
+ netrc (~> 0.7)
117
+ rmagick (2.15.4)
118
+ rubocop (0.34.2)
119
+ astrolabe (~> 1.3)
120
+ parser (>= 2.2.2.5, < 3.0)
121
+ powerpack (~> 0.1)
122
+ rainbow (>= 1.99.1, < 3.0)
123
+ ruby-progressbar (~> 1.4)
124
+ ruby-progressbar (1.7.5)
125
+ ruby-terminfo (0.1.1)
126
+ safe_yaml (1.0.4)
127
+ shellany (0.0.1)
128
+ shoulda (3.5.0)
129
+ shoulda-context (~> 1.0, >= 1.0.1)
130
+ shoulda-matchers (>= 1.4.1, < 3.0)
131
+ shoulda-context (1.2.1)
132
+ shoulda-matchers (2.8.0)
133
+ activesupport (>= 3.0.0)
134
+ simplecov (0.9.2)
135
+ docile (~> 1.1.0)
136
+ multi_json (~> 1.0)
137
+ simplecov-html (~> 0.9.0)
138
+ simplecov-html (0.9.0)
139
+ slop (3.6.0)
140
+ tco (0.1.8)
141
+ term-ansicolor (1.3.0)
142
+ tins (~> 1.0)
143
+ thor (0.19.1)
144
+ thread_safe (0.3.5)
145
+ tins (1.3.5)
146
+ tzinfo (1.2.2)
147
+ thread_safe (~> 0.1)
148
+ webmock (1.21.0)
149
+ addressable (>= 2.3.6)
150
+ crack (>= 0.3.2)
151
+
152
+ PLATFORMS
153
+ ruby
154
+
155
+ DEPENDENCIES
156
+ bourne
157
+ bundler
158
+ coveralls
159
+ esp_sdk!
160
+ factory_girl
161
+ guard
162
+ guard-minitest
163
+ guard-rubocop
164
+ minitest
165
+ minitest-reporters
166
+ mocha
167
+ rake
168
+ rdoc
169
+ rubocop
170
+ shoulda
171
+ webmock
data/Guardfile ADDED
@@ -0,0 +1,47 @@
1
+ # A sample Guardfile
2
+ # More info at https://github.com/guard/guard#readme
3
+
4
+ ## Uncomment and set this to only include directories you want to watch
5
+ # directories %w(app lib config test spec features) \
6
+ # .select{|d| Dir.exists?(d) ? d : UI.warning("Directory #{d} does not exist")}
7
+
8
+ ## Note: if you are using the `directories` clause above and you are not
9
+ ## watching the project directory ('.'), then you will want to move
10
+ ## the Guardfile to a watched dir and symlink it back, e.g.
11
+ #
12
+ # $ mkdir config
13
+ # $ mv Guardfile config/
14
+ # $ ln -s config/Guardfile .
15
+ #
16
+ # and, you'll have to watch "config/Guardfile" instead of "Guardfile"
17
+
18
+ guard :minitest do
19
+ # with Minitest::Unit
20
+ watch(%r{^test/(.*)\/?test_(.*)\.rb$})
21
+ watch(%r{^lib/(.*/)?([^/]+)\.rb$}) { |m| "test/#{m[1]}test_#{m[2]}.rb" }
22
+ watch(%r{^test/test_helper\.rb$}) { 'test' }
23
+
24
+ # with Minitest::Spec
25
+ # watch(%r{^spec/(.*)_spec\.rb$})
26
+ # watch(%r{^lib/(.+)\.rb$}) { |m| "spec/#{m[1]}_spec.rb" }
27
+ # watch(%r{^spec/spec_helper\.rb$}) { 'spec' }
28
+
29
+ # Rails 4
30
+ # watch(%r{^app/(.+)\.rb$}) { |m| "test/#{m[1]}_test.rb" }
31
+ # watch(%r{^app/controllers/application_controller\.rb$}) { 'test/controllers' }
32
+ # watch(%r{^app/controllers/(.+)_controller\.rb$}) { |m| "test/integration/#{m[1]}_test.rb" }
33
+ # watch(%r{^app/views/(.+)_mailer/.+}) { |m| "test/mailers/#{m[1]}_mailer_test.rb" }
34
+ # watch(%r{^lib/(.+)\.rb$}) { |m| "test/lib/#{m[1]}_test.rb" }
35
+ # watch(%r{^test/.+_test\.rb$})
36
+ # watch(%r{^test/test_helper\.rb$}) { 'test' }
37
+
38
+ # Rails < 4
39
+ # watch(%r{^app/controllers/(.*)\.rb$}) { |m| "test/functional/#{m[1]}_test.rb" }
40
+ # watch(%r{^app/helpers/(.*)\.rb$}) { |m| "test/helpers/#{m[1]}_test.rb" }
41
+ # watch(%r{^app/models/(.*)\.rb$}) { |m| "test/unit/#{m[1]}_test.rb" }
42
+ end
43
+
44
+ guard :rubocop do
45
+ watch(%r{.+\.rb$})
46
+ watch(%r{(?:.+/)?\.rubocop\.yml$}) { |m| File.dirname(m[0]) }
47
+ end
data/README.md CHANGED
@@ -1,12 +1,14 @@
1
1
  [![Build Status](https://travis-ci.org/EvidentSecurity/esp_sdk.svg?branch=master)](https://travis-ci.org/EvidentSecurity/esp_sdk)
2
2
  [![Code Climate](https://codeclimate.com/repos/546a526f6956800d2900e3fb/badges/841000b5295e533401c3/gpa.svg)](https://codeclimate.com/repos/546a526f6956800d2900e3fb/feed)
3
- [![Test Coverage](https://codeclimate.com/repos/546a526f6956800d2900e3fb/badges/841000b5295e533401c3/coverage.svg)](https://codeclimate.com/repos/546a526f6956800d2900e3fb/feed)
3
+ [![Coverage Status](https://coveralls.io/repos/EvidentSecurity/esp_sdk/badge.svg)](https://coveralls.io/r/EvidentSecurity/esp_sdk)
4
4
  [![Gem Version](https://badge.fury.io/rb/esp_sdk.svg)](http://badge.fury.io/rb/esp_sdk)
5
5
 
6
- # EspSdk
6
+ # Evident Security Platform SDK
7
7
 
8
8
  A Ruby interface for calling the [Evident.io](https://www.evident.io) API.
9
9
 
10
+ This Readme is for the V2 version of the ESP SDK. For V1 information, see the [**V1 WIKI**](https://github.com/EvidentSecurity/esp_sdk/wiki).
11
+
10
12
  ## Installation
11
13
 
12
14
  Add this line to your application's Gemfile:
@@ -15,15 +17,238 @@ Add this line to your application's Gemfile:
15
17
 
16
18
  And then execute:
17
19
 
18
- $ bundle
20
+ bundle
19
21
 
20
22
  Or install it yourself as:
21
23
 
22
- $ gem install esp_sdk
24
+ gem install esp_sdk
25
+
26
+ # Configuration
27
+
28
+ ## Set your HMAC security keys:
29
+
30
+ You must set your access_key_id and your secret_access_key.
31
+ You can set these directly:
32
+
33
+ ```ruby
34
+ ESP.access_key_id = <your key>
35
+ ESP.secret_access_key = <your secret key>
36
+ ```
37
+
38
+ or with environment variables:
39
+
40
+ ```ruby
41
+ ENV['ESP_ACCESS_KEY_ID'] = <you key>
42
+ ENV['ESP_SECRET_ACCESS_KEY'] = <your secret key>
43
+ ```
44
+
45
+ or, if in a Rails application, you can use the configure block in an initializer:
46
+
47
+ ```ruby
48
+ ESP.configure do |config|
49
+ config.access_key_id = <your key>
50
+ config.secret_access_key = <your secret key>
51
+ end
52
+ ```
53
+
54
+ Get your HMAC keys from the Evident.io website, [esp.evident.io](https://esp.evident.io/settings/api_keys)
55
+
56
+ ## Appliance Users
57
+
58
+ Users of Evident.io's AWS marketplace appliance will need to set the host for their appliance instance.
59
+ You can set this directly:
60
+
61
+ ```ruby
62
+ ESP.host = <host for appliance instance>
63
+ ```
64
+
65
+ or, if in a Rails application, you can use the configure block in an initializer:
66
+
67
+ ```ruby
68
+ ESP.configure do |config|
69
+ config.host = <host for appliance instance>
70
+ end
71
+ ```
72
+
73
+ Alternatively, the site can also be set with an environment variable.
74
+
75
+
76
+ ```
77
+ export ESP_HOST=<host for appliance instance>
78
+ ```
23
79
 
24
80
  # Usage
25
81
 
26
- See the [**WIKI**](https://github.com/EvidentSecurity/esp_sdk/wiki) for information on using the SDK.
82
+ ## Everything is an Object
83
+
84
+ The Evident.io SDK uses Active Resource, so the DSL acts very much like Active Record providing by default, the standard CRUD actions
85
+ `find`, `all`, `create`, `update`, `destroy`, only instead of a database as the data store, it makes calls to the Evident.io API. Not all
86
+ methods are available for all ESP objects. See the [documentation](http://www.rubydoc.info/gems/esp_sdk) to see all the methods
87
+ available for each object.
88
+ So, for instance, to get a report by ID:
89
+
90
+ ```ruby
91
+ espsdk:003:0> report = ESP::Report.find(234)
92
+ ```
93
+
94
+ And to get the alerts for that report:
95
+
96
+ ```ruby
97
+ espsdk:003:0> alerts = report.alerts
98
+ ```
99
+
100
+ For objects that are creatable, updatable, and destroyable, you make the exact same calls you would expect to use with Active Record.
101
+
102
+ ```ruby
103
+ espsdk:003:0> team = ESP::Team.create(name: 'MyTeam', organization_id: 452, sub_organization_id: 599)
104
+
105
+ espsdk:003:0> team.name = 'NewName'
106
+ espsdk:003:0> team.save
107
+
108
+ espsdk:003:0> team.destroy
109
+ ```
110
+
111
+ Use the `attributes` method to get a list of all available attributes that each object has.
112
+
113
+ ```ruby
114
+ espsdk:003:0> team = ESP::Team.find(1)
115
+ espsdk:004:0> team.attributes
116
+ # => {
117
+ # => "id" => "1",
118
+ # => "type" => "teams",
119
+ # => "relationships" => #<ESP::Team::Relationships:0x007fdf1b451710 @attributes={"sub_organization"=>#<ESP::SubOrganization:0x007fdf1b450d60 @attributes={"data"=>#<ESP::SubOrganization::Data:0x007fdf1b450978 @attributes={"id"=>"1", "type"=>"sub_organizations"}, @prefix_options={}, @persisted=true>, "links"=>#<ESP::SubOrganization::Links:0x007fdf1b4503b0 @attributes={"related"=>"http://localhost:3000/api/v2/sub_organizations/1.json"}, @prefix_options={}, @persisted=true>}, @prefix_options={}, @persisted=true>, "organization"=>#<ESP::Organization:0x007fdf1b45bbc0 @attributes={"data"=>#<ESP::Organization::Data:0x007fdf1b45b7d8 @attributes={"id"=>"1", "type"=>"organizations"}, @prefix_options={}, @persisted=true>, "links"=>#<ESP::Organization::Links:0x007fdf1b45b210 @attributes={"related"=>"http://localhost:3000/api/v2/organizations/1.json"}, @prefix_options={}, @persisted=true>}, @prefix_options={}, @persisted=true>, "external_accounts"=>#<ESP::Team::Relationships::ExternalAccounts:0x007fdf1b45a040 @attributes={"data"=>[#<ESP::Team::Relationships::ExternalAccounts::Datum:0x007fdf1b458830 @attributes={"id"=>"1", "type"=>"external_accounts"}, @prefix_options={}, @persisted=true>], "links"=>#<ESP::Team::Links:0x007fdf1b463e38 @attributes={"related"=>"http://localhost:3000/api/v2/external_accounts.json"}, @prefix_options={}, @persisted=true>}, @prefix_options={}, @persisted=true>}, @prefix_options={}, @persisted=true>,
120
+ # => "name" => "Default Team",
121
+ # => "created_at" => "2015-09-23T14:37:48.000Z",
122
+ # => "updated_at" => "2015-09-23T14:37:48.000Z",
123
+ # => "sub_organization_id" => "1",
124
+ # => "organization_id" => "1",
125
+ # => "external_account_ids" => [
126
+ # => [0] "1"
127
+ # => ]
128
+ # => }
129
+ ```
130
+
131
+ ## Errors
132
+ Active Resource objects have an errors collection, just like Active Record objects. If the API call returns a non fatal response, like
133
+ validation issues, you can check the errors object to see what went wrong.
134
+
135
+ ```ruby
136
+ espsdk:003:0> t = ESP::Team.create(name: '')
137
+ espsdk:003:0> t.errors
138
+ # => {
139
+ # => :base => [
140
+ # => [0] "Organization can't be blank",
141
+ # => [1] "Sub organization can't be blank"
142
+ # => ],
143
+ # => :name => [
144
+ # => [0] "can't be blank"
145
+ # => ]
146
+ # => }
147
+ ```
148
+
149
+ The errors will be in the :base key rather than the corresponding attribute key, since we have not defined a schema for the objects
150
+ in order to stay more loosely coupled to the API.
151
+
152
+ ```ruby
153
+ espsdk:003:0> t.errors.full_messages
154
+ # => [
155
+ # => [0] "Organization can't be blank",
156
+ # => [1] "Sub organization can't be blank",
157
+ # => [2] "Name can't be blank"
158
+ # => ]
159
+ ```
160
+
161
+ When an error is thrown, you can rescue the error and check the error message:
162
+
163
+ ```ruby
164
+ espsdk:003:0> c = ESP::CustomSignature.find(435)
165
+ espsdk:003:0> c.run!(external_account_id: 999)
166
+ # => ActiveResource::ResourceInvalid: Failed. Response code = 422. Response message = Couldn't find ExternalAccount.
167
+ # => from /Users/kevintyll/evident/esp_sdk/lib/esp/resources/custom_signature.rb:23:in `run!'
168
+
169
+ begin
170
+ c.run!(external_account_id: 999)
171
+ rescue ActiveResource::ResourceInvalid => e
172
+ puts e.message
173
+ end
174
+ # => Failed. Response code = 422. Response message = Couldn't find ExternalAccount.
175
+ ```
176
+
177
+ All non get requests have a corresponding `!` version of the method. These methods will throw an error rather than swallow
178
+ the error and return an object with the errors object populated. For example, the `run` and `run!` methods on CustomSignature.
179
+
180
+ ## Pagination
181
+ Evident.io API endpoints that return a collection of objects allows for paging and only returns a limited number of items at a time.
182
+ The Evident.io SDK returns an ESP::PaginatedCollection object that provides methods for paginating through the collection.
183
+ The methods with a `!` suffix update the object, methods without the `!` suffix return a new page object preserving the
184
+ original object.
185
+
186
+ ```ruby
187
+ espsdk:004:0> alerts = ESP::Alert.for_report(345)
188
+ espsdk:004:0> alerts.current_page_number # => "1"
189
+ espsdk:004:0> page2 = alerts.next_page
190
+ espsdk:004:0> alerts.current_page_number # => "1"
191
+ espsdk:004:0> page2.current_page_number # => "2"
192
+ espsdk:004:0> page2.previous_page!
193
+ espsdk:004:0> page2.current_page_number # => "1"
194
+ espsdk:004:0> alerts.last_page!
195
+ espsdk:004:0> alerts.current_page_number # => "25"
196
+ espsdk:004:0> page4 = alerts.page(4)
197
+ espsdk:004:0> alerts.current_page_number # => "25"
198
+ espsdk:004:0> page4.current_page_number # => "4"
199
+ ```
200
+
201
+ ## Associated Objects
202
+ Most of the objects in the Evident.io SDK have a corresponding API call associated with it. That means if you call an object's
203
+ association, then that will make another API call. For example:
204
+
205
+ ```ruby
206
+ espsdk:004:0> external_account = ESP::ExternalAccount.find(3)
207
+ espsdk:004:0> organization = external_account.organization
208
+ espsdk:004:0> sub_organization = external_account.sub_organization
209
+ espsdk:004:0> team = external_account.team
210
+ ```
211
+
212
+ The above code will make 4 calls to the Evident.io API. 1 each for the external account, organization, sub_organization and team.
213
+ The [JSON API Specification](http://jsonapi.org/format/#fetching-includes), which the Evident.io API tries to follow, provides
214
+ a means for returning nested objects in a single call. With the SDK, that can be done by providing a comma separated string
215
+ of the relations wanted in an +include+ option.
216
+
217
+ ```ruby
218
+ espsdk:004:0> external_account = ESP::ExternalAccount.find(3, include: 'organization,sub_orgnanization,team')
219
+ ```
220
+
221
+ With that call, organization, sub_organization and team will all come back in the response, and calling, `external_account.organization`,
222
+ `external_account.sub_organization` and `external_account.team`, will not make another API call. Most objects' find method accepts the
223
+ +include+ option.
224
+
225
+ See the [**Documentation**](http://www.rubydoc.info/gems/esp_sdk/ESP/ActiveResource/PaginatedCollection.html) for all the pagination methods available.
226
+
227
+ ## Available Objects
228
+ * [ESP::Alert](http://www.rubydoc.info/gems/esp_sdk/ESP/Alert.html)
229
+ * [ESP::CloudTrailEvent](http://www.rubydoc.info/gems/esp_sdk/ESP/CloudTrailEvent.html)
230
+ * [ESP::ContactRequest](http://www.rubydoc.info/gems/esp_sdk/ESP/ContactRequest.html)
231
+ * [ESP::CustomSignature](http://www.rubydoc.info/gems/esp_sdk/ESP/CustomSignature.html)
232
+ * [ESP::Dashboard](http://www.rubydoc.info/gems/esp_sdk/ESP/Dashboard.html)
233
+ * [ESP::ExternalAccount](http://www.rubydoc.info/gems/esp_sdk/ESP/ExternalAccount.html)
234
+ * [ESP::Organization](http://www.rubydoc.info/gems/esp_sdk/ESP/Organization.html)
235
+ * [ESP::Region](http://www.rubydoc.info/gems/esp_sdk/ESP/Region.html)
236
+ * [ESP::Report](http://www.rubydoc.info/gems/esp_sdk/ESP/Report.html)
237
+ * [ESP::Service](http://www.rubydoc.info/gems/esp_sdk/ESP/Service.html)
238
+ * [ESP::Signature](http://www.rubydoc.info/gems/esp_sdk/ESP/Signature.html)
239
+ * [ESP::Stat](http://www.rubydoc.info/gems/esp_sdk/ESP/Stat.html)
240
+ * [ESP::SubOrganization](http://www.rubydoc.info/gems/esp_sdk/ESP/SubOrganization.html)
241
+ * [ESP::Suppression](http://www.rubydoc.info/gems/esp_sdk/ESP/Suppression.html)
242
+ * [ESP::Suppression::Region](http://www.rubydoc.info/gems/esp_sdk/ESP/Suppression::Region.html)
243
+ * [ESP::Suppression::Signature](http://www.rubydoc.info/gems/esp_sdk/ESP/Suppression::Signature.html)
244
+ * [ESP::Suppression::UniqueIdentifier](http://www.rubydoc.info/gems/esp_sdk/ESP/Suppression::UniqueIdentifier.html)
245
+ * [ESP::Tag](http://www.rubydoc.info/gems/esp_sdk/ESP/Tag.html)
246
+ * [ESP::Team](http://www.rubydoc.info/gems/esp_sdk/ESP/Team.html)
247
+ * [ESP::User](http://www.rubydoc.info/gems/esp_sdk/ESP/User.html)
248
+
249
+ # Console
250
+ The Evident.io SDK gem also provides an IRB console you can use if not using it in a Rails app. Run it with `bin/esp_console`
251
+
27
252
 
28
253
  ## Contributing
29
254