Class: Dor::Services::Client
- Inherits:
-
Object
- Object
- Dor::Services::Client
- Includes:
- Singleton
- Defined in:
- lib/dor/services/client.rb,
lib/dor/services/client/events.rb,
lib/dor/services/client/mutate.rb,
lib/dor/services/client/object.rb,
lib/dor/services/client/members.rb,
lib/dor/services/client/objects.rb,
lib/dor/services/client/version.rb,
lib/dor/services/client/transfer.rb,
lib/dor/services/client/accession.rb,
lib/dor/services/client/workspace.rb,
lib/dor/services/client/collections.rb,
lib/dor/services/client/async_result.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/administrative_tags.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,
lib/dor/services/client/administrative_tag_search.rb
Defined Under Namespace
Classes: Accession, AdministrativeTagSearch, AdministrativeTags, AsyncResult, BackgroundJobResults, BadRequestError, Collections, ConflictResponse, ConnectionFailed, Error, ErrorFaradayMiddleware, Events, MalformedResponse, Members, Mutate, NotFoundResponse, Object, ObjectVersion, Objects, PreconditionFailedResponse, ResponseErrorFormatter, Transfer, UnauthorizedResponse, UnexpectedResponse, VersionedService, VirtualObjects, Workspace
Constant Summary collapse
- DEFAULT_VERSION =
'v1'
- TOKEN_HEADER =
'Authorization'
- VERSION =
'14.2.1'
Instance Attribute Summary collapse
-
#connection ⇒ Object
writeonly
Sets the attribute connection.
-
#enable_get_retries ⇒ Object
writeonly
Sets the attribute enable_get_retries.
-
#logger ⇒ Object
writeonly
Sets the attribute logger.
-
#token ⇒ Object
writeonly
Sets the attribute token.
-
#url ⇒ Object
writeonly
Sets the attribute url.
Class Method Summary collapse
Instance Method Summary collapse
-
#administrative_tags ⇒ Dor::Services::Client::AdministrativeTagSearch
An instance of the ‘Client::AdministrativeTagSearch` class.
-
#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
135 136 137 |
# File 'lib/dor/services/client.rb', line 135 def connection=(value) @connection = value end |
#enable_get_retries=(value) ⇒ Object
Sets the attribute enable_get_retries
135 136 137 |
# File 'lib/dor/services/client.rb', line 135 def enable_get_retries=(value) @enable_get_retries = value end |
#logger=(value) ⇒ Object
Sets the attribute logger
135 136 137 |
# File 'lib/dor/services/client.rb', line 135 def logger=(value) @logger = value end |
#token=(value) ⇒ Object
Sets the attribute token
135 136 137 |
# File 'lib/dor/services/client.rb', line 135 def token=(value) @token = value end |
#url=(value) ⇒ Object
Sets the attribute url
135 136 137 |
# File 'lib/dor/services/client.rb', line 135 def url=(value) @url = value end |
Class Method Details
.configure(url:, token:, enable_get_retries: true, logger: nil) ⇒ Object
120 121 122 123 124 125 126 127 128 129 130 |
# File 'lib/dor/services/client.rb', line 120 def configure(url:, token:, enable_get_retries: true, logger: nil) instance.url = url instance.token = token instance.enable_get_retries = enable_get_retries instance.logger = logger # Force connection to be re-established when `.configure` is called instance.connection = nil self end |
Instance Method Details
#administrative_tags ⇒ Dor::Services::Client::AdministrativeTagSearch
Returns an instance of the ‘Client::AdministrativeTagSearch` class.
96 97 98 |
# File 'lib/dor/services/client.rb', line 96 def @administrative_tags ||= AdministrativeTagSearch.new(connection: connection, version: DEFAULT_VERSION) end |
#background_job_results ⇒ Dor::Services::Client::BackgroundJobResults
Returns an instance of the ‘Client::BackgroundJobResults` class.
111 112 113 |
# File 'lib/dor/services/client.rb', line 111 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.
84 85 86 87 88 89 90 91 92 93 |
# File 'lib/dor/services/client.rb', line 84 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.
101 102 103 |
# File 'lib/dor/services/client.rb', line 101 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.
106 107 108 |
# File 'lib/dor/services/client.rb', line 106 def virtual_objects @virtual_objects ||= VirtualObjects.new(connection: connection, version: DEFAULT_VERSION) end |