google-api-client 0.9.pre1 → 0.9.pre2
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 +4 -4
- data/CHANGELOG.md +5 -0
- data/README.md +4 -3
- data/api_names.yaml +42 -0
- data/api_names_out.yaml +977 -651
- data/generated/google/apis/adexchangebuyer_v1_3.rb +1 -1
- data/generated/google/apis/adexchangeseller_v2_0.rb +1 -1
- data/generated/google/apis/adsense_v1_4.rb +1 -1
- data/generated/google/apis/adsensehost_v4_1.rb +1 -1
- data/generated/google/apis/androidenterprise_v1/classes.rb +31 -24
- data/generated/google/apis/androidenterprise_v1/service.rb +11 -6
- data/generated/google/apis/androidenterprise_v1.rb +2 -1
- data/generated/google/apis/appstate_v1.rb +1 -1
- data/generated/google/apis/autoscaler_v1beta2.rb +1 -1
- data/generated/google/apis/bigquery_v2/classes.rb +34 -0
- data/generated/google/apis/bigquery_v2/representations.rb +14 -0
- data/generated/google/apis/bigquery_v2/service.rb +2 -2
- data/generated/google/apis/bigquery_v2.rb +1 -1
- data/generated/google/apis/calendar_v3/classes.rb +8 -0
- data/generated/google/apis/calendar_v3/representations.rb +1 -0
- data/generated/google/apis/calendar_v3.rb +1 -1
- data/generated/google/apis/civicinfo_v2/classes.rb +61 -0
- data/generated/google/apis/civicinfo_v2/representations.rb +8 -0
- data/generated/google/apis/civicinfo_v2.rb +1 -1
- data/generated/google/apis/classroom_v1beta1/classes.rb +447 -0
- data/generated/google/apis/classroom_v1beta1/representations.rb +190 -0
- data/generated/google/apis/classroom_v1beta1/service.rb +791 -0
- data/generated/google/apis/classroom_v1beta1.rb +49 -0
- data/generated/google/apis/cloudmonitoring_v2beta2.rb +4 -1
- data/generated/google/apis/cloudresourcemanager_v1beta1/classes.rb +20 -19
- data/generated/google/apis/cloudresourcemanager_v1beta1/service.rb +34 -34
- data/generated/google/apis/cloudresourcemanager_v1beta1.rb +2 -5
- data/generated/google/apis/compute_v1/classes.rb +2638 -1136
- data/generated/google/apis/compute_v1/representations.rb +580 -0
- data/generated/google/apis/compute_v1/service.rb +2448 -305
- data/generated/google/apis/compute_v1.rb +1 -1
- data/generated/google/apis/container_v1/classes.rb +438 -0
- data/generated/google/apis/container_v1/representations.rb +163 -0
- data/generated/google/apis/container_v1/service.rb +346 -0
- data/generated/google/apis/container_v1.rb +35 -0
- data/generated/google/apis/container_v1beta1.rb +1 -1
- data/generated/google/apis/content_v2/service.rb +48 -12
- data/generated/google/apis/content_v2.rb +1 -1
- data/generated/google/apis/deploymentmanager_v2beta2/classes.rb +13 -9
- data/generated/google/apis/deploymentmanager_v2beta2/service.rb +110 -15
- data/generated/google/apis/deploymentmanager_v2beta2.rb +1 -1
- data/generated/google/apis/discovery_v1/classes.rb +7 -0
- data/generated/google/apis/discovery_v1/representations.rb +1 -0
- data/generated/google/apis/dns_v1/service.rb +4 -1
- data/generated/google/apis/dns_v1.rb +1 -1
- data/generated/google/apis/doubleclicksearch_v2.rb +1 -1
- data/generated/google/apis/drive_v2.rb +1 -1
- data/generated/google/apis/fitness_v1/classes.rb +65 -2
- data/generated/google/apis/fitness_v1/representations.rb +27 -0
- data/generated/google/apis/fitness_v1.rb +1 -1
- data/generated/google/apis/games_configuration_v1configuration.rb +1 -1
- data/generated/google/apis/games_v1.rb +1 -1
- data/generated/google/apis/genomics_v1/classes.rb +2287 -0
- data/generated/google/apis/genomics_v1/representations.rb +796 -0
- data/generated/google/apis/genomics_v1/service.rb +1520 -0
- data/generated/google/apis/genomics_v1.rb +47 -0
- data/generated/google/apis/genomics_v1beta2/service.rb +36 -0
- data/generated/google/apis/genomics_v1beta2.rb +1 -1
- data/generated/google/apis/identitytoolkit_v3.rb +1 -1
- data/generated/google/apis/mapsengine_v1.rb +1 -1
- data/generated/google/apis/oauth2_v2.rb +1 -1
- data/generated/google/apis/plus_domains_v1.rb +1 -1
- data/generated/google/apis/plus_v1.rb +1 -1
- data/generated/google/apis/prediction_v1_6/classes.rb +1 -1
- data/generated/google/apis/pubsub_v1beta2/classes.rb +42 -42
- data/generated/google/apis/pubsub_v1beta2/service.rb +26 -22
- data/generated/google/apis/pubsub_v1beta2.rb +1 -1
- data/generated/google/apis/replicapool_v1beta2/classes.rb +10 -0
- data/generated/google/apis/replicapool_v1beta2/representations.rb +1 -0
- data/generated/google/apis/replicapool_v1beta2.rb +1 -1
- data/generated/google/apis/resourceviews_v1beta2.rb +1 -1
- data/generated/google/apis/storage_v1/classes.rb +4 -2
- data/generated/google/apis/storage_v1.rb +1 -1
- data/generated/google/apis/youtube_analytics_v1.rb +1 -1
- data/generated/google/apis/youtube_v3/classes.rb +3 -3
- data/generated/google/apis/youtube_v3/representations.rb +1 -1
- data/generated/google/apis/youtube_v3/service.rb +78 -0
- data/generated/google/apis/youtube_v3.rb +1 -1
- data/google-api-client.gemspec +0 -1
- data/lib/google/api_client/auth/installed_app.rb +6 -4
- data/lib/google/api_client/auth/key_utils.rb +93 -0
- data/lib/google/apis/core/api_command.rb +12 -5
- data/lib/google/apis/core/http_command.rb +17 -7
- data/lib/google/apis/core/json_representation.rb +6 -2
- data/lib/google/apis/errors.rb +9 -2
- data/lib/google/apis/version.rb +1 -1
- data/script/generate +4 -3
- data/spec/google/apis/core/http_command_spec.rb +20 -0
- data/spec/google/apis/core/json_representation_spec.rb +1 -1
- metadata +15 -16
|
@@ -26,7 +26,7 @@ module Google
|
|
|
26
26
|
# @see https://developers.google.com/compute/docs/instance-groups/manager/v1beta2
|
|
27
27
|
module ReplicapoolV1beta2
|
|
28
28
|
VERSION = 'V1beta2'
|
|
29
|
-
REVISION = '
|
|
29
|
+
REVISION = '20150708'
|
|
30
30
|
|
|
31
31
|
# View and manage your data across Google Cloud Platform services
|
|
32
32
|
AUTH_CLOUD_PLATFORM = 'https://www.googleapis.com/auth/cloud-platform'
|
|
@@ -26,7 +26,7 @@ module Google
|
|
|
26
26
|
# @see https://developers.google.com/compute/
|
|
27
27
|
module ResourceviewsV1beta2
|
|
28
28
|
VERSION = 'V1beta2'
|
|
29
|
-
REVISION = '
|
|
29
|
+
REVISION = '20150708'
|
|
30
30
|
|
|
31
31
|
# View and manage your data across Google Cloud Platform services
|
|
32
32
|
AUTH_CLOUD_PLATFORM = 'https://www.googleapis.com/auth/cloud-platform'
|
|
@@ -781,7 +781,8 @@ module Google
|
|
|
781
781
|
attr_accessor :content_type
|
|
782
782
|
|
|
783
783
|
# CRC32c checksum, as described in RFC 4960, Appendix B; encoded using base64 in
|
|
784
|
-
# big-endian byte order.
|
|
784
|
+
# big-endian byte order. For more information about using the CRC32c checksum,
|
|
785
|
+
# see Hashes and ETags: Best Practices.
|
|
785
786
|
# Corresponds to the JSON property `crc32c`
|
|
786
787
|
# @return [String]
|
|
787
788
|
attr_accessor :crc32c
|
|
@@ -806,7 +807,8 @@ module Google
|
|
|
806
807
|
# @return [String]
|
|
807
808
|
attr_accessor :kind
|
|
808
809
|
|
|
809
|
-
# MD5 hash of the data; encoded using base64.
|
|
810
|
+
# MD5 hash of the data; encoded using base64. For more information about using
|
|
811
|
+
# the MD5 hash, see Hashes and ETags: Best Practices.
|
|
810
812
|
# Corresponds to the JSON property `md5Hash`
|
|
811
813
|
# @return [String]
|
|
812
814
|
attr_accessor :md5_hash
|
|
@@ -25,7 +25,7 @@ module Google
|
|
|
25
25
|
# @see https://developers.google.com/storage/docs/json_api/
|
|
26
26
|
module StorageV1
|
|
27
27
|
VERSION = 'V1'
|
|
28
|
-
REVISION = '
|
|
28
|
+
REVISION = '20150710'
|
|
29
29
|
|
|
30
30
|
# View and manage your data across Google Cloud Platform services
|
|
31
31
|
AUTH_CLOUD_PLATFORM = 'https://www.googleapis.com/auth/cloud-platform'
|
|
@@ -36,7 +36,7 @@ module Google
|
|
|
36
36
|
# View and manage your assets and associated content on YouTube
|
|
37
37
|
AUTH_YOUTUBEPARTNER = 'https://www.googleapis.com/auth/youtubepartner'
|
|
38
38
|
|
|
39
|
-
# View YouTube Analytics
|
|
39
|
+
# View monetary and non-monetary YouTube Analytics reports for your YouTube content
|
|
40
40
|
AUTH_YT_ANALYTICS_MONETARY_READONLY = 'https://www.googleapis.com/auth/yt-analytics-monetary.readonly'
|
|
41
41
|
|
|
42
42
|
# View YouTube Analytics reports for your YouTube content
|
|
@@ -4029,9 +4029,9 @@ module Google
|
|
|
4029
4029
|
attr_accessor :configuration_issues
|
|
4030
4030
|
|
|
4031
4031
|
# The last time this status was updated (in seconds)
|
|
4032
|
-
# Corresponds to the JSON property `
|
|
4032
|
+
# Corresponds to the JSON property `lastUpdateTimeSeconds`
|
|
4033
4033
|
# @return [String]
|
|
4034
|
-
attr_accessor :
|
|
4034
|
+
attr_accessor :last_update_time_seconds
|
|
4035
4035
|
|
|
4036
4036
|
# The status code of this stream
|
|
4037
4037
|
# Corresponds to the JSON property `status`
|
|
@@ -4045,7 +4045,7 @@ module Google
|
|
|
4045
4045
|
# Update properties of this object
|
|
4046
4046
|
def update!(**args)
|
|
4047
4047
|
@configuration_issues = args[:configuration_issues] unless args[:configuration_issues].nil?
|
|
4048
|
-
@
|
|
4048
|
+
@last_update_time_seconds = args[:last_update_time_seconds] unless args[:last_update_time_seconds].nil?
|
|
4049
4049
|
@status = args[:status] unless args[:status].nil?
|
|
4050
4050
|
end
|
|
4051
4051
|
end
|
|
@@ -1671,7 +1671,7 @@ module Google
|
|
|
1671
1671
|
class Representation < Google::Apis::Core::JsonRepresentation
|
|
1672
1672
|
collection :configuration_issues, as: 'configurationIssues', class: Google::Apis::YoutubeV3::LiveStreamConfigurationIssue, decorator: Google::Apis::YoutubeV3::LiveStreamConfigurationIssue::Representation
|
|
1673
1673
|
|
|
1674
|
-
property :
|
|
1674
|
+
property :last_update_time_seconds, as: 'lastUpdateTimeSeconds'
|
|
1675
1675
|
property :status, as: 'status'
|
|
1676
1676
|
end
|
|
1677
1677
|
end
|
|
@@ -1663,6 +1663,84 @@ module Google
|
|
|
1663
1663
|
execute_or_queue_command(command, &block)
|
|
1664
1664
|
end
|
|
1665
1665
|
|
|
1666
|
+
# Binds a YouTube broadcast to a stream or removes an existing binding between a
|
|
1667
|
+
# broadcast and a stream. A broadcast can only be bound to one video stream,
|
|
1668
|
+
# though a video stream may be bound to more than one broadcast.
|
|
1669
|
+
# @param [String] id
|
|
1670
|
+
# The id parameter specifies the unique ID of the broadcast that is being bound
|
|
1671
|
+
# to a video stream.
|
|
1672
|
+
# @param [String] on_behalf_of_content_owner
|
|
1673
|
+
# Note: This parameter is intended exclusively for YouTube content partners.
|
|
1674
|
+
# The onBehalfOfContentOwner parameter indicates that the request's
|
|
1675
|
+
# authorization credentials identify a YouTube CMS user who is acting on behalf
|
|
1676
|
+
# of the content owner specified in the parameter value. This parameter is
|
|
1677
|
+
# intended for YouTube content partners that own and manage many different
|
|
1678
|
+
# YouTube channels. It allows content owners to authenticate once and get access
|
|
1679
|
+
# to all their video and channel data, without having to provide authentication
|
|
1680
|
+
# credentials for each individual channel. The CMS account that the user
|
|
1681
|
+
# authenticates with must be linked to the specified YouTube content owner.
|
|
1682
|
+
# @param [String] on_behalf_of_content_owner_channel
|
|
1683
|
+
# This parameter can only be used in a properly authorized request. Note: This
|
|
1684
|
+
# parameter is intended exclusively for YouTube content partners.
|
|
1685
|
+
# The onBehalfOfContentOwnerChannel parameter specifies the YouTube channel ID
|
|
1686
|
+
# of the channel to which a video is being added. This parameter is required
|
|
1687
|
+
# when a request specifies a value for the onBehalfOfContentOwner parameter, and
|
|
1688
|
+
# it can only be used in conjunction with that parameter. In addition, the
|
|
1689
|
+
# request must be authorized using a CMS account that is linked to the content
|
|
1690
|
+
# owner that the onBehalfOfContentOwner parameter specifies. Finally, the
|
|
1691
|
+
# channel that the onBehalfOfContentOwnerChannel parameter value specifies must
|
|
1692
|
+
# be linked to the content owner that the onBehalfOfContentOwner parameter
|
|
1693
|
+
# specifies.
|
|
1694
|
+
# This parameter is intended for YouTube content partners that own and manage
|
|
1695
|
+
# many different YouTube channels. It allows content owners to authenticate once
|
|
1696
|
+
# and perform actions on behalf of the channel specified in the parameter value,
|
|
1697
|
+
# without having to provide authentication credentials for each separate channel.
|
|
1698
|
+
# @param [String] part
|
|
1699
|
+
# The part parameter specifies a comma-separated list of one or more
|
|
1700
|
+
# liveBroadcast resource properties that the API response will include. The part
|
|
1701
|
+
# names that you can include in the parameter value are id, snippet,
|
|
1702
|
+
# contentDetails, and status.
|
|
1703
|
+
# @param [String] stream_id
|
|
1704
|
+
# The streamId parameter specifies the unique ID of the video stream that is
|
|
1705
|
+
# being bound to a broadcast. If this parameter is omitted, the API will remove
|
|
1706
|
+
# any existing binding between the broadcast and a video stream.
|
|
1707
|
+
# @param [String] fields
|
|
1708
|
+
# Selector specifying which fields to include in a partial response.
|
|
1709
|
+
# @param [String] quota_user
|
|
1710
|
+
# Available to use for quota purposes for server-side applications. Can be any
|
|
1711
|
+
# arbitrary string assigned to a user, but should not exceed 40 characters.
|
|
1712
|
+
# Overrides userIp if both are provided.
|
|
1713
|
+
# @param [String] user_ip
|
|
1714
|
+
# IP address of the site where the request originates. Use this if you want to
|
|
1715
|
+
# enforce per-user limits.
|
|
1716
|
+
# @param [Google::Apis::RequestOptions] options
|
|
1717
|
+
# Request-specific options
|
|
1718
|
+
#
|
|
1719
|
+
# @yield [result, err] Result & error if block supplied
|
|
1720
|
+
# @yieldparam result [Google::Apis::YoutubeV3::LiveBroadcast] parsed result object
|
|
1721
|
+
# @yieldparam err [StandardError] error object if request failed
|
|
1722
|
+
#
|
|
1723
|
+
# @return [Google::Apis::YoutubeV3::LiveBroadcast]
|
|
1724
|
+
#
|
|
1725
|
+
# @raise [Google::Apis::ServerError] An error occurred on the server and the request can be retried
|
|
1726
|
+
# @raise [Google::Apis::ClientError] The request is invalid and should not be retried without modification
|
|
1727
|
+
# @raise [Google::Apis::AuthorizationError] Authorization is required
|
|
1728
|
+
def bind_direct_live_broadcast(id: nil, on_behalf_of_content_owner: nil, on_behalf_of_content_owner_channel: nil, part: nil, stream_id: nil, fields: nil, quota_user: nil, user_ip: nil, options: nil, &block)
|
|
1729
|
+
path = 'liveBroadcasts/bind/direct'
|
|
1730
|
+
command = make_simple_command(:post, path, options)
|
|
1731
|
+
command.response_representation = Google::Apis::YoutubeV3::LiveBroadcast::Representation
|
|
1732
|
+
command.response_class = Google::Apis::YoutubeV3::LiveBroadcast
|
|
1733
|
+
command.query['id'] = id unless id.nil?
|
|
1734
|
+
command.query['onBehalfOfContentOwner'] = on_behalf_of_content_owner unless on_behalf_of_content_owner.nil?
|
|
1735
|
+
command.query['onBehalfOfContentOwnerChannel'] = on_behalf_of_content_owner_channel unless on_behalf_of_content_owner_channel.nil?
|
|
1736
|
+
command.query['part'] = part unless part.nil?
|
|
1737
|
+
command.query['streamId'] = stream_id unless stream_id.nil?
|
|
1738
|
+
command.query['fields'] = fields unless fields.nil?
|
|
1739
|
+
command.query['quotaUser'] = quota_user unless quota_user.nil?
|
|
1740
|
+
command.query['userIp'] = user_ip unless user_ip.nil?
|
|
1741
|
+
execute_or_queue_command(command, &block)
|
|
1742
|
+
end
|
|
1743
|
+
|
|
1666
1744
|
# Controls the settings for a slate that can be displayed in the broadcast
|
|
1667
1745
|
# stream.
|
|
1668
1746
|
# @param [Boolean] display_slate
|
data/google-api-client.gemspec
CHANGED
|
@@ -23,13 +23,15 @@ module Google
|
|
|
23
23
|
#
|
|
24
24
|
# @example
|
|
25
25
|
#
|
|
26
|
-
# client = Google::APIClient.new
|
|
27
26
|
# flow = Google::APIClient::InstalledAppFlow.new(
|
|
28
27
|
# :client_id => '691380668085.apps.googleusercontent.com',
|
|
29
28
|
# :client_secret => '...',
|
|
30
29
|
# :scope => 'https://www.googleapis.com/auth/drive'
|
|
31
30
|
# )
|
|
32
|
-
#
|
|
31
|
+
# authorization = flow.authorize
|
|
32
|
+
# Drive = Google::Apis::DriveV2
|
|
33
|
+
# drive = Drive::DriveService.new
|
|
34
|
+
# drive.authorization = authorization
|
|
33
35
|
#
|
|
34
36
|
class InstalledAppFlow
|
|
35
37
|
|
|
@@ -83,7 +85,7 @@ module Google
|
|
|
83
85
|
#
|
|
84
86
|
# @return [Signet::OAuth2::Client]
|
|
85
87
|
# Authorization instance, nil if user cancelled.
|
|
86
|
-
def authorize(storage=nil)
|
|
88
|
+
def authorize(storage=nil, options=nil)
|
|
87
89
|
auth = @authorization
|
|
88
90
|
|
|
89
91
|
server = WEBrick::HTTPServer.new(
|
|
@@ -105,7 +107,7 @@ module Google
|
|
|
105
107
|
server.stop
|
|
106
108
|
end
|
|
107
109
|
|
|
108
|
-
Launchy.open(auth.authorization_uri.to_s)
|
|
110
|
+
Launchy.open(auth.authorization_uri(options).to_s)
|
|
109
111
|
server.start
|
|
110
112
|
ensure
|
|
111
113
|
server.shutdown
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
# Copyright 2010 Google Inc.
|
|
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
|
+
module Google
|
|
16
|
+
class APIClient
|
|
17
|
+
##
|
|
18
|
+
# Helper for loading keys from the PKCS12 files downloaded when
|
|
19
|
+
# setting up service accounts at the APIs Console.
|
|
20
|
+
#
|
|
21
|
+
module KeyUtils
|
|
22
|
+
##
|
|
23
|
+
# Loads a key from PKCS12 file, assuming a single private key
|
|
24
|
+
# is present.
|
|
25
|
+
#
|
|
26
|
+
# @param [String] keyfile
|
|
27
|
+
# Path of the PKCS12 file to load. If not a path to an actual file,
|
|
28
|
+
# assumes the string is the content of the file itself.
|
|
29
|
+
# @param [String] passphrase
|
|
30
|
+
# Passphrase for unlocking the private key
|
|
31
|
+
#
|
|
32
|
+
# @return [OpenSSL::PKey] The private key for signing assertions.
|
|
33
|
+
def self.load_from_pkcs12(keyfile, passphrase)
|
|
34
|
+
load_key(keyfile, passphrase) do |content, pass_phrase|
|
|
35
|
+
OpenSSL::PKCS12.new(content, pass_phrase).key
|
|
36
|
+
end
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
##
|
|
41
|
+
# Loads a key from a PEM file.
|
|
42
|
+
#
|
|
43
|
+
# @param [String] keyfile
|
|
44
|
+
# Path of the PEM file to load. If not a path to an actual file,
|
|
45
|
+
# assumes the string is the content of the file itself.
|
|
46
|
+
# @param [String] passphrase
|
|
47
|
+
# Passphrase for unlocking the private key
|
|
48
|
+
#
|
|
49
|
+
# @return [OpenSSL::PKey] The private key for signing assertions.
|
|
50
|
+
#
|
|
51
|
+
def self.load_from_pem(keyfile, passphrase)
|
|
52
|
+
load_key(keyfile, passphrase) do | content, pass_phrase|
|
|
53
|
+
OpenSSL::PKey::RSA.new(content, pass_phrase)
|
|
54
|
+
end
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
private
|
|
58
|
+
|
|
59
|
+
##
|
|
60
|
+
# Helper for loading keys from file or memory. Accepts a block
|
|
61
|
+
# to handle the specific file format.
|
|
62
|
+
#
|
|
63
|
+
# @param [String] keyfile
|
|
64
|
+
# Path of thefile to load. If not a path to an actual file,
|
|
65
|
+
# assumes the string is the content of the file itself.
|
|
66
|
+
# @param [String] passphrase
|
|
67
|
+
# Passphrase for unlocking the private key
|
|
68
|
+
#
|
|
69
|
+
# @yield [String, String]
|
|
70
|
+
# Key file & passphrase to extract key from
|
|
71
|
+
# @yieldparam [String] keyfile
|
|
72
|
+
# Contents of the file
|
|
73
|
+
# @yieldparam [String] passphrase
|
|
74
|
+
# Passphrase to unlock key
|
|
75
|
+
# @yieldreturn [OpenSSL::PKey]
|
|
76
|
+
# Private key
|
|
77
|
+
#
|
|
78
|
+
# @return [OpenSSL::PKey] The private key for signing assertions.
|
|
79
|
+
def self.load_key(keyfile, passphrase, &block)
|
|
80
|
+
begin
|
|
81
|
+
begin
|
|
82
|
+
content = File.open(keyfile, 'rb') { |io| io.read }
|
|
83
|
+
rescue
|
|
84
|
+
content = keyfile
|
|
85
|
+
end
|
|
86
|
+
block.call(content, passphrase)
|
|
87
|
+
rescue OpenSSL::OpenSSLError
|
|
88
|
+
raise ArgumentError.new("Invalid keyfile or passphrase")
|
|
89
|
+
end
|
|
90
|
+
end
|
|
91
|
+
end
|
|
92
|
+
end
|
|
93
|
+
end
|
|
@@ -79,23 +79,30 @@ module Google
|
|
|
79
79
|
#
|
|
80
80
|
# @param [Fixnum] status
|
|
81
81
|
# HTTP status code of response
|
|
82
|
+
# @param [Hurley::Header] header
|
|
83
|
+
# HTTP response headers
|
|
82
84
|
# @param [String] body
|
|
83
85
|
# HTTP response body
|
|
86
|
+
# @param [String] message
|
|
87
|
+
# Error message text
|
|
84
88
|
# @return [void]
|
|
85
89
|
# @raise [Google::Apis::ServerError] An error occurred on the server and the request can be retried
|
|
86
90
|
# @raise [Google::Apis::ClientError] The request is invalid and should not be retried without modification
|
|
87
91
|
# @raise [Google::Apis::AuthorizationError] Authorization is required
|
|
88
|
-
def check_status(status, body = nil)
|
|
92
|
+
def check_status(status, header = nil, body = nil, message = nil)
|
|
89
93
|
case status
|
|
90
94
|
when 400, 402...500
|
|
91
95
|
error = parse_error(body)
|
|
92
96
|
if error
|
|
93
|
-
|
|
94
|
-
|
|
97
|
+
message = error['reason'] if error.has_key?('reason')
|
|
98
|
+
raise Google::Apis::RateLimitError.new(message,
|
|
99
|
+
status_code: status,
|
|
100
|
+
header: header,
|
|
101
|
+
body: body) if RATE_LIMIT_ERRORS.include?(message)
|
|
95
102
|
end
|
|
96
|
-
super(status,
|
|
103
|
+
super(status, header, body, message)
|
|
97
104
|
else
|
|
98
|
-
super(status, body)
|
|
105
|
+
super(status, header, body, message)
|
|
99
106
|
end
|
|
100
107
|
end
|
|
101
108
|
|
|
@@ -159,7 +159,7 @@ module Google
|
|
|
159
159
|
# @raise [Google::Apis::ClientError] The request is invalid and should not be retried without modification
|
|
160
160
|
# @raise [Google::Apis::AuthorizationError] Authorization is required
|
|
161
161
|
def process_response(status, header, body)
|
|
162
|
-
check_status(status, body)
|
|
162
|
+
check_status(status, header, body)
|
|
163
163
|
decode_response_body(header[:content_type], body)
|
|
164
164
|
end
|
|
165
165
|
|
|
@@ -167,28 +167,38 @@ module Google
|
|
|
167
167
|
#
|
|
168
168
|
# @param [Fixnum] status
|
|
169
169
|
# HTTP status code of response
|
|
170
|
+
# @param
|
|
171
|
+
# @param [Hurley::Header] header
|
|
172
|
+
# HTTP response headers
|
|
170
173
|
# @param [String] body
|
|
171
174
|
# HTTP response body
|
|
175
|
+
# @param [String] message
|
|
176
|
+
# Error message text
|
|
172
177
|
# @return [void]
|
|
173
178
|
# @raise [Google::Apis::ServerError] An error occurred on the server and the request can be retried
|
|
174
179
|
# @raise [Google::Apis::ClientError] The request is invalid and should not be retried without modification
|
|
175
180
|
# @raise [Google::Apis::AuthorizationError] Authorization is required
|
|
176
|
-
def check_status(status, body = nil)
|
|
181
|
+
def check_status(status, header = nil, body = nil, message = nil)
|
|
177
182
|
# TODO: 304 Not Modified depends on context...
|
|
178
183
|
case status
|
|
179
184
|
when 200...300
|
|
180
185
|
nil
|
|
181
186
|
when 301, 302, 303, 307
|
|
182
|
-
|
|
187
|
+
message ||= sprintf('Redirect to %s', header[:location])
|
|
188
|
+
raise Google::Apis::RedirectError.new(message, status_code: status, header: header, body: body)
|
|
183
189
|
when 401
|
|
184
|
-
|
|
190
|
+
message ||= 'Unauthorized'
|
|
191
|
+
raise Google::Apis::AuthorizationError.new(message, status_code: status, header: header, body: body)
|
|
185
192
|
when 304, 400, 402...500
|
|
186
|
-
|
|
193
|
+
message ||= 'Invalid request'
|
|
194
|
+
raise Google::Apis::ClientError.new(message, status_code: status, header: header, body: body)
|
|
187
195
|
when 500...600
|
|
188
|
-
|
|
196
|
+
message ||= 'Server error'
|
|
197
|
+
raise Google::Apis::ServerError.new(message, status_code: status, header: header, body: body)
|
|
189
198
|
else
|
|
190
199
|
logger.warn(sprintf('Encountered unexpected status code %s', status))
|
|
191
|
-
|
|
200
|
+
message ||= 'Unknown error'
|
|
201
|
+
raise Google::Apis::TransmissionError.new(message, status_code: status, header: header, body: body)
|
|
192
202
|
end
|
|
193
203
|
end
|
|
194
204
|
|
|
@@ -14,8 +14,8 @@
|
|
|
14
14
|
|
|
15
15
|
require 'representable/json'
|
|
16
16
|
require 'representable/json/hash'
|
|
17
|
-
require 'representable/coercion'
|
|
18
17
|
require 'base64'
|
|
18
|
+
require 'date'
|
|
19
19
|
|
|
20
20
|
module Google
|
|
21
21
|
module Apis
|
|
@@ -72,6 +72,11 @@ module Google
|
|
|
72
72
|
options[:render_filter] = ->(value, _doc, *_args) { Base64.urlsafe_encode64(value) }
|
|
73
73
|
options[:parse_filter] = ->(fragment, _doc, *_args) { Base64.urlsafe_decode64(fragment) }
|
|
74
74
|
end
|
|
75
|
+
if options[:type] == DateTime
|
|
76
|
+
options[:render_filter] = ->(value, _doc, *_args) { value.is_a?(DateTime) ? value.rfc3339(3) : value.to_s }
|
|
77
|
+
options[:parse_filter] = ->(fragment, _doc, *_args) { DateTime.parse(fragment) }
|
|
78
|
+
end
|
|
79
|
+
|
|
75
80
|
options[:render_nil] = true
|
|
76
81
|
options[:getter] = getter_fn(name)
|
|
77
82
|
options[:if] = if_fn(name)
|
|
@@ -114,7 +119,6 @@ module Google
|
|
|
114
119
|
# @see https://github.com/apotonick/representable
|
|
115
120
|
class JsonRepresentation < Representable::Decorator
|
|
116
121
|
include Representable::JSON
|
|
117
|
-
include Representable::Coercion
|
|
118
122
|
feature JsonRepresentationSupport
|
|
119
123
|
end
|
|
120
124
|
end
|