=begin # Mux Ruby - Copyright 2019 Mux Inc. # NOTE: This file is auto generated. Do not edit this file manually. =end require 'uri' module MuxRuby class DirectUploadsApi attr_accessor :api_client def initialize(api_client = ApiClient.default) @api_client = api_client end # Cancel a direct upload # Cancels a direct upload and marks it as cancelled. If a pending upload finishes after this request, no asset will be created. This request will only succeed if the upload is still in the `waiting` state. # @param upload_id ID of the Upload # @param [Hash] opts the optional parameters # @return [UploadResponse] def cancel_direct_upload(upload_id, opts = {}) data, _status_code, _headers = cancel_direct_upload_with_http_info(upload_id, opts) data end # Cancel a direct upload # Cancels a direct upload and marks it as cancelled. If a pending upload finishes after this request, no asset will be created. This request will only succeed if the upload is still in the `waiting` state. # @param upload_id ID of the Upload # @param [Hash] opts the optional parameters # @return [Array<(UploadResponse, Fixnum, Hash)>] UploadResponse data, response status code and response headers def cancel_direct_upload_with_http_info(upload_id, opts = {}) if @api_client.config.debugging @api_client.config.logger.debug 'Calling API: DirectUploadsApi.cancel_direct_upload ...' end # verify the required parameter 'upload_id' is set if @api_client.config.client_side_validation && upload_id.nil? fail ArgumentError, "Missing the required parameter 'upload_id' when calling DirectUploadsApi.cancel_direct_upload" end # resource path local_var_path = '/video/v1/uploads/{UPLOAD_ID}/cancel'.sub('{' + 'UPLOAD_ID' + '}', upload_id.to_s) # query parameters query_params = {} # header parameters header_params = {} # HTTP header 'Accept' (if needed) header_params['Accept'] = @api_client.select_header_accept(['application/json']) # form parameters form_params = {} # http body (model) post_body = nil auth_names = ['accessToken'] data, status_code, headers = @api_client.call_api(:PUT, local_var_path, :header_params => header_params, :query_params => query_params, :form_params => form_params, :body => post_body, :auth_names => auth_names, :return_type => 'UploadResponse') if @api_client.config.debugging @api_client.config.logger.debug "API called: DirectUploadsApi#cancel_direct_upload\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end return data, status_code, headers end # Create a new direct upload URL # @param create_upload_request # @param [Hash] opts the optional parameters # @return [UploadResponse] def create_direct_upload(create_upload_request, opts = {}) data, _status_code, _headers = create_direct_upload_with_http_info(create_upload_request, opts) data end # Create a new direct upload URL # @param create_upload_request # @param [Hash] opts the optional parameters # @return [Array<(UploadResponse, Fixnum, Hash)>] UploadResponse data, response status code and response headers def create_direct_upload_with_http_info(create_upload_request, opts = {}) if @api_client.config.debugging @api_client.config.logger.debug 'Calling API: DirectUploadsApi.create_direct_upload ...' end # verify the required parameter 'create_upload_request' is set if @api_client.config.client_side_validation && create_upload_request.nil? fail ArgumentError, "Missing the required parameter 'create_upload_request' when calling DirectUploadsApi.create_direct_upload" end # resource path local_var_path = '/video/v1/uploads' # query parameters query_params = {} # header parameters header_params = {} # HTTP header 'Accept' (if needed) header_params['Accept'] = @api_client.select_header_accept(['application/json']) # HTTP header 'Content-Type' header_params['Content-Type'] = @api_client.select_header_content_type(['application/json']) # form parameters form_params = {} # http body (model) post_body = @api_client.object_to_http_body(create_upload_request) auth_names = ['accessToken'] data, status_code, headers = @api_client.call_api(:POST, local_var_path, :header_params => header_params, :query_params => query_params, :form_params => form_params, :body => post_body, :auth_names => auth_names, :return_type => 'UploadResponse') if @api_client.config.debugging @api_client.config.logger.debug "API called: DirectUploadsApi#create_direct_upload\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end return data, status_code, headers end # Retrieve a single direct upload's info # @param upload_id ID of the Upload # @param [Hash] opts the optional parameters # @return [UploadResponse] def get_direct_upload(upload_id, opts = {}) data, _status_code, _headers = get_direct_upload_with_http_info(upload_id, opts) data end # Retrieve a single direct upload's info # @param upload_id ID of the Upload # @param [Hash] opts the optional parameters # @return [Array<(UploadResponse, Fixnum, Hash)>] UploadResponse data, response status code and response headers def get_direct_upload_with_http_info(upload_id, opts = {}) if @api_client.config.debugging @api_client.config.logger.debug 'Calling API: DirectUploadsApi.get_direct_upload ...' end # verify the required parameter 'upload_id' is set if @api_client.config.client_side_validation && upload_id.nil? fail ArgumentError, "Missing the required parameter 'upload_id' when calling DirectUploadsApi.get_direct_upload" end # resource path local_var_path = '/video/v1/uploads/{UPLOAD_ID}'.sub('{' + 'UPLOAD_ID' + '}', upload_id.to_s) # query parameters query_params = {} # header parameters header_params = {} # HTTP header 'Accept' (if needed) header_params['Accept'] = @api_client.select_header_accept(['application/json']) # form parameters form_params = {} # http body (model) post_body = nil auth_names = ['accessToken'] data, status_code, headers = @api_client.call_api(:GET, local_var_path, :header_params => header_params, :query_params => query_params, :form_params => form_params, :body => post_body, :auth_names => auth_names, :return_type => 'UploadResponse') if @api_client.config.debugging @api_client.config.logger.debug "API called: DirectUploadsApi#get_direct_upload\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end return data, status_code, headers end # List direct uploads # @param [Hash] opts the optional parameters # @option opts [Integer] :limit Number of items to include in the response (default to 25) # @option opts [Integer] :page Offset by this many pages, of the size of `limit` (default to 1) # @return [ListUploadsResponse] def list_direct_uploads(opts = {}) data, _status_code, _headers = list_direct_uploads_with_http_info(opts) data end # List direct uploads # @param [Hash] opts the optional parameters # @option opts [Integer] :limit Number of items to include in the response # @option opts [Integer] :page Offset by this many pages, of the size of `limit` # @return [Array<(ListUploadsResponse, Fixnum, Hash)>] ListUploadsResponse data, response status code and response headers def list_direct_uploads_with_http_info(opts = {}) if @api_client.config.debugging @api_client.config.logger.debug 'Calling API: DirectUploadsApi.list_direct_uploads ...' end # resource path local_var_path = '/video/v1/uploads' # query parameters query_params = {} query_params[:'limit'] = opts[:'limit'] if !opts[:'limit'].nil? query_params[:'page'] = opts[:'page'] if !opts[:'page'].nil? # header parameters header_params = {} # HTTP header 'Accept' (if needed) header_params['Accept'] = @api_client.select_header_accept(['application/json']) # form parameters form_params = {} # http body (model) post_body = nil auth_names = ['accessToken'] data, status_code, headers = @api_client.call_api(:GET, local_var_path, :header_params => header_params, :query_params => query_params, :form_params => form_params, :body => post_body, :auth_names => auth_names, :return_type => 'ListUploadsResponse') if @api_client.config.debugging @api_client.config.logger.debug "API called: DirectUploadsApi#list_direct_uploads\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end return data, status_code, headers end end end