vgs_api_client 0.0.1.alpha202205061223 → 0.0.1.alpha202205061657
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/VERSION +1 -1
- data/lib/openapi_client/api_client.rb +1 -1
- data/lib/openapi_client/version.rb +1 -1
- data/lib/version.rb +1 -1
- data/lib/vgs_api_client.rb +37 -10
- data/scripts/assemble/run.sh +1 -1
- data/scripts/test/run.sh +1 -1
- data/spec/test_aliases_api_spec.rb +3 -3
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 123134048a65ef511bc67624fafed31288e6976eee580153b83a05595525758b
|
4
|
+
data.tar.gz: 8c424e099764200fb6b90e7278f1f73b377c9aead2a18d3f8aa0bd8cc71413cd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cdd8095625820809fb3cdebd1c4952b227d3d839709a902e9ff9ec75691d60a43f19f02b6f7de79816dea3e10ddfd40ca1c53398042a4a1c366a776ddbfeca79
|
7
|
+
data.tar.gz: d322b0b5f3ca7325018a6b52086ae1eaa64fcda5d459b407de89cc0a932a22fd489084017f2c2ed43e8f3ef2533e3c2b9663b36f11c6cb17abe12970237c603e
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.0.1.
|
1
|
+
0.0.1.alpha202205061657
|
@@ -31,7 +31,7 @@ module VgsApiClient
|
|
31
31
|
# @option config [Configuration] Configuration for initializing the object, default to Configuration.default
|
32
32
|
def initialize(config = Configuration.default)
|
33
33
|
@config = config
|
34
|
-
@user_agent = "vgs-api-client/0.0.1.
|
34
|
+
@user_agent = "vgs-api-client/0.0.1.alpha202205061657/ruby"
|
35
35
|
@default_headers = {
|
36
36
|
'Content-Type' => 'application/json',
|
37
37
|
'User-Agent' => @user_agent
|
data/lib/version.rb
CHANGED
data/lib/vgs_api_client.rb
CHANGED
@@ -1,7 +1,16 @@
|
|
1
1
|
require 'openapi_client'
|
2
2
|
|
3
3
|
module VGS
|
4
|
-
class
|
4
|
+
class VgsApiError < StandardError
|
5
|
+
end
|
6
|
+
|
7
|
+
class UnauthorizedError < VgsApiError
|
8
|
+
end
|
9
|
+
|
10
|
+
class NotFoundError < VgsApiError
|
11
|
+
end
|
12
|
+
|
13
|
+
class ForbiddenError < VgsApiError
|
5
14
|
end
|
6
15
|
|
7
16
|
class Aliases
|
@@ -10,6 +19,25 @@ module VGS
|
|
10
19
|
@aliases_api = VgsApiClient::AliasesApi.new(VgsApiClient::ApiClient.new(config))
|
11
20
|
end
|
12
21
|
|
22
|
+
private def map_exception(message, error)
|
23
|
+
error_message = message
|
24
|
+
if error.is_a? VgsApiClient::ApiError
|
25
|
+
error_message += ". Details: #{error.message}"
|
26
|
+
case error.code
|
27
|
+
when 401
|
28
|
+
UnauthorizedError.new error_message
|
29
|
+
when 403
|
30
|
+
ForbiddenError.new error_message
|
31
|
+
when 404
|
32
|
+
NotFoundError.new error_message
|
33
|
+
else
|
34
|
+
VgsApiError.new error_message
|
35
|
+
end
|
36
|
+
else
|
37
|
+
VgsApiError.new error_message
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
13
41
|
def redact(data)
|
14
42
|
begin
|
15
43
|
requests = data.map do |item|
|
@@ -27,9 +55,8 @@ module VGS
|
|
27
55
|
response = @aliases_api.create_aliases(opts = {
|
28
56
|
:create_aliases_request => create_aliases_request.to_hash
|
29
57
|
})
|
30
|
-
|
31
|
-
|
32
|
-
raise VgsApiException, "Failed to redact data #{ data }"
|
58
|
+
rescue Exception => e
|
59
|
+
raise map_exception("Failed to redact data #{ data }", e)
|
33
60
|
else
|
34
61
|
response.data
|
35
62
|
end
|
@@ -39,8 +66,8 @@ module VGS
|
|
39
66
|
begin
|
40
67
|
query = aliases.kind_of?(Array) ? aliases.join(",") : aliases
|
41
68
|
response = @aliases_api.reveal_multiple_aliases(q = query)
|
42
|
-
rescue
|
43
|
-
raise
|
69
|
+
rescue Exception => e
|
70
|
+
raise map_exception("Failed to reveal aliases #{ aliases }", e)
|
44
71
|
else
|
45
72
|
response.data
|
46
73
|
end
|
@@ -49,8 +76,8 @@ module VGS
|
|
49
76
|
def delete(_alias)
|
50
77
|
begin
|
51
78
|
@aliases_api.delete_alias(_alias = _alias)
|
52
|
-
rescue
|
53
|
-
raise
|
79
|
+
rescue Exception => e
|
80
|
+
raise map_exception("Failed to delete alias #{ _alias }", e)
|
54
81
|
end
|
55
82
|
end
|
56
83
|
|
@@ -64,8 +91,8 @@ module VGS
|
|
64
91
|
@aliases_api.update_alias(_alias = _alias, opts = {
|
65
92
|
:update_alias_request => update_alias_request.to_hash
|
66
93
|
})
|
67
|
-
rescue
|
68
|
-
raise
|
94
|
+
rescue Exception => e
|
95
|
+
raise map_exception("Failed to update alias #{ _alias }", e)
|
69
96
|
end
|
70
97
|
end
|
71
98
|
end
|
data/scripts/assemble/run.sh
CHANGED
@@ -3,7 +3,7 @@
|
|
3
3
|
LIB_VERSION=${LIB_VERSION:-0.0.1.alpha$(date "+%Y%m%d%H%M")}
|
4
4
|
|
5
5
|
# fix version
|
6
|
-
grep -rl 0.0.1.
|
6
|
+
grep -rl 0.0.1.alpha202205061657 . | xargs sed -i "s/0.0.1.alpha202205061657/${LIB_VERSION}/g"
|
7
7
|
|
8
8
|
# build
|
9
9
|
gem build vgs_api_client.gemspec
|
data/scripts/test/run.sh
CHANGED
@@ -5,7 +5,7 @@ set -e
|
|
5
5
|
echo "Installing lib from local sources"
|
6
6
|
# fix version
|
7
7
|
VERSION=0.0.1.alpha$(date "+%Y%m%d%H%M")
|
8
|
-
grep -rl 0.0.1.
|
8
|
+
grep -rl 0.0.1.alpha202205061657 . | xargs sed -i "s/0.0.1.alpha202205061657/$VERSION/g"
|
9
9
|
|
10
10
|
bundle install
|
11
11
|
|
@@ -17,7 +17,7 @@ describe 'AliasesApiSpec' do
|
|
17
17
|
value: 'Joe Doe'
|
18
18
|
}]
|
19
19
|
|
20
|
-
expect { api.redact data }.to raise_error(VGS::
|
20
|
+
expect { api.redact data }.to raise_error(VGS::UnauthorizedError)
|
21
21
|
end
|
22
22
|
end
|
23
23
|
|
@@ -38,7 +38,7 @@ describe 'AliasesApiSpec' do
|
|
38
38
|
format: 'UUID',
|
39
39
|
value: 'Joe Doe'
|
40
40
|
}]
|
41
|
-
expect { api.redact data }.to raise_error(VGS::
|
41
|
+
expect { api.redact data }.to raise_error(VGS::NotFoundError)
|
42
42
|
end
|
43
43
|
end
|
44
44
|
|
@@ -116,7 +116,7 @@ describe 'AliasesApiSpec' do
|
|
116
116
|
|
117
117
|
@api.delete _alias
|
118
118
|
|
119
|
-
expect { @api.reveal _alias }.to raise_error(VGS::
|
119
|
+
expect { @api.reveal _alias }.to raise_error(VGS::VgsApiError)
|
120
120
|
end
|
121
121
|
end
|
122
122
|
|