Method: GoodData::Project#partial_md_export

Defined in:
lib/gooddata/models/project.rb

#partial_md_export(objects, options = {}) ⇒ Boolean | Array<Hash> Also known as: transfer_objects

Transfer objects from one project to another

if you passed only one project. If you provided an array returns list of hashes signifying sucees or failure. Take note that in case of list of projects it does not throw exception.

Parameters:

  • objects (Array<GoodData::MdObject | String>, String, GoodData::MdObject)

    Any representation of the object or a list of those

  • options (Hash) (defaults to: {})

    The options to migration.

Options Hash (options):

  • :project (GoodData::Project | String | Array<String> | Array<GoodData::Project>)

    Project(s) to migrate to

  • :batch_size (Number)

    Number of projects that are migrated at the same time. Default is 10

Returns:

  • (Boolean | Array<Hash>)

    Return either true or throws exception



1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
# File 'lib/gooddata/models/project.rb', line 1510

def partial_md_export(objects, options = {})
  projects = options[:project]
  batch_size = options[:batch_size] || 10
  token = objects_export(objects)
  return if token.nil?

  if projects.is_a?(Array)
    projects.each_slice(batch_size).flat_map do |batch|
      batch.pmap do |proj|
        target_project = client.projects(proj)
        target_project.objects_import(token, options)
        {
          project: target_project,
          result: true
        }
      end
    end
  else
    target_project = client.projects(projects)
    target_project.objects_import(token, options)
    [{
      project: target_project,
      result: true
    }]
  end
end