archivesspace-client 0.1.2 → 0.1.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/archivesspace-client.gemspec +7 -7
- data/examples/export.rb +22 -8
- data/examples/password_reset.rb +2 -2
- data/examples/repo_and_user.rb +25 -19
- data/examples/test_connection.rb +17 -0
- data/lib/archivesspace/client/helpers.rb +4 -4
- data/lib/archivesspace/client/request.rb +2 -2
- data/lib/archivesspace/client/version.rb +1 -1
- metadata +32 -32
- data/examples/perms_and_groups.rb +0 -8
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1723d47efa6b10e5106ca28bfa6f247bf79603d2
|
4
|
+
data.tar.gz: f6b404154c5c87ee9a74036d6501cc3304df01ea
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7de5e06e6900dda657cfae615058c10859ba565aa27f16184ec7d44f23c7c2513a52c9717186f8ce04361adabc3097b562db785694bb38556a003177e92b4718
|
7
|
+
data.tar.gz: 17a2e5174475986516c757f7b4f875352546555f0f3aee8539c7f3d2f090789dd1f7087614ca38ea3d0b554c50a351d7307ec8d29706bc816b4fcb328b2e60d9
|
@@ -20,12 +20,12 @@ Gem::Specification.new do |spec|
|
|
20
20
|
|
21
21
|
spec.add_development_dependency "bundler", "~> 1.10"
|
22
22
|
spec.add_development_dependency "rake", "~> 10.0"
|
23
|
-
spec.add_development_dependency "rspec"
|
24
|
-
spec.add_development_dependency "vcr"
|
25
|
-
spec.add_development_dependency "webmock"
|
26
|
-
spec.add_development_dependency "awesome_print"
|
23
|
+
spec.add_development_dependency "rspec", "3.6.0"
|
24
|
+
spec.add_development_dependency "vcr", "3.0.3"
|
25
|
+
spec.add_development_dependency "webmock", "3.0.1"
|
26
|
+
spec.add_development_dependency "awesome_print", "~> 1.8.0"
|
27
27
|
|
28
|
-
spec.add_dependency "httparty"
|
29
|
-
spec.add_dependency "json"
|
30
|
-
spec.add_dependency "nokogiri"
|
28
|
+
spec.add_dependency "httparty", "0.14.0"
|
29
|
+
spec.add_dependency "json", "2.0.3"
|
30
|
+
spec.add_dependency "nokogiri", "1.6.8.1"
|
31
31
|
end
|
data/examples/export.rb
CHANGED
@@ -2,14 +2,28 @@ $LOAD_PATH.unshift File.expand_path('../../lib', __FILE__)
|
|
2
2
|
require 'awesome_print'
|
3
3
|
require 'archivesspace/client'
|
4
4
|
|
5
|
-
#
|
6
|
-
|
7
|
-
|
5
|
+
# official sandbox
|
6
|
+
config = ArchivesSpace::Configuration.new({
|
7
|
+
base_uri: "http://sandbox.archivesspace.org/api",
|
8
|
+
base_repo: "",
|
9
|
+
username: "admin",
|
10
|
+
password: "admin",
|
11
|
+
page_size: 50,
|
12
|
+
throttle: 0,
|
13
|
+
verify_ssl: false,
|
14
|
+
})
|
8
15
|
|
16
|
+
client = ArchivesSpace::Client.new(config).login
|
17
|
+
client.config.throttle = 0.5
|
9
18
|
client.config.base_repo = "repositories/2"
|
10
|
-
|
11
|
-
|
12
|
-
#
|
13
|
-
|
14
|
-
|
19
|
+
|
20
|
+
begin
|
21
|
+
# date -d '2015-07-01 00:00:00' +'%s' # 1435734000
|
22
|
+
client.resources("ead", { query: { modified_since: "1435734000" } }) do |ead|
|
23
|
+
# for now we are just printing ...
|
24
|
+
# but you would actually write to a zip file or whatever
|
25
|
+
ap ead
|
26
|
+
end
|
27
|
+
rescue ArchivesSpace::RequestError => ex
|
28
|
+
puts ex.message
|
15
29
|
end
|
data/examples/password_reset.rb
CHANGED
@@ -10,6 +10,6 @@ client = ArchivesSpace::Client.new.login
|
|
10
10
|
begin
|
11
11
|
client.password_reset username, password
|
12
12
|
puts "Successfully updated password for #{username}."
|
13
|
-
rescue Exception =>
|
14
|
-
puts "Failed to update password for #{username},\n#{
|
13
|
+
rescue Exception => ex
|
14
|
+
puts "Failed to update password for #{username},\n#{ex.message}"
|
15
15
|
end
|
data/examples/repo_and_user.rb
CHANGED
@@ -13,28 +13,34 @@ repo_data = {
|
|
13
13
|
agent_contact_name: "John Doe",
|
14
14
|
}
|
15
15
|
|
16
|
-
repository = ArchivesSpace::Template.process_template(:repository_with_agent, repo_data)
|
17
|
-
response = client.post('/repositories/with_agent', repository)
|
18
|
-
if response.status_code == 201
|
19
|
-
repository = client.repositories.find { |r| r["repo_code"] == "XYZ" }
|
20
|
-
ap repository
|
21
|
-
ap client.delete(repository["uri"])
|
22
|
-
else
|
23
|
-
ap response.parsed
|
24
|
-
end
|
25
|
-
|
26
16
|
user_data = {
|
27
17
|
username: "lmessi",
|
28
18
|
name: "Lionel Messi",
|
29
19
|
is_admin: true,
|
30
20
|
}
|
21
|
+
user_password = "123456"
|
31
22
|
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
23
|
+
repository = ArchivesSpace::Template.process_template(:repository_with_agent, repo_data)
|
24
|
+
|
25
|
+
begin
|
26
|
+
response = client.post('/repositories/with_agent', repository)
|
27
|
+
if response.status_code == 201
|
28
|
+
repository = client.repositories.find { |r| r["repo_code"] == "XYZ" }
|
29
|
+
ap repository
|
30
|
+
ap client.delete(repository["uri"])
|
31
|
+
else
|
32
|
+
ap response.parsed
|
33
|
+
end
|
34
|
+
|
35
|
+
user = ArchivesSpace::Template.process_template(:user, user_data)
|
36
|
+
response = client.post('users', user, { password: user_password })
|
37
|
+
if response.status_code == 201
|
38
|
+
user = client.users.find { |r| r["username"] == "lmessi" }
|
39
|
+
ap user
|
40
|
+
ap client.delete user["uri"]
|
41
|
+
else
|
42
|
+
ap response.parsed
|
43
|
+
end
|
44
|
+
rescue ArchivesSpace::RequestError => ex
|
45
|
+
puts ex.message
|
46
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
$LOAD_PATH.unshift File.expand_path('../../lib', __FILE__)
|
2
|
+
require 'awesome_print'
|
3
|
+
require 'archivesspace/client'
|
4
|
+
|
5
|
+
# official sandbox
|
6
|
+
config = ArchivesSpace::Configuration.new({
|
7
|
+
base_uri: "http://sandbox.archivesspace.org/api",
|
8
|
+
base_repo: "",
|
9
|
+
username: "admin",
|
10
|
+
password: "admin",
|
11
|
+
page_size: 50,
|
12
|
+
throttle: 0,
|
13
|
+
verify_ssl: false,
|
14
|
+
})
|
15
|
+
|
16
|
+
client = ArchivesSpace::Client.new(config).login
|
17
|
+
puts client.get("version").body
|
@@ -24,13 +24,13 @@ module ArchivesSpace
|
|
24
24
|
# options[:headers] -- add xml headers if format
|
25
25
|
|
26
26
|
result = get(path, options.merge({ query: { all_ids: true } } ))
|
27
|
-
raise RequestError.new
|
27
|
+
raise RequestError.new(result.body) if result.status_code != 200
|
28
28
|
ids = result.parsed
|
29
29
|
ids = ids.map{ |object| object["uri"].split("/")[-1] } if parse_id
|
30
30
|
ids.each do |id|
|
31
31
|
path_with_id = format ? "#{format}/#{id}.xml" : "#{path}/#{id}"
|
32
32
|
result = get(path_with_id, options)
|
33
|
-
raise RequestError.new
|
33
|
+
raise RequestError.new(result.body) if result.status_code != 200
|
34
34
|
record = format ? Nokogiri::XML(result.body).to_xml : result.parsed
|
35
35
|
yield record if block_given?
|
36
36
|
all << record
|
@@ -106,7 +106,7 @@ module ArchivesSpace
|
|
106
106
|
|
107
107
|
def password_reset(username, password)
|
108
108
|
user = all('users').find { |u| u["username"] == username }
|
109
|
-
raise RequestError.new
|
109
|
+
raise RequestError.new(user.status) unless user
|
110
110
|
post(user["uri"], user, { password: password })
|
111
111
|
end
|
112
112
|
|
@@ -159,7 +159,7 @@ module ArchivesSpace
|
|
159
159
|
def get_xml(path, options = {})
|
160
160
|
# add xml headers
|
161
161
|
response = get(path, options)
|
162
|
-
raise RequestError.new
|
162
|
+
raise RequestError.new(response.body) unless response.status_code == 200
|
163
163
|
Nokogiri::XML(response.body).to_xml
|
164
164
|
end
|
165
165
|
|
@@ -26,7 +26,7 @@ module ArchivesSpace
|
|
26
26
|
@path = path
|
27
27
|
|
28
28
|
@options = options
|
29
|
-
@options[:headers] = options[:headers] ? default_headers(@method).merge(options[:headers]) : default_headers
|
29
|
+
@options[:headers] = options[:headers] ? default_headers(@method).merge(options[:headers]) : default_headers(@method)
|
30
30
|
@options[:verify] = config.verify_ssl
|
31
31
|
@options[:query] = {} unless options.has_key? :query
|
32
32
|
|
@@ -41,4 +41,4 @@ module ArchivesSpace
|
|
41
41
|
|
42
42
|
end
|
43
43
|
|
44
|
-
end
|
44
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
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.3
|
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: 2017-07-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -42,100 +42,100 @@ dependencies:
|
|
42
42
|
name: rspec
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
|
-
- -
|
45
|
+
- - '='
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version:
|
47
|
+
version: 3.6.0
|
48
48
|
type: :development
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
|
-
- -
|
52
|
+
- - '='
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version:
|
54
|
+
version: 3.6.0
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: vcr
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
|
-
- -
|
59
|
+
- - '='
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version:
|
61
|
+
version: 3.0.3
|
62
62
|
type: :development
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
|
-
- -
|
66
|
+
- - '='
|
67
67
|
- !ruby/object:Gem::Version
|
68
|
-
version:
|
68
|
+
version: 3.0.3
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: webmock
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
72
72
|
requirements:
|
73
|
-
- -
|
73
|
+
- - '='
|
74
74
|
- !ruby/object:Gem::Version
|
75
|
-
version:
|
75
|
+
version: 3.0.1
|
76
76
|
type: :development
|
77
77
|
prerelease: false
|
78
78
|
version_requirements: !ruby/object:Gem::Requirement
|
79
79
|
requirements:
|
80
|
-
- -
|
80
|
+
- - '='
|
81
81
|
- !ruby/object:Gem::Version
|
82
|
-
version:
|
82
|
+
version: 3.0.1
|
83
83
|
- !ruby/object:Gem::Dependency
|
84
84
|
name: awesome_print
|
85
85
|
requirement: !ruby/object:Gem::Requirement
|
86
86
|
requirements:
|
87
|
-
- - "
|
87
|
+
- - "~>"
|
88
88
|
- !ruby/object:Gem::Version
|
89
|
-
version:
|
89
|
+
version: 1.8.0
|
90
90
|
type: :development
|
91
91
|
prerelease: false
|
92
92
|
version_requirements: !ruby/object:Gem::Requirement
|
93
93
|
requirements:
|
94
|
-
- - "
|
94
|
+
- - "~>"
|
95
95
|
- !ruby/object:Gem::Version
|
96
|
-
version:
|
96
|
+
version: 1.8.0
|
97
97
|
- !ruby/object:Gem::Dependency
|
98
98
|
name: httparty
|
99
99
|
requirement: !ruby/object:Gem::Requirement
|
100
100
|
requirements:
|
101
|
-
- -
|
101
|
+
- - '='
|
102
102
|
- !ruby/object:Gem::Version
|
103
|
-
version:
|
103
|
+
version: 0.14.0
|
104
104
|
type: :runtime
|
105
105
|
prerelease: false
|
106
106
|
version_requirements: !ruby/object:Gem::Requirement
|
107
107
|
requirements:
|
108
|
-
- -
|
108
|
+
- - '='
|
109
109
|
- !ruby/object:Gem::Version
|
110
|
-
version:
|
110
|
+
version: 0.14.0
|
111
111
|
- !ruby/object:Gem::Dependency
|
112
112
|
name: json
|
113
113
|
requirement: !ruby/object:Gem::Requirement
|
114
114
|
requirements:
|
115
|
-
- -
|
115
|
+
- - '='
|
116
116
|
- !ruby/object:Gem::Version
|
117
|
-
version:
|
117
|
+
version: 2.0.3
|
118
118
|
type: :runtime
|
119
119
|
prerelease: false
|
120
120
|
version_requirements: !ruby/object:Gem::Requirement
|
121
121
|
requirements:
|
122
|
-
- -
|
122
|
+
- - '='
|
123
123
|
- !ruby/object:Gem::Version
|
124
|
-
version:
|
124
|
+
version: 2.0.3
|
125
125
|
- !ruby/object:Gem::Dependency
|
126
126
|
name: nokogiri
|
127
127
|
requirement: !ruby/object:Gem::Requirement
|
128
128
|
requirements:
|
129
|
-
- -
|
129
|
+
- - '='
|
130
130
|
- !ruby/object:Gem::Version
|
131
|
-
version:
|
131
|
+
version: 1.6.8.1
|
132
132
|
type: :runtime
|
133
133
|
prerelease: false
|
134
134
|
version_requirements: !ruby/object:Gem::Requirement
|
135
135
|
requirements:
|
136
|
-
- -
|
136
|
+
- - '='
|
137
137
|
- !ruby/object:Gem::Version
|
138
|
-
version:
|
138
|
+
version: 1.6.8.1
|
139
139
|
description: Interact with ArchivesSpace via its RESTful API.
|
140
140
|
email:
|
141
141
|
- mark.c.cooper@outlook.com
|
@@ -153,8 +153,8 @@ files:
|
|
153
153
|
- archivesspace-client.gemspec
|
154
154
|
- examples/export.rb
|
155
155
|
- examples/password_reset.rb
|
156
|
-
- examples/perms_and_groups.rb
|
157
156
|
- examples/repo_and_user.rb
|
157
|
+
- examples/test_connection.rb
|
158
158
|
- lib/archivesspace/client.rb
|
159
159
|
- lib/archivesspace/client/client.rb
|
160
160
|
- lib/archivesspace/client/configuration.rb
|
@@ -191,7 +191,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
191
191
|
version: '0'
|
192
192
|
requirements: []
|
193
193
|
rubyforge_project:
|
194
|
-
rubygems_version: 2.
|
194
|
+
rubygems_version: 2.6.10
|
195
195
|
signing_key:
|
196
196
|
specification_version: 4
|
197
197
|
summary: Interact with ArchivesSpace via its RESTful API.
|
@@ -1,8 +0,0 @@
|
|
1
|
-
$LOAD_PATH.unshift File.expand_path('../../lib', __FILE__)
|
2
|
-
require 'awesome_print'
|
3
|
-
require 'archivesspace/client'
|
4
|
-
|
5
|
-
# default client connection: localhost:8089, admin, admin
|
6
|
-
client = ArchivesSpace::Client.new.login
|
7
|
-
|
8
|
-
# todo ... example of assignment using CSV
|