wowza_rest 0.2.1 → 0.2.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +3 -0
- data/README.md +3 -2
- data/lib/wowza_rest/applications.rb +10 -2
- data/lib/wowza_rest/data/application.rb +48 -0
- data/lib/wowza_rest/data/application_short.rb +7 -0
- data/lib/wowza_rest/data/base.rb +33 -0
- data/lib/wowza_rest/data/incoming_stream_stats.rb +16 -0
- data/lib/wowza_rest/data/instance.rb +33 -0
- data/lib/wowza_rest/ext/string.rb +16 -0
- data/lib/wowza_rest/instances.rb +12 -4
- data/lib/wowza_rest/version.rb +1 -1
- data/lib/wowza_rest.rb +1 -0
- data/wowza_rest.gemspec +1 -1
- metadata +9 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8ed08a4543064704cfc079d99b01ca482ac3b8a1
|
4
|
+
data.tar.gz: 37bb85b09e1e544019344e88ec2ecee4792bc316
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 64daccebf840c89b41bdc941476691912db53ff08e79bc34fb8c35d7b38e810779ad379798fc11487c744fc779927c80ec83d50390607ec65b2738d22a993ffc
|
7
|
+
data.tar.gz: 6a35ba443f8f52838bdbf99168ba82f4c64ac5e236c63082b02b80204add1c8dd14c26bf59ca1cb4e537c83805bc47a7ebd0139933c767c1b41f8ef13664b05c
|
data/.rubocop.yml
CHANGED
data/README.md
CHANGED
@@ -1,7 +1,8 @@
|
|
1
1
|
# WowzaRest
|
2
2
|
|
3
|
-
[![Build Status](https://travis-ci.org/
|
3
|
+
[![Build Status](https://travis-ci.org/ExtremeSolution/wowza-rest.svg?branch=master)](https://travis-ci.org/ExtremeSolution/wowza-rest)
|
4
4
|
[![Code Climate](https://codeclimate.com/github/hazemtaha/wowza_rest/badges/gpa.svg)](https://codeclimate.com/github/hazemtaha/wowza_rest)
|
5
|
+
[![Gem Version](https://badge.fury.io/rb/wowza_rest.svg)](https://badge.fury.io/rb/wowza_rest)
|
5
6
|
|
6
7
|
Ruby wrapper for Wowza Streaming Engine Rest API
|
7
8
|
|
@@ -98,7 +99,7 @@ To install this gem onto your local machine, run `bundle exec rake install`. To
|
|
98
99
|
|
99
100
|
## Contributing
|
100
101
|
|
101
|
-
Bug reports and pull requests are welcome on GitHub at https://github.com/
|
102
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/ExtremeSolution/wowza-rest. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
|
102
103
|
|
103
104
|
|
104
105
|
## License
|
@@ -1,13 +1,21 @@
|
|
1
|
+
require_relative 'data/application'
|
2
|
+
require_relative 'data/application_short'
|
3
|
+
|
1
4
|
module WowzaRest
|
2
5
|
module Applications
|
3
6
|
def applications
|
4
|
-
connection.request(:get, '/applications')
|
7
|
+
response = connection.request(:get, '/applications')
|
8
|
+
return unless response.code == 200
|
9
|
+
response.parsed_response['applications']
|
10
|
+
.map { |e| WowzaRest::Data::ApplicationShort.new(e) }
|
5
11
|
end
|
6
12
|
|
7
13
|
def get_application(app_name)
|
8
14
|
response = connection.request(:get, "/applications/#{app_name}")
|
9
|
-
response.
|
15
|
+
return unless response.code == 200
|
16
|
+
WowzaRest::Data::Application.new(response.parsed_response)
|
10
17
|
end
|
18
|
+
alias application get_application
|
11
19
|
|
12
20
|
def create_application(app_body, use_default_config = true)
|
13
21
|
unless app_body.include?(:name) && app_body.include?(:appType)
|
@@ -0,0 +1,48 @@
|
|
1
|
+
require_relative 'base'
|
2
|
+
|
3
|
+
module WowzaRest
|
4
|
+
module Data
|
5
|
+
class Application < Base
|
6
|
+
attr_reader :security_config, :stream_config, :dvr_config,
|
7
|
+
:drm_config, :transcoder_config, :modules
|
8
|
+
|
9
|
+
def initialize(attrs = {})
|
10
|
+
initialize_object_attrs(attrs)
|
11
|
+
super(attrs)
|
12
|
+
end
|
13
|
+
|
14
|
+
class TranscoderConfig < Base
|
15
|
+
attr_reader :templates
|
16
|
+
def initialize(attrs = {})
|
17
|
+
@templates = map_array_objects(
|
18
|
+
attrs.delete('templates')['templates'], Template
|
19
|
+
)
|
20
|
+
super(attrs)
|
21
|
+
end
|
22
|
+
|
23
|
+
class Template < Base; end
|
24
|
+
end
|
25
|
+
|
26
|
+
class SecurityConfig < Base; end
|
27
|
+
class StreamConfig < Base; end
|
28
|
+
class DVRConfig < Base; end
|
29
|
+
class DRMConfig < Base; end
|
30
|
+
class Module < Base; end
|
31
|
+
|
32
|
+
private
|
33
|
+
|
34
|
+
def initialize_object_attrs(attrs)
|
35
|
+
@security_config = SecurityConfig.new(attrs.delete('securityConfig'))
|
36
|
+
@stream_config = StreamConfig.new(attrs.delete('streamConfig'))
|
37
|
+
@dvr_config = DVRConfig.new(attrs.delete('dvrConfig'))
|
38
|
+
@drm_config = DRMConfig.new(attrs.delete('drmConfig'))
|
39
|
+
@transcoder_config = TranscoderConfig.new(
|
40
|
+
attrs.delete('transcoderConfig')
|
41
|
+
)
|
42
|
+
@modules = map_array_objects(
|
43
|
+
attrs.delete('modules')['moduleList'], Module
|
44
|
+
)
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
module WowzaRest
|
2
|
+
module Data
|
3
|
+
class Base
|
4
|
+
def initialize(attrs = {})
|
5
|
+
setup_attributes(attrs)
|
6
|
+
end
|
7
|
+
|
8
|
+
def setup_attributes(attrs)
|
9
|
+
attrs.each do |k, v|
|
10
|
+
define_attribute_getter(k.underscore)
|
11
|
+
define_attribute_setter(k.underscore)
|
12
|
+
instance_variable_set("@#{k.underscore}", v)
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
def define_attribute_getter(attr_name)
|
17
|
+
define_singleton_method(attr_name.to_s) do
|
18
|
+
instance_variable_get("@#{attr_name}")
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
def define_attribute_setter(attr_name)
|
23
|
+
define_singleton_method("#{attr_name}=") do |value|
|
24
|
+
instance_variable_set("@#{attr_name}", value)
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
def map_array_objects(arr, klass)
|
29
|
+
arr.map { |obj| klass.new(obj) }
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
require_relative 'base'
|
2
|
+
|
3
|
+
module WowzaRest
|
4
|
+
module Data
|
5
|
+
class IncomingStreamStats < Base
|
6
|
+
attr_reader :connection_count
|
7
|
+
|
8
|
+
def initialize(attrs = {})
|
9
|
+
@connection_count = ConnectionCount.new(attrs.delete('connectionCount'))
|
10
|
+
super(attrs)
|
11
|
+
end
|
12
|
+
|
13
|
+
class ConnectionCount < Base; end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
require_relative 'base'
|
2
|
+
|
3
|
+
module WowzaRest
|
4
|
+
module Data
|
5
|
+
class Instance < Base
|
6
|
+
attr_reader :incoming_streams, :outgoing_streams,
|
7
|
+
:recorders, :stream_groups
|
8
|
+
|
9
|
+
# rubocop:disable Metrics/MethodLength
|
10
|
+
def initialize(attrs = {})
|
11
|
+
@incoming_streams = map_array_objects(
|
12
|
+
attrs.delete('incomingStreams'), IncomingStream
|
13
|
+
)
|
14
|
+
@outgoing_streams = map_array_objects(
|
15
|
+
attrs.delete('outgoingStreams'), OutgoingStream
|
16
|
+
)
|
17
|
+
@recorders = map_array_objects(
|
18
|
+
attrs.delete('recorders'), Recorder
|
19
|
+
)
|
20
|
+
@stream_groups = map_array_objects(
|
21
|
+
attrs.delete('streamGroups'), StreamGroup
|
22
|
+
)
|
23
|
+
super(attrs)
|
24
|
+
end
|
25
|
+
# rubocop:enable Metrics/MethodLength
|
26
|
+
|
27
|
+
class IncomingStream < Base; end
|
28
|
+
class OutgoingStream < Base; end
|
29
|
+
class Recorder < Base; end
|
30
|
+
class StreamGroup < Base; end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
class String
|
2
|
+
def underscore
|
3
|
+
gsub(/::/, '/')
|
4
|
+
.gsub(/([A-Z]+)([A-Z][a-z])/, '\1_\2')
|
5
|
+
.gsub(/([a-z\d])([A-Z])/, '\1_\2')
|
6
|
+
.tr('-', '_')
|
7
|
+
.downcase
|
8
|
+
end
|
9
|
+
|
10
|
+
def camelize
|
11
|
+
tr('-', '_')
|
12
|
+
.gsub(/\b[A-Z]+/, &:downcase)
|
13
|
+
.gsub(/_(.)/, &:upcase)
|
14
|
+
.tr('_', '')
|
15
|
+
end
|
16
|
+
end
|
data/lib/wowza_rest/instances.rb
CHANGED
@@ -1,16 +1,23 @@
|
|
1
|
+
require_relative 'data/instance'
|
2
|
+
require_relative 'data/incoming_stream_stats'
|
3
|
+
|
1
4
|
module WowzaRest
|
2
5
|
module Instances
|
3
6
|
def instances(app_name)
|
4
|
-
connection.request(
|
7
|
+
response = connection.request(
|
5
8
|
:get, "/applications/#{app_name}/instances"
|
6
|
-
)
|
9
|
+
)
|
10
|
+
return unless response.code == 200
|
11
|
+
response.parsed_response['instanceList']
|
12
|
+
.map { |e| WowzaRest::Data::Instance.new(e) }
|
7
13
|
end
|
8
14
|
|
9
15
|
def get_instance(app_name, instance_name = '_definst_')
|
10
16
|
response = connection.request(
|
11
17
|
:get, "/applications/#{app_name}/instances/#{instance_name}"
|
12
18
|
)
|
13
|
-
response.code == 200
|
19
|
+
return unless response.code == 200
|
20
|
+
WowzaRest::Data::Instance.new(response.parsed_response)
|
14
21
|
end
|
15
22
|
|
16
23
|
# rubocop:disable Metrics/LineLength
|
@@ -18,7 +25,8 @@ module WowzaRest
|
|
18
25
|
response = connection.request(
|
19
26
|
:get, "/applications/#{app_name}/instances/#{instance_name}/incomingstreams/#{stream_name}/monitoring/current"
|
20
27
|
)
|
21
|
-
response.code == 200
|
28
|
+
return unless response.code == 200
|
29
|
+
WowzaRest::Data::IncomingStreamStats.new(response.parsed_response)
|
22
30
|
end
|
23
31
|
# rubocop:enable Metrics/LineLength
|
24
32
|
end
|
data/lib/wowza_rest/version.rb
CHANGED
data/lib/wowza_rest.rb
CHANGED
data/wowza_rest.gemspec
CHANGED
@@ -12,7 +12,7 @@ Gem::Specification.new do |spec|
|
|
12
12
|
|
13
13
|
spec.summary = 'Wowza REST API Wrapper Gem.'
|
14
14
|
spec.description = 'Wowza REST API Wrapper Gem.'
|
15
|
-
spec.homepage = 'https://github.com/
|
15
|
+
spec.homepage = 'https://github.com/ExtremeSolution/wowza-rest'
|
16
16
|
spec.license = 'MIT'
|
17
17
|
|
18
18
|
# Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: wowza_rest
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Hazem Taha
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-07-
|
11
|
+
date: 2017-07-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -173,12 +173,18 @@ files:
|
|
173
173
|
- lib/wowza_rest/applications.rb
|
174
174
|
- lib/wowza_rest/client.rb
|
175
175
|
- lib/wowza_rest/connection.rb
|
176
|
+
- lib/wowza_rest/data/application.rb
|
177
|
+
- lib/wowza_rest/data/application_short.rb
|
178
|
+
- lib/wowza_rest/data/base.rb
|
179
|
+
- lib/wowza_rest/data/incoming_stream_stats.rb
|
180
|
+
- lib/wowza_rest/data/instance.rb
|
176
181
|
- lib/wowza_rest/errors.rb
|
182
|
+
- lib/wowza_rest/ext/string.rb
|
177
183
|
- lib/wowza_rest/instances.rb
|
178
184
|
- lib/wowza_rest/publishers.rb
|
179
185
|
- lib/wowza_rest/version.rb
|
180
186
|
- wowza_rest.gemspec
|
181
|
-
homepage: https://github.com/
|
187
|
+
homepage: https://github.com/ExtremeSolution/wowza-rest
|
182
188
|
licenses:
|
183
189
|
- MIT
|
184
190
|
metadata: {}
|