wsc_sdk 1.3.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.circleci/config.yml +146 -0
- data/.circleci/docker/build/Dockerfile +3 -0
- data/.circleci/helpers/add_preamble.rb +29 -0
- data/.circleci/helpers/build_docs.sh +5 -0
- data/.circleci/helpers/build_gem.sh +5 -0
- data/.circleci/helpers/debundle-context.sh +14 -0
- data/.circleci/helpers/finalize_release.sh +24 -0
- data/.circleci/helpers/publish_docs.sh +10 -0
- data/.circleci/helpers/release_gem.sh +8 -0
- data/.circleci/helpers/setup.sh +11 -0
- data/.circleci/helpers/setup_aws.sh +13 -0
- data/.circleci/helpers/setup_gem.sh +2 -0
- data/.circleci/helpers/setup_git.sh +27 -0
- data/.circleci/helpers/setup_rubygems.sh +15 -0
- data/.circleci/helpers/test_integration.sh +12 -0
- data/.circleci/helpers/test_unit.sh +6 -0
- data/.circleci/jobs/publish-production.sh +17 -0
- data/.circleci/jobs/publish-staging.sh +17 -0
- data/.circleci/jobs/release-production.sh +21 -0
- data/.circleci/jobs/test-integration.sh +9 -0
- data/.circleci/jobs/test-unit.sh +9 -0
- data/.circleci/tag_repo.rb +46 -0
- data/.gitignore +28 -0
- data/.rspec +2 -0
- data/.yard/config +2 -0
- data/.yard/template/default/fulldoc/html/css/custom.css +151 -0
- data/.yard/template/default/layout/html/footer.erb +0 -0
- data/.yard/template/default/layout/html/headers.erb +10 -0
- data/.yard/template/default/layout/html/layout.erb +45 -0
- data/.yard/template/default/layout/html/setup.rb +24 -0
- data/.yardopts +1 -0
- data/CODE_OF_CONDUCT.md +74 -0
- data/Gemfile +6 -0
- data/Gemfile.lock +99 -0
- data/LICENSE.txt +28 -0
- data/README.md +397 -0
- data/Rakefile +2 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/doc/Hash.html +291 -0
- data/doc/WscSdk.html +570 -0
- data/doc/WscSdk/ApiResponse.html +242 -0
- data/doc/WscSdk/Attributes.html +128 -0
- data/doc/WscSdk/Attributes/Mode.html +191 -0
- data/doc/WscSdk/Attributes/Type.html +389 -0
- data/doc/WscSdk/Client.html +2677 -0
- data/doc/WscSdk/Configuration.html +595 -0
- data/doc/WscSdk/Endpoint.html +2974 -0
- data/doc/WscSdk/Endpoints.html +141 -0
- data/doc/WscSdk/Endpoints/CustomStreamTargets.html +383 -0
- data/doc/WscSdk/Endpoints/LiveStreams.html +197 -0
- data/doc/WscSdk/Endpoints/OutputStreamTargets.html +180 -0
- data/doc/WscSdk/Endpoints/Outputs.html +180 -0
- data/doc/WscSdk/Endpoints/StreamTargets.html +446 -0
- data/doc/WscSdk/Endpoints/Transcoders.html +197 -0
- data/doc/WscSdk/Endpoints/UllStreamTargets.html +383 -0
- data/doc/WscSdk/Endpoints/WowzaStreamTargets.html +383 -0
- data/doc/WscSdk/Enum.html +225 -0
- data/doc/WscSdk/Enums.html +321 -0
- data/doc/WscSdk/Enums/BillingMode.html +188 -0
- data/doc/WscSdk/Enums/BroadcastLocation.html +396 -0
- data/doc/WscSdk/Enums/BufferSize.html +301 -0
- data/doc/WscSdk/Enums/ClosedCaptionType.html +221 -0
- data/doc/WscSdk/Enums/CustomProvider.html +252 -0
- data/doc/WscSdk/Enums/DeliveryMethod.html +188 -0
- data/doc/WscSdk/Enums/DeliveryType.html +188 -0
- data/doc/WscSdk/Enums/Encoder.html +460 -0
- data/doc/WscSdk/Enums/Errors.html +555 -0
- data/doc/WscSdk/Enums/IdleTimeout.html +398 -0
- data/doc/WscSdk/Enums/ImagePosition.html +220 -0
- data/doc/WscSdk/Enums/ModelMode.html +175 -0
- data/doc/WscSdk/Enums/ModelType.html +373 -0
- data/doc/WscSdk/Enums/PlayerType.html +188 -0
- data/doc/WscSdk/Enums/Protocol.html +204 -0
- data/doc/WscSdk/Enums/TargetDeliveryProtocol.html +188 -0
- data/doc/WscSdk/Enums/TranscoderType.html +188 -0
- data/doc/WscSdk/Enums/UserRegion.html +383 -0
- data/doc/WscSdk/Enums/WowzaProvider.html +188 -0
- data/doc/WscSdk/Errors.html +683 -0
- data/doc/WscSdk/Loggable.html +346 -0
- data/doc/WscSdk/Model.html +3316 -0
- data/doc/WscSdk/ModelList.html +442 -0
- data/doc/WscSdk/ModelTemplate.html +267 -0
- data/doc/WscSdk/Models.html +141 -0
- data/doc/WscSdk/Models/CustomStreamTarget.html +192 -0
- data/doc/WscSdk/Models/Error.html +351 -0
- data/doc/WscSdk/Models/LiveStream.html +601 -0
- data/doc/WscSdk/Models/LiveStreamConnectionCode.html +192 -0
- data/doc/WscSdk/Models/LiveStreamState.html +200 -0
- data/doc/WscSdk/Models/LiveStreamStats.html +200 -0
- data/doc/WscSdk/Models/LiveStreamThumbnailUrl.html +200 -0
- data/doc/WscSdk/Models/Output.html +294 -0
- data/doc/WscSdk/Models/OutputStreamTarget.html +274 -0
- data/doc/WscSdk/Models/StreamTarget.html +273 -0
- data/doc/WscSdk/Models/Transcoder.html +793 -0
- data/doc/WscSdk/Models/TranscoderBooleanStat.html +278 -0
- data/doc/WscSdk/Models/TranscoderConnectionCode.html +192 -0
- data/doc/WscSdk/Models/TranscoderFloatStat.html +278 -0
- data/doc/WscSdk/Models/TranscoderIntegerStat.html +278 -0
- data/doc/WscSdk/Models/TranscoderState.html +196 -0
- data/doc/WscSdk/Models/TranscoderStats.html +196 -0
- data/doc/WscSdk/Models/TranscoderStreamTargetState.html +192 -0
- data/doc/WscSdk/Models/TranscoderStringStat.html +278 -0
- data/doc/WscSdk/Models/TranscoderThumbnailUrl.html +196 -0
- data/doc/WscSdk/Models/UllStreamTarget.html +360 -0
- data/doc/WscSdk/Models/WowzaStreamTarget.html +380 -0
- data/doc/WscSdk/Pagination.html +1277 -0
- data/doc/WscSdk/Schema.html +861 -0
- data/doc/WscSdk/SchemaAttribute.html +2400 -0
- data/doc/WscSdk/Templates.html +141 -0
- data/doc/WscSdk/Templates/CustomStreamTarget.html +1045 -0
- data/doc/WscSdk/Templates/LiveStream.html +1432 -0
- data/doc/WscSdk/Templates/Output.html +829 -0
- data/doc/WscSdk/Templates/Transcoder.html +699 -0
- data/doc/WscSdk/Templates/UllStreamTarget.html +411 -0
- data/doc/WscSdk/Templates/WowzaStreamTarget.html +447 -0
- data/doc/WscSdk/TranscoderSharedMethods.html +1113 -0
- data/doc/_index.html +705 -0
- data/doc/class_list.html +51 -0
- data/doc/css/bootstrap.css +5 -0
- data/doc/css/common.css +1 -0
- data/doc/css/custom.css +151 -0
- data/doc/css/full_list.css +58 -0
- data/doc/css/style.css +496 -0
- data/doc/file.README.html +570 -0
- data/doc/file_list.html +56 -0
- data/doc/frames.html +17 -0
- data/doc/images/wsc-ruby-1800x400.png +0 -0
- data/doc/index.html +570 -0
- data/doc/js/app.js +292 -0
- data/doc/js/full_list.js +216 -0
- data/doc/js/jquery.js +4 -0
- data/doc/method_list.html +1731 -0
- data/doc/top-level-namespace.html +182 -0
- data/examples/client.rb +40 -0
- data/examples/helpers.rb +100 -0
- data/examples/live_streams/create.rb +39 -0
- data/examples/live_streams/delete.rb +32 -0
- data/examples/live_streams/find.rb +22 -0
- data/examples/live_streams/flood.rb +126 -0
- data/examples/live_streams/list.rb +24 -0
- data/examples/live_streams/regenerate_connection_code.rb +29 -0
- data/examples/live_streams/reset.rb +32 -0
- data/examples/live_streams/reset_and_wait.rb +51 -0
- data/examples/live_streams/start.rb +33 -0
- data/examples/live_streams/start_and_wait.rb +51 -0
- data/examples/live_streams/state.rb +33 -0
- data/examples/live_streams/stats.rb +43 -0
- data/examples/live_streams/stop.rb +33 -0
- data/examples/live_streams/stop_and_wait.rb +51 -0
- data/examples/live_streams/thumbnail_url.rb +46 -0
- data/examples/live_streams/update.rb +43 -0
- data/examples/live_streams/workflow.rb +165 -0
- data/examples/output_stream_targets/create.rb +56 -0
- data/examples/output_stream_targets/delete.rb +45 -0
- data/examples/output_stream_targets/find.rb +37 -0
- data/examples/output_stream_targets/list.rb +36 -0
- data/examples/output_stream_targets/update.rb +56 -0
- data/examples/outputs/create.rb +49 -0
- data/examples/outputs/delete.rb +39 -0
- data/examples/outputs/find.rb +31 -0
- data/examples/outputs/list.rb +29 -0
- data/examples/outputs/update.rb +50 -0
- data/examples/stream_targets/custom/create.rb +42 -0
- data/examples/stream_targets/custom/delete.rb +31 -0
- data/examples/stream_targets/custom/find.rb +23 -0
- data/examples/stream_targets/custom/list.rb +24 -0
- data/examples/stream_targets/custom/update.rb +43 -0
- data/examples/stream_targets/list.rb +24 -0
- data/examples/stream_targets/ull/create.rb +41 -0
- data/examples/stream_targets/ull/delete.rb +31 -0
- data/examples/stream_targets/ull/find.rb +23 -0
- data/examples/stream_targets/ull/list.rb +24 -0
- data/examples/stream_targets/ull/update.rb +43 -0
- data/examples/stream_targets/wowza/create.rb +42 -0
- data/examples/stream_targets/wowza/delete.rb +31 -0
- data/examples/stream_targets/wowza/find.rb +23 -0
- data/examples/stream_targets/wowza/list.rb +23 -0
- data/examples/stream_targets/wowza/update.rb +43 -0
- data/examples/transcoders/create.rb +39 -0
- data/examples/transcoders/delete.rb +31 -0
- data/examples/transcoders/find.rb +23 -0
- data/examples/transcoders/list.rb +24 -0
- data/examples/transcoders/reset.rb +32 -0
- data/examples/transcoders/reset_and_wait.rb +48 -0
- data/examples/transcoders/start.rb +33 -0
- data/examples/transcoders/start_and_wait.rb +50 -0
- data/examples/transcoders/state.rb +33 -0
- data/examples/transcoders/stats.rb +43 -0
- data/examples/transcoders/stop.rb +33 -0
- data/examples/transcoders/stop_and_wait.rb +50 -0
- data/examples/transcoders/thumbnail_url.rb +46 -0
- data/examples/transcoders/update.rb +43 -0
- data/images/wsc-ruby-1800x400.png +0 -0
- data/lib/wsc_sdk.rb +81 -0
- data/lib/wsc_sdk/client.rb +417 -0
- data/lib/wsc_sdk/configuration.rb +21 -0
- data/lib/wsc_sdk/constants.rb +29 -0
- data/lib/wsc_sdk/endpoint.rb +492 -0
- data/lib/wsc_sdk/endpoints/custom_stream_targets.rb +44 -0
- data/lib/wsc_sdk/endpoints/live_streams.rb +34 -0
- data/lib/wsc_sdk/endpoints/output_stream_targets.rb +17 -0
- data/lib/wsc_sdk/endpoints/outputs.rb +17 -0
- data/lib/wsc_sdk/endpoints/stream_targets.rb +45 -0
- data/lib/wsc_sdk/endpoints/transcoders.rb +38 -0
- data/lib/wsc_sdk/endpoints/ull_stream_targets.rb +44 -0
- data/lib/wsc_sdk/endpoints/wowza_stream_targets.rb +44 -0
- data/lib/wsc_sdk/enums.rb +31 -0
- data/lib/wsc_sdk/enums/billing_mode.rb +20 -0
- data/lib/wsc_sdk/enums/broadcast_location.rb +58 -0
- data/lib/wsc_sdk/enums/buffer_size.rb +41 -0
- data/lib/wsc_sdk/enums/closed_caption_type.rb +26 -0
- data/lib/wsc_sdk/enums/custom_provider.rb +32 -0
- data/lib/wsc_sdk/enums/delivery_method.rb +20 -0
- data/lib/wsc_sdk/enums/delivery_type.rb +20 -0
- data/lib/wsc_sdk/enums/encoder.rb +71 -0
- data/lib/wsc_sdk/enums/idle_timeout.rb +50 -0
- data/lib/wsc_sdk/enums/image_position.rb +26 -0
- data/lib/wsc_sdk/enums/player_type.rb +20 -0
- data/lib/wsc_sdk/enums/protocol.rb +23 -0
- data/lib/wsc_sdk/enums/target_delivery_protocol.rb +20 -0
- data/lib/wsc_sdk/enums/transcoder_type.rb +20 -0
- data/lib/wsc_sdk/enums/wowza_provider.rb +20 -0
- data/lib/wsc_sdk/errors.rb +115 -0
- data/lib/wsc_sdk/model.rb +515 -0
- data/lib/wsc_sdk/model_list.rb +42 -0
- data/lib/wsc_sdk/model_template.rb +27 -0
- data/lib/wsc_sdk/models/custom_stream_target.rb +34 -0
- data/lib/wsc_sdk/models/error.rb +53 -0
- data/lib/wsc_sdk/models/live_stream.rb +130 -0
- data/lib/wsc_sdk/models/live_stream_connection_code.rb +31 -0
- data/lib/wsc_sdk/models/live_stream_state.rb +20 -0
- data/lib/wsc_sdk/models/live_stream_stats.rb +20 -0
- data/lib/wsc_sdk/models/live_stream_thumbnail_url.rb +20 -0
- data/lib/wsc_sdk/models/output.rb +61 -0
- data/lib/wsc_sdk/models/output_stream_target.rb +37 -0
- data/lib/wsc_sdk/models/stream_target.rb +29 -0
- data/lib/wsc_sdk/models/transcoder.rb +135 -0
- data/lib/wsc_sdk/models/transcoder_boolean_stat.rb +41 -0
- data/lib/wsc_sdk/models/transcoder_connection_code.rb +29 -0
- data/lib/wsc_sdk/models/transcoder_float_stat.rb +40 -0
- data/lib/wsc_sdk/models/transcoder_integer_stat.rb +40 -0
- data/lib/wsc_sdk/models/transcoder_state.rb +31 -0
- data/lib/wsc_sdk/models/transcoder_stats.rb +51 -0
- data/lib/wsc_sdk/models/transcoder_stream_target_state.rb +29 -0
- data/lib/wsc_sdk/models/transcoder_string_stat.rb +40 -0
- data/lib/wsc_sdk/models/transcoder_thumbnail_url.rb +29 -0
- data/lib/wsc_sdk/models/ull_stream_target.rb +54 -0
- data/lib/wsc_sdk/models/wowza_stream_target.rb +60 -0
- data/lib/wsc_sdk/modules/api_response.rb +24 -0
- data/lib/wsc_sdk/modules/loggable.rb +44 -0
- data/lib/wsc_sdk/modules/transcoder_shared_methods.rb +221 -0
- data/lib/wsc_sdk/pagination.rb +89 -0
- data/lib/wsc_sdk/schema.rb +140 -0
- data/lib/wsc_sdk/schema_attribute.rb +349 -0
- data/lib/wsc_sdk/templates/custom_stream_target.rb +154 -0
- data/lib/wsc_sdk/templates/live_stream.rb +234 -0
- data/lib/wsc_sdk/templates/output.rb +133 -0
- data/lib/wsc_sdk/templates/transcoder.rb +97 -0
- data/lib/wsc_sdk/templates/ull_stream_target.rb +49 -0
- data/lib/wsc_sdk/templates/wowza_stream_target.rb +57 -0
- data/lib/wsc_sdk/version.rb +7 -0
- data/wsc_sdk.gemspec +48 -0
- metadata +460 -0
@@ -0,0 +1,40 @@
|
|
1
|
+
####> This code and all components © 2015 – 2019 Wowza Media Systems, LLC. All rights reserved.
|
2
|
+
####> This code is licensed pursuant to the BSD 3-Clause License.
|
3
|
+
|
4
|
+
require 'wsc_sdk/model'
|
5
|
+
|
6
|
+
module WscSdk
|
7
|
+
module Models
|
8
|
+
|
9
|
+
# A model to represent the Stats of a Transcoder in the Wowza Streaming
|
10
|
+
# Cloud API.
|
11
|
+
#
|
12
|
+
class TranscoderStringStat < WscSdk::Model
|
13
|
+
|
14
|
+
model_name_singular :transcoder
|
15
|
+
model_name_plural :transcoders
|
16
|
+
|
17
|
+
#---------------------------------------------------------------------------
|
18
|
+
# ___ _
|
19
|
+
# / __| __| |_ ___ _ __ __ _
|
20
|
+
# \__ \/ _| ' \/ -_) ' \/ _` |
|
21
|
+
# |___/\__|_||_\___|_|_|_\__,_|
|
22
|
+
#
|
23
|
+
#---------------------------------------------------------------------------
|
24
|
+
|
25
|
+
attribute :value, :string, access: :read
|
26
|
+
attribute :status, :string, access: :read
|
27
|
+
attribute :text, :string, access: :read
|
28
|
+
attribute :units, :string, access: :read
|
29
|
+
|
30
|
+
# Convert the stat to a string
|
31
|
+
#
|
32
|
+
def to_s
|
33
|
+
str = "#{value.to_s}#{units}"
|
34
|
+
str += " | #{self.text}" if status != "normal"
|
35
|
+
str
|
36
|
+
end
|
37
|
+
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
####> This code and all components © 2015 – 2019 Wowza Media Systems, LLC. All rights reserved.
|
2
|
+
####> This code is licensed pursuant to the BSD 3-Clause License.
|
3
|
+
|
4
|
+
require 'wsc_sdk/model'
|
5
|
+
|
6
|
+
module WscSdk
|
7
|
+
module Models
|
8
|
+
|
9
|
+
# A model to represent the Thumbnail URL of a Transcoder in the Wowza Streaming
|
10
|
+
# Cloud API.
|
11
|
+
#
|
12
|
+
class TranscoderThumbnailUrl < WscSdk::Model
|
13
|
+
|
14
|
+
model_name_singular :transcoder
|
15
|
+
model_name_plural :transcoders
|
16
|
+
|
17
|
+
#---------------------------------------------------------------------------
|
18
|
+
# ___ _
|
19
|
+
# / __| __| |_ ___ _ __ __ _
|
20
|
+
# \__ \/ _| ' \/ -_) ' \/ _` |
|
21
|
+
# |___/\__|_||_\___|_|_|_\__,_|
|
22
|
+
#
|
23
|
+
#---------------------------------------------------------------------------
|
24
|
+
|
25
|
+
attribute :thumbnail_url, :string, access: :read
|
26
|
+
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,54 @@
|
|
1
|
+
####> This code and all components © 2015 – 2019 Wowza Media Systems, LLC. All rights reserved.
|
2
|
+
####> This code is licensed pursuant to the BSD 3-Clause License.
|
3
|
+
|
4
|
+
require 'wsc_sdk/model'
|
5
|
+
require 'wsc_sdk/models/stream_target'
|
6
|
+
|
7
|
+
module WscSdk
|
8
|
+
module Models
|
9
|
+
|
10
|
+
# A model to represent a ULL Stream Target in the Wowza Streaming Cloud API.
|
11
|
+
#
|
12
|
+
class UllStreamTarget < WscSdk::Model
|
13
|
+
|
14
|
+
model_name_singular :stream_target_ull
|
15
|
+
model_name_plural :stream_targets_ull
|
16
|
+
|
17
|
+
attribute :id, :string, access: :read
|
18
|
+
attribute :name, :string, required: true
|
19
|
+
attribute :source_delivery_method, :string, required: true, access: :new_model_access
|
20
|
+
attribute :source_url, :string, required: :source_url_required_if_pull
|
21
|
+
attribute :type, :string, access: :read
|
22
|
+
attribute :provider, :string
|
23
|
+
attribute :enabled, :boolean
|
24
|
+
attribute :enable_hls, :boolean
|
25
|
+
attribute :state, :string
|
26
|
+
attribute :ingest_ip_whitelist, :array
|
27
|
+
attribute :region_override, :string
|
28
|
+
attribute :stream_name, :string, access: :read
|
29
|
+
attribute :primary_url, :string, access: :read
|
30
|
+
attribute :playback_urls, :hash, access: :read
|
31
|
+
attribute :connection_code, :string, access: :read
|
32
|
+
attribute :connection_code_expires_at, :datetime, access: :read
|
33
|
+
attribute :created_at, :datetime, access: :read
|
34
|
+
attribute :updated_at, :datetime, access: :read
|
35
|
+
|
36
|
+
# Determines the access level of the model based on whether it's a new
|
37
|
+
# model or not.
|
38
|
+
#
|
39
|
+
# @return [Symbol]
|
40
|
+
# Returns :read_write if it's a new model, or :read if it's not.
|
41
|
+
#
|
42
|
+
def new_model_access
|
43
|
+
self.new_model? ? :read_write : :read
|
44
|
+
end
|
45
|
+
|
46
|
+
# Determines the requirement of the source_url field based on whether the
|
47
|
+
# target has a `pull` source delivery method.
|
48
|
+
#
|
49
|
+
def source_url_required_if_pull
|
50
|
+
self.source_delivery_method == WscSdk::Enums::DeliveryMethod::PULL
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
@@ -0,0 +1,60 @@
|
|
1
|
+
####> This code and all components © 2015 – 2019 Wowza Media Systems, LLC. All rights reserved.
|
2
|
+
####> This code is licensed pursuant to the BSD 3-Clause License.
|
3
|
+
|
4
|
+
require 'wsc_sdk/model'
|
5
|
+
|
6
|
+
module WscSdk
|
7
|
+
module Models
|
8
|
+
|
9
|
+
# A model to represent a Wowza Stream Target in the Wowza Streaming Cloud API.
|
10
|
+
#
|
11
|
+
class WowzaStreamTarget < WscSdk::Model
|
12
|
+
|
13
|
+
model_name_singular :stream_target_wowza
|
14
|
+
model_name_plural :stream_targets_wowza
|
15
|
+
|
16
|
+
attribute :id, :string, access: :read
|
17
|
+
attribute :name, :string, required: true
|
18
|
+
attribute :type, :string, access: :read
|
19
|
+
attribute :provider, :string
|
20
|
+
attribute :location, :string, access: :new_location_access
|
21
|
+
attribute :use_secure_ingest, :boolean, access: :new_model_access
|
22
|
+
attribute :use_cors, :boolean, access: :new_model_access
|
23
|
+
attribute :stream_name, :string, access: :read
|
24
|
+
attribute :secure_ingest_query_param, :string, access: :read
|
25
|
+
attribute :username, :string, access: :read
|
26
|
+
attribute :password, :string, access: :read
|
27
|
+
attribute :primary_url, :string, access: :read
|
28
|
+
attribute :backup_url, :string, access: :read
|
29
|
+
attribute :hds_playback_url, :string, access: :read
|
30
|
+
attribute :hls_playback_url, :string, access: :read
|
31
|
+
attribute :rtmp_playback_url, :string, access: :read
|
32
|
+
attribute :connection_code, :string, access: :read
|
33
|
+
attribute :connection_code_expires_at, :datetime, access: :read
|
34
|
+
attribute :created_at, :datetime, access: :read
|
35
|
+
attribute :updated_at, :datetime, access: :read
|
36
|
+
|
37
|
+
# Determines the access level of the model based on whether it's a new
|
38
|
+
# model or not.
|
39
|
+
#
|
40
|
+
# @return [Symbol]
|
41
|
+
# Returns :read_write if it's a new model, or :read if it's not.
|
42
|
+
#
|
43
|
+
def new_model_access
|
44
|
+
self.new_model? ? :read_write : :read
|
45
|
+
end
|
46
|
+
|
47
|
+
# Location can only be set if its a new record and not an Akmai Cupertino
|
48
|
+
# provider.
|
49
|
+
#
|
50
|
+
# @return [Symbol]
|
51
|
+
# Returns :read_write if it's a new model and not a Akamai Cupertino
|
52
|
+
# provider, or :read otherwise.
|
53
|
+
#
|
54
|
+
def new_location_access
|
55
|
+
(self.new_model? and not self.provider.start_with?("akamai_cupertino")) ? :read_write : :read
|
56
|
+
end
|
57
|
+
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
####> This code and all components © 2015 – 2019 Wowza Media Systems, LLC. All rights reserved.
|
2
|
+
####> This code is licensed pursuant to the BSD 3-Clause License.
|
3
|
+
|
4
|
+
module WscSdk
|
5
|
+
|
6
|
+
# Module that adds common functionality for an API response object.
|
7
|
+
#
|
8
|
+
module ApiResponse
|
9
|
+
|
10
|
+
# Determine if the response was a result of a successful API call.
|
11
|
+
#
|
12
|
+
# @return [Boolean]
|
13
|
+
# An indication of the success of the call.
|
14
|
+
#
|
15
|
+
def success?
|
16
|
+
if @success.nil?
|
17
|
+
@success = true
|
18
|
+
end
|
19
|
+
|
20
|
+
@success
|
21
|
+
end
|
22
|
+
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,44 @@
|
|
1
|
+
####> This code and all components © 2015 – 2019 Wowza Media Systems, LLC. All rights reserved.
|
2
|
+
####> This code is licensed pursuant to the BSD 3-Clause License.
|
3
|
+
|
4
|
+
module WscSdk
|
5
|
+
|
6
|
+
# A module that adds access to a logger.
|
7
|
+
#
|
8
|
+
# This will check to see if a Client object is available, and use its logger
|
9
|
+
# otherwise it checks for an endpoint and will use its logger, as a last ditch
|
10
|
+
# it will build a new plain old logger that logs to STDOUT.
|
11
|
+
#
|
12
|
+
# There is a logger attribute accessor, so you can overwrite the logger with
|
13
|
+
# your own.
|
14
|
+
#
|
15
|
+
module Loggable
|
16
|
+
|
17
|
+
# Returns an instance of a logger.
|
18
|
+
#
|
19
|
+
# @return [Logger]
|
20
|
+
# The assigned logger.
|
21
|
+
#
|
22
|
+
def logger
|
23
|
+
if @logger.nil?
|
24
|
+
if self.respond_to?(:client)
|
25
|
+
@logger = self.client.logger
|
26
|
+
elsif self.respond_to?(:endpoint)
|
27
|
+
@logger = self.endpoint.logger
|
28
|
+
end
|
29
|
+
|
30
|
+
@logger ||= Logger.new(STDOUT)
|
31
|
+
end
|
32
|
+
|
33
|
+
@logger
|
34
|
+
end
|
35
|
+
|
36
|
+
# Sets the instance of logger.
|
37
|
+
#
|
38
|
+
# @param _logger [Logger]
|
39
|
+
# The logger instance to use for logging.
|
40
|
+
def logger= _logger
|
41
|
+
@logger = _logger
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
@@ -0,0 +1,221 @@
|
|
1
|
+
####> This code and all components © 2015 – 2019 Wowza Media Systems, LLC. All rights reserved.
|
2
|
+
####> This code is licensed pursuant to the BSD 3-Clause License.
|
3
|
+
|
4
|
+
module WscSdk
|
5
|
+
|
6
|
+
# Module for providing methods to handle state actions and transitions for a
|
7
|
+
# Transcoder or Live Stream model, since they have a lot of shared
|
8
|
+
# functionality.
|
9
|
+
#
|
10
|
+
module TranscoderSharedMethods
|
11
|
+
|
12
|
+
#---------------------------------------------------------------------------
|
13
|
+
# _ _ _
|
14
|
+
# /_\ __| |_(_)___ _ _ ___
|
15
|
+
# / _ \/ _| _| / _ \ ' \(_-<
|
16
|
+
# /_/ \_\__|\__|_\___/_||_/__/
|
17
|
+
#
|
18
|
+
#---------------------------------------------------------------------------
|
19
|
+
|
20
|
+
|
21
|
+
# Start the transcoder/live stream
|
22
|
+
#
|
23
|
+
# If a block is passed to the call, the SDK will start a state request
|
24
|
+
# loop that checks the state of the transcoder for a given period of time
|
25
|
+
# (timeout). Each iteration of the wait loop will call the block with the
|
26
|
+
# current state of the wait loop, and the current state of the
|
27
|
+
# transcoder
|
28
|
+
#
|
29
|
+
# The wait state will be one of 3 options: :waiting, :complete or :timeout
|
30
|
+
#
|
31
|
+
# The loop will exit when the transcoder state is "started" or the timeout
|
32
|
+
# limit is reached.
|
33
|
+
#
|
34
|
+
# @param options [Hash] A hash of options
|
35
|
+
#
|
36
|
+
# @option options [Integer] :timeout (30) The maximum wait for a `started` state response.
|
37
|
+
# @option options [Integer] :poll_interval (5) The wait time (in seconds) between state requests. (Min: 1)
|
38
|
+
#
|
39
|
+
# @return [WscSdk::Model::TranscoderState] The transcoder state after the method execution has completed.
|
40
|
+
#
|
41
|
+
# @yield [wait_state, transcoder_state] Calls the block with the states of the wait loop and the transcoder.
|
42
|
+
# @yieldparam wait_state [Symbol] The current state of the wait loop. Will always be one of the following: :waiting, :complete, :cannot_change_state or :timeout
|
43
|
+
# @yieldparam transcoder_state [WscSdk::Model::TranscoderState] The current transcoder state data.
|
44
|
+
#
|
45
|
+
# @example Simple Start Request
|
46
|
+
# state = transcoder.start
|
47
|
+
#
|
48
|
+
# @example Start and Wait for Started
|
49
|
+
# transcoder.start do |wait_state, transcoder_state|
|
50
|
+
# if wait_state == :waiting
|
51
|
+
# puts "Waiting for the transcoder to start..."
|
52
|
+
# if wait_state == :timeout
|
53
|
+
# puts "The transcoder did not start in within the timeout period."
|
54
|
+
# else
|
55
|
+
# puts "Transcoder is #{state.state}. The IP Address is #{state.ip_address}."
|
56
|
+
# end
|
57
|
+
# end
|
58
|
+
#
|
59
|
+
def start(options={}, &block)
|
60
|
+
current_state = self.endpoint.start(self.id)
|
61
|
+
return wait_for_state(:started, options, &block) if current_state.success? and block_given?
|
62
|
+
return current_state
|
63
|
+
end
|
64
|
+
|
65
|
+
# Stop the transcoder
|
66
|
+
#
|
67
|
+
# If a block is passed to the call, the SDK will start a state request
|
68
|
+
# loop that checks the state of the transcoder for a given period of time
|
69
|
+
# (timeout). Each iteration of the wait loop will call the block with the
|
70
|
+
# current state of the wait loop, and the current state of the
|
71
|
+
# transcoder
|
72
|
+
#
|
73
|
+
# The wait state will be one of 3 options: :waiting, :complete or :timeout
|
74
|
+
#
|
75
|
+
# The loop will exit when the transcoder state is "stopped" or the timeout
|
76
|
+
# limit is reached.
|
77
|
+
#
|
78
|
+
# @param options [Hash] A hash of options
|
79
|
+
#
|
80
|
+
# @option options [Integer] :timeout (30) The maximum wait for a `stopped` state response.
|
81
|
+
# @option options [Integer] :poll_interval (5) The wait time (in seconds) between state requests. (Min: 1)
|
82
|
+
#
|
83
|
+
# @return [WscSdk::Model::TranscoderState] The transcoder state after the method execution has completed.
|
84
|
+
#
|
85
|
+
# @yield [wait_state, transcoder_state] Calls the block with the states of the wait loop and the transcoder.
|
86
|
+
# @yieldparam wait_state [Symbol] The current state of the wait loop. Will always be one of the following: :waiting, :complete, :cannot_change_state or :timeout
|
87
|
+
# @yieldparam transcoder_state [WscSdk::Model::TranscoderState] The current transcoder state data.
|
88
|
+
#
|
89
|
+
# @example Simple Stop Request
|
90
|
+
# state = transcoder.stop
|
91
|
+
#
|
92
|
+
# @example Stop and Wait for Stopped
|
93
|
+
# transcoder.stop do |wait_state, transcoder_state|
|
94
|
+
# if wait_state == :waiting
|
95
|
+
# puts "Waiting for the transcoder to stop..."
|
96
|
+
# if wait_state == :timeout
|
97
|
+
# puts "The transcoder did not stop in within the timeout period."
|
98
|
+
# else
|
99
|
+
# puts "Transcoder is #{state.state}."
|
100
|
+
# end
|
101
|
+
# end
|
102
|
+
#
|
103
|
+
def stop(options={}, &block)
|
104
|
+
current_state = self.endpoint.stop(self.id)
|
105
|
+
return wait_for_state(:stopped, options, &block) if current_state.success? and block_given?
|
106
|
+
return current_state
|
107
|
+
end
|
108
|
+
|
109
|
+
# Reset the transcoder/live stream
|
110
|
+
#
|
111
|
+
# If a block is passed to the call, the SDK will start a state request
|
112
|
+
# loop that checks the state of the transcoder for a given period of time
|
113
|
+
# (timeout). Each iteration of the wait loop will call the block with the
|
114
|
+
# current state of the wait loop, and the current state of the
|
115
|
+
# transcoder
|
116
|
+
#
|
117
|
+
# The wait state will be one of 3 options: :waiting, :complete or :timeout
|
118
|
+
#
|
119
|
+
# The loop will exit when the transcoder state is "started" or the timeout
|
120
|
+
# limit is reached.
|
121
|
+
#
|
122
|
+
# @param options [Hash] A hash of options
|
123
|
+
#
|
124
|
+
# @option options [Integer] :timeout (30) The maximum wait for a `started` state response.
|
125
|
+
# @option options [Integer] :poll_interval (5) The wait time (in seconds) between state requests. (Min: 1)
|
126
|
+
#
|
127
|
+
# @return [WscSdk::Model::TranscoderState] The transcoder state after the method execution has completed.
|
128
|
+
#
|
129
|
+
# @yield [wait_state, transcoder_state] Calls the block with the states of the wait loop and the transcoder.
|
130
|
+
# @yieldparam wait_state [Symbol] The current state of the wait loop. Will always be one of the following: :waiting, :complete, :cannot_change_state or :timeout
|
131
|
+
# @yieldparam transcoder_state [WscSdk::Model::TranscoderState] The current transcoder state data.
|
132
|
+
#
|
133
|
+
# @example Simple Reset Request
|
134
|
+
# state = transcoder.reset
|
135
|
+
#
|
136
|
+
# @example Reset and Wait for Started
|
137
|
+
# transcoder.reset do |wait_state, transcoder_state|
|
138
|
+
# if wait_state == :waiting
|
139
|
+
# puts "Waiting for the transcoder to start..."
|
140
|
+
# if wait_state == :timeout
|
141
|
+
# puts "The transcoder did not start in within the timeout period."
|
142
|
+
# else
|
143
|
+
# puts "Transcoder is #{state.state}. The IP Address is #{state.ip_address}."
|
144
|
+
# end
|
145
|
+
# end
|
146
|
+
#
|
147
|
+
def reset(options={}, &block)
|
148
|
+
current_state = self.endpoint.reset(self.id)
|
149
|
+
return wait_for_state(:started, options, &block) if current_state.success? and block_given?
|
150
|
+
return current_state
|
151
|
+
end
|
152
|
+
|
153
|
+
# Return the current state of the transcoder/live stream.
|
154
|
+
#
|
155
|
+
# @return [WscSdk::Model::TranscoderState]
|
156
|
+
#
|
157
|
+
def state
|
158
|
+
return self.endpoint.state(self.id)
|
159
|
+
end
|
160
|
+
|
161
|
+
|
162
|
+
# Return the url of the current thumbnail for transcoder/live stream.
|
163
|
+
#
|
164
|
+
# @return [WscSdk::Model::TranscoderThumbnailUrl]
|
165
|
+
#
|
166
|
+
def thumbnail_url
|
167
|
+
return self.endpoint.thumbnail_url(self.id)
|
168
|
+
end
|
169
|
+
|
170
|
+
# Return the url of the current stats for the transcoder/live stream.
|
171
|
+
#
|
172
|
+
# @return [WscSdk::Model::TranscoderStats]
|
173
|
+
#
|
174
|
+
def stats
|
175
|
+
return self.endpoint.stats(self.id)
|
176
|
+
end
|
177
|
+
|
178
|
+
# Wait for a given state to be returned from the API.
|
179
|
+
#
|
180
|
+
# @param state [Symbol] The name of the state we are expecting to be returned.
|
181
|
+
# @param options [Hash] A hash of options
|
182
|
+
#
|
183
|
+
# @option options [Integer] :timeout (120) The maximum wait (in seconds) for a `started` state response.
|
184
|
+
# @option options [Integer] :poll_interval (5) The wait time (in seconds) between state requests. (Min: 1)
|
185
|
+
#
|
186
|
+
# @return [Array<Symbol, WscSdk::Model::TranscoderState>] The `state` of the transcoder when the request is made or when the state request loop is complete.
|
187
|
+
#
|
188
|
+
# @yield [wait_state, state] Returns the state of the waiting loop and the state of the of the transcoder when the transcoder has started, or the timeout has been reached.
|
189
|
+
# @yieldparam result [Symbol] The result of waiting for the transcoder start. Returns either the current state of the transcoder, or :timeout if the wait timout was reached.
|
190
|
+
# @yieldparam state [WscSdk::Model::TranscoderState] The last transcoder state data before the start wait cycle was completed.
|
191
|
+
#
|
192
|
+
private def wait_for_state(state, options={}, block=Proc.new)
|
193
|
+
state = state.to_sym
|
194
|
+
first = true
|
195
|
+
timeout = options.fetch(:timeout, 120)
|
196
|
+
poll_interval = [options.fetch(:poll_interval, 5).to_i, 1].max
|
197
|
+
start = Time.now
|
198
|
+
elapsed = 0
|
199
|
+
wait_state = :waiting
|
200
|
+
current_state = nil
|
201
|
+
|
202
|
+
while((elapsed < timeout) and (wait_state == :waiting))
|
203
|
+
sleep(poll_interval) unless first # Don't sleep on the first iteration.
|
204
|
+
first = false
|
205
|
+
current_state = self.state
|
206
|
+
elapsed = Time.now - start
|
207
|
+
wait_state = :timeout if elapsed >= timeout
|
208
|
+
|
209
|
+
if current_state.success?
|
210
|
+
wait_state = :complete if current_state.state.to_sym == state.to_sym
|
211
|
+
else
|
212
|
+
wait_state = :cannot_change_state
|
213
|
+
end
|
214
|
+
block.call(wait_state, current_state)
|
215
|
+
end
|
216
|
+
result ||= :timeout
|
217
|
+
return current_state
|
218
|
+
end
|
219
|
+
|
220
|
+
end
|
221
|
+
end
|