Class: Preservation::Client
- Inherits:
-
Object
- Object
- Preservation::Client
- Includes:
- Singleton
- Defined in:
- lib/preservation/client.rb,
lib/preservation/client/catalog.rb,
lib/preservation/client/objects.rb,
lib/preservation/client/version.rb,
lib/preservation/client/versioned_api_service.rb,
lib/preservation/client/error_faraday_middleware.rb,
lib/preservation/client/response_error_formatter.rb
Overview
REST API client wrapper for PreservationCatalog with error handling
Defined Under Namespace
Classes: Catalog, ConflictError, ConnectionFailedError, Error, ErrorFaradayMiddleware, IntegrityError, LockedError, NotFoundError, Object, Objects, ResponseErrorFormatter, UnexpectedResponseError, VersionedApiService
Constant Summary collapse
- DEFAULT_API_VERSION =
'v1'- DEFAULT_TIMEOUT =
300- DEFAULT_RETRY_MAX =
3- DEFAULT_RETRY_INTERVAL =
0.5- RETRY_BACKOFF_FACTOR =
2- TOKEN_HEADER =
'Authorization'- VERSION =
'8.0.0'
Instance Attribute Summary collapse
-
#connection ⇒ Object
writeonly
Sets the attribute connection.
-
#read_timeout ⇒ Object
writeonly
Sets the attribute read_timeout.
-
#retry_interval ⇒ Object
writeonly
Sets the attribute retry_interval.
-
#retry_max ⇒ Object
writeonly
Sets the attribute retry_max.
-
#streaming_connection ⇒ Object
writeonly
Sets the attribute streaming_connection.
-
#token ⇒ Object
writeonly
Sets the attribute token.
-
#url ⇒ Object
writeonly
Sets the attribute url.
Class Method Summary collapse
Instance Method Summary collapse
-
#catalog ⇒ Preservation::Client::Catalog
An instance of the
Client::Catalogclass. -
#objects ⇒ Preservation::Client::Objects
An instance of the
Client::Objectsclass.
Instance Attribute Details
#connection=(value) ⇒ Object
Sets the attribute connection
100 101 102 |
# File 'lib/preservation/client.rb', line 100 def connection=(value) @connection = value end |
#read_timeout=(value) ⇒ Object
Sets the attribute read_timeout
100 101 102 |
# File 'lib/preservation/client.rb', line 100 def read_timeout=(value) @read_timeout = value end |
#retry_interval=(value) ⇒ Object
Sets the attribute retry_interval
100 101 102 |
# File 'lib/preservation/client.rb', line 100 def retry_interval=(value) @retry_interval = value end |
#retry_max=(value) ⇒ Object
Sets the attribute retry_max
100 101 102 |
# File 'lib/preservation/client.rb', line 100 def retry_max=(value) @retry_max = value end |
#streaming_connection=(value) ⇒ Object
Sets the attribute streaming_connection
100 101 102 |
# File 'lib/preservation/client.rb', line 100 def streaming_connection=(value) @streaming_connection = value end |
#token=(value) ⇒ Object
Sets the attribute token
100 101 102 |
# File 'lib/preservation/client.rb', line 100 def token=(value) @token = value end |
#url=(value) ⇒ Object
Sets the attribute url
100 101 102 |
# File 'lib/preservation/client.rb', line 100 def url=(value) @url = value end |
Class Method Details
.configure(url:, token:, read_timeout: DEFAULT_TIMEOUT, retry_max: DEFAULT_RETRY_MAX, retry_interval: DEFAULT_RETRY_INTERVAL) ⇒ Object
82 83 84 85 86 87 88 89 90 91 92 93 94 95 |
# File 'lib/preservation/client.rb', line 82 def configure(url:, token:, read_timeout: DEFAULT_TIMEOUT, retry_max: DEFAULT_RETRY_MAX, retry_interval: DEFAULT_RETRY_INTERVAL) instance.url = url instance.token = token instance.read_timeout = read_timeout instance.retry_max = retry_max instance.retry_interval = retry_interval # Force connections to be re-established when `.configure` is called instance.connection = nil instance.streaming_connection = nil self end |
Instance Method Details
#catalog ⇒ Preservation::Client::Catalog
Returns an instance of the Client::Catalog class.
72 73 74 |
# File 'lib/preservation/client.rb', line 72 def catalog @catalog ||= Catalog.new(connection: connection, api_version: DEFAULT_API_VERSION) end |
#objects ⇒ Preservation::Client::Objects
Returns an instance of the Client::Objects class.
65 66 67 68 69 |
# File 'lib/preservation/client.rb', line 65 def objects @objects ||= Objects.new(connection: connection, streaming_connection: streaming_connection, retry_max: retry_max, retry_interval: retry_interval, api_version: DEFAULT_API_VERSION) end |