hsds_transformer 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 6e911449b148656bce8dcd5c10110a25e8f2d86af9d676544a059516860daa5a
4
+ data.tar.gz: 246bbd0c2d57cdf66b3ddb8f9b586ab30d75732eef53216244247f59ee2ca572
5
+ SHA512:
6
+ metadata.gz: 36870c841e466cf83927ee4e586c76d83dbc485420810db0cb6f4b1f3d9940b2e6a440407627a68bb050870981738511920a4ebc9441e91181adb2dc96ab23f4
7
+ data.tar.gz: 87d3e610a1a951449b77b4715f823eeadc71b9e4ca19770c6c1c94ee7a9939897f5007670a2001f048aa1a4a89614c73172af6dab5d83ff8025de26ca2aa6390
data/lib/api.rb ADDED
@@ -0,0 +1,52 @@
1
+ require "sinatra"
2
+ require "sinatra/base"
3
+ require_relative "../lib/hsds_transformer"
4
+
5
+ class Api < Sinatra::Base
6
+ set :bind, '0.0.0.0'
7
+
8
+ before do
9
+ content_type 'multipart/form-data'
10
+ end
11
+
12
+ get "/transform" do
13
+ "Submit your data uri"
14
+ end
15
+
16
+ # TODO catch the Exceptions and return error reponses
17
+ post "/transform" do
18
+ input_path = params[:input_path]
19
+ mapping_uri = params[:mapping]
20
+ include_custom = params[:include_custom]
21
+ custom_transformer = params[:custom_transformer]
22
+
23
+ if mapping_uri.nil?
24
+ halt 422, "A mapping file is required."
25
+ end
26
+
27
+ if input_path.nil?
28
+ halt 422, "An input_path is required."
29
+ end
30
+
31
+ transformer = HsdsTransformer::Runner.run(
32
+ input_path: input_path,
33
+ mapping: mapping_uri,
34
+ include_custom: include_custom,
35
+ zip_output: true,
36
+ custom_transformer: custom_transformer
37
+ )
38
+
39
+ send_file transformer.zipfile_name
40
+ end
41
+ end
42
+
43
+
44
+ #require "net/http"
45
+
46
+ # uri = URI.parse("http://localhost:4567")
47
+
48
+ # http = Net::HTTP.new(uri.host, uri.port)
49
+ # request = Net::HTTP::Post.new("/v1.1/auth")
50
+ # request.add_field('Content-Type', 'application/json')
51
+ # request.body = {'credentials' => ''}
52
+ #response = http.request(request)