aliyun-mts 0.0.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 94bbeb3c98e474749b3f554ba54ab54ba58aca12
4
+ data.tar.gz: 5b9c74aced2081e839c0b73dada4a6d0c9a7f7c0
5
+ SHA512:
6
+ metadata.gz: d5625a89bc00685da3c785959daef518b74d549dbc6b777fa151f8e7e436421e2c35b03b6889aa11054b97342687d374007e8f774c97f2c307d72820bbd5fa14
7
+ data.tar.gz: 062520310dee33a9aa09b9dbbac8f929228fc317d64d07dbd5eb407e0c4824269e0a98cd497a795f40771dfe4c1f7b60e73832c44153726b5d9b256324fe7bc3
data/.gitignore ADDED
File without changes
data/Gemfile ADDED
@@ -0,0 +1,6 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in yuntongxun.gemspec
4
+ gemspec
5
+
6
+ gem 'pry'
data/Gemfile.lock ADDED
@@ -0,0 +1,28 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ aliyun-mts (0.0.0)
5
+
6
+ GEM
7
+ remote: https://rubygems.org/
8
+ specs:
9
+ coderay (1.1.1)
10
+ method_source (0.8.2)
11
+ pry (0.10.4)
12
+ coderay (~> 1.1.0)
13
+ method_source (~> 0.8.1)
14
+ slop (~> 3.4)
15
+ rake (11.2.2)
16
+ slop (3.6.0)
17
+
18
+ PLATFORMS
19
+ ruby
20
+
21
+ DEPENDENCIES
22
+ aliyun-mts!
23
+ bundler (~> 1.3)
24
+ pry
25
+ rake (~> 11.2)
26
+
27
+ BUNDLED WITH
28
+ 1.12.5
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2016 Fwshun8023
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,24 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'aliyun/mts/version'
5
+
6
+ Gem::Specification.new do |s|
7
+ s.name = 'aliyun-mts'
8
+ s.version = Aliyun::MTS::VERSION
9
+ s.date = '2016-08-23'
10
+ s.summary = "Ruby SDK for Aliyun MTS API development"
11
+ s.description = "Ruby SDK for Aliyun MTS API development"
12
+ s.authors = ["fwshun8023"]
13
+ s.email = ['fwshun8023@gmai.com']
14
+ s.homepage = 'https://github.com/fwshun8023/aliyun-mts'
15
+ s.license = 'MIT'
16
+
17
+ s.files = `git ls-files`.split($/)
18
+ s.executables = s.files.grep(%r{^bin/}) { |f| File.basename(f) }
19
+ s.test_files = s.files.grep(%r{^(test|spec|features)/})
20
+ s.require_paths = ["lib"]
21
+
22
+ s.add_development_dependency "bundler", "~> 1.3"
23
+ s.add_development_dependency "rake", "~> 11.2"
24
+ end
data/lib/aliyun/mts.rb ADDED
@@ -0,0 +1,15 @@
1
+ require 'net/https'
2
+ require 'uri'
3
+ require 'json'
4
+ require_relative 'mts/util'
5
+ require_relative 'mts/media_info'
6
+ require_relative 'mts/snapshot'
7
+
8
+ module Aliyun
9
+ module MTS
10
+ BASE_URL = "https://mts.aliyuncs.com"
11
+ class << self
12
+ attr_accessor :access_key_id, :access_key_secret
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,17 @@
1
+ module Aliyun
2
+ module MTS
3
+ module MediaInfo
4
+ def self.submit(input = {}, pipeline_id = "", user_data = "")
5
+ params = { Action: "SubmitMediaInfoJob" }
6
+ params[:Input] = input.to_json
7
+ params[:pipeline_id] = pipeline_id
8
+ params[:user_data] = user_data
9
+
10
+ uri = URI(BASE_URL)
11
+ uri.query = URI.encode_www_form( Util.signature_params(params))
12
+ res = Net::HTTP.get_response(uri)
13
+ JSON.parse res.body
14
+ end
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,18 @@
1
+ module Aliyun
2
+ module MTS
3
+ module Snapshot
4
+ def self.submit(input = {}, config = {}, pipeline_id = "", user_data = "")
5
+ params = { Action: "SubmitSnapshotJob" }
6
+ params[:Input] = input.to_json
7
+ params[:SnapshotConfig] = config.to_json
8
+ params[:pipeline_id] = pipeline_id
9
+ params[:user_data] = user_data
10
+
11
+ uri = URI(BASE_URL)
12
+ uri.query = URI.encode_www_form( Util.signature_params(params))
13
+ res = Net::HTTP.get_response(uri)
14
+ JSON.parse res.body
15
+ end
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,51 @@
1
+ # -*- encoding: utf-8 -*-
2
+
3
+ require 'time'
4
+ require 'base64'
5
+ require 'cgi'
6
+ require 'openssl'
7
+ require 'digest/md5'
8
+
9
+ module Aliyun
10
+ module MTS
11
+ module Util
12
+ class << self
13
+
14
+ # 签名后参数
15
+ def signature_params(params)
16
+ params.merge!(default_params)
17
+ params[:Signature] = get_signature(params)
18
+ params
19
+ end
20
+
21
+ def get_signature(params)
22
+ cano_query = params.sort.map {
23
+ |k, v| [CGI.escape(k.to_s), CGI.escape(v)].join('=') }.join('&')
24
+
25
+ string_to_sign =
26
+ 'GET&' + CGI.escape('/') + '&' + CGI.escape(cano_query)
27
+
28
+ Base64.strict_encode64(
29
+ OpenSSL::HMAC.digest('sha1', Aliyun::MTS.access_key_secret + "&", string_to_sign))
30
+ end
31
+
32
+ def default_params
33
+ {
34
+ Format: "JSON",
35
+ Version: "2014-06-18",
36
+ AccessKeyId: Aliyun::MTS.access_key_id,
37
+ SignatureMethod: "HMAC-SHA1",
38
+ Timestamp: Time.now.utc.iso8601,
39
+ SignatureVersion: "1.0",
40
+ SignatureNonce: signature_nonce
41
+ }
42
+ end
43
+
44
+ private
45
+ def signature_nonce
46
+ (rand * 1_000_000_000).to_s
47
+ end
48
+ end
49
+ end
50
+ end
51
+ end
@@ -0,0 +1,5 @@
1
+ module Aliyun
2
+ module MTS
3
+ VERSION = "0.0.0"
4
+ end
5
+ end
metadata ADDED
@@ -0,0 +1,82 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: aliyun-mts
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.0
5
+ platform: ruby
6
+ authors:
7
+ - fwshun8023
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2016-08-23 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.3'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.3'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '11.2'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '11.2'
41
+ description: Ruby SDK for Aliyun MTS API development
42
+ email:
43
+ - fwshun8023@gmai.com
44
+ executables: []
45
+ extensions: []
46
+ extra_rdoc_files: []
47
+ files:
48
+ - ".gitignore"
49
+ - Gemfile
50
+ - Gemfile.lock
51
+ - LICENSE.txt
52
+ - aliyun-mts.gemspec
53
+ - lib/aliyun/mts.rb
54
+ - lib/aliyun/mts/media_info.rb
55
+ - lib/aliyun/mts/snapshot.rb
56
+ - lib/aliyun/mts/util.rb
57
+ - lib/aliyun/mts/version.rb
58
+ homepage: https://github.com/fwshun8023/aliyun-mts
59
+ licenses:
60
+ - MIT
61
+ metadata: {}
62
+ post_install_message:
63
+ rdoc_options: []
64
+ require_paths:
65
+ - lib
66
+ required_ruby_version: !ruby/object:Gem::Requirement
67
+ requirements:
68
+ - - ">="
69
+ - !ruby/object:Gem::Version
70
+ version: '0'
71
+ required_rubygems_version: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ requirements: []
77
+ rubyforge_project:
78
+ rubygems_version: 2.6.4
79
+ signing_key:
80
+ specification_version: 4
81
+ summary: Ruby SDK for Aliyun MTS API development
82
+ test_files: []