s33r 0.4.2 → 0.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (114) hide show
  1. data/examples/cli/instant_download_server.rb +88 -0
  2. data/examples/cli/s3cli.rb +31 -52
  3. data/examples/cli/simple.rb +16 -6
  4. data/examples/fores33r/app/controllers/browser_controller.rb +12 -10
  5. data/examples/fores33r/app/helpers/application_helper.rb +2 -1
  6. data/examples/fores33r/app/views/browser/_upload.rhtml +1 -1
  7. data/examples/fores33r/app/views/browser/index.rhtml +4 -4
  8. data/examples/fores33r/config/environment.rb +5 -3
  9. data/examples/fores33r/log/development.log +2259 -0
  10. data/examples/fores33r/log/mongrel.log +59 -0
  11. data/examples/s3.yaml +2 -6
  12. data/lib/s33r/bucket.rb +103 -0
  13. data/lib/s33r/bucket_listing.rb +33 -76
  14. data/lib/s33r/client.rb +305 -446
  15. data/lib/s33r/networking.rb +197 -0
  16. data/lib/s33r/s33r_exception.rb +29 -18
  17. data/lib/s33r/s33r_http.rb +36 -18
  18. data/lib/s33r/s3_acl.rb +32 -52
  19. data/lib/s33r/s3_logging.rb +117 -0
  20. data/lib/s33r/s3_obj.rb +124 -69
  21. data/lib/s33r/utility.rb +447 -0
  22. data/test/cases/spec_acl.rb +10 -40
  23. data/test/cases/spec_bucket_listing.rb +12 -32
  24. data/test/cases/spec_logging.rb +47 -0
  25. data/test/cases/spec_networking.rb +11 -0
  26. data/test/cases/spec_s3_object.rb +44 -5
  27. data/test/cases/spec_utility.rb +264 -0
  28. data/test/files/acl.xml +0 -6
  29. data/test/files/config.yaml +5 -0
  30. data/test/files/logging_status_disabled.xml +3 -0
  31. data/test/files/logging_status_enabled.xml +7 -0
  32. data/test/test_setup.rb +7 -2
  33. metadata +16 -94
  34. data/examples/cli/acl_x.rb +0 -41
  35. data/examples/cli/logging_x.rb +0 -20
  36. data/examples/fores33r/README +0 -183
  37. data/html/classes/MIME.html +0 -120
  38. data/html/classes/MIME/InvalidContentType.html +0 -119
  39. data/html/classes/MIME/Type.html +0 -1173
  40. data/html/classes/MIME/Types.html +0 -566
  41. data/html/classes/Net.html +0 -108
  42. data/html/classes/Net/HTTPGenericRequest.html +0 -233
  43. data/html/classes/Net/HTTPResponse.html +0 -271
  44. data/html/classes/S33r.html +0 -986
  45. data/html/classes/S33r/BucketListing.html +0 -434
  46. data/html/classes/S33r/Client.html +0 -1575
  47. data/html/classes/S33r/LoggingResource.html +0 -222
  48. data/html/classes/S33r/NamedBucket.html +0 -693
  49. data/html/classes/S33r/OrderlyXmlMarkup.html +0 -165
  50. data/html/classes/S33r/S33rException.html +0 -124
  51. data/html/classes/S33r/S33rException/BucketListingMaxKeysError.html +0 -111
  52. data/html/classes/S33r/S33rException/BucketNotLogTargetable.html +0 -119
  53. data/html/classes/S33r/S33rException/InvalidBucketListing.html +0 -111
  54. data/html/classes/S33r/S33rException/InvalidPermission.html +0 -111
  55. data/html/classes/S33r/S33rException/InvalidS3GroupType.html +0 -111
  56. data/html/classes/S33r/S33rException/MalformedBucketName.html +0 -111
  57. data/html/classes/S33r/S33rException/MethodNotAvailable.html +0 -111
  58. data/html/classes/S33r/S33rException/MissingBucketName.html +0 -111
  59. data/html/classes/S33r/S33rException/MissingRequiredHeaders.html +0 -111
  60. data/html/classes/S33r/S33rException/MissingResource.html +0 -111
  61. data/html/classes/S33r/S33rException/S3FallenOver.html +0 -111
  62. data/html/classes/S33r/S33rException/TryingToPutEmptyResource.html +0 -117
  63. data/html/classes/S33r/S33rException/UnsupportedCannedACL.html +0 -111
  64. data/html/classes/S33r/S33rException/UnsupportedHTTPMethod.html +0 -111
  65. data/html/classes/S33r/S3ACL.html +0 -125
  66. data/html/classes/S33r/S3ACL/ACLDoc.html +0 -521
  67. data/html/classes/S33r/S3ACL/AmazonCustomer.html +0 -168
  68. data/html/classes/S33r/S3ACL/CanonicalUser.html +0 -212
  69. data/html/classes/S33r/S3ACL/Grant.html +0 -403
  70. data/html/classes/S33r/S3ACL/Grantee.html +0 -239
  71. data/html/classes/S33r/S3ACL/Group.html +0 -178
  72. data/html/classes/S33r/S3Object.html +0 -618
  73. data/html/classes/S33r/Sync.html +0 -152
  74. data/html/classes/XML.html +0 -202
  75. data/html/classes/XML/Document.html +0 -125
  76. data/html/classes/XML/Node.html +0 -124
  77. data/html/created.rid +0 -1
  78. data/html/files/CHANGELOG.html +0 -107
  79. data/html/files/MIT-LICENSE.html +0 -129
  80. data/html/files/README_txt.html +0 -259
  81. data/html/files/lib/s33r/bucket_listing_rb.html +0 -101
  82. data/html/files/lib/s33r/builder_rb.html +0 -108
  83. data/html/files/lib/s33r/client_rb.html +0 -111
  84. data/html/files/lib/s33r/core_rb.html +0 -113
  85. data/html/files/lib/s33r/libxml_extensions_rb.html +0 -101
  86. data/html/files/lib/s33r/libxml_loader_rb.html +0 -109
  87. data/html/files/lib/s33r/logging_rb.html +0 -108
  88. data/html/files/lib/s33r/mimetypes_rb.html +0 -120
  89. data/html/files/lib/s33r/named_bucket_rb.html +0 -101
  90. data/html/files/lib/s33r/s33r_exception_rb.html +0 -101
  91. data/html/files/lib/s33r/s33r_http_rb.html +0 -108
  92. data/html/files/lib/s33r/s3_acl_rb.html +0 -108
  93. data/html/files/lib/s33r/s3_obj_rb.html +0 -108
  94. data/html/files/lib/s33r/sync_rb.html +0 -101
  95. data/html/files/lib/s33r_rb.html +0 -101
  96. data/html/fr_class_index.html +0 -66
  97. data/html/fr_file_index.html +0 -44
  98. data/html/fr_method_index.html +0 -183
  99. data/html/index.html +0 -24
  100. data/html/rdoc-style.css +0 -208
  101. data/lib/s33r/core.rb +0 -296
  102. data/lib/s33r/logging.rb +0 -43
  103. data/lib/s33r/named_bucket.rb +0 -148
  104. data/lib/s33r/sync.rb +0 -13
  105. data/test/cases/spec_all_buckets.rb +0 -28
  106. data/test/cases/spec_client.rb +0 -101
  107. data/test/cases/spec_core.rb +0 -128
  108. data/test/cases/spec_namedbucket.rb +0 -46
  109. data/test/cases/spec_sync.rb +0 -34
  110. data/test/files/all_buckets.xml +0 -21
  111. data/test/files/client_config.yml +0 -5
  112. data/test/files/namedbucket_config.yml +0 -8
  113. data/test/files/namedbucket_config2.yml +0 -8
  114. data/test/test_bucket_setup.rb +0 -41
@@ -1,434 +0,0 @@
1
- <?xml version="1.0" encoding="iso-8859-1"?>
2
- <!DOCTYPE html
3
- PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
4
- "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
5
-
6
- <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
7
- <head>
8
- <title>Class: S33r::BucketListing</title>
9
- <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
10
- <meta http-equiv="Content-Script-Type" content="text/javascript" />
11
- <link rel="stylesheet" href="../.././rdoc-style.css" type="text/css" media="screen" />
12
- <script type="text/javascript">
13
- // <![CDATA[
14
-
15
- function popupCode( url ) {
16
- window.open(url, "Code", "resizable=yes,scrollbars=yes,toolbar=no,status=no,height=150,width=400")
17
- }
18
-
19
- function toggleCode( id ) {
20
- if ( document.getElementById )
21
- elem = document.getElementById( id );
22
- else if ( document.all )
23
- elem = eval( "document.all." + id );
24
- else
25
- return false;
26
-
27
- elemStyle = elem.style;
28
-
29
- if ( elemStyle.display != "block" ) {
30
- elemStyle.display = "block"
31
- } else {
32
- elemStyle.display = "none"
33
- }
34
-
35
- return true;
36
- }
37
-
38
- // Make codeblocks hidden by default
39
- document.writeln( "<style type=\"text/css\">div.method-source-code { display: none }</style>" )
40
-
41
- // ]]>
42
- </script>
43
-
44
- </head>
45
- <body>
46
-
47
-
48
-
49
- <div id="classHeader">
50
- <table class="header-table">
51
- <tr class="top-aligned-row">
52
- <td><strong>Class</strong></td>
53
- <td class="class-name-in-header">S33r::BucketListing</td>
54
- </tr>
55
- <tr class="top-aligned-row">
56
- <td><strong>In:</strong></td>
57
- <td>
58
- <a href="../../files/lib/s33r/bucket_listing_rb.html">
59
- lib/s33r/bucket_listing.rb
60
- </a>
61
- <br />
62
- </td>
63
- </tr>
64
-
65
- <tr class="top-aligned-row">
66
- <td><strong>Parent:</strong></td>
67
- <td>
68
- Object
69
- </td>
70
- </tr>
71
- </table>
72
- </div>
73
- <!-- banner header -->
74
-
75
- <div id="bodyContent">
76
-
77
-
78
-
79
- <div id="contextContent">
80
-
81
- <div id="description">
82
- <p>
83
- Object representation of the content of a bucket.
84
- </p>
85
-
86
- </div>
87
-
88
-
89
- </div>
90
-
91
- <div id="method-list">
92
- <h3 class="section-bar">Methods</h3>
93
-
94
- <div class="name-list">
95
- <a href="#M000155">[]</a>&nbsp;&nbsp;
96
- <a href="#M000154">last_key</a>&nbsp;&nbsp;
97
- <a href="#M000151">new</a>&nbsp;&nbsp;
98
- <a href="#M000153">parse_listing</a>&nbsp;&nbsp;
99
- <a href="#M000156">pretty</a>&nbsp;&nbsp;
100
- <a href="#M000152">set_listing_xml</a>&nbsp;&nbsp;
101
- </div>
102
- </div>
103
-
104
- </div>
105
-
106
-
107
- <!-- if includes -->
108
-
109
- <div id="section">
110
-
111
-
112
-
113
-
114
-
115
- <div id="attribute-list">
116
- <h3 class="section-bar">Attributes</h3>
117
-
118
- <div class="name-list">
119
- <table>
120
- <tr class="top-aligned-row context-row">
121
- <td class="context-item-name">common_prefixes</td>
122
- <td class="context-item-value">&nbsp;[R]&nbsp;</td>
123
- <td class="context-item-desc"></td>
124
- </tr>
125
- <tr class="top-aligned-row context-row">
126
- <td class="context-item-name">contents</td>
127
- <td class="context-item-value">&nbsp;[R]&nbsp;</td>
128
- <td class="context-item-desc">
129
- Hash of objects in this bucket, keyed by their S3 keys.
130
-
131
- </td>
132
- </tr>
133
- <tr class="top-aligned-row context-row">
134
- <td class="context-item-name">delimiter</td>
135
- <td class="context-item-value">&nbsp;[R]&nbsp;</td>
136
- <td class="context-item-desc"></td>
137
- </tr>
138
- <tr class="top-aligned-row context-row">
139
- <td class="context-item-name">is_truncated</td>
140
- <td class="context-item-value">&nbsp;[R]&nbsp;</td>
141
- <td class="context-item-desc"></td>
142
- </tr>
143
- <tr class="top-aligned-row context-row">
144
- <td class="context-item-name">last_key</td>
145
- <td class="context-item-value">&nbsp;[R]&nbsp;</td>
146
- <td class="context-item-desc">
147
- The last key listed in this <a href="BucketListing.html">BucketListing</a>.
148
-
149
- </td>
150
- </tr>
151
- <tr class="top-aligned-row context-row">
152
- <td class="context-item-name">marker</td>
153
- <td class="context-item-value">&nbsp;[R]&nbsp;</td>
154
- <td class="context-item-desc"></td>
155
- </tr>
156
- <tr class="top-aligned-row context-row">
157
- <td class="context-item-name">max_keys</td>
158
- <td class="context-item-value">&nbsp;[R]&nbsp;</td>
159
- <td class="context-item-desc"></td>
160
- </tr>
161
- <tr class="top-aligned-row context-row">
162
- <td class="context-item-name">name</td>
163
- <td class="context-item-value">&nbsp;[R]&nbsp;</td>
164
- <td class="context-item-desc">
165
- Name of the bucket this listing is for.
166
-
167
- </td>
168
- </tr>
169
- <tr class="top-aligned-row context-row">
170
- <td class="context-item-name">named_bucket</td>
171
- <td class="context-item-value">&nbsp;[RW]&nbsp;</td>
172
- <td class="context-item-desc">
173
- A <a href="NamedBucket.html">NamedBucket</a> instance associated with this
174
- listing.
175
-
176
- </td>
177
- </tr>
178
- <tr class="top-aligned-row context-row">
179
- <td class="context-item-name">prefix</td>
180
- <td class="context-item-value">&nbsp;[R]&nbsp;</td>
181
- <td class="context-item-desc"></td>
182
- </tr>
183
- <tr class="top-aligned-row context-row">
184
- <td class="context-item-name">raw</td>
185
- <td class="context-item-value">&nbsp;[RW]&nbsp;</td>
186
- <td class="context-item-desc">
187
- Set to true to show raw parsing errors, instead of the catch all error
188
- message (useful for debugging).
189
-
190
- </td>
191
- </tr>
192
- </table>
193
- </div>
194
- </div>
195
-
196
-
197
-
198
- <!-- if method_list -->
199
- <div id="methods">
200
- <h3 class="section-bar">Public Class methods</h3>
201
-
202
- <div id="method-M000151" class="method-detail">
203
- <a name="M000151"></a>
204
-
205
- <div class="method-heading">
206
- <a href="#M000151" class="method-signature">
207
- <span class="method-name">new</span><span class="method-args">(bucket_listing_xml, named_bucket=nil, raw=false)</span>
208
- </a>
209
- </div>
210
-
211
- <div class="method-description">
212
- <p>
213
- Create a new object representing a ListBucketResult.
214
- </p>
215
- <p>
216
- <tt>bucket_listing_xml</tt> is a ListBucketResult document, as returned
217
- from a GET on a bucket (see <a
218
- href="http://docs.amazonwebservices.com/AmazonS3/2006-03-01">docs.amazonwebservices.com/AmazonS3/2006-03-01</a>/).
219
- </p>
220
- <p>
221
- <tt>named_bucket</tt> can be set to an existing <a
222
- href="NamedBucket.html">NamedBucket</a> instance, so that any objects
223
- inside this listing can be associated with that instance. This enables
224
- objects to be easily deleted without having to create a new <a
225
- href="Client.html">Client</a> instance.
226
- </p>
227
- <p>
228
- If <tt>raw</tt> is set to true, you get ugly parser errors.
229
- </p>
230
- <p><a class="source-toggle" href="#"
231
- onclick="toggleCode('M000151-source');return false;">[Source]</a></p>
232
- <div class="method-source-code" id="M000151-source">
233
- <pre>
234
- <span class="ruby-comment cmt"># File lib/s33r/bucket_listing.rb, line 32</span>
235
- 32: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">initialize</span>(<span class="ruby-identifier">bucket_listing_xml</span>, <span class="ruby-identifier">named_bucket</span>=<span class="ruby-keyword kw">nil</span>, <span class="ruby-identifier">raw</span>=<span class="ruby-keyword kw">false</span>)
236
- 33: <span class="ruby-ivar">@contents</span> = {}
237
- 34: <span class="ruby-ivar">@common_prefixes</span> = {}
238
- 35: <span class="ruby-comment cmt"># the NamedBucket instance associated with this listing (if any)</span>
239
- 36: <span class="ruby-ivar">@named_bucket</span> = <span class="ruby-identifier">named_bucket</span>
240
- 37: <span class="ruby-ivar">@raw</span> = <span class="ruby-identifier">raw</span>
241
- 38: <span class="ruby-identifier">set_listing_xml</span>(<span class="ruby-identifier">bucket_listing_xml</span>)
242
- 39: <span class="ruby-keyword kw">end</span>
243
- </pre>
244
- </div>
245
- </div>
246
- </div>
247
-
248
- <h3 class="section-bar">Public Instance methods</h3>
249
-
250
- <div id="method-M000155" class="method-detail">
251
- <a name="M000155"></a>
252
-
253
- <div class="method-heading">
254
- <a href="#M000155" class="method-signature">
255
- <span class="method-name">[]</span><span class="method-args">(key)</span>
256
- </a>
257
- </div>
258
-
259
- <div class="method-description">
260
- <p>
261
- Return an object in this bucket by key.
262
- </p>
263
- <p><a class="source-toggle" href="#"
264
- onclick="toggleCode('M000155-source');return false;">[Source]</a></p>
265
- <div class="method-source-code" id="M000155-source">
266
- <pre>
267
- <span class="ruby-comment cmt"># File lib/s33r/bucket_listing.rb, line 98</span>
268
- 98: <span class="ruby-keyword kw">def</span> <span class="ruby-operator">[]</span>(<span class="ruby-identifier">key</span>)
269
- 99: <span class="ruby-ivar">@contents</span>[<span class="ruby-identifier">key</span>]
270
- 100: <span class="ruby-keyword kw">end</span>
271
- </pre>
272
- </div>
273
- </div>
274
- </div>
275
-
276
- <div id="method-M000154" class="method-detail">
277
- <a name="M000154"></a>
278
-
279
- <div class="method-heading">
280
- <a href="#M000154" class="method-signature">
281
- <span class="method-name">last_key</span><span class="method-args">()</span>
282
- </a>
283
- </div>
284
-
285
- <div class="method-description">
286
- <p>
287
- Get the last key in the contents hash.
288
- </p>
289
- <p><a class="source-toggle" href="#"
290
- onclick="toggleCode('M000154-source');return false;">[Source]</a></p>
291
- <div class="method-source-code" id="M000154-source">
292
- <pre>
293
- <span class="ruby-comment cmt"># File lib/s33r/bucket_listing.rb, line 93</span>
294
- 93: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">last_key</span>
295
- 94: <span class="ruby-ivar">@contents</span>.<span class="ruby-identifier">keys</span>.<span class="ruby-identifier">last</span>
296
- 95: <span class="ruby-keyword kw">end</span>
297
- </pre>
298
- </div>
299
- </div>
300
- </div>
301
-
302
- <div id="method-M000153" class="method-detail">
303
- <a name="M000153"></a>
304
-
305
- <div class="method-heading">
306
- <a href="#M000153" class="method-signature">
307
- <span class="method-name">parse_listing</span><span class="method-args">(bucket_listing_xml)</span>
308
- </a>
309
- </div>
310
-
311
- <div class="method-description">
312
- <p>
313
- Parse raw <a href="../XML.html">XML</a> ListBucketResponse from S3 into
314
- object instances. The S3Objects are skeletons, and are not automatically
315
- populated from S3 (their @value attributes are nil). To load the data into
316
- an object, grab it from the listing and call its load method to pull the
317
- data down from S3.
318
- </p>
319
- <p><a class="source-toggle" href="#"
320
- onclick="toggleCode('M000153-source');return false;">[Source]</a></p>
321
- <div class="method-source-code" id="M000153-source">
322
- <pre>
323
- <span class="ruby-comment cmt"># File lib/s33r/bucket_listing.rb, line 68</span>
324
- 68: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">parse_listing</span>(<span class="ruby-identifier">bucket_listing_xml</span>)
325
- 69: <span class="ruby-identifier">doc</span> = <span class="ruby-constant">XML</span>.<span class="ruby-identifier">get_xml_doc</span>(<span class="ruby-identifier">bucket_listing_xml</span>)
326
- 70:
327
- 71: <span class="ruby-identifier">prop_setter</span> = <span class="ruby-identifier">lambda</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">prop</span>, <span class="ruby-identifier">path</span><span class="ruby-operator">|</span>
328
- 72: <span class="ruby-identifier">node</span> = <span class="ruby-identifier">doc</span>.<span class="ruby-identifier">find</span>(<span class="ruby-node">&quot;//ListBucketResult/#{path}&quot;</span>).<span class="ruby-identifier">to_a</span>.<span class="ruby-identifier">first</span>
329
- 73: <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">send</span>(<span class="ruby-node">&quot;#{prop}=&quot;</span>, <span class="ruby-identifier">node</span>.<span class="ruby-identifier">content</span>) <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">node</span>
330
- 74: <span class="ruby-keyword kw">end</span>
331
- 75:
332
- 76: <span class="ruby-comment cmt"># metadata</span>
333
- 77: <span class="ruby-identifier">prop_setter</span>.<span class="ruby-identifier">call</span>(<span class="ruby-identifier">:name</span>, <span class="ruby-value str">'Name'</span>)
334
- 78: <span class="ruby-identifier">prop_setter</span>.<span class="ruby-identifier">call</span>(<span class="ruby-identifier">:delimiter</span>, <span class="ruby-value str">'Delimiter'</span>)
335
- 79: <span class="ruby-identifier">prop_setter</span>.<span class="ruby-identifier">call</span>(<span class="ruby-identifier">:prefix</span>, <span class="ruby-value str">'Prefix'</span>)
336
- 80: <span class="ruby-identifier">prop_setter</span>.<span class="ruby-identifier">call</span>(<span class="ruby-identifier">:marker</span>, <span class="ruby-value str">'Marker'</span>)
337
- 81: <span class="ruby-identifier">prop_setter</span>.<span class="ruby-identifier">call</span>(<span class="ruby-identifier">:max_keys</span>, <span class="ruby-value str">'MaxKeys'</span>)
338
- 82: <span class="ruby-identifier">prop_setter</span>.<span class="ruby-identifier">call</span>(<span class="ruby-identifier">:is_truncated</span>, <span class="ruby-value str">'IsTruncated'</span>)
339
- 83:
340
- 84: <span class="ruby-comment cmt"># contents</span>
341
- 85: <span class="ruby-identifier">doc</span>.<span class="ruby-identifier">find</span>(<span class="ruby-value str">'//Contents'</span>).<span class="ruby-identifier">to_a</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">node</span><span class="ruby-operator">|</span>
342
- 86: <span class="ruby-identifier">obj</span> = <span class="ruby-constant">S3Object</span>.<span class="ruby-identifier">from_xml_node</span>(<span class="ruby-identifier">node</span>)
343
- 87: <span class="ruby-comment cmt"># Add to the content listing for the bucket</span>
344
- 88: <span class="ruby-ivar">@contents</span>[<span class="ruby-identifier">obj</span>.<span class="ruby-identifier">key</span>] = <span class="ruby-identifier">obj</span>
345
- 89: <span class="ruby-keyword kw">end</span>
346
- 90: <span class="ruby-keyword kw">end</span>
347
- </pre>
348
- </div>
349
- </div>
350
- </div>
351
-
352
- <div id="method-M000156" class="method-detail">
353
- <a name="M000156"></a>
354
-
355
- <div class="method-heading">
356
- <a href="#M000156" class="method-signature">
357
- <span class="method-name">pretty</span><span class="method-args">()</span>
358
- </a>
359
- </div>
360
-
361
- <div class="method-description">
362
- <p>
363
- Pretty listing of keys in alphabetical order.
364
- </p>
365
- <p><a class="source-toggle" href="#"
366
- onclick="toggleCode('M000156-source');return false;">[Source]</a></p>
367
- <div class="method-source-code" id="M000156-source">
368
- <pre>
369
- <span class="ruby-comment cmt"># File lib/s33r/bucket_listing.rb, line 103</span>
370
- 103: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">pretty</span>
371
- 104: <span class="ruby-ivar">@contents</span>.<span class="ruby-identifier">keys</span>.<span class="ruby-identifier">sort</span>.<span class="ruby-identifier">each</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">k</span><span class="ruby-operator">|</span> <span class="ruby-identifier">puts</span> <span class="ruby-identifier">k</span> }
372
- 105: <span class="ruby-keyword kw">end</span>
373
- </pre>
374
- </div>
375
- </div>
376
- </div>
377
-
378
- <div id="method-M000152" class="method-detail">
379
- <a name="M000152"></a>
380
-
381
- <div class="method-heading">
382
- <a href="#M000152" class="method-signature">
383
- <span class="method-name">set_listing_xml</span><span class="method-args">(bucket_listing_xml)</span>
384
- </a>
385
- </div>
386
-
387
- <div class="method-description">
388
- <p>
389
- Convert a ListBucketResult <a href="../XML.html">XML</a> document into an
390
- object representation.
391
- </p>
392
- <p><a class="source-toggle" href="#"
393
- onclick="toggleCode('M000152-source');return false;">[Source]</a></p>
394
- <div class="method-source-code" id="M000152-source">
395
- <pre>
396
- <span class="ruby-comment cmt"># File lib/s33r/bucket_listing.rb, line 42</span>
397
- 42: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">set_listing_xml</span>(<span class="ruby-identifier">bucket_listing_xml</span>)
398
- 43: <span class="ruby-comment cmt"># proc to remove the namespace and parse the listing</span>
399
- 44: <span class="ruby-identifier">work</span> = <span class="ruby-identifier">lambda</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">bucket_listing_xml</span><span class="ruby-operator">|</span>
400
- 45: <span class="ruby-comment cmt"># remove the namespace declaration: libxml doesn't like it</span>
401
- 46: <span class="ruby-identifier">bucket_listing_xml</span> = <span class="ruby-constant">S33r</span>.<span class="ruby-identifier">remove_namespace</span>(<span class="ruby-identifier">bucket_listing_xml</span>)
402
- 47: <span class="ruby-identifier">parse_listing</span>(<span class="ruby-identifier">bucket_listing_xml</span>)
403
- 48: <span class="ruby-keyword kw">end</span>
404
- 49:
405
- 50: <span class="ruby-keyword kw">if</span> <span class="ruby-ivar">@raw</span>
406
- 51: <span class="ruby-identifier">work</span>.<span class="ruby-identifier">call</span>(<span class="ruby-identifier">bucket_listing_xml</span>)
407
- 52: <span class="ruby-keyword kw">else</span>
408
- 53: <span class="ruby-keyword kw">begin</span>
409
- 54: <span class="ruby-identifier">work</span>.<span class="ruby-identifier">call</span>(<span class="ruby-identifier">bucket_listing_xml</span>)
410
- 55: <span class="ruby-keyword kw">rescue</span>
411
- 56: <span class="ruby-identifier">message</span> = <span class="ruby-value str">&quot;Cannot create bucket listing from supplied XML&quot;</span>
412
- 57: <span class="ruby-identifier">message</span> <span class="ruby-operator">+=</span> <span class="ruby-value str">&quot; (was nil)&quot;</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">bucket_listing_xml</span>.<span class="ruby-identifier">nil?</span>
413
- 58: <span class="ruby-identifier">raise</span> <span class="ruby-constant">S33rException</span><span class="ruby-operator">::</span><span class="ruby-constant">InvalidBucketListing</span>, <span class="ruby-identifier">message</span>
414
- 59: <span class="ruby-keyword kw">end</span>
415
- 60: <span class="ruby-keyword kw">end</span>
416
- 61: <span class="ruby-keyword kw">end</span>
417
- </pre>
418
- </div>
419
- </div>
420
- </div>
421
-
422
-
423
- </div>
424
-
425
-
426
- </div>
427
-
428
-
429
- <div id="validator-badges">
430
- <p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
431
- </div>
432
-
433
- </body>
434
- </html>
@@ -1,1575 +0,0 @@
1
- <?xml version="1.0" encoding="iso-8859-1"?>
2
- <!DOCTYPE html
3
- PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
4
- "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
5
-
6
- <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
7
- <head>
8
- <title>Class: S33r::Client</title>
9
- <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
10
- <meta http-equiv="Content-Script-Type" content="text/javascript" />
11
- <link rel="stylesheet" href="../.././rdoc-style.css" type="text/css" media="screen" />
12
- <script type="text/javascript">
13
- // <![CDATA[
14
-
15
- function popupCode( url ) {
16
- window.open(url, "Code", "resizable=yes,scrollbars=yes,toolbar=no,status=no,height=150,width=400")
17
- }
18
-
19
- function toggleCode( id ) {
20
- if ( document.getElementById )
21
- elem = document.getElementById( id );
22
- else if ( document.all )
23
- elem = eval( "document.all." + id );
24
- else
25
- return false;
26
-
27
- elemStyle = elem.style;
28
-
29
- if ( elemStyle.display != "block" ) {
30
- elemStyle.display = "block"
31
- } else {
32
- elemStyle.display = "none"
33
- }
34
-
35
- return true;
36
- }
37
-
38
- // Make codeblocks hidden by default
39
- document.writeln( "<style type=\"text/css\">div.method-source-code { display: none }</style>" )
40
-
41
- // ]]>
42
- </script>
43
-
44
- </head>
45
- <body>
46
-
47
-
48
-
49
- <div id="classHeader">
50
- <table class="header-table">
51
- <tr class="top-aligned-row">
52
- <td><strong>Class</strong></td>
53
- <td class="class-name-in-header">S33r::Client</td>
54
- </tr>
55
- <tr class="top-aligned-row">
56
- <td><strong>In:</strong></td>
57
- <td>
58
- <a href="../../files/lib/s33r/client_rb.html">
59
- lib/s33r/client.rb
60
- </a>
61
- <br />
62
- </td>
63
- </tr>
64
-
65
- <tr class="top-aligned-row">
66
- <td><strong>Parent:</strong></td>
67
- <td>
68
- Object
69
- </td>
70
- </tr>
71
- </table>
72
- </div>
73
- <!-- banner header -->
74
-
75
- <div id="bodyContent">
76
-
77
-
78
-
79
- <div id="contextContent">
80
-
81
- <div id="description">
82
- <p>
83
- The client performs operations over the network, using the core to build
84
- request headers and content; only client-specific headers are managed here:
85
- other headers can be handled by the core.
86
- </p>
87
-
88
- </div>
89
-
90
-
91
- </div>
92
-
93
- <div id="method-list">
94
- <h3 class="section-bar">Methods</h3>
95
-
96
- <div class="name-list">
97
- <a href="#M000145">add_client_headers</a>&nbsp;&nbsp;
98
- <a href="#M000126">bucket_exists?</a>&nbsp;&nbsp;
99
- <a href="#M000124">create_bucket</a>&nbsp;&nbsp;
100
- <a href="#M000125">delete_bucket</a>&nbsp;&nbsp;
101
- <a href="#M000144">delete_resource</a>&nbsp;&nbsp;
102
- <a href="#M000137">disable_log_target</a>&nbsp;&nbsp;
103
- <a href="#M000139">disable_logging</a>&nbsp;&nbsp;
104
- <a href="#M000150">do_delete</a>&nbsp;&nbsp;
105
- <a href="#M000146">do_get</a>&nbsp;&nbsp;
106
- <a href="#M000147">do_head</a>&nbsp;&nbsp;
107
- <a href="#M000148">do_post</a>&nbsp;&nbsp;
108
- <a href="#M000149">do_put</a>&nbsp;&nbsp;
109
- <a href="#M000119">do_request</a>&nbsp;&nbsp;
110
- <a href="#M000136">enable_log_target</a>&nbsp;&nbsp;
111
- <a href="#M000138">enable_logging</a>&nbsp;&nbsp;
112
- <a href="#M000131">get_acl</a>&nbsp;&nbsp;
113
- <a href="#M000116">get_client</a>&nbsp;&nbsp;
114
- <a href="#M000140">get_logging</a>&nbsp;&nbsp;
115
- <a href="#M000127">get_named_bucket</a>&nbsp;&nbsp;
116
- <a href="#M000130">get_object</a>&nbsp;&nbsp;
117
- <a href="#M000120">get_requester</a>&nbsp;&nbsp;
118
- <a href="#M000128">get_resource</a>&nbsp;&nbsp;
119
- <a href="#M000117">init</a>&nbsp;&nbsp;
120
- <a href="#M000122">list</a>&nbsp;&nbsp;
121
- <a href="#M000123">list_bucket</a>&nbsp;&nbsp;
122
- <a href="#M000121">list_buckets</a>&nbsp;&nbsp;
123
- <a href="#M000118">load_config</a>&nbsp;&nbsp;
124
- <a href="#M000135">make_private</a>&nbsp;&nbsp;
125
- <a href="#M000134">make_public</a>&nbsp;&nbsp;
126
- <a href="#M000115">new</a>&nbsp;&nbsp;
127
- <a href="#M000143">put_file</a>&nbsp;&nbsp;
128
- <a href="#M000141">put_resource</a>&nbsp;&nbsp;
129
- <a href="#M000142">put_text</a>&nbsp;&nbsp;
130
- <a href="#M000129">resource_exists?</a>&nbsp;&nbsp;
131
- <a href="#M000132">set_acl</a>&nbsp;&nbsp;
132
- <a href="#M000133">set_logging</a>&nbsp;&nbsp;
133
- </div>
134
- </div>
135
-
136
- </div>
137
-
138
-
139
- <!-- if includes -->
140
- <div id="includes">
141
- <h3 class="section-bar">Included Modules</h3>
142
-
143
- <div id="includes-list">
144
- <span class="include-name"><a href="../S33r.html">S33r</a></span>
145
- </div>
146
- </div>
147
-
148
- <div id="section">
149
-
150
-
151
-
152
-
153
-
154
- <div id="attribute-list">
155
- <h3 class="section-bar">Attributes</h3>
156
-
157
- <div class="name-list">
158
- <table>
159
- <tr class="top-aligned-row context-row">
160
- <td class="context-item-name">aws_access_key</td>
161
- <td class="context-item-value">&nbsp;[RW]&nbsp;</td>
162
- <td class="context-item-desc">
163
- S3 keys.
164
-
165
- </td>
166
- </tr>
167
- <tr class="top-aligned-row context-row">
168
- <td class="context-item-name">aws_secret_access_key</td>
169
- <td class="context-item-value">&nbsp;[RW]&nbsp;</td>
170
- <td class="context-item-desc">
171
- S3 keys.
172
-
173
- </td>
174
- </tr>
175
- <tr class="top-aligned-row context-row">
176
- <td class="context-item-name">chunk_size</td>
177
- <td class="context-item-value">&nbsp;[RW]&nbsp;</td>
178
- <td class="context-item-desc">
179
- Size of data chunk to be sent per request when putting data.
180
-
181
- </td>
182
- </tr>
183
- <tr class="top-aligned-row context-row">
184
- <td class="context-item-name">client_headers</td>
185
- <td class="context-item-value">&nbsp;[RW]&nbsp;</td>
186
- <td class="context-item-desc">
187
- Headers which should be sent with every request by default (unless
188
- overridden).
189
-
190
- </td>
191
- </tr>
192
- <tr class="top-aligned-row context-row">
193
- <td class="context-item-name">dump_requests</td>
194
- <td class="context-item-value">&nbsp;[RW]&nbsp;</td>
195
- <td class="context-item-desc">
196
- Whether client dumps headers from requests.
197
-
198
- </td>
199
- </tr>
200
- <tr class="top-aligned-row context-row">
201
- <td class="context-item-name">log_bucket</td>
202
- <td class="context-item-value">&nbsp;[RW]&nbsp;</td>
203
- <td class="context-item-desc">
204
- Default log bucket location.
205
-
206
- </td>
207
- </tr>
208
- <tr class="top-aligned-row context-row">
209
- <td class="context-item-name">options</td>
210
- <td class="context-item-value">&nbsp;[R]&nbsp;</td>
211
- <td class="context-item-desc">
212
- The options used to create the client (useful when spawning <a
213
- href="NamedBucket.html">NamedBucket</a> instances from <a
214
- href="Client.html">Client</a> instances).
215
-
216
- </td>
217
- </tr>
218
- <tr class="top-aligned-row context-row">
219
- <td class="context-item-name">use_ssl</td>
220
- <td class="context-item-value">&nbsp;[RW]&nbsp;</td>
221
- <td class="context-item-desc">
222
- Whether client should use SSL.
223
-
224
- </td>
225
- </tr>
226
- </table>
227
- </div>
228
- </div>
229
-
230
-
231
-
232
- <!-- if method_list -->
233
- <div id="methods">
234
- <h3 class="section-bar">Public Class methods</h3>
235
-
236
- <div id="method-M000117" class="method-detail">
237
- <a name="M000117"></a>
238
-
239
- <div class="method-heading">
240
- <a href="#M000117" class="method-signature">
241
- <span class="method-name">init</span><span class="method-args">(config_file)</span>
242
- </a>
243
- </div>
244
-
245
- <div class="method-description">
246
- <p>
247
- Initialise client from YAML configuration file (see <a
248
- href="Client.html#M000118">load_config</a> method for details of acceptable
249
- format).
250
- </p>
251
- <p><a class="source-toggle" href="#"
252
- onclick="toggleCode('M000117-source');return false;">[Source]</a></p>
253
- <div class="method-source-code" id="M000117-source">
254
- <pre>
255
- <span class="ruby-comment cmt"># File lib/s33r/client.rb, line 95</span>
256
- 95: <span class="ruby-keyword kw">def</span> <span class="ruby-constant">Client</span>.<span class="ruby-identifier">init</span>(<span class="ruby-identifier">config_file</span>)
257
- 96: <span class="ruby-identifier">aws_access_key</span>, <span class="ruby-identifier">aws_secret_access_key</span>, <span class="ruby-identifier">options</span> = <span class="ruby-identifier">load_config</span>(<span class="ruby-identifier">config_file</span>)
258
- 97: <span class="ruby-constant">Client</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">aws_access_key</span>, <span class="ruby-identifier">aws_secret_access_key</span>, <span class="ruby-identifier">options</span>)
259
- 98: <span class="ruby-keyword kw">end</span>
260
- </pre>
261
- </div>
262
- </div>
263
- </div>
264
-
265
- <div id="method-M000118" class="method-detail">
266
- <a name="M000118"></a>
267
-
268
- <div class="method-heading">
269
- <a href="#M000118" class="method-signature">
270
- <span class="method-name">load_config</span><span class="method-args">(config_file)</span>
271
- </a>
272
- </div>
273
-
274
- <div class="method-description">
275
- <p>
276
- Load YAML config. file for a client. The config. file looks like this:
277
- </p>
278
- <pre>
279
- aws_access_key: 'youraccesskey'
280
- aws_secret_access_key: 'yoursecretkey'
281
- # options for Client or NamedBucket instances
282
- options:
283
- strict: false
284
- public_contents: true
285
- use_ssl: false
286
- default_bucket: 'nobucket'#
287
- </pre>
288
- <p>
289
- Note that the loader also runs the config. file through ERB, so you can add
290
- dynamic blocks of ERB (Ruby) code into your files.
291
- </p>
292
- <p>
293
- The <tt>options</tt> section contains other settings, either specific to
294
- the <a href="Client.html">Client</a> or <a
295
- href="NamedBucket.html">NamedBucket</a> classes, or general application
296
- settings. The <tt>options</tt> section can be omitted, but settings for AWS
297
- keys are required.
298
- </p>
299
- <p>
300
- Returns an array <tt>[aws_access_key, aws_secret_access_key, options]</tt>,
301
- where <tt>options</tt> is a hash.
302
- </p>
303
- <p><a class="source-toggle" href="#"
304
- onclick="toggleCode('M000118-source');return false;">[Source]</a></p>
305
- <div class="method-source-code" id="M000118-source">
306
- <pre>
307
- <span class="ruby-comment cmt"># File lib/s33r/client.rb, line 113</span>
308
- 113: <span class="ruby-keyword kw">def</span> <span class="ruby-constant">Client</span>.<span class="ruby-identifier">load_config</span>(<span class="ruby-identifier">config_file</span>)
309
- 114: <span class="ruby-identifier">config</span> = <span class="ruby-constant">YAML</span><span class="ruby-operator">::</span><span class="ruby-identifier">load</span>(<span class="ruby-constant">ERB</span>.<span class="ruby-identifier">new</span>(<span class="ruby-constant">IO</span>.<span class="ruby-identifier">read</span>(<span class="ruby-identifier">config_file</span>)).<span class="ruby-identifier">result</span>)
310
- 115: <span class="ruby-identifier">aws_access_key</span> = <span class="ruby-identifier">config</span>[<span class="ruby-value str">'aws_access_key'</span>]
311
- 116: <span class="ruby-identifier">aws_secret_access_key</span> = <span class="ruby-identifier">config</span>[<span class="ruby-value str">'aws_secret_access_key'</span>]
312
- 117:
313
- 118: <span class="ruby-identifier">options</span> = {}
314
- 119: <span class="ruby-identifier">options</span> = <span class="ruby-constant">S33r</span>.<span class="ruby-identifier">keys_to_symbols</span>(<span class="ruby-identifier">config</span>[<span class="ruby-value str">'options'</span>]) <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">config</span>[<span class="ruby-value str">'options'</span>]
315
- 120:
316
- 121: [<span class="ruby-identifier">aws_access_key</span>, <span class="ruby-identifier">aws_secret_access_key</span>, <span class="ruby-identifier">options</span>]
317
- 122: <span class="ruby-keyword kw">end</span>
318
- </pre>
319
- </div>
320
- </div>
321
- </div>
322
-
323
- <div id="method-M000115" class="method-detail">
324
- <a name="M000115"></a>
325
-
326
- <div class="method-heading">
327
- <a href="#M000115" class="method-signature">
328
- <span class="method-name">new</span><span class="method-args">(aws_access_key, aws_secret_access_key, options={})</span>
329
- </a>
330
- </div>
331
-
332
- <div class="method-description">
333
- <p>
334
- Configure either an SSL-enabled or plain HTTP client. (If using SSL, no
335
- verification of server certificate is performed.)
336
- </p>
337
- <p>
338
- <tt>options</tt>: hash of optional client config.:
339
- </p>
340
- <ul>
341
- <li><tt>:use_ssl =&gt; false</tt>: only use plain HTTP for connections
342
-
343
- </li>
344
- <li><tt>:dump_requests =&gt; true</tt>: dump each request&#8217;s initial line
345
- and headers to STDOUT
346
-
347
- </li>
348
- </ul>
349
- <p><a class="source-toggle" href="#"
350
- onclick="toggleCode('M000115-source');return false;">[Source]</a></p>
351
- <div class="method-source-code" id="M000115-source">
352
- <pre>
353
- <span class="ruby-comment cmt"># File lib/s33r/client.rb, line 51</span>
354
- 51: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">initialize</span>(<span class="ruby-identifier">aws_access_key</span>, <span class="ruby-identifier">aws_secret_access_key</span>, <span class="ruby-identifier">options</span>={})
355
- 52: <span class="ruby-ivar">@use_ssl</span> = <span class="ruby-keyword kw">true</span>
356
- 53: <span class="ruby-ivar">@use_ssl</span> = <span class="ruby-keyword kw">false</span> <span class="ruby-keyword kw">if</span> (<span class="ruby-keyword kw">false</span> <span class="ruby-operator">==</span> <span class="ruby-identifier">options</span>[<span class="ruby-identifier">:use_ssl</span>])
357
- 54: <span class="ruby-identifier">options</span>[<span class="ruby-identifier">:use_ssl</span>] = <span class="ruby-ivar">@use_ssl</span>
358
- 55:
359
- 56: <span class="ruby-ivar">@dump_requests</span> = (<span class="ruby-keyword kw">true</span> <span class="ruby-operator">==</span> <span class="ruby-identifier">options</span>[<span class="ruby-identifier">:dump_requests</span>])
360
- 57:
361
- 58: <span class="ruby-comment cmt"># set default chunk size for streaming request body</span>
362
- 59: <span class="ruby-ivar">@chunk_size</span> = <span class="ruby-constant">DEFAULT_CHUNK_SIZE</span>
363
- 60:
364
- 61: <span class="ruby-ivar">@log_bucket</span> = <span class="ruby-identifier">options</span>[<span class="ruby-identifier">:log_bucket</span>]
365
- 62:
366
- 63: <span class="ruby-comment cmt"># Amazon S3 developer keys</span>
367
- 64: <span class="ruby-ivar">@aws_access_key</span> = <span class="ruby-identifier">aws_access_key</span>
368
- 65: <span class="ruby-ivar">@aws_secret_access_key</span> = <span class="ruby-identifier">aws_secret_access_key</span>
369
- 66:
370
- 67: <span class="ruby-comment cmt"># headers sent with every request made by this client</span>
371
- 68: <span class="ruby-ivar">@client_headers</span> = {}
372
- 69:
373
- 70: <span class="ruby-comment cmt"># keep a record of the options used to create this instance</span>
374
- 71: <span class="ruby-ivar">@options</span> = <span class="ruby-identifier">options</span>
375
- 72: <span class="ruby-keyword kw">end</span>
376
- </pre>
377
- </div>
378
- </div>
379
- </div>
380
-
381
- <h3 class="section-bar">Public Instance methods</h3>
382
-
383
- <div id="method-M000145" class="method-detail">
384
- <a name="M000145"></a>
385
-
386
- <div class="method-heading">
387
- <a href="#M000145" class="method-signature">
388
- <span class="method-name">add_client_headers</span><span class="method-args">(headers)</span>
389
- </a>
390
- </div>
391
-
392
- <div class="method-description">
393
- <p>
394
- Add any default headers which should be sent with every request from the
395
- client.
396
- </p>
397
- <p>
398
- <tt>headers</tt> is a hash of headers already set up. Any headers passed in
399
- here override the defaults in <tt>client_headers</tt>.
400
- </p>
401
- <p>
402
- Returns <tt>headers</tt> with the content of <tt>client_headers</tt> merged
403
- in.
404
- </p>
405
- <p><a class="source-toggle" href="#"
406
- onclick="toggleCode('M000145-source');return false;">[Source]</a></p>
407
- <div class="method-source-code" id="M000145-source">
408
- <pre>
409
- <span class="ruby-comment cmt"># File lib/s33r/client.rb, line 520</span>
410
- 520: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">add_client_headers</span>(<span class="ruby-identifier">headers</span>)
411
- 521: <span class="ruby-identifier">headers</span>.<span class="ruby-identifier">merge!</span>(<span class="ruby-identifier">client_headers</span>) { <span class="ruby-operator">|</span><span class="ruby-identifier">key</span>, <span class="ruby-identifier">arg</span>, <span class="ruby-identifier">default</span><span class="ruby-operator">|</span> <span class="ruby-identifier">arg</span> }
412
- 522: <span class="ruby-keyword kw">end</span>
413
- </pre>
414
- </div>
415
- </div>
416
- </div>
417
-
418
- <div id="method-M000126" class="method-detail">
419
- <a name="M000126"></a>
420
-
421
- <div class="method-heading">
422
- <a href="#M000126" class="method-signature">
423
- <span class="method-name">bucket_exists?</span><span class="method-args">(bucket_name)</span>
424
- </a>
425
- </div>
426
-
427
- <div class="method-description">
428
- <p>
429
- Check whether a bucket exists or not.
430
- </p>
431
- <p><a class="source-toggle" href="#"
432
- onclick="toggleCode('M000126-source');return false;">[Source]</a></p>
433
- <div class="method-source-code" id="M000126-source">
434
- <pre>
435
- <span class="ruby-comment cmt"># File lib/s33r/client.rb, line 280</span>
436
- 280: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">bucket_exists?</span>(<span class="ruby-identifier">bucket_name</span>)
437
- 281: <span class="ruby-identifier">resource_exists?</span>(<span class="ruby-identifier">bucket_name</span>)
438
- 282: <span class="ruby-keyword kw">end</span>
439
- </pre>
440
- </div>
441
- </div>
442
- </div>
443
-
444
- <div id="method-M000124" class="method-detail">
445
- <a name="M000124"></a>
446
-
447
- <div class="method-heading">
448
- <a href="#M000124" class="method-signature">
449
- <span class="method-name">create_bucket</span><span class="method-args">(bucket_name, headers={})</span>
450
- </a>
451
- </div>
452
-
453
- <div class="method-description">
454
- <p>
455
- Create a bucket.
456
- </p>
457
- <p>
458
- Returns true if response returned a 200 code; false otherwise.
459
- </p>
460
- <p><a class="source-toggle" href="#"
461
- onclick="toggleCode('M000124-source');return false;">[Source]</a></p>
462
- <div class="method-source-code" id="M000124-source">
463
- <pre>
464
- <span class="ruby-comment cmt"># File lib/s33r/client.rb, line 257</span>
465
- 257: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">create_bucket</span>(<span class="ruby-identifier">bucket_name</span>, <span class="ruby-identifier">headers</span>={})
466
- 258: <span class="ruby-identifier">resp</span> = <span class="ruby-identifier">do_put</span>(<span class="ruby-node">&quot;/#{bucket_name}&quot;</span>, <span class="ruby-keyword kw">nil</span>, <span class="ruby-identifier">headers</span>)
467
- 259: <span class="ruby-identifier">resp</span>.<span class="ruby-identifier">ok?</span>
468
- 260: <span class="ruby-keyword kw">end</span>
469
- </pre>
470
- </div>
471
- </div>
472
- </div>
473
-
474
- <div id="method-M000125" class="method-detail">
475
- <a name="M000125"></a>
476
-
477
- <div class="method-heading">
478
- <a href="#M000125" class="method-signature">
479
- <span class="method-name">delete_bucket</span><span class="method-args">(bucket_name, headers={}, options={})</span>
480
- </a>
481
- </div>
482
-
483
- <div class="method-description">
484
- <p>
485
- Delete a bucket.
486
- </p>
487
- <p>
488
- <tt>options</tt> hash can contain the following:
489
- </p>
490
- <ul>
491
- <li><tt>:force =&gt; true</tt>: delete all keys within the bucket then delete
492
- the bucket itself
493
-
494
- </li>
495
- </ul>
496
- <p><a class="source-toggle" href="#"
497
- onclick="toggleCode('M000125-source');return false;">[Source]</a></p>
498
- <div class="method-source-code" id="M000125-source">
499
- <pre>
500
- <span class="ruby-comment cmt"># File lib/s33r/client.rb, line 268</span>
501
- 268: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">delete_bucket</span>(<span class="ruby-identifier">bucket_name</span>, <span class="ruby-identifier">headers</span>={}, <span class="ruby-identifier">options</span>={})
502
- 269: <span class="ruby-keyword kw">if</span> <span class="ruby-keyword kw">true</span> <span class="ruby-operator">==</span> <span class="ruby-identifier">options</span>[<span class="ruby-identifier">:force</span>]
503
- 270: <span class="ruby-identifier">_</span>, <span class="ruby-identifier">bucket_listing</span> = <span class="ruby-identifier">list_bucket</span>(<span class="ruby-identifier">bucket_name</span>)
504
- 271: <span class="ruby-identifier">bucket_listing</span>.<span class="ruby-identifier">contents</span>.<span class="ruby-identifier">each_value</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">obj</span><span class="ruby-operator">|</span>
505
- 272: <span class="ruby-identifier">delete_resource</span>(<span class="ruby-identifier">bucket_name</span>, <span class="ruby-identifier">obj</span>.<span class="ruby-identifier">key</span>)
506
- 273: <span class="ruby-keyword kw">end</span>
507
- 274: <span class="ruby-keyword kw">end</span>
508
- 275:
509
- 276: <span class="ruby-identifier">do_delete</span>(<span class="ruby-node">&quot;/#{bucket_name}&quot;</span>, <span class="ruby-identifier">headers</span>)
510
- 277: <span class="ruby-keyword kw">end</span>
511
- </pre>
512
- </div>
513
- </div>
514
- </div>
515
-
516
- <div id="method-M000144" class="method-detail">
517
- <a name="M000144"></a>
518
-
519
- <div class="method-heading">
520
- <a href="#M000144" class="method-signature">
521
- <span class="method-name">delete_resource</span><span class="method-args">(bucket_name, resource_key, headers={})</span>
522
- </a>
523
- </div>
524
-
525
- <div class="method-description">
526
- <p>
527
- Delete a resource from S3.
528
- </p>
529
- <p>
530
- Note that S3 returns the same response code regardless of whether the
531
- resource was successfully deleted, or didn&#8217;t exist in the first
532
- place.
533
- </p>
534
- <p><a class="source-toggle" href="#"
535
- onclick="toggleCode('M000144-source');return false;">[Source]</a></p>
536
- <div class="method-source-code" id="M000144-source">
537
- <pre>
538
- <span class="ruby-comment cmt"># File lib/s33r/client.rb, line 510</span>
539
- 510: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">delete_resource</span>(<span class="ruby-identifier">bucket_name</span>, <span class="ruby-identifier">resource_key</span>, <span class="ruby-identifier">headers</span>={})
540
- 511: <span class="ruby-identifier">do_delete</span>(<span class="ruby-node">&quot;/#{bucket_name}/#{resource_key}&quot;</span>, <span class="ruby-identifier">headers</span>)
541
- 512: <span class="ruby-keyword kw">end</span>
542
- </pre>
543
- </div>
544
- </div>
545
- </div>
546
-
547
- <div id="method-M000137" class="method-detail">
548
- <a name="M000137"></a>
549
-
550
- <div class="method-heading">
551
- <a href="#M000137" class="method-signature">
552
- <span class="method-name">disable_log_target</span><span class="method-args">(bucket_name)</span>
553
- </a>
554
- </div>
555
-
556
- <div class="method-description">
557
- <p>
558
- Disable permissions for access logging into a bucket.
559
- </p>
560
- <p>
561
- Returns true if the bucket is no longer log targetable; false if it remains
562
- a log target.
563
- </p>
564
- <p><a class="source-toggle" href="#"
565
- onclick="toggleCode('M000137-source');return false;">[Source]</a></p>
566
- <div class="method-source-code" id="M000137-source">
567
- <pre>
568
- <span class="ruby-comment cmt"># File lib/s33r/client.rb, line 396</span>
569
- 396: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">disable_log_target</span>(<span class="ruby-identifier">bucket_name</span>)
570
- 397: <span class="ruby-identifier">acl</span> = <span class="ruby-identifier">get_acl</span>(<span class="ruby-identifier">bucket_name</span>)
571
- 398: <span class="ruby-identifier">acl</span>.<span class="ruby-identifier">remove_log_target</span>
572
- 399: <span class="ruby-identifier">set_acl</span>(<span class="ruby-identifier">acl</span>, <span class="ruby-identifier">bucket_name</span>)
573
- 400: <span class="ruby-operator">!</span><span class="ruby-identifier">acl</span>.<span class="ruby-identifier">log_targetable?</span>
574
- 401: <span class="ruby-keyword kw">end</span>
575
- </pre>
576
- </div>
577
- </div>
578
- </div>
579
-
580
- <div id="method-M000139" class="method-detail">
581
- <a name="M000139"></a>
582
-
583
- <div class="method-heading">
584
- <a href="#M000139" class="method-signature">
585
- <span class="method-name">disable_logging</span><span class="method-args">()</span>
586
- </a>
587
- </div>
588
-
589
- <div class="method-description">
590
- <p>
591
- Turn off logging of a resource.
592
- </p>
593
- <p><a class="source-toggle" href="#"
594
- onclick="toggleCode('M000139-source');return false;">[Source]</a></p>
595
- <div class="method-source-code" id="M000139-source">
596
- <pre>
597
- <span class="ruby-comment cmt"># File lib/s33r/client.rb, line 436</span>
598
- 436: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">disable_logging</span>
599
- 437: <span class="ruby-keyword kw">end</span>
600
- </pre>
601
- </div>
602
- </div>
603
- </div>
604
-
605
- <div id="method-M000150" class="method-detail">
606
- <a name="M000150"></a>
607
-
608
- <div class="method-heading">
609
- <a href="#M000150" class="method-signature">
610
- <span class="method-name">do_delete</span><span class="method-args">(path, headers={})</span>
611
- </a>
612
- </div>
613
-
614
- <div class="method-description">
615
- <p><a class="source-toggle" href="#"
616
- onclick="toggleCode('M000150-source');return false;">[Source]</a></p>
617
- <div class="method-source-code" id="M000150-source">
618
- <pre>
619
- <span class="ruby-comment cmt"># File lib/s33r/client.rb, line 540</span>
620
- 540: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">do_delete</span>(<span class="ruby-identifier">path</span>, <span class="ruby-identifier">headers</span>={})
621
- 541: <span class="ruby-identifier">do_request</span>(<span class="ruby-value str">'DELETE'</span>, <span class="ruby-identifier">path</span>, <span class="ruby-keyword kw">nil</span>, <span class="ruby-identifier">headers</span>)
622
- 542: <span class="ruby-keyword kw">end</span>
623
- </pre>
624
- </div>
625
- </div>
626
- </div>
627
-
628
- <div id="method-M000146" class="method-detail">
629
- <a name="M000146"></a>
630
-
631
- <div class="method-heading">
632
- <a href="#M000146" class="method-signature">
633
- <span class="method-name">do_get</span><span class="method-args">(path='/', headers={})</span>
634
- </a>
635
- </div>
636
-
637
- <div class="method-description">
638
- <p><a class="source-toggle" href="#"
639
- onclick="toggleCode('M000146-source');return false;">[Source]</a></p>
640
- <div class="method-source-code" id="M000146-source">
641
- <pre>
642
- <span class="ruby-comment cmt"># File lib/s33r/client.rb, line 524</span>
643
- 524: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">do_get</span>(<span class="ruby-identifier">path</span>=<span class="ruby-value str">'/'</span>, <span class="ruby-identifier">headers</span>={})
644
- 525: <span class="ruby-identifier">do_request</span>(<span class="ruby-value str">'GET'</span>, <span class="ruby-identifier">path</span>, <span class="ruby-keyword kw">nil</span>, <span class="ruby-identifier">headers</span>)
645
- 526: <span class="ruby-keyword kw">end</span>
646
- </pre>
647
- </div>
648
- </div>
649
- </div>
650
-
651
- <div id="method-M000147" class="method-detail">
652
- <a name="M000147"></a>
653
-
654
- <div class="method-heading">
655
- <a href="#M000147" class="method-signature">
656
- <span class="method-name">do_head</span><span class="method-args">(path='/', headers={})</span>
657
- </a>
658
- </div>
659
-
660
- <div class="method-description">
661
- <p><a class="source-toggle" href="#"
662
- onclick="toggleCode('M000147-source');return false;">[Source]</a></p>
663
- <div class="method-source-code" id="M000147-source">
664
- <pre>
665
- <span class="ruby-comment cmt"># File lib/s33r/client.rb, line 528</span>
666
- 528: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">do_head</span>(<span class="ruby-identifier">path</span>=<span class="ruby-value str">'/'</span>, <span class="ruby-identifier">headers</span>={})
667
- 529: <span class="ruby-identifier">do_request</span>(<span class="ruby-value str">'HEAD'</span>, <span class="ruby-identifier">path</span>, <span class="ruby-keyword kw">nil</span>, <span class="ruby-identifier">headers</span>)
668
- 530: <span class="ruby-keyword kw">end</span>
669
- </pre>
670
- </div>
671
- </div>
672
- </div>
673
-
674
- <div id="method-M000148" class="method-detail">
675
- <a name="M000148"></a>
676
-
677
- <div class="method-heading">
678
- <a href="#M000148" class="method-signature">
679
- <span class="method-name">do_post</span><span class="method-args">(path='/', data=nil, headers={})</span>
680
- </a>
681
- </div>
682
-
683
- <div class="method-description">
684
- <p><a class="source-toggle" href="#"
685
- onclick="toggleCode('M000148-source');return false;">[Source]</a></p>
686
- <div class="method-source-code" id="M000148-source">
687
- <pre>
688
- <span class="ruby-comment cmt"># File lib/s33r/client.rb, line 532</span>
689
- 532: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">do_post</span>(<span class="ruby-identifier">path</span>=<span class="ruby-value str">'/'</span>, <span class="ruby-identifier">data</span>=<span class="ruby-keyword kw">nil</span>, <span class="ruby-identifier">headers</span>={})
690
- 533: <span class="ruby-identifier">do_request</span>(<span class="ruby-value str">'POST'</span>, <span class="ruby-identifier">path</span>, <span class="ruby-identifier">data</span>, <span class="ruby-identifier">headers</span>)
691
- 534: <span class="ruby-keyword kw">end</span>
692
- </pre>
693
- </div>
694
- </div>
695
- </div>
696
-
697
- <div id="method-M000149" class="method-detail">
698
- <a name="M000149"></a>
699
-
700
- <div class="method-heading">
701
- <a href="#M000149" class="method-signature">
702
- <span class="method-name">do_put</span><span class="method-args">(path='/', data=nil, headers={})</span>
703
- </a>
704
- </div>
705
-
706
- <div class="method-description">
707
- <p><a class="source-toggle" href="#"
708
- onclick="toggleCode('M000149-source');return false;">[Source]</a></p>
709
- <div class="method-source-code" id="M000149-source">
710
- <pre>
711
- <span class="ruby-comment cmt"># File lib/s33r/client.rb, line 536</span>
712
- 536: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">do_put</span>(<span class="ruby-identifier">path</span>=<span class="ruby-value str">'/'</span>, <span class="ruby-identifier">data</span>=<span class="ruby-keyword kw">nil</span>, <span class="ruby-identifier">headers</span>={})
713
- 537: <span class="ruby-identifier">do_request</span>(<span class="ruby-value str">'PUT'</span>, <span class="ruby-identifier">path</span>, <span class="ruby-identifier">data</span>, <span class="ruby-identifier">headers</span>)
714
- 538: <span class="ruby-keyword kw">end</span>
715
- </pre>
716
- </div>
717
- </div>
718
- </div>
719
-
720
- <div id="method-M000119" class="method-detail">
721
- <a name="M000119"></a>
722
-
723
- <div class="method-heading">
724
- <a href="#M000119" class="method-signature">
725
- <span class="method-name">do_request</span><span class="method-args">(method, path, data=nil, headers={})</span>
726
- </a>
727
- </div>
728
-
729
- <div class="method-description">
730
- <p>
731
- Send a request over the wire.
732
- </p>
733
- <p>
734
- This method streams <tt>data</tt> if it responds to the <tt>stat</tt>
735
- method (as files do).
736
- </p>
737
- <p>
738
- Returns a <a href="../Net/HTTPResponse.html">Net::HTTPResponse</a>
739
- instance.
740
- </p>
741
- <p><a class="source-toggle" href="#"
742
- onclick="toggleCode('M000119-source');return false;">[Source]</a></p>
743
- <div class="method-source-code" id="M000119-source">
744
- <pre>
745
- <span class="ruby-comment cmt"># File lib/s33r/client.rb, line 130</span>
746
- 130: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">do_request</span>(<span class="ruby-identifier">method</span>, <span class="ruby-identifier">path</span>, <span class="ruby-identifier">data</span>=<span class="ruby-keyword kw">nil</span>, <span class="ruby-identifier">headers</span>={})
747
- 131: <span class="ruby-identifier">req</span> = <span class="ruby-identifier">get_requester</span>(<span class="ruby-identifier">method</span>, <span class="ruby-identifier">path</span>)
748
- 132: <span class="ruby-identifier">req</span>.<span class="ruby-identifier">chunk_size</span> = <span class="ruby-ivar">@chunk_size</span>
749
- 133:
750
- 134: <span class="ruby-comment cmt"># Add the S3 headers which are always required.</span>
751
- 135: <span class="ruby-identifier">headers</span> = <span class="ruby-identifier">add_default_headers</span>(<span class="ruby-identifier">headers</span>)
752
- 136:
753
- 137: <span class="ruby-comment cmt"># Add any client-specific default headers.</span>
754
- 138: <span class="ruby-identifier">headers</span> = <span class="ruby-identifier">add_client_headers</span>(<span class="ruby-identifier">headers</span>)
755
- 139:
756
- 140: <span class="ruby-comment cmt"># Generate the S3 authorization header.</span>
757
- 141: <span class="ruby-identifier">headers</span>[<span class="ruby-value str">'Authorization'</span>] = <span class="ruby-identifier">generate_auth_header_value</span>(<span class="ruby-identifier">method</span>, <span class="ruby-identifier">path</span>, <span class="ruby-identifier">headers</span>,
758
- 142: <span class="ruby-ivar">@aws_access_key</span>, <span class="ruby-ivar">@aws_secret_access_key</span>)
759
- 143:
760
- 144: <span class="ruby-comment cmt"># Insert the headers into the request object.</span>
761
- 145: <span class="ruby-identifier">headers</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">key</span>, <span class="ruby-identifier">value</span><span class="ruby-operator">|</span>
762
- 146: <span class="ruby-identifier">req</span>[<span class="ruby-identifier">key</span>] = <span class="ruby-identifier">value</span>
763
- 147: <span class="ruby-keyword kw">end</span>
764
- 148:
765
- 149: <span class="ruby-comment cmt"># Add data to the request as a stream.</span>
766
- 150: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">req</span>.<span class="ruby-identifier">request_body_permitted?</span>
767
- 151: <span class="ruby-comment cmt"># For streaming files; NB Content-Length will be set by Net::HTTP</span>
768
- 152: <span class="ruby-comment cmt"># for character-based data: this section of code is only used</span>
769
- 153: <span class="ruby-comment cmt"># when reading directly from a file.</span>
770
- 154: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">data</span>.<span class="ruby-identifier">respond_to?</span>(<span class="ruby-identifier">:stat</span>)
771
- 155: <span class="ruby-identifier">req</span>.<span class="ruby-identifier">body_stream</span> = <span class="ruby-identifier">data</span>
772
- 156: <span class="ruby-identifier">req</span>[<span class="ruby-value str">'Content-Length'</span>] = <span class="ruby-identifier">data</span>.<span class="ruby-identifier">stat</span>.<span class="ruby-identifier">size</span>.<span class="ruby-identifier">to_s</span>
773
- 157: <span class="ruby-identifier">data</span> = <span class="ruby-keyword kw">nil</span>
774
- 158: <span class="ruby-keyword kw">end</span>
775
- 159: <span class="ruby-keyword kw">else</span>
776
- 160: <span class="ruby-identifier">data</span> = <span class="ruby-keyword kw">nil</span>
777
- 161: <span class="ruby-keyword kw">end</span>
778
- 162:
779
- 163: <span class="ruby-keyword kw">if</span> <span class="ruby-ivar">@dump_requests</span>
780
- 164: <span class="ruby-identifier">puts</span> <span class="ruby-identifier">req</span>.<span class="ruby-identifier">to_s</span>
781
- 165: <span class="ruby-keyword kw">end</span>
782
- 166:
783
- 167: <span class="ruby-comment cmt"># Run the request.</span>
784
- 168: <span class="ruby-identifier">client</span> = <span class="ruby-identifier">get_client</span>
785
- 169: <span class="ruby-identifier">client</span>.<span class="ruby-identifier">start</span> <span class="ruby-keyword kw">do</span>
786
- 170: <span class="ruby-identifier">response</span> = <span class="ruby-identifier">client</span>.<span class="ruby-identifier">request</span>(<span class="ruby-identifier">req</span>, <span class="ruby-identifier">data</span>)
787
- 171:
788
- 172: <span class="ruby-comment cmt"># Check the response to see whether S3 is down;</span>
789
- 173: <span class="ruby-comment cmt"># raises an S3FallenOver error if S3 returns a 500-503 response code</span>
790
- 174: <span class="ruby-identifier">response</span>.<span class="ruby-identifier">check_s3_availability</span>
791
- 175:
792
- 176: <span class="ruby-identifier">response</span>
793
- 177: <span class="ruby-keyword kw">end</span>
794
- 178: <span class="ruby-keyword kw">end</span>
795
- </pre>
796
- </div>
797
- </div>
798
- </div>
799
-
800
- <div id="method-M000136" class="method-detail">
801
- <a name="M000136"></a>
802
-
803
- <div class="method-heading">
804
- <a href="#M000136" class="method-signature">
805
- <span class="method-name">enable_log_target</span><span class="method-args">(bucket_name)</span>
806
- </a>
807
- </div>
808
-
809
- <div class="method-description">
810
- <p>
811
- Make a bucket capable of being a target for access logging.
812
- </p>
813
- <p>
814
- Returns true if the bucket is now a possible log target; false otherwise.
815
- </p>
816
- <p><a class="source-toggle" href="#"
817
- onclick="toggleCode('M000136-source');return false;">[Source]</a></p>
818
- <div class="method-source-code" id="M000136-source">
819
- <pre>
820
- <span class="ruby-comment cmt"># File lib/s33r/client.rb, line 382</span>
821
- 382: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">enable_log_target</span>(<span class="ruby-identifier">bucket_name</span>)
822
- 383: <span class="ruby-identifier">acl</span> = <span class="ruby-identifier">get_acl</span>(<span class="ruby-identifier">bucket_name</span>)
823
- 384: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">acl</span>.<span class="ruby-identifier">add_log_target_grants</span>
824
- 385: <span class="ruby-identifier">set_acl</span>(<span class="ruby-identifier">acl</span>, <span class="ruby-identifier">bucket_name</span>)
825
- 386: <span class="ruby-keyword kw">end</span>
826
- 387: <span class="ruby-identifier">acl</span>.<span class="ruby-identifier">log_targetable?</span>
827
- 388: <span class="ruby-keyword kw">end</span>
828
- </pre>
829
- </div>
830
- </div>
831
- </div>
832
-
833
- <div id="method-M000138" class="method-detail">
834
- <a name="M000138"></a>
835
-
836
- <div class="method-heading">
837
- <a href="#M000138" class="method-signature">
838
- <span class="method-name">enable_logging</span><span class="method-args">(bucket_name, log_bucket=nil, options={})</span>
839
- </a>
840
- </div>
841
-
842
- <div class="method-description">
843
- <p>
844
- Enable logging for a resource (only buckets are supported presently).
845
- </p>
846
- <p>
847
- <tt>log_prefix</tt> is the prefix for the logs. <tt>bucket_name</tt> is the
848
- bucket to log. <tt>log_bucket</tt> is the bucket to put logs into.
849
- </p>
850
- <p>
851
- options:
852
- </p>
853
- <pre>
854
- +:for_key =&gt; 'key'+ is the (optional) resource to log in the bucket
855
- (NB this is not currently supported by S3).
856
- +:log_prefix =&gt; 'prefix'+ is the (optional) log file prefix
857
- (defaults to bucket_name + '-')
858
- </pre>
859
- <p><a class="source-toggle" href="#"
860
- onclick="toggleCode('M000138-source');return false;">[Source]</a></p>
861
- <div class="method-source-code" id="M000138-source">
862
- <pre>
863
- <span class="ruby-comment cmt"># File lib/s33r/client.rb, line 416</span>
864
- 416: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">enable_logging</span>(<span class="ruby-identifier">bucket_name</span>, <span class="ruby-identifier">log_bucket</span>=<span class="ruby-keyword kw">nil</span>, <span class="ruby-identifier">options</span>={})
865
- 417: <span class="ruby-comment cmt"># Set to the default log_bucket if not set explicitly.</span>
866
- 418: <span class="ruby-identifier">log_bucket</span> <span class="ruby-operator">||=</span> <span class="ruby-ivar">@log_bucket</span>
867
- 419:
868
- 420: <span class="ruby-identifier">resource_key</span> = <span class="ruby-identifier">options</span>[<span class="ruby-identifier">:for_key</span>]
869
- 421: <span class="ruby-identifier">resource_key</span> <span class="ruby-operator">||=</span> <span class="ruby-value str">''</span>
870
- 422:
871
- 423: <span class="ruby-identifier">log_prefix</span> = <span class="ruby-identifier">options</span>[<span class="ruby-identifier">:prefix</span>]
872
- 424: <span class="ruby-identifier">log_prefix</span> <span class="ruby-operator">||=</span> <span class="ruby-identifier">bucket_name</span> <span class="ruby-operator">+</span> <span class="ruby-value str">'-'</span>
873
- 425:
874
- 426: <span class="ruby-identifier">log_bucket_acl</span> = <span class="ruby-identifier">get_acl</span>(<span class="ruby-identifier">log_bucket</span>)
875
- 427: <span class="ruby-keyword kw">if</span> <span class="ruby-operator">!</span>(<span class="ruby-identifier">log_bucket_acl</span>.<span class="ruby-identifier">log_targetable?</span>)
876
- 428: <span class="ruby-identifier">raise</span> <span class="ruby-constant">BucketNotLogTargetable</span>, <span class="ruby-node">&quot;The bucket #{log_bucket} cannot be specified as a log target&quot;</span>
877
- 429: <span class="ruby-keyword kw">end</span>
878
- 430: <span class="ruby-identifier">logging_resource</span> = <span class="ruby-constant">LoggingResource</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">log_bucket</span>, <span class="ruby-identifier">log_prefix</span>)
879
- 431: <span class="ruby-identifier">set_logging</span>(<span class="ruby-identifier">logging_resource</span>, <span class="ruby-identifier">bucket_name</span>, <span class="ruby-identifier">resource_key</span>)
880
- 432: <span class="ruby-keyword kw">end</span>
881
- </pre>
882
- </div>
883
- </div>
884
- </div>
885
-
886
- <div id="method-M000131" class="method-detail">
887
- <a name="M000131"></a>
888
-
889
- <div class="method-heading">
890
- <a href="#M000131" class="method-signature">
891
- <span class="method-name">get_acl</span><span class="method-args">(bucket_name, resource_key='')</span>
892
- </a>
893
- </div>
894
-
895
- <div class="method-description">
896
- <p>
897
- Fetch the ACL document for a resource.
898
- </p>
899
- <p>
900
- Raises an exception if there is a problem with the resource (e.g. it
901
- doesn&#8217;t exist).
902
- </p>
903
- <p><a class="source-toggle" href="#"
904
- onclick="toggleCode('M000131-source');return false;">[Source]</a></p>
905
- <div class="method-source-code" id="M000131-source">
906
- <pre>
907
- <span class="ruby-comment cmt"># File lib/s33r/client.rb, line 326</span>
908
- 326: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">get_acl</span>(<span class="ruby-identifier">bucket_name</span>, <span class="ruby-identifier">resource_key</span>=<span class="ruby-value str">''</span>)
909
- 327: <span class="ruby-identifier">path</span> = <span class="ruby-identifier">s3_acl_path</span>(<span class="ruby-identifier">bucket_name</span>, <span class="ruby-identifier">resource_key</span>)
910
- 328: <span class="ruby-identifier">response</span> = <span class="ruby-identifier">do_get</span>(<span class="ruby-identifier">path</span>)
911
- 329: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">response</span>.<span class="ruby-identifier">ok?</span>
912
- 330: <span class="ruby-constant">S3ACL</span><span class="ruby-operator">::</span><span class="ruby-constant">ACLDoc</span>.<span class="ruby-identifier">from_xml</span>(<span class="ruby-identifier">response</span>.<span class="ruby-identifier">body</span>)
913
- 331: <span class="ruby-keyword kw">else</span>
914
- 332: <span class="ruby-identifier">raise</span> <span class="ruby-constant">S33rException</span><span class="ruby-operator">::</span><span class="ruby-constant">MissingResource</span>, <span class="ruby-node">&quot;Tried to get an ACL from a non-existent resource [#{path}]&quot;</span>
915
- 333: <span class="ruby-keyword kw">end</span>
916
- 334: <span class="ruby-keyword kw">end</span>
917
- </pre>
918
- </div>
919
- </div>
920
- </div>
921
-
922
- <div id="method-M000116" class="method-detail">
923
- <a name="M000116"></a>
924
-
925
- <div class="method-heading">
926
- <a href="#M000116" class="method-signature">
927
- <span class="method-name">get_client</span><span class="method-args">()</span>
928
- </a>
929
- </div>
930
-
931
- <div class="method-description">
932
- <p>
933
- Get an HTTP client instance.
934
- </p>
935
- <p>
936
- NB this has been moved here so that client instances are only instantiated
937
- when needed (so <a href="Client.html">Client</a> can be used as an empty
938
- shell when <a href="Client.html#M000121">list_buckets</a> is called).
939
- </p>
940
- <p><a class="source-toggle" href="#"
941
- onclick="toggleCode('M000116-source');return false;">[Source]</a></p>
942
- <div class="method-source-code" id="M000116-source">
943
- <pre>
944
- <span class="ruby-comment cmt"># File lib/s33r/client.rb, line 79</span>
945
- 79: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">get_client</span>
946
- 80: <span class="ruby-keyword kw">if</span> <span class="ruby-ivar">@use_ssl</span>
947
- 81: <span class="ruby-identifier">client</span> = <span class="ruby-constant">HTTP</span>.<span class="ruby-identifier">new</span>(<span class="ruby-constant">HOST</span>, <span class="ruby-constant">PORT</span>)
948
- 82: <span class="ruby-comment cmt"># turn off SSL certificate verification</span>
949
- 83: <span class="ruby-identifier">client</span>.<span class="ruby-identifier">verify_mode</span> = <span class="ruby-constant">OpenSSL</span><span class="ruby-operator">::</span><span class="ruby-constant">SSL</span><span class="ruby-operator">::</span><span class="ruby-constant">VERIFY_NONE</span>
950
- 84: <span class="ruby-identifier">client</span>.<span class="ruby-identifier">use_ssl</span> = <span class="ruby-keyword kw">true</span>
951
- 85: <span class="ruby-keyword kw">else</span>
952
- 86: <span class="ruby-identifier">client</span> = <span class="ruby-constant">HTTP</span>.<span class="ruby-identifier">new</span>(<span class="ruby-constant">HOST</span>, <span class="ruby-constant">NON_SSL_PORT</span>)
953
- 87: <span class="ruby-identifier">client</span>.<span class="ruby-identifier">use_ssl</span> = <span class="ruby-keyword kw">false</span>
954
- 88: <span class="ruby-keyword kw">end</span>
955
- 89:
956
- 90: <span class="ruby-identifier">client</span>
957
- 91: <span class="ruby-keyword kw">end</span>
958
- </pre>
959
- </div>
960
- </div>
961
- </div>
962
-
963
- <div id="method-M000140" class="method-detail">
964
- <a name="M000140"></a>
965
-
966
- <div class="method-heading">
967
- <a href="#M000140" class="method-signature">
968
- <span class="method-name">get_logging</span><span class="method-args">()</span>
969
- </a>
970
- </div>
971
-
972
- <div class="method-description">
973
- <p>
974
- Get the logging status of a resource.
975
- </p>
976
- <p><a class="source-toggle" href="#"
977
- onclick="toggleCode('M000140-source');return false;">[Source]</a></p>
978
- <div class="method-source-code" id="M000140-source">
979
- <pre>
980
- <span class="ruby-comment cmt"># File lib/s33r/client.rb, line 441</span>
981
- 441: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">get_logging</span>
982
- 442: <span class="ruby-keyword kw">end</span>
983
- </pre>
984
- </div>
985
- </div>
986
- </div>
987
-
988
- <div id="method-M000127" class="method-detail">
989
- <a name="M000127"></a>
990
-
991
- <div class="method-heading">
992
- <a href="#M000127" class="method-signature">
993
- <span class="method-name">get_named_bucket</span><span class="method-args">(bucket_name, options={}) {|named_bucket if block_given?| ...}</span>
994
- </a>
995
- </div>
996
-
997
- <div class="method-description">
998
- <p>
999
- Create a <a href="NamedBucket.html">NamedBucket</a> instance.
1000
- </p>
1001
- <p>
1002
- <tt>options</tt> is a hash of extra options to use when creating the <a
1003
- href="NamedBucket.html">NamedBucket</a> instance (see
1004
- NamedBucket.initialize); specify :parent to use the same options used to
1005
- create this <a href="Client.html">Client</a> instance.
1006
- </p>
1007
- <p><a class="source-toggle" href="#"
1008
- onclick="toggleCode('M000127-source');return false;">[Source]</a></p>
1009
- <div class="method-source-code" id="M000127-source">
1010
- <pre>
1011
- <span class="ruby-comment cmt"># File lib/s33r/client.rb, line 290</span>
1012
- 290: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">get_named_bucket</span>(<span class="ruby-identifier">bucket_name</span>, <span class="ruby-identifier">options</span>={}, <span class="ruby-operator">&amp;</span><span class="ruby-identifier">block</span>)
1013
- 291: <span class="ruby-identifier">options</span> = <span class="ruby-ivar">@options</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">:parent</span> <span class="ruby-operator">==</span> <span class="ruby-identifier">options</span>
1014
- 292: <span class="ruby-identifier">options</span>[<span class="ruby-identifier">:default_bucket</span>] = <span class="ruby-identifier">bucket_name</span>
1015
- 293: <span class="ruby-identifier">named_bucket</span> = <span class="ruby-constant">NamedBucket</span>.<span class="ruby-identifier">new</span>(<span class="ruby-ivar">@aws_access_key</span>, <span class="ruby-ivar">@aws_secret_access_key</span>, <span class="ruby-identifier">options</span>)
1016
- 294: <span class="ruby-keyword kw">yield</span> <span class="ruby-identifier">named_bucket</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">block_given?</span>
1017
- 295: <span class="ruby-identifier">named_bucket</span>
1018
- 296: <span class="ruby-keyword kw">end</span>
1019
- </pre>
1020
- </div>
1021
- </div>
1022
- </div>
1023
-
1024
- <div id="method-M000130" class="method-detail">
1025
- <a name="M000130"></a>
1026
-
1027
- <div class="method-heading">
1028
- <a href="#M000130" class="method-signature">
1029
- <span class="method-name">get_object</span><span class="method-args">(bucket_name, resource_key, headers={})</span>
1030
- </a>
1031
- </div>
1032
-
1033
- <div class="method-description">
1034
- <p>
1035
- Fetch an object. Note that this actually pulls down the object from S3 and
1036
- instantiates the <a href="S3Object.html">S3Object</a> instance with it.
1037
- </p>
1038
- <p><a class="source-toggle" href="#"
1039
- onclick="toggleCode('M000130-source');return false;">[Source]</a></p>
1040
- <div class="method-source-code" id="M000130-source">
1041
- <pre>
1042
- <span class="ruby-comment cmt"># File lib/s33r/client.rb, line 317</span>
1043
- 317: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">get_object</span>(<span class="ruby-identifier">bucket_name</span>, <span class="ruby-identifier">resource_key</span>, <span class="ruby-identifier">headers</span>={})
1044
- 318: <span class="ruby-identifier">response</span> = <span class="ruby-identifier">get_resource</span>(<span class="ruby-identifier">bucket_name</span>, <span class="ruby-identifier">resource_key</span>, <span class="ruby-identifier">headers</span>)
1045
- 319: <span class="ruby-constant">S3Object</span>.<span class="ruby-identifier">from_response</span>(<span class="ruby-identifier">resource_key</span>, <span class="ruby-identifier">response</span>)
1046
- 320: <span class="ruby-keyword kw">end</span>
1047
- </pre>
1048
- </div>
1049
- </div>
1050
- </div>
1051
-
1052
- <div id="method-M000120" class="method-detail">
1053
- <a name="M000120"></a>
1054
-
1055
- <div class="method-heading">
1056
- <a href="#M000120" class="method-signature">
1057
- <span class="method-name">get_requester</span><span class="method-args">(method, path)</span>
1058
- </a>
1059
- </div>
1060
-
1061
- <div class="method-description">
1062
- <p>
1063
- Return an instance of an appropriate request class.
1064
- </p>
1065
- <p><a class="source-toggle" href="#"
1066
- onclick="toggleCode('M000120-source');return false;">[Source]</a></p>
1067
- <div class="method-source-code" id="M000120-source">
1068
- <pre>
1069
- <span class="ruby-comment cmt"># File lib/s33r/client.rb, line 181</span>
1070
- 181: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">get_requester</span>(<span class="ruby-identifier">method</span>, <span class="ruby-identifier">path</span>)
1071
- 182: <span class="ruby-identifier">raise</span> <span class="ruby-constant">S33rException</span><span class="ruby-operator">::</span><span class="ruby-constant">UnsupportedHTTPMethod</span>, <span class="ruby-node">&quot;The #{method} HTTP method is not supported&quot;</span> <span class="ruby-keyword kw">if</span> <span class="ruby-operator">!</span>(<span class="ruby-constant">METHOD_VERBS</span>.<span class="ruby-identifier">include?</span>(<span class="ruby-identifier">method</span>))
1072
- 183: <span class="ruby-identifier">eval</span>(<span class="ruby-value str">&quot;HTTP::&quot;</span> <span class="ruby-operator">+</span> <span class="ruby-identifier">method</span>[<span class="ruby-value">0</span>,<span class="ruby-value">1</span>].<span class="ruby-identifier">upcase</span> <span class="ruby-operator">+</span> <span class="ruby-identifier">method</span>[<span class="ruby-value">1</span><span class="ruby-operator">..</span><span class="ruby-value">-1</span>].<span class="ruby-identifier">downcase</span> <span class="ruby-operator">+</span> <span class="ruby-node">&quot;.new('#{path}')&quot;</span>)
1073
- 184: <span class="ruby-keyword kw">end</span>
1074
- </pre>
1075
- </div>
1076
- </div>
1077
- </div>
1078
-
1079
- <div id="method-M000128" class="method-detail">
1080
- <a name="M000128"></a>
1081
-
1082
- <div class="method-heading">
1083
- <a href="#M000128" class="method-signature">
1084
- <span class="method-name">get_resource</span><span class="method-args">(bucket_name, resource_key, headers={})</span>
1085
- </a>
1086
- </div>
1087
-
1088
- <div class="method-description">
1089
- <p>
1090
- Fetch a resource.
1091
- </p>
1092
- <p>
1093
- Returns a plain response, not an <a href="S3Object.html">S3Object</a>: if
1094
- you want an object back, use <a href="Client.html#M000130">get_object</a>
1095
- instead.
1096
- </p>
1097
- <p><a class="source-toggle" href="#"
1098
- onclick="toggleCode('M000128-source');return false;">[Source]</a></p>
1099
- <div class="method-source-code" id="M000128-source">
1100
- <pre>
1101
- <span class="ruby-comment cmt"># File lib/s33r/client.rb, line 302</span>
1102
- 302: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">get_resource</span>(<span class="ruby-identifier">bucket_name</span>, <span class="ruby-identifier">resource_key</span>, <span class="ruby-identifier">headers</span>={})
1103
- 303: <span class="ruby-identifier">do_get</span>(<span class="ruby-node">&quot;/#{bucket_name}/#{resource_key}&quot;</span>, <span class="ruby-identifier">headers</span>)
1104
- 304: <span class="ruby-keyword kw">end</span>
1105
- </pre>
1106
- </div>
1107
- </div>
1108
- </div>
1109
-
1110
- <div id="method-M000122" class="method-detail">
1111
- <a name="M000122"></a>
1112
-
1113
- <div class="method-heading">
1114
- <a href="#M000122" class="method-signature">
1115
- <span class="method-name">list</span><span class="method-args">()</span>
1116
- </a>
1117
- </div>
1118
-
1119
- <div class="method-description">
1120
- <p>
1121
- List just bucket names.
1122
- </p>
1123
- <p><a class="source-toggle" href="#"
1124
- onclick="toggleCode('M000122-source');return false;">[Source]</a></p>
1125
- <div class="method-source-code" id="M000122-source">
1126
- <pre>
1127
- <span class="ruby-comment cmt"># File lib/s33r/client.rb, line 211</span>
1128
- 211: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">list</span>
1129
- 212: <span class="ruby-identifier">list_buckets</span>.<span class="ruby-identifier">map</span> {<span class="ruby-operator">|</span><span class="ruby-identifier">bucket</span><span class="ruby-operator">|</span> <span class="ruby-identifier">bucket</span>.<span class="ruby-identifier">name</span>}
1130
- 213: <span class="ruby-keyword kw">end</span>
1131
- </pre>
1132
- </div>
1133
- </div>
1134
- </div>
1135
-
1136
- <div id="method-M000123" class="method-detail">
1137
- <a name="M000123"></a>
1138
-
1139
- <div class="method-heading">
1140
- <a href="#M000123" class="method-signature">
1141
- <span class="method-name">list_bucket</span><span class="method-args">(bucket_name, query_params={})</span>
1142
- </a>
1143
- </div>
1144
-
1145
- <div class="method-description">
1146
- <p>
1147
- List entries in a bucket.
1148
- </p>
1149
- <p>
1150
- <tt>query_params</tt>: hash of options on the bucket listing request,
1151
- passed as querystring parameters to S3 (see <a
1152
- href="http://docs.amazonwebservices.com/AmazonS3/2006-03-01">docs.amazonwebservices.com/AmazonS3/2006-03-01</a>/).
1153
- </p>
1154
- <ul>
1155
- <li><tt>:prefix =&gt; &#8216;some_string&#8216;</tt>: restrict results to keys
1156
- beginning with &#8216;some_string&#8216;
1157
-
1158
- </li>
1159
- <li><tt>:marker =&gt; &#8216;some_string&#8216;</tt>: restict results to keys
1160
- occurring lexicographically after &#8216;some_string&#8216;
1161
-
1162
- </li>
1163
- <li><tt>:max_keys =&gt; 1000</tt>: return at most this number of keys (maximum
1164
- possible value is 1000)
1165
-
1166
- </li>
1167
- <li><tt>:delimiter =&gt; &#8216;some_string&#8216;</tt>: keys containing the
1168
- same string between prefix and the delimiter are rolled up into a
1169
- CommonPrefixes element inside the response
1170
-
1171
- </li>
1172
- </ul>
1173
- <p>
1174
- NB if you pass a :marker, this takes up one of your :max_keys; so if you
1175
- are fetching page two from a bucket, and you want 10 items, you need to set
1176
- :max_keys to 11.
1177
- </p>
1178
- <p>
1179
- To page through a bucket 10 keys at a time, you can do:
1180
- </p>
1181
- <pre>
1182
- resp, listing = list_bucket('mybucket', :max_keys =&gt; 10)
1183
- resp, listing = list_bucket('mybucket', :max_keys =&gt; 11, :marker =&gt; listing.last_key)
1184
- resp, listing = list_bucket('mybucket', :max_keys =&gt; 11, :marker =&gt; listing.last_key)
1185
- etc.
1186
- </pre>
1187
- <p>
1188
- Note in the example code, <tt>listing</tt> is a <a
1189
- href="BucketListing.html">BucketListing</a> instance; call its contents
1190
- method to get a hash of the keys in the bucket, along with associated
1191
- objects.
1192
- </p>
1193
- <p>
1194
- Returns [raw_response, <a href="BucketListing.html">BucketListing</a>
1195
- instance].
1196
- </p>
1197
- <p><a class="source-toggle" href="#"
1198
- onclick="toggleCode('M000123-source');return false;">[Source]</a></p>
1199
- <div class="method-source-code" id="M000123-source">
1200
- <pre>
1201
- <span class="ruby-comment cmt"># File lib/s33r/client.rb, line 239</span>
1202
- 239: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">list_bucket</span>(<span class="ruby-identifier">bucket_name</span>, <span class="ruby-identifier">query_params</span>={})
1203
- 240: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">query_params</span>[<span class="ruby-identifier">:max_keys</span>]
1204
- 241: <span class="ruby-identifier">max_keys</span> = <span class="ruby-identifier">query_params</span>[<span class="ruby-identifier">:max_keys</span>].<span class="ruby-identifier">to_i</span>
1205
- 242: <span class="ruby-identifier">raise</span> <span class="ruby-constant">S33rException</span><span class="ruby-operator">::</span><span class="ruby-constant">BucketListingMaxKeysError</span>, <span class="ruby-node">&quot;max_keys option to list bucket cannot be &gt; #{BUCKET_LIST_MAX_MAX_KEYS}&quot;</span> \
1206
- 243: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">max_keys</span> <span class="ruby-operator">&gt;</span> <span class="ruby-constant">BUCKET_LIST_MAX_MAX_KEYS</span>
1207
- 244:
1208
- 245: <span class="ruby-comment cmt"># convert :max_keys querystring parameter to 'max-keys' parameter</span>
1209
- 246: <span class="ruby-identifier">query_params</span>[<span class="ruby-value str">'max-keys'</span>] = <span class="ruby-identifier">query_params</span>.<span class="ruby-identifier">delete</span>(<span class="ruby-identifier">:max_keys</span>)
1210
- 247: <span class="ruby-keyword kw">end</span>
1211
- 248:
1212
- 249: <span class="ruby-identifier">resp</span> = <span class="ruby-identifier">do_get</span>(<span class="ruby-node">&quot;/#{bucket_name}&quot;</span> <span class="ruby-operator">+</span> <span class="ruby-identifier">generate_querystring</span>(<span class="ruby-identifier">query_params</span>))
1213
- 250:
1214
- 251: [<span class="ruby-identifier">resp</span>, <span class="ruby-constant">BucketListing</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">resp</span>.<span class="ruby-identifier">body</span>)]
1215
- 252: <span class="ruby-keyword kw">end</span>
1216
- </pre>
1217
- </div>
1218
- </div>
1219
- </div>
1220
-
1221
- <div id="method-M000121" class="method-detail">
1222
- <a name="M000121"></a>
1223
-
1224
- <div class="method-heading">
1225
- <a href="#M000121" class="method-signature">
1226
- <span class="method-name">list_buckets</span><span class="method-args">()</span>
1227
- </a>
1228
- </div>
1229
-
1230
- <div class="method-description">
1231
- <p>
1232
- List all buckets.
1233
- </p>
1234
- <p>
1235
- Returns an array of <a href="NamedBucket.html">NamedBucket</a> instances;
1236
- array will be empty if the <a href="BucketListing.html">BucketListing</a>
1237
- parse fails for any reason (i.e. no &lt;Bucket&gt; elements occur in it).
1238
- </p>
1239
- <p><a class="source-toggle" href="#"
1240
- onclick="toggleCode('M000121-source');return false;">[Source]</a></p>
1241
- <div class="method-source-code" id="M000121-source">
1242
- <pre>
1243
- <span class="ruby-comment cmt"># File lib/s33r/client.rb, line 191</span>
1244
- 191: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">list_buckets</span>
1245
- 192: <span class="ruby-identifier">bucket_list_xml</span> = <span class="ruby-identifier">do_get</span>(<span class="ruby-value str">'/'</span>).<span class="ruby-identifier">body</span>
1246
- 193: <span class="ruby-identifier">doc</span> = <span class="ruby-constant">XML</span>.<span class="ruby-identifier">get_xml_doc</span>(<span class="ruby-constant">S33r</span>.<span class="ruby-identifier">remove_namespace</span>(<span class="ruby-identifier">bucket_list_xml</span>))
1247
- 194:
1248
- 195: <span class="ruby-identifier">named_buckets</span> = []
1249
- 196:
1250
- 197: <span class="ruby-identifier">doc</span>.<span class="ruby-identifier">find</span>(<span class="ruby-value str">&quot;//Bucket&quot;</span>).<span class="ruby-identifier">to_a</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">node</span><span class="ruby-operator">|</span>
1251
- 198: <span class="ruby-identifier">bucket_name</span> = <span class="ruby-identifier">node</span>.<span class="ruby-identifier">xget</span>(<span class="ruby-value str">'Name'</span>)
1252
- 199: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">bucket_name</span>
1253
- 200: <span class="ruby-comment cmt"># The NamedBucket instances inherit the request dumping behaviour</span>
1254
- 201: <span class="ruby-comment cmt"># of this client.</span>
1255
- 202: <span class="ruby-identifier">named_buckets</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-constant">NamedBucket</span>.<span class="ruby-identifier">new</span>(<span class="ruby-ivar">@aws_access_key</span>, <span class="ruby-ivar">@aws_secret_access_key</span>,
1256
- 203: {<span class="ruby-identifier">:default_bucket</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">bucket_name</span>, <span class="ruby-identifier">:dump_request</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">dump_requests</span>})
1257
- 204: <span class="ruby-keyword kw">end</span>
1258
- 205: <span class="ruby-keyword kw">end</span>
1259
- 206:
1260
- 207: <span class="ruby-identifier">named_buckets</span>
1261
- 208: <span class="ruby-keyword kw">end</span>
1262
- </pre>
1263
- </div>
1264
- </div>
1265
- </div>
1266
-
1267
- <div id="method-M000135" class="method-detail">
1268
- <a name="M000135"></a>
1269
-
1270
- <div class="method-heading">
1271
- <a href="#M000135" class="method-signature">
1272
- <span class="method-name">make_private</span><span class="method-args">()</span>
1273
- </a>
1274
- </div>
1275
-
1276
- <div class="method-description">
1277
- <p><a class="source-toggle" href="#"
1278
- onclick="toggleCode('M000135-source');return false;">[Source]</a></p>
1279
- <div class="method-source-code" id="M000135-source">
1280
- <pre>
1281
- <span class="ruby-comment cmt"># File lib/s33r/client.rb, line 373</span>
1282
- 373: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">make_private</span>
1283
- 374: <span class="ruby-keyword kw">end</span>
1284
- </pre>
1285
- </div>
1286
- </div>
1287
- </div>
1288
-
1289
- <div id="method-M000134" class="method-detail">
1290
- <a name="M000134"></a>
1291
-
1292
- <div class="method-heading">
1293
- <a href="#M000134" class="method-signature">
1294
- <span class="method-name">make_public</span><span class="method-args">(bucket_name, resource_key='')</span>
1295
- </a>
1296
- </div>
1297
-
1298
- <div class="method-description">
1299
- <p>
1300
- Make a resource public (i.e. grant READ permissions to the AllUsers group
1301
- type). NB separate method is used on buckets, to make all of their content
1302
- public too.
1303
- </p>
1304
- <p>
1305
- Returns nil if resource does not exist.
1306
- </p>
1307
- <p><a class="source-toggle" href="#"
1308
- onclick="toggleCode('M000134-source');return false;">[Source]</a></p>
1309
- <div class="method-source-code" id="M000134-source">
1310
- <pre>
1311
- <span class="ruby-comment cmt"># File lib/s33r/client.rb, line 365</span>
1312
- 365: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">make_public</span>(<span class="ruby-identifier">bucket_name</span>, <span class="ruby-identifier">resource_key</span>=<span class="ruby-value str">''</span>)
1313
- 366: <span class="ruby-identifier">acl</span> = <span class="ruby-identifier">get_acl</span>(<span class="ruby-identifier">bucket_name</span>, <span class="ruby-identifier">resource_key</span>)
1314
- 367: <span class="ruby-keyword kw">if</span> <span class="ruby-operator">!</span><span class="ruby-identifier">acl</span>.<span class="ruby-identifier">nil?</span> <span class="ruby-keyword kw">and</span> <span class="ruby-identifier">acl</span>.<span class="ruby-identifier">add_public_read_grants</span>
1315
- 368: <span class="ruby-identifier">set_acl</span>(<span class="ruby-identifier">acl</span>, <span class="ruby-identifier">bucket_name</span>, <span class="ruby-identifier">resource_key</span>)
1316
- 369: <span class="ruby-keyword kw">end</span>
1317
- 370: <span class="ruby-keyword kw">end</span>
1318
- </pre>
1319
- </div>
1320
- </div>
1321
- </div>
1322
-
1323
- <div id="method-M000143" class="method-detail">
1324
- <a name="M000143"></a>
1325
-
1326
- <div class="method-heading">
1327
- <a href="#M000143" class="method-signature">
1328
- <span class="method-name">put_file</span><span class="method-args">(filename, bucket_name, resource_key=nil, headers={}, options={})</span>
1329
- </a>
1330
- </div>
1331
-
1332
- <div class="method-description">
1333
- <p>
1334
- Put a file onto S3.
1335
- </p>
1336
- <p>
1337
- If <tt>resource_key</tt> is nil, the filename is used as the key instead.
1338
- </p>
1339
- <p>
1340
- <tt>headers</tt> sets some headers with the request; useful if you have an
1341
- odd file type not recognised by the mimetypes library, and want to
1342
- explicitly set the Content-Type header.
1343
- </p>
1344
- <p>
1345
- <tt>options</tt> hash simplifies setting some headers with specific meaning
1346
- to S3:
1347
- </p>
1348
- <ul>
1349
- <li><tt>:render_as_attachment =&gt; true</tt>: set the Content-Disposition for
1350
- this file to &quot;attachment&quot; and set the default filename for saving
1351
- the file (when accessed by a web browser) to <tt>filename</tt>; this turns
1352
- the file into a download when opened in a browser, rather than trying to
1353
- render it inline.
1354
-
1355
- </li>
1356
- </ul>
1357
- <p>
1358
- Note that this method uses a handle to the file, so it can be streamed in
1359
- chunks to S3.
1360
- </p>
1361
- <p><a class="source-toggle" href="#"
1362
- onclick="toggleCode('M000143-source');return false;">[Source]</a></p>
1363
- <div class="method-source-code" id="M000143-source">
1364
- <pre>
1365
- <span class="ruby-comment cmt"># File lib/s33r/client.rb, line 473</span>
1366
- 473: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">put_file</span>(<span class="ruby-identifier">filename</span>, <span class="ruby-identifier">bucket_name</span>, <span class="ruby-identifier">resource_key</span>=<span class="ruby-keyword kw">nil</span>, <span class="ruby-identifier">headers</span>={}, <span class="ruby-identifier">options</span>={})
1367
- 474: <span class="ruby-comment cmt"># default to the file path as the resource key if none explicitly set</span>
1368
- 475: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">resource_key</span>.<span class="ruby-identifier">nil?</span>
1369
- 476: <span class="ruby-identifier">resource_key</span> = <span class="ruby-identifier">filename</span>
1370
- 477: <span class="ruby-keyword kw">end</span>
1371
- 478:
1372
- 479: <span class="ruby-comment cmt"># set Content-Disposition header</span>
1373
- 480: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">options</span>[<span class="ruby-identifier">:render_as_attachment</span>]
1374
- 481: <span class="ruby-identifier">headers</span>[<span class="ruby-value str">'Content-Disposition'</span>] = <span class="ruby-node">&quot;attachment; filename=#{File.basename(filename)}&quot;</span>
1375
- 482: <span class="ruby-keyword kw">end</span>
1376
- 483:
1377
- 484: <span class="ruby-comment cmt"># content type is explicitly set in the headers, so apply to request</span>
1378
- 485: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">headers</span>[<span class="ruby-identifier">:content_type</span>]
1379
- 486: <span class="ruby-comment cmt"># use the first MIME type corresponding to this content type string</span>
1380
- 487: <span class="ruby-comment cmt"># (MIME::Types returns an array of possible MIME types)</span>
1381
- 488: <span class="ruby-identifier">mime_type</span> = <span class="ruby-constant">MIME</span><span class="ruby-operator">::</span><span class="ruby-constant">Types</span>[<span class="ruby-identifier">headers</span>[<span class="ruby-identifier">:content_type</span>]][<span class="ruby-value">0</span>]
1382
- 489: <span class="ruby-keyword kw">else</span>
1383
- 490: <span class="ruby-comment cmt"># we're not going to use this much, just for parsing the content type etc.</span>
1384
- 491: <span class="ruby-identifier">mime_type</span> = <span class="ruby-identifier">guess_mime_type</span>(<span class="ruby-identifier">filename</span>)
1385
- 492: <span class="ruby-keyword kw">end</span>
1386
- 493: <span class="ruby-identifier">content_type</span> = <span class="ruby-identifier">mime_type</span>.<span class="ruby-identifier">simplified</span>
1387
- 494: <span class="ruby-identifier">headers</span>[<span class="ruby-value str">'Content-Type'</span>] = <span class="ruby-identifier">content_type</span>
1388
- 495: <span class="ruby-identifier">headers</span>[<span class="ruby-value str">'Content-Transfer-Encoding'</span>] = <span class="ruby-value str">'binary'</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">mime_type</span>.<span class="ruby-identifier">binary?</span>
1389
- 496:
1390
- 497: <span class="ruby-comment cmt"># Open the file, and pass the handle to the HTTP client so content</span>
1391
- 498: <span class="ruby-comment cmt"># can be streamed.</span>
1392
- 499: <span class="ruby-constant">File</span>.<span class="ruby-identifier">open</span>(<span class="ruby-identifier">filename</span>) <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">data</span><span class="ruby-operator">|</span>
1393
- 500: <span class="ruby-comment cmt"># send the put request</span>
1394
- 501: <span class="ruby-identifier">put_resource</span>(<span class="ruby-identifier">bucket_name</span>, <span class="ruby-identifier">resource_key</span>, <span class="ruby-identifier">data</span>, <span class="ruby-identifier">headers</span>)
1395
- 502: <span class="ruby-keyword kw">end</span>
1396
- 503: <span class="ruby-keyword kw">end</span>
1397
- </pre>
1398
- </div>
1399
- </div>
1400
- </div>
1401
-
1402
- <div id="method-M000141" class="method-detail">
1403
- <a name="M000141"></a>
1404
-
1405
- <div class="method-heading">
1406
- <a href="#M000141" class="method-signature">
1407
- <span class="method-name">put_resource</span><span class="method-args">(bucket_name, resource_key, data, headers={})</span>
1408
- </a>
1409
- </div>
1410
-
1411
- <div class="method-description">
1412
- <p>
1413
- Put some generic resource onto S3.
1414
- </p>
1415
- <p>
1416
- To stream with this method, <tt>data</tt> should respond to the
1417
- <tt>stat</tt> method; examples of data types which respond to this include
1418
- File instances.
1419
- </p>
1420
- <p><a class="source-toggle" href="#"
1421
- onclick="toggleCode('M000141-source');return false;">[Source]</a></p>
1422
- <div class="method-source-code" id="M000141-source">
1423
- <pre>
1424
- <span class="ruby-comment cmt"># File lib/s33r/client.rb, line 448</span>
1425
- 448: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">put_resource</span>(<span class="ruby-identifier">bucket_name</span>, <span class="ruby-identifier">resource_key</span>, <span class="ruby-identifier">data</span>, <span class="ruby-identifier">headers</span>={})
1426
- 449: <span class="ruby-identifier">raise</span> <span class="ruby-constant">S33r</span><span class="ruby-operator">::</span><span class="ruby-constant">S33rException</span><span class="ruby-operator">::</span><span class="ruby-constant">TryingToPutEmptyResource</span>, <span class="ruby-node">&quot;No data to put for key '#{resource_key}'&quot;</span> <span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">data</span>
1427
- 450: <span class="ruby-identifier">resp</span> = <span class="ruby-identifier">do_put</span>(<span class="ruby-node">&quot;/#{bucket_name}/&quot;</span> <span class="ruby-operator">+</span> <span class="ruby-node">&quot;#{CGI::escape(resource_key)}&quot;</span>, <span class="ruby-identifier">data</span>, <span class="ruby-identifier">headers</span>)
1428
- 451: <span class="ruby-identifier">resp</span>.<span class="ruby-identifier">ok?</span>
1429
- 452: <span class="ruby-keyword kw">end</span>
1430
- </pre>
1431
- </div>
1432
- </div>
1433
- </div>
1434
-
1435
- <div id="method-M000142" class="method-detail">
1436
- <a name="M000142"></a>
1437
-
1438
- <div class="method-heading">
1439
- <a href="#M000142" class="method-signature">
1440
- <span class="method-name">put_text</span><span class="method-args">(string, bucket_name, resource_key, headers={})</span>
1441
- </a>
1442
- </div>
1443
-
1444
- <div class="method-description">
1445
- <p>
1446
- Put a string onto S3.
1447
- </p>
1448
- <p><a class="source-toggle" href="#"
1449
- onclick="toggleCode('M000142-source');return false;">[Source]</a></p>
1450
- <div class="method-source-code" id="M000142-source">
1451
- <pre>
1452
- <span class="ruby-comment cmt"># File lib/s33r/client.rb, line 455</span>
1453
- 455: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">put_text</span>(<span class="ruby-identifier">string</span>, <span class="ruby-identifier">bucket_name</span>, <span class="ruby-identifier">resource_key</span>, <span class="ruby-identifier">headers</span>={})
1454
- 456: <span class="ruby-identifier">headers</span>[<span class="ruby-value str">&quot;Content-Type&quot;</span>] = <span class="ruby-value str">&quot;text/plain&quot;</span>
1455
- 457: <span class="ruby-identifier">put_resource</span>(<span class="ruby-identifier">bucket_name</span>, <span class="ruby-identifier">resource_key</span>, <span class="ruby-identifier">string</span>, <span class="ruby-identifier">headers</span>)
1456
- 458: <span class="ruby-keyword kw">end</span>
1457
- </pre>
1458
- </div>
1459
- </div>
1460
- </div>
1461
-
1462
- <div id="method-M000129" class="method-detail">
1463
- <a name="M000129"></a>
1464
-
1465
- <div class="method-heading">
1466
- <a href="#M000129" class="method-signature">
1467
- <span class="method-name">resource_exists?</span><span class="method-args">(bucket_name, resource_key=nil)</span>
1468
- </a>
1469
- </div>
1470
-
1471
- <div class="method-description">
1472
- <p>
1473
- Check whether a bucket contains a key.
1474
- </p>
1475
- <p>
1476
- Returns true if resource_key exists inside bucket_name.
1477
- </p>
1478
- <p><a class="source-toggle" href="#"
1479
- onclick="toggleCode('M000129-source');return false;">[Source]</a></p>
1480
- <div class="method-source-code" id="M000129-source">
1481
- <pre>
1482
- <span class="ruby-comment cmt"># File lib/s33r/client.rb, line 309</span>
1483
- 309: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">resource_exists?</span>(<span class="ruby-identifier">bucket_name</span>, <span class="ruby-identifier">resource_key</span>=<span class="ruby-keyword kw">nil</span>)
1484
- 310: <span class="ruby-identifier">path</span> = <span class="ruby-node">&quot;/#{bucket_name}&quot;</span>
1485
- 311: <span class="ruby-identifier">path</span> <span class="ruby-operator">+=</span> <span class="ruby-node">&quot;/#{resource_key}&quot;</span> <span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">resource_key</span>.<span class="ruby-identifier">nil?</span>
1486
- 312: <span class="ruby-identifier">do_head</span>(<span class="ruby-identifier">path</span>).<span class="ruby-identifier">ok?</span>
1487
- 313: <span class="ruby-keyword kw">end</span>
1488
- </pre>
1489
- </div>
1490
- </div>
1491
- </div>
1492
-
1493
- <div id="method-M000132" class="method-detail">
1494
- <a name="M000132"></a>
1495
-
1496
- <div class="method-heading">
1497
- <a href="#M000132" class="method-signature">
1498
- <span class="method-name">set_acl</span><span class="method-args">(acl_doc, bucket_name, resource_key='')</span>
1499
- </a>
1500
- </div>
1501
-
1502
- <div class="method-description">
1503
- <p>
1504
- Put the ACL document back to a resource.
1505
- </p>
1506
- <p>
1507
- <tt>acl_doc</tt> is an <a href="S3ACL/ACLDoc.html">S33r::S3ACL::ACLDoc</a>
1508
- instance.
1509
- </p>
1510
- <p>
1511
- Returns true if response had a 200 code, false otherwise. If you get a 400
1512
- Bad Request back, it means a CanonicalUser could not be identified from the
1513
- email address.
1514
- </p>
1515
- <p><a class="source-toggle" href="#"
1516
- onclick="toggleCode('M000132-source');return false;">[Source]</a></p>
1517
- <div class="method-source-code" id="M000132-source">
1518
- <pre>
1519
- <span class="ruby-comment cmt"># File lib/s33r/client.rb, line 343</span>
1520
- 343: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">set_acl</span>(<span class="ruby-identifier">acl_doc</span>, <span class="ruby-identifier">bucket_name</span>, <span class="ruby-identifier">resource_key</span>=<span class="ruby-value str">''</span>)
1521
- 344: <span class="ruby-identifier">path</span> = <span class="ruby-identifier">s3_acl_path</span>(<span class="ruby-identifier">bucket_name</span>, <span class="ruby-identifier">resource_key</span>)
1522
- 345: <span class="ruby-identifier">response</span> = <span class="ruby-identifier">do_put</span>(<span class="ruby-identifier">path</span>, <span class="ruby-identifier">acl_doc</span>.<span class="ruby-identifier">to_xml</span>)
1523
- 346: <span class="ruby-identifier">response</span>.<span class="ruby-identifier">ok?</span>
1524
- 347: <span class="ruby-keyword kw">end</span>
1525
- </pre>
1526
- </div>
1527
- </div>
1528
- </div>
1529
-
1530
- <div id="method-M000133" class="method-detail">
1531
- <a name="M000133"></a>
1532
-
1533
- <div class="method-heading">
1534
- <a href="#M000133" class="method-signature">
1535
- <span class="method-name">set_logging</span><span class="method-args">(logging_resource, bucket_name, resource_key='')</span>
1536
- </a>
1537
- </div>
1538
-
1539
- <div class="method-description">
1540
- <p>
1541
- Set up logging for a bucket and resource key.
1542
- </p>
1543
- <p>
1544
- <tt>logging_resource</tt> = a <a
1545
- href="LoggingResource.html">LoggingResource</a> instance.
1546
- <tt>bucket_name</tt> = a bucket to log. <tt>resource_key</tt> = a resource
1547
- to log (if empty, logging gets added to the bucket).
1548
- </p>
1549
- <p><a class="source-toggle" href="#"
1550
- onclick="toggleCode('M000133-source');return false;">[Source]</a></p>
1551
- <div class="method-source-code" id="M000133-source">
1552
- <pre>
1553
- <span class="ruby-comment cmt"># File lib/s33r/client.rb, line 355</span>
1554
- 355: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">set_logging</span>(<span class="ruby-identifier">logging_resource</span>, <span class="ruby-identifier">bucket_name</span>, <span class="ruby-identifier">resource_key</span>=<span class="ruby-value str">''</span>)
1555
- 356: <span class="ruby-identifier">path</span> = <span class="ruby-identifier">s3_logging_path</span>(<span class="ruby-identifier">bucket_name</span>, <span class="ruby-identifier">resource_key</span>)
1556
- 357: <span class="ruby-identifier">response</span> = <span class="ruby-identifier">do_put</span>(<span class="ruby-identifier">path</span>, <span class="ruby-identifier">logging_resource</span>.<span class="ruby-identifier">to_xml</span>)
1557
- 358: <span class="ruby-keyword kw">end</span>
1558
- </pre>
1559
- </div>
1560
- </div>
1561
- </div>
1562
-
1563
-
1564
- </div>
1565
-
1566
-
1567
- </div>
1568
-
1569
-
1570
- <div id="validator-badges">
1571
- <p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
1572
- </div>
1573
-
1574
- </body>
1575
- </html>