gcloud 0.11.0 → 0.12.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +8 -8
- data/AUTHENTICATION.md +3 -3
- data/CHANGELOG.md +92 -0
- data/OVERVIEW.md +3 -3
- data/lib/gcloud.rb +75 -25
- data/lib/gcloud/backoff.rb +5 -1
- data/lib/gcloud/bigquery.rb +25 -43
- data/lib/gcloud/bigquery/copy_job.rb +13 -13
- data/lib/gcloud/bigquery/data.rb +20 -16
- data/lib/gcloud/bigquery/dataset.rb +202 -177
- data/lib/gcloud/bigquery/dataset/access.rb +118 -104
- data/lib/gcloud/bigquery/dataset/list.rb +14 -18
- data/lib/gcloud/bigquery/extract_job.rb +12 -12
- data/lib/gcloud/bigquery/insert_response.rb +12 -14
- data/lib/gcloud/bigquery/job.rb +45 -57
- data/lib/gcloud/bigquery/job/list.rb +18 -24
- data/lib/gcloud/bigquery/load_job.rb +35 -27
- data/lib/gcloud/bigquery/project.rb +53 -73
- data/lib/gcloud/bigquery/query_data.rb +28 -35
- data/lib/gcloud/bigquery/query_job.rb +18 -18
- data/lib/gcloud/bigquery/schema.rb +359 -0
- data/lib/gcloud/bigquery/service.rb +506 -0
- data/lib/gcloud/bigquery/table.rb +185 -266
- data/lib/gcloud/bigquery/table/list.rb +15 -19
- data/lib/gcloud/bigquery/view.rb +126 -81
- data/lib/gcloud/datastore.rb +39 -27
- data/lib/gcloud/datastore/commit.rb +2 -2
- data/lib/gcloud/datastore/dataset.rb +8 -19
- data/lib/gcloud/datastore/dataset/lookup_results.rb +2 -4
- data/lib/gcloud/datastore/dataset/query_results.rb +0 -2
- data/lib/gcloud/datastore/entity.rb +7 -1
- data/lib/gcloud/datastore/errors.rb +5 -27
- data/lib/gcloud/datastore/grpc_utils.rb +4 -3
- data/lib/gcloud/datastore/key.rb +6 -0
- data/lib/gcloud/datastore/service.rb +18 -12
- data/lib/gcloud/datastore/transaction.rb +0 -10
- data/lib/gcloud/dns.rb +29 -19
- data/lib/gcloud/dns/change.rb +10 -15
- data/lib/gcloud/dns/change/list.rb +4 -4
- data/lib/gcloud/dns/importer.rb +1 -1
- data/lib/gcloud/dns/project.rb +32 -49
- data/lib/gcloud/dns/record.rb +8 -2
- data/lib/gcloud/dns/record/list.rb +4 -4
- data/lib/gcloud/dns/service.rb +167 -0
- data/lib/gcloud/dns/zone.rb +33 -52
- data/lib/gcloud/dns/zone/list.rb +12 -16
- data/lib/gcloud/errors.rb +31 -19
- data/lib/gcloud/logging.rb +50 -39
- data/lib/gcloud/logging/entry.rb +197 -24
- data/lib/gcloud/logging/entry/list.rb +0 -2
- data/lib/gcloud/logging/logger.rb +1 -1
- data/lib/gcloud/logging/metric.rb +3 -9
- data/lib/gcloud/logging/metric/list.rb +0 -2
- data/lib/gcloud/logging/project.rb +58 -54
- data/lib/gcloud/logging/resource_descriptor.rb +2 -2
- data/lib/gcloud/logging/resource_descriptor/list.rb +0 -2
- data/lib/gcloud/logging/service.rb +32 -23
- data/lib/gcloud/logging/sink.rb +8 -14
- data/lib/gcloud/logging/sink/list.rb +0 -2
- data/lib/gcloud/pubsub.rb +21 -16
- data/lib/gcloud/pubsub/policy.rb +204 -0
- data/lib/gcloud/pubsub/project.rb +26 -38
- data/lib/gcloud/pubsub/service.rb +39 -31
- data/lib/gcloud/pubsub/subscription.rb +56 -59
- data/lib/gcloud/pubsub/subscription/list.rb +4 -4
- data/lib/gcloud/pubsub/topic.rb +69 -66
- data/lib/gcloud/pubsub/topic/list.rb +0 -2
- data/lib/gcloud/pubsub/topic/{batch.rb → publisher.rb} +15 -2
- data/lib/gcloud/resource_manager.rb +27 -26
- data/lib/gcloud/resource_manager/manager.rb +19 -39
- data/lib/gcloud/resource_manager/policy.rb +211 -0
- data/lib/gcloud/resource_manager/project.rb +97 -121
- data/lib/gcloud/resource_manager/project/list.rb +7 -7
- data/lib/gcloud/resource_manager/project/updater.rb +4 -9
- data/lib/gcloud/resource_manager/service.rb +127 -0
- data/lib/gcloud/storage.rb +24 -42
- data/lib/gcloud/storage/bucket.rb +104 -192
- data/lib/gcloud/storage/bucket/acl.rb +47 -143
- data/lib/gcloud/storage/bucket/cors.rb +55 -11
- data/lib/gcloud/storage/bucket/list.rb +14 -14
- data/lib/gcloud/storage/errors.rb +3 -43
- data/lib/gcloud/storage/file.rb +114 -111
- data/lib/gcloud/storage/file/acl.rb +27 -113
- data/lib/gcloud/storage/file/list.rb +21 -21
- data/lib/gcloud/storage/project.rb +49 -59
- data/lib/gcloud/storage/service.rb +347 -0
- data/lib/gcloud/translate.rb +24 -14
- data/lib/gcloud/translate/api.rb +12 -21
- data/lib/gcloud/translate/detection.rb +5 -5
- data/lib/gcloud/translate/language.rb +1 -1
- data/lib/gcloud/translate/service.rb +80 -0
- data/lib/gcloud/translate/translation.rb +6 -6
- data/lib/gcloud/version.rb +1 -1
- data/lib/gcloud/vision.rb +24 -15
- data/lib/gcloud/vision/annotate.rb +24 -21
- data/lib/gcloud/vision/annotation.rb +9 -9
- data/lib/gcloud/vision/annotation/entity.rb +11 -11
- data/lib/gcloud/vision/annotation/face.rb +25 -25
- data/lib/gcloud/vision/annotation/properties.rb +8 -8
- data/lib/gcloud/vision/annotation/safe_search.rb +4 -4
- data/lib/gcloud/vision/annotation/text.rb +7 -7
- data/lib/gcloud/vision/annotation/vertex.rb +1 -1
- data/lib/gcloud/vision/image.rb +11 -11
- data/lib/gcloud/vision/location.rb +5 -2
- data/lib/gcloud/vision/project.rb +14 -16
- data/lib/gcloud/vision/service.rb +66 -0
- data/lib/google/api_client.rb +0 -0
- metadata +27 -24
- data/lib/gcloud/bigquery/connection.rb +0 -624
- data/lib/gcloud/bigquery/errors.rb +0 -68
- data/lib/gcloud/bigquery/table/schema.rb +0 -234
- data/lib/gcloud/dns/connection.rb +0 -173
- data/lib/gcloud/dns/errors.rb +0 -68
- data/lib/gcloud/resource_manager/connection.rb +0 -134
- data/lib/gcloud/resource_manager/errors.rb +0 -68
- data/lib/gcloud/storage/connection.rb +0 -444
- data/lib/gcloud/translate/connection.rb +0 -85
- data/lib/gcloud/translate/errors.rb +0 -68
- data/lib/gcloud/upload.rb +0 -95
- data/lib/gcloud/vision/connection.rb +0 -63
- data/lib/gcloud/vision/errors.rb +0 -69
@@ -1,85 +0,0 @@
|
|
1
|
-
# Copyright 2016 Google Inc. All rights reserved.
|
2
|
-
#
|
3
|
-
# Licensed under the Apache License, Version 2.0 (the "License");
|
4
|
-
# you may not use this file except in compliance with the License.
|
5
|
-
# You may obtain a copy of the License at
|
6
|
-
#
|
7
|
-
# http://www.apache.org/licenses/LICENSE-2.0
|
8
|
-
#
|
9
|
-
# Unless required by applicable law or agreed to in writing, software
|
10
|
-
# distributed under the License is distributed on an "AS IS" BASIS,
|
11
|
-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
12
|
-
# See the License for the specific language governing permissions and
|
13
|
-
# limitations under the License.
|
14
|
-
|
15
|
-
|
16
|
-
require "gcloud/version"
|
17
|
-
require "gcloud/backoff"
|
18
|
-
require "google/api_client"
|
19
|
-
|
20
|
-
module Gcloud
|
21
|
-
module Translate
|
22
|
-
##
|
23
|
-
# @private Represents the connection to Translate, as well as expose the API
|
24
|
-
# calls
|
25
|
-
class Connection
|
26
|
-
API_VERSION = "v2"
|
27
|
-
|
28
|
-
attr_accessor :client
|
29
|
-
|
30
|
-
##
|
31
|
-
# Creates a new Connection instance.
|
32
|
-
def initialize key
|
33
|
-
@client = Google::APIClient.new application_name: "gcloud-ruby",
|
34
|
-
application_version: Gcloud::VERSION,
|
35
|
-
authorization: nil
|
36
|
-
@translate = @client.discovered_api "translate", API_VERSION
|
37
|
-
@client.key = key # set key after discovery, helps with tests
|
38
|
-
end
|
39
|
-
|
40
|
-
def translate text, to: nil, from: nil, format: nil, cid: nil
|
41
|
-
params = { q: Array(text),
|
42
|
-
target: to,
|
43
|
-
source: from,
|
44
|
-
format: format,
|
45
|
-
cid: cid,
|
46
|
-
prettyprint: false
|
47
|
-
}.delete_if { |_, v| v.nil? }
|
48
|
-
|
49
|
-
execute(
|
50
|
-
api_method: @translate.translations.list,
|
51
|
-
parameters: params
|
52
|
-
)
|
53
|
-
end
|
54
|
-
|
55
|
-
def detect text
|
56
|
-
execute(
|
57
|
-
api_method: @translate.detections.list,
|
58
|
-
parameters: { q: Array(text), prettyprint: false }
|
59
|
-
)
|
60
|
-
end
|
61
|
-
|
62
|
-
def languages language = nil
|
63
|
-
params = { target: language,
|
64
|
-
prettyprint: false }.delete_if { |_, v| v.nil? }
|
65
|
-
|
66
|
-
execute(
|
67
|
-
api_method: @translate.languages.list,
|
68
|
-
parameters: params
|
69
|
-
)
|
70
|
-
end
|
71
|
-
|
72
|
-
def inspect
|
73
|
-
"#{self.class}(#{@project})"
|
74
|
-
end
|
75
|
-
|
76
|
-
protected
|
77
|
-
|
78
|
-
def execute options
|
79
|
-
Gcloud::Backoff.new.execute_gapi do
|
80
|
-
@client.execute options
|
81
|
-
end
|
82
|
-
end
|
83
|
-
end
|
84
|
-
end
|
85
|
-
end
|
@@ -1,68 +0,0 @@
|
|
1
|
-
# Copyright 2016 Google Inc. All rights reserved.
|
2
|
-
#
|
3
|
-
# Licensed under the Apache License, Version 2.0 (the "License");
|
4
|
-
# you may not use this file except in compliance with the License.
|
5
|
-
# You may obtain a copy of the License at
|
6
|
-
#
|
7
|
-
# http://www.apache.org/licenses/LICENSE-2.0
|
8
|
-
#
|
9
|
-
# Unless required by applicable law or agreed to in writing, software
|
10
|
-
# distributed under the License is distributed on an "AS IS" BASIS,
|
11
|
-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
12
|
-
# See the License for the specific language governing permissions and
|
13
|
-
# limitations under the License.
|
14
|
-
|
15
|
-
|
16
|
-
require "gcloud/errors"
|
17
|
-
|
18
|
-
module Gcloud
|
19
|
-
module Translate
|
20
|
-
##
|
21
|
-
# Base Translate exception class.
|
22
|
-
class Error < Gcloud::Error
|
23
|
-
end
|
24
|
-
|
25
|
-
##
|
26
|
-
# Raised when an API call is not successful.
|
27
|
-
class ApiError < Error
|
28
|
-
##
|
29
|
-
# The code of the error.
|
30
|
-
attr_reader :code
|
31
|
-
|
32
|
-
##
|
33
|
-
# The errors encountered.
|
34
|
-
attr_reader :errors
|
35
|
-
|
36
|
-
# @private
|
37
|
-
def initialize message, code, errors = []
|
38
|
-
super message
|
39
|
-
@code = code
|
40
|
-
@errors = errors
|
41
|
-
end
|
42
|
-
|
43
|
-
# @private
|
44
|
-
def self.from_response resp
|
45
|
-
if resp.data? && resp.data["error"]
|
46
|
-
from_response_data resp.data["error"]
|
47
|
-
else
|
48
|
-
from_response_status resp
|
49
|
-
end
|
50
|
-
end
|
51
|
-
|
52
|
-
# @private
|
53
|
-
def self.from_response_data error
|
54
|
-
new error["message"], error["code"], error["errors"]
|
55
|
-
end
|
56
|
-
|
57
|
-
# @private
|
58
|
-
def self.from_response_status resp
|
59
|
-
if resp.status == 404
|
60
|
-
new "#{resp.error_message}: #{resp.request.uri.request_uri}",
|
61
|
-
resp.status
|
62
|
-
else
|
63
|
-
new resp.error_message, resp.status
|
64
|
-
end
|
65
|
-
end
|
66
|
-
end
|
67
|
-
end
|
68
|
-
end
|
data/lib/gcloud/upload.rb
DELETED
@@ -1,95 +0,0 @@
|
|
1
|
-
# Copyright 2014 Google Inc. All rights reserved.
|
2
|
-
#
|
3
|
-
# Licensed under the Apache License, Version 2.0 (the "License");
|
4
|
-
# you may not use this file except in compliance with the License.
|
5
|
-
# You may obtain a copy of the License at
|
6
|
-
#
|
7
|
-
# http://www.apache.org/licenses/LICENSE-2.0
|
8
|
-
#
|
9
|
-
# Unless required by applicable law or agreed to in writing, software
|
10
|
-
# distributed under the License is distributed on an "AS IS" BASIS,
|
11
|
-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
12
|
-
# See the License for the specific language governing permissions and
|
13
|
-
# limitations under the License.
|
14
|
-
|
15
|
-
|
16
|
-
require "gcloud"
|
17
|
-
|
18
|
-
module Gcloud
|
19
|
-
##
|
20
|
-
# # Upload Settings
|
21
|
-
#
|
22
|
-
# Upload allows users to configure how files are uploaded to the Google Cloud
|
23
|
-
# Service APIs.
|
24
|
-
#
|
25
|
-
# @example
|
26
|
-
# require "gcloud/upload"
|
27
|
-
#
|
28
|
-
# # Set the default threshold to 10 MiB.
|
29
|
-
# Gcloud::Upload.resumable_threshold = 10_000_000
|
30
|
-
#
|
31
|
-
module Upload
|
32
|
-
##
|
33
|
-
# Retrieve resumable threshold.
|
34
|
-
# If uploads are larger in size than this value then
|
35
|
-
# resumable uploads are used.
|
36
|
-
#
|
37
|
-
# The default value is 5 MiB (5,000,000 bytes).
|
38
|
-
def self.resumable_threshold
|
39
|
-
@@resumable_threshold
|
40
|
-
end
|
41
|
-
|
42
|
-
##
|
43
|
-
# Sets a new resumable threshold value in number of bytes.
|
44
|
-
def self.resumable_threshold= new_resumable_threshold
|
45
|
-
@@resumable_threshold = new_resumable_threshold.to_i
|
46
|
-
end
|
47
|
-
|
48
|
-
##
|
49
|
-
# Default chunk size used on resumable uploads.
|
50
|
-
#
|
51
|
-
# The default value is 10 MB (10,485,760 bytes).
|
52
|
-
def self.default_chunk_size
|
53
|
-
@@default_chunk_size
|
54
|
-
end
|
55
|
-
|
56
|
-
##
|
57
|
-
# Sets a new default chunk_size value in number of bytes. Must be a multiple
|
58
|
-
# of 256KB (262,144).
|
59
|
-
def self.default_chunk_size= new_chunk_size
|
60
|
-
new_chunk_size = normalize_chunk_size new_chunk_size
|
61
|
-
@@default_chunk_size = new_chunk_size if new_chunk_size
|
62
|
-
end
|
63
|
-
|
64
|
-
##
|
65
|
-
# @private Determines if a chunk_size is valid. Must be a multiple of 256KB.
|
66
|
-
# Returns lowest possible chunk_size if given a very small value.
|
67
|
-
def self.normalize_chunk_size chunk_size
|
68
|
-
chunk_size = chunk_size.to_i
|
69
|
-
chunk_mod = 256 * 1024 # 256KB
|
70
|
-
if (chunk_size.to_i % chunk_mod) != 0
|
71
|
-
chunk_size = (chunk_size / chunk_mod) * chunk_mod
|
72
|
-
end
|
73
|
-
return chunk_mod if chunk_size.zero?
|
74
|
-
chunk_size
|
75
|
-
end
|
76
|
-
|
77
|
-
##
|
78
|
-
# @private Determines if a chunk_size is valid. Must be a multiple of 256KB.
|
79
|
-
# Returns the default chunk_size if one is not provided.
|
80
|
-
def self.verify_chunk_size chunk_size, file_size
|
81
|
-
if chunk_size.to_i.zero?
|
82
|
-
return nil if file_size < default_chunk_size
|
83
|
-
return default_chunk_size
|
84
|
-
else
|
85
|
-
chunk_size = normalize_chunk_size chunk_size
|
86
|
-
return nil if file_size < chunk_size
|
87
|
-
return chunk_size
|
88
|
-
end
|
89
|
-
end
|
90
|
-
|
91
|
-
# Set the default values for threshold and chunk_size.
|
92
|
-
self.resumable_threshold = 5_000_000 # 5 MiB
|
93
|
-
self.default_chunk_size = 10_485_760 # 10 MB
|
94
|
-
end
|
95
|
-
end
|
@@ -1,63 +0,0 @@
|
|
1
|
-
# Copyright 2016 Google Inc. All rights reserved.
|
2
|
-
#
|
3
|
-
# Licensed under the Apache License, Version 2.0 (the "License");
|
4
|
-
# you may not use this file except in compliance with the License.
|
5
|
-
# You may obtain a copy of the License at
|
6
|
-
#
|
7
|
-
# http://www.apache.org/licenses/LICENSE-2.0
|
8
|
-
#
|
9
|
-
# Unless required by applicable law or agreed to in writing, software
|
10
|
-
# distributed under the License is distributed on an "AS IS" BASIS,
|
11
|
-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
12
|
-
# See the License for the specific language governing permissions and
|
13
|
-
# limitations under the License.
|
14
|
-
|
15
|
-
|
16
|
-
require "gcloud/version"
|
17
|
-
require "gcloud/backoff"
|
18
|
-
require "google/api_client"
|
19
|
-
|
20
|
-
module Gcloud
|
21
|
-
module Vision
|
22
|
-
##
|
23
|
-
# @private Represents the connection to Vision,
|
24
|
-
# as well as expose the API calls.
|
25
|
-
class Connection
|
26
|
-
attr_accessor :project
|
27
|
-
attr_accessor :credentials
|
28
|
-
|
29
|
-
##
|
30
|
-
# Creates a new Connection instance.
|
31
|
-
def initialize project, credentials
|
32
|
-
@project = project
|
33
|
-
@credentials = credentials
|
34
|
-
@client = Google::APIClient.new application_name: "gcloud-ruby",
|
35
|
-
application_version: Gcloud::VERSION
|
36
|
-
@client.authorization = @credentials.client
|
37
|
-
custom_discovery_url = Addressable::URI.parse(
|
38
|
-
"https://vision.googleapis.com/$discovery/rest?version=v1")
|
39
|
-
@client.register_discovery_uri "vision", "v1", custom_discovery_url
|
40
|
-
@vision = @client.discovered_api "vision", "v1"
|
41
|
-
end
|
42
|
-
|
43
|
-
def annotate requests
|
44
|
-
execute(
|
45
|
-
api_method: @vision.images.annotate,
|
46
|
-
body_object: { requests: requests }
|
47
|
-
)
|
48
|
-
end
|
49
|
-
|
50
|
-
def inspect
|
51
|
-
"#{self.class}(#{@project})"
|
52
|
-
end
|
53
|
-
|
54
|
-
protected
|
55
|
-
|
56
|
-
def execute options
|
57
|
-
Gcloud::Backoff.new.execute_gapi do
|
58
|
-
@client.execute options
|
59
|
-
end
|
60
|
-
end
|
61
|
-
end
|
62
|
-
end
|
63
|
-
end
|
data/lib/gcloud/vision/errors.rb
DELETED
@@ -1,69 +0,0 @@
|
|
1
|
-
# Copyright 2016 Google Inc. All rights reserved.
|
2
|
-
#
|
3
|
-
# Licensed under the Apache License, Version 2.0 (the "License");
|
4
|
-
# you may not use this file except in compliance with the License.
|
5
|
-
# You may obtain a copy of the License at
|
6
|
-
#
|
7
|
-
# http://www.apache.org/licenses/LICENSE-2.0
|
8
|
-
#
|
9
|
-
# Unless required by applicable law or agreed to in writing, software
|
10
|
-
# distributed under the License is distributed on an "AS IS" BASIS,
|
11
|
-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
12
|
-
# See the License for the specific language governing permissions and
|
13
|
-
# limitations under the License.
|
14
|
-
|
15
|
-
|
16
|
-
require "gcloud/errors"
|
17
|
-
|
18
|
-
module Gcloud
|
19
|
-
module Vision
|
20
|
-
##
|
21
|
-
# # Vision Error
|
22
|
-
#
|
23
|
-
# Base Vision exception class.
|
24
|
-
class Error < Gcloud::Error
|
25
|
-
##
|
26
|
-
# The response object of the failed HTTP request.
|
27
|
-
attr_reader :response
|
28
|
-
|
29
|
-
# @private
|
30
|
-
def self.from_response resp
|
31
|
-
new.tap do |e|
|
32
|
-
e.instance_variable_set "@response", resp
|
33
|
-
end
|
34
|
-
end
|
35
|
-
end
|
36
|
-
|
37
|
-
##
|
38
|
-
# # ApiError
|
39
|
-
#
|
40
|
-
# Raised when an API call is not successful.
|
41
|
-
class ApiError < Error
|
42
|
-
##
|
43
|
-
# The HTTP code of the error.
|
44
|
-
attr_reader :code
|
45
|
-
|
46
|
-
##
|
47
|
-
# The Google API error status.
|
48
|
-
attr_reader :status
|
49
|
-
|
50
|
-
##
|
51
|
-
# The errors encountered.
|
52
|
-
attr_reader :errors
|
53
|
-
|
54
|
-
# @private
|
55
|
-
def self.from_response resp
|
56
|
-
if resp.data? && resp.data["error"]
|
57
|
-
new(resp.data["error"]["message"]).tap do |e|
|
58
|
-
e.instance_variable_set "@code", resp.data["error"]["code"]
|
59
|
-
e.instance_variable_set "@status", resp.data["error"]["status"]
|
60
|
-
e.instance_variable_set "@errors", resp.data["error"]["errors"]
|
61
|
-
e.instance_variable_set "@response", resp
|
62
|
-
end
|
63
|
-
else
|
64
|
-
Error.from_response_status resp
|
65
|
-
end
|
66
|
-
end
|
67
|
-
end
|
68
|
-
end
|
69
|
-
end
|