Class: Dor::Services::Client::Object

Inherits:
VersionedService show all
Defined in:
lib/dor/services/client/object.rb

Overview

API calls that are about a repository object

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(connection:, version:, object_identifier:) ⇒ Object

Returns a new instance of Object.

Parameters:

  • object_identifier (String)

    the pid for the object

Raises:

  • (ArgumentError)


17
18
19
20
21
22
# File 'lib/dor/services/client/object.rb', line 17

def initialize(connection:, version:, object_identifier:)
  raise ArgumentError, "The `object_identifier` parameter must be an identifier string: #{object_identifier.inspect}" unless object_identifier.is_a?(String)

  super(connection: connection, version: version)
  @object_identifier = object_identifier
end

Instance Attribute Details

#object_identifierObject (readonly)

Returns the value of attribute object_identifier.



14
15
16
# File 'lib/dor/services/client/object.rb', line 14

def object_identifier
  @object_identifier
end

Instance Method Details

#close_version(**params) ⇒ String

Close current version for an object

Parameters:

  • params (Hash)

    optional params (see dor-services-app)

Returns:

  • (String)

    a message confirming successful closing

Raises:



101
102
103
104
105
106
107
108
109
110
# File 'lib/dor/services/client/object.rb', line 101

def close_version(**params)
  resp = connection.post do |req|
    req.url close_version_path
    req.headers['Content-Type'] = 'application/json'
    req.body = params.to_json if params.any?
  end
  return resp.body if resp.success?

  raise_exception_based_on_response!(resp)
end

#current_versionString

Get the current_version for a DOR object. This comes from Dor::VersionMetadataDS

Returns:

  • (String)

    the version identifier

Raises:



74
75
76
77
78
79
80
81
# File 'lib/dor/services/client/object.rb', line 74

def current_version
  resp = connection.get do |req|
    req.url "#{object_path}/versions/current"
  end
  return resp.body if resp.success?

  raise_exception_based_on_response!(resp)
end

#filesObject



28
29
30
# File 'lib/dor/services/client/object.rb', line 28

def files
  @files ||= Files.new(connection: connection, version: api_version, object_identifier: object_identifier)
end

#notify_goobiboolean

Notify the external Goobi system for a new object that was registered in DOR

Returns:

  • (boolean)

    true on success

Raises:



61
62
63
64
65
66
67
68
# File 'lib/dor/services/client/object.rb', line 61

def notify_goobi
  resp = connection.post do |req|
    req.url "#{object_path}/notify_goobi"
  end
  return true if resp.success?

  raise_exception_based_on_response!(resp)
end

#open_new_version(**params) ⇒ String

Open new version for an object

Parameters:

  • params (Hash)

    optional params (see dor-services-app)

Returns:

  • (String)

    the current version

Raises:



89
90
91
92
93
94
# File 'lib/dor/services/client/object.rb', line 89

def open_new_version(**params)
  version = open_new_version_response(**params)
  raise MalformedResponse, "Version of #{object_identifier} is empty" if version.empty?

  version
end

#publishboolean

Publish a new object

Returns:

  • (boolean)

    true on success

Raises:



48
49
50
51
52
53
54
55
# File 'lib/dor/services/client/object.rb', line 48

def publish
  resp = connection.post do |req|
    req.url "#{object_path}/publish"
  end
  return true if resp.success?

  raise_exception_based_on_response!(resp)
end

#release_tagsObject



40
41
42
# File 'lib/dor/services/client/object.rb', line 40

def release_tags
  @release_tags ||= ReleaseTags.new(connection: connection, version: api_version, object_identifier: object_identifier)
end

#sdrObject



24
25
26
# File 'lib/dor/services/client/object.rb', line 24

def sdr
  @sdr ||= SDR.new(connection: connection, version: api_version, object_identifier: object_identifier)
end

#workflowObject



32
33
34
# File 'lib/dor/services/client/object.rb', line 32

def workflow
  @workflow ||= Workflow.new(connection: connection, version: api_version, object_identifier: object_identifier)
end

#workspaceObject



36
37
38
# File 'lib/dor/services/client/object.rb', line 36

def workspace
  @workspace ||= Workspace.new(connection: connection, version: api_version, object_identifier: object_identifier)
end