Sha256: e956d60c74f639e49a39735630f162fc3186b3dbfc953b25e49d4fce91403924

Contents?: true

Size: 1.11 KB

Versions: 6

Compression:

Stored size: 1.11 KB

Contents

# -*- coding: utf-8 -*-
require "magellan/cli/resources"

module Magellan
  module Cli
    module Resources

      class Project < Base
        self.resource_name = "project"
        self.resource_dependency = nil
        self.hidden_fields = %w[default_nebula_id created_at updated_at].map(&:freeze).freeze
        self.field_associations = {"organization_id" => {name: "organization", class: "Organization"} }

        desc "update ATTRIBUTES", "update project with ATTRIBUTES"
        def update(attrs)
          s = load_selection("project")
          attrs = JSON.parse(File.readable?(attrs) ? File.read(attrs) : attrs)
          put_json("/admin/project/#{s['id']}/edit", {"project" => attrs})
        end

        desc "create NAME", "create new project with NAME"
        def create(name)
          o = load_selection(Organization.parameter_name)
          params = {
            parameter_name => {
              "organization_id" => o["id"],
              "name" => name,
            }
          }
          post_json("/admin/#{resource_name}/new.json", params)
          select(name)
        end
      end

    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
magellan-cli-0.2.17 lib/magellan/cli/resources/project.rb
magellan-cli-0.2.16 lib/magellan/cli/resources/project.rb
magellan-cli-0.2.15 lib/magellan/cli/resources/project.rb
magellan-cli-0.2.14 lib/magellan/cli/resources/project.rb
magellan-cli-0.2.13 lib/magellan/cli/resources/project.rb
magellan-cli-0.2.12 lib/magellan/cli/resources/project.rb