Class: Terraspace::Terraform::Api::Runs
- Extended by:
- Memoist
- Defined in:
- lib/terraspace/terraform/api/runs.rb
Instance Attribute Summary collapse
-
#workspace_id ⇒ Object
readonly
Returns the value of attribute workspace_id.
Instance Method Summary collapse
- #action(action, id) ⇒ Object
- #cancel(id) ⇒ Object
- #discard(id) ⇒ Object
-
#initialize(workspace_id) ⇒ Runs
constructor
A new instance of Runs.
- #list ⇒ Object
Methods included from Util::Logging
Methods included from Http::Concern
Constructor Details
#initialize(workspace_id) ⇒ Runs
Returns a new instance of Runs.
6 7 8 |
# File 'lib/terraspace/terraform/api/runs.rb', line 6 def initialize(workspace_id) @workspace_id = workspace_id end |
Instance Attribute Details
#workspace_id ⇒ Object (readonly)
Returns the value of attribute workspace_id.
5 6 7 |
# File 'lib/terraspace/terraform/api/runs.rb', line 5 def workspace_id @workspace_id end |
Instance Method Details
#action(action, id) ⇒ Object
34 35 36 37 |
# File 'lib/terraspace/terraform/api/runs.rb', line 34 def action(action, id) payload = http.post("runs/#{id}/actions/#{action}") payload['data'] if payload end |
#cancel(id) ⇒ Object
30 31 32 |
# File 'lib/terraspace/terraform/api/runs.rb', line 30 def cancel(id) action("cancel", id) end |
#discard(id) ⇒ Object
26 27 28 |
# File 'lib/terraspace/terraform/api/runs.rb', line 26 def discard(id) action("discard", id) end |
#list ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/terraspace/terraform/api/runs.rb', line 10 def list data, next_page = [], :start while next_page == :start || next_page url = "workspaces/#{@workspace_id}/runs" if next_page qs = URI.encode_www_form('page[number]': next_page) if next_page url += "?#{qs}" end payload = http.get(url) return unless payload data += payload['data'] next_page = payload['meta']['pagination']['next-page'] end data end |