Class: Dor::Services::Client::ReleaseTags

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

Overview

API calls that are about a repository object

Instance Method Summary collapse

Methods inherited from VersionedService

#async_result

Constructor Details

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

Returns a new instance of ReleaseTags.

Parameters:

  • object_identifier (String)

    the pid for the object



9
10
11
12
# File 'lib/dor/services/client/release_tags.rb', line 9

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

Instance Method Details

#create(release:, what:, to:, who:) ⇒ Boolean

Creates a new release tag for the object rubocop:disable Metrics/MethodLength

Parameters:

  • release (Boolean)
  • what (String)
  • to (String)
  • who (String)

Returns:

  • (Boolean)

    true if successful

Raises:



23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/dor/services/client/release_tags.rb', line 23

def create(release:, what:, to:, who:)
  params = {
    to: to,
    who: who,
    what: what,
    release: release
  }
  resp = connection.post do |req|
    req.url "#{api_version}/objects/#{object_identifier}/release_tags"
    req.headers['Content-Type'] = 'application/json'
    req.body = params.to_json
  end
  raise_exception_based_on_response!(resp, object_identifier) unless resp.success?

  true
end

#listObject

List new release tags for the object

Raises:



45
46
47
48
49
50
51
52
53
# File 'lib/dor/services/client/release_tags.rb', line 45

def list
  resp = connection.get do |req|
    req.url "#{api_version}/objects/#{object_identifier}/release_tags"
  end

  raise_exception_based_on_response!(resp, object_identifier) unless resp.success?

  JSON.parse(resp.body)
end