Method: GoodData::Project#objects_export
- Defined in:
- lib/gooddata/models/project.rb
#objects_export(objs, options = {}) ⇒ String
Transfer objects from one project to another
1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 |
# File 'lib/gooddata/models/project.rb', line 1422 def objects_export(objs, = {}) fail 'Nothing to migrate. You have to pass list of objects, ids or uris that you would like to migrate' if objs.nil? objs = Array(objs).map { |o| o.respond_to?(:uri) ? o.uri : o } if objs.empty? GoodData.logger.warn 'Nothing to migrate.' return end export_payload = { :partialMDExport => { :uris => objs, :exportAttributeProperties => '1', :crossDataCenterExport => '1' } } export_uri = "/gdc/md/#{pid}/maintenance/partialmdexport" GoodData.gd_logger.info("Project export action=objects_export, project_id=#{pid}, uri=#{export_uri}, export_status=start, export_objs=#{export_payload}") if GoodData.gd_logger # Export api will take time to finish So increasing timeout during calling the api result = client.post(export_uri, export_payload, :timeout => 10) polling_url = result['partialMDArtifact']['status']['uri'] token = result['partialMDArtifact']['token'] GoodData.gd_logger.info("Project export action=objects_export, project_id=#{pid}, uri=#{polling_url}, export_status=polling") if GoodData.gd_logger polling_result = client.poll_on_response(polling_url, ) do |body| body['wTaskStatus'] && body['wTaskStatus']['status'] == 'RUNNING' end if polling_result['wTaskStatus'] && polling_result['wTaskStatus']['status'] == 'ERROR' = GoodData::Helpers.(polling_result['wTaskStatus']['messages']).join(' ') fail ObjectsExportError, "Exporting objects failed with messages. #{}" end GoodData.gd_logger.info("Project export action=objects_export, project_id=#{pid}, export_status=success") if GoodData.gd_logger token end |