Class: Dor::Services::Client
- Inherits:
-
Object
- Object
- Dor::Services::Client
- Includes:
- Singleton
- Defined in:
- lib/dor/services/client.rb,
lib/dor/services/client/sdr.rb,
lib/dor/services/client/files.rb,
lib/dor/services/client/object.rb,
lib/dor/services/client/embargo.rb,
lib/dor/services/client/objects.rb,
lib/dor/services/client/version.rb,
lib/dor/services/client/metadata.rb,
lib/dor/services/client/workspace.rb,
lib/dor/services/client/collections.rb,
lib/dor/services/client/release_tags.rb,
lib/dor/services/client/object_version.rb,
lib/dor/services/client/virtual_objects.rb,
lib/dor/services/client/versioned_service.rb,
lib/dor/services/client/background_job_results.rb,
lib/dor/services/client/error_faraday_middleware.rb,
lib/dor/services/client/response_error_formatter.rb
Defined Under Namespace
Classes: BackgroundJobResults, Collections, ConnectionFailed, Embargo, Error, ErrorFaradayMiddleware, Files, MalformedResponse, Metadata, NotFoundResponse, Object, ObjectVersion, Objects, ReleaseTags, ResponseErrorFormatter, SDR, UnexpectedResponse, VersionedService, VirtualObjects, Workspace
Constant Summary collapse
- DEFAULT_VERSION =
'v1'
- TOKEN_HEADER =
'Authorization'
- VERSION =
'3.3.0'
Instance Attribute Summary collapse
-
#connection ⇒ Object
writeonly
Sets the attribute connection.
-
#token ⇒ Object
writeonly
Sets the attribute token.
-
#url ⇒ Object
writeonly
Sets the attribute url.
Class Method Summary collapse
Instance Method Summary collapse
-
#background_job_results ⇒ Dor::Services::Client::BackgroundJobResults
An instance of the ‘Client::BackgroundJobResults` class.
-
#object(object_identifier) ⇒ Dor::Services::Client::Object
An instance of the ‘Client::Object` class.
-
#objects ⇒ Dor::Services::Client::Objects
An instance of the ‘Client::Objects` class.
-
#virtual_objects ⇒ Dor::Services::Client::VirtualObjects
An instance of the ‘Client::VirtualObjects` class.
Instance Attribute Details
#connection=(value) ⇒ Object
Sets the attribute connection
99 100 101 |
# File 'lib/dor/services/client.rb', line 99 def connection=(value) @connection = value end |
#token=(value) ⇒ Object
Sets the attribute token
99 100 101 |
# File 'lib/dor/services/client.rb', line 99 def token=(value) @token = value end |
#url=(value) ⇒ Object
Sets the attribute url
99 100 101 |
# File 'lib/dor/services/client.rb', line 99 def url=(value) @url = value end |
Class Method Details
.configure(url:, token:) ⇒ Object
86 87 88 89 90 91 92 93 94 |
# File 'lib/dor/services/client.rb', line 86 def configure(url:, token:) instance.url = url instance.token = token # Force connection to be re-established when `.configure` is called instance.connection = nil self end |
Instance Method Details
#background_job_results ⇒ Dor::Services::Client::BackgroundJobResults
Returns an instance of the ‘Client::BackgroundJobResults` class.
79 80 81 |
# File 'lib/dor/services/client.rb', line 79 def background_job_results @background_job_results ||= BackgroundJobResults.new(connection: connection, version: DEFAULT_VERSION) end |
#object(object_identifier) ⇒ Dor::Services::Client::Object
Returns an instance of the ‘Client::Object` class.
57 58 59 60 61 62 63 64 65 66 |
# File 'lib/dor/services/client.rb', line 57 def object(object_identifier) raise ArgumentError, '`object_identifier` argument cannot be `nil` in call to `#object(object_identifier)' if object_identifier.nil? # Return memoized object instance if object identifier value is the same # This allows us to test the client more easily in downstream codebases, # opening up stubbing without requiring `any_instance_of` return @object if @object&.object_identifier == object_identifier @object = Object.new(connection: connection, version: DEFAULT_VERSION, object_identifier: object_identifier) end |
#objects ⇒ Dor::Services::Client::Objects
Returns an instance of the ‘Client::Objects` class.
69 70 71 |
# File 'lib/dor/services/client.rb', line 69 def objects @objects ||= Objects.new(connection: connection, version: DEFAULT_VERSION) end |
#virtual_objects ⇒ Dor::Services::Client::VirtualObjects
Returns an instance of the ‘Client::VirtualObjects` class.
74 75 76 |
# File 'lib/dor/services/client.rb', line 74 def virtual_objects @virtual_objects ||= VirtualObjects.new(connection: connection, version: DEFAULT_VERSION) end |