Class: Terraspace::Cloud::Comment

Inherits:
Base show all
Defined in:
lib/terraspace/cloud/comment.rb

Instance Method Summary collapse

Methods inherited from Base

#cancelled?, #changes?, #clean_cache2_stage, #cloud_upload, #initialize, #record?, #sh, #stage_attrs, #success_status

Methods included from Util::Pretty

#pretty_path, #pretty_time

Methods included from Util::Sure

#sure?

Methods included from Util::Logging

#logger

Methods included from Context

#setup_context

Methods included from Api::Validate

#validate

Methods included from Api::Concern

#api, #cloud_stack_name, #expander, #region

Methods included from Api::Concern::Errors

#error_message, #errors?

Methods inherited from Terraspace::CLI::Base

#initialize

Constructor Details

This class inherits a constructor from Terraspace::Cloud::Base

Instance Method Details

#cani?(exit_on_error: true) ⇒ Boolean

Returns:

  • (Boolean)


24
25
26
# File 'lib/terraspace/cloud/comment.rb', line 24

def cani?(exit_on_error: true)
  api.create_cost(cani: 1, exit_on_error: exit_on_error)
end

#get(record, cost) ⇒ Object



3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/terraspace/cloud/comment.rb', line 3

def get(record, cost)
  return unless Terraspace.cloud?

  params = {}
  params[:record_id] = record['data']['id']
  params[:cost_id] = cost['data']['id'] if cost

  sleep 1 # delay a second since job is queued
  resp = nil
  Timeout::timeout(20) do
    loop do
      resp = api.get_comment(params)
      break if resp['data']['attributes']['status'] == 'completed'
      sleep 2
    end
  end
  resp
rescue Timeout::Error
  # nil
end