Class: Ubiquity::MediaSilo::API::V3::Client
- Inherits:
-
Object
- Object
- Ubiquity::MediaSilo::API::V3::Client
- Defined in:
- lib/ubiquity/mediasilo/api/v3/client/requests/base_request.rb,
lib/ubiquity/mediasilo/api/v3/client.rb
Direct Known Subclasses
Defined Under Namespace
Modules: Requests Classes: Paginator
Instance Attribute Summary collapse
-
#batch_requests ⇒ Object
Returns the value of attribute batch_requests.
-
#http_client ⇒ Object
Returns the value of attribute http_client.
-
#http_response ⇒ Object
Returns the value of attribute http_response.
-
#logger ⇒ Object
Returns the value of attribute logger.
-
#request ⇒ Object
Returns the value of attribute request.
-
#response ⇒ Object
Returns the value of attribute response.
API Methods collapse
- #aspera_file_download_ticket_create(args = { }, options = { }) ⇒ Object
- #aspera_file_upload_ticket_create(args = { }, options = { }) ⇒ Object
- #asset_copy_to_folder(args = { }, options = { }) ⇒ Object
- #asset_copy_to_project(args = { }, options = { }) ⇒ Object
- #asset_create(args = { }, options = { }) ⇒ Object
- #asset_delete_by_id(args = { }, options = { }) ⇒ Object (also: #asset_delete)
- #asset_edit(args = { }, options = { }) ⇒ Object
- #asset_get_by_id(args = { }, options = { }) ⇒ Object
- #asset_move_to_folder(args = { }, options = { }) ⇒ Object
- #asset_move_to_project(args = { }, options = { }) ⇒ Object
- #asset_tag_add(args = { }, options = { }) ⇒ Object (also: #asset_tags_add, #asset_add_tag)
- #asset_tag_delete(args = { }, options = { }) ⇒ Object (also: #asset_tag_remove)
- #asset_upload(args = { }, options = { }) ⇒ Object
- #asset_upload_ticket_create(args = { }, options = { }) ⇒ Object
-
#asset_watermark_trigger(args = { }, options = { }) ⇒ Object
This endpoint is available to admins on any user id, or the current user on their own user id.
- #assets_get(args = { }, options = { }) ⇒ Object
- #assets_get_by_folder_id(args = { }, options = { }) ⇒ Array
- #assets_get_by_project_id(args = { }, options = { }) ⇒ Array
-
#batch_execute(requests = nil, options = { }) ⇒ Object
Executes the queued requests as a batch.
-
#batch_mode=(value, options = { }) ⇒ Object
Sets the batch mode.
-
#batch_mode? ⇒ Boolean
(also: #batch_mode)
Returns true if the client is currently batching requests.
- #batch_mode_enable ⇒ Object
- #folder_create(args = { }, options = { }) ⇒ Object
- #folder_delete(args = { }, options = { }) ⇒ Object
- #folder_get_by_id(args = { }, options = { }) ⇒ Object
- #folders_get_by_parent_id(args = { }) ⇒ Object
- #folders_get_by_project_id(args = { }) ⇒ Object
- #metadata_create_or_update(args = { }, options = { }) ⇒ Object (also: #metadata_set, #metadata_add, #metadata_create_if_not_exists)
- #metadata_delete(args = { }, options = { }) ⇒ Object
- #metadata_get(args = { }, options = { }) ⇒ Object (also: #metadata_get_by_asset_id, #metadata_get_by_asset_uuid)
- #metadata_replace(args = { }, options = { }) ⇒ Object (also: #metadata_mirror)
- #project_create(args = { }, options = { }) ⇒ Object
- #project_delete(args = { }, options = { }) ⇒ Object
- #project_get_by_id(args = { }, options = { }) ⇒ Object
- #project_watermark_settings_get(args = { }, options = { }) ⇒ Object
- #project_watermark_settings_set(args = { }, options = { }) ⇒ Object
- #projects_get(options = { }) ⇒ Object
- #quicklink_create(args = { }, options = { }) ⇒ Object
- #quicklink_share(args = { }, options = { }) ⇒ Object
- #tag_edit(args = { }, options = { }) ⇒ Object
- #tags_get ⇒ Object
- #user_delete(args = { }, options = { }) ⇒ Object
- #users_get(args = { }, options = { }) ⇒ Object
Instance Method Summary collapse
- #error_message ⇒ Object
-
#initialize(args = { }) ⇒ Client
constructor
A new instance of Client.
- #initialize_http_client(args = { }) ⇒ Object
- #initialize_logger(args = { }) ⇒ Object
- #paginator ⇒ Object
- #process_request(request, options = nil) ⇒ Object
- #process_request_using_class(request_class, args = { }, options = { }) ⇒ Object
- #success? ⇒ Boolean
Constructor Details
#initialize(args = { }) ⇒ Client
Returns a new instance of Client.
11 12 13 14 15 16 17 |
# File 'lib/ubiquity/mediasilo/api/v3/client.rb', line 11 def initialize(args = { }) initialize_logger(args) initialize_http_client(args) @batch_mode = false @batch_requests = [ ] end |
Instance Attribute Details
#batch_requests ⇒ Object
Returns the value of attribute batch_requests.
9 10 11 |
# File 'lib/ubiquity/mediasilo/api/v3/client.rb', line 9 def batch_requests @batch_requests end |
#http_client ⇒ Object
Returns the value of attribute http_client.
9 10 11 |
# File 'lib/ubiquity/mediasilo/api/v3/client.rb', line 9 def http_client @http_client end |
#http_response ⇒ Object
Returns the value of attribute http_response.
9 10 11 |
# File 'lib/ubiquity/mediasilo/api/v3/client.rb', line 9 def http_response @http_response end |
#logger ⇒ Object
Returns the value of attribute logger.
7 8 9 |
# File 'lib/ubiquity/mediasilo/api/v3/client.rb', line 7 def logger @logger end |
#request ⇒ Object
Returns the value of attribute request.
9 10 11 |
# File 'lib/ubiquity/mediasilo/api/v3/client.rb', line 9 def request @request end |
#response ⇒ Object
Returns the value of attribute response.
9 10 11 |
# File 'lib/ubiquity/mediasilo/api/v3/client.rb', line 9 def response @response end |
Instance Method Details
#aspera_file_download_ticket_create(args = { }, options = { }) ⇒ Object
97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 |
# File 'lib/ubiquity/mediasilo/api/v3/client.rb', line 97 def aspera_file_download_ticket_create(args = { }, = { }) _request = Requests::BaseRequest.new( args, { :http_path => 'aspera/download/#{path_arguments[:asset_id]}/#{path_arguments[:target]}', :http_method => :post, :parameters => [ { :name => :asset_id, :send_in => :path }, { :name => :target, :send_in => :path } # Either 'source' or 'proxy' ] } ) response = process_request(_request, ) response end |
#aspera_file_upload_ticket_create(args = { }, options = { }) ⇒ Object
114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 |
# File 'lib/ubiquity/mediasilo/api/v3/client.rb', line 114 def aspera_file_upload_ticket_create(args = { }, = { }) _request = Requests::BaseRequest.new( args, { :http_path => 'aspera/upload', :http_method => :post, :parameters => [ { :name => :fileName, :send_in => :body } ] } ) response = process_request(_request, ) response end |
#asset_copy_to_folder(args = { }, options = { }) ⇒ Object
130 131 132 |
# File 'lib/ubiquity/mediasilo/api/v3/client.rb', line 130 def asset_copy_to_folder(args = { }, = { }) process_request_using_class(Requests::AssetCopyToFolder, args, ) end |
#asset_copy_to_project(args = { }, options = { }) ⇒ Object
134 135 136 |
# File 'lib/ubiquity/mediasilo/api/v3/client.rb', line 134 def asset_copy_to_project(args = { }, = { }) process_request_using_class(Requests::AssetCopyToProject, args, ) end |
#asset_create(args = { }, options = { }) ⇒ Object
139 140 141 142 143 |
# File 'lib/ubiquity/mediasilo/api/v3/client.rb', line 139 def asset_create(args = { }, = { }) # args_out = Requests::AssetCreate.new(args, options).arguments # @response = http_client.post('/assets', args_out) process_request_using_class(Requests::AssetCreate, args, ) end |
#asset_delete_by_id(args = { }, options = { }) ⇒ Object Also known as: asset_delete
145 146 147 148 149 150 151 152 153 |
# File 'lib/ubiquity/mediasilo/api/v3/client.rb', line 145 def asset_delete_by_id(args = { }, = { }) # asset_id = asset_id[:id] if asset_id.is_a?(Hash) # @response = http_client.delete('/assets/%s' % asset_id) args = { :assetId => args } if args.is_a?(String) # _request = Requests::AssetDelete.new(args, options) # @response = http_client.delete(_request.path) process_request_using_class(Requests::AssetDelete, args, ) end |
#asset_edit(args = { }, options = { }) ⇒ Object
157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 |
# File 'lib/ubiquity/mediasilo/api/v3/client.rb', line 157 def asset_edit(args = { }, = { }) _request = Requests::BaseRequest.new( args, { :http_method => :put, :http_path => 'assets/#{path_arguments[:asset_id]}', :http_success_code => 204, :parameters => [ { :name => :asset_id, :aliases => [ :id ], :send_in => :path, :required => true }, { :name => :title, :send_in => :body }, { :name => :description, :send_in => :body } ] } ) process_request(_request, ) end |
#asset_get_by_id(args = { }, options = { }) ⇒ Object
175 176 177 178 |
# File 'lib/ubiquity/mediasilo/api/v3/client.rb', line 175 def asset_get_by_id(args = { }, = { }) args = { :asset_id => args } if args.is_a?(String) process_request_using_class(Requests::AssetGetById, args, ) end |
#asset_move_to_folder(args = { }, options = { }) ⇒ Object
257 258 259 |
# File 'lib/ubiquity/mediasilo/api/v3/client.rb', line 257 def asset_move_to_folder(args = { }, = { }) process_request_using_class(Requests::AssetMoveToFolder, args, ) end |
#asset_move_to_project(args = { }, options = { }) ⇒ Object
261 262 263 |
# File 'lib/ubiquity/mediasilo/api/v3/client.rb', line 261 def asset_move_to_project(args = { }, = { }) process_request_using_class(Requests::AssetMoveToProject, args, ) end |
#asset_tag_add(args = { }, options = { }) ⇒ Object Also known as: asset_add_tag ,
266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 |
# File 'lib/ubiquity/mediasilo/api/v3/client.rb', line 266 def asset_tag_add(args = { }, = { }) _request = Requests::BaseRequest.new( args, { :http_method => :post, :http_success_code => '204', :http_path => 'assets/#{path_arguments[:asset_id]}/tags', :parameters => [ { :name => :asset_id, :aliases => [ :id ], :send_in => :path, :required => true }, { :name => :tags, :aliases => [ :tag ], :send_in => :body }, ] } ) = _request.arguments[:tags] _request.arguments[:tags] = [*] unless .is_a?(Array) process_request(_request, ) end |
#asset_tag_delete(args = { }, options = { }) ⇒ Object Also known as: asset_tag_remove
287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 |
# File 'lib/ubiquity/mediasilo/api/v3/client.rb', line 287 def asset_tag_delete(args = { }, = { }) _request = Requests::BaseRequest.new( args, { :http_method => :delete, :http_success_code => '204', :http_path => 'assets/#{path_arguments[:asset_id]}/tags/#{path_arguments[:tag]}', :parameters => [ { :name => :asset_id, :aliases => [ :id ], :send_in => :path, :required => true }, { :name => :tag, :send_in => :path }, ] } ) process_request(_request, ) end |
#asset_upload(args = { }, options = { }) ⇒ Object
318 319 320 |
# File 'lib/ubiquity/mediasilo/api/v3/client.rb', line 318 def asset_upload(args = { }, = { }) end |
#asset_upload_ticket_create(args = { }, options = { }) ⇒ Object
304 305 306 307 308 309 310 311 312 313 314 315 316 |
# File 'lib/ubiquity/mediasilo/api/v3/client.rb', line 304 def asset_upload_ticket_create(args = { }, = { }) _request = Requests::BaseRequest.new( args, { :http_method => :post, :http_path => 'assets/upload', :parameters => [ { :name => :fileName, :send_in => :body } ] } ) process_request(_request, ) end |
#asset_watermark_trigger(args = { }, options = { }) ⇒ Object
This endpoint is available to admins on any user id, or the current user on their own user id. It returns immediately, and watermarking runs in the background. To check whether the watermarking is done, you need to get the ‘proxy’ derivative our of the asset response model and check the ‘progress’ key. Be careful, because there are also ‘progress’ values at the base of the asset response model as well as in the ‘preroll’ derivative. You want the ‘proxy’ one. When that hits 100, the video is ready to play back.
331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 |
# File 'lib/ubiquity/mediasilo/api/v3/client.rb', line 331 def asset_watermark_trigger(args = { }, = { }) _request = Requests::BaseRequest.new( args, { :http_method => :post, :http_success_code => '204', :http_path => 'assets/#{path_arguments[:asset_id]}/watermark/#{path_arguments[:user_id]}', :parameters => [ { :name => :asset_id, :aliases => [ :id ], :send_in => :path, :required => true }, { :name => :user_id, :send_in => :path }, ] } ) process_request(_request, ) end |
#assets_get(args = { }, options = { }) ⇒ Object
181 182 183 184 185 186 187 |
# File 'lib/ubiquity/mediasilo/api/v3/client.rb', line 181 def assets_get(args = { }, = { }) # query = options[:query] || { :type => '{"in":"video,image,document,archive,audio"}' } # @response = http_client.get('/assets', query) _response = process_request_using_class(Requests::AssetsGet, args, ) _response = [ ] unless _response.is_a?(Array) _response end |
#assets_get_by_folder_id(args = { }, options = { }) ⇒ Array
This will get all assets for a folder
194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 |
# File 'lib/ubiquity/mediasilo/api/v3/client.rb', line 194 def assets_get_by_folder_id(args = { }, = { }) args = { :id => args } if args.is_a?(String) _request = Requests::BaseRequest.new( args, { :http_path => 'folders/#{path_arguments[:folder_id]}/assets', :parameters => [ { :name => :folder_id, :aliases => [ :id ], :send_in => :path, :required => true }, { :name => :type, # Received a 500 Request Failed error if 'type' was not set so we default it # :default_value => '{"in":"video,image,document,archive,audio"}', :send_in => :query }, { :name => :_page, :aliases => [ :page ], :send_in => :query }, { :name => :_pageSize, :aliases => [ :page_size ], :send_in => :query }, { :name => :_sort, :aliases => [ :sort ], :send_in => :query }, { :name => :_sortBy, :aliases => [ :sort_by ], :send_in => :query } ] } ) response = process_request(_request, ) response end |
#assets_get_by_project_id(args = { }, options = { }) ⇒ Array
This will get all assets for a project
226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 |
# File 'lib/ubiquity/mediasilo/api/v3/client.rb', line 226 def assets_get_by_project_id(args = { }, = { }) args = { :id => args } if args.is_a?(String) # return_all_results = options.fetch(:return_all_results, false) _request = Requests::BaseRequest.new( args, { :http_path => 'projects/#{path_arguments[:project_id]}/assets', :parameters => [ { :name => :project_id, :aliases => [ :id ], :send_in => :path, :required => true }, { :name => :type, # Received a 500 Request Failed error if 'type' was not set so we default it # :default_value => '{"in":"video,image,document,archive,audio"}', :send_in => :query }, { :name => :_page, :aliases => [ :page ], :send_in => :query }, { :name => :_pageSize, :aliases => [ :page_size ], :send_in => :query }, { :name => :_sort, :aliases => [ :sort ], :send_in => :query }, { :name => :_sortBy, :aliases => [ :sort_by ], :send_in => :query } ] } ) response = process_request(_request, args) # response.delete_if { |asset| asset['folderId'] } if response.is_a?(Array) &&!return_all_results response end |
#batch_execute(requests = nil, options = { }) ⇒ Object
Executes the queued requests as a batch
350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 |
# File 'lib/ubiquity/mediasilo/api/v3/client.rb', line 350 def batch_execute(requests = nil, = { }) if block_given? @batch_mode = true yield _requests = @batch_requests + (requests || [ ]) else _requests = requests.nil? ? @batch_requests.dup : requests.dup end @batch_mode = false return [ ] if _requests.empty? _requests.map! { |req| req.respond_to?(:to_batchable_request) ? req.to_batchable_request : req } _response = [ ] if requests.nil? and .fetch(:clear_requests, true) @batch_requests = [ ] else requests = [ ] end # @request_history.concat(_requests) _requests.each_slice(50) do |_req| process_request_using_class(Requests::Batch, { :requests => _req }, ) _response << @response end @response = _response end |
#batch_mode=(value, options = { }) ⇒ Object
Sets the batch mode
379 380 381 382 383 |
# File 'lib/ubiquity/mediasilo/api/v3/client.rb', line 379 def batch_mode=(value, = { }) @batch_mode = value @batch_requests = [ ] if value and .fetch(:clear_requests, true) @batch_mode end |
#batch_mode? ⇒ Boolean Also known as: batch_mode
Returns true if the client is currently batching requests
386 387 388 |
# File 'lib/ubiquity/mediasilo/api/v3/client.rb', line 386 def batch_mode? @batch_mode end |
#batch_mode_enable ⇒ Object
391 392 393 |
# File 'lib/ubiquity/mediasilo/api/v3/client.rb', line 391 def batch_mode_enable self.batch_mode = true end |
#error_message ⇒ Object
33 34 35 |
# File 'lib/ubiquity/mediasilo/api/v3/client.rb', line 33 def response.is_a?(String) ? response.gsub(/<[^>]*>/ui,'') : '' end |
#folder_create(args = { }, options = { }) ⇒ Object
396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 |
# File 'lib/ubiquity/mediasilo/api/v3/client.rb', line 396 def folder_create(args = { }, = { }) # @response = http_client.post('/folders', args) _request = Requests::BaseRequest.new( args, { :http_method => :post, :http_path => 'folders', :parameters => [ { :name => :name, :send_in => :body }, { :name => :projectId, :send_in => :body }, { :name => :parentId, :default_value => 0, :send_in => :body } ] } ) # arguments = _request.arguments # parent_id = arguments[:parentId] # # if parent_id && parent_id != 0 # logger.debug { 'Unsetting projectId because parentId is set.' } # arguments.delete(:projectId) # end # # _request.arguments = arguments process_request(_request, ) end |
#folder_delete(args = { }, options = { }) ⇒ Object
425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 |
# File 'lib/ubiquity/mediasilo/api/v3/client.rb', line 425 def folder_delete(args = { }, = { }) # folder_id = folder_id[:id] if folder_id.is_a?(Hash) # @response = http_client.delete('/folders/%s' % folder_id) args = { :folder_id => args } if args.is_a?(String) _request = Requests::BaseRequest.new( args, { :http_method => :delete, :http_path => 'folders/#{path_arguments[:folder_id]}', :parameters => [ { :name => :folder_id, :aliases => [ :id ], :send_in => :path } ] }.merge() ) process_request(_request, ) end |
#folder_get_by_id(args = { }, options = { }) ⇒ Object
443 444 445 446 447 448 449 450 451 452 453 454 455 |
# File 'lib/ubiquity/mediasilo/api/v3/client.rb', line 443 def folder_get_by_id(args = { }, = { }) args = { :folder_id => args } if args.is_a?(String) _request = Requests::BaseRequest.new( args, { :http_path => 'folders/#{path_arguments[:folder_id]}', :parameters => [ { :name => :folder_id, :aliases => [ :id ], :send_in => :path } ] }.merge() ) process_request(_request, ) end |
#folders_get_by_parent_id(args = { }) ⇒ Object
457 458 459 460 461 462 463 |
# File 'lib/ubiquity/mediasilo/api/v3/client.rb', line 457 def folders_get_by_parent_id(args = { }) folder_id = case args when String; args when Hash; args[:id] || args[:parent_id] end @response = http_client.get('/folders/%s/subfolders' % folder_id) end |
#folders_get_by_project_id(args = { }) ⇒ Object
465 466 467 468 469 470 471 |
# File 'lib/ubiquity/mediasilo/api/v3/client.rb', line 465 def folders_get_by_project_id(args = { }) project_id = case args when String; args when Hash; args[:id] || args[:project_id] end @response = http_client.get('/projects/%s/folders' % project_id) end |
#initialize_http_client(args = { }) ⇒ Object
29 30 31 |
# File 'lib/ubiquity/mediasilo/api/v3/client.rb', line 29 def initialize_http_client(args = { }) @http_client = Ubiquity::MediaSilo::API::V3::HTTPClient.new(args) end |
#initialize_logger(args = { }) ⇒ Object
19 20 21 22 23 24 25 26 27 |
# File 'lib/ubiquity/mediasilo/api/v3/client.rb', line 19 def initialize_logger(args = { }) @logger = args[:logger] ||= Logger.new(args[:log_to] || STDOUT) log_level = args[:log_level] if log_level @logger.level = log_level args[:logger] = @logger end @logger end |
#metadata_create_or_update(args = { }, options = { }) ⇒ Object Also known as: metadata_set, metadata_add, metadata_create_if_not_exists
500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 |
# File 'lib/ubiquity/mediasilo/api/v3/client.rb', line 500 def (args = { }, = { }) _request = Requests::BaseRequest.new( args, { :http_path => 'assets/#{path_arguments[:asset_id]}/metadata', :http_method => :post, :http_success_code => 204, :parameters => [ { :name => :asset_id, :aliases => [ :id ], :send_in => :path, :required => true }, { :name => :key, :send_in => :body}, { :name => :value, :send_in => :body}, { :name => :metadata, :send_in => :body}, ] }.merge() ) = _request.body_arguments.delete(:metadata) { } = .map { |k,v| { 'key' => k, 'value' => v } } if .is_a?(Hash) _request.body = .delete_if { |h| v = h['value']; (v.respond_to?(:empty?) && v.empty?) } if process_request(_request, ) end |
#metadata_delete(args = { }, options = { }) ⇒ Object
526 527 528 529 530 531 532 533 534 535 536 537 538 539 |
# File 'lib/ubiquity/mediasilo/api/v3/client.rb', line 526 def (args = { }, = { }) _request = Requests::BaseRequest.new( args, { :http_path => 'assets/#{path_arguments[:asset_id]}/metadata/#{path_arguments[:metadata_key]}', :http_method => :delete, :parameters => [ { :name => :asset_id, :aliases => [ :id ], :send_in => :path, :required => true }, { :name => :metadata_key, :aliases => [ :key ], :send_in => :path }, ] }.merge() ) process_request(_request, ) end |
#metadata_get(args = { }, options = { }) ⇒ Object Also known as: metadata_get_by_asset_id, metadata_get_by_asset_uuid
473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 |
# File 'lib/ubiquity/mediasilo/api/v3/client.rb', line 473 def (args = { }, = { }) return_as_hash = .delete(:return_as_hash) { false } args = { :asset_id => args } unless args.is_a?(Hash) _request = Requests::BaseRequest.new( args, { :http_path => 'assets/#{path_arguments[:asset_id]}/metadata', :http_success_code => %w(200 404), :parameters => [ { :name => :asset_id, :aliases => [ :id ], :send_in => :path } ] }.merge() ) _response = process_request(_request, ) return (return_as_hash ? {} : []) if _request.client.http_client.response.code == '404' return false unless _response.is_a?(Array) return Hash[ _response.map { |m| [ m['key'], m['value'] ] } ] if return_as_hash _response end |
#metadata_replace(args = { }, options = { }) ⇒ Object Also known as: metadata_mirror
542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 |
# File 'lib/ubiquity/mediasilo/api/v3/client.rb', line 542 def (args = { }, = { }) _request = Requests::BaseRequest.new( args, { :http_path => 'assets/#{path_arguments[:asset_id]}/metadata', :http_method => :put, :parameters => [ { :name => :asset_id, :aliases => [ :id ], :send_in => :path, :required => true }, { :name => :key, :send_in => :body }, { :name => :value, :send_in => :body }, { :name => :metadata, :send_in => :body }, ] }.merge() ) = _request.body_arguments.delete(:metadata) { } = .map { |k,v| { 'key' => k, 'value' => v} } if .is_a?(Hash) _request.body = if process_request(_request, ) end |
#paginator ⇒ Object
83 84 85 |
# File 'lib/ubiquity/mediasilo/api/v3/client.rb', line 83 def paginator @paginator ||= Paginator.new(self) if @response end |
#process_request(request, options = nil) ⇒ Object
49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 |
# File 'lib/ubiquity/mediasilo/api/v3/client.rb', line 49 def process_request(request, = nil) @paginator = nil @response = nil @request = request logger.warn { "Request is Missing Required Arguments: #{request.missing_required_arguments.inspect}" } unless request.missing_required_arguments.empty? if batch_mode logger.debug { "Adding Request to Batch. #{request.inspect}" } @batch_requests << request return batch_requests end if ([:all, 'all'].include?(request.arguments[:_page])) request.arguments[:_page] = 1 include_remaining_pages = true else include_remaining_pages = false end request.client = self unless request.client ||= request. return (.fetch(:return_request, true) ? request : nil) unless .fetch(:execute_request, true) #@response = http_client.call_method(request.http_method, { :path => request.path, :query => request.query, :body => request.body }, options) @response = request.execute if include_remaining_pages return paginator.include_remaining_pages end @response end |
#process_request_using_class(request_class, args = { }, options = { }) ⇒ Object
87 88 89 90 91 |
# File 'lib/ubiquity/mediasilo/api/v3/client.rb', line 87 def process_request_using_class(request_class, args = { }, = { }) @response = nil @request = request_class.new(args, ) process_request(request, ) end |
#project_create(args = { }, options = { }) ⇒ Object
564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 |
# File 'lib/ubiquity/mediasilo/api/v3/client.rb', line 564 def project_create(args = { }, = { }) args = { :name => args } if args.is_a?(String) _request = Requests::BaseRequest.new( args, { :http_path => 'projects', :http_method => :post, :parameters => [ { :name => :name, :send_in => :body, :required => true }, { :name => :description, :send_in => :body } ] }.merge() ) process_request(_request, ) end |
#project_delete(args = { }, options = { }) ⇒ Object
580 581 582 583 584 585 586 587 588 589 590 591 592 593 |
# File 'lib/ubiquity/mediasilo/api/v3/client.rb', line 580 def project_delete(args = { }, = { }) args = { :project_id => args } if args.is_a?(String) _request = Requests::BaseRequest.new( args, { :http_path => 'projects/#{path_arguments[:project_id]}', :http_method => :delete, :parameters => [ { :name => :project_id, :aliases => [ :id ], :send_in => :path } ] }.merge() ) process_request(_request, ) end |
#project_get_by_id(args = { }, options = { }) ⇒ Object
595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 |
# File 'lib/ubiquity/mediasilo/api/v3/client.rb', line 595 def project_get_by_id(args = { }, = { }) # project_id = project_id[:id] if project_id.is_a?(Hash) # @response = http_client.get('/projects/%s' % project_id) args = { :project_id => args } if args.is_a?(String) _request = Requests::BaseRequest.new( args, { :http_path => 'projects/#{path_arguments[:project_id]}', :parameters => [ { :name => :project_id, :aliases => [ :id ], :send_in => :path } ] }.merge() ) process_request(_request, ) end |
#project_watermark_settings_get(args = { }, options = { }) ⇒ Object
628 629 630 631 632 633 634 635 636 637 638 639 640 |
# File 'lib/ubiquity/mediasilo/api/v3/client.rb', line 628 def project_watermark_settings_get(args = { }, = { }) args = { :project_id => args } if args.is_a?(String) _request = Requests::BaseRequest.new( args, { :http_path => 'projects/#{path_arguments[:project_id]}/watermarkSettings', :parameters => [ { :name => :project_id, :aliases => [ :id ], :send_in => :path } ] }.merge() ) process_request(_request, ) end |
#project_watermark_settings_set(args = { }, options = { }) ⇒ Object
642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 |
# File 'lib/ubiquity/mediasilo/api/v3/client.rb', line 642 def project_watermark_settings_set(args = { }, = { }) args = { :project_id => args } if args.is_a?(String) _request = Requests::BaseRequest.new( args, { :http_path => 'projects/#{body_arguments[:context]}/watermarkSettings', :http_method => 'PUT', :parameters => [ { :name => :context, :aliases => [ :project_id ], :send_in => :body }, { :name => :id, :send_in => :body }, { :name => :settings, :send_in => :body }, { :name => :enabled, :send_in => :body }, ] }.merge() ) process_request(_request, ) end |
#projects_get(options = { }) ⇒ Object
612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 |
# File 'lib/ubiquity/mediasilo/api/v3/client.rb', line 612 def projects_get( = { }) #@response = http_client.get('/projects') _request = Requests::BaseRequest.new( { }, { :http_path => 'projects', :http_success_code => %w(200 404), }.merge() ) _response = process_request(_request, ) return [] if _request.client.http_client.response.code == '404' return _response end |
#quicklink_create(args = { }, options = { }) ⇒ Object
660 661 662 |
# File 'lib/ubiquity/mediasilo/api/v3/client.rb', line 660 def quicklink_create(args = { }, = { }) process_request_using_class(Requests::QuicklinkCreate, args, ) end |
#quicklink_share(args = { }, options = { }) ⇒ Object
664 665 666 |
# File 'lib/ubiquity/mediasilo/api/v3/client.rb', line 664 def quicklink_share(args = { }, = { }) process_request_using_class(Requests::QuicklinkShare, args, ) end |
#success? ⇒ Boolean
37 38 39 40 41 42 |
# File 'lib/ubiquity/mediasilo/api/v3/client.rb', line 37 def success? return request.success? if request.respond_to?(:success?) _code = http_client.response.code _code and _code.start_with?('2') end |
#tag_edit(args = { }, options = { }) ⇒ Object
668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 |
# File 'lib/ubiquity/mediasilo/api/v3/client.rb', line 668 def tag_edit(args = { }, = { }) _request = Requests::BaseRequest.new( args, { :http_path => 'tags', :http_method => :put, :http_success_code => '204', :parameters => [ { :name => :currentName, :required => true, :send_in => :body }, { :name => :newName, :required => true, :send_in => :body } ] # :http_success_code => %w(200 404), }.merge() ) process_request(_request, ) end |
#tags_get ⇒ Object
685 686 687 |
# File 'lib/ubiquity/mediasilo/api/v3/client.rb', line 685 def http_client.get('tags') end |
#user_delete(args = { }, options = { }) ⇒ Object
689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 |
# File 'lib/ubiquity/mediasilo/api/v3/client.rb', line 689 def user_delete(args = { }, = { }) args = { :userId => args } if args.is_a?(String) _request = Requests::BaseRequest.new( args, { :http_path => '/users/#{arguments[:userId]}', :http_method => :delete, :http_success_code => '204', :parameters => [ { :name => :userId, :required => true, :send_in => :query }, ] # :http_success_code => %w(200 404), }.merge() ) process_request(_request, ) end |
#users_get(args = { }, options = { }) ⇒ Object
706 707 708 |
# File 'lib/ubiquity/mediasilo/api/v3/client.rb', line 706 def users_get(args = { }, = { }) http_client.get('users?_pageSize=250') end |