Sha256: bd1e970d2a73303a8258c27d74df23b65e5f977414bc15d8a37d8e5f44887a6c

Contents?: true

Size: 1.14 KB

Versions: 5

Compression:

Stored size: 1.14 KB

Contents

require 'pry'
require 'highline'

module GoodData
  class Process

    class << self
      def [](id)
        if id == :all
          GoodData.get("/gdc/projects/#{GoodData.project.pid}/dataload/processes")
        else 
          self.new(GoodData.get("/gdc/projects/#{GoodData.project.pid}/dataload/processes/#{id}"))
        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

5 entries across 5 versions & 1 rubygems

Version Path
gooddata-0.6.0.pre11 lib/gooddata/models/process.rb
gooddata-0.6.0.pre10 lib/gooddata/models/process.rb
gooddata-0.6.0.pre9 lib/gooddata/models/process.rb
gooddata-0.6.0.pre8 lib/gooddata/models/process.rb
gooddata-0.6.0.pre7 lib/gooddata/models/process.rb