Class: SdrClient::RedesignedClient::CreateResource
- Inherits:
-
Object
- Object
- SdrClient::RedesignedClient::CreateResource
- Defined in:
- lib/sdr_client/redesigned_client/create_resource.rb
Overview
Creates a resource (metadata) in SDR
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(accession:, metadata:, assign_doi: false, priority: nil, user_versions: nil) ⇒ CreateResource
constructor
A new instance of CreateResource.
-
#run ⇒ String
Job id for the background job result.
Constructor Details
#initialize(accession:, metadata:, assign_doi: false, priority: nil, user_versions: nil) ⇒ CreateResource
Returns a new instance of CreateResource.
18 19 20 21 22 23 24 |
# File 'lib/sdr_client/redesigned_client/create_resource.rb', line 18 def initialize(accession:, metadata:, assign_doi: false, priority: nil, user_versions: nil) @accession = accession @priority = priority @assign_doi = assign_doi @metadata = @user_versions = user_versions end |
Class Method Details
.run ⇒ Object
7 8 9 |
# File 'lib/sdr_client/redesigned_client/create_resource.rb', line 7 def self.run(...) new(...).run end |
Instance Method Details
#run ⇒ String
Returns job id for the background job result.
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/sdr_client/redesigned_client/create_resource.rb', line 28 def run json = .to_json logger.debug("Starting upload metadata: #{json}") response_hash = client.post( path: path, body: json, headers: { 'X-Cocina-Models-Version' => Cocina::Models::VERSION }, expected_status: 201 ) logger.info("Response from server: #{response_hash.to_json}") response_hash.fetch(:jobId) end |