Class: Dor::Services::Client

Inherits:
Object
  • Object
show all
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/objects.rb,
lib/dor/services/client/version.rb,
lib/dor/services/client/workflow.rb,
lib/dor/services/client/workflows.rb,
lib/dor/services/client/workspace.rb,
lib/dor/services/client/release_tags.rb,
lib/dor/services/client/versioned_service.rb

Defined Under Namespace

Classes: Error, Files, MalformedResponse, NotFoundResponse, Object, Objects, ReleaseTags, SDR, UnexpectedResponse, VersionedService, Workflow, Workflows, Workspace

Constant Summary collapse

DEFAULT_VERSION =
'v1'
VERSION =
'1.5.1'

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#connection=(value) ⇒ Object

Sets the attribute connection

Parameters:

  • value

    the value to set the attribute connection to.



69
70
71
# File 'lib/dor/services/client.rb', line 69

def connection=(value)
  @connection = value
end

#password=(value) ⇒ Object

Sets the attribute password

Parameters:

  • value

    the value to set the attribute password to.



69
70
71
# File 'lib/dor/services/client.rb', line 69

def password=(value)
  @password = value
end

#url=(value) ⇒ Object

Sets the attribute url

Parameters:

  • value

    the value to set the attribute url to.



69
70
71
# File 'lib/dor/services/client.rb', line 69

def url=(value)
  @url = value
end

#username=(value) ⇒ Object

Sets the attribute username

Parameters:

  • value

    the value to set the attribute username to.



69
70
71
# File 'lib/dor/services/client.rb', line 69

def username=(value)
  @username = value
end

Class Method Details

.configure(url:, username: nil, password: nil) ⇒ Object



56
57
58
59
60
61
62
63
64
# File 'lib/dor/services/client.rb', line 56

def configure(url:, username: nil, password: nil)
  instance.url = url
  instance.username = username
  instance.password = password
  # Force connection to be re-established when `.configure` is called
  instance.connection = nil

  self
end

Instance Method Details

#object(object_identifier) ⇒ Dor::Services::Client::Object

Returns an instance of the ‘Client::Object` class.

Parameters:

  • object_identifier (String)

    the pid for the object

Returns:

Raises:

  • (ArgumentError)

    when ‘object_identifier` is `nil`



35
36
37
38
39
40
41
42
43
44
# File 'lib/dor/services/client.rb', line 35

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

#objectsDor::Services::Client::Objects

Returns an instance of the ‘Client::Objects` class.

Returns:



47
48
49
# File 'lib/dor/services/client.rb', line 47

def objects
  @objects ||= Objects.new(connection: connection, version: DEFAULT_VERSION)
end

#workflowsObject



51
52
53
# File 'lib/dor/services/client.rb', line 51

def workflows
  @workflows ||= Workflows.new(connection: connection, version: DEFAULT_VERSION)
end