Google Cloud Ruby Client Libraries

repository·main·Indexed 23 days ago

https://github.com/googleapis/google-cloud-ruby

Idiomatic Ruby client libraries for Google Cloud Platform services and selected Google APIs. This repository provides high-level interfaces for interacting with Google's cloud infrastructure, including specific clients for Google Ad Manager, Data Manager, Google Marketing Platform Admin, and Google Analytics Admin.

Tokens
462.7K
Snippets
1.6K
Records
2.4K
Agent score
77%

What's inside google-cloud-ruby

  1. Merchant API Sub-APIs Overview

    main

    The Merchant API is composed of several Sub-APIs that allow for different management tasks:

    • Accounts Sub-API: Manage Merchant Center Accounts.
    • Conversions Sub-API: Manage conversion sources.
    • Datasources Sub-API: Manage datasources.
    • Inventories Sub-API: Manage local and regional inventories.
    • Local Feeds Partnerships Sub-API: Submit local inventories (for LFP partners).
    • Notifications Sub-API: Manage notification subscriptions.
    • Products Sub-API: Manage products.
    • Promotions Sub-API: Manage product promotions.
    • Quota Sub-API: List quotas for all APIs used.
    • Reports Sub-API: Retrieve reports and insights about products and performance.
  2. What is Optimistic Concurrency Control (OCC) for IAM?

    main

    Optimistic Concurrency Control (OCC) is a strategy used to prevent "lost updates" or race conditions when multiple processes attempt to modify the same IAM policy simultaneously.

    In Google Cloud IAM, every policy object contains an etag (entity tag). The OCC mechanism works as follows:

    1. Read: When you fetch a policy, the server returns an etag.
    2. Write: When you send a modified policy back to the server, you must include that original etag.
    3. Validation: The server compares the provided etag with the current stored etag. If they do not match (meaning someone else modified the policy in the meantime), the write fails.

    When a write fails due to an etag mismatch, the client must catch the error and retry the entire cycle: re-read the new policy, re-apply changes, and attempt to write again.

  3. Which Cloud Build client should I use?

    main

    Google Cloud Ruby clients generally come in three flavors. Choosing the right one depends on your requirements:

    Example: google-cloud-build (no version number in name).

    • Why use it: It provides the recommended interfaces, factory methods, and higher-level abstractions. It embodies best practices and is the focus of official documentation and samples.

    2. The Versioned Client

    Example: google-cloud-build-v1.

    • Why use it: Use this if you need to access a specific service version not covered by the main client, or if you require a lower-level, code-generated interface.

    3. The google-apis-<name> Clients

    • Why use it: These are older clients based on REST/JSON. They are generally less performant and feature-rich than the modern gRPC-based clients. Only use these if a modern client is not yet available for the service you need.
  4. Which Cloud Location Finder client should I use?

    main

    Google provides different types of client libraries. For most users, the main client is the correct choice.

    Main Client (google-cloud-location_finder)

    • Recommended for most users.
    • Provides high-level factory methods for constructing recommended client objects.
    • Embodies best practices and may include handwritten convenience methods or tighter framework integration.
    • Documentation and samples from Google typically use this client.

    Versioned Client (google-cloud-location_finder-v1)

    • Provides a basic set of data types and client classes for a single specific version of the API.
    • Usually generated from code.
    • Use this if you need to access a specific service version not covered by the main client or if you want a lower-level interface.

    Legacy Clients (google-apis-<name>)

    • Based on older code generation technology.
    • Communicate via REST/JSON instead of the modern gRPC backend used by current clients.
    • Generally offer lower performance and fewer features. Only use these if a modern client is not available for the service you need.
  5. Understand the google-cloud-automl 1.0 library structure

    main

    In 1.0, the library is split into multiple gems. The google-cloud-automl gem acts as a convenience wrapper providing factory methods, but the actual client classes reside in version-specific gems:

    • google-cloud-automl-v1: Contains Google::Cloud::AutoML::V1::AutoML::Client and related types.
    • google-cloud-automl-v1beta1: Contains Google::Cloud::AutoML::V1beta1::AutoML::Client and related types.

    Usage Options:

    1. Convenience: Install google-cloud-automl. It will automatically pull in the necessary versioned gems as dependencies.
    2. Minimalist: If you only need a specific version (e.g., V1), install only google-cloud-automl-v1 and instantiate the client class directly.
  6. Understand credential precedence in google-ads-marketing_platform-admin

    main

    The library searches for credentials in a specific order. If multiple methods are used, the one with the highest precedence wins. The order is:

    1. Credentials specified directly in method arguments
    2. Credentials specified in configuration (client-specific or global)
    3. Credentials provided via environment variables
    4. Credentials found in the local Application Default Credentials (ADC) file
    5. Credentials retrieved from the Google Cloud Platform (GCP) metadata server (for attached service accounts)
  7. Which Network Services client should I use?

    main

    Google Cloud Ruby libraries typically offer two types of gems. For most use cases, you should install the main client.

    Main Client (google-cloud-network_services)

    • Recommended for most users.
    • Provides high-level methods and factory methods for constructing recommended client objects.
    • Embodies best practices and may include handwritten convenience methods or tighter framework integrations.
    • Defaults to a recommended service version.

    Versioned Client (google-cloud-network_services-v1)

    • Provides a basic, lower-level set of data types and client classes for a single version of the service.
    • Use this if you need to access a specific service version not covered by the main client, or if you want to avoid the abstractions provided by the main client.

    google-apis-<name> Clients

    • These are based on older code generation technology and use a REST/JSON backend.
    • Most modern clients (like the ones above) use a gRPC backend, which generally offers better performance and features.
    • Only use these if a modern client is not available for the service you need.
  8. Choosing between the main client and a versioned client

    main

    Google Cloud Ruby libraries typically offer two types of clients. Choosing the right one depends on your requirements for abstraction and specific API versions.

    Example: google-cloud-trace (no version in name)

    • Purpose: Provides the recommended interfaces for the service.
    • Features: Includes factory methods, higher-level handwritten objects, convenience methods, and best practices. It defaults to a recommended service version.
    • When to use: In almost all cases. It is the standard for Google's documentation and samples.

    Versioned Client

    Example: google-cloud-trace-v2 (version in name)

    • Purpose: Provides basic client classes and data types for a single specific version of the API.
    • Features: Often generated by code generators, providing a lower-level interface.
    • When to use: If you need to access a specific service version not covered by the main client, or if you explicitly want to avoid the abstractions provided by the main client.

    Note on google-apis-<name> clients

    These are older clients based on REST/JSON backends. Modern clients (like the ones described above) use gRPC and generally offer better performance and features. Use google-apis- clients only if a modern client is unavailable for the service you need.

  9. Understand credential precedence in google-cloud-gdc_hardware_management

    main

    The library searches for credentials in a specific order of precedence. If multiple methods are used, the first one found in this list is applied:

    1. Credentials specified in method arguments
    2. Credentials specified in configuration
    3. Credentials pointed to or included in environment variables
    4. Credentials found in local ADC file
    5. Credentials returned by the metadata server for the attached service account (GCP)