Class: Gcloud::Search::Project
- Inherits:
-
Object
- Object
- Gcloud::Search::Project
- Defined in:
- lib/gcloud/search/project.rb
Overview
# Project
Projects are top-level containers in Google Cloud Platform. They store information about billing and authorized users, and they control access to Google Cloud Search resources. Each project has a friendly name and a unique ID. Projects can be created only in the [Google Developers Console](console.developers.google.com). See Gcloud#search.
Instance Attribute Summary collapse
Class Method Summary collapse
Instance Method Summary collapse
-
#index(index_id, skip_lookup: false) ⇒ Gcloud::Search::Index?
Retrieves an existing index by ID.
-
#indexes(prefix: nil, token: nil, max: nil) ⇒ Array<Gcloud::Search::Index>
Retrieves the list of indexes belonging to the project.
-
#initialize(project, credentials) ⇒ Project
constructor
See Gcloud.search.
-
#project ⇒ String
The ID of the current project.
Constructor Details
#initialize(project, credentials) ⇒ Project
See Gcloud.search
49 50 51 52 53 |
# File 'lib/gcloud/search/project.rb', line 49 def initialize project, credentials project = project.to_s # Always cast to a string fail ArgumentError, "project is missing" if project.empty? @connection = Connection.new project, credentials end |
Instance Attribute Details
#connection ⇒ Object
43 44 45 |
# File 'lib/gcloud/search/project.rb', line 43 def connection @connection end |
Class Method Details
.default_project ⇒ Object
74 75 76 77 78 79 |
# File 'lib/gcloud/search/project.rb', line 74 def self.default_project ENV["SEARCH_PROJECT"] || ENV["GCLOUD_PROJECT"] || ENV["GOOGLE_CLOUD_PROJECT"] || Gcloud::GCE.project_id end |
Instance Method Details
#index(index_id, skip_lookup: false) ⇒ Gcloud::Search::Index?
Retrieves an existing index by ID.
112 113 114 115 116 117 118 119 120 |
# File 'lib/gcloud/search/project.rb', line 112 def index index_id, skip_lookup: false if skip_lookup index_hash = { "indexId" => index_id, "projectId" => project } return Gcloud::Search::Index.from_raw index_hash, connection end indexes(prefix: index_id).all.detect do |ix| ix.index_id == index_id end end |
#indexes(prefix: nil, token: nil, max: nil) ⇒ Array<Gcloud::Search::Index>
Retrieves the list of indexes belonging to the project.
161 162 163 164 165 166 167 168 169 170 |
# File 'lib/gcloud/search/project.rb', line 161 def indexes prefix: nil, token: nil, max: nil ensure_connection! = { prefix: prefix, token: token, max: max } resp = connection.list_indexes if resp.success? Index::List.from_response resp, connection else fail ApiError.from_response(resp) end end |
#project ⇒ String
The ID of the current project.
68 69 70 |
# File 'lib/gcloud/search/project.rb', line 68 def project connection.project end |