ruby-scaleengine 0.1.0

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.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 3a32289a7e4ee078d0d991abb3e8b978bf707a67
4
+ data.tar.gz: 68dc467458618151394ed2a6d7338698bf94b35a
5
+ SHA512:
6
+ metadata.gz: 688aae77a3e4cc492e2118e9210469dfaed9bfedbe14e5850315d8643baadfd1e146b72feee3600a7a5de0c70720d8973e20dac737e7ed2e8230128bc79559e3
7
+ data.tar.gz: ef5a3670231f4cb3c28e537ceae0b6d15af26547244f516633ea0964bceecbf5dc4e8b0ed111738f8403588bda0cd186a887bc7d53d1ade51bf48d545b89bafe
data/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2015 John-Alan Simmons <johnalan@conferencecloud.co>
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
@@ -0,0 +1,38 @@
1
+ require "rest-client"
2
+ require "json"
3
+ require "scaleengine/configuration"
4
+ require "scaleengine/response"
5
+ require "scaleengine/request"
6
+
7
+ class ScaleEngineAPI
8
+
9
+ # Specific endpoint for record_controls action
10
+ def record_control(action, params)
11
+ if not params.is_a?(Hash)
12
+ # Invalid params type. Not a hash
13
+ raise InvalidParamsException.new("Params must be hash")
14
+ elsif action.blank?
15
+ # Missing action
16
+ raise InvalidParamsException.new("Action must not be empty")
17
+ end
18
+
19
+ params[:action] = action
20
+ Request.new(Configuration.record_control_end_point, params)
21
+ end
22
+
23
+ # Normal API methods found under the API documentation at https://cp.scaleengine.net/docs/api
24
+ def method_missing(method, *args)
25
+ params = args[0].is_a?(Hash) ? args[0] : {}
26
+
27
+ # Set the vairous params that are required for each test
28
+ params[:command] = "#{method}"
29
+ params[:api_key] = Configuration.api_key
30
+ params[:cdn] = Configuration.cdn
31
+
32
+ Request.new(Configuration.api_end_point, params)
33
+ end
34
+
35
+ class APIException < ::Exception; end
36
+ class MissingIdException < APIException; end
37
+ class InvalidParamsException < APIException; end
38
+ end
@@ -0,0 +1,18 @@
1
+ class ScaleEngineAPI
2
+ class Configuration
3
+ class << self
4
+ attr_accessor :api_key
5
+ attr_accessor :secret_key
6
+ attr_accessor :cdn
7
+ attr_accessor :username
8
+
9
+ def api_end_point
10
+ "https://api.scaleengine.net/stable/"
11
+ end
12
+
13
+ def record_control_end_point
14
+ "http://#{:username}-rec.vorigin.scaleengine.net:8086/serecordcontrols"
15
+ end
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,47 @@
1
+ require 'json'
2
+ require 'base64'
3
+
4
+ class ScaleEngineAPI
5
+ class Request
6
+ attr_accessor :path, :query
7
+
8
+ def initialize(path = "", query = {})
9
+ @path = path
10
+ @query = query
11
+ end
12
+
13
+ def send
14
+ body = prepare_request
15
+ response = RestClient.post path, body
16
+ Response.new(response)
17
+ end
18
+
19
+ def method_missing(method, *args)
20
+ query_new = query
21
+ query_new[:command] += ".#{method}"
22
+
23
+ params = args[0].is_a?(Hash) ? args[0] : {}
24
+ params.delete(:command)
25
+ params.keys.each do |x|
26
+ query_new[x] = params[x]
27
+ end
28
+
29
+ Request.new(path, query_new)
30
+ end
31
+
32
+ def prepare_request
33
+ query[:timestamp] = Time.now.to_i
34
+ query[:signature] = Base64.strict_encode64(request_signature)
35
+ body = {:json => JSON.generate(query), :multipart => true}
36
+ end
37
+
38
+ def request_signature
39
+ params = query
40
+ json_params = JSON.generate(params)
41
+
42
+ # Compute new SHA256 HMAC
43
+ digest = OpenSSL::Digest::SHA256.new
44
+ OpenSSL::HMAC.digest(digest, Configuration.secret_key, json_params)
45
+ end
46
+ end
47
+ end
@@ -0,0 +1,9 @@
1
+ class ScaleEngineAPI
2
+ class Response
3
+ attr_accessor :body
4
+
5
+ def initialize(json)
6
+ @body = JSON.parse(json)
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,24 @@
1
+ ## NOT AN OFFICIAL TEST
2
+ ## No Unit/Functional tests present
3
+ ## THIS FILE IS JUST A TEMPORARY TEST SCRIPT
4
+ require "logger"
5
+ require_relative "../lib/scaleengine"
6
+
7
+ logger = Logger.new(STDOUT)
8
+ logger.level = Logger::DEBUG
9
+
10
+ ScaleEngineAPI::Configuration.api_key = ENV["SCALEENGINE_API_KEY"]
11
+ ScaleEngineAPI::Configuration.secret_key = ENV["SCALEENGINE_SECRET_KEY"]
12
+ ScaleEngineAPI::Configuration.username = ENV["SCALEENGINE_USERNAME"]
13
+ ScaleEngineAPI::Configuration.cdn = ENV["SCALEENGINE_CDN"]
14
+
15
+ se = ScaleEngineAPI.new
16
+ logger.debug se.sevu
17
+ req = se.sevu.addstreamuser({
18
+ app: 'conferencecloud-origin',
19
+ stream: "conferencecloud-test",
20
+ user: "conferencecloud",
21
+ pass: "unique_random_string_per_request"
22
+ })
23
+ logger.debug req
24
+ logger.debug req.send
metadata ADDED
@@ -0,0 +1,63 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: ruby-scaleengine
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - John-Alan Simmons
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-01-28 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: rest-client
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.7'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.7'
27
+ description: Wrapper for the ScaleEngine API
28
+ email:
29
+ - johnalan@conferencecloud.co
30
+ executables: []
31
+ extensions: []
32
+ extra_rdoc_files: []
33
+ files:
34
+ - LICENSE
35
+ - lib/scaleengine.rb
36
+ - lib/scaleengine/configuration.rb
37
+ - lib/scaleengine/request.rb
38
+ - lib/scaleengine/response.rb
39
+ - tests/test.rb
40
+ homepage: https://github.com/ConferenceCloud/ruby-scaleengine
41
+ licenses: []
42
+ metadata: {}
43
+ post_install_message:
44
+ rdoc_options: []
45
+ require_paths:
46
+ - lib
47
+ required_ruby_version: !ruby/object:Gem::Requirement
48
+ requirements:
49
+ - - ">="
50
+ - !ruby/object:Gem::Version
51
+ version: '0'
52
+ required_rubygems_version: !ruby/object:Gem::Requirement
53
+ requirements:
54
+ - - ">="
55
+ - !ruby/object:Gem::Version
56
+ version: '0'
57
+ requirements: []
58
+ rubyforge_project: ruby-scaleengine
59
+ rubygems_version: 2.2.2
60
+ signing_key:
61
+ specification_version: 4
62
+ summary: Wrapper for the ScaleEngine API
63
+ test_files: []