Go to file
Yoshi Automation Bot 9decc6ed53
feat: Automated regeneration of datafusion v1beta1 client (#2254)
2021-01-08 08:43:32 -08:00
.github chore: Update release-please jobs to reference separate gems (#2146) 2021-01-06 12:02:24 -08:00
.kokoro chore: Rename kokoro release jobs to reduce logic (#2147) 2021-01-01 17:57:55 -08:00
docs chore: Update some language prior to releasing separated clients 2021-01-07 14:57:10 -08:00
generated feat: Automated regeneration of datafusion v1beta1 client (#2254) 2021-01-08 08:43:32 -08:00
google-api-client feat: Deprecate google-api-client in favor of individual service-specific gems 2021-01-07 13:49:46 -08:00
google-apis-core chore: release google-apis-core 0.2.0 (#2216) 2021-01-06 17:02:29 -08:00
google-apis-generator chore: Update some language prior to releasing separated clients 2021-01-07 14:57:10 -08:00
rakelib chore: Another attempt to fix the releaser (#2220) 2021-01-06 16:37:33 -08:00
samples docs: Update readme and samples to reflect separated packages 2021-01-07 13:31:56 -08:00
script chore: Extract generator into google-apis-generator gem (#2143) 2021-01-01 12:29:10 -08:00
.gitignore chore: Add synth scripts for client generation (#912) 2020-10-15 12:21:50 -07:00
.repo-metadata.json chore: add release and continuous/post kokoro jobs (#836) 2019-11-05 12:10:36 -08:00
.rubocop.yml chore: add release and continuous/post kokoro jobs (#836) 2019-11-05 12:10:36 -08:00
.rubocop_todo.yml Import refactored library. See MIGRATING.MD for details 2015-06-23 15:15:14 -07:00
CODE_OF_CONDUCT.md Add Code of Conduct 2018-07-02 12:47:32 -07:00
Gemfile chore: Move google-api-client into a subdirectory 2020-12-22 15:10:52 -08:00
LICENSE Basic project skeleton. 2010-07-28 19:30:56 +00:00
README.md docs: Update readme and samples to reflect separated packages 2021-01-07 13:31:56 -08:00
Rakefile chore: Attempt to fix the releaser (#2218) 2021-01-06 15:48:03 -08:00
api_list_config.yaml chore: Add synth scripts for client generation (#912) 2020-10-15 12:21:50 -07:00
api_names.yaml chore: Fix displayvideo v1beta naming conflict (#908) 2020-09-14 16:12:45 -07:00
api_names_out.yaml feat: Automated regeneration of datafusion v1beta1 client (#2254) 2021-01-08 08:43:32 -08:00
synth.metadata feat: Automated removal of obsolete clients (#1742) 2020-12-11 11:54:03 +00:00
synth.py chore: Add synth scripts for client generation (#912) 2020-10-15 12:21:50 -07:00

README.md

Simple REST Clients for Google APIs

This repository contains a set of simple client libraries for various Google APIs. These libraries are generated automatically from Discovery Documents, and the code generator is also hosted here in this repository.

Each client provides:

  • A client object that connects to the HTTP/JSON REST endpoint for the service.
  • Ruby objects for data structures related to the service.
  • Integration with the googleauth gem for authentication using OAuth, API keys, and service accounts.
  • Control of retry, pagination, and timeouts.

These client libraries are officially supported by Google, and are updated regularly to track changes to the service. However, many Google services, especially Google Cloud Platform services such as Cloud Storage, Pub/Sub, and BigQuery, may provide a more modern client that is easier to use and more performant. See the section below titled "Which client should I use?" for more information.

Using the clients

The client gems are named according to the pattern google-apis-<servicename>_<serviceversion>. For example, the client for the Google Drive V3 API is google-apis-drive_v3.

Install the client using gem install or by adding it to your Gemfile. Then, to use it, require the file and instantiate the service. For example to use the Drive API:

require 'google/apis/drive_v3'

drive = Google::Apis::DriveV3::DriveService.new
drive.authorization = ... # See Googleauth or Signet libraries

# Search for files in Drive (first page only)
files = drive.list_files(q: "title contains 'finances'")
files.items.each do |file|
  puts file.title
end

# Upload a file
metadata = Google::Apis::DriveV3::File.new(title: 'My document')
metadata = drive.insert_file(metadata, upload_source: 'test.txt', content_type: 'text/plain')

# Download a file
drive.get_file(metadata.id, download_dest: '/tmp/myfile.txt')

Following is another example using the Content API (Google Merchant Center), provided by the google-apis-content_v2 gem:

require 'google/apis/content_v2'
require 'googleauth' # https://github.com/googleapis/google-auth-library-ruby

content = Google::Apis::ContentV2::ShoppingContentService.new

scope = 'https://www.googleapis.com/auth/content'
merchant_id = # Merchant ID found on dashboard

content.authorization = Google::Auth::ServiceAccountCredentials.make_creds(
  json_key_io: File.open('./content-api-key.json'),
  scope: scope)

content.authorization.fetch_access_token!
# Service methods: https://googleapis.dev/ruby/google-api-client/latest/Google/Apis/ContentV2/ShoppingContentService.html
content.list_datafeeds(merchant_id) # Returns Google::Apis::ContentV2::ListDatafeedsResponse

For more detailed information, see the Usage Guide.

Which client should I use?

Google provides two types of Ruby API client libraries: simple REST clients and modern clients.

The libraries in this repo are simple REST clients. These clients connect to HTTP/JSON REST endpoints and are automatically generated from service discovery documents. They support most API functionality, but their class interfaces are sometimes awkward.

Modern clients are produced by a modern code generator, combined with hand-crafted functionality for some services. Most modern clients connect to high-performance gRPC endpoints, although a few are backed by REST services. Modern clients are available for many Google services, especially Cloud Platform services, but do not yet support all the services covered by the simple clients. Most modern clients live in the https://github.com/googleapis/google-cloud-ruby repository.

For most users, we recommend the modern client, if one is available. Compared with simple clients, modern clients are generally much easier to use and more Ruby-like, support more advanced features such as streaming and long-running operations, and often provide much better performance. You may consider using a simple client instead, if a modern client is not yet available for the service you want to use, or if you are not able to use gRPC on your infrastructure.

The documentation for the particular Google service you are working with, may provide guidance regarding the preferred client library to use.

Samples

See the samples for examples on how to use the client library for various services.

Supported Ruby versions

This library is supported on Ruby 2.5+.

Google provides official support for Ruby versions that are actively supported by Ruby Core -- that is, Ruby versions that are either in normal maintenance or in security maintenance, and not end of life. Currently, this means Ruby 2.5 and later. Older versions of Ruby may still work, but are unsupported and not recommended. See https://www.ruby-lang.org/en/downloads/branches/ for details about the Ruby support schedule.

License

This library is licensed under Apache 2.0. Full license text is available in the LICENSE.

Contributing

See CONTRIBUTING.

Support

Please report bugs at the project on Github. Don't hesitate to ask questions about the client or APIs on StackOverflow.