### Setup Development Environment with Git Source: https://github.com/googleapis/google-cloud-python/blob/main/packages/db-dtypes/CONTRIBUTING.rst Commands to clone the repository, configure the upstream remote, and synchronize the local main branch with the official googleapis repository. ```bash cd ${HOME} git clone git@github.com:USERNAME/google-cloud-python.git hack-on-google-cloud-python cd hack-on-google-cloud-python git remote add upstream git@github.com:googleapis/google-cloud-python.git git fetch upstream git merge upstream/main ``` -------------------------------- ### Install Migration Tools Source: https://github.com/googleapis/google-cloud-python/blob/main/packages/google-cloud-logging/UPGRADING.md Commands to install the library and the libcst dependency required for the automated migration script. ```bash python3 -m pip install google-cloud-logging libcst fixup_logging_v2_keywords.py --input-directory .samples/ --output-directory samples/ ``` -------------------------------- ### Install Google Cloud BigQuery Library Source: https://github.com/googleapis/google-cloud-python/blob/main/packages/google-cloud-bigquery/UPGRADING.md Demonstrates the updated installation command for the BigQuery library, removing the now-deprecated bqstorage and bignumeric_type extras. ```bash pip install google-cloud-bigquery ``` -------------------------------- ### Install System Dependencies Source: https://github.com/googleapis/google-cloud-python/blob/main/packages/db-dtypes/CONTRIBUTING.rst System-level commands to resolve missing headers during development, specifically for Debian/Ubuntu environments. ```bash sudo apt-get install python-dev ``` -------------------------------- ### Get Default Credentials with Python Source: https://github.com/googleapis/google-cloud-python/blob/main/packages/google-api-core/docs/auth.rst Retrieves Application Default Credentials and the project ID using the `google.auth.default()` function. This method follows a predefined precedence order for finding credentials, starting with user-provided credentials. ```python import google.auth credentials, project = google.auth.default() ``` -------------------------------- ### Install Binary Authorization Client Library Source: https://github.com/googleapis/google-cloud-python/blob/main/packages/google-cloud-binary-authorization/README.rst Commands to create a virtual environment and install the google-cloud-binary-authorization package on different operating systems. ```bash python3 -m venv source /bin/activate pip install google-cloud-binary-authorization ``` ```powershell py -m venv .\\Scripts\activate pip install google-cloud-binary-authorization ``` -------------------------------- ### Install Shopping Type Protos library via virtual environment Source: https://github.com/googleapis/google-cloud-python/blob/main/packages/google-shopping-type/docs/README.rst Commands to create a virtual environment and install the google-shopping-type package. Separate commands are provided for Unix-based systems and Windows. ```bash python3 -m venv source /bin/activate pip install google-shopping-type ``` ```batch py -m venv .\\Scripts\activate pip install google-shopping-type ``` -------------------------------- ### Install google-cloud-bigquery without 'bqstorage' extra Source: https://github.com/googleapis/google-cloud-python/blob/main/packages/google-cloud-bigquery/docs/UPGRADING.md This snippet shows the recommended way to install the google-cloud-bigquery library after the 'bqstorage' extra became a no-op. It simplifies installation by omitting unnecessary extras. ```bash $ pip install google-cloud-bigquery[bqstorage] ``` ```bash $ pip install google-cloud-bigquery ``` -------------------------------- ### Install google-cloud-logging and libcst Source: https://github.com/googleapis/google-cloud-python/blob/main/packages/google-cloud-logging/docs/UPGRADING.md Installs the necessary libraries for migrating the google-cloud-logging client. libcst is required for the provided fixup script. ```shell python3 -m pip install google-cloud-logging libcst ``` -------------------------------- ### Install Network Management Client Library Source: https://github.com/googleapis/google-cloud-python/blob/main/packages/google-cloud-network-management/README.rst Commands to create a virtual environment and install the google-cloud-network-management package. Provides separate instructions for Unix-based systems and Windows. ```bash python3 -m venv source /bin/activate pip install google-cloud-network-management ``` ```batch py -m venv .\\Scripts\activate pip install google-cloud-network-management ``` -------------------------------- ### Install Cloud Billing Budget Library Source: https://github.com/googleapis/google-cloud-python/blob/main/packages/google-cloud-billing-budgets/docs/README.rst Commands to create a virtual environment and install the Google Cloud Billing Budget client library. Supports both Unix-based systems and Windows environments. ```bash python3 -m venv source /bin/activate pip install google-cloud-billing-budgets ``` ```powershell py -m venv .\\Scripts\activate pip install google-cloud-billing-budgets ``` -------------------------------- ### Install google-cloud-bigquery without 'bignumeric_type' extra Source: https://github.com/googleapis/google-cloud-python/blob/main/packages/google-cloud-bigquery/docs/UPGRADING.md This snippet demonstrates the removal of the 'bignumeric_type' extra. The BIGNUMERIC type is now automatically supported, so this extra should no longer be used during installation. ```bash $ pip install google-cloud-bigquery[bignumeric_type] ``` ```bash $ pip install google-cloud-bigquery ``` -------------------------------- ### Install Data QnA on Windows Source: https://github.com/googleapis/google-cloud-python/blob/main/packages/google-cloud-data-qna/docs/README.rst Installs the google-cloud-data-qna library using pip within a virtual environment on Windows systems. ```console py -m venv .\\Scripts\activate pip install google-cloud-data-qna ``` -------------------------------- ### Install Cloud AutoML Client Library Source: https://github.com/googleapis/google-cloud-python/blob/main/packages/google-cloud-automl/docs/README.rst Commands to create a virtual environment and install the google-cloud-automl package on different operating systems. ```bash python3 -m venv source /bin/activate pip install google-cloud-automl ``` ```batch py -m venv .\\Scripts\activate pip install google-cloud-automl ``` -------------------------------- ### Install Google Cloud Pub/Sub Library Source: https://github.com/googleapis/google-cloud-python/blob/main/packages/google-cloud-pubsub/docs/README.rst Commands to create a virtual environment and install the google-cloud-pubsub package on different operating systems. ```bash python3 -m venv source /bin/activate pip install google-cloud-pubsub ``` ```batch py -m venv .\\Scripts\activate pip install google-cloud-pubsub ``` -------------------------------- ### Install IAM Logging Protos library in a virtual environment Source: https://github.com/googleapis/google-cloud-python/blob/main/packages/google-cloud-iam-logging/docs/README.rst Commands to create a virtual environment and install the google-cloud-iam-logging package. Provides separate instructions for Unix-based systems and Windows. ```bash python3 -m venv source /bin/activate pip install google-cloud-iam-logging ``` ```batch py -m venv .\\Scripts\activate pip install google-cloud-iam-logging ``` -------------------------------- ### Construct resource path strings manually Source: https://github.com/googleapis/google-cloud-python/blob/main/packages/google-cloud-logging/docs/UPGRADING.md Provides examples of manually constructing resource path strings, as the helper methods for resource paths have been removed from the google-cloud-logging library. ```python billing_account = "my-billing-account" folder = "my-folder" organization = "my-organization" log = "my-log" exclusion = "exclusion" sink = "my-sink" # LoggingServiceV2Client billing_log_path = f"billingAccounts/{billing_account}/logs/{log}" folder_log_path = f"folders/{folder}/logs/{log}" organization_log_path = f"organizations/{organization}/logs/{log}" ``` -------------------------------- ### Authenticated Requests with Requests Transport Source: https://github.com/googleapis/google-cloud-python/blob/main/packages/google-auth/docs/user-guide.rst Demonstrates how to make authenticated HTTP GET requests using the google-auth library with the Requests transport. It initializes an AuthorizedSession with credentials and then uses it to fetch data from a Google Cloud Storage bucket. ```python from google.auth.transport.requests import AuthorizedSession authed_session = AuthorizedSession(credentials) response = authed_session.get( 'https://www.googleapis.com/storage/v1/b') ``` -------------------------------- ### Install Data QnA on Mac/Linux Source: https://github.com/googleapis/google-cloud-python/blob/main/packages/google-cloud-data-qna/docs/README.rst Installs the google-cloud-data-qna library using pip within a virtual environment on macOS or Linux systems. ```console python3 -m venv source /bin/activate pip install google-cloud-data-qna ``` -------------------------------- ### Install Merchant API Client Library Source: https://github.com/googleapis/google-cloud-python/blob/main/packages/google-shopping-merchant-products/README.rst Commands to create a virtual environment and install the google-shopping-merchant-products package on different operating systems. ```bash python3 -m venv source /bin/activate pip install google-shopping-merchant-products ``` ```powershell py -m venv .\\Scripts\activate pip install google-shopping-merchant-products ```