bio-basespace-sdk 0.1.6 → 0.1.7
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of bio-basespace-sdk might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/README.md +28 -41
- data/VERSION +1 -1
- data/examples/0_app_triggering.rb +2 -11
- data/examples/1_authentication.rb +4 -5
- data/examples/3_accessing_files.rb +3 -3
- data/examples/4_app_result_upload.rb +6 -6
- data/lib/basespace/api/api_client.rb +24 -7
- data/lib/basespace/api/basespace_api.rb +20 -2
- data/lib/basespace/model.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 38663bab5ac57105f9da4aaae07971d4658195eb
|
4
|
+
data.tar.gz: 55137c26115b7eace35f0fad0f18da5efeeb6370
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 94fb03cf092de3975a870e99746da14e4b5f46f68313a3a7123ced9aa8c98a1958f19ae0852531172eac13a234aa3242784b7f9690b1923aae112825c317e080
|
7
|
+
data.tar.gz: ea4a8f35884515c7d92c6bfc2fa493c39724a9118429f046d30ebfba7ac69e8717c83c92781b8bd45275c1370ff1c347e0e73331becc50f343910b1769ed0368
|
data/README.md
CHANGED
@@ -72,10 +72,10 @@ Creating a `BaseSpaceAPI` object using `new`:
|
|
72
72
|
include Bio::BaseSpace
|
73
73
|
|
74
74
|
# Authentication and connection details:
|
75
|
-
client_id = 'my client key'
|
76
|
-
client_secret = 'my client secret'
|
77
|
-
app_session_id = 'my app session id'
|
78
|
-
access_token = 'my access token'
|
75
|
+
client_id = '<my client key>'
|
76
|
+
client_secret = '<my client secret>'
|
77
|
+
app_session_id = '<my app session id>'
|
78
|
+
access_token = '<my access token>'
|
79
79
|
basespace_url = 'https://api.basespace.illumina.com/'
|
80
80
|
api_version = 'v1pre3'
|
81
81
|
|
@@ -94,10 +94,10 @@ Creating a `BaseSpaceAPI` object using `credentials.json`:
|
|
94
94
|
The file `credentials.json` contains the authentication/connection details in [JSON](http://json.org) format:
|
95
95
|
|
96
96
|
{
|
97
|
-
"client_id": "my client id",
|
98
|
-
"client_secret": "my client secret",
|
99
|
-
"app_session_id": "my app session id",
|
100
|
-
"access_token": "my access token",
|
97
|
+
"client_id": "<my client id>",
|
98
|
+
"client_secret": "<my client secret>",
|
99
|
+
"app_session_id": "<my app session id>",
|
100
|
+
"access_token": "<my access token>",
|
101
101
|
"basespace_url": "https://api.basespace.illumina.com",
|
102
102
|
"api_version": "v1pre3"
|
103
103
|
}
|
@@ -120,13 +120,13 @@ The initial HTTP request to our App from BaseSpace is identified by an `AppSessi
|
|
120
120
|
# An app session contains a referral to one or more AppSessionLaunchObject instances, which reference the
|
121
121
|
# data module the user launched the App on. This can be a list of projects, samples, or a mixture of objects
|
122
122
|
puts "Type of data the app was triggered on can be seen in 'references':"
|
123
|
-
puts my_app_session.references
|
123
|
+
puts my_app_session.references
|
124
124
|
|
125
125
|
The output will be similar to:
|
126
126
|
|
127
127
|
App session by 600602: Eri Kibukawa - Id: <my app session id> - status: Complete
|
128
128
|
Type of data the app was triggered on can be seen in 'references':
|
129
|
-
|
129
|
+
Project
|
130
130
|
|
131
131
|
We can get a handle to the user who started the `AppSession` and further information on the `AppSessionLaunchObject`:
|
132
132
|
|
@@ -173,20 +173,9 @@ The output will be similar to:
|
|
173
173
|
Scope string for requesting write access to the reference object:
|
174
174
|
write project 848850
|
175
175
|
|
176
|
-
We can request write access to the reference object now, so that our App can start contributing to an analysis.
|
177
|
-
|
178
|
-
The following call requests write permissions for a Web App:
|
179
|
-
|
180
|
-
verification_with_code_uri = bs_api.get_access(my_reference_content, 'write')
|
181
|
-
puts "Visit the URI within 15 seconds and grant access:"
|
182
|
-
puts verification_with_code_uri
|
183
|
-
|
184
|
-
The output will be similar to:
|
176
|
+
We can request write access to the reference object now, so that our App can start contributing to an analysis.
|
185
177
|
|
186
|
-
|
187
|
-
https://cloud-hoth.illumina.com//oauth/authorize?<authorization paramers>
|
188
|
-
|
189
|
-
The following call requests write permissions for other Apps (Desktop, Mobile, Native):
|
178
|
+
The following call requests write permissions:
|
190
179
|
|
191
180
|
access_map = bs_api.get_access(my_reference_content, 'write')
|
192
181
|
puts "Access map:"
|
@@ -197,7 +186,7 @@ The output will be similar to:
|
|
197
186
|
Access map:
|
198
187
|
{"device_code"=>"<my device code>", "user_code"=>"<my user code>", "verification_uri"=>"https://basespace.illumina.com/oauth/device", "verification_with_code_uri"=>"https://basespace.illumina.com/oauth/device?code=<my user code>", "expires_in"=>1800, "interval"=>1}
|
199
188
|
|
200
|
-
|
189
|
+
Have the user visit the verification URI to grant us access:
|
201
190
|
|
202
191
|
puts "Visit the URI within 15 seconds and grant access:"
|
203
192
|
verification_with_code_uri = access_map['verification_with_code_uri']
|
@@ -208,9 +197,8 @@ The output will be:
|
|
208
197
|
Visit the URI within 15 seconds and grant access:
|
209
198
|
https://basespace.illumina.com/oauth/device?code=<my user code>
|
210
199
|
|
211
|
-
|
200
|
+
The URI can be opened in a web browser using this portable Ruby code:
|
212
201
|
|
213
|
-
link = access_map['verification_with_code_uri']
|
214
202
|
host = RbConfig::CONFIG['host_os']
|
215
203
|
case host
|
216
204
|
when /mswin|mingw|cygwin/
|
@@ -227,7 +215,7 @@ Once the user has granted us access to objects we requested we can get the BaseS
|
|
227
215
|
code = access_map['device_code']
|
228
216
|
bs_api.update_privileges(code)
|
229
217
|
|
230
|
-
For more details on access-requests and authentication and an example of the web-based case see example 1\_authentication.rb
|
218
|
+
For more details on access-requests and authentication and an example of the web-based case see example [1\_authentication.rb](https://github.com/basespace/basespace-ruby-sdk/blob/master/examples/1_authentication.rb)
|
231
219
|
|
232
220
|
## BaseSpace Authentication
|
233
221
|
|
@@ -247,14 +235,13 @@ It will be useful if you are logged in to the BaseSpace web-site before launchin
|
|
247
235
|
|
248
236
|
First, get the verification code and URI for scope 'browse global':
|
249
237
|
|
250
|
-
|
251
|
-
puts
|
238
|
+
access_map = bs_api.get_verification_code('browse global')
|
252
239
|
puts "URI for user to visit and grant access:"
|
253
|
-
puts
|
240
|
+
puts access_map['verification_with_code_uri']
|
254
241
|
|
255
242
|
At this point the user must visit the verification URI to grant the requested privilege. From Ruby, it is possible to launch a browser pointing to the verification URI using:
|
256
243
|
|
257
|
-
link =
|
244
|
+
link = access_map['verification_with_code_uri']
|
258
245
|
host = RbConfig::CONFIG['host_os']
|
259
246
|
case host
|
260
247
|
when /mswin|mingw|cygwin/
|
@@ -273,7 +260,7 @@ The output will be:
|
|
273
260
|
|
274
261
|
Once access has been granted, we can get the BaseSpace `access_token` and start browsing simply by calling `update_privileges` on the baseSpaceApi instance.
|
275
262
|
|
276
|
-
code =
|
263
|
+
code = access_map['device_code']
|
277
264
|
bs_api.update_privileges(code)
|
278
265
|
|
279
266
|
As a reference the provided access-token can be obtained from the `BaseSpaceAPI` object:
|
@@ -410,8 +397,8 @@ Now, we have a look at some of the methods calls specific to BAM and VCF files.
|
|
410
397
|
|
411
398
|
# Request privileges:
|
412
399
|
# NOTE THAT YOUR PROJECT ID (469469 here) WILL MOST LIKELY BE DIFFERENT!
|
413
|
-
|
414
|
-
link =
|
400
|
+
access_map = bs_api.get_verification_code('read project 469469')
|
401
|
+
link = access_map['verification_with_code_uri']
|
415
402
|
puts "Visit the URI within 15 seconds and grant access:"
|
416
403
|
puts link
|
417
404
|
host = RbConfig::CONFIG['host_os']
|
@@ -425,7 +412,7 @@ Now, we have a look at some of the methods calls specific to BAM and VCF files.
|
|
425
412
|
end
|
426
413
|
sleep(15)
|
427
414
|
|
428
|
-
code =
|
415
|
+
code = access_map['device_code']
|
429
416
|
bs_api.update_privileges(code)
|
430
417
|
|
431
418
|
# Get the coverage for an interval + accompanying meta-data:
|
@@ -470,8 +457,8 @@ and upload result files to it as well as retrieve files from it.
|
|
470
457
|
|
471
458
|
First we get a project to work on. We will need write permissions for the project we are working on -- meaning that we will need to update our privileges accordingly:
|
472
459
|
|
473
|
-
|
474
|
-
link =
|
460
|
+
access_map = bs_api.get_verification_code('browse global')
|
461
|
+
link = access_map['verification_with_code_uri']
|
475
462
|
puts "Visit the URI within 15 seconds and grant access:"
|
476
463
|
puts link
|
477
464
|
host = RbConfig::CONFIG['host_os']
|
@@ -485,7 +472,7 @@ First we get a project to work on. We will need write permissions for the projec
|
|
485
472
|
end
|
486
473
|
sleep(15)
|
487
474
|
|
488
|
-
code =
|
475
|
+
code = access_map['device_code']
|
489
476
|
bs_api.update_privileges(code)
|
490
477
|
|
491
478
|
# NOTE THAT YOUR PROJECT ID WILL MOST LIKELY BE DIFFERENT!
|
@@ -505,8 +492,8 @@ The output will be similar to:
|
|
505
492
|
|
506
493
|
To create an `AppResult` for a project, request 'create' privileges, then simply give the name and description:
|
507
494
|
|
508
|
-
|
509
|
-
link =
|
495
|
+
access_map = bs_api.get_verification_code("create project #{prj.id}")
|
496
|
+
link = access_map['verification_with_code_uri']
|
510
497
|
puts "Visit the URI within 15 seconds and grant access:"
|
511
498
|
puts link
|
512
499
|
host = RbConfig::CONFIG['host_os']
|
@@ -520,7 +507,7 @@ To create an `AppResult` for a project, request 'create' privileges, then simply
|
|
520
507
|
end
|
521
508
|
sleep(15)
|
522
509
|
|
523
|
-
code =
|
510
|
+
code = access_map['device_code']
|
524
511
|
bs_api.update_privileges(code)
|
525
512
|
|
526
513
|
# NOTE THAT THE APP SESSION ID OF A RUNNING APP MUST BE PROVIDED!
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.1.
|
1
|
+
0.1.7
|
@@ -47,7 +47,7 @@ puts my_app_session
|
|
47
47
|
# An app session contains a referral to one or more AppSessionLaunchObject instances, which reference the
|
48
48
|
# data module the user launched the App on. This can be a list of projects, samples, or a mixture of objects
|
49
49
|
puts "Type of data the app was triggered on can be seen in 'references':"
|
50
|
-
puts my_app_session.references
|
50
|
+
puts my_app_session.references
|
51
51
|
|
52
52
|
#
|
53
53
|
# We can get a handle to the user who started the `AppSession` and further information on the `AppSessionLaunchObject`:
|
@@ -84,15 +84,7 @@ puts "Scope string for requesting write access to the reference object:"
|
|
84
84
|
puts my_reference_content.get_access_str('write')
|
85
85
|
|
86
86
|
#
|
87
|
-
# The following call requests write permissions
|
88
|
-
#
|
89
|
-
|
90
|
-
verification_with_code_uri = bs_api.get_access(my_reference_content, 'write')
|
91
|
-
puts "Visit the URI within 15 seconds and grant access:"
|
92
|
-
puts verification_with_code_uri
|
93
|
-
|
94
|
-
#
|
95
|
-
# The following call requests write permissions for other Apps (Desktop, Mobile, Native):
|
87
|
+
# The following call requests write permissions:
|
96
88
|
#
|
97
89
|
|
98
90
|
access_map = bs_api.get_access(my_reference_content, 'write')
|
@@ -107,7 +99,6 @@ puts "Visit the URI within 15 seconds and grant access:"
|
|
107
99
|
verification_with_code_uri = access_map['verification_with_code_uri']
|
108
100
|
puts verification_with_code_uri
|
109
101
|
|
110
|
-
link = access_map['verification_with_code_uri']
|
111
102
|
host = RbConfig::CONFIG['host_os']
|
112
103
|
case host
|
113
104
|
when /mswin|mingw|cygwin/
|
@@ -43,16 +43,15 @@ bs_api = BaseSpaceAPI.new(opts['client_id'], opts['client_secret'], opts['basesp
|
|
43
43
|
# Get the verification code and uri for scope 'browse global':
|
44
44
|
#
|
45
45
|
|
46
|
-
|
47
|
-
puts
|
46
|
+
access_map = bs_api.get_verification_code('browse global')
|
48
47
|
puts "URI for user to visit and grant access:"
|
49
|
-
puts
|
48
|
+
puts access_map['verification_with_code_uri']
|
50
49
|
|
51
50
|
#
|
52
51
|
# Grant access privileges:
|
53
52
|
#
|
54
53
|
|
55
|
-
link =
|
54
|
+
link = access_map['verification_with_code_uri']
|
56
55
|
host = RbConfig::CONFIG['host_os']
|
57
56
|
case host
|
58
57
|
when /mswin|mingw|cygwin/
|
@@ -64,7 +63,7 @@ when /linux/
|
|
64
63
|
end
|
65
64
|
sleep(15)
|
66
65
|
|
67
|
-
code =
|
66
|
+
code = access_map['device_code']
|
68
67
|
bs_api.update_privileges(code)
|
69
68
|
|
70
69
|
puts "Access-token: #{bs_api.get_access_token}"
|
@@ -82,8 +82,8 @@ end
|
|
82
82
|
|
83
83
|
# NOTE THAT YOUR PROJECT ID (469469 here) WILL MOST LIKELY BE DIFFERENT!
|
84
84
|
puts 'NOTE: CHANGE THE PROJECT ID IN THE EXAMPLE TO MATCH A PROJECT OF YOURS!'
|
85
|
-
|
86
|
-
link =
|
85
|
+
access_map = bs_api.get_verification_code('read project 469469')
|
86
|
+
link = access_map['verification_with_code_uri']
|
87
87
|
puts "Visit the URI within 15 seconds and grant access:"
|
88
88
|
puts link
|
89
89
|
host = RbConfig::CONFIG['host_os']
|
@@ -97,7 +97,7 @@ when /linux/
|
|
97
97
|
end
|
98
98
|
sleep(15)
|
99
99
|
|
100
|
-
code =
|
100
|
+
code = access_map['device_code']
|
101
101
|
bs_api.update_privileges(code)
|
102
102
|
|
103
103
|
#
|
@@ -48,8 +48,8 @@ bs_api = BaseSpaceAPI.new(opts['client_id'], opts['client_secret'], opts['basesp
|
|
48
48
|
# Request privileges
|
49
49
|
#
|
50
50
|
|
51
|
-
|
52
|
-
link =
|
51
|
+
access_map = bs_api.get_verification_code('browse global')
|
52
|
+
link = access_map['verification_with_code_uri']
|
53
53
|
puts "Visit the URI within 15 seconds and grant access:"
|
54
54
|
puts link
|
55
55
|
host = RbConfig::CONFIG['host_os']
|
@@ -63,7 +63,7 @@ when /linux/
|
|
63
63
|
end
|
64
64
|
sleep(15)
|
65
65
|
|
66
|
-
code =
|
66
|
+
code = access_map['device_code']
|
67
67
|
bs_api.update_privileges(code)
|
68
68
|
|
69
69
|
#
|
@@ -88,8 +88,8 @@ puts "AppResult instances: #{app_res.map { |r| r.to_s }.join(', ')}"
|
|
88
88
|
# Request project creation privileges
|
89
89
|
#
|
90
90
|
|
91
|
-
|
92
|
-
link =
|
91
|
+
access_map = bs_api.get_verification_code("create project #{prj.id}")
|
92
|
+
link = access_map['verification_with_code_uri']
|
93
93
|
puts "Visit the URI within 15 seconds and grant access:"
|
94
94
|
puts link
|
95
95
|
host = RbConfig::CONFIG['host_os']
|
@@ -103,7 +103,7 @@ when /linux/
|
|
103
103
|
end
|
104
104
|
sleep(15)
|
105
105
|
|
106
|
-
code =
|
106
|
+
code = access_map['device_code']
|
107
107
|
bs_api.update_privileges(code)
|
108
108
|
|
109
109
|
# NOTE THAT THE APP SESSION ID OF A RUNNING APP MUST BE PROVIDED!
|
@@ -150,27 +150,44 @@ class APIClient
|
|
150
150
|
if cgi_params
|
151
151
|
url += "?#{cgi_params}"
|
152
152
|
end
|
153
|
-
# [TODO] confirm this works or not
|
154
|
-
#request = urllib2.Request(url, headers)
|
155
153
|
uri = URI.parse(url)
|
156
|
-
|
154
|
+
# https://www.ruby-forum.com/topic/4411398
|
155
|
+
# In Ruby 1.9: Use Net::HTTP::Get.new(uri.path) or Net::HTTP::Get.new(uri.path + '?' + uri.query)
|
156
|
+
# In Ruby 2.0: Use Net::HTTP::Get.new(uri)
|
157
|
+
case RUBY_VERSION
|
158
|
+
when /^1.9/
|
159
|
+
if uri.query and not uri.query.empty?
|
160
|
+
request = Net::HTTP::Get.new(uri.path + '?' + uri.query, headers)
|
161
|
+
else
|
162
|
+
request = Net::HTTP::Get.new(uri.path, headers)
|
163
|
+
end
|
164
|
+
else
|
165
|
+
request = Net::HTTP::Get.new(uri, headers)
|
166
|
+
end
|
157
167
|
when 'POST', 'PUT', 'DELETE'
|
158
168
|
if cgi_params
|
159
169
|
force_post_url = url
|
160
170
|
url += "?#{cgi_params}"
|
161
171
|
end
|
162
172
|
if post_data
|
163
|
-
# [TODO] Do we need to skip String, Integer, Float and bool in Ruby?
|
173
|
+
# [TODO] Do we need to skip String, Integer, Float and bool also in Ruby?
|
164
174
|
data = post_data # if not [str, int, float, bool].include?(type(post_data))
|
165
175
|
end
|
166
176
|
if force_post
|
167
177
|
response = force_post_call(force_post_url, sent_query_params, headers)
|
168
178
|
else
|
169
179
|
data = {} if not data or (data and data.empty?) # temp fix, in case is no data in the file, to prevent post request from failing
|
170
|
-
# [TODO] confirm this works or not
|
171
|
-
#request = urllib2.Request(url, headers, data)#, @timeout)
|
172
180
|
uri = URI.parse(url)
|
173
|
-
|
181
|
+
case RUBY_VERSION
|
182
|
+
when /^1.9/
|
183
|
+
if uri.query and not uri.query.empty?
|
184
|
+
request = Net::HTTP::Post.new(uri.path + '?' + uri.query, headers)
|
185
|
+
else
|
186
|
+
request = Net::HTTP::Post.new(uri.path, headers)
|
187
|
+
end
|
188
|
+
else
|
189
|
+
request = Net::HTTP::Post.new(uri, headers)
|
190
|
+
end
|
174
191
|
if data.kind_of?(Hash) then
|
175
192
|
request.set_form_data(data)
|
176
193
|
else
|
@@ -149,7 +149,16 @@ class BaseSpaceAPI < BaseAPI
|
|
149
149
|
http_opts[:use_ssl] = true
|
150
150
|
end
|
151
151
|
response = Net::HTTP.start(uri.host, uri.port, http_opts) { |http|
|
152
|
-
|
152
|
+
case RUBY_VERSION
|
153
|
+
when /^1.9/
|
154
|
+
if uri.query and not uri.query.empty?
|
155
|
+
request = Net::HTTP::Get.new(uri.path + '?' + uri.query)
|
156
|
+
else
|
157
|
+
request = Net::HTTP::Get.new(uri.path)
|
158
|
+
end
|
159
|
+
else
|
160
|
+
request = Net::HTTP::Get.new(uri)
|
161
|
+
end
|
153
162
|
request.basic_auth uri.user, uri.password
|
154
163
|
http.request(request)
|
155
164
|
}
|
@@ -672,7 +681,16 @@ class BaseSpaceAPI < BaseAPI
|
|
672
681
|
end
|
673
682
|
res = Net::HTTP.start(uri.host, uri.port, http_opts) { |http|
|
674
683
|
# [TODO] Do we need user and pass here also?
|
675
|
-
|
684
|
+
case RUBY_VERSION
|
685
|
+
when /^1.9/
|
686
|
+
if uri.query and not uri.query.empty?
|
687
|
+
http.get(uri.path + '?' + uri.query, header)
|
688
|
+
else
|
689
|
+
http.get(uri.path, header)
|
690
|
+
end
|
691
|
+
else
|
692
|
+
http.get(uri, header)
|
693
|
+
end
|
676
694
|
}
|
677
695
|
fp.print res.body
|
678
696
|
end
|
data/lib/basespace/model.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bio-basespace-sdk
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Joachim Baran
|
@@ -12,7 +12,7 @@ authors:
|
|
12
12
|
autorequire:
|
13
13
|
bindir: bin
|
14
14
|
cert_chain: []
|
15
|
-
date: 2013-08-
|
15
|
+
date: 2013-08-08 00:00:00.000000000 Z
|
16
16
|
dependencies:
|
17
17
|
- !ruby/object:Gem::Dependency
|
18
18
|
name: getopt
|