Sha256: cdafee62761f7aee9dc6bbfa26e0a9d4d6aeaa093ae09a4d2aba04bf0efaf36c

Contents?: true

Size: 1.17 KB

Versions: 1

Compression:

Stored size: 1.17 KB

Contents

# encoding: UTF-8

require 'pry'

module GoodData
  class Process
    class << self
      def [](id)
        if id == :all
          uri = "/gdc/projects/#{GoodData.project.pid}/dataload/processes"
          GoodData.get(uri)
        else
          uri = "/gdc/projects/#{GoodData.project.pid}/dataload/processes/#{id}"
          self.new(GoodData.get(uri))
        end
      end
    end

    def initialize(data)
      @data = data
    end

    def links
      @data['process']['links']
    end

    def link
      links['self']
    end

    def executions_link
      links['executions']
    end

    def execute_process(graph, options = {})
      result = GoodData.post(executions_link, {
        :execution => {
          :graph => graph,
          :params => {}
        }
      })
      begin
        GoodData.poll(result, 'executionTask')
      rescue RestClient::RequestFailed => e

      ensure
        result = GoodData.get(result['executionTask']['links']['detail'])
        if result['executionDetail']['status'] == 'ERROR'
          fail "Runing process failed. You can look at a log here #{result['executionDetail']['logFileName']}"
        end
      end
      result
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
gooddata-0.6.0 lib/gooddata/models/process.rb