class GoodData::Execution

Attributes

data[R]
dirty[R]
json[R]

Public Class Methods

new(json) click to toggle source

Initializes object instance from raw wire JSON

@param json Json used for initialization

Calls superclass method
# File lib/gooddata/models/execution.rb, line 18
def initialize(json)
  super
  @json = json
end

Public Instance Methods

==(other) click to toggle source

Compares two executions - based on their URI

# File lib/gooddata/models/execution.rb, line 115
def ==(other)
  other.respond_to?(:uri) && other.uri == uri && other.respond_to?(:to_hash) && other.to_hash == to_hash
end
created() click to toggle source

Timestamp when execution was created

# File lib/gooddata/models/execution.rb, line 24
def created
  Time.parse(json['execution']['createdTime'])
end
duration() click to toggle source
# File lib/gooddata/models/execution.rb, line 106
def duration
  if running?
    Time.now - started
  else
    finished && finished - started
  end
end
error?() click to toggle source

Has execution failed?

# File lib/gooddata/models/execution.rb, line 34
def error?
  status == :error
end
finished() click to toggle source

Timestamp when execution was finished

# File lib/gooddata/models/execution.rb, line 39
def finished
  json['execution']['endTime'] && Time.parse(json['execution']['endTime'])
end
log() click to toggle source

Log for execution

# File lib/gooddata/models/execution.rb, line 44
def log
  @client.get(json['execution']['log'])
end
ok?() click to toggle source

Is execution ok?

# File lib/gooddata/models/execution.rb, line 49
def ok?
  status == :ok
end
running?() click to toggle source

Is execution running?

# File lib/gooddata/models/execution.rb, line 62
def running?
  status == :running
end
schedule() click to toggle source

Returns schedule

@return [String] Schedule URL

# File lib/gooddata/models/execution.rb, line 69
def schedule
  schedule_uri && project.schedules(schedule_uri)
end
schedule_uri() click to toggle source

Returns schedule URL

@return [String] Schedule URL

# File lib/gooddata/models/execution.rb, line 56
def schedule_uri
  uri = @json['execution']['links']['self'] if @json && @json['execution'] && @json['execution']['links']
  uri.split('/')[0..-3].join('/')
end
started() click to toggle source

Timestamp when execution was started

# File lib/gooddata/models/execution.rb, line 74
def started
  Time.parse(json['execution']['startTime'])
end
status() click to toggle source

Status of execution

# File lib/gooddata/models/execution.rb, line 79
def status
  json['execution']['status'].downcase.to_sym
end
uri() click to toggle source

Returns URL

@return [String] Schedule URL

# File lib/gooddata/models/execution.rb, line 86
def uri
  @json['execution']['links']['self'] if @json && @json['execution'] && @json['execution']['links']
end
wait_for_result(options = {}) click to toggle source

Wait for execution result, status different than RUNNING or SCHEDULED

@return [GoodData::Execution] Execution result

# File lib/gooddata/models/execution.rb, line 93
def wait_for_result(options = {})
  start_time = Time.now
  timeout = options[:timeout]
  res = client.poll_on_response(uri, options) do |body|
    timeout_exceeded = timeout && (start_time + timeout) < Time.now
    fail 'Waiting for schedule execution timed out.' if timeout_exceeded

    body['execution'] && (body['execution']['status'] == 'RUNNING' || body['execution']['status'] == 'SCHEDULED')
  end
  @json = res
  self
end