Sha256: 0aca4a5be3113faa745f8b9015f0bda5078ccd0d1db2dfaccd279f027fd4876c

Contents?: true

Size: 1.24 KB

Versions: 3

Compression:

Stored size: 1.24 KB

Contents

module Aptible
  module Api
    class Stack < Resource
      has_many :aws_instances
      has_many :stack_layers
      has_many :operations

      field :id
      field :type
      field :name
      field :version
      field :region
      field :default, type: Aptible::Resource::Boolean
      field :ssh_host_dsa_public_key
      field :ssh_host_rsa_public_key
      field :ssh_host_ecdsa_public_key
      field :ssh_portal_host
      field :ssh_portal_port
      field :created_at, type: Time
      field :updated_at, type: Time

      def dns_layers
        stack_layers.reject! { |l| l.dns_name.blank? }
      end

      # This method is necessary because we need to include a query parameter
      # when requesting aws_instances.
      # Copied the important bits from
      # https://github.com/aptible/aptible-resource/blob/4708fb80a6c21013de07c2779ffc4928cee37d4e/lib/aptible/resource/base.rb#L138
      def aws_instances_with_deprovisionable
        get unless loaded

        return unless links['aws_instances']

        param = 'include_deprovisionable=true'
        href = "#{links['aws_instances'].base_href}?#{param}"
        self.class.all(
          href: href,
          token: token,
          headers: headers
        )
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
aptible-api-1.2.22 lib/aptible/api/stack.rb
aptible-api-1.2.21 lib/aptible/api/stack.rb
aptible-api-1.2.20 lib/aptible/api/stack.rb