Sha256: fee00f841daabd332a9a28de1612fac2a0ce8b1de02308767de242ee44932d19

Contents?: true

Size: 1.44 KB

Versions: 17

Compression:

Stored size: 1.44 KB

Contents

module Terraspace::Cloud
  class Api
    include Context
    include HttpMethods

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

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

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

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

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

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

    # data: {upload_id: "upload-nRPSpyWd65Ps6978", kind: "apply", stack_id: '...'}
    def create_plan(data)
      post("#{stack_path}/plans", @options.merge(data))
    end

    # data: {upload_id: "upload-nRPSpyWd65Ps6978", kind: "apply", stack_id: '...'}
    def create_update(data)
      post("#{stack_path}/updates", @options.merge(data))
    end

    # data: {upload_id: "upload-nRPSpyWd65Ps6978", stack_id: '...'}
    def create_cost(data)
      post("#{stack_path}/costs", @options.merge(data))
    end

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

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

Version data entries

17 entries across 17 versions & 1 rubygems

Version Path
terraspace-2.2.8 lib/terraspace/cloud/api.rb
terraspace-2.2.7 lib/terraspace/cloud/api.rb
terraspace-2.2.6 lib/terraspace/cloud/api.rb
terraspace-2.2.5 lib/terraspace/cloud/api.rb
terraspace-2.2.4 lib/terraspace/cloud/api.rb
terraspace-2.2.3 lib/terraspace/cloud/api.rb
terraspace-2.2.2 lib/terraspace/cloud/api.rb
terraspace-2.2.1 lib/terraspace/cloud/api.rb
terraspace-2.2.0 lib/terraspace/cloud/api.rb
terraspace-2.1.7 lib/terraspace/cloud/api.rb
terraspace-2.1.6 lib/terraspace/cloud/api.rb
terraspace-2.1.5 lib/terraspace/cloud/api.rb
terraspace-2.1.4 lib/terraspace/cloud/api.rb
terraspace-2.1.3 lib/terraspace/cloud/api.rb
terraspace-2.1.2 lib/terraspace/cloud/api.rb
terraspace-2.1.1 lib/terraspace/cloud/api.rb
terraspace-2.1.0 lib/terraspace/cloud/api.rb