tencent-cloud 0.0.1 → 0.0.3
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/Gemfile.lock +1 -1
- data/lib/tencent/cloud.rb +9 -2
- data/lib/tencent/cloud/client.rb +13 -6
- data/lib/tencent/cloud/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 843cfcdf9c8ecfad6557ea8f75138d579c7e8758a541943231e5c01abfe21d43
|
4
|
+
data.tar.gz: 3c9fcf9c245c31f8a599f3fabb918aab83daa17ec3154dd89aff04bcd0419ebf
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5dbcf6a687bc4140f3508b6606bc2cba93302af7ab24c6555582ddd96bd2b5ec30376601997d4501577b5420a7aa900b0bed8a879ca5b7c348aa171c925a679d
|
7
|
+
data.tar.gz: 3c752207a73ecb492b8072ac5303c432931761966f5ee1bd5aa6f4b7d837b9a791729ce6b2db1aaa010f69b7df0467408ad172a7b6bf225ef3f4e7f4a1b047e9
|
data/Gemfile.lock
CHANGED
data/lib/tencent/cloud.rb
CHANGED
@@ -2,13 +2,20 @@ require 'logger'
|
|
2
2
|
|
3
3
|
module Tencent
|
4
4
|
module Cloud
|
5
|
+
class Error < StandardError; end
|
5
6
|
|
6
7
|
def self.logger
|
7
|
-
|
8
|
+
@logger ||= defined?(Rails) ? Rails.logger : ::Logger.new(STDOUT)
|
8
9
|
end
|
9
10
|
|
10
11
|
def self.logger=(logger)
|
11
|
-
|
12
|
+
@logger = logger
|
13
|
+
end
|
14
|
+
|
15
|
+
def self.client
|
16
|
+
return @client = yield(Client) if block_given?
|
17
|
+
|
18
|
+
@client || raise(::Tencent::Cloud::Error, 'initialize client with block first')
|
12
19
|
end
|
13
20
|
end
|
14
21
|
end
|
data/lib/tencent/cloud/client.rb
CHANGED
@@ -12,7 +12,7 @@ module Tencent
|
|
12
12
|
# > client.post json_text # text or hash, hash will use MultiJson.dump to convert
|
13
13
|
#
|
14
14
|
class Client
|
15
|
-
attr_reader :host, :service, :secret_id, :secret_key, :region, :options
|
15
|
+
attr_reader :schema, :host, :service, :secret_id, :secret_key, :region, :options
|
16
16
|
|
17
17
|
def initialize(region, secret_id, secret_key, **options)
|
18
18
|
@secret_id = secret_id
|
@@ -21,14 +21,16 @@ module Tencent
|
|
21
21
|
@options = options
|
22
22
|
end
|
23
23
|
|
24
|
-
def switch_to(service, host)
|
25
|
-
Cloud.logger.debug { {service: service, host: host} }
|
24
|
+
def switch_to(service, host, schema: 'https')
|
25
|
+
Cloud.logger.debug { { schema: schema, service: service, host: host } }
|
26
26
|
@service = service
|
27
27
|
@host = host
|
28
|
+
@schema = schema
|
29
|
+
self
|
28
30
|
end
|
29
31
|
|
30
32
|
def connection
|
31
|
-
Faraday.new(url: "
|
33
|
+
Faraday.new(url: "#{schema}://#{host}") do |conn|
|
32
34
|
conn.request :retry
|
33
35
|
# conn.request :url_encoded
|
34
36
|
conn.response :logger
|
@@ -50,7 +52,12 @@ module Tencent
|
|
50
52
|
# pp key, ::Tencent::Cloud.constants, ::Tencent::Cloud.const_defined?(key)
|
51
53
|
super(symbol, *args) unless ::Tencent::Cloud.const_defined?(key)
|
52
54
|
|
53
|
-
|
55
|
+
var_name = "@#{symbol}"
|
56
|
+
instance_variable_get(var_name) || begin
|
57
|
+
c = Tencent::Cloud.const_get(key).new region, secret_id, secret_key, options
|
58
|
+
instance_variable_set(var_name, c)
|
59
|
+
c
|
60
|
+
end
|
54
61
|
end
|
55
62
|
|
56
63
|
def respond_to_missing?(method_name, include_private = false)
|
@@ -140,7 +147,7 @@ module Tencent
|
|
140
147
|
end
|
141
148
|
|
142
149
|
def sign_time
|
143
|
-
|
150
|
+
Time.now.getutc
|
144
151
|
end
|
145
152
|
|
146
153
|
def sign_timestamp
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: tencent-cloud
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ryan Wong
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-03-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: faraday
|