Method: GoodData::Project#objects_import

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

#objects_import(token, options = {}) ⇒ Boolean

Import objects from import token. If you do not need specifically this method what you are probably looking for is transfer_objects. This is a lower level method.

Parameters:

  • Migration token ID

  • (defaults to: {})

    The options to migration.

Options Hash (options):

  • :time_limit (Number)

    Time in seconds before the blocking call will fail. See GoodData::Rest::Client.poll_on_response for additional details

  • :sleep_interval (Number)

    Interval between polls on the status of the migration.

Returns:

  • Returns true if it succeeds or throws exceoption



1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
# File 'lib/gooddata/models/project.rb', line 1466

def objects_import(token, options = {})
  fail 'You need to provide a token for object import' if token.blank?

  import_payload = {
    :partialMDImport => {
      :token => token,
      :overwriteNewer => '1',
      :updateLDMObjects => '1',
      :importAttributeProperties => '1'
    }
  }

  import_uri = "/gdc/md/#{pid}/maintenance/partialmdimport"
  GoodData.gd_logger.info("Project import action=objects_import, project_id=#{pid}, uri=#{import_uri}, import_status=start") if GoodData.gd_logger

  result = client.post(import_uri, import_payload)
  polling_url = result['uri']
  GoodData.gd_logger.info("Project import action=objects_import, project_id=#{pid}, uri=#{polling_url}, import_status=polling") if GoodData.gd_logger

  polling_result = client.poll_on_response(polling_url, options) do |body|
    body['wTaskStatus'] && body['wTaskStatus']['status'] == 'RUNNING'
  end

  if polling_result['wTaskStatus']['status'] == 'ERROR'
    messages = GoodData::Helpers.interpolate_error_messages(polling_result['wTaskStatus']['messages']).join(' ')
    fail ObjectsImportError, "Importing objects failed with messages. #{messages}"
  end

  GoodData.gd_logger.info("Project import action=objects_import, project_id=#{pid}, uri=#{import_uri}, import_status=success") if GoodData.gd_logger

  true
end