Module: StrawberryAPI::Client::Libraries

Included in:
StrawberryAPI::Client
Defined in:
lib/strawberry_api/client/libraries.rb

Instance Method Summary collapse

Instance Method Details

#create_library(project_id:, ingest_storage: 'media_1', ingest_path:, external: false, options: {mxf_handling: false}) ⇒ StrawberryAPI::Library

Creates a library

Parameters:

  • project_id (Integer)

    Id of the project where to ingest media

  • ingest_storage (String)

    Name of the storage to ingest into

  • ingest_path (<type>)

    Watchfoler path

  • external (<type>)

    false Whether to keep in place ingest media

  • options (<type>)

    false Hash of options

Returns:



38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
# File 'lib/strawberry_api/client/libraries.rb', line 38

def create_library(project_id:, ingest_storage: 'media_1', ingest_path:, external: false, options: {mxf_handling: false})
  update_project(id: project_id, options: {is_library_project: true, encoding_priority: 'high'})

  body = {
    project_id: project_id,
    ingest_storage: ingest_storage,
    ingest_path: ingest_path,
    external: external,
    options: options
  }.to_json

  job = post("/library_ingests", body: body).parse['job']

  job.nil? ? nil : library(project_id: job['project_id'])
end

#delete_library(id:) ⇒ Boolean

Deletes a library

Parameters:

  • id (Integer)

    Id of the library to delete

Returns:

  • (Boolean)

    Success



60
61
62
# File 'lib/strawberry_api/client/libraries.rb', line 60

def delete_library(id:)
  delete("/library_ingests/#{id}").success?
end

#librariesArray<StrawberryAPI::Library>

Fetches all libraries

Returns:



10
11
12
13
14
# File 'lib/strawberry_api/client/libraries.rb', line 10

def libraries
  get("/library_ingests").parse['array']&.map do |library|
    Library.new(library)
  end
end

#library(id: nil, project_id: nil) ⇒ StrawberryAPI::Library

Fetches a library

Parameters:

  • id (Integer)

    Id of the library to retrieve

Returns:



22
23
24
25
26
# File 'lib/strawberry_api/client/libraries.rb', line 22

def library(id: nil, project_id: nil)
  libraries.find do |library|
    library.id == id.to_i || library.project_id == project_id.to_i
  end
end