Class: ArchivesSpace::Client
- Inherits:
-
Object
- Object
- ArchivesSpace::Client
- Includes:
- Pagination, Task
- Defined in:
- lib/archivesspace/client/cli.rb,
lib/archivesspace/client/client.rb,
lib/archivesspace/client/version.rb,
lib/archivesspace/client/cli/exec.rb,
lib/archivesspace/client/cli/version.rb
Defined Under Namespace
Modules: CLI
Constant Summary collapse
- NAME =
"ArchivesSpaceClient"- TOKEN =
"X-ArchivesSpace-Session"- VERSION =
"0.5.0"
Constants included from Pagination
Instance Attribute Summary collapse
-
#config ⇒ Object
readonly
Returns the value of attribute config.
-
#context ⇒ Object
readonly
Returns the value of attribute context.
-
#token ⇒ Object
Returns the value of attribute token.
Instance Method Summary collapse
- #backend_version ⇒ Object
- #delete(path) ⇒ Object
- #get(path, options = {}) ⇒ Object
-
#initialize(config = Configuration.new) ⇒ Client
constructor
A new instance of Client.
- #post(path, payload, params = {}) ⇒ Object
- #put(path, payload, params = {}) ⇒ Object
-
#repository(id) ⇒ Object
Scoping requests.
- #use_global_repository ⇒ Object
Methods included from Task
#group_user_assignment, #login, #password_reset
Methods included from Pagination
Constructor Details
#initialize(config = Configuration.new) ⇒ Client
Returns a new instance of Client.
14 15 16 17 18 19 20 21 22 |
# File 'lib/archivesspace/client/client.rb', line 14 def initialize(config = Configuration.new) unless config.is_a? ArchivesSpace::Configuration raise ConfigurationError, "expected ArchivesSpace::Configuration, got #{config.class}" end @config = config @context = nil @token = nil end |
Instance Attribute Details
#config ⇒ Object (readonly)
Returns the value of attribute config.
9 10 11 |
# File 'lib/archivesspace/client/client.rb', line 9 def config @config end |
#context ⇒ Object (readonly)
Returns the value of attribute context.
9 10 11 |
# File 'lib/archivesspace/client/client.rb', line 9 def context @context end |
#token ⇒ Object
Returns the value of attribute token.
8 9 10 |
# File 'lib/archivesspace/client/client.rb', line 8 def token @token end |
Instance Method Details
#backend_version ⇒ Object
24 25 26 |
# File 'lib/archivesspace/client/client.rb', line 24 def backend_version get "version" end |
#delete(path) ⇒ Object
40 41 42 |
# File 'lib/archivesspace/client/client.rb', line 40 def delete(path) request "DELETE", path end |
#get(path, options = {}) ⇒ Object
28 29 30 |
# File 'lib/archivesspace/client/client.rb', line 28 def get(path, = {}) request "GET", path, end |
#post(path, payload, params = {}) ⇒ Object
32 33 34 |
# File 'lib/archivesspace/client/client.rb', line 32 def post(path, payload, params = {}) request "POST", path, {body: payload.to_json, query: params} end |
#put(path, payload, params = {}) ⇒ Object
36 37 38 |
# File 'lib/archivesspace/client/client.rb', line 36 def put(path, payload, params = {}) request "PUT", path, {body: payload.to_json, query: params} end |
#repository(id) ⇒ Object
Scoping requests
45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 |
# File 'lib/archivesspace/client/client.rb', line 45 def repository(id) return use_global_repository if id.nil? begin Integer(id) rescue ArgumentError, TypeError raise RepositoryIdError, "Invalid Repository id: #{id}" end new_context = "repositories/#{id}" return @context = new_context unless block_given? previous = @context @context = new_context begin yield ensure @context = previous end end |
#use_global_repository ⇒ Object
66 67 68 |
# File 'lib/archivesspace/client/client.rb', line 66 def use_global_repository @context = nil end |