Class: GoodData::Execution
- Inherits:
-
Rest::Resource
- Object
- Rest::Object
- Rest::Resource
- GoodData::Execution
- Defined in:
- lib/gooddata/models/execution.rb
Instance Attribute Summary collapse
-
#dirty ⇒ Object
readonly
Returns the value of attribute dirty.
-
#json ⇒ Object
(also: #data)
readonly
Returns the value of attribute json.
Attributes inherited from Rest::Object
Instance Method Summary collapse
-
#==(other) ⇒ Object
Compares two executions - based on their URI.
-
#created ⇒ Object
Timestamp when execution was created.
- #duration ⇒ Object
-
#error? ⇒ Boolean
Has execution failed?.
-
#finished ⇒ Object
Timestamp when execution was finished.
-
#initialize(json) ⇒ Execution
constructor
Initializes object instance from raw wire JSON.
-
#log ⇒ Object
Log for execution.
-
#ok? ⇒ Boolean
Is execution ok?.
-
#running? ⇒ Boolean
Is execution running?.
-
#schedule ⇒ String
Returns schedule.
-
#schedule_uri ⇒ String
Returns schedule URL.
-
#started ⇒ Object
Timestamp when execution was started.
-
#status ⇒ Object
Status of execution.
-
#uri ⇒ String
Returns URL.
-
#wait_for_result(options = {}) ⇒ GoodData::Execution
Wait for execution result, status different than RUNNING or SCHEDULED.
Methods included from Mixin::ObjId
Methods inherited from Rest::Object
client, default_client, #saved?
Methods included from Mixin::DataPropertyReader
Methods included from Mixin::DataPropertyWriter
Methods included from Mixin::MetaPropertyReader
Methods included from Mixin::MetaPropertyWriter
Methods included from Mixin::MetaGetter
Methods included from Mixin::RootKeyGetter
Methods included from Mixin::ContentGetter
Constructor Details
#initialize(json) ⇒ Execution
Initializes object instance from raw wire JSON
18 19 20 21 |
# File 'lib/gooddata/models/execution.rb', line 18 def initialize(json) super @json = json end |
Instance Attribute Details
#dirty ⇒ Object (readonly)
Returns the value of attribute dirty.
11 12 13 |
# File 'lib/gooddata/models/execution.rb', line 11 def dirty @dirty end |
#json ⇒ Object (readonly) Also known as: data
Returns the value of attribute json.
11 12 13 |
# File 'lib/gooddata/models/execution.rb', line 11 def json @json end |
Instance Method Details
#==(other) ⇒ Object
Compares two executions - based on their URI
115 116 117 |
# 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 ⇒ Object
Timestamp when execution was created
24 25 26 |
# File 'lib/gooddata/models/execution.rb', line 24 def created Time.parse(json['execution']['createdTime']) end |
#duration ⇒ Object
106 107 108 109 110 111 112 |
# File 'lib/gooddata/models/execution.rb', line 106 def duration if running? Time.now - started else finished && finished - started end end |
#error? ⇒ Boolean
Has execution failed?
34 35 36 |
# File 'lib/gooddata/models/execution.rb', line 34 def error? status == :error end |
#finished ⇒ Object
Timestamp when execution was finished
39 40 41 |
# File 'lib/gooddata/models/execution.rb', line 39 def finished json['execution']['endTime'] && Time.parse(json['execution']['endTime']) end |
#log ⇒ Object
Log for execution
44 45 46 |
# File 'lib/gooddata/models/execution.rb', line 44 def log @client.get(json['execution']['log']) end |
#ok? ⇒ Boolean
Is execution ok?
49 50 51 |
# File 'lib/gooddata/models/execution.rb', line 49 def ok? status == :ok end |
#running? ⇒ Boolean
Is execution running?
62 63 64 |
# File 'lib/gooddata/models/execution.rb', line 62 def running? status == :running end |
#schedule ⇒ String
Returns schedule
69 70 71 |
# File 'lib/gooddata/models/execution.rb', line 69 def schedule schedule_uri && project.schedules(schedule_uri) end |
#schedule_uri ⇒ String
Returns schedule URL
56 57 58 59 |
# 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 ⇒ Object
Timestamp when execution was started
74 75 76 |
# File 'lib/gooddata/models/execution.rb', line 74 def started Time.parse(json['execution']['startTime']) end |
#status ⇒ Object
Status of execution
79 80 81 |
# File 'lib/gooddata/models/execution.rb', line 79 def status json['execution']['status'].downcase.to_sym end |
#uri ⇒ String
Returns URL
86 87 88 |
# 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 = {}) ⇒ GoodData::Execution
Wait for execution result, status different than RUNNING or SCHEDULED
93 94 95 96 97 98 99 100 101 102 103 104 |
# File 'lib/gooddata/models/execution.rb', line 93 def wait_for_result( = {}) start_time = Time.now timeout = [:timeout] res = client.poll_on_response(uri, ) 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 |