mux_ruby 1.0.0 → 1.5.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (103) hide show
  1. checksums.yaml +5 -5
  2. data/Gemfile +2 -1
  3. data/Gemfile.lock +37 -35
  4. data/README.md +5 -0
  5. data/docs/Asset.md +2 -1
  6. data/docs/AssetsApi.md +157 -0
  7. data/docs/CreateAssetRequest.md +3 -1
  8. data/docs/CreateLiveStreamRequest.md +4 -0
  9. data/docs/CreateSimulcastTargetRequest.md +10 -0
  10. data/docs/CreateTrackRequest.md +14 -0
  11. data/docs/CreateTrackResponse.md +8 -0
  12. data/docs/CreateUploadRequest.md +1 -0
  13. data/docs/DeliveryReport.md +14 -0
  14. data/docs/DeliveryUsageApi.md +68 -0
  15. data/docs/GetMetricTimeseriesDataResponse.md +1 -1
  16. data/docs/GetOverallValuesResponse.md +1 -1
  17. data/docs/InputSettings.md +6 -1
  18. data/docs/InputTrack.md +0 -2
  19. data/docs/Insight.md +2 -2
  20. data/docs/ListAllMetricValuesResponse.md +1 -1
  21. data/docs/ListBreakdownValuesResponse.md +1 -1
  22. data/docs/ListDeliveryUsageResponse.md +11 -0
  23. data/docs/ListErrorsResponse.md +1 -1
  24. data/docs/ListExportsResponse.md +1 -1
  25. data/docs/ListFilterValuesResponse.md +1 -1
  26. data/docs/ListFiltersResponse.md +1 -1
  27. data/docs/ListInsightsResponse.md +1 -1
  28. data/docs/ListVideoViewsResponse.md +1 -1
  29. data/docs/LiveStream.md +3 -0
  30. data/docs/LiveStreamsApi.md +161 -0
  31. data/docs/SigningKeyResponse.md +1 -1
  32. data/docs/SimulcastTarget.md +12 -0
  33. data/docs/SimulcastTargetResponse.md +8 -0
  34. data/docs/Track.md +5 -2
  35. data/docs/UpdateAssetMasterAccessRequest.md +8 -0
  36. data/docs/Upload.md +1 -0
  37. data/docs/VideoViewResponse.md +1 -1
  38. data/examples/data/exercise-errors.rb +1 -1
  39. data/examples/data/exercise-metrics.rb +0 -7
  40. data/examples/video/exercise-assets.rb +27 -1
  41. data/examples/video/exercise-delivery-usage.rb +23 -0
  42. data/examples/video/exercise-live-streams.rb +28 -1
  43. data/lib/mux_ruby.rb +9 -0
  44. data/lib/mux_ruby/api/assets_api.rb +174 -0
  45. data/lib/mux_ruby/api/delivery_usage_api.rb +75 -0
  46. data/lib/mux_ruby/api/live_streams_api.rb +176 -0
  47. data/lib/mux_ruby/api_client.rb +7 -2
  48. data/lib/mux_ruby/api_error.rb +3 -0
  49. data/lib/mux_ruby/configuration.rb +1 -4
  50. data/lib/mux_ruby/models/asset.rb +24 -13
  51. data/lib/mux_ruby/models/create_asset_request.rb +46 -13
  52. data/lib/mux_ruby/models/create_live_stream_request.rb +66 -4
  53. data/lib/mux_ruby/models/create_simulcast_target_request.rb +210 -0
  54. data/lib/mux_ruby/models/create_track_request.rb +304 -0
  55. data/lib/mux_ruby/models/create_track_response.rb +184 -0
  56. data/lib/mux_ruby/models/create_upload_request.rb +13 -4
  57. data/lib/mux_ruby/models/delivery_report.rb +238 -0
  58. data/lib/mux_ruby/models/get_metric_timeseries_data_response.rb +1 -1
  59. data/lib/mux_ruby/models/get_overall_values_response.rb +1 -1
  60. data/lib/mux_ruby/models/input_settings.rb +104 -13
  61. data/lib/mux_ruby/models/input_settings_overlay_settings.rb +46 -0
  62. data/lib/mux_ruby/models/input_track.rb +4 -22
  63. data/lib/mux_ruby/models/insight.rb +2 -2
  64. data/lib/mux_ruby/models/list_all_metric_values_response.rb +1 -1
  65. data/lib/mux_ruby/models/list_breakdown_values_response.rb +1 -1
  66. data/lib/mux_ruby/models/list_delivery_usage_response.rb +216 -0
  67. data/lib/mux_ruby/models/list_errors_response.rb +1 -1
  68. data/lib/mux_ruby/models/list_exports_response.rb +1 -1
  69. data/lib/mux_ruby/models/list_filter_values_response.rb +1 -1
  70. data/lib/mux_ruby/models/list_filters_response.rb +1 -1
  71. data/lib/mux_ruby/models/list_insights_response.rb +1 -1
  72. data/lib/mux_ruby/models/list_video_views_response.rb +1 -1
  73. data/lib/mux_ruby/models/live_stream.rb +33 -4
  74. data/lib/mux_ruby/models/simulcast_target.rb +259 -0
  75. data/lib/mux_ruby/models/simulcast_target_response.rb +184 -0
  76. data/lib/mux_ruby/models/track.rb +86 -13
  77. data/lib/mux_ruby/models/update_asset_master_access_request.rb +219 -0
  78. data/lib/mux_ruby/models/upload.rb +13 -4
  79. data/lib/mux_ruby/models/video_view_response.rb +1 -1
  80. data/lib/mux_ruby/version.rb +1 -1
  81. data/spec/api/assets_api_spec.rb +37 -0
  82. data/spec/api/delivery_usage_api_spec.rb +43 -0
  83. data/spec/api/live_streams_api_spec.rb +39 -0
  84. data/spec/models/asset_spec.rb +12 -6
  85. data/spec/models/create_asset_request_spec.rb +22 -6
  86. data/spec/models/create_live_stream_request_spec.rb +24 -0
  87. data/spec/models/create_simulcast_target_request_spec.rb +46 -0
  88. data/spec/models/create_track_request_spec.rb +78 -0
  89. data/spec/models/create_track_response_spec.rb +34 -0
  90. data/spec/models/create_upload_request_spec.rb +6 -0
  91. data/spec/models/delivery_report_spec.rb +70 -0
  92. data/spec/models/input_settings_overlay_settings_spec.rb +8 -0
  93. data/spec/models/input_settings_spec.rb +40 -2
  94. data/spec/models/input_track_spec.rb +0 -12
  95. data/spec/models/list_delivery_usage_response_spec.rb +52 -0
  96. data/spec/models/live_stream_spec.rb +18 -0
  97. data/spec/models/simulcast_target_response_spec.rb +34 -0
  98. data/spec/models/simulcast_target_spec.rb +62 -0
  99. data/spec/models/track_spec.rb +28 -2
  100. data/spec/models/update_asset_master_access_request_spec.rb +38 -0
  101. data/spec/models/upload_spec.rb +6 -0
  102. data/test.sh +28 -0
  103. metadata +91 -54
@@ -69,7 +69,12 @@ module MuxRuby
69
69
  :response_headers => response.headers,
70
70
  :response_body => response.body),
71
71
  response.status_message
72
- elsif 500 <= response.code <= 599
72
+ elsif response.code == 429
73
+ fail TooManyRequestsError.new(:code => response.code,
74
+ :response_headers => response.headers,
75
+ :response_body => response.body),
76
+ response.status_message
77
+ elsif response.code.between?(500, 599)
73
78
  fail ServiceError.new(:code => response.code,
74
79
  :response_headers => response.headers,
75
80
  :response_body => response.body),
@@ -275,7 +280,7 @@ module MuxRuby
275
280
  def build_request_url(path)
276
281
  # Add leading and trailing slashes to path
277
282
  path = "/#{path}".gsub(/\/+/, '/')
278
- URI.encode(@config.base_url + path)
283
+ "#{@config.base_url}#{path}"
279
284
  end
280
285
 
281
286
  # Builds the HTTP request body
@@ -41,4 +41,7 @@ module MuxRuby
41
41
  class ServiceError < ApiError
42
42
  end
43
43
 
44
+ class TooManyRequestsError < ApiError
45
+ end
46
+
44
47
  end
@@ -3,8 +3,6 @@
3
3
  # NOTE: This file is auto generated. Do not edit this file manually.
4
4
  =end
5
5
 
6
- require 'uri'
7
-
8
6
  module MuxRuby
9
7
  class Configuration
10
8
  # Defines url scheme
@@ -167,8 +165,7 @@ module MuxRuby
167
165
  end
168
166
 
169
167
  def base_url
170
- url = "#{scheme}://#{[host, base_path].join('/').gsub(/\/+/, '/')}".sub(/\/+\z/, '')
171
- URI.encode(url)
168
+ "#{scheme}://#{[host, base_path].join('/').gsub(/\/+/, '/')}".sub(/\/+\z/, '')
172
169
  end
173
170
 
174
171
  # Gets API key (with prefix if set).
@@ -27,8 +27,6 @@ module MuxRuby
27
27
 
28
28
  attr_accessor :tracks
29
29
 
30
- attr_accessor :demo
31
-
32
30
  attr_accessor :errors
33
31
 
34
32
  attr_accessor :per_title_encode
@@ -45,8 +43,12 @@ module MuxRuby
45
43
 
46
44
  attr_accessor :mp4_support
47
45
 
46
+ attr_accessor :normalize_audio
47
+
48
48
  attr_accessor :static_renditions
49
49
 
50
+ attr_accessor :test
51
+
50
52
  class EnumAttributeValidator
51
53
  attr_reader :datatype
52
54
  attr_reader :allowable_values
@@ -82,7 +84,6 @@ module MuxRuby
82
84
  :'aspect_ratio' => :'aspect_ratio',
83
85
  :'playback_ids' => :'playback_ids',
84
86
  :'tracks' => :'tracks',
85
- :'demo' => :'demo',
86
87
  :'errors' => :'errors',
87
88
  :'per_title_encode' => :'per_title_encode',
88
89
  :'is_live' => :'is_live',
@@ -91,7 +92,9 @@ module MuxRuby
91
92
  :'master' => :'master',
92
93
  :'master_access' => :'master_access',
93
94
  :'mp4_support' => :'mp4_support',
94
- :'static_renditions' => :'static_renditions'
95
+ :'normalize_audio' => :'normalize_audio',
96
+ :'static_renditions' => :'static_renditions',
97
+ :'test' => :'test'
95
98
  }
96
99
  end
97
100
 
@@ -108,7 +111,6 @@ module MuxRuby
108
111
  :'aspect_ratio' => :'String',
109
112
  :'playback_ids' => :'Array<PlaybackID>',
110
113
  :'tracks' => :'Array<Track>',
111
- :'demo' => :'BOOLEAN',
112
114
  :'errors' => :'AssetErrors',
113
115
  :'per_title_encode' => :'BOOLEAN',
114
116
  :'is_live' => :'BOOLEAN',
@@ -117,7 +119,9 @@ module MuxRuby
117
119
  :'master' => :'AssetMaster',
118
120
  :'master_access' => :'String',
119
121
  :'mp4_support' => :'String',
120
- :'static_renditions' => :'AssetStaticRenditions'
122
+ :'normalize_audio' => :'BOOLEAN',
123
+ :'static_renditions' => :'AssetStaticRenditions',
124
+ :'test' => :'BOOLEAN'
121
125
  }
122
126
  end
123
127
 
@@ -173,10 +177,6 @@ module MuxRuby
173
177
  end
174
178
  end
175
179
 
176
- if attributes.has_key?(:'demo')
177
- self.demo = attributes[:'demo']
178
- end
179
-
180
180
  if attributes.has_key?(:'errors')
181
181
  self.errors = attributes[:'errors']
182
182
  end
@@ -213,9 +213,19 @@ module MuxRuby
213
213
  self.mp4_support = 'none'
214
214
  end
215
215
 
216
+ if attributes.has_key?(:'normalize_audio')
217
+ self.normalize_audio = attributes[:'normalize_audio']
218
+ else
219
+ self.normalize_audio = false
220
+ end
221
+
216
222
  if attributes.has_key?(:'static_renditions')
217
223
  self.static_renditions = attributes[:'static_renditions']
218
224
  end
225
+
226
+ if attributes.has_key?(:'test')
227
+ self.test = attributes[:'test']
228
+ end
219
229
  end
220
230
 
221
231
  # Show invalid properties with the reasons. Usually used together with valid?
@@ -270,7 +280,6 @@ module MuxRuby
270
280
  aspect_ratio == o.aspect_ratio &&
271
281
  playback_ids == o.playback_ids &&
272
282
  tracks == o.tracks &&
273
- demo == o.demo &&
274
283
  errors == o.errors &&
275
284
  per_title_encode == o.per_title_encode &&
276
285
  is_live == o.is_live &&
@@ -279,7 +288,9 @@ module MuxRuby
279
288
  master == o.master &&
280
289
  master_access == o.master_access &&
281
290
  mp4_support == o.mp4_support &&
282
- static_renditions == o.static_renditions
291
+ normalize_audio == o.normalize_audio &&
292
+ static_renditions == o.static_renditions &&
293
+ test == o.test
283
294
  end
284
295
 
285
296
  # @see the `==` method
@@ -291,7 +302,7 @@ module MuxRuby
291
302
  # Calculates hash code according to all attributes.
292
303
  # @return [Fixnum] Hash code
293
304
  def hash
294
- [id, created_at, deleted_at, status, duration, max_stored_resolution, max_stored_frame_rate, aspect_ratio, playback_ids, tracks, demo, errors, per_title_encode, is_live, passthrough, live_stream_id, master, master_access, mp4_support, static_renditions].hash
305
+ [id, created_at, deleted_at, status, duration, max_stored_resolution, max_stored_frame_rate, aspect_ratio, playback_ids, tracks, errors, per_title_encode, is_live, passthrough, live_stream_id, master, master_access, mp4_support, normalize_audio, static_renditions, test].hash
295
306
  end
296
307
 
297
308
  # Builds the object from hash
@@ -11,14 +11,19 @@ module MuxRuby
11
11
 
12
12
  attr_accessor :playback_policy
13
13
 
14
- attr_accessor :demo
15
-
16
14
  attr_accessor :per_title_encode
17
15
 
18
16
  attr_accessor :passthrough
19
17
 
20
18
  attr_accessor :mp4_support
21
19
 
20
+ # Normalize the audio track loudness level. This parameter is only applicable to on-demand (not live) assets.
21
+ attr_accessor :normalize_audio
22
+
23
+ attr_accessor :master_access
24
+
25
+ attr_accessor :test
26
+
22
27
  class EnumAttributeValidator
23
28
  attr_reader :datatype
24
29
  attr_reader :allowable_values
@@ -46,10 +51,12 @@ module MuxRuby
46
51
  {
47
52
  :'input' => :'input',
48
53
  :'playback_policy' => :'playback_policy',
49
- :'demo' => :'demo',
50
54
  :'per_title_encode' => :'per_title_encode',
51
55
  :'passthrough' => :'passthrough',
52
- :'mp4_support' => :'mp4_support'
56
+ :'mp4_support' => :'mp4_support',
57
+ :'normalize_audio' => :'normalize_audio',
58
+ :'master_access' => :'master_access',
59
+ :'test' => :'test'
53
60
  }
54
61
  end
55
62
 
@@ -58,10 +65,12 @@ module MuxRuby
58
65
  {
59
66
  :'input' => :'Array<InputSettings>',
60
67
  :'playback_policy' => :'Array<PlaybackPolicy>',
61
- :'demo' => :'BOOLEAN',
62
68
  :'per_title_encode' => :'BOOLEAN',
63
69
  :'passthrough' => :'String',
64
- :'mp4_support' => :'String'
70
+ :'mp4_support' => :'String',
71
+ :'normalize_audio' => :'BOOLEAN',
72
+ :'master_access' => :'String',
73
+ :'test' => :'BOOLEAN'
65
74
  }
66
75
  end
67
76
 
@@ -85,10 +94,6 @@ module MuxRuby
85
94
  end
86
95
  end
87
96
 
88
- if attributes.has_key?(:'demo')
89
- self.demo = attributes[:'demo']
90
- end
91
-
92
97
  if attributes.has_key?(:'per_title_encode')
93
98
  self.per_title_encode = attributes[:'per_title_encode']
94
99
  end
@@ -100,6 +105,20 @@ module MuxRuby
100
105
  if attributes.has_key?(:'mp4_support')
101
106
  self.mp4_support = attributes[:'mp4_support']
102
107
  end
108
+
109
+ if attributes.has_key?(:'normalize_audio')
110
+ self.normalize_audio = attributes[:'normalize_audio']
111
+ else
112
+ self.normalize_audio = false
113
+ end
114
+
115
+ if attributes.has_key?(:'master_access')
116
+ self.master_access = attributes[:'master_access']
117
+ end
118
+
119
+ if attributes.has_key?(:'test')
120
+ self.test = attributes[:'test']
121
+ end
103
122
  end
104
123
 
105
124
  # Show invalid properties with the reasons. Usually used together with valid?
@@ -114,6 +133,8 @@ module MuxRuby
114
133
  def valid?
115
134
  mp4_support_validator = EnumAttributeValidator.new('String', ['none', 'standard'])
116
135
  return false unless mp4_support_validator.valid?(@mp4_support)
136
+ master_access_validator = EnumAttributeValidator.new('String', ['none', 'temporary'])
137
+ return false unless master_access_validator.valid?(@master_access)
117
138
  true
118
139
  end
119
140
 
@@ -127,6 +148,16 @@ module MuxRuby
127
148
  @mp4_support = mp4_support
128
149
  end
129
150
 
151
+ # Custom attribute writer method checking allowed values (enum).
152
+ # @param [Object] master_access Object to be assigned
153
+ def master_access=(master_access)
154
+ validator = EnumAttributeValidator.new('String', ['none', 'temporary'])
155
+ unless validator.valid?(master_access)
156
+ fail ArgumentError, 'invalid value for "master_access", must be one of #{validator.allowable_values}.'
157
+ end
158
+ @master_access = master_access
159
+ end
160
+
130
161
  # Checks equality by comparing each attribute.
131
162
  # @param [Object] Object to be compared
132
163
  def ==(o)
@@ -134,10 +165,12 @@ module MuxRuby
134
165
  self.class == o.class &&
135
166
  input == o.input &&
136
167
  playback_policy == o.playback_policy &&
137
- demo == o.demo &&
138
168
  per_title_encode == o.per_title_encode &&
139
169
  passthrough == o.passthrough &&
140
- mp4_support == o.mp4_support
170
+ mp4_support == o.mp4_support &&
171
+ normalize_audio == o.normalize_audio &&
172
+ master_access == o.master_access &&
173
+ test == o.test
141
174
  end
142
175
 
143
176
  # @see the `==` method
@@ -149,7 +182,7 @@ module MuxRuby
149
182
  # Calculates hash code according to all attributes.
150
183
  # @return [Fixnum] Hash code
151
184
  def hash
152
- [input, playback_policy, demo, per_title_encode, passthrough, mp4_support].hash
185
+ [input, playback_policy, per_title_encode, passthrough, mp4_support, normalize_audio, master_access, test].hash
153
186
  end
154
187
 
155
188
  # Builds the object from hash
@@ -11,11 +11,25 @@ module MuxRuby
11
11
 
12
12
  attr_accessor :new_asset_settings
13
13
 
14
+ # When live streaming software disconnects from Mux, either intentionally or due to a drop in the network, the Reconnect Window is the time in seconds that Mux should wait for the streaming software to reconnect before considering the live stream finished and completing the recorded asset. Defaults to 60 seconds on the API if not specified.
15
+ attr_accessor :reconnect_window
16
+
17
+ attr_accessor :passthrough
18
+
19
+ # Latency is the time from when the streamer does something in real life to when you see it happen in the player. Set this if you want lower latency for your live stream. Note: Reconnect windows are incompatible with Reduced Latency and will always be set to zero (0) seconds. Read more here: https://mux.com/blog/reduced-latency-for-mux-live-streaming-now-available/
20
+ attr_accessor :reduced_latency
21
+
22
+ attr_accessor :test
23
+
14
24
  # Attribute mapping from ruby-style variable name to JSON key.
15
25
  def self.attribute_map
16
26
  {
17
27
  :'playback_policy' => :'playback_policy',
18
- :'new_asset_settings' => :'new_asset_settings'
28
+ :'new_asset_settings' => :'new_asset_settings',
29
+ :'reconnect_window' => :'reconnect_window',
30
+ :'passthrough' => :'passthrough',
31
+ :'reduced_latency' => :'reduced_latency',
32
+ :'test' => :'test'
19
33
  }
20
34
  end
21
35
 
@@ -23,7 +37,11 @@ module MuxRuby
23
37
  def self.openapi_types
24
38
  {
25
39
  :'playback_policy' => :'Array<PlaybackPolicy>',
26
- :'new_asset_settings' => :'CreateAssetRequest'
40
+ :'new_asset_settings' => :'CreateAssetRequest',
41
+ :'reconnect_window' => :'Float',
42
+ :'passthrough' => :'String',
43
+ :'reduced_latency' => :'BOOLEAN',
44
+ :'test' => :'BOOLEAN'
27
45
  }
28
46
  end
29
47
 
@@ -44,28 +62,72 @@ module MuxRuby
44
62
  if attributes.has_key?(:'new_asset_settings')
45
63
  self.new_asset_settings = attributes[:'new_asset_settings']
46
64
  end
65
+
66
+ if attributes.has_key?(:'reconnect_window')
67
+ self.reconnect_window = attributes[:'reconnect_window']
68
+ end
69
+
70
+ if attributes.has_key?(:'passthrough')
71
+ self.passthrough = attributes[:'passthrough']
72
+ end
73
+
74
+ if attributes.has_key?(:'reduced_latency')
75
+ self.reduced_latency = attributes[:'reduced_latency']
76
+ end
77
+
78
+ if attributes.has_key?(:'test')
79
+ self.test = attributes[:'test']
80
+ end
47
81
  end
48
82
 
49
83
  # Show invalid properties with the reasons. Usually used together with valid?
50
84
  # @return Array for valid properties with the reasons
51
85
  def list_invalid_properties
52
86
  invalid_properties = Array.new
87
+ if !@reconnect_window.nil? && @reconnect_window > 300
88
+ invalid_properties.push('invalid value for "reconnect_window", must be smaller than or equal to 300.')
89
+ end
90
+
91
+ if !@reconnect_window.nil? && @reconnect_window < 0.1
92
+ invalid_properties.push('invalid value for "reconnect_window", must be greater than or equal to 0.1.')
93
+ end
94
+
53
95
  invalid_properties
54
96
  end
55
97
 
56
98
  # Check to see if the all the properties in the model are valid
57
99
  # @return true if the model is valid
58
100
  def valid?
101
+ return false if !@reconnect_window.nil? && @reconnect_window > 300
102
+ return false if !@reconnect_window.nil? && @reconnect_window < 0.1
59
103
  true
60
104
  end
61
105
 
106
+ # Custom attribute writer method with validation
107
+ # @param [Object] reconnect_window Value to be assigned
108
+ def reconnect_window=(reconnect_window)
109
+ if !reconnect_window.nil? && reconnect_window > 300
110
+ fail ArgumentError, 'invalid value for "reconnect_window", must be smaller than or equal to 300.'
111
+ end
112
+
113
+ if !reconnect_window.nil? && reconnect_window < 0.1
114
+ fail ArgumentError, 'invalid value for "reconnect_window", must be greater than or equal to 0.1.'
115
+ end
116
+
117
+ @reconnect_window = reconnect_window
118
+ end
119
+
62
120
  # Checks equality by comparing each attribute.
63
121
  # @param [Object] Object to be compared
64
122
  def ==(o)
65
123
  return true if self.equal?(o)
66
124
  self.class == o.class &&
67
125
  playback_policy == o.playback_policy &&
68
- new_asset_settings == o.new_asset_settings
126
+ new_asset_settings == o.new_asset_settings &&
127
+ reconnect_window == o.reconnect_window &&
128
+ passthrough == o.passthrough &&
129
+ reduced_latency == o.reduced_latency &&
130
+ test == o.test
69
131
  end
70
132
 
71
133
  # @see the `==` method
@@ -77,7 +139,7 @@ module MuxRuby
77
139
  # Calculates hash code according to all attributes.
78
140
  # @return [Fixnum] Hash code
79
141
  def hash
80
- [playback_policy, new_asset_settings].hash
142
+ [playback_policy, new_asset_settings, reconnect_window, passthrough, reduced_latency, test].hash
81
143
  end
82
144
 
83
145
  # Builds the object from hash
@@ -0,0 +1,210 @@
1
+ =begin
2
+ # Mux Ruby - Copyright 2019 Mux Inc.
3
+ # NOTE: This file is auto generated. Do not edit this file manually.
4
+ =end
5
+
6
+ require 'date'
7
+
8
+ module MuxRuby
9
+ class CreateSimulcastTargetRequest
10
+ # Arbitrary metadata set by you when creating a simulcast target.
11
+ attr_accessor :passthrough
12
+
13
+ # Stream Key represents a stream identifier on the third party live streaming service to send the parent live stream to.
14
+ attr_accessor :stream_key
15
+
16
+ # RTMP hostname including application name for the third party live streaming service. Example: 'rtmp://live.example.com/app'.
17
+ attr_accessor :url
18
+
19
+ # Attribute mapping from ruby-style variable name to JSON key.
20
+ def self.attribute_map
21
+ {
22
+ :'passthrough' => :'passthrough',
23
+ :'stream_key' => :'stream_key',
24
+ :'url' => :'url'
25
+ }
26
+ end
27
+
28
+ # Attribute type mapping.
29
+ def self.openapi_types
30
+ {
31
+ :'passthrough' => :'String',
32
+ :'stream_key' => :'String',
33
+ :'url' => :'String'
34
+ }
35
+ end
36
+
37
+ # Initializes the object
38
+ # @param [Hash] attributes Model attributes in the form of hash
39
+ def initialize(attributes = {})
40
+ return unless attributes.is_a?(Hash)
41
+
42
+ # convert string to symbol for hash key
43
+ attributes = attributes.each_with_object({}) { |(k, v), h| h[k.to_sym] = v }
44
+
45
+ if attributes.has_key?(:'passthrough')
46
+ self.passthrough = attributes[:'passthrough']
47
+ end
48
+
49
+ if attributes.has_key?(:'stream_key')
50
+ self.stream_key = attributes[:'stream_key']
51
+ end
52
+
53
+ if attributes.has_key?(:'url')
54
+ self.url = attributes[:'url']
55
+ end
56
+ end
57
+
58
+ # Show invalid properties with the reasons. Usually used together with valid?
59
+ # @return Array for valid properties with the reasons
60
+ def list_invalid_properties
61
+ invalid_properties = Array.new
62
+ if @url.nil?
63
+ invalid_properties.push('invalid value for "url", url cannot be nil.')
64
+ end
65
+
66
+ invalid_properties
67
+ end
68
+
69
+ # Check to see if the all the properties in the model are valid
70
+ # @return true if the model is valid
71
+ def valid?
72
+ return false if @url.nil?
73
+ true
74
+ end
75
+
76
+ # Checks equality by comparing each attribute.
77
+ # @param [Object] Object to be compared
78
+ def ==(o)
79
+ return true if self.equal?(o)
80
+ self.class == o.class &&
81
+ passthrough == o.passthrough &&
82
+ stream_key == o.stream_key &&
83
+ url == o.url
84
+ end
85
+
86
+ # @see the `==` method
87
+ # @param [Object] Object to be compared
88
+ def eql?(o)
89
+ self == o
90
+ end
91
+
92
+ # Calculates hash code according to all attributes.
93
+ # @return [Fixnum] Hash code
94
+ def hash
95
+ [passthrough, stream_key, url].hash
96
+ end
97
+
98
+ # Builds the object from hash
99
+ # @param [Hash] attributes Model attributes in the form of hash
100
+ # @return [Object] Returns the model itself
101
+ def self.build_from_hash(attributes)
102
+ new.build_from_hash(attributes)
103
+ end
104
+
105
+ # Builds the object from hash
106
+ # @param [Hash] attributes Model attributes in the form of hash
107
+ # @return [Object] Returns the model itself
108
+ def build_from_hash(attributes)
109
+ return nil unless attributes.is_a?(Hash)
110
+ self.class.openapi_types.each_pair do |key, type|
111
+ if type =~ /\AArray<(.*)>/i
112
+ # check to ensure the input is an array given that the attribute
113
+ # is documented as an array but the input is not
114
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
115
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
116
+ end
117
+ elsif !attributes[self.class.attribute_map[key]].nil?
118
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
119
+ end # or else data not found in attributes(hash), not an issue as the data can be optional
120
+ end
121
+
122
+ self
123
+ end
124
+
125
+ # Deserializes the data based on type
126
+ # @param string type Data type
127
+ # @param string value Value to be deserialized
128
+ # @return [Object] Deserialized data
129
+ def _deserialize(type, value)
130
+ case type.to_sym
131
+ when :DateTime
132
+ DateTime.parse(value)
133
+ when :Date
134
+ Date.parse(value)
135
+ when :String
136
+ value.to_s
137
+ when :Integer
138
+ value.to_i
139
+ when :Float
140
+ value.to_f
141
+ when :BOOLEAN
142
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
143
+ true
144
+ else
145
+ false
146
+ end
147
+ when :Object
148
+ # generic object (usually a Hash), return directly
149
+ value
150
+ when /\AArray<(?<inner_type>.+)>\z/
151
+ inner_type = Regexp.last_match[:inner_type]
152
+ value.map { |v| _deserialize(inner_type, v) }
153
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
154
+ k_type = Regexp.last_match[:k_type]
155
+ v_type = Regexp.last_match[:v_type]
156
+ {}.tap do |hash|
157
+ value.each do |k, v|
158
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
159
+ end
160
+ end
161
+ else # model
162
+ MuxRuby.const_get(type).build_from_hash(value)
163
+ end
164
+ end
165
+
166
+ # Returns the string representation of the object
167
+ # @return [String] String presentation of the object
168
+ def to_s
169
+ to_hash.to_s
170
+ end
171
+
172
+ # to_body is an alias to to_hash (backward compatibility)
173
+ # @return [Hash] Returns the object in the form of hash
174
+ def to_body
175
+ to_hash
176
+ end
177
+
178
+ # Returns the object in the form of hash
179
+ # @return [Hash] Returns the object in the form of hash
180
+ def to_hash
181
+ hash = {}
182
+ self.class.attribute_map.each_pair do |attr, param|
183
+ value = self.send(attr)
184
+ next if value.nil?
185
+ hash[param] = _to_hash(value)
186
+ end
187
+ hash
188
+ end
189
+
190
+ # Outputs non-array value in the form of hash
191
+ # For object, use to_hash. Otherwise, just return the value
192
+ # @param [Object] value Any valid value
193
+ # @return [Hash] Returns the value in the form of hash
194
+ def _to_hash(value)
195
+ if value.is_a?(Array)
196
+ value.compact.map { |v| _to_hash(v) }
197
+ elsif value.is_a?(Hash)
198
+ {}.tap do |hash|
199
+ value.each { |k, v| hash[k] = _to_hash(v) }
200
+ end
201
+ elsif value.respond_to? :to_hash
202
+ value.to_hash
203
+ else
204
+ value
205
+ end
206
+ end
207
+
208
+ end
209
+
210
+ end