sequencescape-client-api 0.5.0 → 0.6.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/ruby.yml +39 -0
- data/.gitignore +1 -0
- data/README.markdown +10 -7
- data/lib/sequencescape/specific_tube_creation.rb +1 -0
- data/lib/sequencescape-api/connection_factory/actions.rb +1 -1
- data/lib/sequencescape-api/connection_factory.rb +5 -5
- data/lib/sequencescape-api/rails.rb +5 -9
- data/lib/sequencescape-api/version.rb +1 -1
- data/lib/sequencescape-api.rb +1 -0
- data/spec/sequencescape-api/contracts/create-invalid-resource.txt +1 -1
- data/spec/sequencescape-api/contracts/create-model-c-has-many-inline-nested.txt +1 -1
- data/spec/sequencescape-api/contracts/create-model-c-has-many-inline.txt +1 -1
- data/spec/sequencescape-api/contracts/create-model-c-has-many.txt +1 -1
- data/spec/sequencescape-api/contracts/create-model-c.txt +1 -1
- data/spec/sequencescape-api/contracts/create-via-has-many.txt +1 -1
- data/spec/sequencescape-api/contracts/retrieve-belongs-to-association.txt +1 -1
- data/spec/sequencescape-api/contracts/retrieve-model.txt +1 -2
- data/spec/sequencescape-api/contracts/retrieve-results-page-1.txt +1 -1
- data/spec/sequencescape-api/contracts/retrieve-results-page-2.txt +1 -1
- data/spec/sequencescape-api/contracts/retrieve-results-page-3.txt +1 -1
- data/spec/sequencescape-api/contracts/retrieve-root-with-an-authorised-client.txt +1 -2
- data/spec/sequencescape-api/contracts/retrieve-root-with-an-unauthorised-client.txt +1 -2
- data/spec/sequencescape-api/contracts/retrieve-unauthorised-model-a-list.txt +1 -2
- data/spec/sequencescape-api/contracts/retrieve-unauthorised-model-b-list.txt +1 -2
- data/spec/sequencescape-api/contracts/retrieve-unauthorised-model-c-list.txt +1 -2
- data/spec/sequencescape-api/contracts/update-invalid-resource.txt +1 -1
- data/spec/sequencescape-api/contracts/update-model-c.txt +1 -1
- data/spec/sequencescape-api/root_spec.rb +2 -2
- data/spec/support/contract_helper.rb +2 -2
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3e0a6a18b4640b08e89761dbb369dcbb698ca94e467ca4fb1eb5c32323289a96
|
4
|
+
data.tar.gz: ffd377901ea915147af612107ddcc171d478a90d06900f660e4706164b5746e4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2fd96700191c07809f21fba700449a0fae26d6c126cf6f3d5349746950d037c3315968928994c7002c161bbe023e7a267cb48e7cf6178e065980d70ae8e11729
|
7
|
+
data.tar.gz: 27b21e7ddc8027c802b8938794325dc45630c33917e7bed13b9ec56556beb9623af569996d3b984bb0d07f5d397027351916cbafeb202cd7f99646ff9a02080c
|
@@ -0,0 +1,39 @@
|
|
1
|
+
name: Ruby
|
2
|
+
|
3
|
+
on:
|
4
|
+
- push
|
5
|
+
- pull_request
|
6
|
+
|
7
|
+
jobs:
|
8
|
+
test:
|
9
|
+
runs-on: ubuntu-latest
|
10
|
+
strategy:
|
11
|
+
matrix:
|
12
|
+
ruby: ["2.5", "2.6", "2.7", "3.0"]
|
13
|
+
name: Ruby Test ${{ matrix.ruby }}
|
14
|
+
|
15
|
+
steps:
|
16
|
+
- uses: actions/checkout@v2
|
17
|
+
- name: Set up Ruby
|
18
|
+
uses: ruby/setup-ruby@v1
|
19
|
+
with:
|
20
|
+
ruby-version: ${{ matrix.ruby }}
|
21
|
+
bundler-cache:
|
22
|
+
true # Runs bundle install and caches gems. See the ruby_test.yml
|
23
|
+
# example if you need more control over bundler.
|
24
|
+
- name: Run tests
|
25
|
+
run: bundle exec rspec
|
26
|
+
lint:
|
27
|
+
runs-on: ubuntu-latest
|
28
|
+
|
29
|
+
steps:
|
30
|
+
- uses: actions/checkout@v2
|
31
|
+
- name: Set up Ruby
|
32
|
+
uses: ruby/setup-ruby@v1
|
33
|
+
with:
|
34
|
+
ruby-version: 3.0
|
35
|
+
bundler-cache:
|
36
|
+
true # Runs bundle install and caches gems. See the ruby_test.yml
|
37
|
+
# example if you need more control over bundler.
|
38
|
+
- name: Run lint
|
39
|
+
run: bundle exec rubocop
|
data/.gitignore
CHANGED
data/README.markdown
CHANGED
@@ -1,24 +1,25 @@
|
|
1
|
-
Sequencescape Client API
|
2
|
-
========================
|
1
|
+
# Sequencescape Client API
|
3
2
|
|
4
3
|
This is the Ruby client library for the Sequencescape API.
|
5
4
|
Documentation can be found [on the wiki](https://github.com/sanger/sequencescape-client-api/wiki).
|
6
5
|
|
7
|
-
Version Guides
|
8
|
-
--------------
|
6
|
+
## Version Guides
|
9
7
|
|
10
8
|
- 0.2.x Supports older versions of Rails.
|
11
9
|
- 0.3.x Supports Rails 3.2.x to 5.1.x
|
12
10
|
- 0.4.x Supports Rails 5.0 and up
|
13
11
|
- 0.5.x Supports Rails 5.0 and up, drops yajl in favour of multi-json
|
12
|
+
- 0.6.x Removes usage of WTSISignOn cookie. Replaces with user specific api key,
|
13
|
+
can be provided to Sequencescape::Api.new as user_api_key: or via
|
14
|
+
`api_connection_options` in the controller.
|
14
15
|
|
15
|
-
- master currently corresponds to 0.
|
16
|
+
- master currently corresponds to 0.6.x
|
16
17
|
|
17
18
|
Rails 6 appears to be supported judging by Specs, but haven't used it in anger
|
18
19
|
yet.
|
19
20
|
|
20
|
-
Making a release
|
21
|
-
|
21
|
+
## Making a release
|
22
|
+
|
22
23
|
1. Update the version number in `lib/sequencescape-api/version.rb`
|
23
24
|
2. For pre-releases the version number should be in the format:
|
24
25
|
major.minor.point-rcx
|
@@ -26,6 +27,8 @@ Making a release
|
|
26
27
|
major.minor.point
|
27
28
|
4. Ensure everything is committed, and for non-pre-releases, make sure you are
|
28
29
|
merged to master.
|
30
|
+
|
29
31
|
```
|
30
32
|
rake release
|
31
33
|
``
|
34
|
+
```
|
@@ -3,6 +3,7 @@ require 'sequencescape-api/resource'
|
|
3
3
|
class Sequencescape::SpecificTubeCreation < ::Sequencescape::Api::Resource
|
4
4
|
belongs_to :user
|
5
5
|
belongs_to :parent, class_name: 'Plate'
|
6
|
+
has_many :parents, class_name: 'Asset'
|
6
7
|
attribute_writer :child_purposes, :tube_attributes
|
7
8
|
has_many :children, class_name: 'Tube'
|
8
9
|
end
|
@@ -151,7 +151,7 @@ module Sequencescape::Api::ConnectionFactory::Actions
|
|
151
151
|
private :parse_json_from
|
152
152
|
|
153
153
|
def headers
|
154
|
-
{ 'Accept' => 'application/json', 'Cookie' => "
|
154
|
+
{ 'Accept' => 'application/json', 'Cookie' => "api_key=#{user_api_key}" }.tap do |standard|
|
155
155
|
standard.merge!('X-Sequencescape-Client-ID' => @authorisation) unless @authorisation.blank?
|
156
156
|
end
|
157
157
|
end
|
@@ -7,8 +7,8 @@ class Sequencescape::Api::ConnectionFactory
|
|
7
7
|
|
8
8
|
def self.create(options)
|
9
9
|
required_options = []
|
10
|
-
required_options.push(:
|
11
|
-
required_options.push(:url)
|
10
|
+
required_options.push(:user_api_key) if options[:authorisation].blank?
|
11
|
+
required_options.push(:url) if default_url.blank?
|
12
12
|
|
13
13
|
required_options.push(allow_blank: false)
|
14
14
|
options.required!(*required_options) do |missing|
|
@@ -19,12 +19,12 @@ class Sequencescape::Api::ConnectionFactory
|
|
19
19
|
new(options)
|
20
20
|
end
|
21
21
|
|
22
|
-
attr_reader :url, :
|
23
|
-
private :url, :
|
22
|
+
attr_reader :url, :user_api_key, :read_timeout
|
23
|
+
private :url, :user_api_key, :read_timeout
|
24
24
|
|
25
25
|
def initialize(options)
|
26
26
|
@url = options[:url]
|
27
|
-
@
|
27
|
+
@user_api_key = options[:user_api_key]
|
28
28
|
@authorisation = options[:authorisation]
|
29
29
|
@read_timeout = options[:read_timeout] || 120
|
30
30
|
end
|
@@ -1,7 +1,6 @@
|
|
1
1
|
module Sequencescape::Api::Rails
|
2
2
|
# Including this module into your Rails ApplicationController adds a before filter that will
|
3
|
-
# provide a
|
4
|
-
# use, accessible through `api`.
|
3
|
+
# provide a Sequencescape::Api instance to use, accessible through `api`.
|
5
4
|
module ApplicationController
|
6
5
|
def self.included(base) # rubocop:todo Metrics/MethodLength
|
7
6
|
base.class_eval do
|
@@ -20,32 +19,29 @@ module Sequencescape::Api::Rails
|
|
20
19
|
end
|
21
20
|
end
|
22
21
|
|
22
|
+
private
|
23
|
+
|
23
24
|
def api_class
|
24
25
|
::Sequencescape::Api
|
25
26
|
end
|
26
|
-
private :api_class
|
27
27
|
|
28
28
|
def configure_api
|
29
|
-
@api = api_class.new(
|
29
|
+
@api = api_class.new(api_connection_options)
|
30
30
|
end
|
31
|
-
private :configure_api
|
32
31
|
|
33
32
|
def api_connection_options
|
34
|
-
{}
|
33
|
+
raise Sequencescape::Api::Error, "api_connection_options not implemented for #{self.class}"
|
35
34
|
end
|
36
|
-
private :api_connection_options
|
37
35
|
|
38
36
|
def sequencescape_api_error_handler(exception)
|
39
37
|
Rails.logger.error "#{exception}, #{exception.backtrace}"
|
40
38
|
raise StandardError, "There is an issue with the API connection to Sequencescape (#{exception.message})"
|
41
39
|
end
|
42
|
-
private :sequencescape_api_error_handler
|
43
40
|
|
44
41
|
def sequencescape_api_unauthenticated_handler(exception)
|
45
42
|
Rails.logger.error "#{exception}, #{exception.backtrace}"
|
46
43
|
raise StandardError, 'You are not authenticated; please visit the WTSI login page'
|
47
44
|
end
|
48
|
-
private :sequencescape_api_unauthenticated_handler
|
49
45
|
end
|
50
46
|
|
51
47
|
# Including this module into your Rails model indicates that the model is associated with
|
data/lib/sequencescape-api.rb
CHANGED
@@ -5,7 +5,7 @@ require 'spec_helper'
|
|
5
5
|
describe 'Handling authentication issues' do
|
6
6
|
stub_request_from('retrieve-root-with-an-unauthorised-client') { response('client-fails-authentication') }
|
7
7
|
|
8
|
-
subject { Sequencescape::Api.new(url: 'http://localhost:3000/',
|
8
|
+
subject { Sequencescape::Api.new(url: 'http://localhost:3000/', user_api_key: 'single-sign-on-cookie') }
|
9
9
|
|
10
10
|
it 'raises an exception' do
|
11
11
|
-> { subject }.should raise_error(Sequencescape::Api::UnauthenticatedError)
|
@@ -17,7 +17,7 @@ describe 'Retrieving the root URL' do
|
|
17
17
|
is_working_as_an_unauthorised_client
|
18
18
|
|
19
19
|
context 'with no namespace' do
|
20
|
-
subject { Sequencescape::Api.new(url: 'http://localhost:3000/',
|
20
|
+
subject { Sequencescape::Api.new(url: 'http://localhost:3000/', user_api_key: 'single-sign-on-cookie') }
|
21
21
|
|
22
22
|
Unauthorised::MODELS_THROUGH_API.each do |model|
|
23
23
|
it "provides the #{model} through the API instance" do
|
@@ -96,7 +96,7 @@ module ContractHelper
|
|
96
96
|
end
|
97
97
|
let(:api) do
|
98
98
|
Sequencescape::Api.new(
|
99
|
-
url: 'http://localhost:3000/',
|
99
|
+
url: 'http://localhost:3000/', user_api_key: 'single-sign-on-cookie',
|
100
100
|
namespace: Unauthorised
|
101
101
|
)
|
102
102
|
end
|
@@ -107,7 +107,7 @@ module ContractHelper
|
|
107
107
|
|
108
108
|
let(:api) do
|
109
109
|
Sequencescape::Api.new(
|
110
|
-
url: 'http://localhost:3000/',
|
110
|
+
url: 'http://localhost:3000/', user_api_key: 'single-sign-on-cookie',
|
111
111
|
authorisation: 'authorised!', namespace: Authenticated
|
112
112
|
)
|
113
113
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sequencescape-client-api
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.6.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Matthew Denner
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date:
|
13
|
+
date: 2021-08-27 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: activemodel
|
@@ -190,6 +190,7 @@ executables: []
|
|
190
190
|
extensions: []
|
191
191
|
extra_rdoc_files: []
|
192
192
|
files:
|
193
|
+
- ".github/workflows/ruby.yml"
|
193
194
|
- ".gitignore"
|
194
195
|
- ".rspec"
|
195
196
|
- ".rubocop.yml"
|