=begin #Mux API #Mux is how developers build online video. This API encompasses both Mux Video and Mux Data functionality to help you build your video-related projects better and faster than ever before. The version of the OpenAPI document: v1 Generated by: https://openapi-generator.tech OpenAPI Generator version: 5.0.1 =end require 'cgi' 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 [String] 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 [String] ID of the Upload # @param [Hash] opts the optional parameters # @return [Array<(UploadResponse, Integer, 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' + '}', CGI.escape(upload_id.to_s)) # query parameters query_params = opts[:query_params] || {} # header parameters header_params = opts[:header_params] || {} # HTTP header 'Accept' (if needed) header_params['Accept'] = @api_client.select_header_accept(['application/json']) # form parameters form_params = opts[:form_params] || {} # http body (model) post_body = opts[:debug_body] # return_type return_type = opts[:debug_return_type] || 'UploadResponse' # auth_names auth_names = opts[:debug_auth_names] || ['accessToken'] new_options = opts.merge( :operation => :"DirectUploadsApi.cancel_direct_upload", :header_params => header_params, :query_params => query_params, :form_params => form_params, :body => post_body, :auth_names => auth_names, :return_type => return_type ) data, status_code, headers = @api_client.call_api(:PUT, local_var_path, new_options) 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 [CreateUploadRequest] # @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 [CreateUploadRequest] # @param [Hash] opts the optional parameters # @return [Array<(UploadResponse, Integer, 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 = opts[:query_params] || {} # header parameters header_params = opts[: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 = opts[:form_params] || {} # http body (model) post_body = opts[:debug_body] || @api_client.object_to_http_body(create_upload_request) # return_type return_type = opts[:debug_return_type] || 'UploadResponse' # auth_names auth_names = opts[:debug_auth_names] || ['accessToken'] new_options = opts.merge( :operation => :"DirectUploadsApi.create_direct_upload", :header_params => header_params, :query_params => query_params, :form_params => form_params, :body => post_body, :auth_names => auth_names, :return_type => return_type ) data, status_code, headers = @api_client.call_api(:POST, local_var_path, new_options) 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 [String] 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 [String] ID of the Upload # @param [Hash] opts the optional parameters # @return [Array<(UploadResponse, Integer, 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' + '}', CGI.escape(upload_id.to_s)) # query parameters query_params = opts[:query_params] || {} # header parameters header_params = opts[:header_params] || {} # HTTP header 'Accept' (if needed) header_params['Accept'] = @api_client.select_header_accept(['application/json']) # form parameters form_params = opts[:form_params] || {} # http body (model) post_body = opts[:debug_body] # return_type return_type = opts[:debug_return_type] || 'UploadResponse' # auth_names auth_names = opts[:debug_auth_names] || ['accessToken'] new_options = opts.merge( :operation => :"DirectUploadsApi.get_direct_upload", :header_params => header_params, :query_params => query_params, :form_params => form_params, :body => post_body, :auth_names => auth_names, :return_type => return_type ) data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options) 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, Integer, 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 = opts[:query_params] || {} query_params[:'limit'] = opts[:'limit'] if !opts[:'limit'].nil? query_params[:'page'] = opts[:'page'] if !opts[:'page'].nil? # header parameters header_params = opts[:header_params] || {} # HTTP header 'Accept' (if needed) header_params['Accept'] = @api_client.select_header_accept(['application/json']) # form parameters form_params = opts[:form_params] || {} # http body (model) post_body = opts[:debug_body] # return_type return_type = opts[:debug_return_type] || 'ListUploadsResponse' # auth_names auth_names = opts[:debug_auth_names] || ['accessToken'] new_options = opts.merge( :operation => :"DirectUploadsApi.list_direct_uploads", :header_params => header_params, :query_params => query_params, :form_params => form_params, :body => post_body, :auth_names => auth_names, :return_type => return_type ) data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options) 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