Class: Google::Cloud::Gemserver::CLI::Project

Inherits:
Object
  • Object
show all
Defined in:
lib/google/cloud/gemserver/cli/project.rb

Overview

Project

Holds a reference to a project on Google Cloud Platform.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name = nil) ⇒ Project

Initializes the project name and Configuration object.



43
44
45
46
# File 'lib/google/cloud/gemserver/cli/project.rb', line 43

def initialize name = nil
  @proj_name = name
  @config = Configuration.new
end

Instance Attribute Details

#configConfiguration

The Configuration object storing the settings used by the Project object.

Returns:



39
40
41
# File 'lib/google/cloud/gemserver/cli/project.rb', line 39

def config
  @config
end

#proj_nameString

The name of the project on Google Cloud platform; same as ID.

Returns:

  • (String)


33
34
35
# File 'lib/google/cloud/gemserver/cli/project.rb', line 33

def proj_name
  @proj_name
end

Instance Method Details

#createObject

Fetches a reference to the given project on Google Cloud Platform and prompts the user to configure it correctly.



51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
# File 'lib/google/cloud/gemserver/cli/project.rb', line 51

def create
  raise "Project name was not provided!" unless @proj_name
  begin
    @config.update_config @proj_name, :proj_id
    create_gae_project
    enable_api
    enable_billing
    project
  rescue Google::Cloud::PermissionDeniedError, RuntimeError => e
    puts "Permission denied. You might not be authorized with " \
      "gcloud. Read github.com/GoogleCloudPlatform/google-cloud`." \
      "-ruby/google-cloud-gemserver/docs/authentication.md for " \
      "more information on how to get authenticated."
    puts "If you still get this error the Cloud Resource Manager " \
      "API might not be enabled."
    abort "More details: #{e.message}"
  end
end