dpn-client 1.3.1 → 2.0.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 55ea45ebadcb8d3e8af3c0a8597ec31f8bb49f23
4
- data.tar.gz: ad3e2f35e5572ece674d8cb48c3e1adae5a3903c
3
+ metadata.gz: 29bc947b3dc7eae26d526bf33466eff74b1faace
4
+ data.tar.gz: 717644a7872c356e8b578d7d79fd7d8897554806
5
5
  SHA512:
6
- metadata.gz: df13b7da524edb3e8bf7fd7e1d4b34ac4eef89b7d012b24d59c7b33e889afae7dbcc5e79809a13e94497670545ae3344cf613cef3ee103c5394f51db86d1aee0
7
- data.tar.gz: d70510caeb2651423862d6a895b097a7cbc8fcbb312e733cf0b4505030f0d0a8afd5952cc59e3f7f0bc4ea26bf9e6c29b619d52ff7351166cdcc8ff28a0f1f51
6
+ metadata.gz: 12a3cfcb42b6114c6725d0516609fe635d9ce63f4319265a383a516f21e14f5784e5fbc09d0c226c353abb9916dc45a388775108142f4f782a2d48a360d22166
7
+ data.tar.gz: 32783328da098a1acc306abb002e5c71ea8405b380b342e0953383a682a0dee6d54b75b566a1bdd3f33893c484e32c5f5489ed2461be89c942e1e267cb6f725d
data/.gitignore CHANGED
@@ -1,6 +1,9 @@
1
1
  # Ignore bundler config.
2
2
  /.bundle
3
3
 
4
+ # Ignore gem packages
5
+ /pkg
6
+
4
7
  # Ignore the default SQLite database.
5
8
  /db/*.sqlite3
6
9
  /db/*.sqlite3-journal
data/Gemfile.lock CHANGED
@@ -1,8 +1,8 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- dpn-client (1.3.1)
5
- httpclient (~> 2.6.0.1)
4
+ dpn-client (2.0.1)
5
+ httpclient (~> 2.8.0)
6
6
 
7
7
  GEM
8
8
  remote: https://rubygems.org/
@@ -10,12 +10,21 @@ GEM
10
10
  addressable (2.3.8)
11
11
  codeclimate-test-reporter (0.4.8)
12
12
  simplecov (>= 0.7.1, < 1.0.0)
13
+ coderay (1.1.0)
13
14
  crack (0.4.2)
14
15
  safe_yaml (~> 1.0.0)
15
16
  diff-lcs (1.2.5)
16
17
  docile (1.1.5)
17
- httpclient (2.6.0.1)
18
+ httpclient (2.8.2.4)
18
19
  json (1.8.3)
20
+ method_source (0.8.2)
21
+ pry (0.10.3)
22
+ coderay (~> 1.1.0)
23
+ method_source (~> 0.8.1)
24
+ slop (~> 3.4)
25
+ pry-doc (0.8.0)
26
+ pry (~> 0.9)
27
+ yard (~> 0.8)
19
28
  rake (10.4.2)
20
29
  rspec (3.3.0)
21
30
  rspec-core (~> 3.3.0)
@@ -36,6 +45,7 @@ GEM
36
45
  json (~> 1.8)
37
46
  simplecov-html (~> 0.10.0)
38
47
  simplecov-html (0.10.0)
48
+ slop (3.6.0)
39
49
  webmock (1.21.0)
40
50
  addressable (>= 2.3.6)
41
51
  crack (>= 0.3.2)
@@ -48,10 +58,12 @@ DEPENDENCIES
48
58
  bundler (~> 1.10)
49
59
  codeclimate-test-reporter
50
60
  dpn-client!
61
+ pry
62
+ pry-doc
51
63
  rake (~> 10.0)
52
64
  rspec
53
65
  webmock
54
66
  yard
55
67
 
56
68
  BUNDLED WITH
57
- 1.11.2
69
+ 1.12.5
data/README.md CHANGED
@@ -9,8 +9,7 @@
9
9
  Add this line to your application's Gemfile:
10
10
 
11
11
  ```ruby
12
- gem 'dpn-client', :git => 'https://github.com/dpn-admin/dpn-client.git'
13
-
12
+ gem 'dpn-client'
14
13
  ```
15
14
 
16
15
  And then execute:
data/dpn-client.gemspec CHANGED
@@ -24,9 +24,11 @@ Gem::Specification.new do |spec|
24
24
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
25
25
  spec.require_paths = ["lib"]
26
26
 
27
- spec.add_runtime_dependency "httpclient", "~> 2.6.0.1"
27
+ spec.add_runtime_dependency "httpclient", "~> 2.8.0"
28
28
 
29
29
  spec.add_development_dependency "bundler", "~> 1.10"
30
+ spec.add_development_dependency "pry"
31
+ spec.add_development_dependency "pry-doc"
30
32
  spec.add_development_dependency "rake", "~> 10.0"
31
33
  spec.add_development_dependency "rspec"
32
34
  spec.add_development_dependency "yard"
@@ -5,10 +5,14 @@
5
5
 
6
6
  require "dpn/client/agent/configuration"
7
7
  require "dpn/client/agent/connection"
8
- require "dpn/client/agent/node"
9
8
  require "dpn/client/agent/bag"
10
- require "dpn/client/agent/replicate"
9
+ require "dpn/client/agent/digest"
10
+ require "dpn/client/agent/fixity_check"
11
+ require "dpn/client/agent/ingest"
11
12
  require "dpn/client/agent/member"
13
+ require "dpn/client/agent/node"
14
+ require "dpn/client/agent/replicate"
15
+ require "dpn/client/agent/restore"
12
16
 
13
17
  module DPN
14
18
  module Client
@@ -16,10 +20,14 @@ module DPN
16
20
  include DPN::Client::Agent::Configuration
17
21
  include DPN::Client::Agent::Connection
18
22
 
19
- include DPN::Client::Agent::Node
20
23
  include DPN::Client::Agent::Bag
21
- include DPN::Client::Agent::Replicate
24
+ include DPN::Client::Agent::Digest
25
+ include DPN::Client::Agent::FixityCheck
26
+ include DPN::Client::Agent::Ingest
22
27
  include DPN::Client::Agent::Member
28
+ include DPN::Client::Agent::Node
29
+ include DPN::Client::Agent::Replicate
30
+ include DPN::Client::Agent::Restore
23
31
 
24
32
  def initialize(options = {})
25
33
  self.configure(options)
@@ -15,40 +15,28 @@ module DPN
15
15
  # before this date.
16
16
  # @option options [DateTime String] :after (nil) Include only entries last modified
17
17
  # after this date.
18
+ # @option options [String] :bag_type (nil) One of 'D', 'R', 'I', for data, rights, and
19
+ # interpretive, respectively.
18
20
  # @option options [String] :admin_node (nil) Namespace of the admin_node of the bag.
21
+ # @option options [String] :ingest_node (nil) Namespace of the ingest_node of the bag.
19
22
  # @option options [String] :member (nil) The UUID of the member that owns or is vested
20
23
  # in this bag.
21
- # @option options [String] :bag_type (nil) One of 'D', 'R', 'I', for data, rights, and
22
- # interpretive, respectively.
23
- # @yield [Response] Optional block to process individual bag.
24
- # @return [Array<Hash>] Array of all bag data. Generated and returned
25
- # only if no block is passed.
24
+ # @option options [String] :first_version_uuid (nil) UUIDv4 of the bag's first version.
25
+ # @option options [Array<String>] :replicated_by ([]) Namespaces of replicating nodes; the
26
+ # result is the UNION of these filters.
27
+ # @yield [Response] Block to process each individual bag.
28
+ # @see Connection#paginate
26
29
  def bags(options = {page_size: 25}, &block)
27
- [:after, :before].each do |date_field|
28
- if options[date_field].is_a?(DateTime)
29
- options[date_field] = options[:date_field].new_offset(0).strftime(DPN::Client.time_format)
30
- end
31
- end
32
-
33
- return paginate_each "/bag/", options, options[:page_size], &block
30
+ paginate_each "/bag/", options, options[:page_size], &block
34
31
  end
35
32
 
36
33
 
37
- # @overload bag(uuid, &block)
38
- # Get a specific bag
39
- # @param [String] uuid UUID of the bag.
40
- # @yield [Response]
41
- # @return [Response]
42
- # @overload bag(options)
43
- # Alias for #bags
44
- # @return [Array<Hash>]
45
- # @see #bags
46
- def bag(uuid = nil, options = {page_size: 25}, &block)
47
- if uuid
48
- get "/bag/#{uuid}/", nil, &block
49
- else
50
- bags(options, &block)
51
- end
34
+ # Get a specific bag
35
+ # @param [String] uuid UUID of the bag.
36
+ # @yield [Response]
37
+ # @return [Response]
38
+ def bag(uuid, &block)
39
+ get "/bag/#{uuid}/", nil, &block
52
40
  end
53
41
 
54
42
 
@@ -57,7 +45,7 @@ module DPN
57
45
  # @yield [Response]
58
46
  # @return [Response]
59
47
  def create_bag(bag, &block)
60
- post "/bag", bag, &block
48
+ post "/bag/", bag, &block
61
49
  end
62
50
 
63
51
 
@@ -26,6 +26,13 @@ module DPN
26
26
  :per_page, :user_agent
27
27
  attr_writer :logger
28
28
 
29
+ def api_ver
30
+ @api_ver ||= "api-v#{DPN::Client.api_version}"
31
+ end
32
+
33
+ def base_url
34
+ @api_root
35
+ end
29
36
 
30
37
  # Apply the options hash to the configuration
31
38
  def configure(options_hash = {})
@@ -50,9 +57,6 @@ module DPN
50
57
  end
51
58
  alias_method :setup, :reset
52
59
 
53
- def base_url
54
- File.join(@api_root, "api-v#{DPN::Client.api_version}")
55
- end
56
60
 
57
61
  def logger
58
62
  @logger ||= NullLogger.new
@@ -77,4 +81,4 @@ module DPN
77
81
  end
78
82
  end
79
83
  end
80
- end
84
+ end
@@ -57,7 +57,7 @@ module DPN
57
57
  end
58
58
 
59
59
 
60
- # Make a one or more GET requests, fetching the next
60
+ # Make one or more GET requests, fetching the next
61
61
  # page of results one page at a time, so long as the
62
62
  # response indicates there is another page.
63
63
  # @param url [String] The path, relative to base_url
@@ -73,6 +73,12 @@ module DPN
73
73
  query ||= {}
74
74
  query = query.merge({ :page_size => page_size, :page => 1})
75
75
 
76
+ [:after, :before].each do |date_field|
77
+ if query[date_field].is_a?(DateTime)
78
+ query[date_field] = query[:date_field].new_offset(0).strftime(DPN::Client.time_format)
79
+ end
80
+ end
81
+
76
82
  response = get(url, query) # pass an empty block so we can call the block manually on :results
77
83
  yield response
78
84
  while response.success? && response[:next] && response[:results].empty? == false
@@ -93,15 +99,16 @@ module DPN
93
99
  # @param page_size [Fixnum] The number of results to request
94
100
  # from each page.
95
101
  # @yield [Response] Mandatory block that takes each individual
96
- # result wrapped in a response object as a parameter. If a
97
- # request is unsuccessful, the failed response is yielded.
102
+ # result wrapped in a response object as a parameter. Should
103
+ # a request receive an error, the error will be wrapped in
104
+ # a response object and yielded.
98
105
  def paginate_each(url, query, page_size, &block)
99
- raise ArgumentError, "Must pass a block" unless block_given?
106
+ raise ArgumentError, "Block required" unless block_given?
100
107
  paginate(url, query, (page_size || 25)) do |response|
101
108
  if response.success?
102
109
  logger.info("Response has #{response[:results].size} results.")
103
110
  response[:results].each do |result|
104
- yield Response.from_data(response.status, result)
111
+ yield Response.from_data(response.status, result)
105
112
  end
106
113
  else
107
114
  yield response
@@ -112,6 +119,18 @@ module DPN
112
119
 
113
120
  protected
114
121
 
122
+ def connection
123
+ @connection ||= ::HTTPClient.new({
124
+ agent_name: user_agent,
125
+ base_url: base_url,
126
+ default_header: {
127
+ "Content-Type" => "application/json",
128
+ "Authorization" => "Token #{auth_token}"
129
+ },
130
+ force_basic_auth: true
131
+ })
132
+ end
133
+
115
134
  def request(method, url, query, body, &block)
116
135
  url, extra_query = parse_url(url)
117
136
  query ||= {}
@@ -120,50 +139,32 @@ module DPN
120
139
  body: body.to_json,
121
140
  follow_redirect: true
122
141
  }
123
-
124
- logger.info("Sending #{method.upcase}: #{File.join(base_url, fix_url(url))} #{options} ")
125
- raw_response = connection.request method, fix_url(url), options
142
+ logger.info("Sending #{method.upcase}: #{File.join(base_url, url)} #{options} ")
143
+ raw_response = connection.request method, url, options
126
144
  logger.debug("Received #{raw_response.inspect}")
127
145
  response = DPN::Client::Response.new(raw_response)
128
146
  logger.info("Received #{response.status}")
129
147
  if block_given?
130
148
  yield response
131
149
  end
132
-
133
- return response
150
+ response
134
151
  end
135
152
 
136
-
137
153
  def parse_url(raw_url)
138
154
  url, query = raw_url.split("?", 2)
139
- url = File.join url, ""
140
- if query
141
- query = URI::decode_www_form(query).to_h
142
- else
143
- query = {}
144
- end
145
- return url, query
146
- end
147
-
148
-
149
- def connection
150
- @connection ||= ::HTTPClient.new({
151
- agent_name: user_agent,
152
- base_url: base_url,
153
- default_header: {
154
- "Content-Type" => "application/json",
155
- "Authorization" => "Token #{auth_token}"
156
- },
157
- force_basic_auth: true
158
- })
155
+ query = if query
156
+ URI.decode_www_form(query).to_h
157
+ else
158
+ {}
159
+ end
160
+ return fix_url(url), query
159
161
  end
160
162
 
161
-
162
163
  def fix_url(url)
163
- File.join url, "/"
164
+ url = File.join(api_ver, url) unless url.include?(api_ver)
165
+ File.join "/", url, "/"
164
166
  end
165
167
 
166
-
167
168
  # Convert array values to csv
168
169
  # Only goes one level deep.
169
170
  # @param [Hash] hash
@@ -180,4 +181,4 @@ module DPN
180
181
  end
181
182
  end
182
183
  end
183
- end
184
+ end
@@ -0,0 +1,60 @@
1
+ # Copyright (c) 2015 The Regents of the University of Michigan.
2
+ # All Rights Reserved.
3
+ # Licensed according to the terms of the Revised BSD License
4
+ # See LICENSE.md for details.
5
+
6
+ module DPN
7
+ module Client
8
+ class Agent
9
+
10
+ # Operations on the digest resource.
11
+ module Digest
12
+
13
+ # Get the digests index
14
+ # @param [Hash] options
15
+ # @option options [Fixnum] :page_size (25) Number of results per page
16
+ # @option options [DateTime String] :before (nil) Include only entries last modified
17
+ # before this date.
18
+ # @option options [DateTime String] :after (nil) Include only entries last modified
19
+ # after this date.
20
+ # @yield [Response] Block to process each individual result.
21
+ def digests(options = {page_size: 25}, &block)
22
+ paginate_each "/digest/", options, options[:page_size], &block
23
+ end
24
+
25
+
26
+ # Get the digests for a specific bag
27
+ # @option options [Fixnum] :page_size (25) Number of results per page
28
+ # @option options [DateTime String] :before (nil) Include only entries last modified
29
+ # before this date.
30
+ # @option options [DateTime String] :after (nil) Include only entries last modified
31
+ # after this date.
32
+ # @yield [Response] Block to process each individual result.
33
+ def bag_digests(bag, options = {page_size: 25}, &block)
34
+ paginate_each "/bag/#{bag}/digest/", options, options[:page_size], &block
35
+ end
36
+
37
+
38
+ # Get a specific digest
39
+ # @param [String] bag UUIDv4 of the bag.
40
+ # @param [String] algorithm Name of the algorithm.
41
+ # @yield [Response] Optional block to process the response.
42
+ # @return [Response]
43
+ def digest(bag, algorithm, &block)
44
+ get "/bag/#{bag}/digest/#{algorithm}/", nil, &block
45
+ end
46
+
47
+
48
+ # Create a digest
49
+ # @param [Hash] digest Body of the digest
50
+ # @yield [Response]
51
+ # @return [Response]
52
+ def create_digest(digest, &block)
53
+ post "/bag/#{digest[:bag]}/digest/", digest, &block
54
+ end
55
+
56
+ end
57
+
58
+ end
59
+ end
60
+ end
@@ -0,0 +1,41 @@
1
+ # Copyright (c) 2015 The Regents of the University of Michigan.
2
+ # All Rights Reserved.
3
+ # Licensed according to the terms of the Revised BSD License
4
+ # See LICENSE.md for details.
5
+
6
+ module DPN
7
+ module Client
8
+ class Agent
9
+
10
+ # Operations on the fixity_check resource.
11
+ module FixityCheck
12
+
13
+ # Get the fixity_check index
14
+ # @param [Hash] options
15
+ # @option options [Fixnum] :page_size (25) Number of results per page
16
+ # @option options [DateTime String] :before (nil) Include only entries last modified
17
+ # before this date.
18
+ # @option options [DateTime String] :after (nil) Include only entries last modified
19
+ # after this date.
20
+ # @option options [String] bag (nil) Filter by a specific bag's UUID.
21
+ # @option options [Boolean] latest (false) Request latest results only.
22
+ # @option options [String] :node (nil) Namespace of the node.
23
+ # @yield [Response] Block to process each individual result.
24
+ def fixity_checks(options = {page_size: 25}, &block)
25
+ paginate_each "/fixity_check/", options, options[:page_size], &block
26
+ end
27
+
28
+
29
+ # Create a fixity_check
30
+ # @param [Hash] fixity_check Body of the fixity_check
31
+ # @yield [Response]
32
+ # @return [Response]
33
+ def create_fixity_check(fixity_check, &block)
34
+ post "/fixity_check/", fixity_check, &block
35
+ end
36
+
37
+ end
38
+
39
+ end
40
+ end
41
+ end
@@ -0,0 +1,42 @@
1
+ # Copyright (c) 2015 The Regents of the University of Michigan.
2
+ # All Rights Reserved.
3
+ # Licensed according to the terms of the Revised BSD License
4
+ # See LICENSE.md for details.
5
+
6
+ module DPN
7
+ module Client
8
+ class Agent
9
+
10
+ # Operations on the ingest resource.
11
+ module Ingest
12
+
13
+ # Get the ingest index
14
+ # @param [Hash] options
15
+ # @option options [Fixnum] :page_size (25) Number of results per page
16
+ # @option options [DateTime String] :before (nil) Include only entries last modified
17
+ # before this date.
18
+ # @option options [DateTime String] :after (nil) Include only entries last modified
19
+ # after this date.
20
+ # @option options [String] bag (nil) Filter by a specific bag's UUID.
21
+ # @option options [Boolean] latest (false) Request latest results only.
22
+ # @option options [Boolean] ingested (nil) Filter by value of the ingested field.
23
+ # @option options [String] :node (nil) Namespace of the node.
24
+ # @yield [Response] Block to process each individual result.
25
+ def ingests(options = {page_size: 25}, &block)
26
+ paginate_each "/ingest/", options, options[:page_size], &block
27
+ end
28
+
29
+
30
+ # Create a ingest
31
+ # @param [Hash] ingest Body of the ingest
32
+ # @yield [Response]
33
+ # @return [Response]
34
+ def create_ingest(ingest, &block)
35
+ post "/ingest/", ingest, &block
36
+ end
37
+
38
+ end
39
+
40
+ end
41
+ end
42
+ end
@@ -13,29 +13,41 @@ module DPN
13
13
  # Get the members index
14
14
  # @param [Hash] options
15
15
  # @option options [Fixnum] :page_size (25) Number of members per page
16
- # @yield [Response] Optional block to process each individual member.
17
- # @return [Array<Hash>] Array of all member data. Generated and returned
18
- # only if no block is passed.
16
+ # @option options [DateTime String] :before (nil) Include only entries last modified
17
+ # before this date.
18
+ # @option options [DateTime String] :after (nil) Include only entries last modified
19
+ # after this date.
20
+ # @yield [Response] Block to process each individual member.
19
21
  def members(options = {page_size: 25}, &block)
20
- return paginate_each "/member/", options, options[:page_size], &block
22
+ paginate_each "/member/", options, options[:page_size], &block
21
23
  end
22
24
 
23
25
 
24
- # @overload member(uuid, &block)
25
- # Get a specific member
26
- # @param [String] uuid UUIDv4 of the member.
27
- # @yield [Response] Optional block to process the response.
28
- # @return [Response]
29
- # @overload member(options, &block)
30
- # Alias for #members
31
- # @return [Array<Hash>]
32
- # @see #members
33
- def member(uuid = nil, options = {page_size: 25}, &block)
34
- if uuid
35
- get "/member/#{fix_uuid(uuid)}/", nil, &block
36
- else
37
- members(options, &block)
38
- end
26
+ # Get a specific member
27
+ # @param [String] member_id UUIDv4 of the member.
28
+ # @yield [Response] Optional block to process the response.
29
+ # @return [Response]
30
+ def member(member_id, &block)
31
+ get "/member/#{member_id}/", nil, &block
32
+ end
33
+
34
+
35
+ # Get a member's bags
36
+ # @param [String] member_id The specific member's member_id
37
+ # @param [Hash] options
38
+ # @option options [Fixnum] :page_size (25) Number of entries per page
39
+ # @option options [DateTime String] :before (nil) Include only entries last modified
40
+ # before this date.
41
+ # @option options [DateTime String] :after (nil) Include only entries last modified
42
+ # after this date.
43
+ # @option options [String] :admin_node (nil) Namespace of the admin_node of the bag.
44
+ # @option options [String] :bag_type (nil) One of 'D', 'R', 'I', for data, rights, and
45
+ # interpretive, respectively.
46
+ # @yield [Response] Optional block to process individual bag.
47
+ # @return [Array<Hash>] Array of all bag data. Generated and returned
48
+ # only if no block is passed.
49
+ def member_bags(member_id, options = {page_size: 25}, &block)
50
+ paginate_each "/member/#{member_id}/bags/", options, options[:page_size], &block
39
51
  end
40
52
 
41
53
 
@@ -53,34 +65,19 @@ module DPN
53
65
  # @yield [Response]
54
66
  # @return [Response]
55
67
  def update_member(member, &block)
56
- put "/member/#{fix_uuid(member[:uuid])}/", member, &block
68
+ put "/member/#{member[:member_id]}/", member, &block
57
69
  end
58
70
 
59
71
 
60
72
  # Delete a member
61
- # @param [String] uuid UUIDv4 of the member.
73
+ # @param [String] member_id UUIDv4 of the member.
62
74
  # @yield [Response]
63
75
  # @return [Response]
64
- def delete_member(uuid, &block)
65
- delete "/member/#{fix_uuid(uuid)}/", &block
76
+ def delete_member(member_id, &block)
77
+ delete "/member/#{member_id}/", &block
66
78
  end
67
79
 
68
80
 
69
- private
70
- # Add dashes to a uuid if they are missing
71
- def fix_uuid(uuid)
72
- if uuid && uuid.size == 32
73
- unless uuid.include?("-")
74
- uuid.insert(8, "-") # 9th, 14th, 19th and 24th
75
- uuid.insert(13, "-")
76
- uuid.insert(18, "-")
77
- uuid.insert(23, "-")
78
- end
79
- end
80
- uuid.downcase
81
- end
82
-
83
-
84
81
  end
85
82
 
86
83
  end
@@ -10,41 +10,12 @@ module DPN
10
10
  # Operations on the node resource.
11
11
  module Node
12
12
 
13
- # Get the nodes index
14
- # @param [Hash] options
15
- # @option options [Fixnum] :page_size (25) Number of nodes per page
16
- # @yield [Response] Optional block to process each individual node.
17
- # @return [Array<Hash>] Array of all node data. Generated and returned
18
- # only if no block is passed.
19
- def nodes(options = {page_size: 25}, &block)
20
- return paginate_each "/node/", options, options[:page_size], &block
21
- end
22
-
23
-
24
- # @overload node(namespace, &block)
25
- # Get a specific node
26
- # @param [String] namespace Namespace of the node.
27
- # @yield [Response] Optional block to process the response.
28
- # @return [Response]
29
- # @overload node(options, &block)
30
- # Alias for #nodes
31
- # @return [Array<Hash>]
32
- # @see #nodes
33
- def node(namespace = nil, options = {page_size: 25}, &block)
34
- if namespace
35
- get "/node/#{namespace}/", nil, &block
36
- else
37
- nodes(options, &block)
38
- end
39
- end
40
-
41
-
42
- # Create a node
43
- # @param [Hash] node Body of the node
44
- # @yield [Response]
13
+ # Get a specific node
14
+ # @param [String] namespace Namespace of the node.
15
+ # @yield [Response] Optional block to process the response.
45
16
  # @return [Response]
46
- def create_node(node, &block)
47
- post "/node/", node, &block
17
+ def node(namespace, &block)
18
+ get "/node/#{namespace}/", nil, &block
48
19
  end
49
20
 
50
21
 
@@ -57,14 +28,6 @@ module DPN
57
28
  end
58
29
 
59
30
 
60
- # Delete a node
61
- # @param [String] namespace Namespace of the node.
62
- # @yield [Response]
63
- # @return [Response]
64
- def delete_node(namespace, &block)
65
- delete "/node/#{namespace}/", &block
66
- end
67
-
68
31
  end
69
32
  end
70
33
  end
@@ -11,25 +11,20 @@ module DPN
11
11
  # Get the replication request index
12
12
  # @param [Hash] options
13
13
  # @option options [Fixnum] :page_size (25) Number of entries per page
14
- # @option options [DateTime,String] :after (nil) Include only entries last modified
15
- # after this date. Takes a properly formatted string, or a datetime.
16
- # @option options [String] uuid (nil) Filter by a specific bag's UUID.
17
- # @option options [String] status (nil) Filter by status.
18
- # @option options [Boolean] fixity_accept (nil) Filter by the value of fixity_accept.
19
- # @option options [Boolean] bag_valid (nil) Filter by the value of bag_valid.
20
- # @option options [String] :from_node (nil) Namespace of the from_node of the bag.
14
+ # @option options [DateTime String] :before (nil) Include only entries last modified
15
+ # before this date.
16
+ # @option options [DateTime String] :after (nil) Include only entries last modified
17
+ # after this date.
18
+ # @option options [String] bag (nil) Filter by a specific bag's UUID.
21
19
  # @option options [String] :to_node (nil) Namespace of the to_node of the bag.
22
- # @option options [String] :order_by (nil) Comma-separated list of strings to order the
23
- # result by. Accepted values are 'created_at' and 'updated_at'
24
- # @yield [Response] Optional block to process each individual replication.
25
- # @return [Array<Hash>] Array of all replication data. Generated and returned
26
- # only if no block is passed.
20
+ # @option options [String] :from_node (nil) Namespace of the from_node of the bag.
21
+ # @option options [Boolean] store_requested (nil) Filter by the value of store_requested.
22
+ # @option options [Boolean] stored (nil) Filter by the value of stored.
23
+ # @option options [Boolean] cancelled (nil) Filter by the value of cancelled.
24
+ # @option options [String] cancel_reason (nil) Filter by cancel_reason.
25
+ # @yield [Response] Block to process each individual replication.
27
26
  def replications(options = {page_size: 25}, &block)
28
- if options[:after].is_a?(DateTime)
29
- options[:after] = options[:after].new_offset(0).strftime(DPN::Client.time_format)
30
- end
31
-
32
- return paginate_each "/replicate/", options, options[:page_size], &block
27
+ paginate_each "/replicate/", options, options[:page_size], &block
33
28
  end
34
29
 
35
30
 
@@ -42,12 +37,14 @@ module DPN
42
37
  # Alias for #replications
43
38
  # @return [Array<Hash>]
44
39
  # @see #replications
45
- def replicate(replication_id = nil, options = {page_size: 25}, &block)
46
- if replication_id
47
- get "/replicate/#{replication_id}/", nil, &block
48
- else
49
- replications(options, &block)
50
- end
40
+ def replicate(replication_id, &block)
41
+ get "/replicate/#{replication_id}/", nil, &block
42
+ end
43
+
44
+
45
+ # Alias of #replicate
46
+ def replication(replication_id, &block)
47
+ replicate replication_id, &block
51
48
  end
52
49
 
53
50
 
@@ -56,7 +53,7 @@ module DPN
56
53
  # @yield [Response]
57
54
  # @return [Response]
58
55
  def create_replication(request, &block)
59
- post "/replicate", request, &block
56
+ post "/replicate/", request, &block
60
57
  end
61
58
 
62
59
 
@@ -68,15 +65,6 @@ module DPN
68
65
  put "/replicate/#{request[:replication_id]}/", request, &block
69
66
  end
70
67
 
71
-
72
- # Delete a replication request
73
- # @param [String] replication_id The replication_id of the replication request
74
- # @yield [Response]
75
- # @return [Response]
76
- def delete_replication(replication_id, &block)
77
- delete "/replicate/#{replication_id}/", &block
78
- end
79
-
80
68
  end
81
69
  end
82
70
  end
@@ -0,0 +1,60 @@
1
+ # Copyright (c) 2015 The Regents of the University of Michigan.
2
+ # All Rights Reserved.
3
+ # Licensed according to the terms of the Revised BSD License
4
+ # See LICENSE.md for details.
5
+
6
+ module DPN
7
+ module Client
8
+ class Agent
9
+ module Restore
10
+
11
+ # Get the restore request index
12
+ # @param [Hash] options
13
+ # @option options [Fixnum] :page_size (25) Number of entries per page
14
+ # @option options [DateTime String] :before (nil) Include only entries last modified
15
+ # before this date.
16
+ # @option options [DateTime String] :after (nil) Include only entries last modified
17
+ # after this date.
18
+ # @option options [String] bag (nil) Filter by a specific bag's UUID.
19
+ # @option options [String] :to_node (nil) Namespace of the to_node of the bag.
20
+ # @option options [String] :from_node (nil) Namespace of the from_node of the bag.
21
+ # @option options [Boolean] accepted (nil) Filter by the value of accepted.
22
+ # @option options [Boolean] finished (nil) Filter by the value of finished.
23
+ # @option options [Boolean] cancelled (nil) Filter by the value of cancelled.
24
+ # @option options [String] cancel_reason (nil) Filter by cancel_reason.
25
+ # @yield [Response] Block to process each individual result.
26
+ def restores(options = {page_size: 25}, &block)
27
+ paginate_each "/restore/", options, options[:page_size], &block
28
+ end
29
+
30
+
31
+ # Get a specific restore request.
32
+ # @param [String] restore_id
33
+ # @yield [Response]
34
+ # @return [Response]
35
+ def restore(restore_id, &block)
36
+ get "/restore/#{restore_id}/", nil, &block
37
+ end
38
+
39
+
40
+ # Create a restore request
41
+ # @param [Hash] request Body of the restore request
42
+ # @yield [Response]
43
+ # @return [Response]
44
+ def create_restore(request, &block)
45
+ post "/restore/", request, &block
46
+ end
47
+
48
+
49
+ # Update a restore request
50
+ # @param [Hash] request Body of the restore request
51
+ # @yield [Response]
52
+ # @return [Response]
53
+ def update_restore(request, &block)
54
+ put "/restore/#{request[:restore_id]}/", request, &block
55
+ end
56
+
57
+ end
58
+ end
59
+ end
60
+ end
@@ -24,8 +24,6 @@ module DPN
24
24
  self.new.load_from_data!(status, body)
25
25
  end
26
26
 
27
- attr_reader :status, :body
28
-
29
27
 
30
28
  def json
31
29
  @cached_json ||= @body.to_json
@@ -83,4 +81,4 @@ module DPN
83
81
 
84
82
  end
85
83
  end
86
- end
84
+ end
@@ -5,6 +5,6 @@
5
5
 
6
6
  module DPN
7
7
  module Client
8
- VERSION = "1.3.1"
8
+ VERSION = "2.0.1"
9
9
  end
10
10
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dpn-client
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.1
4
+ version: 2.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Bryan Hockey
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-08-12 00:00:00.000000000 Z
11
+ date: 2016-12-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: httpclient
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: 2.6.0.1
19
+ version: 2.8.0
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: 2.6.0.1
26
+ version: 2.8.0
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: bundler
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -38,6 +38,34 @@ dependencies:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
40
  version: '1.10'
41
+ - !ruby/object:Gem::Dependency
42
+ name: pry
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: pry-doc
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'
41
69
  - !ruby/object:Gem::Dependency
42
70
  name: rake
43
71
  requirement: !ruby/object:Gem::Requirement
@@ -129,9 +157,13 @@ files:
129
157
  - lib/dpn/client/agent/bag.rb
130
158
  - lib/dpn/client/agent/configuration.rb
131
159
  - lib/dpn/client/agent/connection.rb
160
+ - lib/dpn/client/agent/digest.rb
161
+ - lib/dpn/client/agent/fixity_check.rb
162
+ - lib/dpn/client/agent/ingest.rb
132
163
  - lib/dpn/client/agent/member.rb
133
164
  - lib/dpn/client/agent/node.rb
134
165
  - lib/dpn/client/agent/replicate.rb
166
+ - lib/dpn/client/agent/restore.rb
135
167
  - lib/dpn/client/response.rb
136
168
  - lib/dpn/client/version.rb
137
169
  homepage: https://github.com/dpn-admin/dpn-client