Class: Terraspace::Cloud::Api

Inherits:
Object
  • Object
show all
Extended by:
Memoist
Includes:
HttpMethods, Context
Defined in:
lib/terraspace/cloud/api.rb,
lib/terraspace/cloud/api/cani.rb,
lib/terraspace/cloud/api/concern.rb,
lib/terraspace/cloud/api/validate.rb,
lib/terraspace/cloud/api/http_methods.rb

Defined Under Namespace

Modules: Concern, HttpMethods, Validate Classes: Cani

Instance Method Summary collapse

Methods included from HttpMethods

#build_request, #check, #delete, #get, #http, #load_json, #parseable?, #patch, #post, #put, #request, #set_headers!, #token, #url

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 Validate

#validate

Constructor Details

#initialize(options) ⇒ Api

Returns a new instance of Api.



7
8
9
10
# File 'lib/terraspace/cloud/api.rb', line 7

def initialize(options)
  @options = options
  setup_context(@options)
end

Instance Method Details

#complete_stream(data = {}) ⇒ Object

data: success:



31
32
33
# File 'lib/terraspace/cloud/api.rb', line 31

def complete_stream(data={})
  post("#{stack_path}/streams/#{data[:id]}/complete", @options.merge(data))
end

#create_cost(data) ⇒ Object

data: “upload-nRPSpyWd65Ps6978”, stack_id: ‘…’



46
47
48
# File 'lib/terraspace/cloud/api.rb', line 46

def create_cost(data)
  post("#{stack_path}/costs", @options.merge(data))
end

#create_plan(data) ⇒ Object

data: “upload-nRPSpyWd65Ps6978”, kind: “apply”, stack_id: ‘…’



36
37
38
# File 'lib/terraspace/cloud/api.rb', line 36

def create_plan(data)
  post("#{stack_path}/plans", @options.merge(data))
end

#create_stream(data) ⇒ Object

data: stream_id:



26
27
28
# File 'lib/terraspace/cloud/api.rb', line 26

def create_stream(data)
  post("#{stack_path}/streams", @options.merge(data))
end

#create_update(data) ⇒ Object

data: “upload-nRPSpyWd65Ps6978”, kind: “apply”, stack_id: ‘…’



41
42
43
# File 'lib/terraspace/cloud/api.rb', line 41

def create_update(data)
  post("#{stack_path}/updates", @options.merge(data))
end

#create_upload(data) ⇒ Object

data: stream_id:



21
22
23
# File 'lib/terraspace/cloud/api.rb', line 21

def create_upload(data)
  post("#{stack_path}/uploads", @options.merge(data))
end

#endpointObject



12
13
14
# File 'lib/terraspace/cloud/api.rb', line 12

def endpoint
  ENV['TS_API'].blank? ? 'https://api.terraspace.cloud/api/v1' : ENV['TS_API']
end

#get_comment(data) ⇒ Object



54
55
56
# File 'lib/terraspace/cloud/api.rb', line 54

def get_comment(data)
  get("#{stack_path}/comment", @options.merge(data))
end

#get_previous_cost(data) ⇒ Object



50
51
52
# File 'lib/terraspace/cloud/api.rb', line 50

def get_previous_cost(data)
  get("#{stack_path}/costs/previous", @options.merge(data))
end

#stack_pathObject



16
17
18
# File 'lib/terraspace/cloud/api.rb', line 16

def stack_path
  "orgs/#{@org}/projects/#{@project}/stacks/#{@stack}"
end