lib/gooddata/models/project.rb
# Transfer objects from one project to another
#
# @param [Array<GoodData::MdObject | String>, String, GoodData::MdObject] objs Any representation of the object or a list of those
# @param [Hash] options The options to migration.
# @option options [Number] :time_limit Time in seconds before the blocking call will fail. See GoodData::Rest::Client.poll_on_response for additional details
# @option options [Number] :sleep_interval Interval between polls on the status of the migration.
# @return [String] Returns token that you can use as input for object_import
Transfer objects from one project to another
Transfer objects from one project to another
def objects_export(objs, options = {})
      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)
      fail 'Nothing to migrate. The list you provided is empty' if objs.empty?
      objs = objs.pmap { |obj| [obj, objects(obj)] }
      fail ObjectsExportError, "Exporting objects failed with messages. Object #{objs.select { |_, obj| obj.nil? }.map { |o, _| o }.join(', ')} could not be found." if objs.any? { |_, obj| obj.nil? }
      export_payload = {
        :partialMDExport => {
          :uris => objs.map { |_, obj| obj.uri },
          :exportAttributeProperties => '1',
          :crossDataCenterExport => '1'
        }
      }
      result = client.post("#{md['maintenance']}/partialmdexport", export_payload)
      polling_url = result['partialMDArtifact']['status']['uri']
      token = result['partialMDArtifact']['token']
      polling_result = client.poll_on_response(polling_url, options) do |body|
        body['wTaskStatus'] && body['wTaskStatus']['status'] == 'RUNNING'
      end
      if polling_result['wTaskStatus'] && polling_result['wTaskStatus']['status'] == 'ERROR'
        messages = GoodData::Helpers.interpolate_error_messages(polling_result['wTaskStatus']['messages']).join(' ')
        fail ObjectsExportError, "Exporting objects failed with messages. #{messages}"
      end
      token
    end
def objects_export ( objs , options = { } ) 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 ) fail 'Nothing to migrate. The list you provided is empty' if objs . empty? objs = objs . pmap { | obj | [ obj , objects ( obj ) ] } fail ObjectsExportError , "Exporting objects failed with messages. Object #{objs.select { |_, obj| obj.nil? }.map { |o, _| o }.join(', ')} could not be found." if objs . any? { | _ , obj | obj . nil? } export_payload = { :partialMDExport => { :uris => objs . map { | _ , obj | obj . uri } , :exportAttributeProperties => '1' , :crossDataCenterExport => '1' } } result = client . post ( "#{md['maintenance']}/partialmdexport" , export_payload ) polling_url = result [ 'partialMDArtifact' ] [ 'status' ] [ 'uri' ] token = result [ 'partialMDArtifact' ] [ 'token' ] polling_result = client . poll_on_response ( polling_url , options ) do | body | body [ 'wTaskStatus' ] && body [ 'wTaskStatus' ] [ 'status' ] == 'RUNNING' end if polling_result [ 'wTaskStatus' ] && polling_result [ 'wTaskStatus' ] [ 'status' ] == 'ERROR' messages = GoodData :: Helpers . interpolate_error_messages ( polling_result [ 'wTaskStatus' ] [ 'messages' ] ) . join ( ' ' ) fail ObjectsExportError , "Exporting objects failed with messages. #{messages}" end token end
Transfer objects from one project to another
Transfer objects from one project to another
Returns token that you can use as input for object_import
Returns token that you can use as input for object_import
String
objs
options
:sleep_interval Interval between polls on the status of the migration.
: sleep_interval Interval between polls on the status of the migration .
options The options to migration.
options The options to migration .