Module: Gcloud

Defined in:
lib/gcloud/backoff.rb,
lib/gcloud.rb,
lib/gcloud/storage.rb,
lib/gcloud/version.rb,
lib/gcloud/datastore.rb,
lib/gcloud/credentials.rb,
lib/gcloud/storage/file.rb,
lib/gcloud/datastore/key.rb,
lib/gcloud/storage/bucket.rb,
lib/gcloud/storage/errors.rb,
lib/gcloud/datastore/proto.rb,
lib/gcloud/datastore/query.rb,
lib/gcloud/storage/project.rb,
lib/gcloud/datastore/entity.rb,
lib/gcloud/datastore/errors.rb,
lib/gcloud/storage/file/acl.rb,
lib/gcloud/datastore/dataset.rb,
lib/gcloud/storage/file/list.rb,
lib/gcloud/storage/bucket/acl.rb,
lib/gcloud/storage/connection.rb,
lib/gcloud/storage/bucket/list.rb,
lib/gcloud/storage/credentials.rb,
lib/gcloud/datastore/connection.rb,
lib/gcloud/datastore/properties.rb,
lib/gcloud/datastore/credentials.rb,
lib/gcloud/datastore/transaction.rb,
lib/gcloud/proto/datastore_v1.pb.rb,
lib/gcloud/storage/file/verifier.rb,
lib/gcloud/datastore/dataset/query_results.rb,
lib/gcloud/datastore/dataset/lookup_results.rb

Overview

Copyright 2014 Google Inc. All rights reserved.

Licensed under the Apache License, Version 2.0 (the “License”); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an “AS IS” BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Defined Under Namespace

Modules: Datastore, Storage Classes: Backoff, Credentials, Error

Constant Summary collapse

VERSION =
"0.1.0"

Class Method Summary collapse

Class Method Details

.datastore(project = ENV["DATASTORE_PROJECT"], keyfile = nil) ⇒ Gcloud::Datastore::Dataset

Create a new Gcloud::Datastore::Dataset.

entity = Gcloud::Datastore::Entity.new
entity.key = Gcloud::Datastore::Key.new "Task"
entity["description"] = "Get started with Google Cloud"
entity["completed"] = false

dataset = Gcloud.datastore "my-todo-project",
                           "/path/to/keyfile.json"
dataset.save entity

you are connecting to. Google Cloud. The file must readable. See Gcloud::Datastore::Dataset

Parameters:

  • dataset_id (String)

    the dataset identifier for the Datastore

  • keyfile (String) (defaults to: nil)

    the path to the keyfile you downloaded from

Returns:



43
44
45
46
47
48
49
50
51
# File 'lib/gcloud/datastore.rb', line 43

def self.datastore project = ENV["DATASTORE_PROJECT"],
                   keyfile = nil
  if keyfile.nil?
    credentials = Gcloud::Datastore::Credentials.default
  else
    credentials = Gcloud::Datastore::Credentials.new keyfile
  end
  Gcloud::Datastore::Dataset.new project, credentials
end

.storage(project = ENV["STORAGE_PROJECT"], keyfile = nil) ⇒ Gcloud::Storage::Project

Create a new Storage project.

storage = Gcloud.storage "my-todo-project",
                         "/path/to/keyfile.json"
bucket = storage.find_bucket "my-bucket"
file = bucket.find_file "path/to/my-file.ext"

account you are connecting to. Google Cloud. The file must readable. See Gcloud::Storage::Project

Parameters:

  • project (String) (defaults to: ENV["STORAGE_PROJECT"])

    the project identifier for the Storage

  • keyfile (String) (defaults to: nil)

    the path to the keyfile you downloaded from

Returns:



36
37
38
39
40
41
42
43
44
# File 'lib/gcloud/storage.rb', line 36

def self.storage project = ENV["STORAGE_PROJECT"],
                 keyfile = nil
  if keyfile.nil?
    credentials = Gcloud::Storage::Credentials.default
  else
    credentials = Gcloud::Storage::Credentials.new keyfile
  end
  Gcloud::Storage::Project.new project, credentials
end