hearth 1.0.0.pre1 → 1.0.0.pre3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (176) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +9 -4
  3. data/VERSION +1 -1
  4. data/lib/hearth/anonymous_auth_resolver.rb +11 -0
  5. data/lib/hearth/api_error.rb +15 -1
  6. data/lib/hearth/auth_option.rb +21 -0
  7. data/lib/hearth/auth_schemes/anonymous.rb +21 -0
  8. data/lib/hearth/auth_schemes/http_api_key.rb +16 -0
  9. data/lib/hearth/auth_schemes/http_basic.rb +16 -0
  10. data/lib/hearth/auth_schemes/http_bearer.rb +16 -0
  11. data/lib/hearth/auth_schemes/http_digest.rb +16 -0
  12. data/lib/hearth/auth_schemes.rb +32 -0
  13. data/lib/hearth/checksums.rb +31 -0
  14. data/lib/hearth/client.rb +66 -0
  15. data/lib/hearth/client_stubs.rb +128 -0
  16. data/lib/hearth/config/env_provider.rb +53 -0
  17. data/lib/hearth/config/resolver.rb +53 -0
  18. data/lib/hearth/configuration.rb +15 -0
  19. data/lib/hearth/connection_pool.rb +77 -0
  20. data/lib/hearth/context.rb +29 -4
  21. data/lib/hearth/dns/host_address.rb +27 -0
  22. data/lib/hearth/dns/host_resolver.rb +92 -0
  23. data/lib/hearth/dns.rb +48 -0
  24. data/lib/hearth/endpoint_rules.rb +154 -0
  25. data/lib/hearth/http/api_error.rb +4 -8
  26. data/lib/hearth/http/client.rb +206 -59
  27. data/lib/hearth/http/error_inspector.rb +85 -0
  28. data/lib/hearth/http/error_parser.rb +18 -20
  29. data/lib/hearth/http/field.rb +49 -0
  30. data/lib/hearth/http/fields.rb +117 -0
  31. data/lib/hearth/http/header_list_builder.rb +42 -0
  32. data/lib/hearth/http/header_list_parser.rb +92 -0
  33. data/lib/hearth/http/middleware/content_length.rb +7 -4
  34. data/lib/hearth/http/middleware/content_md5.rb +30 -0
  35. data/lib/hearth/http/middleware/request_compression.rb +154 -0
  36. data/lib/hearth/http/middleware.rb +12 -0
  37. data/lib/hearth/http/networking_error.rb +1 -14
  38. data/lib/hearth/http/request.rb +83 -56
  39. data/lib/hearth/http/response.rb +42 -13
  40. data/lib/hearth/http.rb +16 -5
  41. data/lib/hearth/identities/anonymous.rb +8 -0
  42. data/lib/hearth/identities/http_api_key.rb +16 -0
  43. data/lib/hearth/identities/http_bearer.rb +16 -0
  44. data/lib/hearth/identities/http_login.rb +20 -0
  45. data/lib/hearth/identities.rb +21 -0
  46. data/lib/hearth/identity_provider.rb +17 -0
  47. data/lib/hearth/interceptor.rb +506 -0
  48. data/lib/hearth/interceptor_context.rb +40 -0
  49. data/lib/hearth/interceptor_list.rb +48 -0
  50. data/lib/hearth/interceptors.rb +76 -0
  51. data/lib/hearth/json.rb +4 -4
  52. data/lib/hearth/middleware/auth.rb +103 -0
  53. data/lib/hearth/middleware/build.rb +32 -1
  54. data/lib/hearth/middleware/endpoint.rb +79 -0
  55. data/lib/hearth/middleware/host_prefix.rb +11 -8
  56. data/lib/hearth/middleware/initialize.rb +57 -0
  57. data/lib/hearth/middleware/parse.rb +45 -7
  58. data/lib/hearth/middleware/retry.rb +105 -24
  59. data/lib/hearth/middleware/send.rb +137 -26
  60. data/lib/hearth/middleware/sign.rb +65 -0
  61. data/lib/hearth/middleware/validate.rb +11 -1
  62. data/lib/hearth/middleware.rb +20 -8
  63. data/lib/hearth/middleware_stack.rb +2 -44
  64. data/lib/hearth/networking_error.rb +18 -0
  65. data/lib/hearth/number_helper.rb +3 -3
  66. data/lib/hearth/output.rb +8 -4
  67. data/lib/hearth/plugin_list.rb +53 -0
  68. data/lib/hearth/query/param.rb +56 -0
  69. data/lib/hearth/query/param_list.rb +54 -0
  70. data/lib/hearth/query/param_matcher.rb +31 -0
  71. data/lib/hearth/refreshing_identity_provider.rb +63 -0
  72. data/lib/hearth/request.rb +22 -0
  73. data/lib/hearth/response.rb +36 -0
  74. data/lib/hearth/retry/adaptive.rb +60 -0
  75. data/lib/hearth/retry/capacity_not_available_error.rb +9 -0
  76. data/lib/hearth/retry/client_rate_limiter.rb +145 -0
  77. data/lib/hearth/retry/exponential_backoff.rb +15 -0
  78. data/lib/hearth/retry/retry_quota.rb +56 -0
  79. data/lib/hearth/retry/standard.rb +46 -0
  80. data/lib/hearth/retry.rb +29 -0
  81. data/lib/hearth/signers/anonymous.rb +16 -0
  82. data/lib/hearth/signers/http_api_key.rb +29 -0
  83. data/lib/hearth/signers/http_basic.rb +23 -0
  84. data/lib/hearth/signers/http_bearer.rb +19 -0
  85. data/lib/hearth/signers/http_digest.rb +19 -0
  86. data/lib/hearth/signers.rb +23 -0
  87. data/lib/hearth/structure.rb +7 -3
  88. data/lib/hearth/stubs.rb +38 -0
  89. data/lib/hearth/time_helper.rb +6 -5
  90. data/lib/hearth/validator.rb +60 -5
  91. data/lib/hearth/waiters/poller.rb +10 -9
  92. data/lib/hearth/waiters/waiter.rb +23 -9
  93. data/lib/hearth/xml/formatter.rb +11 -2
  94. data/lib/hearth/xml/node.rb +2 -3
  95. data/lib/hearth/xml/node_matcher.rb +0 -1
  96. data/lib/hearth.rb +37 -6
  97. data/sig/lib/hearth/aliases.rbs +6 -0
  98. data/sig/lib/hearth/anonymous_auth_resolver.rbs +5 -0
  99. data/sig/lib/hearth/api_error.rbs +13 -0
  100. data/sig/lib/hearth/auth_option.rbs +11 -0
  101. data/sig/lib/hearth/auth_schemes/anonymous.rbs +7 -0
  102. data/sig/lib/hearth/auth_schemes/http_api_key.rbs +7 -0
  103. data/sig/lib/hearth/auth_schemes/http_basic.rbs +7 -0
  104. data/sig/lib/hearth/auth_schemes/http_bearer.rbs +7 -0
  105. data/sig/lib/hearth/auth_schemes/http_digest.rbs +7 -0
  106. data/sig/lib/hearth/auth_schemes.rbs +13 -0
  107. data/sig/lib/hearth/block_io.rbs +9 -0
  108. data/sig/lib/hearth/client.rbs +9 -0
  109. data/sig/lib/hearth/client_stubs.rbs +5 -0
  110. data/sig/lib/hearth/configuration.rbs +7 -0
  111. data/sig/lib/hearth/dns/host_address.rbs +11 -0
  112. data/sig/lib/hearth/dns/host_resolver.rbs +19 -0
  113. data/sig/lib/hearth/endpoint_rules.rbs +17 -0
  114. data/sig/lib/hearth/http/api_error.rbs +13 -0
  115. data/sig/lib/hearth/http/client.rbs +9 -0
  116. data/sig/lib/hearth/http/field.rbs +19 -0
  117. data/sig/lib/hearth/http/fields.rbs +43 -0
  118. data/sig/lib/hearth/http/header_list_builder.rbs +15 -0
  119. data/sig/lib/hearth/http/header_list_parser.rbs +19 -0
  120. data/sig/lib/hearth/http/networking_error.rbs +6 -0
  121. data/sig/lib/hearth/http/request.rbs +25 -0
  122. data/sig/lib/hearth/http/response.rbs +21 -0
  123. data/sig/lib/hearth/identities/anonymous.rbs +6 -0
  124. data/sig/lib/hearth/identities/http_api_key.rbs +9 -0
  125. data/sig/lib/hearth/identities/http_bearer.rbs +9 -0
  126. data/sig/lib/hearth/identities/http_login.rbs +11 -0
  127. data/sig/lib/hearth/identities.rbs +9 -0
  128. data/sig/lib/hearth/identity_provider.rbs +7 -0
  129. data/sig/lib/hearth/interceptor.rbs +9 -0
  130. data/sig/lib/hearth/interceptor_context.rbs +17 -0
  131. data/sig/lib/hearth/interceptor_list.rbs +16 -0
  132. data/sig/lib/hearth/interfaces.rbs +87 -0
  133. data/sig/lib/hearth/json/parse_error.rbs +9 -0
  134. data/sig/lib/hearth/networking_error.rbs +7 -0
  135. data/sig/lib/hearth/output.rbs +11 -0
  136. data/sig/lib/hearth/plugin_list.rbs +13 -0
  137. data/sig/lib/hearth/query/param.rbs +17 -0
  138. data/sig/lib/hearth/query/param_list.rbs +25 -0
  139. data/sig/lib/hearth/refreshing_identity_provider.rbs +10 -0
  140. data/sig/lib/hearth/request.rbs +9 -0
  141. data/sig/lib/hearth/response.rbs +11 -0
  142. data/sig/lib/hearth/retry/adaptive.rbs +13 -0
  143. data/sig/lib/hearth/retry/exponential_backoff.rbs +7 -0
  144. data/sig/lib/hearth/retry/standard.rbs +13 -0
  145. data/sig/lib/hearth/retry/strategy.rbs +11 -0
  146. data/sig/lib/hearth/retry.rbs +9 -0
  147. data/sig/lib/hearth/signers/anonymous.rbs +9 -0
  148. data/sig/lib/hearth/signers/http_api_key.rbs +9 -0
  149. data/sig/lib/hearth/signers/http_basic.rbs +9 -0
  150. data/sig/lib/hearth/signers/http_bearer.rbs +9 -0
  151. data/sig/lib/hearth/signers/http_digest.rbs +9 -0
  152. data/sig/lib/hearth/signers.rbs +9 -0
  153. data/sig/lib/hearth/structure.rbs +6 -0
  154. data/sig/lib/hearth/stubs.rbs +9 -0
  155. data/sig/lib/hearth/union.rbs +5 -0
  156. data/sig/lib/hearth/waiters/waiter.rbs +17 -0
  157. data/sig/lib/hearth/xml/parse_error.rbs +9 -0
  158. metadata +151 -25
  159. data/lib/hearth/http/headers.rb +0 -70
  160. data/lib/hearth/middleware/around_handler.rb +0 -24
  161. data/lib/hearth/middleware/request_handler.rb +0 -24
  162. data/lib/hearth/middleware/response_handler.rb +0 -25
  163. data/lib/hearth/middleware_builder.rb +0 -246
  164. data/lib/hearth/stubbing/client_stubs.rb +0 -115
  165. data/lib/hearth/stubbing/stubs.rb +0 -32
  166. data/lib/hearth/waiters/errors.rb +0 -15
  167. data/sig/lib/seahorse/api_error.rbs +0 -10
  168. data/sig/lib/seahorse/document.rbs +0 -2
  169. data/sig/lib/seahorse/http/api_error.rbs +0 -21
  170. data/sig/lib/seahorse/http/headers.rbs +0 -47
  171. data/sig/lib/seahorse/http/response.rbs +0 -21
  172. data/sig/lib/seahorse/simple_delegator.rbs +0 -3
  173. data/sig/lib/seahorse/structure.rbs +0 -18
  174. data/sig/lib/seahorse/stubbing/client_stubs.rbs +0 -103
  175. data/sig/lib/seahorse/stubbing/stubs.rbs +0 -14
  176. data/sig/lib/seahorse/union.rbs +0 -6
@@ -0,0 +1,5 @@
1
+ module Hearth
2
+ class Union < SimpleDelegator
3
+ include Structure
4
+ end
5
+ end
@@ -0,0 +1,17 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Hearth
4
+ module Waiters
5
+ class WaiterFailed < StandardError
6
+ end
7
+
8
+ class FailureStateError < WaiterFailed
9
+ end
10
+
11
+ class MaxWaitTimeExceededError < WaiterFailed
12
+ end
13
+
14
+ class UnexpectedError < WaiterFailed
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,9 @@
1
+ module Hearth
2
+ module XML
3
+ class ParseError < StandardError
4
+ def initialize: (StandardError original_error) -> void
5
+
6
+ attr_reader original_error: StandardError
7
+ end
8
+ end
9
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hearth
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0.pre1
4
+ version: 1.0.0.pre3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Amazon Web Services
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-02-16 00:00:00.000000000 Z
11
+ date: 2024-05-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: jmespath
@@ -24,6 +24,26 @@ dependencies:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
26
  version: '1.4'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rexml
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '3.2'
34
+ - - ">="
35
+ - !ruby/object:Gem::Version
36
+ version: 3.2.4
37
+ type: :runtime
38
+ prerelease: false
39
+ version_requirements: !ruby/object:Gem::Requirement
40
+ requirements:
41
+ - - "~>"
42
+ - !ruby/object:Gem::Version
43
+ version: '3.2'
44
+ - - ">="
45
+ - !ruby/object:Gem::Version
46
+ version: 3.2.4
27
47
  description:
28
48
  email:
29
49
  executables: []
@@ -33,41 +53,96 @@ files:
33
53
  - CHANGELOG.md
34
54
  - VERSION
35
55
  - lib/hearth.rb
56
+ - lib/hearth/anonymous_auth_resolver.rb
36
57
  - lib/hearth/api_error.rb
58
+ - lib/hearth/auth_option.rb
59
+ - lib/hearth/auth_schemes.rb
60
+ - lib/hearth/auth_schemes/anonymous.rb
61
+ - lib/hearth/auth_schemes/http_api_key.rb
62
+ - lib/hearth/auth_schemes/http_basic.rb
63
+ - lib/hearth/auth_schemes/http_bearer.rb
64
+ - lib/hearth/auth_schemes/http_digest.rb
37
65
  - lib/hearth/block_io.rb
66
+ - lib/hearth/checksums.rb
67
+ - lib/hearth/client.rb
68
+ - lib/hearth/client_stubs.rb
69
+ - lib/hearth/config/env_provider.rb
70
+ - lib/hearth/config/resolver.rb
71
+ - lib/hearth/configuration.rb
72
+ - lib/hearth/connection_pool.rb
38
73
  - lib/hearth/context.rb
74
+ - lib/hearth/dns.rb
75
+ - lib/hearth/dns/host_address.rb
76
+ - lib/hearth/dns/host_resolver.rb
77
+ - lib/hearth/endpoint_rules.rb
39
78
  - lib/hearth/http.rb
40
79
  - lib/hearth/http/api_error.rb
41
80
  - lib/hearth/http/client.rb
81
+ - lib/hearth/http/error_inspector.rb
42
82
  - lib/hearth/http/error_parser.rb
43
- - lib/hearth/http/headers.rb
83
+ - lib/hearth/http/field.rb
84
+ - lib/hearth/http/fields.rb
85
+ - lib/hearth/http/header_list_builder.rb
86
+ - lib/hearth/http/header_list_parser.rb
87
+ - lib/hearth/http/middleware.rb
44
88
  - lib/hearth/http/middleware/content_length.rb
89
+ - lib/hearth/http/middleware/content_md5.rb
90
+ - lib/hearth/http/middleware/request_compression.rb
45
91
  - lib/hearth/http/networking_error.rb
46
92
  - lib/hearth/http/request.rb
47
93
  - lib/hearth/http/response.rb
94
+ - lib/hearth/identities.rb
95
+ - lib/hearth/identities/anonymous.rb
96
+ - lib/hearth/identities/http_api_key.rb
97
+ - lib/hearth/identities/http_bearer.rb
98
+ - lib/hearth/identities/http_login.rb
99
+ - lib/hearth/identity_provider.rb
100
+ - lib/hearth/interceptor.rb
101
+ - lib/hearth/interceptor_context.rb
102
+ - lib/hearth/interceptor_list.rb
103
+ - lib/hearth/interceptors.rb
48
104
  - lib/hearth/json.rb
49
105
  - lib/hearth/json/parse_error.rb
50
106
  - lib/hearth/middleware.rb
51
- - lib/hearth/middleware/around_handler.rb
107
+ - lib/hearth/middleware/auth.rb
52
108
  - lib/hearth/middleware/build.rb
109
+ - lib/hearth/middleware/endpoint.rb
53
110
  - lib/hearth/middleware/host_prefix.rb
111
+ - lib/hearth/middleware/initialize.rb
54
112
  - lib/hearth/middleware/parse.rb
55
- - lib/hearth/middleware/request_handler.rb
56
- - lib/hearth/middleware/response_handler.rb
57
113
  - lib/hearth/middleware/retry.rb
58
114
  - lib/hearth/middleware/send.rb
115
+ - lib/hearth/middleware/sign.rb
59
116
  - lib/hearth/middleware/validate.rb
60
- - lib/hearth/middleware_builder.rb
61
117
  - lib/hearth/middleware_stack.rb
118
+ - lib/hearth/networking_error.rb
62
119
  - lib/hearth/number_helper.rb
63
120
  - lib/hearth/output.rb
121
+ - lib/hearth/plugin_list.rb
122
+ - lib/hearth/query/param.rb
123
+ - lib/hearth/query/param_list.rb
124
+ - lib/hearth/query/param_matcher.rb
125
+ - lib/hearth/refreshing_identity_provider.rb
126
+ - lib/hearth/request.rb
127
+ - lib/hearth/response.rb
128
+ - lib/hearth/retry.rb
129
+ - lib/hearth/retry/adaptive.rb
130
+ - lib/hearth/retry/capacity_not_available_error.rb
131
+ - lib/hearth/retry/client_rate_limiter.rb
132
+ - lib/hearth/retry/exponential_backoff.rb
133
+ - lib/hearth/retry/retry_quota.rb
134
+ - lib/hearth/retry/standard.rb
135
+ - lib/hearth/signers.rb
136
+ - lib/hearth/signers/anonymous.rb
137
+ - lib/hearth/signers/http_api_key.rb
138
+ - lib/hearth/signers/http_basic.rb
139
+ - lib/hearth/signers/http_bearer.rb
140
+ - lib/hearth/signers/http_digest.rb
64
141
  - lib/hearth/structure.rb
65
- - lib/hearth/stubbing/client_stubs.rb
66
- - lib/hearth/stubbing/stubs.rb
142
+ - lib/hearth/stubs.rb
67
143
  - lib/hearth/time_helper.rb
68
144
  - lib/hearth/union.rb
69
145
  - lib/hearth/validator.rb
70
- - lib/hearth/waiters/errors.rb
71
146
  - lib/hearth/waiters/poller.rb
72
147
  - lib/hearth/waiters/waiter.rb
73
148
  - lib/hearth/xml.rb
@@ -75,17 +150,68 @@ files:
75
150
  - lib/hearth/xml/node.rb
76
151
  - lib/hearth/xml/node_matcher.rb
77
152
  - lib/hearth/xml/parse_error.rb
78
- - sig/lib/seahorse/api_error.rbs
79
- - sig/lib/seahorse/document.rbs
80
- - sig/lib/seahorse/http/api_error.rbs
81
- - sig/lib/seahorse/http/headers.rbs
82
- - sig/lib/seahorse/http/response.rbs
83
- - sig/lib/seahorse/simple_delegator.rbs
84
- - sig/lib/seahorse/structure.rbs
85
- - sig/lib/seahorse/stubbing/client_stubs.rbs
86
- - sig/lib/seahorse/stubbing/stubs.rbs
87
- - sig/lib/seahorse/union.rbs
88
- homepage:
153
+ - sig/lib/hearth/aliases.rbs
154
+ - sig/lib/hearth/anonymous_auth_resolver.rbs
155
+ - sig/lib/hearth/api_error.rbs
156
+ - sig/lib/hearth/auth_option.rbs
157
+ - sig/lib/hearth/auth_schemes.rbs
158
+ - sig/lib/hearth/auth_schemes/anonymous.rbs
159
+ - sig/lib/hearth/auth_schemes/http_api_key.rbs
160
+ - sig/lib/hearth/auth_schemes/http_basic.rbs
161
+ - sig/lib/hearth/auth_schemes/http_bearer.rbs
162
+ - sig/lib/hearth/auth_schemes/http_digest.rbs
163
+ - sig/lib/hearth/block_io.rbs
164
+ - sig/lib/hearth/client.rbs
165
+ - sig/lib/hearth/client_stubs.rbs
166
+ - sig/lib/hearth/configuration.rbs
167
+ - sig/lib/hearth/dns/host_address.rbs
168
+ - sig/lib/hearth/dns/host_resolver.rbs
169
+ - sig/lib/hearth/endpoint_rules.rbs
170
+ - sig/lib/hearth/http/api_error.rbs
171
+ - sig/lib/hearth/http/client.rbs
172
+ - sig/lib/hearth/http/field.rbs
173
+ - sig/lib/hearth/http/fields.rbs
174
+ - sig/lib/hearth/http/header_list_builder.rbs
175
+ - sig/lib/hearth/http/header_list_parser.rbs
176
+ - sig/lib/hearth/http/networking_error.rbs
177
+ - sig/lib/hearth/http/request.rbs
178
+ - sig/lib/hearth/http/response.rbs
179
+ - sig/lib/hearth/identities.rbs
180
+ - sig/lib/hearth/identities/anonymous.rbs
181
+ - sig/lib/hearth/identities/http_api_key.rbs
182
+ - sig/lib/hearth/identities/http_bearer.rbs
183
+ - sig/lib/hearth/identities/http_login.rbs
184
+ - sig/lib/hearth/identity_provider.rbs
185
+ - sig/lib/hearth/interceptor.rbs
186
+ - sig/lib/hearth/interceptor_context.rbs
187
+ - sig/lib/hearth/interceptor_list.rbs
188
+ - sig/lib/hearth/interfaces.rbs
189
+ - sig/lib/hearth/json/parse_error.rbs
190
+ - sig/lib/hearth/networking_error.rbs
191
+ - sig/lib/hearth/output.rbs
192
+ - sig/lib/hearth/plugin_list.rbs
193
+ - sig/lib/hearth/query/param.rbs
194
+ - sig/lib/hearth/query/param_list.rbs
195
+ - sig/lib/hearth/refreshing_identity_provider.rbs
196
+ - sig/lib/hearth/request.rbs
197
+ - sig/lib/hearth/response.rbs
198
+ - sig/lib/hearth/retry.rbs
199
+ - sig/lib/hearth/retry/adaptive.rbs
200
+ - sig/lib/hearth/retry/exponential_backoff.rbs
201
+ - sig/lib/hearth/retry/standard.rbs
202
+ - sig/lib/hearth/retry/strategy.rbs
203
+ - sig/lib/hearth/signers.rbs
204
+ - sig/lib/hearth/signers/anonymous.rbs
205
+ - sig/lib/hearth/signers/http_api_key.rbs
206
+ - sig/lib/hearth/signers/http_basic.rbs
207
+ - sig/lib/hearth/signers/http_bearer.rbs
208
+ - sig/lib/hearth/signers/http_digest.rbs
209
+ - sig/lib/hearth/structure.rbs
210
+ - sig/lib/hearth/stubs.rbs
211
+ - sig/lib/hearth/union.rbs
212
+ - sig/lib/hearth/waiters/waiter.rbs
213
+ - sig/lib/hearth/xml/parse_error.rbs
214
+ homepage: https://github.com/smithy-lang/smithy-ruby
89
215
  licenses:
90
216
  - Apache-2.0
91
217
  metadata: {}
@@ -97,14 +223,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
97
223
  requirements:
98
224
  - - ">="
99
225
  - !ruby/object:Gem::Version
100
- version: '2.5'
226
+ version: '3.0'
101
227
  required_rubygems_version: !ruby/object:Gem::Requirement
102
228
  requirements:
103
- - - ">"
229
+ - - ">="
104
230
  - !ruby/object:Gem::Version
105
- version: 1.3.1
231
+ version: '0'
106
232
  requirements: []
107
- rubygems_version: 3.2.22
233
+ rubygems_version: 3.5.9
108
234
  signing_key:
109
235
  specification_version: 4
110
236
  summary: A base library for Smithy generated SDKs
@@ -1,70 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Hearth
4
- module HTTP
5
- # Provides Hash like access for Headers with key normalization
6
- # @api private
7
- class Headers
8
- # @param [Hash<String,String>] headers
9
- def initialize(headers: {})
10
- @headers = {}
11
- headers.each_pair do |key, value|
12
- self[key] = value
13
- end
14
- end
15
-
16
- # @param [String] key
17
- def [](key)
18
- @headers[normalize(key)]
19
- end
20
-
21
- # @param [String] key
22
- # @param [String] value
23
- def []=(key, value)
24
- @headers[normalize(key)] = value.to_s
25
- end
26
-
27
- # @param [String] key
28
- # @return [Boolean] Returns `true` if there is a header with
29
- # the given key.
30
- def key?(key)
31
- @headers.key?(normalize(key))
32
- end
33
-
34
- # @return [Array<String>]
35
- def keys
36
- @headers.keys
37
- end
38
-
39
- # @param [String] key
40
- # @return [String, nil] Returns the value for the deleted key.
41
- def delete(key)
42
- @headers.delete(normalize(key))
43
- end
44
-
45
- # @return [Enumerable<String,String>]
46
- def each_pair(&block)
47
- @headers.each(&block)
48
- end
49
- alias each each_pair
50
-
51
- # @return [Hash]
52
- def to_hash
53
- @headers.dup
54
- end
55
- alias to_h to_hash
56
-
57
- # @return [Integer] Returns the number of entries in the headers
58
- # hash.
59
- def size
60
- @headers.size
61
- end
62
-
63
- private
64
-
65
- def normalize(key)
66
- key.to_s.gsub(/[^-]+/, &:capitalize)
67
- end
68
- end
69
- end
70
- end
@@ -1,24 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Hearth
4
- module Middleware
5
- # A class used to register middleware around a request.
6
- # @api private
7
- class AroundHandler
8
- # @param [Class] app The next middleware in the stack.
9
- # @param [Proc] handler A proc object that is called around the request.
10
- # The proc must return the next middleware.
11
- def initialize(app, handler:)
12
- @app = app
13
- @handler = handler
14
- end
15
-
16
- # @param input
17
- # @param context
18
- # @return [Output]
19
- def call(input, context)
20
- @handler.call(@app, input, context)
21
- end
22
- end
23
- end
24
- end
@@ -1,24 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Hearth
4
- module Middleware
5
- # A class used to register middleware before a request is sent.
6
- # @api private
7
- class RequestHandler
8
- # @param [Class] app The next middleware in the stack.
9
- # @param [Proc] handler A proc object that is called before the request.
10
- def initialize(app, handler:)
11
- @app = app
12
- @handler = handler
13
- end
14
-
15
- # @param input
16
- # @param context
17
- # @return [Output]
18
- def call(input, context)
19
- @handler.call(input, context)
20
- @app.call(input, context)
21
- end
22
- end
23
- end
24
- end
@@ -1,25 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Hearth
4
- module Middleware
5
- # A class used to register middleware after a request is sent.
6
- # @api private
7
- class ResponseHandler
8
- # @param [Class] app The next middleware in the stack.
9
- # @param [Proc] handler A proc object that is called after the request.
10
- def initialize(app, handler:)
11
- @app = app
12
- @handler = handler
13
- end
14
-
15
- # @param input
16
- # @param context
17
- # @return [Output]
18
- def call(input, context)
19
- output = @app.call(input, context)
20
- @handler.call(output, context)
21
- output
22
- end
23
- end
24
- end
25
- end
@@ -1,246 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Hearth
4
- # A utility class for registering middleware for a request.
5
- # You register middleware handlers to execute relative to
6
- # Middleware classes. You can register middleware
7
- # before/after/around any middleware class in the stack.
8
- # You may also remove middleware from the stack.
9
- # There are also convenience methods
10
- # (eg: before_build, after_parse, ect)
11
- # defined for all of the key request lifecycle events:
12
- #
13
- # * validate
14
- # * host_prefix
15
- # * build
16
- # * send
17
- # * parse
18
- # * retry
19
- #
20
- # You can register request handlers that invoke before, after,
21
- # or around each lifecycle events. These handlers are
22
- # request, response, or around handlers.
23
- #
24
- # All before/after/around methods are defined on the class
25
- # and instance and are chainable:
26
- #
27
- # MiddlewareBuilder.before_send(my_request_handler)
28
- # .after_parse(my_response_handler)
29
- #
30
- # ## Request Handlers
31
- #
32
- # A request handler is invoked before the request is sent.
33
- #
34
- # # invoked after a request has been built, but before it has
35
- # # been signed/authorized
36
- # middleware.before_build do |input, context|
37
- # # use input, inspect or modify the request
38
- # # context.request
39
- # end
40
- #
41
- # ## Response Handlers
42
- #
43
- # A response handler is invoked after the HTTP request has been sent
44
- # and a HTTP response has been received.
45
- #
46
- # # invoked after the HTTP response has been parsed
47
- # middleware.after_parse do |output, context|
48
- # # inspect or modify the output or context
49
- # # output.data
50
- # # output.error
51
- # # context.response
52
- # end
53
- #
54
- # ## Around Handlers
55
- #
56
- # Around handlers see a request before it has been sent along
57
- # with the response returned. Around handlers must invoke `#call`
58
- # method of the next middleware in the stack. Around handlers
59
- # must also return the response returned from the next middleware.
60
- #
61
- # # invoke before the request has been sent, receives the
62
- # # response from the send middleware
63
- # middleware.around_send do |app, input, context|
64
- #
65
- # # this code is invoked before the request is sent
66
- # # ...
67
- #
68
- # # around handlers MUST call the next middleware in the stack
69
- # output = app.call(input, context)
70
- #
71
- # # this code is invoked after the response has been received
72
- # # ...
73
- #
74
- # # around handlers must return the response down the stack
75
- # output
76
- # end
77
- #
78
- # ## Removing Middleware
79
- # You may remove existing middleware from the stack using either the class
80
- # or instance `remove` methods and providing the middleware class to
81
- # be removed. The remove methods are chainable and convenience methods are
82
- # defined for the same set of lifecycle events as the `before`, `after`
83
- # and `around` methods:
84
- #
85
- # # create a middleware builder that removes send and build middlewares
86
- # MiddlewareBuilder
87
- # .remove_send
88
- # .remove_build
89
- #
90
- class MiddlewareBuilder
91
- # @private
92
- BOTH = 'expected a handler or a Proc, got both'
93
-
94
- # @private
95
- NEITHER = 'expected a handler or a Proc, got neither'
96
-
97
- # @private
98
- TOO_MANY = 'wrong number of arguments (given %<count>d, expected 0 or 1)'
99
-
100
- # @private
101
- CALLABLE = 'expected handler to respond to #call'
102
-
103
- # @param [Proc, MiddlewareBuilder] middleware
104
- #
105
- # If `middleware` is another {MiddlewareBuilder} instance, then
106
- # the middleware handlers are copied.
107
- #
108
- def initialize(middleware = nil)
109
- @middleware = []
110
- case middleware
111
- when MiddlewareBuilder then @middleware.concat(middleware.to_a)
112
- when nil then nil
113
- else
114
- raise ArgumentError, 'expected :middleware to be a' \
115
- 'Hearth::MiddlewareBuilder,' \
116
- " got #{middleware.class}"
117
- end
118
- end
119
-
120
- # @param [MiddlewareStack] middleware_stack
121
- def apply(middleware_stack)
122
- @middleware.each do |handler|
123
- method, relation, middleware, kwargs = handler
124
- if method == :remove
125
- middleware_stack.remove(relation)
126
- else
127
- middleware_stack.send(method, relation, middleware, **kwargs)
128
- end
129
- end
130
- end
131
-
132
- def before(klass, *args, &block)
133
- @middleware << [
134
- :use_before,
135
- klass,
136
- Middleware::RequestHandler,
137
- { handler: handler_or_proc!(args, &block) }
138
- ]
139
- self
140
- end
141
-
142
- def after(klass, *args, &block)
143
- @middleware << [
144
- :use_before,
145
- klass,
146
- Middleware::ResponseHandler,
147
- { handler: handler_or_proc!(args, &block) }
148
- ]
149
- self
150
- end
151
-
152
- def around(klass, *args, &block)
153
- @middleware << [
154
- :use_before,
155
- klass,
156
- Middleware::AroundHandler,
157
- { handler: handler_or_proc!(args, &block) }
158
- ]
159
- self
160
- end
161
-
162
- def remove(klass)
163
- @middleware << [
164
- :remove,
165
- klass,
166
- nil,
167
- nil
168
- ]
169
- self
170
- end
171
-
172
- # Define convenience methods for chaining
173
- class << self
174
- def before(klass, *args, &block)
175
- MiddlewareBuilder.new.before(klass, *args, &block)
176
- end
177
-
178
- def after(klass, *args, &block)
179
- MiddlewareBuilder.new.after(klass, *args, &block)
180
- end
181
-
182
- def around(klass, *args, &block)
183
- MiddlewareBuilder.new.around(klass, *args, &block)
184
- end
185
-
186
- def remove(klass)
187
- MiddlewareBuilder.new.remove(klass)
188
- end
189
- end
190
-
191
- # define convenience methods for standard middleware classes
192
- # these define methods and class methods for before,after,around
193
- # eg: before_build, after_build, around_build.
194
- STANDARD_MIDDLEWARE = [
195
- Hearth::Middleware::Validate,
196
- Hearth::Middleware::HostPrefix,
197
- Hearth::Middleware::Build,
198
- Hearth::Middleware::Send,
199
- Hearth::Middleware::Retry,
200
- Hearth::Middleware::Parse
201
- ].freeze
202
-
203
- STANDARD_MIDDLEWARE.each do |klass|
204
- simple_step_name = klass.to_s.split('::').last.downcase
205
- %w[before after around].each do |method|
206
- method_name = "#{method}_#{simple_step_name}"
207
- define_method(method_name) do |*args, &block|
208
- return send(method, klass, *args, &block)
209
- end
210
-
211
- define_singleton_method(method_name) do |*args, &block|
212
- return send(method, klass, *args, &block)
213
- end
214
- end
215
-
216
- remove_method_name = "remove_#{simple_step_name}"
217
- define_method(remove_method_name) do
218
- return remove(klass)
219
- end
220
-
221
- define_singleton_method(remove_method_name) do
222
- return remove(klass)
223
- end
224
- end
225
-
226
- def to_a
227
- @middleware
228
- end
229
-
230
- private
231
-
232
- def handler_or_proc!(args, &block)
233
- validate_args!(args, &block)
234
- callable = args.first || Proc.new(&block)
235
- raise ArgumentError, CALLABLE unless callable.respond_to?(:call)
236
-
237
- callable
238
- end
239
-
240
- def validate_args!(args, &block)
241
- raise ArgumentError, BOTH if args.size.positive? && block
242
- raise ArgumentError, NEITHER if args.empty? && block.nil?
243
- raise ArgumentError, format(TOO_MANY, count: args.size) if args.size > 1
244
- end
245
- end
246
- end