wowza_cloud 0.2.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.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 75252e7830b78751e1f56b7683d9528d702ce785
4
+ data.tar.gz: c213409ce42330930f764f179399f921142f198d
5
+ SHA512:
6
+ metadata.gz: ec276e2cf729a4487672052d79c3a754342f33afd56cddb2a31fa37c343702b121e14fa79db089bffcf3f5f29af514e5cc2d1c1244797deee3424cd9a38a514b
7
+ data.tar.gz: 1bbbcfcef0d4f728c87dfe40fb26f0f0a123d23f1a4a66ab77cfef2b362a9351dfddca2013bcb70a4340bee154371825789e98775bdf226db79555957661164e
data/.gitignore ADDED
@@ -0,0 +1,13 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
10
+ credentials.yml
11
+
12
+ # rspec failure tracking
13
+ .rspec_status
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --format documentation
2
+ --color
data/.travis.yml ADDED
@@ -0,0 +1,5 @@
1
+ sudo: false
2
+ language: ruby
3
+ rvm:
4
+ - 2.3.3
5
+ before_install: gem install bundler -v 1.14.6
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in wowza_cloud.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2017 Steve Lewis
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.
data/README.md ADDED
@@ -0,0 +1,138 @@
1
+ # WowzaCloud
2
+
3
+ This gem is a dead-simple wrapper around the [Wowza Streaming Cloud
4
+ API]('https://sandbox.cloud.wowza.com/apidocs/v1/'). The quickest way to get
5
+ started with this library would be to glance over the Wowza documentation, then
6
+ come back here and take a look at some of the examples below.
7
+
8
+ Thus far, this only covers the live streams portion of the API, and is missing
9
+ delete, create and update from that section. I'm planning on adding more
10
+ functionality as I need it, but feel free to add a pull request if there's
11
+ something missing here that you'd like to see.
12
+
13
+ ## Installation
14
+
15
+ Add this line to your application's Gemfile:
16
+
17
+ ```ruby
18
+ gem 'wowza_cloud'
19
+ ```
20
+
21
+ And then execute:
22
+
23
+ $ bundle
24
+
25
+ Or install it yourself as:
26
+
27
+ $ gem install wowza_cloud
28
+
29
+ ## Usage
30
+
31
+ ### Configuration
32
+
33
+ Before you can use the Wowza Streaming Cloud API, you'll need to get an API key
34
+ and an Access key from Wowza. You can do so through your account settings. Once
35
+ you have them, you'll need to provide them to the gem, via a configuration
36
+ block. For Rails users, your best bet is to create a `wowza-cloud.rb` file in
37
+ your `config/initializers/` directory, then place something like the below in
38
+ it:
39
+
40
+ ```ruby
41
+ WowzaCloud.configure do |config|
42
+ yaml_path = `path/to_file/containing/credentials.yml`
43
+ hsh = YAML.load(File.read(yaml_path))
44
+ config.api_key = hsh['api_key']
45
+ config.access_key = hsh['access_key']
46
+ end
47
+ ```
48
+
49
+ For non-Rails users, some variation of the above called somewhere before you
50
+ start using the gem should do.
51
+
52
+ ### Getting a list of streams
53
+
54
+ One of the more basic things you'll want to do is to get a list of all of your
55
+ streams. Doing so is as simple as:
56
+
57
+ ```ruby
58
+ streams = WowzaCloud::Stream.all
59
+ ```
60
+
61
+ The above will return an array of `Wowza::Stream` objects, which you can use to
62
+ manipulate individual streams.
63
+
64
+ ### Fetching a single stream
65
+
66
+ If you have a specific stream you need to work with, you can pull it by itself,
67
+ using it's ID:
68
+
69
+ ```ruby
70
+ stream = WowzaCloud::Stream.get_stream('vxy4nprl')
71
+ ```
72
+
73
+ The above will return a single instance of `Wowza::Stream` that you can use to
74
+ manipulate that particular stream.
75
+
76
+ ### Working with a Stream
77
+
78
+ The gem gives you a number of basic actions you can take for a particular
79
+ stream.
80
+
81
+ #### Checking Stream Status
82
+
83
+ You can get the status, (also called state), of a stream by calling the
84
+ `status` method on a WowzaCloud::Stream instance:
85
+
86
+ ```ruby
87
+ stream = WowzaCloud::Stream.get_stream('vxy4nprl')
88
+ stream.status # => 'started'
89
+ ```
90
+
91
+ The method above will return a string representing the status of the stream,
92
+ Possible return states are: starting, stopping, started, stopped, and
93
+ resetting.
94
+
95
+ #### Getting stream statistics
96
+
97
+ You can get a hash of stream-related statistics. This is important for
98
+ monitoring and reporting purposes:
99
+
100
+ ```ruby
101
+ stream = WowzaCloud::Stream.get_stream('vxy4nprl')
102
+ stream.stats # => {...}
103
+ ```
104
+
105
+ #### Starting, Stopping, and Resetting a Stream
106
+
107
+ You can manipulate the state of a stream with a few simple commands. Each of
108
+ the commands below return a string representing the state of the stream after
109
+ your call was made. For instance, if you were to stop a running stream, the
110
+ return value of the call would be "stopping":
111
+
112
+ ```ruby
113
+ stream = WowzaCloud::Stream.get_stream('vxy4nprl')
114
+ # Start a stream
115
+ stream.start # => 'starting'
116
+ # Reset a stream
117
+ stream.reset # => 'resetting'
118
+ # Stop a stream
119
+ stream.stop # => 'stopping'
120
+ ```
121
+
122
+
123
+ ## Development
124
+
125
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
126
+
127
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
128
+
129
+ ## Contributing
130
+
131
+ Bug reports and pull requests are welcome on GitHub at
132
+ https://github.com/stlewis/wowza_cloud.
133
+
134
+
135
+ ## License
136
+
137
+ The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
138
+
data/Rakefile ADDED
@@ -0,0 +1,6 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task :default => :spec
data/bin/console ADDED
@@ -0,0 +1,21 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "wowza_cloud"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+ #
13
+ WowzaCloud.configure do |config|
14
+ yaml_path = File.dirname(__FILE__) + '/../credentials.yml'
15
+ hsh = YAML.load(File.read(yaml_path))
16
+ config.api_key = hsh['api_key']
17
+ config.access_key = hsh['access_key']
18
+ end
19
+
20
+ require "irb"
21
+ IRB.start(__FILE__)
data/bin/setup ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,14 @@
1
+ require 'httparty'
2
+
3
+ module WowzaCloud
4
+ class Client
5
+ include HTTParty
6
+
7
+ base_uri 'https://api-sandbox.cloud.wowza.com/api/v1'
8
+ attr_reader :headers
9
+
10
+ def initialize(params = {})
11
+ @headers = {'wsc-api-key' => WowzaCloud.configuration.api_key, 'wsc-access-key' => WowzaCloud.configuration.access_key }
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,80 @@
1
+ module WowzaCloud
2
+ class Stream < WowzaCloud::Client
3
+ attr_accessor :aspect_ratio_height, :aspect_ratio_width, :billing_mode, :broadcast_location, :closed_caption_type, :delivery_method, :delivery_protocols, :delivery_protocol,
4
+ :delivery_type, :disable_authentication, :encoder, :hosted_page, :hosted_page_description, :hosted_page_logo_image, :hosted_page_sharing_icons,
5
+ :hosted_page_title, :name, :password, :player_countdown, :player_countdown_at, :player_logo_image, :player_resposive, :player_type,
6
+ :player_video_poster_image, :player_width, :recording, :remove_hosted_page_logo_image, :remove_player_video_poster_image, :source_url,
7
+ :transcoder_type, :use_stream_source, :username, :video_fallback, :api_key, :access_key, :id, :low_latency, :target_delivery_protocol, :source_connection_information,
8
+ :streaming_server, :stream_name, :player_id, :player_embed_code
9
+
10
+
11
+ def self.all()
12
+ result = []
13
+ headers = {'wsc-api-key' => WowzaCloud.configuration.api_key, 'wsc-access-key' => WowzaCloud.configuration.access_key}
14
+ raw_result = get('/live_streams', headers: headers)
15
+ raw_result['live_streams'].each do |data|
16
+ result << WowzaCloud::Stream.new(data)
17
+ end
18
+ return result
19
+ end
20
+
21
+ def self.get_stream(stream_id)
22
+ headers = {'wsc-api-key' => WowzaCloud.configuration.api_key, 'wsc-access-key' => WowzaCloud.configuration.access_key}
23
+ raw_result = get("/live_streams/#{stream_id}", headers: headers)
24
+ return WowzaCloud::Stream.new(raw_result[1].first)
25
+ end
26
+
27
+
28
+ def initialize(params = {})
29
+ super
30
+ params.each do |k, v|
31
+ instance_variable_set(:"@#{k}", v) if self.respond_to?("#{k}=")
32
+ end
33
+ if(conn_params = params['source_connection_information'])
34
+ self.streaming_server = conn_params['primary_server']
35
+ self.stream_name = conn_params['stream_name']
36
+ self.disable_authentication = conn_params['disable_authentication']
37
+ self.username = conn_params['username']
38
+ self.password = conn_params['password']
39
+ end
40
+ end
41
+
42
+ #def destroy
43
+ #raw_response = self.class.delete("/live_streams/#{self.id}", headers: @headers)
44
+ #return raw_response.code == 204
45
+ #end
46
+
47
+ def status
48
+ raw_response = self.class.get("/live_streams/#{self.id}/state/", headers: @headers)
49
+ return raw_response['live_stream']['state']
50
+ end
51
+
52
+ alias state status
53
+
54
+ def stats
55
+ raw_response = self.class.get("/live_streams/#{self.id}/stats", headers: @headers)
56
+ return raw_response['live_stream']
57
+ end
58
+
59
+ def thumbnail
60
+ raw_response = self.class.get("/live_streams/#{self.id}/thumbnail_url", headers: @headers)
61
+ return raw_response['live_stream']['thumbnail_url']
62
+ end
63
+
64
+ def start
65
+ raw_response = self.class.put("/live_streams/#{self.id}/start", headers: @headers)
66
+ return raw_response['live_stream']['state']
67
+ end
68
+
69
+ def reset
70
+ raw_response = self.class.put("/live_streams/#{self.id}/reset", headers: @headers)
71
+ return raw_response['live_stream']['state']
72
+ end
73
+
74
+ def stop
75
+ raw_response = self.class.put("/live_streams/#{self.id}/stop", headers: @headers)
76
+ return raw_response['live_stream']['state']
77
+ end
78
+
79
+ end
80
+ end
@@ -0,0 +1,3 @@
1
+ module WowzaCloud
2
+ VERSION = "0.2.0"
3
+ end
@@ -0,0 +1,18 @@
1
+ require "wowza_cloud/version"
2
+ require "wowza_cloud/client"
3
+ require "wowza_cloud/stream"
4
+
5
+ module WowzaCloud
6
+ class << self
7
+ attr_accessor :configuration
8
+ end
9
+
10
+ def self.configure
11
+ self.configuration ||= Configuration.new
12
+ yield(configuration)
13
+ end
14
+
15
+ class Configuration
16
+ attr_accessor :api_key, :access_key
17
+ end
18
+ end
@@ -0,0 +1,37 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'wowza_cloud/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "wowza_cloud"
8
+ spec.version = WowzaCloud::VERSION
9
+ spec.authors = ["Steve Lewis"]
10
+ spec.email = ["steve@decodingsteve.com"]
11
+
12
+ spec.summary = %q{Thin wrapper around the Wowza Cloud API}
13
+ spec.homepage = "https://www.github.com/stlewis/wowza_cloud"
14
+ spec.license = "MIT"
15
+
16
+ # Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
17
+ # to allow pushing to a single host or delete this section to allow pushing to any host.
18
+ if spec.respond_to?(:metadata)
19
+ spec.metadata['allowed_push_host'] = "https://rubygems.org"
20
+ else
21
+ raise "RubyGems 2.0 or newer is required to protect against " \
22
+ "public gem pushes."
23
+ end
24
+
25
+ spec.files = `git ls-files -z`.split("\x0").reject do |f|
26
+ f.match(%r{^(test|spec|features)/})
27
+ end
28
+ spec.bindir = "exe"
29
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
30
+ spec.require_paths = ["lib"]
31
+
32
+ spec.add_dependency 'httparty'
33
+
34
+ spec.add_development_dependency "bundler", "~> 1.14"
35
+ spec.add_development_dependency "rake", "~> 10.0"
36
+ spec.add_development_dependency "rspec", "~> 3.0"
37
+ end
metadata ADDED
@@ -0,0 +1,115 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: wowza_cloud
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.2.0
5
+ platform: ruby
6
+ authors:
7
+ - Steve Lewis
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2017-04-10 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: httparty
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: bundler
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '1.14'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '1.14'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rake
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '10.0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '10.0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rspec
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '3.0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '3.0'
69
+ description:
70
+ email:
71
+ - steve@decodingsteve.com
72
+ executables: []
73
+ extensions: []
74
+ extra_rdoc_files: []
75
+ files:
76
+ - ".gitignore"
77
+ - ".rspec"
78
+ - ".travis.yml"
79
+ - Gemfile
80
+ - LICENSE.txt
81
+ - README.md
82
+ - Rakefile
83
+ - bin/console
84
+ - bin/setup
85
+ - lib/wowza_cloud.rb
86
+ - lib/wowza_cloud/client.rb
87
+ - lib/wowza_cloud/stream.rb
88
+ - lib/wowza_cloud/version.rb
89
+ - wowza_cloud.gemspec
90
+ homepage: https://www.github.com/stlewis/wowza_cloud
91
+ licenses:
92
+ - MIT
93
+ metadata:
94
+ allowed_push_host: https://rubygems.org
95
+ post_install_message:
96
+ rdoc_options: []
97
+ require_paths:
98
+ - lib
99
+ required_ruby_version: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - ">="
102
+ - !ruby/object:Gem::Version
103
+ version: '0'
104
+ required_rubygems_version: !ruby/object:Gem::Requirement
105
+ requirements:
106
+ - - ">="
107
+ - !ruby/object:Gem::Version
108
+ version: '0'
109
+ requirements: []
110
+ rubyforge_project:
111
+ rubygems_version: 2.5.2
112
+ signing_key:
113
+ specification_version: 4
114
+ summary: Thin wrapper around the Wowza Cloud API
115
+ test_files: []