Sha256: 5e6fb7eb497a5741d83bd677233e3cd238989bf8de381241ec08fd361ebb8404

Contents?: true

Size: 1.55 KB

Versions: 14

Compression:

Stored size: 1.55 KB

Contents

require 'fog/openstack/models/model'

module Fog
  module Openstack
    class Planning
      class Plan < Fog::OpenStack::Model
        MASTER_TEMPLATE_NAME = 'plan.yaml'.freeze
        ENVIRONMENT_NAME = 'environment.yaml'.freeze

        identity :uuid

        attribute :description
        attribute :name
        attribute :uuid
        attribute :created_at
        attribute :updated_at
        attribute :parameters

        def templates
          service.get_plan_templates(uuid).body
        end

        def master_template
          templates[MASTER_TEMPLATE_NAME]
        end

        def environment
          templates[ENVIRONMENT_NAME]
        end

        def provider_resource_templates
          templates.select do |key, _template|
            ![MASTER_TEMPLATE_NAME, ENVIRONMENT_NAME].include?(key)
          end
        end

        def patch(parameters)
          service.patch_plan(uuid, parameters[:parameters]).body
        end

        def add_role(role_uuid)
          service.add_role_to_plan(uuid, role_uuid)
        end

        def remove_role(role_uuid)
          service.remove_role_from_plan(uuid, role_uuid)
        end

        def destroy
          requires :uuid
          service.delete_plan(uuid)
          true
        end

        def create
          requires :name
          merge_attributes(service.create_plan(attributes).body)
          self
        end

        def update(parameters = nil)
          requires :uuid
          merge_attributes(service.patch_plan(uuid, parameters).body)
          self
        end
      end
    end
  end
end

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
fog-openstack-0.1.25 lib/fog/planning/openstack/models/plan.rb
fog-openstack-0.1.24 lib/fog/planning/openstack/models/plan.rb
fog-openstack-0.1.23 lib/fog/planning/openstack/models/plan.rb
fog-openstack-0.1.22 lib/fog/planning/openstack/models/plan.rb
fog-openstack-0.1.21 lib/fog/planning/openstack/models/plan.rb
fog-openstack-0.1.20 lib/fog/planning/openstack/models/plan.rb
fog-openstack-0.1.19 lib/fog/planning/openstack/models/plan.rb
fog-openstack-0.1.18 lib/fog/planning/openstack/models/plan.rb
fog-openstack-0.1.17 lib/fog/planning/openstack/models/plan.rb
fog-openstack-0.1.15 lib/fog/planning/openstack/models/plan.rb
fog-openstack-0.1.14 lib/fog/planning/openstack/models/plan.rb
fog-openstack-0.1.13 lib/fog/planning/openstack/models/plan.rb
fog-openstack-0.1.12 lib/fog/planning/openstack/models/plan.rb
fog-openstack-0.1.11 lib/fog/planning/openstack/models/plan.rb