ubiquity-vdms 1.0.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
+ SHA256:
3
+ metadata.gz: a4a0f565b003c38872efd7383dbb1776a0e3d816cdc9cd6dda87439c122c15f5
4
+ data.tar.gz: fe5016b6d9936f6d82362c9c50dcb1ba2e8063385c358e8072742eeb6d9beafa
5
+ SHA512:
6
+ metadata.gz: 3d32fafe3d91d674f4c56876cd1f15d95dcdc7e4cac77a10d3ea58953dc0cf6dd9a7f3953fc8c0bab22b1e15d61461f633f8d8aa7ee1c676404de4d5917c5590
7
+ data.tar.gz: dcdb7b6d99921f27dad2b6b7507880d7aaddc394fd6780d7c7dbf9ebdb0018cf575b78543a9a849efd133a0f6ce201966f62407bcf55cf739a0828b3066a43fd
@@ -0,0 +1,10 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /dev/
7
+ /doc/
8
+ /pkg/
9
+ /spec/reports/
10
+ /tmp/
@@ -0,0 +1,5 @@
1
+ sudo: false
2
+ language: ruby
3
+ rvm:
4
+ - 1.8.7
5
+ before_install: gem install bundler -v 1.14.5
data/Gemfile ADDED
@@ -0,0 +1,6 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gem 'json', '~> 1.8', :platforms => :mri_18
4
+
5
+ # Specify your gem's dependencies in ubiquity-vdms.gemspec
6
+ gemspec
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2017 TODO: Write your name
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,41 @@
1
+ # Ubiquity::VDMS
2
+
3
+ Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/ubiquity/vdms`. To experiment with that code, run `bin/console` for an interactive prompt.
4
+
5
+ TODO: Delete this and the text above, and describe your gem
6
+
7
+ ## Installation
8
+
9
+ Add this line to your application's Gemfile:
10
+
11
+ ```ruby
12
+ gem 'ubiquity-vdms'
13
+ ```
14
+
15
+ And then execute:
16
+
17
+ $ bundle
18
+
19
+ Or install it yourself as:
20
+
21
+ $ gem install ubiquity-vdms
22
+
23
+ ## Usage
24
+
25
+ TODO: Write usage instructions here
26
+
27
+ ## Development
28
+
29
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
30
+
31
+ 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).
32
+
33
+ ## Contributing
34
+
35
+ Bug reports and pull requests are welcome on GitHub at https://github.com/XPlatform-Consulting/ubiquity-vdms.
36
+
37
+
38
+ ## License
39
+
40
+ The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
41
+
@@ -0,0 +1,10 @@
1
+ require "bundler/gem_tasks"
2
+ require "rake/testtask"
3
+
4
+ Rake::TestTask.new(:test) do |t|
5
+ t.libs << "test"
6
+ t.libs << "lib"
7
+ t.test_files = FileList['test/**/*_test.rb']
8
+ end
9
+
10
+ task :default => :test
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "ubiquity/vdms"
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
+ require "irb"
14
+ IRB.start(__FILE__)
@@ -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,3 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'ubiquity/vdms'
@@ -0,0 +1,7 @@
1
+ require 'ubiquity/vdms/version'
2
+
3
+ module Ubiquity
4
+ module VDMS
5
+
6
+ end
7
+ end
@@ -0,0 +1,199 @@
1
+ require 'base64'
2
+ require 'cgi'
3
+ require 'json'
4
+ require 'logger'
5
+ require 'openssl'
6
+ require 'uri'
7
+ require 'zlib'
8
+
9
+ require 'ubiquity/vdms/uplynk/api/client/http_client'
10
+
11
+ module Ubiquity
12
+
13
+ module VDMS
14
+
15
+ module Uplynk
16
+
17
+ module API
18
+
19
+ class Client
20
+
21
+ attr_accessor :http_client, :request, :response, :logger
22
+
23
+ attr_accessor :owner, :secret
24
+
25
+ def initialize(args = { })
26
+ @http_client = HTTPClient.new(args)
27
+
28
+ @owner = args[:owner] || args[:username]
29
+ @secret = args[:secret] || args[:password]
30
+
31
+ @logger = http_client.logger
32
+ end
33
+
34
+ def message_encode(msg, _owner = owner)
35
+ msg['_owner'] = _owner
36
+ msg['_timestamp'] = Time.now.to_i
37
+ msg = JSON.generate(msg)
38
+
39
+ msg = Zlib::Deflate.deflate(msg, 9)
40
+ msg = Base64.encode64(msg).strip
41
+
42
+ msg
43
+ end
44
+
45
+ def signature_generate(encoded_msg, _secret = secret)
46
+ OpenSSL::HMAC.hexdigest('sha256', _secret, encoded_msg)
47
+ end
48
+
49
+ def encode_body(body)
50
+ msg = message_encode(body)
51
+ sig = signature_generate(msg)
52
+ _body = "msg=#{CGI.escape(msg)}&sig=#{CGI.escape(sig)}"
53
+ end
54
+
55
+ def post(path, body = { }, opts = { })
56
+ _body = encode_body(body)
57
+ http_client.post(path, _body, opts)
58
+ end
59
+
60
+ # Retrieves a specific asset from your library.
61
+ # @see https://support.uplynk.com/doc_integration_apis_asset.html
62
+ #
63
+ # Request parameters
64
+ # +--------------+--------+-------------------------------------------------------------------------------+
65
+ # | id | string | (optional*) the asset's ID |
66
+ # | external_id | string | (optional*) the asset's external ID |
67
+ # | ids | list | (optional*) a list of assets' IDs to be returned as a list of assets |
68
+ # | external_ids | list | (optional*) a list of assets' external IDs to be returned as a list of assets |
69
+ # +--------------+--------+-------------------------------------------------------------------------------+
70
+ # * One of id, external_id, ids, external_ids must be specified.
71
+ #
72
+ # @param [Hash] args
73
+ # @option args [String] id
74
+ # @option args [String] external_id
75
+ # @option args [<Array>String] ids
76
+ # @option args [<Array>String] external_ids
77
+ #
78
+ # @param [Hash] opts
79
+ #
80
+ # @return [Hash]
81
+ def asset_get(args = { }, opts = { })
82
+ post('asset/get', args, opts)
83
+ end
84
+
85
+ # Returns a base64 representation of the specified frame from the highest bitrate variant of the specified asset.
86
+ #
87
+ # Request parameters
88
+ # +----+------------+-------------------------------------------------------------------------------------------------------------------+
89
+ # | id | int | ID of the asset from which to grab a frame |
90
+ # | ts | int/string | Timestamp of the frame to grab. Specify in milliseconds as an integer, or as a string in the 'hh:mm:ss.ms' format |
91
+ # +----+------------+-------------------------------------------------------------------------------------------------------------------+
92
+ #
93
+ # Response parameters
94
+ #
95
+ # @param [Hash] args
96
+ # @param [Hash] opts
97
+ # @return [Hash]
98
+ def asset_getframe(args = { }, opts = { })
99
+
100
+ end
101
+ alias :asset_get_frame :asset_getframe
102
+
103
+ # Lists or searches for assets.
104
+ #
105
+ # Request parameters
106
+ # +--------+---------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
107
+ # | search | string | (optional) Text to search for in the asset's description, ID, or external ID. |
108
+ # | limit | integer | (optional) Cap the number of items returned, maximum of 100 items. |
109
+ # | skip | integer | (optional) Skip the first N results. The skip and limit parameters can be used together for paginated results. |
110
+ # | order | string | (optional) Sort the results by the given field. Supported fields include: desc, created, lastmod, duration, state, and external_id. Prefix the sort field with a minus sign for descending order (e.g. order='-desc' to retrieve values in reverse alphabetical order) |
111
+ # +--------+---------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
112
+ #
113
+ # Response parameters
114
+ # +--------+------+----------------------------------------------------------------------+
115
+ # | assets | list | A list of assets, where each matches the form returned by asset/get. |
116
+ # +--------+------+----------------------------------------------------------------------+
117
+ #
118
+ # @param [Hash] args
119
+ # @param [Hash] opts
120
+ # @return [Hash]
121
+ def asset_list(args = { }, opts = { })
122
+ post('asset/list', args, opts)
123
+ end
124
+
125
+ # Modifies an asset in your library.
126
+ #
127
+ # Request parameters
128
+ # +------------------+--------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
129
+ # | id | string | (optional*) the ID of the asset to modify |
130
+ # | external_id | string | (optional*) A new external_id for the asset. Note: if you retrieved the asset by external ID, you cannot also update the external ID at the same time. |
131
+ # | desc | string | (optional) A description for the asset |
132
+ # | test_player_url | any | (optional) Specifying any value for this parameter will cause a new test player URL to be generated. Note that this does not expire any existing test players; it adds a new test player to the list of test players. To expire a test player please use the CMS web interface. |
133
+ # | embed_player_url | any | (optional) Specifying any value for this parameter will cause a new embed player URL to be generated. |
134
+ # | require_drm | int | (optional) Specify a 1 to enable required tokens. Specify a 0 to disable required tokens. |
135
+ # | meta | string | (optional) The metadata to set on the asset. This must be a dictionary in JSON format. If the asset has existing meta, any new meta will be merged. To clear all metadata, set to '{}'. |
136
+ # | poster_img | string | (optional) The image to be used for this asset's poster image, as a base64-encoded string. Limited to images that are smaller than 3MB before base64 encoding. To reset the asset's poster image, set to the empty string ''. |
137
+ # | autoexpire | string | (optional) A timestamp in milliseconds after which the asset will be deleted automatically. Use a value of 0 to indicate that the asset should not auto-expire. |
138
+ # +------------------+--------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
139
+ # * Either id or external_id must be specified.
140
+ #
141
+ # @param [Hash] args
142
+ # @param [Hash] opts
143
+ # @return [Hash]
144
+ def asset_update(args = { }, opts = { })
145
+ post('asset/update')
146
+ end
147
+
148
+
149
+
150
+ # @see https://support.uplynk.com/doc_integration_apis_cloudslicer.html#jobscancel
151
+ def cloudslicer_job_cancel(args = { }, opts = { })
152
+ post('cloudslicer/jobs/cancel', args, opts)
153
+ end
154
+
155
+ # @see https://support.uplynk.com/doc_integration_apis_cloudslicer.html#jobscreate
156
+ def cloudslicer_job_create(args = { }, opts = { })
157
+ post('cloudslicer/jobs/create', args, opts)
158
+ end
159
+
160
+ # @see https://support.uplynk.com/doc_integration_apis_cloudslicer.html#jobsdelete
161
+ def cloudslicer_job_delete(args, opts)
162
+ post('cloudslicer/jobs/delete', args, opts)
163
+ end
164
+
165
+ # @see https://support.uplynk.com/doc_integration_apis_cloudslicer.html#jobscexport
166
+ def cloudslicer_job_export_create(args = { }, opts = { })
167
+ post('cloudslicer/jobs/create_export', args, opts)
168
+ end
169
+
170
+ # @see https://support.uplynk.com/doc_integration_apis_cloudslicer.html#jobsget
171
+ def cloudslicer_job_get(args = { }, opts = { })
172
+ post('cloudslicer/jobs/get', args, opts)
173
+ end
174
+
175
+ # @see https://support.uplynk.com/doc_integration_apis_cloudslicer.html#jobsqc
176
+ def cloudslicer_job_quickclip_create(args = { }, opts = { })
177
+ post('cloudslicer/jobs/quickclip', args, opts)
178
+ end
179
+
180
+ # @see https://support.uplynk.com/doc_integration_apis_cloudslicer.html#jobslist
181
+ def cloudslicer_jobs_list(args = { }, opts = { })
182
+ post('cloudslicer/jobs/list', args, opts)
183
+ end
184
+
185
+ # Client
186
+ end
187
+
188
+ # API
189
+ end
190
+
191
+ # Uplynk
192
+ end
193
+
194
+
195
+ # VDMS
196
+ end
197
+
198
+ # Ubiquity
199
+ end
@@ -0,0 +1,312 @@
1
+ require 'json'
2
+ require 'net/http'
3
+
4
+ class Net::HTTP::GetWithBody < Net::HTTPRequest
5
+ METHOD = 'GET'
6
+ REQUEST_HAS_BODY = true
7
+ RESPONSE_HAS_BODY = true
8
+ end
9
+
10
+
11
+ module Ubiquity
12
+
13
+ module VDMS
14
+
15
+ module Uplynk
16
+
17
+ module API
18
+ class Client
19
+
20
+ class HTTPClient
21
+
22
+ class HTTPAuthorizationError < RuntimeError;
23
+ end
24
+
25
+ attr_accessor :logger, :http, :http_host_address, :http_host_port, :base_uri
26
+ attr_accessor :username, :password
27
+
28
+ attr_accessor :default_request_headers,
29
+ :authorization_header_key, :authorization_header_value
30
+
31
+ attr_accessor :log_request_body, :log_response_body, :log_pretty_print_body
32
+
33
+ attr_accessor :request, :response, :use_exceptions
34
+
35
+ DEFAULT_HTTP_HOST_ADDRESS = 'services.uplynk.com'
36
+ DEFAULT_HTTP_HOST_PORT = 80
37
+
38
+ DEFAULT_BASE_PATH = '/api2/'
39
+
40
+ DEFAULT_HEADER_CONTENT_TYPE = 'application/x-www-form-urlencoded'
41
+ DEFAULT_HEADER_ACCEPTS = 'application/json'
42
+
43
+ def initialize(args = {})
44
+ args = args.dup
45
+
46
+ @use_exceptions = args.fetch(:use_exceptions, true)
47
+
48
+ initialize_logger(args)
49
+ initialize_http(args)
50
+
51
+ logger.debug { "#{self.class.name}::#{__method__} Arguments: #{args.inspect}" }
52
+
53
+ @username = args[:username] || args[:owner]
54
+ @password = args[:password] || args[:secret]
55
+
56
+ @base_uri = args[:base_uri] || "http#{http.use_ssl? ? 's' : ''}://#{http.address}:#{http.port}"
57
+ @default_base_path = args[:default_base_path] || DEFAULT_BASE_PATH
58
+
59
+ # @user_agent_default = "#{@hostname}:#{@username} Ruby SDK Version #{Vidispine::VERSION}"
60
+
61
+ @authorization_header_key ||= 'Authorization' #CaseSensitiveHeaderKey.new('Authorization')
62
+ @authorization_header_value ||= %(Basic #{["#{username}:#{password}"].pack('m').delete("\r\n")})
63
+
64
+ content_type = args[:content_type_header] ||= DEFAULT_HEADER_CONTENT_TYPE
65
+ accepts = args[:accepts_header] ||= args[:accept_header] || DEFAULT_HEADER_ACCEPTS
66
+
67
+ @default_request_headers = {
68
+ 'Content-Type' => content_type,
69
+ 'Accept' => accepts,
70
+ }
71
+
72
+ @log_request_body = args.fetch(:log_request_body, true)
73
+ @log_response_body = args.fetch(:log_response_body, true)
74
+ @log_pretty_print_body = args.fetch(:log_pretty_print_body, true)
75
+
76
+ @parse_response = args.fetch(:parse_response, true)
77
+ end
78
+
79
+ def initialize_logger(args = {})
80
+ @logger = args[:logger] ||= Logger.new(args[:log_to] || STDOUT)
81
+ log_level = args[:log_level]
82
+ if log_level
83
+ @logger.level = log_level
84
+ args[:logger] = @logger
85
+ end
86
+ @logger
87
+ end
88
+
89
+ def initialize_http(args = {})
90
+ @http_host_address = args[:http_host_address] ||= DEFAULT_HTTP_HOST_ADDRESS
91
+ @http_host_port = args[:http_host_port] ||= DEFAULT_HTTP_HOST_PORT
92
+ @http = Net::HTTP.new(http_host_address, http_host_port)
93
+
94
+ use_ssl = args[:http_host_use_ssl]
95
+ if use_ssl
96
+ @http.use_ssl = true
97
+ http_verify_mode = args[:http_host_ssl_verify_mode] #|| OpenSSL::SSL::VERIFY_NONE
98
+ @http.verify_mode = http_verify_mode if http_verify_mode
99
+ end
100
+
101
+ http
102
+ end
103
+
104
+ # Formats a HTTPRequest or HTTPResponse body for log output.
105
+ # @param [HTTPRequest|HTTPResponse] obj
106
+ # @return [String]
107
+ def format_body_for_log_output(obj)
108
+ if obj.content_type == 'application/json'
109
+ if @log_pretty_print_body
110
+ _body = obj.body
111
+ output = JSON.pretty_generate(JSON.parse(_body)) rescue _body
112
+ return output
113
+ else
114
+ return obj.body
115
+ end
116
+ elsif obj.content_type == 'application/xml'
117
+ return obj.body
118
+ else
119
+ return obj.body.inspect
120
+ end
121
+ end
122
+
123
+ # @param [HTTPRequest] request
124
+ def send_request(request)
125
+ @response_parsed = nil
126
+ @request = request
127
+ logger.debug { %(REQUEST: #{request.method} http#{http.use_ssl? ? 's' : ''}://#{http.address}:#{http.port}#{request.path} HEADERS: #{request.to_hash.inspect} #{log_request_body and request.request_body_permitted? ? "\n-- BODY BEGIN --\n#{format_body_for_log_output(request)}\n-- BODY END --" : ''}) }
128
+
129
+ @request_time_start = Time.now
130
+ @response = http.request(request)
131
+ @request_time_end = Time.now
132
+ logger.debug { %(RESPONSE: #{response.inspect} HEADERS: #{response.to_hash.inspect} #{log_response_body and response.respond_to?(:body) ? "\n-- BODY BEGIN --\n#{format_body_for_log_output(response)}\n-- BODY END--" : ''}\nTook: #{@request_time_end - @request_time_start} seconds) }
133
+ #logger.debug { "Parse Response? #{@parse_response}" }
134
+
135
+ raise HTTPAuthorizationError if @use_exceptions && @response.code == '401'
136
+
137
+ @parse_response ? response_parsed : response.body
138
+ end
139
+
140
+ def response_parsed
141
+ @response_parsed ||= begin
142
+ response_body = response.respond_to?(:body) ? response.body : ''
143
+ logger.debug { "Parsing Response. #{response_body.inspect}" }
144
+
145
+ case response.content_type
146
+ when 'application/json'
147
+ response_body.empty? ? response_body : JSON.parse(response_body) # rescue response
148
+ else
149
+ response_body
150
+ end
151
+ end
152
+ end
153
+
154
+ # @param [String] path
155
+ # @param [Hash|String|Nil] query
156
+ # @return [URI]
157
+ def build_uri(path = '', query = nil)
158
+ _query = query.is_a?(Hash) ? query.map { |k, v| "#{CGI.escape(k.to_s)}=#{CGI.escape(v.respond_to?(:to_s) ? v.to_s : v)}" }.join('&') : query
159
+ _path = "#{path}#{_query and _query.respond_to?(:empty?) and !_query.empty? ? "?#{_query}" : ''}"
160
+ URI.parse(File.join(base_uri, _path))
161
+ end
162
+
163
+ if RUBY_VERSION.start_with? '1.8.'
164
+ def request_method_name_to_class_name(method_name)
165
+ method_name.to_s.capitalize
166
+ end
167
+ else
168
+ def request_method_name_to_class_name(method_name)
169
+ method_name.to_s.capitalize.to_sym
170
+ end
171
+ end
172
+
173
+ # @param [Symbol] method_name (:get)
174
+ # @param [Hash] args
175
+ # @option args [Hash] :headers ({})
176
+ # @option args [String] :path ('')
177
+ # @option args [Hash] :query ({})
178
+ # @option args [Any] :body (nil)
179
+ # @param [Hash] options
180
+ # @option options [Hash] :default_request_headers (@default_request_headers)
181
+ def call_method(method_name = :get, args = {}, options = {})
182
+ headers = args[:headers] || options[:headers] || {}
183
+ path = args[:path] || ''
184
+ query = args[:query] || {}
185
+ body = args[:body]
186
+
187
+ # Allow the default request headers to be overridden
188
+ _default_request_headers = options.fetch(:default_request_headers, default_request_headers)
189
+ _default_request_headers ||= {}
190
+ _headers = _default_request_headers.merge(headers)
191
+
192
+ @uri = build_uri(path, query)
193
+ klass_name = request_method_name_to_class_name(method_name)
194
+ klass_name = :GetWithBody if klass_name == :GET || klass_name == 'GET'
195
+ klass = Net::HTTP.const_get(klass_name)
196
+
197
+ request = klass.new(@uri.request_uri, _headers)
198
+
199
+ if request.request_body_permitted?
200
+ _body = (body and !body.is_a?(String)) ? JSON.generate(body) : body
201
+ logger.debug { "Processing Body: '#{_body}'" }
202
+ request.body = _body if _body
203
+ end
204
+
205
+ send_request(request)
206
+ end
207
+
208
+ def delete(path, options = {})
209
+ query = options.fetch(:query, {})
210
+ base_path = options[:base_path] || (path.start_with?(DEFAULT_BASE_PATH) ? '' : @default_base_path)
211
+ @uri = build_uri(File.join(base_path, path), query)
212
+ request = Net::HTTP::Delete.new(@uri.request_uri, default_request_headers)
213
+ send_request(request)
214
+ end
215
+
216
+ def get(path, body, options = {})
217
+ # Allow the default request headers to be overridden
218
+ headers = options[:headers] || {}
219
+ _default_request_headers = options.fetch(:default_request_headers, default_request_headers) || {}
220
+ _headers = _default_request_headers.merge(headers)
221
+
222
+ query ||= options.fetch(:query, {})
223
+ base_path = options[:base_path] || (path.start_with?(DEFAULT_BASE_PATH) ? '' : @default_base_path)
224
+ @uri = build_uri(File.join(base_path, path), query)
225
+ request = Net::HTTP::GetWithBody.new(@uri.request_uri, _headers)
226
+
227
+ body = JSON.generate(body) if body and !body.is_a?(String)
228
+
229
+ request.body = body if body
230
+
231
+ send_request(request)
232
+ end
233
+
234
+ def head(path, options = {})
235
+ # Allow the default request headers to be overridden
236
+ headers = options[:headers] || {}
237
+ _default_request_headers = options.fetch(:default_request_headers, default_request_headers) || {}
238
+ _headers = _default_request_headers.merge(headers)
239
+
240
+ query ||= options.fetch(:query, {})
241
+ base_path = options[:base_path] || (path.start_with?(DEFAULT_BASE_PATH) ? '' : @default_base_path)
242
+ @uri = build_uri(File.join(base_path, path), query)
243
+
244
+ request = Net::HTTP::Head.new(@uri.request_uri, _headers)
245
+ send_request(request)
246
+ end
247
+
248
+ def options(path, options = {})
249
+ # Allow the default request headers to be overridden
250
+ headers = options[:headers] || {}
251
+ _default_request_headers = options.fetch(:default_request_headers, default_request_headers) || {}
252
+ _headers = _default_request_headers.merge(headers)
253
+
254
+ query ||= options.fetch(:query, {})
255
+ base_path = options[:base_path] || (path.start_with?(DEFAULT_BASE_PATH) ? '' : @default_base_path)
256
+ @uri = build_uri(File.join(base_path, path), query)
257
+ request = Net::HTTP::Options.new(@uri.request_uri, _headers)
258
+ send_request(request)
259
+ end
260
+
261
+ def put(path, body, options = {})
262
+ # Allow the default request headers to be overridden
263
+ headers = options[:headers] || {}
264
+ _default_request_headers = options.fetch(:default_request_headers, default_request_headers) || {}
265
+ _headers = _default_request_headers.merge(headers)
266
+
267
+ query = options.fetch(:query, {})
268
+ base_path = options[:base_path] || (path.start_with?(DEFAULT_BASE_PATH) ? '' : @default_base_path)
269
+ @uri = build_uri(File.join(base_path, path), query)
270
+ request = Net::HTTP::Put.new(@uri.request_uri, _headers)
271
+
272
+ body = JSON.generate(body) if body and !body.is_a?(String)
273
+
274
+ request.body = body if body
275
+ send_request(request)
276
+ end
277
+
278
+ def post(path, body, options = {})
279
+ # Allow the default request headers to be overridden
280
+ headers = options[:headers] || {}
281
+ _default_request_headers = options.fetch(:default_request_headers, default_request_headers) || {}
282
+ _headers = _default_request_headers.merge(headers)
283
+
284
+ query = options.fetch(:query, {})
285
+ base_path = options[:base_path] || (path.start_with?(DEFAULT_BASE_PATH) ? '' : @default_base_path)
286
+ @uri = build_uri(File.join(base_path, path), query)
287
+
288
+ request = Net::HTTP::Post.new(@uri.request_uri, _headers)
289
+
290
+ body = JSON.generate(body) if body and !body.is_a?(String)
291
+
292
+ request.body = body if body
293
+ send_request(request)
294
+ end
295
+
296
+ # HTTPClient
297
+ end
298
+
299
+ # Client
300
+ end
301
+
302
+ # API
303
+ end
304
+
305
+ # Uplynk
306
+ end
307
+
308
+ # VDMS
309
+ end
310
+
311
+ # Ubiquity
312
+ end
@@ -0,0 +1,5 @@
1
+ module Ubiquity
2
+ module VDMS
3
+ VERSION = '1.0.0'
4
+ end
5
+ end
@@ -0,0 +1,27 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'ubiquity/vdms/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = 'ubiquity-vdms'
8
+ spec.version = Ubiquity::VDMS::VERSION
9
+ spec.authors = ['John Whitson']
10
+ spec.email = ['john.whitson@gmail.com']
11
+
12
+ spec.summary = %q{Gem and utilities to interact with Verizon Digital Media Services.}
13
+ spec.description = %q{}
14
+ spec.homepage = 'https://github.com/XPlatform-Consulting/ubiquity-vdms/blob/837efb00b62fe8fe2850055aedfb16fbca808dba/README.md'
15
+ spec.license = 'MIT'
16
+
17
+ spec.files = `git ls-files -z`.split("\x0").reject do |f|
18
+ f.match(%r{^(test|spec|features)/})
19
+ end
20
+ spec.bindir = 'exe'
21
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
22
+ spec.require_paths = ['lib']
23
+
24
+ spec.add_development_dependency 'bundler', '~> 1.14'
25
+ spec.add_development_dependency 'rake', '~> 10.0'
26
+ spec.add_development_dependency 'minitest', '~> 5.0'
27
+ end
metadata ADDED
@@ -0,0 +1,101 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: ubiquity-vdms
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ platform: ruby
6
+ authors:
7
+ - John Whitson
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2018-05-23 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.14'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.14'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '10.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '10.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: minitest
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '5.0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '5.0'
55
+ description: ''
56
+ email:
57
+ - john.whitson@gmail.com
58
+ executables:
59
+ - ubiquity-vdms
60
+ extensions: []
61
+ extra_rdoc_files: []
62
+ files:
63
+ - ".gitignore"
64
+ - ".travis.yml"
65
+ - Gemfile
66
+ - LICENSE.txt
67
+ - README.md
68
+ - Rakefile
69
+ - bin/console
70
+ - bin/setup
71
+ - exe/ubiquity-vdms
72
+ - lib/ubiquity/vdms.rb
73
+ - lib/ubiquity/vdms/uplynk/api/client.rb
74
+ - lib/ubiquity/vdms/uplynk/api/client/http_client.rb
75
+ - lib/ubiquity/vdms/version.rb
76
+ - ubiquity-vdms.gemspec
77
+ homepage: https://github.com/XPlatform-Consulting/ubiquity-vdms/blob/837efb00b62fe8fe2850055aedfb16fbca808dba/README.md
78
+ licenses:
79
+ - MIT
80
+ metadata: {}
81
+ post_install_message:
82
+ rdoc_options: []
83
+ require_paths:
84
+ - lib
85
+ required_ruby_version: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ required_rubygems_version: !ruby/object:Gem::Requirement
91
+ requirements:
92
+ - - ">="
93
+ - !ruby/object:Gem::Version
94
+ version: '0'
95
+ requirements: []
96
+ rubyforge_project:
97
+ rubygems_version: 2.7.6
98
+ signing_key:
99
+ specification_version: 4
100
+ summary: Gem and utilities to interact with Verizon Digital Media Services.
101
+ test_files: []