aliyun-rails 0.1.15 → 0.1.16

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 485e0e5b14e3aefe6c6e0865cf20ff3a043fe38d012c05f067b1d9d59a21940f
4
- data.tar.gz: d18b4c36f7a38b64a25928a4222c23d7021851267f25f15099c1d8a73c6f9146
3
+ metadata.gz: 3240b73e02b5bf35dfa310205d8dae87e0850fdd55a89f61ffd3ede196b4dd2f
4
+ data.tar.gz: 1b547158d62ab63a243c32e4e4b53b7aa793f29373857585a7e24f1b989e688a
5
5
  SHA512:
6
- metadata.gz: 97971caf232a968deca9341f24613a98f2e671b0d762f2f198fdb266b119bf01994c1858d536817a084e27fb2e143bab3cbc5c1b1da99767f831e6ea6158d64c
7
- data.tar.gz: 18bf61bee58194b9dcb6f462d08ebbf05d117ca0577854723f3ee0a9e68bfff428c99789a04623ca34742bfe918dbf748536f8777e280d6e1829790083f5fa7e
6
+ metadata.gz: 17a9fe79cb951e258a942b1e429ae99d28ca94a8d5b36b7e6df3e3f0a179f1d565c9fa7d5c0f7f88e9323e44810fdf1fe3ec9cca42a26528e9d7116d0a6978f4
7
+ data.tar.gz: ae4449f0facadcecb91d5f752b9129eb3c3f0ac527c1d04d601e0008d39041b718dd58c062560ebc342ebba2c069e550229717e707526cc52a986628d7b386d5
data/README.md CHANGED
@@ -5,23 +5,25 @@
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
- <a href="https://badge.fury.io/rb/aliyunsdkcore"><img src="https://badge.fury.io/rb/aliyunsdkcore.svg" alt="Gem Version"></a>
12
- <a href="https://travis-ci.org/aliyun/openapi-core-ruby-sdk"><img src="https://travis-ci.org/aliyun/openapi-core-ruby-sdk.svg?branch=master" alt="Build Status"></a>
13
- <a href="https://ci.appveyor.com/project/aliyun/openapi-core-ruby-sdk/branch/master"><img src="https://ci.appveyor.com/api/projects/status/uyepkk5bjbynofvu/branch/master?svg=true" alt="Build status"></a>
14
- <a href="https://codecov.io/gh/aliyun/openapi-core-ruby-sdk"><img src="https://codecov.io/gh/aliyun/openapi-core-ruby-sdk/branch/master/graph/badge.svg" alt="codecov"></a>
11
+ <a href="https://badge.fury.io/rb/aliyun-rails"><img src="https://badge.fury.io/rb/aliyun-rails.svg" alt="Gem Version"></a>
12
+ <a href="https://travis-ci.org/ciscolive/aliyun-rails"><img src="https://travis-ci.org/ciscolive/aliyun-rails.svg?branch=master" alt="Build Status"></a>
13
+ <a href="https://ci.appveyor.com/project/ciscolive/aliyun-rails/branch/master"><img src="https://ci.appveyor.com/api/projects/status/uyepkk5bjbynofvu/branch/master?svg=true" alt="Build status"></a>
14
+ <a href="https://codecov.io/gh/ciscolive/aliyun-rails"><img src="https://codecov.io/gh/ciscolive/aliyun-rails/branch/master/graph/badge.svg" alt="codecov"></a>
15
15
  </p>
16
16
 
17
17
 
18
- 支持 Rails 轻松访问阿里云服务,例如:弹性云主机(ECS)、负载均衡(SLB)、云监控(CloudMonitor)等。当前已集成短信服务、语音服务功能,后续可以根据业务需要拓展。
18
+ - 支持 Rails 轻松访问阿里云服务,例如:弹性云主机(ECS)、负载均衡(SLB)、云监控(CloudMonitor)等。
19
+ - 已集成阿里云短信服务和语音服务,满足日常短信和电话告警需求。
19
20
 
20
21
  本文档介绍如何安装和使用 aliyun-rails
21
- 本项目是个人用于集成阿里云短信推送、电话告警功能编排,部分代码借鉴自官方 openapi-core-ruby-sdk
22
22
 
23
23
  ## 使用诊断
24
- [Troubleshoot](https://troubleshoot.api.aliyun.com/?source=github_sdk) 提供 OpenAPI 使用诊断服务,通过 `RequestID` 或 `报错信息` ,帮助开发者快速定位,为开发者提供解决方案。
24
+
25
+ [Troubleshoot](https://troubleshoot.api.aliyun.com/?source=github_sdk) 提供 OpenAPI 使用诊断服务,通过 `RequestID` 或 `报错信息`
26
+ ,帮助开发者快速定位,为开发者提供解决方案。
25
27
 
26
28
  ## 安装
27
29
 
@@ -31,36 +33,90 @@ $ gem install aliyun-rails
31
33
 
32
34
  ## 使用
33
35
 
34
- RPC 示例;
36
+ - 加载模块自动挂载几个常量:Dysms、Dyvms、RPCClient和ROAClient
37
+
38
+ CALL_TTS 实例:
39
+
40
+ ```ruby
41
+ require "aliyun-rails"
42
+
43
+ client = Aliyun::Dyvms.new(
44
+ access_key_id: ENV['ACCESS_KEY_ID'],
45
+ access_key_secret: ENV['ACCESS_KEY_SECRET'],
46
+ )
47
+
48
+ # 可以直接将API参数放到RAILS项目 * config/initializers *下
49
+ # Aliyun.config do |aliyun|
50
+ # aliyun.access_key_id = "XXX"
51
+ # aliyun.access_key_secret = "YYY"
52
+ # end
53
+ # 随后直接初始化
54
+ # client = Aliyun::Dyvms.new
55
+
56
+ # 调用语音方法 single_call_by_tts method
57
+ response = client.single_call_by_tts("075566668888", "13900001234", "TTS_CODE", { TTS_PARAM: 2022 })
58
+
59
+ puts response
60
+
61
+ ```
62
+
63
+ SEND_SMS 示例:
35
64
 
36
65
  ```ruby
37
66
  require "aliyun-rails"
38
67
 
39
- client = Dysms.new(
68
+ client = Aliyun::Dysms.new(
40
69
  access_key_id: ENV['ACCESS_KEY_ID'],
41
70
  access_key_secret: ENV['ACCESS_KEY_SECRET'],
42
71
  )
43
72
 
44
- # 可以直接将API参数放到 initializers
45
- # Aliyun::Rails.config do |i|
46
- # i.access_key_id = "XXX"
47
- # i.access_key_secret = "YYYY"
73
+ # 可以直接将API参数放到RAILS项目 * config/initializers *下
74
+ # Aliyun.config do |aliyun|
75
+ # aliyun.access_key_id = "XXX"
76
+ # aliyun.access_key_secret = "YYY"
48
77
  # end
49
78
  # 随后直接初始化
50
79
  # client = Dysms.new
51
80
 
52
- # then use the send_sms method
53
- response = client.send_sms("1380000000", "SMS_10010", {param1: "11"}, "SIGN_NAME")
81
+ # 调用短信方法 send_sms method
82
+ response = client.send_sms("1380000000", "SMS_10010", { param1: "11" }, "SIGN_NAME")
54
83
 
55
84
  puts response
56
85
  ```
57
86
 
87
+ RPC 示例:
88
+
89
+ ```ruby
90
+ require 'aliyun-rails'
91
+
92
+ # 实例化对象
93
+ client = RPCClient.new(
94
+ endpoint: 'http://ros.aliyuncs.com',
95
+ api_version: '2015-09-01',
96
+ access_key_id: ENV['ACCESS_KEY_ID'],
97
+ access_key_secret: ENV['ACCESS_KEY_SECRET'],
98
+ security_token: 'TOKEN_KEY'
99
+ )
100
+
101
+ # 请求接口查询
102
+ params = { key: (1..11).to_a.map(&:to_s) }
103
+ request_option = { method: 'POST', timeout: 15000 }
104
+ response = client.request(
105
+ action: 'DescribeRegions',
106
+ params: params,
107
+ opts: request_option
108
+ )
109
+
110
+ puts response
111
+
112
+ ```
58
113
 
59
114
  ROA 示例:
60
115
 
61
116
  ```ruby
62
117
  require 'aliyun-rails'
63
118
 
119
+ # 初始化对象
64
120
  client = ROAClient.new(
65
121
  endpoint: 'http://ros.aliyuncs.com',
66
122
  api_version: '2015-09-01',
@@ -68,28 +124,30 @@ client = ROAClient.new(
68
124
  access_key_secret: ENV['ACCESS_KEY_SECRET'],
69
125
  )
70
126
 
127
+ # 请求接口查询
71
128
  response = client.request(
72
- method: 'GET',
73
- uri: '/regions',
129
+ method: 'GET',
130
+ uri: '/regions',
74
131
  options: {
75
132
  timeout: 15000
76
133
  }
77
134
  )
78
135
 
79
- print response.body
136
+ puts response.body
80
137
  ```
81
138
 
82
139
  ## 问题
83
- [提交 Issue](https://github.com/ciscolive/aliyun-rails/issues/new/choose),不符合指南的问题可能会立即关闭。
84
140
 
141
+ [提交 Issue](https://github.com/ciscolive/aliyun-rails/issues/new/choose),不符合指南的问题可能会立即关闭。
85
142
 
86
143
  ## 发行说明
87
- 每个版本的详细更改记录在[发行说明](CHANGELOG.md)中。
88
144
 
145
+ 每个版本的详细更改记录在[发行说明](CHANGELOG.md)中。
89
146
 
90
147
  ## 贡献
91
- 提交 Pull Request 之前请阅读[贡献指南](CONTRIBUTING.md)。
92
148
 
149
+ 提交 Pull Request 之前请阅读[贡献指南](CONTRIBUTING.md)。
93
150
 
94
151
  ## 许可证
95
- [MIT](LICENSE.md)
152
+
153
+ [MIT](LICENSE.txt)
@@ -1,9 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Aliyun
4
- module Rails
5
- VERSION = "0.1.15"
6
- DEFAULT_UA = "AlibabaCloud (#{Gem::Platform.local.os}; " +
7
- "#{Gem::Platform.local.cpu}) Ruby/#{RUBY_VERSION} Core/#{VERSION}"
8
- end
4
+ VERSION = "0.1.16"
5
+ DEFAULT_UA = "AlibabaCloud (#{Gem::Platform.local.os}; " +
6
+ "#{Gem::Platform.local.cpu}) Ruby/#{RUBY_VERSION} Core/#{VERSION}"
9
7
  end
data/lib/aliyun-rails.rb CHANGED
@@ -18,3 +18,9 @@ module Aliyun
18
18
 
19
19
  # Your code goes here...
20
20
  end
21
+
22
+ # 加载模块,自动初始化的常量
23
+ RPCClient = Aliyun::Connector::RPCClient
24
+ ROAClient = Aliyun::Connector::ROAClient
25
+ Dysms = Aliyun::Dysms
26
+ Dyvms = Aliyun::Dyvms
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.15
4
+ version: 0.1.16
5
5
  platform: ruby
6
6
  authors:
7
7
  - WENWU.YAN