aliyun-rails 0.1.10 → 0.1.13

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 0bfda2ced83243ced803fb987f85b20ceb20501b1a5ad5217c5892e38ba49f81
4
- data.tar.gz: 285b9b4ef3ec57c4085a717d3a5e2f821ab3971c82c5be1ef0ae8fd29e2f7d73
3
+ metadata.gz: 54b953cc3442bb86cdfccfb2fe1cd80f7237280f67384588d27effb11cadb580
4
+ data.tar.gz: 17e808edae1fac737e133b2fecf62a6b4923cc21490a5c4bf83547b261dd0be9
5
5
  SHA512:
6
- metadata.gz: ed383278974ad1383c8f9fef1ce1112826de64231ead5a16eae70fa0dd77d544a0d9a50a356ecf7b8b127d98472552ca80a2edae92fcce73a285bc63ab54e1ee
7
- data.tar.gz: 8ff7bbdb1d7aea338877387e876b8eb6365329309a219db622f9607aed48a78597d9c5957dcd96039f0c1c0a01d51e1727c286d2f2d5adc8c0ef6f846d9a61fd
6
+ metadata.gz: c6642a259e9b175b99a97b7acf03c2931a3ff02a01b03e01118a20cec4f51ac20b5bd250ab1c821fa41103ea78f379d476416b32438dd5fc7c28c2b1a1c9b598
7
+ data.tar.gz: 3aa40ca9000cdc6b2ca7618f25d9e2742c99048d8d496f41fd3715ed678f3fb47de60168518facb66d18ebbb90749cd13dc316e1f8deb21188a94265491f60cc
data/README.md CHANGED
@@ -5,7 +5,7 @@
5
5
  <a href=" https://www.alibabacloud.com"><img src="https://aliyunsdk-pages.alicdn.com/icons/Aliyun.svg"></a>
6
6
  </p>
7
7
 
8
- <h1 align="center">非官方SDK套件-用于RAILS项目的</h1>
8
+ <h1 align="center">非官方SDK套件-用于RAILS项目管理阿里云资源</h1>
9
9
 
10
10
  <p align="center">
11
11
  <a href="https://badge.fury.io/rb/aliyunsdkcore"><img src="https://badge.fury.io/rb/aliyunsdkcore.svg" alt="Gem Version"></a>
@@ -15,9 +15,10 @@
15
15
  </p>
16
16
 
17
17
 
18
- 支持 Rails 轻松访问阿里云服务,例如:弹性云主机(ECS)、负载均衡(SLB)、云监控(CloudMonitor)等。
18
+ 支持 Rails 轻松访问阿里云服务,例如:弹性云主机(ECS)、负载均衡(SLB)、云监控(CloudMonitor)等。当前已集成短信服务、语音服务功能,后续可以根据业务需要拓展。
19
19
 
20
20
  本文档介绍如何安装和使用 aliyun-rails
21
+ 本项目是个人用于集成阿里云短信推送、电话告警功能编排,部分代码借鉴自官方 openapi-core-ruby-sdk
21
22
 
22
23
  ## 使用诊断
23
24
  [Troubleshoot](https://troubleshoot.api.aliyun.com/?source=github_sdk) 提供 OpenAPI 使用诊断服务,通过 `RequestID` 或 `报错信息` ,帮助开发者快速定位,为开发者提供解决方案。
@@ -40,6 +41,15 @@ client = Dysms.new(
40
41
  access_key_secret: ENV['ACCESS_KEY_SECRET'],
41
42
  )
42
43
 
44
+ # 可以直接将API参数放到 initializers下
45
+ # Aliyun::Rails.config do |i|
46
+ # i.access_key_id = "XXX"
47
+ # i.access_key_secret = "YYYY"
48
+ # end
49
+ # 随后直接初始化
50
+ # client = Dysms.new
51
+
52
+ # then use the send_sms method
43
53
  response = client.send_sms("1380000000", "SMS_10010", {param1: "11"}, "SIGN_NAME")
44
54
 
45
55
  puts response
@@ -14,13 +14,13 @@ module Aliyun
14
14
  :security_token, :codes, :opts, :verbose
15
15
 
16
16
  # 对象初始化属性
17
- def initialize(config, verbose = false)
17
+ def initialize(config = {}, verbose = false)
18
18
  validate config
19
19
 
20
20
  self.endpoint = config[:endpoint]
21
21
  self.api_version = config[:api_version]
22
- self.access_key_id = config[:access_key_id]
23
- self.access_key_secret = config[:access_key_secret]
22
+ self.access_key_id = config[:access_key_id] || Aliyun::Rails.access_key_id
23
+ self.access_key_secret = config[:access_key_secret] || Aliyun::Rails.access_key_secret
24
24
  self.security_token = config[:security_token]
25
25
  self.opts = config[:opts] || {}
26
26
  self.verbose = verbose.instance_of?(TrueClass) && verbose
@@ -104,8 +104,12 @@ module Aliyun
104
104
  raise ArgumentError, '"config.endpoint" must starts with \'https://\' or \'http://\'.'
105
105
  end
106
106
  raise ArgumentError, 'must pass "config[:api_version]"' unless config[:api_version]
107
- raise ArgumentError, 'must pass "config[:access_key_id]"' unless config[:access_key_id]
108
- raise ArgumentError, 'must pass "config[:access_key_secret]"' unless config[:access_key_secret]
107
+ unless config[:access_key_id] || Aliyun::Rails.access_key_id
108
+ raise ArgumentError, 'must pass "config[:access_key_id]" or define "Aliyun::Rails.access_key_id"'
109
+ end
110
+ unless config[:access_key_secret] || Aliyun::Rails.access_key_secret
111
+ raise ArgumentError, 'must pass "config[:access_key_secret]" or define "Aliyun::Rails.access_key_secret"'
112
+ end
109
113
  end
110
114
  end
111
115
  end
@@ -5,9 +5,9 @@ module Aliyun
5
5
  class Dysms < Aliyun::Rails::Connector::RPCClient
6
6
  # 本产品(Dysmsapi/2017-05-25)的OpenAPI采用RPC签名风格,签名细节参见签名机制说明。
7
7
  # 我们已经为开发者封装了常见编程语言的SDK,开发者可通过下载SDK直接调用本产品OpenAPI而无需关心技术细节。
8
- def initialize(config, verbose = nil)
9
- config[:endpoint] = "http://dysmsapi.aliyuncs.com"
10
- config[:api_version] = "2017-05-25"
8
+ def initialize(config = {}, verbose = nil)
9
+ config[:endpoint] ||= "http://dysmsapi.aliyuncs.com"
10
+ config[:api_version] ||= "2017-05-25"
11
11
  super(config, verbose)
12
12
  end
13
13
 
@@ -2,12 +2,12 @@
2
2
 
3
3
  module Aliyun
4
4
  module Rails
5
- class Dysms < Aliyun::Rails::Connector::RPCClient
5
+ class Dyvms < Aliyun::Rails::Connector::RPCClient
6
6
  # 本产品(Dyvmsapi/2017-05-25)的OpenAPI采用RPC签名风格,签名细节参见签名机制说明。
7
7
  # 我们已经为开发者封装了常见编程语言的SDK,开发者可通过下载SDK直接调用本产品OpenAPI而无需关心技术细节。
8
- def initialize(config, verbose = nil)
9
- config[:endpoint] = "http://dyvmsapi.aliyuncs.com"
10
- config[:api_version] = "2017-05-25"
8
+ def initialize(config = {}, verbose = nil)
9
+ config[:endpoint] ||= "http://dyvmsapi.aliyuncs.com"
10
+ config[:api_version] ||= "2017-05-25"
11
11
  super(config, verbose)
12
12
  end
13
13
 
@@ -2,7 +2,7 @@
2
2
 
3
3
  module Aliyun
4
4
  module Rails
5
- VERSION = "0.1.10"
5
+ VERSION = "0.1.13"
6
6
  DEFAULT_UA = "AlibabaCloud (#{Gem::Platform.local.os}; " +
7
7
  "#{Gem::Platform.local.cpu}) Ruby/#{RUBY_VERSION} Core/#{VERSION}"
8
8
  end
data/lib/aliyun/rails.rb CHANGED
@@ -3,18 +3,19 @@
3
3
  require_relative "rails/version"
4
4
  require_relative "rails/connector/roa_client"
5
5
  require_relative "rails/connector/rpc_client"
6
- require_relative "rails/dysms"
7
6
  require_relative "rails/dyvms"
7
+ require_relative "rails/dysms"
8
8
 
9
9
  module Aliyun
10
10
  module Rails
11
11
  class Error < StandardError; end
12
12
 
13
- # class << self
14
- # def config(&block)
15
- # RPCClient.init_params(&block)
16
- # end
17
- # end
13
+ class << self
14
+ attr_accessor :access_key_id, :access_key_secret
15
+ def config
16
+ yield self
17
+ end
18
+ end
18
19
 
19
20
  # Your code goes here...
20
21
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: aliyun-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.10
4
+ version: 0.1.13
5
5
  platform: ruby
6
6
  authors:
7
7
  - WENWU.YAN