chore: Move google-api-client into a subdirectory

This commit is contained in:
Daniel Azuma 2020-12-22 15:10:52 -08:00 committed by GitHub
parent 33fbe068c1
commit 15add33c34
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1655 changed files with 303 additions and 338 deletions

55
Gemfile
View File

@ -1,55 +1,4 @@
source 'https://rubygems.org'
# Specify your gem's dependencies in google-apis.gemspec
gemspec
group :development do
gem 'bundler', '>= 1.7'
gem 'rake', '~> 11.2'
gem 'rspec', '~> 3.1'
gem 'json_spec', '~> 1.1'
gem 'webmock', '~> 2.1'
gem 'simplecov', '~> 0.12'
gem 'coveralls', '~> 0.8'
gem 'rubocop', '~> 0.49.0'
gem 'launchy', '~> 2.4'
gem 'dotenv', '~> 2.0'
gem 'fakefs', '~> 0.6', require: "fakefs/safe"
gem 'google-id-token', '~> 1.3'
gem 'os', '~> 0.9'
gem 'rmail', '~> 1.1'
gem 'redis', '~> 3.2'
gem 'logging', '~> 2.2'
gem 'opencensus', '~> 0.4'
gem 'httparty'
gem 'gems', '~> 1.2'
end
platforms :jruby do
group :development do
gem 'jruby-openssl'
end
end
platforms :ruby do
group :development do
gem 'yard', '~> 0.9', '>= 0.9.11'
gem 'redcarpet', '~> 3.2'
gem 'github-markup', '~> 1.3'
gem 'pry-doc', '~> 0.8'
gem 'pry-byebug', '~> 3.2'
end
end
platforms :mri_21, :mri_22, :mri_23 do
group :development do
gem 'derailed_benchmarks'
gem 'stackprof'
gem 'rack-test'
end
end
if ENV['RAILS_VERSION']
gem 'rails', ENV['RAILS_VERSION']
end
gem "rake", "~> 13.0"
gem "gems", "~> 1.2"

View File

@ -1,215 +0,0 @@
# Migrating from version`0.10` to `0.11`
## Unicode normalization
The client no longer normalizes unicode strings in path parameters. This may affect
some applications using multibyte strings that were previously normalized.:
To restore the previous behavior, use the `normalize_unicode` request option.
## Type change for large numbers
Previously, types declared as 64 bit numbers were mapped to strings. These are now mapped to
`Fixednum`/`Bignum`.
## Timeouts
Timeout options have been moved from `RequestOptions` to `ClientOptions`.
Old | New
----------------------------------|-----------------
`RequestOptions.open_timeout_sec` | `ClientOptions.open_timeout_sec`
`RequestOptions.timeout_sec` | `ClientOptions.read_timeout_sec`
`RequestOptions.timeout_sec` | `ClientOptions.send_timeout_sec`
## Batch requests across services no longer supported
It is no longer possible to combine multiple services (e.g. Gail & Drive)
in a batch request. If batching requests that span services, group
requests for each service in their own batch request.
# Migrating from version `0.9.x` to `0.10`
Only one minor breaking change was introduced in the `to_json` method due to a version bump for the `representable` gem from `2.3` to `3.0`. If you used the `skip_undefined` in `to_json`, you should replace that with `user_options: { skip_undefined: true }`.
ex:
```ruby
foo.to_json(skip_undefined: true)
```
to
```ruby
foo.to_json(user_options: { skip_undefined: true })
```
# Migrating from version `0.8.x` to `0.9` or above
Many changes and improvements have been made to the `google-api-ruby-client`
library to bring it to `0.9`. If you are starting a new project or haven't used
this library before version `0.9`, see the [README](README.md) to get started
as you won't need to migrate anything.
Code written against the `0.8.x` version of this library will not work with the `0.9`
version without modification.
## Discovery
In `0.8.x` the library would "discover" APIs on the fly, introducing
additional network calls and instability. That has been fixed in `0.9`.
To get the `drive` client in `0.8.x` required this:
```ruby
require 'google/api_client'
client = Google::APIClient.new
drive = client.discovered_api('drive', 'v2')
```
In `0.9` the same thing can be accomplished like this:
```ruby
require 'google/apis/drive_v2'
drive = Google::Apis::DriveV2::DriveService.new
```
All APIs are immediately accessible without requiring additional network calls or runtime code generation.
## API Methods
The calling style for API methods has changed. In `0.8.x` all calls were via a generic `execute` method. In `0.9`
the generated services have fully defined method signatures for all available methods.
To get a file using the Google Drive API in `0.8.x` required this:
```ruby
file = client.execute(:api_method => drive.file.get, :parameters => { 'id' => 'abc123' })
```
In `0.9` the same thing can be accomplished like this:
```ruby
file = drive.get_file('abc123')
```
Full API definitions including available methods, parameters, and data classes can be found in the `generated` directory.
## Authorization
In the 0.9 version of this library, the authentication and authorization code was moved
to the new [googleauth](https://github.com/google/google-auth-library-ruby) library. While the new library provides
significantly simpler APIs for some use cases, not all features have been migrated. Missing features
are expected to be added by end of Q2 2015.
The underlying [Signet](https://github.com/google/signet) is still used for authorization. OAuth 2 credentials obtained
previously will continue to work with the `0.9` version. OAuth 1 is no longer supported.
If you were using a PKCS12 file to authorize, we recommend you generate a new key for the service account using the JSON format ( client_secret.json) file with googleauth.
## Media uploads
Media uploads are significantly simpler in `0.9`.
The old `0.8.x` way of uploading media:
```ruby
media = Google::APIClient::UploadIO.new('mymovie.m4v', 'video/mp4')
metadata = {
'title' => 'My movie',
'description' => 'The best home movie ever made'
}
client.execute(:api_method => drive.files.insert,
:parameters => { 'uploadType' => 'multipart' },
:body_object => metadata,
:media => media )
```
The new way in `0.9` using `upload_source` and `content_type` parameters:
```ruby
metadata = {
title: 'My movie',
description: 'The best home movie ever made'
}
drive.insert_file(metadata, upload_source: 'mymovie.m4v', content_type: 'video/mp4')
```
`upload_source` can be either a path to a file, an `IO` stream, or a `StringIO` instance.
Uploads are resumable and will be automatically retried if interrupted.
## Media downloads
`0.9` introduces support for media downloads (`alt=media`). To download content, use the `download_dest` parameter:
```ruby
drive.get_file('abc123', download_dest: '/tmp/myfile.txt')
```
`download_dest` may be either a path to a file or an `IO` stream.
## Batch Requests
The old `0.8.x` way of performing batch requests:
```ruby
client = Google::APIClient.new
urlshortener = client.discovered_api('urlshortener')
batch = Google::APIClient::BatchRequest.new do |result|
puts result.data
end
batch.add(:api_method => urlshortener.url.insert,
:body_object => { 'longUrl' => 'http://example.com/foo' })
batch.add(:api_method => urlshortener.url.insert,
:body_object => { 'longUrl' => 'http://example.com/bar' })
client.execute(batch)
```
In `0.9`, the equivalent code is:
```ruby
require 'google/apis/urlshortener_v1'
urlshortener = Google::Apis::UrlshortenerV1::UrlshortenerService.new
urlshortener.batch do |urlshortener|
urlshortener.insert_url({long_url: 'http://example.com/foo'}) do |res, err|
puts res
end
urlshortener.insert_url({long_url: 'http://example.com/bar'}) do |res, err|
puts res
end
end
```
Or if sharing the same block:
```ruby
require 'google/apis/urlshortener_v1'
urlshortener = Google::Apis::UrlshortenerV1::UrlshortenerService.new
callback = lambda { |res, err| puts res }
urlshortener.batch do |urlshortener|
urlshortener.insert_url({long_url: 'http://example.com/foo'}, &callback)
urlshortener.insert_url({long_url: 'http://example.com/bar'}, &callback)
end
```
## JRuby
Jruby 1.7.4 in 2.0 compatibility mode is supported. To enable for a specific script:
```
jruby --2.0 myscript.rb
```
Or set as the default:
```
export JRUBY_OPTS=--2.0
```
JRuby 9000 will be supported once released.

View File

@ -1,73 +1,35 @@
require "bundler/gem_tasks"
require "json"
task :release_gem, :tag do |_t, args|
tag = args[:tag]
raise "You must provide a tag to release." if tag.nil?
# Verify the tag format "vVERSION"
m = tag.match(/v(?<version>\S*)/)
raise "Tag #{tag} does not match the expected format." if m.nil?
version = m[:version]
raise "You must provide a version." if version.nil?
api_token = ENV["RUBYGEMS_API_TOKEN"]
require "gems"
if api_token
::Gems.configure do |config|
config.key = api_token
end
end
Bundler.with_clean_env do
sh "rm -rf pkg"
sh "bundle update"
sh "bundle exec rake build"
end
path_to_be_pushed = "pkg/google-api-client-#{version}.gem"
gem_was_published = nil
if File.file? path_to_be_pushed
begin
response = ::Gems.push File.new(path_to_be_pushed)
puts response
raise unless response.include? "Successfully registered gem:"
gem_was_published = true
puts "Successfully built and pushed google-api-client for version #{version}"
rescue StandardError => e
gem_was_published = false
puts "Error while releasing google-api-client version #{version}: #{e.message}"
end
else
raise "Cannot build google-api-client for version #{version}"
end
Rake::Task["kokoro:publish_docs"].invoke if gem_was_published
end
task default: :spec
namespace :kokoro do
task :load_env_vars do
service_account = "#{ENV['KOKORO_GFILE_DIR']}/service-account.json"
ENV["GOOGLE_APPLICATION_CREDENTIALS"] = service_account
filename = "#{ENV['KOKORO_GFILE_DIR']}/env_vars.json"
env_vars = JSON.parse File.read(filename)
env_vars.each { |k, v| ENV[k] = v }
load_env_vars
end
task :presubmit do
Rake::Task["spec"].invoke
cd "google-api-client" do
Bundler.with_clean_env do
sh "bundle update"
sh "bundle exec rake spec"
end
end
end
task :continuous do
Rake::Task["spec"].invoke
cd "google-api-client" do
Bundler.with_clean_env do
sh "bundle update"
sh "bundle exec rake spec"
end
end
end
task :nightly do
Rake::Task["spec"].invoke
cd "google-api-client" do
Bundler.with_clean_env do
sh "bundle update"
sh "bundle exec rake spec"
end
end
end
task :post do
@ -94,21 +56,28 @@ namespace :kokoro do
end
end
cd "google-api-client" do
Bundler.with_clean_env do
rm_rf "pkg"
Rake::Task["build"].invoke
sh "bundle update"
sh "bundle exec rake build"
built_gem_path = Dir.glob("pkg/google-api-client-*.gem").last
response = ::Gems.push File.new built_gem_path
puts response
raise "Failed to release gem" unless response.include? "Successfully registered gem:"
end
end
end
desc "Publish docs for the latest git tag"
task :publish_docs do
require_relative "rakelib/devsite/devsite_builder.rb"
cd "google-api-client" do
DevsiteBuilder.new.publish ENV["DOCS_BUILD_TAG"]
end
end
end
def load_env_vars

View File

@ -22,5 +22,4 @@ docs/logging.md
docs/media-upload.md
docs/pagination.md
docs/performance.md
MIGRATING.md
LICENSE

55
google-api-client/Gemfile Normal file
View File

@ -0,0 +1,55 @@
source 'https://rubygems.org'
# Specify your gem's dependencies in google-apis.gemspec
gemspec
group :development do
gem 'bundler', '>= 1.7'
gem 'rake', '~> 11.2'
gem 'rspec', '~> 3.1'
gem 'json_spec', '~> 1.1'
gem 'webmock', '~> 2.1'
gem 'simplecov', '~> 0.12'
gem 'coveralls', '~> 0.8'
gem 'rubocop', '~> 0.49.0'
gem 'launchy', '~> 2.4'
gem 'dotenv', '~> 2.0'
gem 'fakefs', '~> 0.6', require: "fakefs/safe"
gem 'google-id-token', '~> 1.3'
gem 'os', '~> 0.9'
gem 'rmail', '~> 1.1'
gem 'redis', '~> 3.2'
gem 'logging', '~> 2.2'
gem 'opencensus', '~> 0.4'
gem 'httparty'
gem 'gems', '~> 1.2'
end
platforms :jruby do
group :development do
gem 'jruby-openssl'
end
end
platforms :ruby do
group :development do
gem 'yard', '~> 0.9', '>= 0.9.11'
gem 'redcarpet', '~> 3.2'
gem 'github-markup', '~> 1.3'
gem 'pry-doc', '~> 0.8'
gem 'pry-byebug', '~> 3.2'
end
end
platforms :mri_21, :mri_22, :mri_23 do
group :development do
gem 'derailed_benchmarks'
gem 'stackprof'
gem 'rack-test'
end
end
if ENV['RAILS_VERSION']
gem 'rails', ENV['RAILS_VERSION']
end

202
google-api-client/LICENSE Normal file
View File

@ -0,0 +1,202 @@
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
1. Definitions.
"License" shall mean the terms and conditions for use, reproduction,
and distribution as defined by Sections 1 through 9 of this document.
"Licensor" shall mean the copyright owner or entity authorized by
the copyright owner that is granting the License.
"Legal Entity" shall mean the union of the acting entity and all
other entities that control, are controlled by, or are under common
control with that entity. For the purposes of this definition,
"control" means (i) the power, direct or indirect, to cause the
direction or management of such entity, whether by contract or
otherwise, or (ii) ownership of fifty percent (50%) or more of the
outstanding shares, or (iii) beneficial ownership of such entity.
"You" (or "Your") shall mean an individual or Legal Entity
exercising permissions granted by this License.
"Source" form shall mean the preferred form for making modifications,
including but not limited to software source code, documentation
source, and configuration files.
"Object" form shall mean any form resulting from mechanical
transformation or translation of a Source form, including but
not limited to compiled object code, generated documentation,
and conversions to other media types.
"Work" shall mean the work of authorship, whether in Source or
Object form, made available under the License, as indicated by a
copyright notice that is included in or attached to the work
(an example is provided in the Appendix below).
"Derivative Works" shall mean any work, whether in Source or Object
form, that is based on (or derived from) the Work and for which the
editorial revisions, annotations, elaborations, or other modifications
represent, as a whole, an original work of authorship. For the purposes
of this License, Derivative Works shall not include works that remain
separable from, or merely link (or bind by name) to the interfaces of,
the Work and Derivative Works thereof.
"Contribution" shall mean any work of authorship, including
the original version of the Work and any modifications or additions
to that Work or Derivative Works thereof, that is intentionally
submitted to Licensor for inclusion in the Work by the copyright owner
or by an individual or Legal Entity authorized to submit on behalf of
the copyright owner. For the purposes of this definition, "submitted"
means any form of electronic, verbal, or written communication sent
to the Licensor or its representatives, including but not limited to
communication on electronic mailing lists, source code control systems,
and issue tracking systems that are managed by, or on behalf of, the
Licensor for the purpose of discussing and improving the Work, but
excluding communication that is conspicuously marked or otherwise
designated in writing by the copyright owner as "Not a Contribution."
"Contributor" shall mean Licensor and any individual or Legal Entity
on behalf of whom a Contribution has been received by Licensor and
subsequently incorporated within the Work.
2. Grant of Copyright License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
copyright license to reproduce, prepare Derivative Works of,
publicly display, publicly perform, sublicense, and distribute the
Work and such Derivative Works in Source or Object form.
3. Grant of Patent License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
(except as stated in this section) patent license to make, have made,
use, offer to sell, sell, import, and otherwise transfer the Work,
where such license applies only to those patent claims licensable
by such Contributor that are necessarily infringed by their
Contribution(s) alone or by combination of their Contribution(s)
with the Work to which such Contribution(s) was submitted. If You
institute patent litigation against any entity (including a
cross-claim or counterclaim in a lawsuit) alleging that the Work
or a Contribution incorporated within the Work constitutes direct
or contributory patent infringement, then any patent licenses
granted to You under this License for that Work shall terminate
as of the date such litigation is filed.
4. Redistribution. You may reproduce and distribute copies of the
Work or Derivative Works thereof in any medium, with or without
modifications, and in Source or Object form, provided that You
meet the following conditions:
(a) You must give any other recipients of the Work or
Derivative Works a copy of this License; and
(b) You must cause any modified files to carry prominent notices
stating that You changed the files; and
(c) You must retain, in the Source form of any Derivative Works
that You distribute, all copyright, patent, trademark, and
attribution notices from the Source form of the Work,
excluding those notices that do not pertain to any part of
the Derivative Works; and
(d) If the Work includes a "NOTICE" text file as part of its
distribution, then any Derivative Works that You distribute must
include a readable copy of the attribution notices contained
within such NOTICE file, excluding those notices that do not
pertain to any part of the Derivative Works, in at least one
of the following places: within a NOTICE text file distributed
as part of the Derivative Works; within the Source form or
documentation, if provided along with the Derivative Works; or,
within a display generated by the Derivative Works, if and
wherever such third-party notices normally appear. The contents
of the NOTICE file are for informational purposes only and
do not modify the License. You may add Your own attribution
notices within Derivative Works that You distribute, alongside
or as an addendum to the NOTICE text from the Work, provided
that such additional attribution notices cannot be construed
as modifying the License.
You may add Your own copyright statement to Your modifications and
may provide additional or different license terms and conditions
for use, reproduction, or distribution of Your modifications, or
for any such Derivative Works as a whole, provided Your use,
reproduction, and distribution of the Work otherwise complies with
the conditions stated in this License.
5. Submission of Contributions. Unless You explicitly state otherwise,
any Contribution intentionally submitted for inclusion in the Work
by You to the Licensor shall be under the terms and conditions of
this License, without any additional terms or conditions.
Notwithstanding the above, nothing herein shall supersede or modify
the terms of any separate license agreement you may have executed
with Licensor regarding such Contributions.
6. Trademarks. This License does not grant permission to use the trade
names, trademarks, service marks, or product names of the Licensor,
except as required for reasonable and customary use in describing the
origin of the Work and reproducing the content of the NOTICE file.
7. Disclaimer of Warranty. Unless required by applicable law or
agreed to in writing, Licensor provides the Work (and each
Contributor provides its Contributions) on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
implied, including, without limitation, any warranties or conditions
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
PARTICULAR PURPOSE. You are solely responsible for determining the
appropriateness of using or redistributing the Work and assume any
risks associated with Your exercise of permissions under this License.
8. Limitation of Liability. In no event and under no legal theory,
whether in tort (including negligence), contract, or otherwise,
unless required by applicable law (such as deliberate and grossly
negligent acts) or agreed to in writing, shall any Contributor be
liable to You for damages, including any direct, indirect, special,
incidental, or consequential damages of any character arising as a
result of this License or out of the use or inability to use the
Work (including but not limited to damages for loss of goodwill,
work stoppage, computer failure or malfunction, or any and all
other commercial damages or losses), even if such Contributor
has been advised of the possibility of such damages.
9. Accepting Warranty or Additional Liability. While redistributing
the Work or Derivative Works thereof, You may choose to offer,
and charge a fee for, acceptance of support, warranty, indemnity,
or other liability obligations and/or rights consistent with this
License. However, in accepting such obligations, You may act only
on Your own behalf and on Your sole responsibility, not on behalf
of any other Contributor, and only if You agree to indemnify,
defend, and hold each Contributor harmless for any liability
incurred by, or claims asserted against, such Contributor by reason
of your accepting any such warranty or additional liability.
END OF TERMS AND CONDITIONS
APPENDIX: How to apply the Apache License to your work.
To apply the Apache License to your work, attach the following
boilerplate notice, with the fields enclosed by brackets "[]"
replaced with your own identifying information. (Don't include
the brackets!) The text should be enclosed in the appropriate
comment syntax for the file format. We also recommend that a
file or class name and description of purpose be included on the
same "printed page" as the copyright notice for easier
identification within third-party archives.
Copyright [yyyy] [name of copyright owner]
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.

View File

@ -0,0 +1,3 @@
require "bundler/gem_tasks"
task :default => :spec

View File

@ -172,7 +172,7 @@ module Google
end
def api_list_config
@api_list_config ||= Psych.load_file(__dir__ + "/../api_list_config.yaml")
@api_list_config ||= Psych.load_file(__dir__ + "/../../api_list_config.yaml")
end
def ensure_active_support

Some files were not shown because too many files have changed in this diff Show More