Module: NexosisApi::Client::Imports
- Included in:
- NexosisApi::Client
- Defined in:
- lib/nexosis_api/client/imports.rb
Overview
Imports-based API operations
Instance Method Summary collapse
-
#import_from_s3(dataset_name, bucket_name, path, region = "us-east-1", column_metadata = []) ⇒ NexosisApi::ImportsResponse
Import a file from AWS s3 as your dataset.
-
#list_imports ⇒ Array of NexosisApi::ImportsResponse
List all existing import requests.
-
#retrieve_import(import_id) ⇒ NexosisApi::ImportsResponse
Get s3 response back from import created previously.
Instance Method Details
#import_from_s3(dataset_name, bucket_name, path, region = "us-east-1", column_metadata = []) ⇒ NexosisApi::ImportsResponse
Import a file from AWS s3 as your dataset
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/nexosis_api/client/imports.rb', line 35 def import_from_s3(dataset_name, bucket_name, path, region = "us-east-1", = []) raise ArgumentError "dataset_name was not provided and is not optional " unless dataset_name.to_s.empty? == false raise ArgumentError "bucket_name was not provided and is not optional " unless bucket_name.to_s.empty? == false raise ArgumentError "path was not provided and is not optional " unless path.to_s.empty? == false s3_import_url = "/imports/s3" column_json = DatasetColumn.to_json() body = { "dataSetName" => dataset_name, "bucket" => bucket_name, "path" => path, "region" => region, "columns" => column_json } response = self.class.post(s3_import_url, :headers => @headers, :body => body.to_json) if(response.success?) NexosisApi::ImportsResponse.new(response.parsed_response) else raise HttpException.new("There was a problem importing from s3: #{response.code}.", "uploading dataset from s3 #{dataset_name}" ,response) end end |
#list_imports ⇒ Array of NexosisApi::ImportsResponse
List all existing import requests
12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/nexosis_api/client/imports.rb', line 12 def list_imports imports_url = "/imports" response = self.class.get(imports_url, :headers => @headers) if(response.success?) items = [] response.parsed_response["items"].each do |i| items << NexosisApi::ImportsResponse.new(i) end items else raise HttpException.new("There was a problem getting the imports: #{response.code}.", "uploading dataset from s3 #{dataset_name}" ,response) end end |
#retrieve_import(import_id) ⇒ NexosisApi::ImportsResponse
Get s3 response back from import created previously. Presumably to check status.
63 64 65 66 67 68 69 70 71 72 |
# File 'lib/nexosis_api/client/imports.rb', line 63 def retrieve_import(import_id) raise ArgumentError "import_id was not provided and is not optional " unless import_id.to_s.empty? == false imports_url = "/imports/#{import_id}" response = self.class.get(imports_url, :headers => @headers) if(response.success?) NexosisApi::ImportsResponse.new(response.parsed_response) else raise HttpException.new("There was a problem getting the import #{response.code}.", "requesting an import #{import_id}" ,response) end end |