baidubce-sdk 0.9.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,82 @@
1
+ # Copyright (c) 2017 Baidu.com, Inc. All Rights Reserved
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
4
+ # the License. You may obtain a copy of the License at
5
+ #
6
+ # http://www.apache.org/licenses/LICENSE-2.0
7
+ #
8
+ # Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
9
+ # an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
10
+ # specific language governing permissions and limitations under the License.
11
+
12
+ # Samples for sts client.
13
+
14
+ $LOAD_PATH.unshift(File.expand_path("../../../lib", __FILE__))
15
+
16
+ require 'baidubce/services/sts/sts_client'
17
+ require 'baidubce/services/bos/bos_client'
18
+
19
+ credentials = Baidubce::Auth::BceCredentials.new(
20
+ # "your ak",
21
+ # "your sk"
22
+ )
23
+
24
+ sts_conf = Baidubce::BceClientConfiguration.new(
25
+ credentials,
26
+ "http://sts.bj.baidubce.com"
27
+ )
28
+
29
+ sts_client = Baidubce::Services::StsClient.new(sts_conf)
30
+
31
+ # log config
32
+ Baidubce::Log.set_log_file("./test.log")
33
+ Baidubce::Log.set_log_level(Logger::DEBUG)
34
+
35
+ def demo(msg)
36
+ puts "--------- #{msg} --------"
37
+ puts
38
+ yield
39
+ puts "----------- end --------------"
40
+ puts
41
+ end
42
+
43
+ demo 'sts client' do
44
+ acl = {
45
+ id: '8c47a952db4444c5a097b41be3f24c94',
46
+ accessControlList: [
47
+ {
48
+ eid: 'shj',
49
+ service: 'bce:bos',
50
+ region: 'bj',
51
+ effect: 'Allow',
52
+ resource: ["bos-demo"],
53
+ permission: ["READ"]
54
+ }
55
+ ]
56
+ }
57
+
58
+ # durationSeconds为失效时间,如果为非int值或者不设置该参数,会使用默认的12小时作为失效时间
59
+ # puts sts_client.get_session_token(acl, "test")
60
+ # puts sts_client.get_session_token(acl, 1024)
61
+ sts_response = sts_client.get_session_token(acl)
62
+
63
+ # 使用获取到的ak, sk, token新建BosClient访问BOS
64
+ sts_ak = sts_response["accessKeyId"]
65
+ sts_sk = sts_response['secretAccessKey']
66
+ token = sts_response['sessionToken']
67
+
68
+ sts_credentials = Baidubce::Auth::BceCredentials.new(
69
+ sts_ak,
70
+ sts_sk,
71
+ token
72
+ )
73
+
74
+ conf = Baidubce::BceClientConfiguration.new(
75
+ sts_credentials,
76
+ "http://bj.bcebos.com",
77
+ )
78
+
79
+ client = Baidubce::Services::BosClient.new(conf)
80
+
81
+ puts client.get_bucket_location('bos-demo')
82
+ end
metadata ADDED
@@ -0,0 +1,174 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: baidubce-sdk
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.9.0
5
+ platform: ruby
6
+ authors:
7
+ - xiaoyong
8
+ autorequire:
9
+ bindir: lib/baidubce
10
+ cert_chain: []
11
+ date: 2018-05-22 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.15'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.15'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '10.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '10.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rspec
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '3.0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '3.0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rest-client
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '2.0'
62
+ - - ">="
63
+ - !ruby/object:Gem::Version
64
+ version: 2.0.2
65
+ type: :development
66
+ prerelease: false
67
+ version_requirements: !ruby/object:Gem::Requirement
68
+ requirements:
69
+ - - "~>"
70
+ - !ruby/object:Gem::Version
71
+ version: '2.0'
72
+ - - ">="
73
+ - !ruby/object:Gem::Version
74
+ version: 2.0.2
75
+ - !ruby/object:Gem::Dependency
76
+ name: logger
77
+ requirement: !ruby/object:Gem::Requirement
78
+ requirements:
79
+ - - "~>"
80
+ - !ruby/object:Gem::Version
81
+ version: '1.2'
82
+ - - ">="
83
+ - !ruby/object:Gem::Version
84
+ version: 1.2.8
85
+ type: :development
86
+ prerelease: false
87
+ version_requirements: !ruby/object:Gem::Requirement
88
+ requirements:
89
+ - - "~>"
90
+ - !ruby/object:Gem::Version
91
+ version: '1.2'
92
+ - - ">="
93
+ - !ruby/object:Gem::Version
94
+ version: 1.2.8
95
+ - !ruby/object:Gem::Dependency
96
+ name: mimemagic
97
+ requirement: !ruby/object:Gem::Requirement
98
+ requirements:
99
+ - - "~>"
100
+ - !ruby/object:Gem::Version
101
+ version: '0.3'
102
+ - - ">="
103
+ - !ruby/object:Gem::Version
104
+ version: 0.3.2
105
+ type: :development
106
+ prerelease: false
107
+ version_requirements: !ruby/object:Gem::Requirement
108
+ requirements:
109
+ - - "~>"
110
+ - !ruby/object:Gem::Version
111
+ version: '0.3'
112
+ - - ">="
113
+ - !ruby/object:Gem::Version
114
+ version: 0.3.2
115
+ description: The official Ruby sdk used to accessing BaiduBce Object Storage Service
116
+ email:
117
+ - xiaoyong@baidu.com
118
+ executables: []
119
+ extensions: []
120
+ extra_rdoc_files: []
121
+ files:
122
+ - ".gitignore"
123
+ - ".rspec"
124
+ - ".travis.yml"
125
+ - CODE_OF_CONDUCT.md
126
+ - Gemfile
127
+ - LICENSE
128
+ - README.md
129
+ - Rakefile
130
+ - baidubce-sdk.gemspec
131
+ - bin/console
132
+ - bin/setup
133
+ - lib/baidubce/auth/bce_credentials.rb
134
+ - lib/baidubce/auth/bce_v1_signer.rb
135
+ - lib/baidubce/bce_base_client.rb
136
+ - lib/baidubce/bce_client_configuration.rb
137
+ - lib/baidubce/bce_constants.rb
138
+ - lib/baidubce/exception.rb
139
+ - lib/baidubce/http/base_http_client.rb
140
+ - lib/baidubce/http/http_constants.rb
141
+ - lib/baidubce/retry_policy.rb
142
+ - lib/baidubce/services/bos/bos_client.rb
143
+ - lib/baidubce/services/bos/bos_constants.rb
144
+ - lib/baidubce/services/sts/sts_client.rb
145
+ - lib/baidubce/utils/log.rb
146
+ - lib/baidubce/utils/utils.rb
147
+ - lib/baidubce/version.rb
148
+ - samples/baidubce/bos_sample.rb
149
+ - samples/baidubce/sts_sample.rb
150
+ homepage: https://github.com/baidubce/bce-sdk-ruby
151
+ licenses:
152
+ - Apache-2.0
153
+ metadata: {}
154
+ post_install_message:
155
+ rdoc_options: []
156
+ require_paths:
157
+ - lib
158
+ required_ruby_version: !ruby/object:Gem::Requirement
159
+ requirements:
160
+ - - ">="
161
+ - !ruby/object:Gem::Version
162
+ version: 2.0.0
163
+ required_rubygems_version: !ruby/object:Gem::Requirement
164
+ requirements:
165
+ - - ">="
166
+ - !ruby/object:Gem::Version
167
+ version: '0'
168
+ requirements: []
169
+ rubyforge_project:
170
+ rubygems_version: 2.6.14
171
+ signing_key:
172
+ specification_version: 4
173
+ summary: BaiduBce BOS Ruby SDK
174
+ test_files: []