archivesspace-client 0.1.6 → 0.1.11
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +2 -0
- data/README.md +59 -5
- data/Rakefile +11 -3
- data/archivesspace-client.gemspec +25 -19
- data/examples/export.rb +20 -17
- data/examples/password_reset.rb +8 -7
- data/examples/repo_and_user.rb +32 -29
- data/examples/test_connection.rb +15 -11
- data/examples/user_groups.rb +44 -0
- data/exe/asclient +7 -0
- data/features/exec.feature +4 -0
- data/features/support/setup.rb +9 -0
- data/features/version.feature +12 -0
- data/lib/archivesspace/client/cli/exec.rb +44 -0
- data/lib/archivesspace/client/cli/version.rb +16 -0
- data/lib/archivesspace/client/cli.rb +24 -0
- data/lib/archivesspace/client/client.rb +33 -10
- data/lib/archivesspace/client/configuration.rb +10 -10
- data/lib/archivesspace/client/pagination.rb +60 -0
- data/lib/archivesspace/client/request.rb +11 -13
- data/lib/archivesspace/client/response.rb +4 -6
- data/lib/archivesspace/client/task.rb +70 -0
- data/lib/archivesspace/client/template.rb +14 -13
- data/lib/archivesspace/client/version.rb +3 -1
- data/lib/archivesspace/client.rb +24 -12
- data/spec/archivesspace/client_spec.rb +57 -10
- data/spec/archivesspace/configuration_spec.rb +6 -6
- data/spec/archivesspace/templates_spec.rb +26 -0
- data/spec/spec_helper.rb +8 -6
- metadata +106 -22
- data/lib/archivesspace/client/helpers.rb +0 -126
metadata
CHANGED
@@ -1,15 +1,43 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: archivesspace-client
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.11
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Mark Cooper
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-11-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: aruba
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: awesome_print
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: 1.8.0
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: 1.8.0
|
13
41
|
- !ruby/object:Gem::Dependency
|
14
42
|
name: bundler
|
15
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -24,6 +52,48 @@ dependencies:
|
|
24
52
|
- - ">="
|
25
53
|
- !ruby/object:Gem::Version
|
26
54
|
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: capybara_discoball
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: cucumber
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: json_spec
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - ">="
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - ">="
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
27
97
|
- !ruby/object:Gem::Dependency
|
28
98
|
name: rake
|
29
99
|
requirement: !ruby/object:Gem::Requirement
|
@@ -81,62 +151,62 @@ dependencies:
|
|
81
151
|
- !ruby/object:Gem::Version
|
82
152
|
version: 3.0.1
|
83
153
|
- !ruby/object:Gem::Dependency
|
84
|
-
name:
|
154
|
+
name: dry-cli
|
85
155
|
requirement: !ruby/object:Gem::Requirement
|
86
156
|
requirements:
|
87
157
|
- - "~>"
|
88
158
|
- !ruby/object:Gem::Version
|
89
|
-
version:
|
90
|
-
type: :
|
159
|
+
version: '0.7'
|
160
|
+
type: :runtime
|
91
161
|
prerelease: false
|
92
162
|
version_requirements: !ruby/object:Gem::Requirement
|
93
163
|
requirements:
|
94
164
|
- - "~>"
|
95
165
|
- !ruby/object:Gem::Version
|
96
|
-
version:
|
166
|
+
version: '0.7'
|
97
167
|
- !ruby/object:Gem::Dependency
|
98
168
|
name: httparty
|
99
169
|
requirement: !ruby/object:Gem::Requirement
|
100
170
|
requirements:
|
101
|
-
- -
|
171
|
+
- - "~>"
|
102
172
|
- !ruby/object:Gem::Version
|
103
|
-
version: 0.14
|
173
|
+
version: '0.14'
|
104
174
|
type: :runtime
|
105
175
|
prerelease: false
|
106
176
|
version_requirements: !ruby/object:Gem::Requirement
|
107
177
|
requirements:
|
108
|
-
- -
|
178
|
+
- - "~>"
|
109
179
|
- !ruby/object:Gem::Version
|
110
|
-
version: 0.14
|
180
|
+
version: '0.14'
|
111
181
|
- !ruby/object:Gem::Dependency
|
112
182
|
name: json
|
113
183
|
requirement: !ruby/object:Gem::Requirement
|
114
184
|
requirements:
|
115
|
-
- -
|
185
|
+
- - "~>"
|
116
186
|
- !ruby/object:Gem::Version
|
117
|
-
version: 2.0
|
187
|
+
version: '2.0'
|
118
188
|
type: :runtime
|
119
189
|
prerelease: false
|
120
190
|
version_requirements: !ruby/object:Gem::Requirement
|
121
191
|
requirements:
|
122
|
-
- -
|
192
|
+
- - "~>"
|
123
193
|
- !ruby/object:Gem::Version
|
124
|
-
version: 2.0
|
194
|
+
version: '2.0'
|
125
195
|
- !ruby/object:Gem::Dependency
|
126
196
|
name: nokogiri
|
127
197
|
requirement: !ruby/object:Gem::Requirement
|
128
198
|
requirements:
|
129
|
-
- -
|
199
|
+
- - "~>"
|
130
200
|
- !ruby/object:Gem::Version
|
131
|
-
version: 1.10
|
201
|
+
version: '1.10'
|
132
202
|
type: :runtime
|
133
203
|
prerelease: false
|
134
204
|
version_requirements: !ruby/object:Gem::Requirement
|
135
205
|
requirements:
|
136
|
-
- -
|
206
|
+
- - "~>"
|
137
207
|
- !ruby/object:Gem::Version
|
138
|
-
version: 1.10
|
139
|
-
description: Interact with ArchivesSpace via
|
208
|
+
version: '1.10'
|
209
|
+
description: Interact with ArchivesSpace via the API.
|
140
210
|
email:
|
141
211
|
- mark.c.cooper@outlook.com
|
142
212
|
executables: []
|
@@ -155,12 +225,21 @@ files:
|
|
155
225
|
- examples/password_reset.rb
|
156
226
|
- examples/repo_and_user.rb
|
157
227
|
- examples/test_connection.rb
|
228
|
+
- examples/user_groups.rb
|
229
|
+
- exe/asclient
|
230
|
+
- features/exec.feature
|
231
|
+
- features/support/setup.rb
|
232
|
+
- features/version.feature
|
158
233
|
- lib/archivesspace/client.rb
|
234
|
+
- lib/archivesspace/client/cli.rb
|
235
|
+
- lib/archivesspace/client/cli/exec.rb
|
236
|
+
- lib/archivesspace/client/cli/version.rb
|
159
237
|
- lib/archivesspace/client/client.rb
|
160
238
|
- lib/archivesspace/client/configuration.rb
|
161
|
-
- lib/archivesspace/client/
|
239
|
+
- lib/archivesspace/client/pagination.rb
|
162
240
|
- lib/archivesspace/client/request.rb
|
163
241
|
- lib/archivesspace/client/response.rb
|
242
|
+
- lib/archivesspace/client/task.rb
|
164
243
|
- lib/archivesspace/client/template.rb
|
165
244
|
- lib/archivesspace/client/templates/digital_object.json.erb
|
166
245
|
- lib/archivesspace/client/templates/repository.json.erb
|
@@ -169,6 +248,7 @@ files:
|
|
169
248
|
- lib/archivesspace/client/version.rb
|
170
249
|
- spec/archivesspace/client_spec.rb
|
171
250
|
- spec/archivesspace/configuration_spec.rb
|
251
|
+
- spec/archivesspace/templates_spec.rb
|
172
252
|
- spec/fixtures/cassettes/backend_version.yml
|
173
253
|
- spec/spec_helper.rb
|
174
254
|
homepage: ''
|
@@ -190,12 +270,16 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
190
270
|
- !ruby/object:Gem::Version
|
191
271
|
version: '0'
|
192
272
|
requirements: []
|
193
|
-
rubygems_version: 3.
|
273
|
+
rubygems_version: 3.1.6
|
194
274
|
signing_key:
|
195
275
|
specification_version: 4
|
196
|
-
summary: Interact with ArchivesSpace via
|
276
|
+
summary: Interact with ArchivesSpace via the API.
|
197
277
|
test_files:
|
278
|
+
- features/exec.feature
|
279
|
+
- features/support/setup.rb
|
280
|
+
- features/version.feature
|
198
281
|
- spec/archivesspace/client_spec.rb
|
199
282
|
- spec/archivesspace/configuration_spec.rb
|
283
|
+
- spec/archivesspace/templates_spec.rb
|
200
284
|
- spec/fixtures/cassettes/backend_version.yml
|
201
285
|
- spec/spec_helper.rb
|
@@ -1,126 +0,0 @@
|
|
1
|
-
# needed for roundtrip hash merging
|
2
|
-
class ::Hash
|
3
|
-
def deep_merge(second)
|
4
|
-
merger = proc { |key, v1, v2| Hash === v1 && Hash === v2 ? v1.merge(v2, &merger) : v2 }
|
5
|
-
self.merge(second, &merger)
|
6
|
-
end
|
7
|
-
end
|
8
|
-
|
9
|
-
module ArchivesSpace
|
10
|
-
|
11
|
-
module Helpers
|
12
|
-
|
13
|
-
def accessions(options = {})
|
14
|
-
all('accessions', options)
|
15
|
-
end
|
16
|
-
|
17
|
-
def all(path, options = {})
|
18
|
-
Enumerator.new do |yielder|
|
19
|
-
page = 1
|
20
|
-
unlimited_listing = false
|
21
|
-
loop do
|
22
|
-
result = get(path, options.merge(query: { page: page }))
|
23
|
-
results = []
|
24
|
-
|
25
|
-
if result.parsed.respond_to?(:key) && result.parsed.key?('results')
|
26
|
-
results = result.parsed['results']
|
27
|
-
else
|
28
|
-
results = result.parsed
|
29
|
-
unlimited_listing = true
|
30
|
-
end
|
31
|
-
|
32
|
-
if results.any?
|
33
|
-
results.each do |i|
|
34
|
-
yielder << i
|
35
|
-
end
|
36
|
-
raise StopIteration if unlimited_listing
|
37
|
-
|
38
|
-
page += 1
|
39
|
-
else
|
40
|
-
raise StopIteration
|
41
|
-
end
|
42
|
-
end
|
43
|
-
end.lazy
|
44
|
-
end
|
45
|
-
|
46
|
-
def backend_version
|
47
|
-
get "version"
|
48
|
-
end
|
49
|
-
|
50
|
-
def batch_import(payload, params = {})
|
51
|
-
# create "batch_import", payload, params
|
52
|
-
end
|
53
|
-
|
54
|
-
def digital_objects(options = {})
|
55
|
-
all('digital_objects', options)
|
56
|
-
end
|
57
|
-
|
58
|
-
def groups(options = {})
|
59
|
-
all('groups', options)
|
60
|
-
end
|
61
|
-
|
62
|
-
def group_user_assignment(users_with_roles, params = { with_members: true })
|
63
|
-
updated = []
|
64
|
-
groups.each do |group|
|
65
|
-
changed = false
|
66
|
-
|
67
|
-
users_with_roles.each do |user, roles|
|
68
|
-
if roles.include? group["group_code"]
|
69
|
-
unless group["member_usernames"].include? user
|
70
|
-
group["member_usernames"] << user
|
71
|
-
changed = true
|
72
|
-
end
|
73
|
-
else
|
74
|
-
if group["member_usernames"].include? user
|
75
|
-
group["member_usernames"].delete user
|
76
|
-
changed = true
|
77
|
-
end
|
78
|
-
end
|
79
|
-
end
|
80
|
-
|
81
|
-
if changed
|
82
|
-
id = group["uri"].split("/")[-1]
|
83
|
-
response = post( "/groups/#{id}", group, params )
|
84
|
-
updated << response.parsed
|
85
|
-
end
|
86
|
-
end
|
87
|
-
updated
|
88
|
-
end
|
89
|
-
|
90
|
-
def login
|
91
|
-
username, password = config.username, config.password
|
92
|
-
result = request('POST', "/users/#{username}/login", { query: { password: password } })
|
93
|
-
raise ConnectionError.new "Failed to connect to ArchivesSpace backend as #{username} #{password}" unless result.parsed["session"]
|
94
|
-
@token = result.parsed["session"]
|
95
|
-
self
|
96
|
-
end
|
97
|
-
|
98
|
-
def password_reset(username, password)
|
99
|
-
user = all('users').find { |u| u["username"] == username }
|
100
|
-
raise RequestError.new(user.status) unless user
|
101
|
-
post(user["uri"], user, { password: password })
|
102
|
-
end
|
103
|
-
|
104
|
-
def repositories(options = {})
|
105
|
-
all('repositories', options)
|
106
|
-
end
|
107
|
-
|
108
|
-
def repositories_with_agent
|
109
|
-
#
|
110
|
-
end
|
111
|
-
|
112
|
-
def resources(options = {})
|
113
|
-
all('resources', options)
|
114
|
-
end
|
115
|
-
|
116
|
-
def search(params)
|
117
|
-
# get "search", params
|
118
|
-
end
|
119
|
-
|
120
|
-
def users(options = {})
|
121
|
-
all('users', options)
|
122
|
-
end
|
123
|
-
|
124
|
-
end
|
125
|
-
|
126
|
-
end
|