gcloud 0.4.1 → 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +8 -8
- data/CHANGELOG.md +15 -0
- data/OVERVIEW.md +38 -5
- data/lib/gcloud.rb +55 -4
- data/lib/gcloud/bigquery/data.rb +2 -0
- data/lib/gcloud/bigquery/dataset.rb +1 -1
- data/lib/gcloud/bigquery/dataset/list.rb +2 -0
- data/lib/gcloud/bigquery/job/list.rb +2 -0
- data/lib/gcloud/bigquery/project.rb +2 -9
- data/lib/gcloud/bigquery/table/list.rb +2 -0
- data/lib/gcloud/datastore.rb +23 -28
- data/lib/gcloud/datastore/connection.rb +3 -1
- data/lib/gcloud/datastore/dataset.rb +167 -22
- data/lib/gcloud/datastore/dataset/lookup_results.rb +2 -0
- data/lib/gcloud/datastore/dataset/query_results.rb +2 -0
- data/lib/gcloud/datastore/entity.rb +11 -11
- data/lib/gcloud/datastore/key.rb +33 -16
- data/lib/gcloud/dns/change/list.rb +2 -0
- data/lib/gcloud/dns/project.rb +1 -1
- data/lib/gcloud/dns/record/list.rb +2 -0
- data/lib/gcloud/dns/zone.rb +2 -2
- data/lib/gcloud/dns/zone/list.rb +2 -0
- data/lib/gcloud/gce.rb +0 -5
- data/lib/gcloud/pubsub.rb +65 -62
- data/lib/gcloud/pubsub/connection.rb +20 -2
- data/lib/gcloud/pubsub/project.rb +233 -72
- data/lib/gcloud/pubsub/subscription.rb +45 -13
- data/lib/gcloud/pubsub/subscription/list.rb +2 -0
- data/lib/gcloud/pubsub/topic.rb +66 -85
- data/lib/gcloud/pubsub/topic/list.rb +2 -0
- data/lib/gcloud/resource_manager.rb +244 -0
- data/lib/gcloud/resource_manager/connection.rb +124 -0
- data/lib/gcloud/resource_manager/credentials.rb +30 -0
- data/lib/gcloud/resource_manager/errors.rb +64 -0
- data/lib/gcloud/resource_manager/manager.rb +319 -0
- data/lib/gcloud/resource_manager/project.rb +529 -0
- data/lib/gcloud/resource_manager/project/list.rb +91 -0
- data/lib/gcloud/resource_manager/project/updater.rb +137 -0
- data/lib/gcloud/storage/bucket.rb +1 -1
- data/lib/gcloud/storage/bucket/cors.rb +2 -0
- data/lib/gcloud/storage/bucket/list.rb +2 -0
- data/lib/gcloud/storage/file/list.rb +2 -0
- data/lib/gcloud/storage/project.rb +1 -1
- data/lib/gcloud/version.rb +1 -1
- metadata +10 -2
@@ -0,0 +1,91 @@
|
|
1
|
+
#--
|
2
|
+
# Copyright 2015 Google Inc. All rights reserved.
|
3
|
+
#
|
4
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
5
|
+
# you may not use this file except in compliance with the License.
|
6
|
+
# You may obtain a copy of the License at
|
7
|
+
#
|
8
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
9
|
+
#
|
10
|
+
# Unless required by applicable law or agreed to in writing, software
|
11
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
12
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
13
|
+
# See the License for the specific language governing permissions and
|
14
|
+
# limitations under the License.
|
15
|
+
|
16
|
+
module Gcloud
|
17
|
+
module ResourceManager
|
18
|
+
class Project
|
19
|
+
##
|
20
|
+
# Project::List is a special case Array with additional values.
|
21
|
+
class List < DelegateClass(::Array)
|
22
|
+
##
|
23
|
+
# If not empty, indicates that there are more projects that match
|
24
|
+
# the request and this value should be passed to continue.
|
25
|
+
attr_accessor :token
|
26
|
+
|
27
|
+
##
|
28
|
+
# Create a new Project::List with an array of Project instances.
|
29
|
+
def initialize arr = []
|
30
|
+
super arr
|
31
|
+
end
|
32
|
+
|
33
|
+
##
|
34
|
+
# Whether there a next page of projects.
|
35
|
+
def next?
|
36
|
+
!token.nil?
|
37
|
+
end
|
38
|
+
|
39
|
+
##
|
40
|
+
# Retrieve the next page of projects.
|
41
|
+
def next
|
42
|
+
return nil unless next?
|
43
|
+
ensure_manager!
|
44
|
+
@manager.projects token: token
|
45
|
+
end
|
46
|
+
|
47
|
+
##
|
48
|
+
# Retrieves all projects by repeatedly loading pages until #next?
|
49
|
+
# returns false. Returns the list instance for method chaining.
|
50
|
+
#
|
51
|
+
# === Example
|
52
|
+
#
|
53
|
+
# require "gcloud"
|
54
|
+
#
|
55
|
+
# gcloud = Gcloud.new
|
56
|
+
# resource_manager = gcloud.resource_manager
|
57
|
+
# projects = resource_manager.projects.all # Load all projects
|
58
|
+
#
|
59
|
+
def all
|
60
|
+
while next?
|
61
|
+
next_projects = self.next
|
62
|
+
push(*next_projects)
|
63
|
+
self.token = next_projects.token
|
64
|
+
end
|
65
|
+
self
|
66
|
+
end
|
67
|
+
|
68
|
+
##
|
69
|
+
# New Projects::List from a response object.
|
70
|
+
def self.from_response resp, manager #:nodoc:
|
71
|
+
projects = new(Array(resp.data["projects"]).map do |gapi_object|
|
72
|
+
Project.from_gapi gapi_object, manager.connection
|
73
|
+
end)
|
74
|
+
projects.instance_eval do
|
75
|
+
@token = resp.data["nextPageToken"]
|
76
|
+
@manager = manager
|
77
|
+
end
|
78
|
+
projects
|
79
|
+
end
|
80
|
+
|
81
|
+
protected
|
82
|
+
|
83
|
+
##
|
84
|
+
# Raise an error unless an active connection is available.
|
85
|
+
def ensure_manager!
|
86
|
+
fail "Must have active connection" unless @manager
|
87
|
+
end
|
88
|
+
end
|
89
|
+
end
|
90
|
+
end
|
91
|
+
end
|
@@ -0,0 +1,137 @@
|
|
1
|
+
#--
|
2
|
+
# Copyright 2015 Google Inc. All rights reserved.
|
3
|
+
#
|
4
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
5
|
+
# you may not use this file except in compliance with the License.
|
6
|
+
# You may obtain a copy of the License at
|
7
|
+
#
|
8
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
9
|
+
#
|
10
|
+
# Unless required by applicable law or agreed to in writing, software
|
11
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
12
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
13
|
+
# See the License for the specific language governing permissions and
|
14
|
+
# limitations under the License.
|
15
|
+
|
16
|
+
require "time"
|
17
|
+
require "gcloud/resource_manager/errors"
|
18
|
+
|
19
|
+
module Gcloud
|
20
|
+
module ResourceManager
|
21
|
+
class Project
|
22
|
+
##
|
23
|
+
# = Project Updater
|
24
|
+
#
|
25
|
+
# This object is used by Project#update when passed a block. These methods
|
26
|
+
# are used to update the project data in a single API call.
|
27
|
+
#
|
28
|
+
# require "gcloud"
|
29
|
+
#
|
30
|
+
# gcloud = Gcloud.new
|
31
|
+
# resource_manager = gcloud.resource_manager
|
32
|
+
# project = resource_manager.project "tokyo-rain-123"
|
33
|
+
# project.update do |p|
|
34
|
+
# p.name = "My Project"
|
35
|
+
# p.labels["env"] = "production"
|
36
|
+
# end
|
37
|
+
#
|
38
|
+
class Updater < DelegateClass(Project)
|
39
|
+
##
|
40
|
+
# Create an Updater object.
|
41
|
+
def initialize project #:nodoc:
|
42
|
+
super project
|
43
|
+
end
|
44
|
+
|
45
|
+
##
|
46
|
+
# Updates the user-assigned name of the project. This field is optional
|
47
|
+
# and can remain unset.
|
48
|
+
#
|
49
|
+
# Allowed characters are: lowercase and uppercase letters, numbers,
|
50
|
+
# hyphen, single-quote, double-quote, space, and exclamation point.
|
51
|
+
#
|
52
|
+
# === Example
|
53
|
+
#
|
54
|
+
# require "gcloud"
|
55
|
+
#
|
56
|
+
# gcloud = Gcloud.new
|
57
|
+
# resource_manager = gcloud.resource_manager
|
58
|
+
# project = resource_manager.project "tokyo-rain-123"
|
59
|
+
# project.update do |p|
|
60
|
+
# p.name = "My Project"
|
61
|
+
# end
|
62
|
+
#
|
63
|
+
def name= new_name
|
64
|
+
gapi["name"] = new_name
|
65
|
+
end
|
66
|
+
|
67
|
+
##
|
68
|
+
# The labels associated with this project.
|
69
|
+
#
|
70
|
+
# Label keys must be between 1 and 63 characters long and must conform
|
71
|
+
# to the following regular expression:
|
72
|
+
# <code>[a-z]([-a-z0-9]*[a-z0-9])?</code>.
|
73
|
+
#
|
74
|
+
# Label values must be between 0 and 63 characters long and must conform
|
75
|
+
# to the regular expression <code>([a-z]([-a-z0-9]*[a-z0-9])?)?</code>.
|
76
|
+
#
|
77
|
+
# No more than 256 labels can be associated with a given resource.
|
78
|
+
# (+Hash+)
|
79
|
+
#
|
80
|
+
# === Example
|
81
|
+
#
|
82
|
+
# require "gcloud"
|
83
|
+
#
|
84
|
+
# gcloud = Gcloud.new
|
85
|
+
# resource_manager = gcloud.resource_manager
|
86
|
+
# project = resource_manager.project "tokyo-rain-123"
|
87
|
+
# project.update do |p|
|
88
|
+
# p.labels["env"] = "production"
|
89
|
+
# end
|
90
|
+
#
|
91
|
+
def labels
|
92
|
+
gapi["labels"]
|
93
|
+
end
|
94
|
+
|
95
|
+
##
|
96
|
+
# Updates the labels associated with this project.
|
97
|
+
#
|
98
|
+
# Label keys must be between 1 and 63 characters long and must conform
|
99
|
+
# to the following regular expression:
|
100
|
+
# <code>[a-z]([-a-z0-9]*[a-z0-9])?</code>.
|
101
|
+
#
|
102
|
+
# Label values must be between 0 and 63 characters long and must conform
|
103
|
+
# to the regular expression <code>([a-z]([-a-z0-9]*[a-z0-9])?)?</code>.
|
104
|
+
#
|
105
|
+
# No more than 256 labels can be associated with a given resource.
|
106
|
+
# (+Hash+)
|
107
|
+
#
|
108
|
+
# === Example
|
109
|
+
#
|
110
|
+
# require "gcloud"
|
111
|
+
#
|
112
|
+
# gcloud = Gcloud.new
|
113
|
+
# resource_manager = gcloud.resource_manager
|
114
|
+
# project = resource_manager.project "tokyo-rain-123"
|
115
|
+
# project.update do |p|
|
116
|
+
# p.labels = { "env" => "production" }
|
117
|
+
# end
|
118
|
+
#
|
119
|
+
def labels= new_labels
|
120
|
+
gapi["labels"] = new_labels
|
121
|
+
end
|
122
|
+
|
123
|
+
##
|
124
|
+
# Create an Updater object.
|
125
|
+
def self.from_project project #:nodoc:
|
126
|
+
dupe_gapi = project.gapi.dup
|
127
|
+
dupe_gapi = dupe_gapi.to_hash if dupe_gapi.respond_to? :to_hash
|
128
|
+
if dupe_gapi["labels"].respond_to? :to_hash
|
129
|
+
dupe_gapi["labels"] = dupe_gapi["labels"].to_hash
|
130
|
+
end
|
131
|
+
dupe_project = Project.from_gapi dupe_gapi, nil # no way to update
|
132
|
+
Updater.new dupe_project
|
133
|
+
end
|
134
|
+
end
|
135
|
+
end
|
136
|
+
end
|
137
|
+
end
|
data/lib/gcloud/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: gcloud
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.5.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Silvano Luciani
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2015-10-
|
12
|
+
date: 2015-10-29 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: beefcake
|
@@ -299,6 +299,14 @@ files:
|
|
299
299
|
- lib/gcloud/pubsub/subscription/list.rb
|
300
300
|
- lib/gcloud/pubsub/topic.rb
|
301
301
|
- lib/gcloud/pubsub/topic/list.rb
|
302
|
+
- lib/gcloud/resource_manager.rb
|
303
|
+
- lib/gcloud/resource_manager/connection.rb
|
304
|
+
- lib/gcloud/resource_manager/credentials.rb
|
305
|
+
- lib/gcloud/resource_manager/errors.rb
|
306
|
+
- lib/gcloud/resource_manager/manager.rb
|
307
|
+
- lib/gcloud/resource_manager/project.rb
|
308
|
+
- lib/gcloud/resource_manager/project/list.rb
|
309
|
+
- lib/gcloud/resource_manager/project/updater.rb
|
302
310
|
- lib/gcloud/storage.rb
|
303
311
|
- lib/gcloud/storage/bucket.rb
|
304
312
|
- lib/gcloud/storage/bucket/acl.rb
|