bucket_sdk 0.1.0 → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.idea/.gitignore +8 -8
- data/.idea/bucket-sdk.iml +92 -92
- data/.idea/modules.xml +7 -7
- data/examples/basic_usage.rb +38 -38
- data/examples/upload_file.rb +72 -72
- data/lib/bucket_sdk/client.rb +81 -79
- data/lib/bucket_sdk/models/list_response.rb +19 -19
- data/lib/bucket_sdk/models/load_request.rb +24 -24
- data/lib/bucket_sdk/models/load_response.rb +19 -19
- data/lib/bucket_sdk/models/validation_error.rb +20 -20
- data/lib/bucket_sdk/models.rb +11 -11
- data/lib/bucket_sdk/version.rb +1 -1
- data/lib/bucket_sdk.rb +8 -8
- data/sig/bucket_sdk/client.rbs +8 -8
- data/sig/bucket_sdk/models/list_response.rbs +9 -9
- data/sig/bucket_sdk/models/load_request.rbs +10 -10
- data/sig/bucket_sdk/models/load_response.rbs +7 -7
- metadata +6 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d23795c8e442e8de774bbe7ef7e1f8f67ca377bf6464e4466ea01a2e4428ea5a
|
4
|
+
data.tar.gz: 7ef4565e268664a4e5c624b976f2491896701955edd1799c0a0ff3bf7d4296b9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b4d2587b608b760ee60310e30e3b9a15986d975adef29ed48121a395d61355b0d88f1f0257ad40525071ab80ec29ec93a63b76d0afae880b9f95f8a560b726df
|
7
|
+
data.tar.gz: f7ffa850c1635efb0f5d5ec43cdfc98dfaff9507e3d7165723d21f20aeed60ddefe52dc22816e723decc211cab50113f5bba9b7984644273ac1c33700bc10337
|
data/.idea/.gitignore
CHANGED
@@ -1,8 +1,8 @@
|
|
1
|
-
# Default ignored files
|
2
|
-
/shelf/
|
3
|
-
/workspace.xml
|
4
|
-
# Editor-based HTTP Client requests
|
5
|
-
/httpRequests/
|
6
|
-
# Datasource local storage ignored files
|
7
|
-
/dataSources/
|
8
|
-
/dataSources.local.xml
|
1
|
+
# Default ignored files
|
2
|
+
/shelf/
|
3
|
+
/workspace.xml
|
4
|
+
# Editor-based HTTP Client requests
|
5
|
+
/httpRequests/
|
6
|
+
# Datasource local storage ignored files
|
7
|
+
/dataSources/
|
8
|
+
/dataSources.local.xml
|
data/.idea/bucket-sdk.iml
CHANGED
@@ -1,93 +1,93 @@
|
|
1
|
-
<?xml version="1.0" encoding="UTF-8"?>
|
2
|
-
<module type="RUBY_MODULE" version="4">
|
3
|
-
<component name="ModuleRunConfigurationManager">
|
4
|
-
<shared />
|
5
|
-
</component>
|
6
|
-
<component name="NewModuleRootManager">
|
7
|
-
<content url="file://$MODULE_DIR$">
|
8
|
-
<sourceFolder url="file://$MODULE_DIR$/features" isTestSource="true" />
|
9
|
-
<sourceFolder url="file://$MODULE_DIR$/spec" isTestSource="true" />
|
10
|
-
<sourceFolder url="file://$MODULE_DIR$/test" isTestSource="true" />
|
11
|
-
</content>
|
12
|
-
<orderEntry type="jdk" jdkName="
|
13
|
-
<orderEntry type="sourceFolder" forTests="false" />
|
14
|
-
<orderEntry type="library" scope="PROVIDED" name="addressable (v2.8.7,
|
15
|
-
<orderEntry type="library" scope="PROVIDED" name="ast (v2.4.3,
|
16
|
-
<orderEntry type="library" scope="PROVIDED" name="bigdecimal (v3.1.9,
|
17
|
-
<orderEntry type="library" scope="PROVIDED" name="bundler (v2.6.2,
|
18
|
-
<orderEntry type="library" scope="PROVIDED" name="crack (v1.0.0,
|
19
|
-
<orderEntry type="library" scope="PROVIDED" name="diff-lcs (v1.6.0,
|
20
|
-
<orderEntry type="library" scope="PROVIDED" name="faraday (v2.12.2,
|
21
|
-
<orderEntry type="library" scope="PROVIDED" name="faraday-multipart (v1.1.0,
|
22
|
-
<orderEntry type="library" scope="PROVIDED" name="faraday-net_http (v3.4.0,
|
23
|
-
<orderEntry type="library" scope="PROVIDED" name="hashdiff (v1.1.2,
|
24
|
-
<orderEntry type="library" scope="PROVIDED" name="json (v2.10.2,
|
25
|
-
<orderEntry type="library" scope="PROVIDED" name="language_server-protocol (v3.17.0.4,
|
26
|
-
<orderEntry type="library" scope="PROVIDED" name="lint_roller (v1.1.0,
|
27
|
-
<orderEntry type="library" scope="PROVIDED" name="logger (v1.6.6,
|
28
|
-
<orderEntry type="library" scope="PROVIDED" name="multipart-post (v2.4.1,
|
29
|
-
<orderEntry type="library" scope="PROVIDED" name="net-http (v0.6.0,
|
30
|
-
<orderEntry type="library" scope="PROVIDED" name="parallel (v1.26.3,
|
31
|
-
<orderEntry type="library" scope="PROVIDED" name="parser (v3.3.7.2,
|
32
|
-
<orderEntry type="library" scope="PROVIDED" name="public_suffix (v6.0.1,
|
33
|
-
<orderEntry type="library" scope="PROVIDED" name="racc (v1.8.1,
|
34
|
-
<orderEntry type="library" scope="PROVIDED" name="rainbow (v3.1.1,
|
35
|
-
<orderEntry type="library" scope="PROVIDED" name="rake (v13.2.1,
|
36
|
-
<orderEntry type="library" scope="PROVIDED" name="regexp_parser (v2.10.0,
|
37
|
-
<orderEntry type="library" scope="PROVIDED" name="rexml (v3.4.1,
|
38
|
-
<orderEntry type="library" scope="PROVIDED" name="rspec (v3.13.0,
|
39
|
-
<orderEntry type="library" scope="PROVIDED" name="rspec-core (v3.13.3,
|
40
|
-
<orderEntry type="library" scope="PROVIDED" name="rspec-expectations (v3.13.3,
|
41
|
-
<orderEntry type="library" scope="PROVIDED" name="rspec-mocks (v3.13.2,
|
42
|
-
<orderEntry type="library" scope="PROVIDED" name="rspec-support (v3.13.2,
|
43
|
-
<orderEntry type="library" scope="PROVIDED" name="rubocop (v1.74.0,
|
44
|
-
<orderEntry type="library" scope="PROVIDED" name="rubocop-ast (v1.41.0,
|
45
|
-
<orderEntry type="library" scope="PROVIDED" name="ruby-progressbar (v1.13.0,
|
46
|
-
<orderEntry type="library" scope="PROVIDED" name="unicode-display_width (v3.1.4,
|
47
|
-
<orderEntry type="library" scope="PROVIDED" name="unicode-emoji (v4.0.4,
|
48
|
-
<orderEntry type="library" scope="PROVIDED" name="uri (v1.0.3,
|
49
|
-
<orderEntry type="library" scope="PROVIDED" name="webmock (v3.25.1,
|
50
|
-
<orderEntry type="library" scope="PROVIDED" name="zeitwerk (v2.7.2,
|
51
|
-
</component>
|
52
|
-
<component name="RakeTasksCache-v2">
|
53
|
-
<option name="myRootTask">
|
54
|
-
<RakeTaskImpl id="rake">
|
55
|
-
<subtasks>
|
56
|
-
<RakeTaskImpl description="Build bucket_sdk-0.1.0.gem into the pkg directory" fullCommand="build" id="build" />
|
57
|
-
<RakeTaskImpl id="build">
|
58
|
-
<subtasks>
|
59
|
-
<RakeTaskImpl description="Generate SHA512 checksum of bucket_sdk-0.1.0.gem into the checksums directory" fullCommand="build:checksum" id="checksum" />
|
60
|
-
</subtasks>
|
61
|
-
</RakeTaskImpl>
|
62
|
-
<RakeTaskImpl description="Remove any temporary products" fullCommand="clean" id="clean" />
|
63
|
-
<RakeTaskImpl description="Remove any generated files" fullCommand="clobber" id="clobber" />
|
64
|
-
<RakeTaskImpl description="Build and install bucket_sdk-0.1.0.gem into system gems" fullCommand="install" id="install" />
|
65
|
-
<RakeTaskImpl id="install">
|
66
|
-
<subtasks>
|
67
|
-
<RakeTaskImpl description="Build and install bucket_sdk-0.1.0.gem into system gems without network access" fullCommand="install:local" id="local" />
|
68
|
-
</subtasks>
|
69
|
-
</RakeTaskImpl>
|
70
|
-
<RakeTaskImpl description="Create tag v0.1.0 and build and push bucket_sdk-0.1.0.gem to https://rubygems.org" fullCommand="release[remote]" id="release[remote]" />
|
71
|
-
<RakeTaskImpl description="Run RuboCop" fullCommand="rubocop" id="rubocop" />
|
72
|
-
<RakeTaskImpl id="rubocop">
|
73
|
-
<subtasks>
|
74
|
-
<RakeTaskImpl description="Autocorrect RuboCop offenses (only when it's safe)" fullCommand="rubocop:autocorrect" id="autocorrect" />
|
75
|
-
<RakeTaskImpl description="Autocorrect RuboCop offenses (safe and unsafe)" fullCommand="rubocop:autocorrect_all" id="autocorrect_all" />
|
76
|
-
<RakeTaskImpl description="" fullCommand="rubocop:auto_correct" id="auto_correct" />
|
77
|
-
</subtasks>
|
78
|
-
</RakeTaskImpl>
|
79
|
-
<RakeTaskImpl description="Run RSpec code examples" fullCommand="spec" id="spec" />
|
80
|
-
<RakeTaskImpl description="" fullCommand="default" id="default" />
|
81
|
-
<RakeTaskImpl description="" fullCommand="release" id="release" />
|
82
|
-
<RakeTaskImpl id="release">
|
83
|
-
<subtasks>
|
84
|
-
<RakeTaskImpl description="" fullCommand="release:guard_clean" id="guard_clean" />
|
85
|
-
<RakeTaskImpl description="" fullCommand="release:rubygem_push" id="rubygem_push" />
|
86
|
-
<RakeTaskImpl description="" fullCommand="release:source_control_push" id="source_control_push" />
|
87
|
-
</subtasks>
|
88
|
-
</RakeTaskImpl>
|
89
|
-
</subtasks>
|
90
|
-
</RakeTaskImpl>
|
91
|
-
</option>
|
92
|
-
</component>
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
2
|
+
<module type="RUBY_MODULE" version="4">
|
3
|
+
<component name="ModuleRunConfigurationManager">
|
4
|
+
<shared />
|
5
|
+
</component>
|
6
|
+
<component name="NewModuleRootManager">
|
7
|
+
<content url="file://$MODULE_DIR$">
|
8
|
+
<sourceFolder url="file://$MODULE_DIR$/features" isTestSource="true" />
|
9
|
+
<sourceFolder url="file://$MODULE_DIR$/spec" isTestSource="true" />
|
10
|
+
<sourceFolder url="file://$MODULE_DIR$/test" isTestSource="true" />
|
11
|
+
</content>
|
12
|
+
<orderEntry type="jdk" jdkName="rbenv: 3.3.5" jdkType="RUBY_SDK" />
|
13
|
+
<orderEntry type="sourceFolder" forTests="false" />
|
14
|
+
<orderEntry type="library" scope="PROVIDED" name="addressable (v2.8.7, rbenv: 3.3.5) [gem]" level="application" />
|
15
|
+
<orderEntry type="library" scope="PROVIDED" name="ast (v2.4.3, rbenv: 3.3.5) [gem]" level="application" />
|
16
|
+
<orderEntry type="library" scope="PROVIDED" name="bigdecimal (v3.1.9, rbenv: 3.3.5) [gem]" level="application" />
|
17
|
+
<orderEntry type="library" scope="PROVIDED" name="bundler (v2.6.2, rbenv: 3.3.5) [gem]" level="application" />
|
18
|
+
<orderEntry type="library" scope="PROVIDED" name="crack (v1.0.0, rbenv: 3.3.5) [gem]" level="application" />
|
19
|
+
<orderEntry type="library" scope="PROVIDED" name="diff-lcs (v1.6.0, rbenv: 3.3.5) [gem]" level="application" />
|
20
|
+
<orderEntry type="library" scope="PROVIDED" name="faraday (v2.12.2, rbenv: 3.3.5) [gem]" level="application" />
|
21
|
+
<orderEntry type="library" scope="PROVIDED" name="faraday-multipart (v1.1.0, rbenv: 3.3.5) [gem]" level="application" />
|
22
|
+
<orderEntry type="library" scope="PROVIDED" name="faraday-net_http (v3.4.0, rbenv: 3.3.5) [gem]" level="application" />
|
23
|
+
<orderEntry type="library" scope="PROVIDED" name="hashdiff (v1.1.2, rbenv: 3.3.5) [gem]" level="application" />
|
24
|
+
<orderEntry type="library" scope="PROVIDED" name="json (v2.10.2, rbenv: 3.3.5) [gem]" level="application" />
|
25
|
+
<orderEntry type="library" scope="PROVIDED" name="language_server-protocol (v3.17.0.4, rbenv: 3.3.5) [gem]" level="application" />
|
26
|
+
<orderEntry type="library" scope="PROVIDED" name="lint_roller (v1.1.0, rbenv: 3.3.5) [gem]" level="application" />
|
27
|
+
<orderEntry type="library" scope="PROVIDED" name="logger (v1.6.6, rbenv: 3.3.5) [gem]" level="application" />
|
28
|
+
<orderEntry type="library" scope="PROVIDED" name="multipart-post (v2.4.1, rbenv: 3.3.5) [gem]" level="application" />
|
29
|
+
<orderEntry type="library" scope="PROVIDED" name="net-http (v0.6.0, rbenv: 3.3.5) [gem]" level="application" />
|
30
|
+
<orderEntry type="library" scope="PROVIDED" name="parallel (v1.26.3, rbenv: 3.3.5) [gem]" level="application" />
|
31
|
+
<orderEntry type="library" scope="PROVIDED" name="parser (v3.3.7.2, rbenv: 3.3.5) [gem]" level="application" />
|
32
|
+
<orderEntry type="library" scope="PROVIDED" name="public_suffix (v6.0.1, rbenv: 3.3.5) [gem]" level="application" />
|
33
|
+
<orderEntry type="library" scope="PROVIDED" name="racc (v1.8.1, rbenv: 3.3.5) [gem]" level="application" />
|
34
|
+
<orderEntry type="library" scope="PROVIDED" name="rainbow (v3.1.1, rbenv: 3.3.5) [gem]" level="application" />
|
35
|
+
<orderEntry type="library" scope="PROVIDED" name="rake (v13.2.1, rbenv: 3.3.5) [gem]" level="application" />
|
36
|
+
<orderEntry type="library" scope="PROVIDED" name="regexp_parser (v2.10.0, rbenv: 3.3.5) [gem]" level="application" />
|
37
|
+
<orderEntry type="library" scope="PROVIDED" name="rexml (v3.4.1, rbenv: 3.3.5) [gem]" level="application" />
|
38
|
+
<orderEntry type="library" scope="PROVIDED" name="rspec (v3.13.0, rbenv: 3.3.5) [gem]" level="application" />
|
39
|
+
<orderEntry type="library" scope="PROVIDED" name="rspec-core (v3.13.3, rbenv: 3.3.5) [gem]" level="application" />
|
40
|
+
<orderEntry type="library" scope="PROVIDED" name="rspec-expectations (v3.13.3, rbenv: 3.3.5) [gem]" level="application" />
|
41
|
+
<orderEntry type="library" scope="PROVIDED" name="rspec-mocks (v3.13.2, rbenv: 3.3.5) [gem]" level="application" />
|
42
|
+
<orderEntry type="library" scope="PROVIDED" name="rspec-support (v3.13.2, rbenv: 3.3.5) [gem]" level="application" />
|
43
|
+
<orderEntry type="library" scope="PROVIDED" name="rubocop (v1.74.0, rbenv: 3.3.5) [gem]" level="application" />
|
44
|
+
<orderEntry type="library" scope="PROVIDED" name="rubocop-ast (v1.41.0, rbenv: 3.3.5) [gem]" level="application" />
|
45
|
+
<orderEntry type="library" scope="PROVIDED" name="ruby-progressbar (v1.13.0, rbenv: 3.3.5) [gem]" level="application" />
|
46
|
+
<orderEntry type="library" scope="PROVIDED" name="unicode-display_width (v3.1.4, rbenv: 3.3.5) [gem]" level="application" />
|
47
|
+
<orderEntry type="library" scope="PROVIDED" name="unicode-emoji (v4.0.4, rbenv: 3.3.5) [gem]" level="application" />
|
48
|
+
<orderEntry type="library" scope="PROVIDED" name="uri (v1.0.3, rbenv: 3.3.5) [gem]" level="application" />
|
49
|
+
<orderEntry type="library" scope="PROVIDED" name="webmock (v3.25.1, rbenv: 3.3.5) [gem]" level="application" />
|
50
|
+
<orderEntry type="library" scope="PROVIDED" name="zeitwerk (v2.7.2, rbenv: 3.3.5) [gem]" level="application" />
|
51
|
+
</component>
|
52
|
+
<component name="RakeTasksCache-v2">
|
53
|
+
<option name="myRootTask">
|
54
|
+
<RakeTaskImpl id="rake">
|
55
|
+
<subtasks>
|
56
|
+
<RakeTaskImpl description="Build bucket_sdk-0.1.0.gem into the pkg directory" fullCommand="build" id="build" />
|
57
|
+
<RakeTaskImpl id="build">
|
58
|
+
<subtasks>
|
59
|
+
<RakeTaskImpl description="Generate SHA512 checksum of bucket_sdk-0.1.0.gem into the checksums directory" fullCommand="build:checksum" id="checksum" />
|
60
|
+
</subtasks>
|
61
|
+
</RakeTaskImpl>
|
62
|
+
<RakeTaskImpl description="Remove any temporary products" fullCommand="clean" id="clean" />
|
63
|
+
<RakeTaskImpl description="Remove any generated files" fullCommand="clobber" id="clobber" />
|
64
|
+
<RakeTaskImpl description="Build and install bucket_sdk-0.1.0.gem into system gems" fullCommand="install" id="install" />
|
65
|
+
<RakeTaskImpl id="install">
|
66
|
+
<subtasks>
|
67
|
+
<RakeTaskImpl description="Build and install bucket_sdk-0.1.0.gem into system gems without network access" fullCommand="install:local" id="local" />
|
68
|
+
</subtasks>
|
69
|
+
</RakeTaskImpl>
|
70
|
+
<RakeTaskImpl description="Create tag v0.1.0 and build and push bucket_sdk-0.1.0.gem to https://rubygems.org" fullCommand="release[remote]" id="release[remote]" />
|
71
|
+
<RakeTaskImpl description="Run RuboCop" fullCommand="rubocop" id="rubocop" />
|
72
|
+
<RakeTaskImpl id="rubocop">
|
73
|
+
<subtasks>
|
74
|
+
<RakeTaskImpl description="Autocorrect RuboCop offenses (only when it's safe)" fullCommand="rubocop:autocorrect" id="autocorrect" />
|
75
|
+
<RakeTaskImpl description="Autocorrect RuboCop offenses (safe and unsafe)" fullCommand="rubocop:autocorrect_all" id="autocorrect_all" />
|
76
|
+
<RakeTaskImpl description="" fullCommand="rubocop:auto_correct" id="auto_correct" />
|
77
|
+
</subtasks>
|
78
|
+
</RakeTaskImpl>
|
79
|
+
<RakeTaskImpl description="Run RSpec code examples" fullCommand="spec" id="spec" />
|
80
|
+
<RakeTaskImpl description="" fullCommand="default" id="default" />
|
81
|
+
<RakeTaskImpl description="" fullCommand="release" id="release" />
|
82
|
+
<RakeTaskImpl id="release">
|
83
|
+
<subtasks>
|
84
|
+
<RakeTaskImpl description="" fullCommand="release:guard_clean" id="guard_clean" />
|
85
|
+
<RakeTaskImpl description="" fullCommand="release:rubygem_push" id="rubygem_push" />
|
86
|
+
<RakeTaskImpl description="" fullCommand="release:source_control_push" id="source_control_push" />
|
87
|
+
</subtasks>
|
88
|
+
</RakeTaskImpl>
|
89
|
+
</subtasks>
|
90
|
+
</RakeTaskImpl>
|
91
|
+
</option>
|
92
|
+
</component>
|
93
93
|
</module>
|
data/.idea/modules.xml
CHANGED
@@ -1,8 +1,8 @@
|
|
1
|
-
<?xml version="1.0" encoding="UTF-8"?>
|
2
|
-
<project version="4">
|
3
|
-
<component name="ProjectModuleManager">
|
4
|
-
<modules>
|
5
|
-
<module fileurl="file://$PROJECT_DIR$/.idea/bucket-sdk.iml" filepath="$PROJECT_DIR$/.idea/bucket-sdk.iml" />
|
6
|
-
</modules>
|
7
|
-
</component>
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
2
|
+
<project version="4">
|
3
|
+
<component name="ProjectModuleManager">
|
4
|
+
<modules>
|
5
|
+
<module fileurl="file://$PROJECT_DIR$/.idea/bucket-sdk.iml" filepath="$PROJECT_DIR$/.idea/bucket-sdk.iml" />
|
6
|
+
</modules>
|
7
|
+
</component>
|
8
8
|
</project>
|
data/examples/basic_usage.rb
CHANGED
@@ -1,38 +1,38 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
# frozen_string_literal: true
|
3
|
-
|
4
|
-
require "bucket_sdk"
|
5
|
-
|
6
|
-
# Initialize the client
|
7
|
-
client = BucketSdk.new(
|
8
|
-
base_url: "https://api.example.com"
|
9
|
-
)
|
10
|
-
|
11
|
-
# Upload an object
|
12
|
-
begin
|
13
|
-
response = client.upload_object(
|
14
|
-
file: File.open(
|
15
|
-
destination: "path/to/file.txt"
|
16
|
-
)
|
17
|
-
puts "File uploaded successfully. URL: #{response.url}"
|
18
|
-
rescue BucketSdk::Error => e
|
19
|
-
puts "Error uploading file: #{e.message}"
|
20
|
-
end
|
21
|
-
|
22
|
-
# List objects
|
23
|
-
begin
|
24
|
-
response = client.list_objects
|
25
|
-
puts "Objects in bucket:"
|
26
|
-
response.objects.each do |object|
|
27
|
-
puts "- #{object.inspect}"
|
28
|
-
end
|
29
|
-
|
30
|
-
# List objects recursively
|
31
|
-
response = client.list_objects(recurse: true)
|
32
|
-
puts "\nAll objects (recursive):"
|
33
|
-
response.objects.each do |object|
|
34
|
-
puts "- #{object.inspect}"
|
35
|
-
end
|
36
|
-
rescue BucketSdk::Error => e
|
37
|
-
puts "Error listing objects: #{e.message}"
|
38
|
-
end
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
require "bucket_sdk"
|
5
|
+
|
6
|
+
# Initialize the client
|
7
|
+
client = BucketSdk.new(
|
8
|
+
base_url: "https://api.example.com"
|
9
|
+
)
|
10
|
+
|
11
|
+
# Upload an object
|
12
|
+
begin
|
13
|
+
response = client.upload_object(
|
14
|
+
file: File.open("path/to/local/file.txt", "r"),
|
15
|
+
destination: "path/to/file.txt"
|
16
|
+
)
|
17
|
+
puts "File uploaded successfully. URL: #{response.url}"
|
18
|
+
rescue BucketSdk::Error => e
|
19
|
+
puts "Error uploading file: #{e.message}"
|
20
|
+
end
|
21
|
+
|
22
|
+
# List objects
|
23
|
+
begin
|
24
|
+
response = client.list_objects
|
25
|
+
puts "Objects in bucket:"
|
26
|
+
response.objects.each do |object|
|
27
|
+
puts "- #{object.inspect}"
|
28
|
+
end
|
29
|
+
|
30
|
+
# List objects recursively
|
31
|
+
response = client.list_objects(recurse: true)
|
32
|
+
puts "\nAll objects (recursive):"
|
33
|
+
response.objects.each do |object|
|
34
|
+
puts "- #{object.inspect}"
|
35
|
+
end
|
36
|
+
rescue BucketSdk::Error => e
|
37
|
+
puts "Error listing objects: #{e.message}"
|
38
|
+
end
|
data/examples/upload_file.rb
CHANGED
@@ -1,72 +1,72 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
# frozen_string_literal: true
|
3
|
-
|
4
|
-
require "bundler/setup"
|
5
|
-
require "bucket_sdk"
|
6
|
-
|
7
|
-
# Initialize the client
|
8
|
-
client = BucketSdk::Client.new(base_url: "http://localhost:8000")
|
9
|
-
|
10
|
-
# Upload a file from disk using File object
|
11
|
-
file_path = "README.md"
|
12
|
-
destination = "uploads/readme.md"
|
13
|
-
puts "Uploading #{file_path} to #{destination} using File object"
|
14
|
-
|
15
|
-
begin
|
16
|
-
response = client.upload_object(
|
17
|
-
file: File.open(file_path, "r"),
|
18
|
-
destination: destination
|
19
|
-
)
|
20
|
-
puts "File uploaded successfully!"
|
21
|
-
puts "URL: #{response.url}"
|
22
|
-
rescue => e
|
23
|
-
puts "Error uploading file: #{e.message}"
|
24
|
-
end
|
25
|
-
|
26
|
-
# Upload a file from disk using file path
|
27
|
-
file_path = "README.md"
|
28
|
-
destination = "uploads/readme2.md"
|
29
|
-
puts "\nUploading #{file_path} to #{destination} using file path"
|
30
|
-
|
31
|
-
begin
|
32
|
-
response = client.upload_object(
|
33
|
-
file: file_path,
|
34
|
-
destination: destination
|
35
|
-
)
|
36
|
-
puts "File uploaded successfully!"
|
37
|
-
puts "URL: #{response.url}"
|
38
|
-
rescue => e
|
39
|
-
puts "Error uploading file: #{e.message}"
|
40
|
-
end
|
41
|
-
|
42
|
-
# Create a temporary file and upload it
|
43
|
-
puts "\nUploading temporary file"
|
44
|
-
temp_file = Tempfile.new(
|
45
|
-
begin
|
46
|
-
temp_file.write("Hello, world!")
|
47
|
-
temp_file.rewind
|
48
|
-
|
49
|
-
response = client.upload_object(
|
50
|
-
file: temp_file,
|
51
|
-
destination: "uploads/temp.txt"
|
52
|
-
)
|
53
|
-
puts "Temporary file uploaded successfully!"
|
54
|
-
puts "URL: #{response.url}"
|
55
|
-
rescue => e
|
56
|
-
puts "Error uploading temporary file: #{e.message}"
|
57
|
-
ensure
|
58
|
-
temp_file.close
|
59
|
-
temp_file.unlink
|
60
|
-
end
|
61
|
-
|
62
|
-
# List objects
|
63
|
-
puts "\nListing objects:"
|
64
|
-
begin
|
65
|
-
response = client.list_objects(recurse: true)
|
66
|
-
puts "Total objects: #{response.objects.count}"
|
67
|
-
response.objects.each do |obj|
|
68
|
-
puts "- #{obj.inspect}"
|
69
|
-
end
|
70
|
-
rescue => e
|
71
|
-
puts "Error listing objects: #{e.message}"
|
72
|
-
end
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
require "bundler/setup"
|
5
|
+
require "bucket_sdk"
|
6
|
+
|
7
|
+
# Initialize the client
|
8
|
+
client = BucketSdk::Client.new(base_url: "http://localhost:8000")
|
9
|
+
|
10
|
+
# Upload a file from disk using File object
|
11
|
+
file_path = "README.md"
|
12
|
+
destination = "uploads/readme.md"
|
13
|
+
puts "Uploading #{file_path} to #{destination} using File object"
|
14
|
+
|
15
|
+
begin
|
16
|
+
response = client.upload_object(
|
17
|
+
file: File.open(file_path, "r"),
|
18
|
+
destination: destination
|
19
|
+
)
|
20
|
+
puts "File uploaded successfully!"
|
21
|
+
puts "URL: #{response.url}"
|
22
|
+
rescue StandardError => e
|
23
|
+
puts "Error uploading file: #{e.message}"
|
24
|
+
end
|
25
|
+
|
26
|
+
# Upload a file from disk using file path
|
27
|
+
file_path = "README.md"
|
28
|
+
destination = "uploads/readme2.md"
|
29
|
+
puts "\nUploading #{file_path} to #{destination} using file path"
|
30
|
+
|
31
|
+
begin
|
32
|
+
response = client.upload_object(
|
33
|
+
file: file_path,
|
34
|
+
destination: destination
|
35
|
+
)
|
36
|
+
puts "File uploaded successfully!"
|
37
|
+
puts "URL: #{response.url}"
|
38
|
+
rescue StandardError => e
|
39
|
+
puts "Error uploading file: #{e.message}"
|
40
|
+
end
|
41
|
+
|
42
|
+
# Create a temporary file and upload it
|
43
|
+
puts "\nUploading temporary file"
|
44
|
+
temp_file = Tempfile.new("example")
|
45
|
+
begin
|
46
|
+
temp_file.write("Hello, world!")
|
47
|
+
temp_file.rewind
|
48
|
+
|
49
|
+
response = client.upload_object(
|
50
|
+
file: temp_file,
|
51
|
+
destination: "uploads/temp.txt"
|
52
|
+
)
|
53
|
+
puts "Temporary file uploaded successfully!"
|
54
|
+
puts "URL: #{response.url}"
|
55
|
+
rescue StandardError => e
|
56
|
+
puts "Error uploading temporary file: #{e.message}"
|
57
|
+
ensure
|
58
|
+
temp_file.close
|
59
|
+
temp_file.unlink
|
60
|
+
end
|
61
|
+
|
62
|
+
# List objects
|
63
|
+
puts "\nListing objects:"
|
64
|
+
begin
|
65
|
+
response = client.list_objects(recurse: true)
|
66
|
+
puts "Total objects: #{response.objects.count}"
|
67
|
+
response.objects.each do |obj|
|
68
|
+
puts "- #{obj.inspect}"
|
69
|
+
end
|
70
|
+
rescue StandardError => e
|
71
|
+
puts "Error listing objects: #{e.message}"
|
72
|
+
end
|
data/lib/bucket_sdk/client.rb
CHANGED
@@ -1,79 +1,81 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require "faraday"
|
4
|
-
require "faraday/multipart"
|
5
|
-
require "json"
|
6
|
-
require "tempfile"
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
end
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "faraday"
|
4
|
+
require "faraday/multipart"
|
5
|
+
require "json"
|
6
|
+
require "tempfile"
|
7
|
+
|
8
|
+
module BucketSdk
|
9
|
+
class Client
|
10
|
+
attr_reader :base_url, :timeout
|
11
|
+
|
12
|
+
def initialize(base_url:, timeout: 60)
|
13
|
+
@base_url = base_url
|
14
|
+
@timeout = timeout
|
15
|
+
end
|
16
|
+
|
17
|
+
# Upload an object to the bucket
|
18
|
+
# @param file [File, String] The file to upload (either a File object or a path to a file)
|
19
|
+
# @param destination [String] The destination path in the bucket
|
20
|
+
# @return [Models::LoadResponse] The response containing the URL of the uploaded object
|
21
|
+
def upload_object(file:, destination:)
|
22
|
+
response = connection.post("/api/v2/objects") do |req|
|
23
|
+
req.options.timeout = timeout
|
24
|
+
|
25
|
+
# Set up multipart form data
|
26
|
+
payload = {}
|
27
|
+
|
28
|
+
if file.is_a?(File) || file.is_a?(Tempfile)
|
29
|
+
payload[:file] = Faraday::Multipart::FilePart.new(file, "application/octet-stream")
|
30
|
+
elsif file.is_a?(String) && File.exist?(file)
|
31
|
+
# If a string is provided and it's a valid file path, open the file
|
32
|
+
payload[:file] = Faraday::Multipart::FilePart.new(File.open(file, "r"), "application/octet-stream")
|
33
|
+
else
|
34
|
+
raise ArgumentError, "File must be a File object or a valid file path"
|
35
|
+
end
|
36
|
+
|
37
|
+
req.params[:destination] = destination
|
38
|
+
req.body = payload
|
39
|
+
end
|
40
|
+
|
41
|
+
handle_response(response, BucketSdk::Models::LoadResponse)
|
42
|
+
end
|
43
|
+
|
44
|
+
# List objects in the bucket
|
45
|
+
# @param recurse [Boolean] Whether to list objects recursively (default: false)
|
46
|
+
# @return [Models::ListResponse] The list of objects
|
47
|
+
def list_objects(recurse: false)
|
48
|
+
response = connection.get("/api/v2/objects") do |req|
|
49
|
+
req.params[:recurse] = recurse
|
50
|
+
end
|
51
|
+
|
52
|
+
handle_response(response, BucketSdk::Models::ListResponse)
|
53
|
+
end
|
54
|
+
|
55
|
+
private
|
56
|
+
|
57
|
+
def connection
|
58
|
+
@connection ||= Faraday.new(url: base_url) do |conn|
|
59
|
+
conn.request :multipart
|
60
|
+
conn.request :json
|
61
|
+
|
62
|
+
conn.headers["Accept"] = "application/json"
|
63
|
+
|
64
|
+
conn.options.timeout = timeout
|
65
|
+
conn.adapter Faraday.default_adapter
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
def handle_response(response, model_class)
|
70
|
+
case response.status
|
71
|
+
when 200..299
|
72
|
+
model_class.new(JSON.parse(response.body))
|
73
|
+
when 422
|
74
|
+
error_data = JSON.parse(response.body)
|
75
|
+
raise BucketSdk::Models::ValidationError, error_data["detail"]
|
76
|
+
else
|
77
|
+
raise BucketSdk::Error, "API request failed with status #{response.status}: #{response.body}"
|
78
|
+
end
|
79
|
+
end
|
80
|
+
end
|
81
|
+
end
|
@@ -1,19 +1,19 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module BucketSdk
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module BucketSdk
|
4
|
+
module Models
|
5
|
+
class ListResponse
|
6
|
+
attr_reader :objects
|
7
|
+
|
8
|
+
def initialize(data)
|
9
|
+
@objects = data["objects"] || []
|
10
|
+
end
|
11
|
+
|
12
|
+
def to_h
|
13
|
+
{
|
14
|
+
objects: objects
|
15
|
+
}
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -1,24 +1,24 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module BucketSdk
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module BucketSdk
|
4
|
+
module Models
|
5
|
+
class LoadRequest
|
6
|
+
attr_reader :file, :destination
|
7
|
+
|
8
|
+
# Initialize a new LoadRequest
|
9
|
+
# @param file [File, String] The file to upload (either a File object or a path to a file)
|
10
|
+
# @param destination [String] The destination path in the bucket
|
11
|
+
def initialize(file:, destination:)
|
12
|
+
@file = file
|
13
|
+
@destination = destination
|
14
|
+
end
|
15
|
+
|
16
|
+
def to_h
|
17
|
+
{
|
18
|
+
file: file,
|
19
|
+
destination: destination
|
20
|
+
}
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -1,19 +1,19 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module BucketSdk
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module BucketSdk
|
4
|
+
module Models
|
5
|
+
class LoadResponse
|
6
|
+
attr_reader :url
|
7
|
+
|
8
|
+
def initialize(data)
|
9
|
+
@url = data["url"]
|
10
|
+
end
|
11
|
+
|
12
|
+
def to_h
|
13
|
+
{
|
14
|
+
url: url
|
15
|
+
}
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -1,20 +1,20 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module BucketSdk
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module BucketSdk
|
4
|
+
module Models
|
5
|
+
class ValidationError < BucketSdk::Error
|
6
|
+
attr_reader :details
|
7
|
+
|
8
|
+
def initialize(details)
|
9
|
+
@details = details
|
10
|
+
super("Validation error: #{details.map { |d| "#{d["msg"]} at #{d["loc"].join(".")}" }.join(", ")}")
|
11
|
+
end
|
12
|
+
|
13
|
+
def to_h
|
14
|
+
{
|
15
|
+
details: details
|
16
|
+
}
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
data/lib/bucket_sdk/models.rb
CHANGED
@@ -1,11 +1,11 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require_relative "models/load_request"
|
4
|
-
require_relative "models/load_response"
|
5
|
-
require_relative "models/list_response"
|
6
|
-
require_relative "models/validation_error"
|
7
|
-
|
8
|
-
module BucketSdk
|
9
|
-
module Models
|
10
|
-
end
|
11
|
-
end
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative "models/load_request"
|
4
|
+
require_relative "models/load_response"
|
5
|
+
require_relative "models/list_response"
|
6
|
+
require_relative "models/validation_error"
|
7
|
+
|
8
|
+
module BucketSdk
|
9
|
+
module Models
|
10
|
+
end
|
11
|
+
end
|
data/lib/bucket_sdk/version.rb
CHANGED
data/lib/bucket_sdk.rb
CHANGED
@@ -3,16 +3,16 @@
|
|
3
3
|
require_relative "bucket_sdk/version"
|
4
4
|
|
5
5
|
module BucketSdk
|
6
|
-
|
6
|
+
class Error < StandardError; end
|
7
7
|
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
end
|
8
|
+
# Creates a new client instance
|
9
|
+
# @param base_url [String] The base URL of the API
|
10
|
+
# @param timeout [Integer] The timeout in seconds for API requests
|
11
|
+
# @return [Bucket::Sdk::Client] A new client instance
|
12
|
+
def self.new(base_url:, timeout: 60)
|
13
|
+
Client.new(base_url: base_url, timeout: timeout)
|
15
14
|
end
|
15
|
+
end
|
16
16
|
|
17
17
|
require_relative "bucket_sdk/models"
|
18
18
|
require_relative "bucket_sdk/client"
|
data/sig/bucket_sdk/client.rbs
CHANGED
@@ -1,8 +1,8 @@
|
|
1
|
-
module BucketSdk
|
2
|
-
class Client
|
3
|
-
attr_reader base_url: string
|
4
|
-
attr_reader timeout: int
|
5
|
-
|
6
|
-
def upload_object: -> Models::LoadResponse
|
7
|
-
end
|
8
|
-
end
|
1
|
+
module BucketSdk
|
2
|
+
class Client
|
3
|
+
attr_reader base_url: string
|
4
|
+
attr_reader timeout: int
|
5
|
+
|
6
|
+
def upload_object: -> Models::LoadResponse
|
7
|
+
end
|
8
|
+
end
|
@@ -1,9 +1,9 @@
|
|
1
|
-
module BucketSdk
|
2
|
-
module Models
|
3
|
-
class ListResponse
|
4
|
-
attr_reader objects: array[untyped]
|
5
|
-
|
6
|
-
def to_h: -> Hash[:objects, untyped]
|
7
|
-
end
|
8
|
-
end
|
9
|
-
end
|
1
|
+
module BucketSdk
|
2
|
+
module Models
|
3
|
+
class ListResponse
|
4
|
+
attr_reader objects: array[untyped]
|
5
|
+
|
6
|
+
def to_h: -> Hash[:objects, untyped]
|
7
|
+
end
|
8
|
+
end
|
9
|
+
end
|
@@ -1,10 +1,10 @@
|
|
1
|
-
module BucketSdk
|
2
|
-
module Models
|
3
|
-
class LoadRequest
|
4
|
-
attr_reader data: untyped
|
5
|
-
attr_reader destination: string
|
6
|
-
|
7
|
-
def to_h: -> untyped
|
8
|
-
end
|
9
|
-
end
|
10
|
-
end
|
1
|
+
module BucketSdk
|
2
|
+
module Models
|
3
|
+
class LoadRequest
|
4
|
+
attr_reader data: untyped
|
5
|
+
attr_reader destination: string
|
6
|
+
|
7
|
+
def to_h: -> untyped
|
8
|
+
end
|
9
|
+
end
|
10
|
+
end
|
@@ -1,7 +1,7 @@
|
|
1
|
-
module BucketSdk
|
2
|
-
module Models
|
3
|
-
class LoadResponse
|
4
|
-
attr_reader url: string
|
5
|
-
end
|
6
|
-
end
|
7
|
-
end
|
1
|
+
module BucketSdk
|
2
|
+
module Models
|
3
|
+
class LoadResponse
|
4
|
+
attr_reader url: string
|
5
|
+
end
|
6
|
+
end
|
7
|
+
end
|
metadata
CHANGED
@@ -1,13 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bucket_sdk
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- drutz-cpnv
|
8
|
+
autorequire:
|
8
9
|
bindir: exe
|
9
10
|
cert_chain: []
|
10
|
-
date: 2025-03-
|
11
|
+
date: 2025-03-24 00:00:00.000000000 Z
|
11
12
|
dependencies:
|
12
13
|
- !ruby/object:Gem::Dependency
|
13
14
|
name: faraday
|
@@ -91,6 +92,7 @@ metadata:
|
|
91
92
|
allowed_push_host: https://rubygems.org
|
92
93
|
homepage_uri: https://github.com/drutz-cpnv/ria-bucket-sdk
|
93
94
|
source_code_uri: https://github.com/drutz-cpnv/ria-bucket-sdk
|
95
|
+
post_install_message:
|
94
96
|
rdoc_options: []
|
95
97
|
require_paths:
|
96
98
|
- lib
|
@@ -105,7 +107,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
105
107
|
- !ruby/object:Gem::Version
|
106
108
|
version: '0'
|
107
109
|
requirements: []
|
108
|
-
rubygems_version: 3.
|
110
|
+
rubygems_version: 3.5.16
|
111
|
+
signing_key:
|
109
112
|
specification_version: 4
|
110
113
|
summary: Ruby SDK for the Bucket Storage Service
|
111
114
|
test_files: []
|