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
19 20 21 22 |
# File 'lib/gooddata/models/execution.rb', line 19 def initialize(json) super @json = json end |
Instance Attribute Details
#dirty ⇒ Object (readonly)
Returns the value of attribute dirty.
12 13 14 |
# File 'lib/gooddata/models/execution.rb', line 12 def dirty @dirty end |
#json ⇒ Object (readonly) Also known as: data
Returns the value of attribute json.
12 13 14 |
# File 'lib/gooddata/models/execution.rb', line 12 def json @json end |
Instance Method Details
#==(other) ⇒ Object
Compares two executions - based on their URI
111 112 113 |
# File 'lib/gooddata/models/execution.rb', line 111 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
25 26 27 |
# File 'lib/gooddata/models/execution.rb', line 25 def created Time.parse(json['execution']['createdTime']) end |
#duration ⇒ Object
102 103 104 105 106 107 108 |
# File 'lib/gooddata/models/execution.rb', line 102 def duration if running? Time.now - started else finished && finished - started end end |
#error? ⇒ Boolean
Has execution failed?
35 36 37 |
# File 'lib/gooddata/models/execution.rb', line 35 def error? status == :error end |
#finished ⇒ Object
Timestamp when execution was finished
40 41 42 |
# File 'lib/gooddata/models/execution.rb', line 40 def finished json['execution']['endTime'] && Time.parse(json['execution']['endTime']) end |
#log ⇒ Object
Log for execution
45 46 47 |
# File 'lib/gooddata/models/execution.rb', line 45 def log @client.get(json['execution']['log']) end |
#ok? ⇒ Boolean
Is execution ok?
50 51 52 |
# File 'lib/gooddata/models/execution.rb', line 50 def ok? status == :ok end |
#running? ⇒ Boolean
Is execution running?
63 64 65 |
# File 'lib/gooddata/models/execution.rb', line 63 def running? status == :running end |
#schedule ⇒ String
Returns schedule
70 71 72 |
# File 'lib/gooddata/models/execution.rb', line 70 def schedule schedule_uri && project.schedules(schedule_uri) end |
#schedule_uri ⇒ String
Returns schedule URL
57 58 59 60 |
# File 'lib/gooddata/models/execution.rb', line 57 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
75 76 77 |
# File 'lib/gooddata/models/execution.rb', line 75 def started Time.parse(json['execution']['startTime']) end |
#status ⇒ Object
Status of execution
80 81 82 |
# File 'lib/gooddata/models/execution.rb', line 80 def status json['execution']['status'].downcase.to_sym end |
#uri ⇒ String
Returns URL
87 88 89 |
# File 'lib/gooddata/models/execution.rb', line 87 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
94 95 96 97 98 99 100 |
# File 'lib/gooddata/models/execution.rb', line 94 def wait_for_result( = {}) res = client.poll_on_response(uri, ) do |body| body['execution'] && (body['execution']['status'] == 'RUNNING' || body['execution']['status'] == 'SCHEDULED') end @json = res self end |